@storybook/builder-webpack5 10.1.0-alpha.1 → 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.
- package/dist/_node-chunks/{chunk-TMJDR5EF.js → chunk-A3CZ3LUF.js} +14 -19
- package/dist/_node-chunks/chunk-EGL5WHAF.js +60 -0
- package/dist/index.js +610 -912
- package/dist/loaders/export-order-loader.js +15 -22
- package/dist/presets/custom-webpack-preset.js +51 -73
- package/dist/presets/preview-preset.js +51 -71
- package/package.json +4 -4
- package/dist/_node-chunks/chunk-7N6JQ3AR.js +0 -85
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_m38t2lu80n from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_m38t2lu80n from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_m38t2lu80n from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_m38t2lu80n.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_m38t2lu80n.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_m38t2lu80n.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
11
|
// ------------------------------------------------------------
|
|
12
|
-
import
|
|
13
|
-
__name
|
|
14
|
-
} from "../_node-chunks/chunk-TMJDR5EF.js";
|
|
12
|
+
import "../_node-chunks/chunk-A3CZ3LUF.js";
|
|
15
13
|
|
|
16
14
|
// src/loaders/export-order-loader.ts
|
|
17
15
|
import assert from "node:assert";
|
|
@@ -19,40 +17,35 @@ import { init as initCjsParser, parse as parseCjs } from "cjs-module-lexer";
|
|
|
19
17
|
import { parse as parseEs } from "es-module-lexer";
|
|
20
18
|
import MagicString from "magic-string";
|
|
21
19
|
async function loader(source, map, meta) {
|
|
22
|
-
|
|
20
|
+
let callback = this.async();
|
|
23
21
|
try {
|
|
24
|
-
|
|
25
|
-
if (!source.includes("__namedExportsOrder"))
|
|
22
|
+
let magicString = new MagicString(source);
|
|
23
|
+
if (!source.includes("__namedExportsOrder"))
|
|
26
24
|
try {
|
|
27
|
-
|
|
28
|
-
const namedExportsOrder = (parseResult[1] || []).map((e) => source.substring(e.s, e.e)).filter((e) => e !== "default");
|
|
25
|
+
let namedExportsOrder = ((await parseEs(source))[1] || []).map((e) => source.substring(e.s, e.e)).filter((e) => e !== "default");
|
|
29
26
|
assert(
|
|
30
27
|
namedExportsOrder.length > 0,
|
|
31
28
|
"No named exports found. Very likely that this is not a ES module."
|
|
32
|
-
)
|
|
33
|
-
magicString.append(
|
|
29
|
+
), magicString.append(
|
|
34
30
|
`;export const __namedExportsOrder = ${JSON.stringify(namedExportsOrder)};`
|
|
35
31
|
);
|
|
36
32
|
} catch {
|
|
37
33
|
await initCjsParser();
|
|
38
|
-
|
|
34
|
+
let namedExportsOrder = (parseCjs(source).exports || []).filter(
|
|
39
35
|
(e) => e !== "default" && e !== "__esModule"
|
|
40
36
|
);
|
|
41
37
|
assert(
|
|
42
38
|
namedExportsOrder.length > 0,
|
|
43
39
|
"No named exports found. Very likely that this is not a CJS module."
|
|
44
|
-
)
|
|
45
|
-
magicString.append(
|
|
40
|
+
), magicString.append(
|
|
46
41
|
`;module.exports.__namedExportsOrder = ${JSON.stringify(namedExportsOrder)};`
|
|
47
42
|
);
|
|
48
43
|
}
|
|
49
|
-
}
|
|
50
44
|
return callback(null, magicString.toString(), map, meta);
|
|
51
|
-
} catch
|
|
45
|
+
} catch {
|
|
52
46
|
return callback(null, source, map, meta);
|
|
53
47
|
}
|
|
54
48
|
}
|
|
55
|
-
__name(loader, "loader");
|
|
56
49
|
export {
|
|
57
50
|
loader as default
|
|
58
51
|
};
|
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_m38t2lu80n from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_m38t2lu80n from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_m38t2lu80n from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_m38t2lu80n.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_m38t2lu80n.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_m38t2lu80n.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
11
|
// ------------------------------------------------------------
|
|
12
|
-
import
|
|
13
|
-
__name
|
|
14
|
-
} from "../_node-chunks/chunk-TMJDR5EF.js";
|
|
12
|
+
import "../_node-chunks/chunk-A3CZ3LUF.js";
|
|
15
13
|
|
|
16
14
|
// src/presets/custom-webpack-preset.ts
|
|
17
15
|
import { logger as logger2 } from "storybook/internal/node-logger";
|
|
@@ -24,36 +22,31 @@ import { logger } from "storybook/internal/node-logger";
|
|
|
24
22
|
async function createDefaultWebpackConfig(storybookBaseConfig, options) {
|
|
25
23
|
if (options.presetsList?.some(
|
|
26
24
|
(preset) => /@storybook(\/|\\)preset-create-react-app/.test(
|
|
27
|
-
typeof preset
|
|
25
|
+
typeof preset == "string" ? preset : preset.name
|
|
28
26
|
)
|
|
29
|
-
))
|
|
27
|
+
))
|
|
30
28
|
return storybookBaseConfig;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
)
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
{
|
|
48
|
-
loader: fileURLToPath(import.meta.resolve("css-loader")),
|
|
49
|
-
options: {
|
|
50
|
-
importLoaders: 1
|
|
51
|
-
}
|
|
29
|
+
let hasPostcssAddon = options.presetsList?.some(
|
|
30
|
+
(preset) => /@storybook(\/|\\)addon-postcss/.test(typeof preset == "string" ? preset : preset.name)
|
|
31
|
+
), cssLoaders = {};
|
|
32
|
+
hasPostcssAddon || (logger.info("=> Using implicit CSS loaders"), cssLoaders = {
|
|
33
|
+
test: /\.css$/,
|
|
34
|
+
sideEffects: !0,
|
|
35
|
+
use: [
|
|
36
|
+
// TODO: Decide if we want to keep style-loader & css-loader in core
|
|
37
|
+
// Trying to apply style-loader or css-loader to files that already have been
|
|
38
|
+
// processed by them causes webpack to crash, so no one else can add similar
|
|
39
|
+
// loader configurations to the `.css` extension.
|
|
40
|
+
fileURLToPath(import.meta.resolve("style-loader")),
|
|
41
|
+
{
|
|
42
|
+
loader: fileURLToPath(import.meta.resolve("css-loader")),
|
|
43
|
+
options: {
|
|
44
|
+
importLoaders: 1
|
|
52
45
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
});
|
|
49
|
+
let isProd = storybookBaseConfig.mode !== "development";
|
|
57
50
|
return {
|
|
58
51
|
...storybookBaseConfig,
|
|
59
52
|
module: {
|
|
@@ -100,52 +93,37 @@ async function createDefaultWebpackConfig(storybookBaseConfig, options) {
|
|
|
100
93
|
"..."
|
|
101
94
|
],
|
|
102
95
|
fallback: {
|
|
103
|
-
crypto:
|
|
104
|
-
assert:
|
|
96
|
+
crypto: !1,
|
|
97
|
+
assert: !1,
|
|
105
98
|
...storybookBaseConfig.resolve?.fallback
|
|
106
99
|
}
|
|
107
100
|
}
|
|
108
101
|
};
|
|
109
102
|
}
|
|
110
|
-
__name(createDefaultWebpackConfig, "createDefaultWebpackConfig");
|
|
111
103
|
|
|
112
104
|
// src/presets/custom-webpack-preset.ts
|
|
113
|
-
var swc =
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
env
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
bugfixes: config?.env?.bugfixes ?? true
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
}, "swc");
|
|
130
|
-
async function webpack(config, options) {
|
|
131
|
-
const { configDir, configType, presets } = options;
|
|
132
|
-
const coreOptions = await presets.apply("core");
|
|
133
|
-
let defaultConfig = config;
|
|
134
|
-
if (!coreOptions?.disableWebpackDefaults) {
|
|
135
|
-
defaultConfig = await createDefaultWebpackConfig(config, options);
|
|
136
|
-
}
|
|
137
|
-
const finalDefaultConfig = await presets.apply("webpackFinal", defaultConfig, options);
|
|
138
|
-
const customConfig = await loadCustomWebpackConfig(configDir);
|
|
139
|
-
if (typeof customConfig === "function") {
|
|
140
|
-
logger2.info("=> Loading custom Webpack config (full-control mode).");
|
|
141
|
-
return customConfig({ config: finalDefaultConfig, mode: configType });
|
|
105
|
+
var swc = (config) => ({
|
|
106
|
+
...config,
|
|
107
|
+
env: {
|
|
108
|
+
...config?.env ?? {},
|
|
109
|
+
targets: config?.env?.targets ?? {
|
|
110
|
+
chrome: 100,
|
|
111
|
+
safari: 15,
|
|
112
|
+
firefox: 91
|
|
113
|
+
},
|
|
114
|
+
// Transpiles the broken syntax to the closest non-broken modern syntax.
|
|
115
|
+
// E.g. it won't transpile parameter destructuring in Safari
|
|
116
|
+
// which would break how we detect if the mount context property is used in the play function.
|
|
117
|
+
bugfixes: config?.env?.bugfixes ?? !0
|
|
142
118
|
}
|
|
143
|
-
|
|
144
|
-
|
|
119
|
+
});
|
|
120
|
+
async function webpack(config, options) {
|
|
121
|
+
let { configDir, configType, presets } = options, coreOptions = await presets.apply("core"), defaultConfig = config;
|
|
122
|
+
coreOptions?.disableWebpackDefaults || (defaultConfig = await createDefaultWebpackConfig(config, options));
|
|
123
|
+
let finalDefaultConfig = await presets.apply("webpackFinal", defaultConfig, options), customConfig = await loadCustomWebpackConfig(configDir);
|
|
124
|
+
return typeof customConfig == "function" ? (logger2.info("=> Loading custom Webpack config (full-control mode)."), customConfig({ config: finalDefaultConfig, mode: configType })) : (logger2.info("=> Using default Webpack5 setup"), finalDefaultConfig);
|
|
145
125
|
}
|
|
146
|
-
|
|
147
|
-
var webpackInstance = /* @__PURE__ */ __name(async () => webpackModule, "webpackInstance");
|
|
148
|
-
var webpackVersion = /* @__PURE__ */ __name(async () => "5", "webpackVersion");
|
|
126
|
+
var webpackInstance = async () => webpackModule, webpackVersion = async () => "5";
|
|
149
127
|
export {
|
|
150
128
|
swc,
|
|
151
129
|
webpack,
|
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_m38t2lu80n from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_m38t2lu80n from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_m38t2lu80n from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_m38t2lu80n.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_m38t2lu80n.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_m38t2lu80n.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
11
|
// ------------------------------------------------------------
|
|
12
12
|
import {
|
|
13
13
|
getVirtualModules
|
|
14
|
-
} from "../_node-chunks/chunk-
|
|
15
|
-
import
|
|
16
|
-
__name
|
|
17
|
-
} from "../_node-chunks/chunk-TMJDR5EF.js";
|
|
14
|
+
} from "../_node-chunks/chunk-EGL5WHAF.js";
|
|
15
|
+
import "../_node-chunks/chunk-A3CZ3LUF.js";
|
|
18
16
|
|
|
19
17
|
// src/presets/preview-preset.ts
|
|
20
18
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
@@ -36,9 +34,8 @@ import TerserWebpackPlugin from "terser-webpack-plugin";
|
|
|
36
34
|
import { dedent } from "ts-dedent";
|
|
37
35
|
import webpackModule from "webpack";
|
|
38
36
|
import VirtualModulePlugin from "webpack-virtual-modules";
|
|
39
|
-
var { DefinePlugin, HotModuleReplacementPlugin, ProgressPlugin } = webpackModule
|
|
40
|
-
|
|
41
|
-
const {
|
|
37
|
+
var { DefinePlugin, HotModuleReplacementPlugin, ProgressPlugin } = webpackModule, iframe_webpack_config_default = async (options) => {
|
|
38
|
+
let {
|
|
42
39
|
outputDir = join(".", "public"),
|
|
43
40
|
quiet,
|
|
44
41
|
packageJson,
|
|
@@ -47,10 +44,7 @@ var iframe_webpack_config_default = /* @__PURE__ */ __name(async (options) => {
|
|
|
47
44
|
previewUrl,
|
|
48
45
|
typescriptOptions,
|
|
49
46
|
features
|
|
50
|
-
} = options
|
|
51
|
-
const isProd = configType === "PRODUCTION";
|
|
52
|
-
const workingDir = process.cwd();
|
|
53
|
-
const [
|
|
47
|
+
} = options, isProd = configType === "PRODUCTION", workingDir = process.cwd(), [
|
|
54
48
|
coreOptions,
|
|
55
49
|
frameworkOptions,
|
|
56
50
|
envs,
|
|
@@ -78,36 +72,27 @@ var iframe_webpack_config_default = /* @__PURE__ */ __name(async (options) => {
|
|
|
78
72
|
options.cache?.get("modulesCount", 1e3),
|
|
79
73
|
options.presets.apply("build"),
|
|
80
74
|
presets.apply("tags", {})
|
|
81
|
-
])
|
|
82
|
-
const stories = normalizeStories(nonNormalizedStories, {
|
|
75
|
+
]), stories = normalizeStories(nonNormalizedStories, {
|
|
83
76
|
configDir: options.configDir,
|
|
84
77
|
workingDir
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
const shouldCheckTs = typescriptOptions.check && !typescriptOptions.skipCompiler;
|
|
88
|
-
const tsCheckOptions = typescriptOptions.checkOptions || {};
|
|
89
|
-
const cacheConfig = builderOptions.fsCache ? { cache: { type: "filesystem" } } : {};
|
|
90
|
-
const lazyCompilationConfig = builderOptions.lazyCompilation && !isProd ? {
|
|
91
|
-
lazyCompilation: { entries: false }
|
|
78
|
+
}), builderOptions = await getBuilderOptions(options), shouldCheckTs = typescriptOptions.check && !typescriptOptions.skipCompiler, tsCheckOptions = typescriptOptions.checkOptions || {}, cacheConfig = builderOptions.fsCache ? { cache: { type: "filesystem" } } : {}, lazyCompilationConfig = builderOptions.lazyCompilation && !isProd ? {
|
|
79
|
+
lazyCompilation: { entries: !1 }
|
|
92
80
|
} : {};
|
|
93
|
-
if (!template)
|
|
81
|
+
if (!template)
|
|
94
82
|
throw new Error(dedent`
|
|
95
83
|
Storybook's Webpack5 builder requires a template to be specified.
|
|
96
84
|
Somehow you've ended up with a falsy value for the template option.
|
|
97
85
|
|
|
98
86
|
Please file an issue at https://github.com/storybookjs/storybook with a reproduction.
|
|
99
87
|
`);
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
externals["@storybook/addon-docs/blocks"] = "__STORYBOOK_BLOCKS_EMPTY_MODULE__";
|
|
104
|
-
}
|
|
105
|
-
const { virtualModules: virtualModuleMapping, entries: dynamicEntries } = await getVirtualModules(options);
|
|
88
|
+
let externals = globalsNameReferenceMap;
|
|
89
|
+
build?.test?.disableBlocks && (externals["@storybook/addon-docs/blocks"] = "__STORYBOOK_BLOCKS_EMPTY_MODULE__");
|
|
90
|
+
let { virtualModules: virtualModuleMapping, entries: dynamicEntries } = await getVirtualModules(options);
|
|
106
91
|
return {
|
|
107
92
|
name: "preview",
|
|
108
93
|
mode: isProd ? "production" : "development",
|
|
109
94
|
bail: isProd,
|
|
110
|
-
devtool: options.build?.test?.disableSourcemaps ?
|
|
95
|
+
devtool: options.build?.test?.disableSourcemaps ? !1 : "cheap-module-source-map",
|
|
111
96
|
entry: [...entries2 ?? [], ...dynamicEntries],
|
|
112
97
|
output: {
|
|
113
98
|
path: resolve(process.cwd(), outputDir),
|
|
@@ -133,11 +118,11 @@ var iframe_webpack_config_default = /* @__PURE__ */ __name(async (options) => {
|
|
|
133
118
|
plugins: [
|
|
134
119
|
Object.keys(virtualModuleMapping).length > 0 ? new VirtualModulePlugin(virtualModuleMapping) : null,
|
|
135
120
|
new HtmlWebpackPlugin({
|
|
136
|
-
filename:
|
|
121
|
+
filename: "iframe.html",
|
|
137
122
|
// FIXME: `none` isn't a known option
|
|
138
123
|
chunksSortMode: "none",
|
|
139
|
-
alwaysWriteToDisk:
|
|
140
|
-
inject:
|
|
124
|
+
alwaysWriteToDisk: !0,
|
|
125
|
+
inject: !1,
|
|
141
126
|
template,
|
|
142
127
|
templateParameters: {
|
|
143
128
|
version: packageJson?.version,
|
|
@@ -160,12 +145,12 @@ var iframe_webpack_config_default = /* @__PURE__ */ __name(async (options) => {
|
|
|
160
145
|
bodyHtmlSnippet
|
|
161
146
|
},
|
|
162
147
|
minify: {
|
|
163
|
-
collapseWhitespace:
|
|
164
|
-
removeComments:
|
|
165
|
-
removeRedundantAttributes:
|
|
166
|
-
removeScriptTypeAttributes:
|
|
167
|
-
removeStyleLinkTypeAttributes:
|
|
168
|
-
useShortDoctype:
|
|
148
|
+
collapseWhitespace: !0,
|
|
149
|
+
removeComments: !0,
|
|
150
|
+
removeRedundantAttributes: !0,
|
|
151
|
+
removeScriptTypeAttributes: !1,
|
|
152
|
+
removeStyleLinkTypeAttributes: !0,
|
|
153
|
+
useShortDoctype: !0
|
|
169
154
|
}
|
|
170
155
|
}),
|
|
171
156
|
new DefinePlugin({
|
|
@@ -181,7 +166,7 @@ var iframe_webpack_config_default = /* @__PURE__ */ __name(async (options) => {
|
|
|
181
166
|
].filter(Boolean),
|
|
182
167
|
module: {
|
|
183
168
|
// Disable warning for dynamic requires
|
|
184
|
-
unknownContextCritical:
|
|
169
|
+
unknownContextCritical: !1,
|
|
185
170
|
rules: [
|
|
186
171
|
{
|
|
187
172
|
test: /\.stories\.([tj])sx?$|(stories|story)\.mdx$/,
|
|
@@ -202,7 +187,7 @@ var iframe_webpack_config_default = /* @__PURE__ */ __name(async (options) => {
|
|
|
202
187
|
{
|
|
203
188
|
test: /\.m?js$/,
|
|
204
189
|
resolve: {
|
|
205
|
-
fullySpecified:
|
|
190
|
+
fullySpecified: !1
|
|
206
191
|
}
|
|
207
192
|
},
|
|
208
193
|
{
|
|
@@ -223,15 +208,15 @@ var iframe_webpack_config_default = /* @__PURE__ */ __name(async (options) => {
|
|
|
223
208
|
splitChunks: {
|
|
224
209
|
chunks: "all"
|
|
225
210
|
},
|
|
226
|
-
runtimeChunk:
|
|
227
|
-
sideEffects:
|
|
228
|
-
usedExports: options.build?.test?.disableTreeShaking ?
|
|
211
|
+
runtimeChunk: !0,
|
|
212
|
+
sideEffects: !0,
|
|
213
|
+
usedExports: options.build?.test?.disableTreeShaking ? !1 : isProd,
|
|
229
214
|
moduleIds: "named",
|
|
230
215
|
...isProd ? {
|
|
231
|
-
minimize:
|
|
216
|
+
minimize: !0,
|
|
232
217
|
minimizer: options.build?.test?.esbuildMinify ? [
|
|
233
218
|
new TerserWebpackPlugin({
|
|
234
|
-
parallel:
|
|
219
|
+
parallel: !0,
|
|
235
220
|
minify: TerserWebpackPlugin.esbuildMinify,
|
|
236
221
|
terserOptions: {
|
|
237
222
|
sourcemap: !options.build?.test?.disableSourcemaps,
|
|
@@ -240,42 +225,37 @@ var iframe_webpack_config_default = /* @__PURE__ */ __name(async (options) => {
|
|
|
240
225
|
})
|
|
241
226
|
] : [
|
|
242
227
|
new TerserWebpackPlugin({
|
|
243
|
-
parallel:
|
|
228
|
+
parallel: !0,
|
|
244
229
|
terserOptions: {
|
|
245
230
|
sourceMap: !options.build?.test?.disableSourcemaps,
|
|
246
|
-
mangle:
|
|
247
|
-
keep_fnames:
|
|
231
|
+
mangle: !1,
|
|
232
|
+
keep_fnames: !0
|
|
248
233
|
}
|
|
249
234
|
})
|
|
250
235
|
]
|
|
251
236
|
} : {}
|
|
252
237
|
},
|
|
253
238
|
performance: {
|
|
254
|
-
hints: isProd ? "warning" :
|
|
239
|
+
hints: isProd ? "warning" : !1
|
|
255
240
|
},
|
|
256
241
|
...cacheConfig,
|
|
257
242
|
experiments: { ...lazyCompilationConfig }
|
|
258
243
|
};
|
|
259
|
-
}
|
|
244
|
+
};
|
|
260
245
|
|
|
261
246
|
// src/presets/preview-preset.ts
|
|
262
|
-
var webpack =
|
|
263
|
-
var entries = /* @__PURE__ */ __name(async (_, options) => {
|
|
247
|
+
var webpack = async (_, options) => iframe_webpack_config_default(options), entries = async (_, options) => {
|
|
264
248
|
let result = [];
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
}
|
|
276
|
-
return result;
|
|
277
|
-
}, "entries");
|
|
278
|
-
var previewMainTemplate = /* @__PURE__ */ __name(() => fileURLToPath2(import.meta.resolve("@storybook/builder-webpack5/templates/preview.ejs")), "previewMainTemplate");
|
|
249
|
+
return options.configType === "DEVELOPMENT" && (result = result.concat(
|
|
250
|
+
`${fileURLToPath2(
|
|
251
|
+
import.meta.resolve("webpack-hot-middleware/client.js")
|
|
252
|
+
)}?reload=true&quiet=false&overlay=${JSON.stringify({
|
|
253
|
+
errors: !0,
|
|
254
|
+
warnings: !1,
|
|
255
|
+
runtimeErrors: !1
|
|
256
|
+
})}&noInfo=${options.quiet}`
|
|
257
|
+
)), result;
|
|
258
|
+
}, previewMainTemplate = () => fileURLToPath2(import.meta.resolve("@storybook/builder-webpack5/templates/preview.ejs"));
|
|
279
259
|
export {
|
|
280
260
|
entries,
|
|
281
261
|
previewMainTemplate,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/builder-webpack5",
|
|
3
|
-
"version": "10.1.0-alpha.
|
|
3
|
+
"version": "10.1.0-alpha.11",
|
|
4
4
|
"description": "A Storybook builder to dev and build with Webpack",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"prep": "jiti ../../../scripts/build/build-package.ts"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@storybook/core-webpack": "10.1.0-alpha.
|
|
56
|
+
"@storybook/core-webpack": "10.1.0-alpha.11",
|
|
57
57
|
"case-sensitive-paths-webpack-plugin": "^2.4.0",
|
|
58
58
|
"cjs-module-lexer": "^1.2.3",
|
|
59
59
|
"css-loader": "^7.1.2",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"typescript": "^5.8.3"
|
|
80
80
|
},
|
|
81
81
|
"peerDependencies": {
|
|
82
|
-
"storybook": "^10.1.0-alpha.
|
|
82
|
+
"storybook": "^10.1.0-alpha.11"
|
|
83
83
|
},
|
|
84
84
|
"peerDependenciesMeta": {
|
|
85
85
|
"typescript": {
|
|
@@ -89,5 +89,5 @@
|
|
|
89
89
|
"publishConfig": {
|
|
90
90
|
"access": "public"
|
|
91
91
|
},
|
|
92
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "a8e7fd8a655c69780bc20b9749d2699e45beae1l"
|
|
93
93
|
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import CJS_COMPAT_NODE_URL_o0h2pkg2c5 from 'node:url';
|
|
2
|
-
import CJS_COMPAT_NODE_PATH_o0h2pkg2c5 from 'node:path';
|
|
3
|
-
import CJS_COMPAT_NODE_MODULE_o0h2pkg2c5 from "node:module";
|
|
4
|
-
|
|
5
|
-
var __filename = CJS_COMPAT_NODE_URL_o0h2pkg2c5.fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = CJS_COMPAT_NODE_PATH_o0h2pkg2c5.dirname(__filename);
|
|
7
|
-
var require = CJS_COMPAT_NODE_MODULE_o0h2pkg2c5.createRequire(import.meta.url);
|
|
8
|
-
|
|
9
|
-
// ------------------------------------------------------------
|
|
10
|
-
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
-
// ------------------------------------------------------------
|
|
12
|
-
import {
|
|
13
|
-
__name
|
|
14
|
-
} from "./chunk-TMJDR5EF.js";
|
|
15
|
-
|
|
16
|
-
// src/preview/virtual-module-mapping.ts
|
|
17
|
-
import { join, resolve } from "node:path";
|
|
18
|
-
import { fileURLToPath } from "node:url";
|
|
19
|
-
import {
|
|
20
|
-
getBuilderOptions,
|
|
21
|
-
loadPreviewOrConfigFile,
|
|
22
|
-
normalizeStories,
|
|
23
|
-
readTemplate
|
|
24
|
-
} from "storybook/internal/common";
|
|
25
|
-
import { toImportFn } from "@storybook/core-webpack";
|
|
26
|
-
|
|
27
|
-
// ../../node_modules/slash/index.js
|
|
28
|
-
function slash(path) {
|
|
29
|
-
const isExtendedLengthPath = path.startsWith("\\\\?\\");
|
|
30
|
-
if (isExtendedLengthPath) {
|
|
31
|
-
return path;
|
|
32
|
-
}
|
|
33
|
-
return path.replace(/\\/g, "/");
|
|
34
|
-
}
|
|
35
|
-
__name(slash, "slash");
|
|
36
|
-
|
|
37
|
-
// src/preview/virtual-module-mapping.ts
|
|
38
|
-
var getVirtualModules = /* @__PURE__ */ __name(async (options) => {
|
|
39
|
-
const virtualModules = {};
|
|
40
|
-
const builderOptions = await getBuilderOptions(options);
|
|
41
|
-
const workingDir = process.cwd();
|
|
42
|
-
const isProd = options.configType === "PRODUCTION";
|
|
43
|
-
const nonNormalizedStories = await options.presets.apply("stories", []);
|
|
44
|
-
const entries = [];
|
|
45
|
-
const stories = normalizeStories(nonNormalizedStories, {
|
|
46
|
-
configDir: options.configDir,
|
|
47
|
-
workingDir
|
|
48
|
-
});
|
|
49
|
-
const previewAnnotations = [
|
|
50
|
-
...(await options.presets.apply("previewAnnotations", [], options)).map(
|
|
51
|
-
(entry) => {
|
|
52
|
-
if (typeof entry === "object") {
|
|
53
|
-
return entry.absolute;
|
|
54
|
-
}
|
|
55
|
-
return slash(entry);
|
|
56
|
-
}
|
|
57
|
-
),
|
|
58
|
-
loadPreviewOrConfigFile(options)
|
|
59
|
-
].filter(Boolean);
|
|
60
|
-
const storiesFilename = "storybook-stories.js";
|
|
61
|
-
const storiesPath = resolve(join(workingDir, storiesFilename));
|
|
62
|
-
const needPipelinedImport = !!builderOptions.lazyCompilation && !isProd;
|
|
63
|
-
virtualModules[storiesPath] = toImportFn(stories, { needPipelinedImport });
|
|
64
|
-
const configEntryPath = resolve(join(workingDir, "storybook-config-entry.js"));
|
|
65
|
-
virtualModules[configEntryPath] = (await readTemplate(
|
|
66
|
-
fileURLToPath(
|
|
67
|
-
import.meta.resolve("@storybook/builder-webpack5/templates/virtualModuleModernEntry.js")
|
|
68
|
-
)
|
|
69
|
-
)).replaceAll(`'{{storiesFilename}}'`, `'./${storiesFilename}'`).replaceAll(
|
|
70
|
-
`'{{previewAnnotations}}'`,
|
|
71
|
-
previewAnnotations.filter(Boolean).map((entry) => `'${entry}'`).join(",")
|
|
72
|
-
).replaceAll(
|
|
73
|
-
`'{{previewAnnotations_requires}}'`,
|
|
74
|
-
previewAnnotations.filter(Boolean).map((entry) => `require('${entry}')`).join(",")
|
|
75
|
-
).replace(/\\/g, "\\\\");
|
|
76
|
-
entries.push(configEntryPath);
|
|
77
|
-
return {
|
|
78
|
-
virtualModules,
|
|
79
|
-
entries
|
|
80
|
-
};
|
|
81
|
-
}, "getVirtualModules");
|
|
82
|
-
|
|
83
|
-
export {
|
|
84
|
-
getVirtualModules
|
|
85
|
-
};
|