@storybook/core-webpack 10.1.0-alpha.10 → 10.1.0-alpha.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +27 -57
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -1,33 +1,29 @@
1
- import CJS_COMPAT_NODE_URL_g52n6qwjudo from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_g52n6qwjudo from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_g52n6qwjudo from "node:module";
1
+ import CJS_COMPAT_NODE_URL_uqg1m7wm52j from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_uqg1m7wm52j from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_uqg1m7wm52j from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_g52n6qwjudo.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_g52n6qwjudo.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_g52n6qwjudo.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_uqg1m7wm52j.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_uqg1m7wm52j.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_uqg1m7wm52j.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
11
  // ------------------------------------------------------------
12
- var __defProp = Object.defineProperty;
13
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
14
12
 
15
13
  // src/load-custom-webpack-config.ts
16
14
  import { resolve } from "node:path";
17
15
  import { serverRequire } from "storybook/internal/common";
18
- var webpackConfigs = ["webpack.config", "webpackfile"];
19
- var loadCustomWebpackConfig = /* @__PURE__ */ __name(async (configDir) => serverRequire(webpackConfigs.map((configName) => resolve(configDir, configName))), "loadCustomWebpackConfig");
16
+ var webpackConfigs = ["webpack.config", "webpackfile"], loadCustomWebpackConfig = async (configDir) => serverRequire(webpackConfigs.map((configName) => resolve(configDir, configName)));
20
17
 
21
18
  // src/check-webpack-version.ts
22
19
  import { logger } from "storybook/internal/node-logger";
23
20
  import { dedent } from "ts-dedent";
24
- var checkWebpackVersion = /* @__PURE__ */ __name((webpack, specifier, caption) => {
21
+ var checkWebpackVersion = (webpack, specifier, caption) => {
25
22
  if (!webpack.version) {
26
23
  logger.info("Skipping webpack version check, no version available");
27
24
  return;
28
25
  }
29
- if (webpack.version !== specifier) {
30
- logger.warn(dedent`
26
+ webpack.version !== specifier && logger.warn(dedent`
31
27
  Unexpected webpack version in ${caption}:
32
28
  - Received '${webpack.version}'
33
29
  - Expected '${specifier}'
@@ -36,29 +32,24 @@ var checkWebpackVersion = /* @__PURE__ */ __name((webpack, specifier, caption) =
36
32
 
37
33
  For more info about Webpack 5 support: https://gist.github.com/shilman/8856ea1786dcd247139b47b270912324#troubleshooting
38
34
  `);
39
- }
40
- }, "checkWebpackVersion");
35
+ };
41
36
 
42
37
  // src/merge-webpack-config.ts
43
38
  function mergePluginsField(defaultPlugins = [], customPlugins = []) {
44
39
  return [...defaultPlugins, ...customPlugins];
45
40
  }
46
- __name(mergePluginsField, "mergePluginsField");
47
41
  function mergeRulesField(defaultRules = [], customRules = []) {
48
42
  return [...defaultRules, ...customRules];
49
43
  }
50
- __name(mergeRulesField, "mergeRulesField");
51
44
  function mergeExtensionsField({ extensions: defaultExtensions = [] }, { extensions: customExtensions = [] }) {
52
45
  return [...defaultExtensions, ...customExtensions];
53
46
  }
54
- __name(mergeExtensionsField, "mergeExtensionsField");
55
47
  function mergeAliasField({ alias: defaultAlias = {} }, { alias: customAlias = {} }) {
56
48
  return {
57
49
  ...defaultAlias,
58
50
  ...customAlias
59
51
  };
60
52
  }
61
- __name(mergeAliasField, "mergeAliasField");
62
53
  function mergeModuleField(a, b) {
63
54
  return {
64
55
  ...a,
@@ -66,7 +57,6 @@ function mergeModuleField(a, b) {
66
57
  rules: mergeRulesField(a.rules || [], b.rules || [])
67
58
  };
68
59
  }
69
- __name(mergeModuleField, "mergeModuleField");
70
60
  function mergeResolveField({ resolve: defaultResolve = {} }, { resolve: customResolve = {} }) {
71
61
  return {
72
62
  ...defaultResolve,
@@ -75,14 +65,12 @@ function mergeResolveField({ resolve: defaultResolve = {} }, { resolve: customRe
75
65
  extensions: mergeExtensionsField(defaultResolve, customResolve)
76
66
  };
77
67
  }
78
- __name(mergeResolveField, "mergeResolveField");
79
68
  function mergeOptimizationField({ optimization: defaultOptimization = {} }, { optimization: customOptimization = {} }) {
80
69
  return {
81
70
  ...defaultOptimization,
82
71
  ...customOptimization
83
72
  };
84
73
  }
85
- __name(mergeOptimizationField, "mergeOptimizationField");
86
74
  function mergeConfigs(config, customConfig) {
87
75
  return {
88
76
  // We'll always load our configurations after the custom config.
@@ -96,7 +84,6 @@ function mergeConfigs(config, customConfig) {
96
84
  optimization: mergeOptimizationField(config, customConfig)
97
85
  };
98
86
  }
99
- __name(mergeConfigs, "mergeConfigs");
100
87
 
101
88
  // src/to-importFn.ts
102
89
  import { globToRegexp } from "storybook/internal/common";
@@ -107,34 +94,24 @@ function importPipeline() {
107
94
  let importGate = Promise.resolve();
108
95
  return async (importFn) => {
109
96
  await importGate;
110
- const moduleExportsPromise = importFn();
111
- importGate = importGate.then(async () => {
97
+ let moduleExportsPromise = importFn();
98
+ return importGate = importGate.then(async () => {
112
99
  await moduleExportsPromise;
113
- });
114
- return moduleExportsPromise;
100
+ }), moduleExportsPromise;
115
101
  };
116
102
  }
117
- __name(importPipeline, "importPipeline");
118
103
 
119
104
  // src/to-importFn.ts
120
105
  function adjustRegexToExcludeNodeModules(originalRegex) {
121
- const originalRegexString = originalRegex.source;
122
- const startsWithCaret = originalRegexString.startsWith("^");
123
- const excludeNodeModulesPattern = startsWithCaret ? "(?!.*node_modules)" : "^(?!.*node_modules)";
124
- const adjustedRegexString = startsWithCaret ? `^${excludeNodeModulesPattern}${originalRegexString.substring(1)}` : excludeNodeModulesPattern + originalRegexString;
106
+ let originalRegexString = originalRegex.source, startsWithCaret = originalRegexString.startsWith("^"), excludeNodeModulesPattern = startsWithCaret ? "(?!.*node_modules)" : "^(?!.*node_modules)", adjustedRegexString = startsWithCaret ? `^${excludeNodeModulesPattern}${originalRegexString.substring(1)}` : excludeNodeModulesPattern + originalRegexString;
125
107
  return new RegExp(adjustedRegexString);
126
108
  }
127
- __name(adjustRegexToExcludeNodeModules, "adjustRegexToExcludeNodeModules");
128
109
  function webpackIncludeRegexp(specifier) {
129
- const { directory, files } = specifier;
130
- const directoryWithoutLeadingDots = directory.replace(/^(\.+\/)+/, "/");
131
- const webpackIncludeGlob = [".", ".."].includes(directory) ? files : `${directoryWithoutLeadingDots}/${files}`;
132
- const webpackIncludeRegexpWithCaret = webpackIncludeGlob.includes("node_modules") ? globToRegexp(webpackIncludeGlob) : adjustRegexToExcludeNodeModules(globToRegexp(webpackIncludeGlob));
110
+ let { directory, files } = specifier, directoryWithoutLeadingDots = directory.replace(/^(\.+\/)+/, "/"), webpackIncludeGlob = [".", ".."].includes(directory) ? files : `${directoryWithoutLeadingDots}/${files}`, webpackIncludeRegexpWithCaret = webpackIncludeGlob.includes("node_modules") ? globToRegexp(webpackIncludeGlob) : adjustRegexToExcludeNodeModules(globToRegexp(webpackIncludeGlob));
133
111
  return new RegExp(webpackIncludeRegexpWithCaret.source.replace(/^\^/, ""));
134
112
  }
135
- __name(webpackIncludeRegexp, "webpackIncludeRegexp");
136
113
  function toImportFnPart(specifier) {
137
- const { directory, importPathMatcher } = specifier;
114
+ let { directory, importPathMatcher } = specifier;
138
115
  return dedent2`
139
116
  async (path) => {
140
117
  if (!${importPathMatcher}.exec(path)) {
@@ -151,20 +128,17 @@ function toImportFnPart(specifier) {
151
128
 
152
129
  `;
153
130
  }
154
- __name(toImportFnPart, "toImportFnPart");
155
131
  function toImportFn(stories, { needPipelinedImport } = {}) {
156
- let pipelinedImport = `const pipeline = (x) => x();`;
157
- if (needPipelinedImport) {
158
- pipelinedImport = `
132
+ let pipelinedImport = "const pipeline = (x) => x();";
133
+ return needPipelinedImport && (pipelinedImport = `
159
134
  const importPipeline = ${importPipeline};
160
135
  const pipeline = importPipeline();
161
- `;
162
- }
163
- return dedent2`
136
+ `), dedent2`
164
137
  ${pipelinedImport}
165
138
 
166
139
  const importers = [
167
- ${stories.map(toImportFnPart).join(",\n")}
140
+ ${stories.map(toImportFnPart).join(`,
141
+ `)}
168
142
  ];
169
143
 
170
144
  export async function importFn(path) {
@@ -177,24 +151,20 @@ function toImportFn(stories, { needPipelinedImport } = {}) {
177
151
  }
178
152
  `;
179
153
  }
180
- __name(toImportFn, "toImportFn");
181
154
 
182
155
  // src/to-require-context.ts
183
156
  import { globToRegexp as globToRegexp2 } from "storybook/internal/common";
184
- var toRequireContext = /* @__PURE__ */ __name((specifier) => {
185
- const { directory, files } = specifier;
186
- const match = globToRegexp2(`./${files}`);
157
+ var toRequireContext = (specifier) => {
158
+ let { directory, files } = specifier, match = globToRegexp2(`./${files}`);
187
159
  return {
188
160
  path: directory,
189
161
  recursive: files.includes("**") || files.split("/").length > 1,
190
162
  match
191
163
  };
192
- }, "toRequireContext");
193
- var toRequireContextString = /* @__PURE__ */ __name((specifier) => {
194
- const { path: p, recursive: r, match: m } = toRequireContext(specifier);
195
- const result = `require.context('${p}', ${r}, ${m})`;
196
- return result;
197
- }, "toRequireContextString");
164
+ }, toRequireContextString = (specifier) => {
165
+ let { path: p, recursive: r, match: m } = toRequireContext(specifier);
166
+ return `require.context('${p}', ${r}, ${m})`;
167
+ };
198
168
  export {
199
169
  checkWebpackVersion,
200
170
  loadCustomWebpackConfig,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/core-webpack",
3
- "version": "10.1.0-alpha.10",
3
+ "version": "10.1.0-alpha.11",
4
4
  "description": "Storybook framework-agnostic API",
5
5
  "keywords": [
6
6
  "storybook"
@@ -48,10 +48,10 @@
48
48
  "webpack": "5"
49
49
  },
50
50
  "peerDependencies": {
51
- "storybook": "^10.1.0-alpha.10"
51
+ "storybook": "^10.1.0-alpha.11"
52
52
  },
53
53
  "publishConfig": {
54
54
  "access": "public"
55
55
  },
56
- "gitHead": "a8e7fd8a655c69780bc20b9749d2699e45beae17"
56
+ "gitHead": "a8e7fd8a655c69780bc20b9749d2699e45beae1l"
57
57
  }