storybook-builder-rsbuild 3.0.0 → 3.2.0
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/compiled/@storybook/core-webpack/index.js +52 -72
- package/compiled/@storybook/core-webpack/package.json +1 -1
- package/dist/_node-chunks/{chunk-EUKC5ATQ.js → chunk-IFQ2M2R3.js} +6 -6
- package/dist/index.js +31 -48
- package/dist/loaders/export-order-loader.js +7 -7
- package/dist/loaders/rsbuild-automock-loader.js +22 -0
- package/dist/loaders/storybook-mock-transform-loader.js +30 -0
- package/dist/preview-preset.js +161 -10
- package/package.json +16 -13
- package/templates/virtualModuleModernEntry.js +3 -5
|
@@ -155,27 +155,21 @@ var dist_dirname = external_node_path_namespaceObject.dirname(dist_filename);
|
|
|
155
155
|
var dist_require = external_node_module_namespaceObject.createRequire(
|
|
156
156
|
import.meta.url,
|
|
157
157
|
);
|
|
158
|
-
var
|
|
159
|
-
|
|
160
|
-
__defProp(target, "name", { value, configurable: true });
|
|
161
|
-
var webpackConfigs = ["webpack.config", "webpackfile"];
|
|
162
|
-
var loadCustomWebpackConfig = __name(
|
|
163
|
-
async (configDir) =>
|
|
158
|
+
var webpackConfigs = ["webpack.config", "webpackfile"],
|
|
159
|
+
loadCustomWebpackConfig = async (configDir) =>
|
|
164
160
|
(0, common_namespaceObject.serverRequire)(
|
|
165
161
|
webpackConfigs.map((configName) =>
|
|
166
162
|
(0, external_node_path_namespaceObject.resolve)(configDir, configName),
|
|
167
163
|
),
|
|
168
|
-
)
|
|
169
|
-
|
|
170
|
-
);
|
|
171
|
-
var checkWebpackVersion = __name((webpack, specifier, caption) => {
|
|
164
|
+
);
|
|
165
|
+
var checkWebpackVersion = (webpack, specifier, caption) => {
|
|
172
166
|
if (!webpack.version) {
|
|
173
167
|
node_logger_namespaceObject.logger.info(
|
|
174
168
|
"Skipping webpack version check, no version available",
|
|
175
169
|
);
|
|
176
170
|
return;
|
|
177
171
|
}
|
|
178
|
-
|
|
172
|
+
webpack.version !== specifier &&
|
|
179
173
|
node_logger_namespaceObject.logger.warn((0, dist.TW)`
|
|
180
174
|
Unexpected webpack version in ${caption}:
|
|
181
175
|
- Received '${webpack.version}'
|
|
@@ -185,34 +179,28 @@ var checkWebpackVersion = __name((webpack, specifier, caption) => {
|
|
|
185
179
|
|
|
186
180
|
For more info about Webpack 5 support: https://gist.github.com/shilman/8856ea1786dcd247139b47b270912324#troubleshooting
|
|
187
181
|
`);
|
|
188
|
-
|
|
189
|
-
}, "checkWebpackVersion");
|
|
182
|
+
};
|
|
190
183
|
function mergePluginsField(defaultPlugins = [], customPlugins = []) {
|
|
191
184
|
return [...defaultPlugins, ...customPlugins];
|
|
192
185
|
}
|
|
193
|
-
__name(mergePluginsField, "mergePluginsField");
|
|
194
186
|
function mergeRulesField(defaultRules = [], customRules = []) {
|
|
195
187
|
return [...defaultRules, ...customRules];
|
|
196
188
|
}
|
|
197
|
-
__name(mergeRulesField, "mergeRulesField");
|
|
198
189
|
function mergeExtensionsField(
|
|
199
190
|
{ extensions: defaultExtensions = [] },
|
|
200
191
|
{ extensions: customExtensions = [] },
|
|
201
192
|
) {
|
|
202
193
|
return [...defaultExtensions, ...customExtensions];
|
|
203
194
|
}
|
|
204
|
-
__name(mergeExtensionsField, "mergeExtensionsField");
|
|
205
195
|
function mergeAliasField(
|
|
206
196
|
{ alias: defaultAlias = {} },
|
|
207
197
|
{ alias: customAlias = {} },
|
|
208
198
|
) {
|
|
209
199
|
return { ...defaultAlias, ...customAlias };
|
|
210
200
|
}
|
|
211
|
-
__name(mergeAliasField, "mergeAliasField");
|
|
212
201
|
function mergeModuleField(a, b) {
|
|
213
202
|
return { ...a, ...b, rules: mergeRulesField(a.rules || [], b.rules || []) };
|
|
214
203
|
}
|
|
215
|
-
__name(mergeModuleField, "mergeModuleField");
|
|
216
204
|
function mergeResolveField(
|
|
217
205
|
{ resolve: defaultResolve = {} },
|
|
218
206
|
{ resolve: customResolve = {} },
|
|
@@ -224,14 +212,12 @@ function mergeResolveField(
|
|
|
224
212
|
extensions: mergeExtensionsField(defaultResolve, customResolve),
|
|
225
213
|
};
|
|
226
214
|
}
|
|
227
|
-
__name(mergeResolveField, "mergeResolveField");
|
|
228
215
|
function mergeOptimizationField(
|
|
229
216
|
{ optimization: defaultOptimization = {} },
|
|
230
217
|
{ optimization: customOptimization = {} },
|
|
231
218
|
) {
|
|
232
219
|
return { ...defaultOptimization, ...customOptimization };
|
|
233
220
|
}
|
|
234
|
-
__name(mergeOptimizationField, "mergeOptimizationField");
|
|
235
221
|
function mergeConfigs(config, customConfig) {
|
|
236
222
|
return {
|
|
237
223
|
...customConfig,
|
|
@@ -243,49 +229,45 @@ function mergeConfigs(config, customConfig) {
|
|
|
243
229
|
optimization: mergeOptimizationField(config, customConfig),
|
|
244
230
|
};
|
|
245
231
|
}
|
|
246
|
-
__name(mergeConfigs, "mergeConfigs");
|
|
247
232
|
function importPipeline() {
|
|
248
233
|
let importGate = Promise.resolve();
|
|
249
234
|
return async (importFn) => {
|
|
250
235
|
await importGate;
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
236
|
+
let moduleExportsPromise = importFn();
|
|
237
|
+
return (
|
|
238
|
+
(importGate = importGate.then(async () => {
|
|
239
|
+
await moduleExportsPromise;
|
|
240
|
+
})),
|
|
241
|
+
moduleExportsPromise
|
|
242
|
+
);
|
|
256
243
|
};
|
|
257
244
|
}
|
|
258
|
-
__name(importPipeline, "importPipeline");
|
|
259
245
|
function adjustRegexToExcludeNodeModules(originalRegex) {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
246
|
+
let originalRegexString = originalRegex.source,
|
|
247
|
+
startsWithCaret = originalRegexString.startsWith("^"),
|
|
248
|
+
excludeNodeModulesPattern = startsWithCaret
|
|
249
|
+
? "(?!.*node_modules)"
|
|
250
|
+
: "^(?!.*node_modules)",
|
|
251
|
+
adjustedRegexString = startsWithCaret
|
|
252
|
+
? `^${excludeNodeModulesPattern}${originalRegexString.substring(1)}`
|
|
253
|
+
: excludeNodeModulesPattern + originalRegexString;
|
|
268
254
|
return new RegExp(adjustedRegexString);
|
|
269
255
|
}
|
|
270
|
-
__name(adjustRegexToExcludeNodeModules, "adjustRegexToExcludeNodeModules");
|
|
271
256
|
function webpackIncludeRegexp(specifier) {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
(0, common_namespaceObject.globToRegexp)(webpackIncludeGlob),
|
|
283
|
-
);
|
|
257
|
+
let { directory, files } = specifier,
|
|
258
|
+
directoryWithoutLeadingDots = directory.replace(/^(\.+\/)+/, "/"),
|
|
259
|
+
webpackIncludeGlob = [".", ".."].includes(directory)
|
|
260
|
+
? files
|
|
261
|
+
: `${directoryWithoutLeadingDots}/${files}`,
|
|
262
|
+
webpackIncludeRegexpWithCaret = webpackIncludeGlob.includes("node_modules")
|
|
263
|
+
? (0, common_namespaceObject.globToRegexp)(webpackIncludeGlob)
|
|
264
|
+
: adjustRegexToExcludeNodeModules(
|
|
265
|
+
(0, common_namespaceObject.globToRegexp)(webpackIncludeGlob),
|
|
266
|
+
);
|
|
284
267
|
return new RegExp(webpackIncludeRegexpWithCaret.source.replace(/^\^/, ""));
|
|
285
268
|
}
|
|
286
|
-
__name(webpackIncludeRegexp, "webpackIncludeRegexp");
|
|
287
269
|
function toImportFnPart(specifier) {
|
|
288
|
-
|
|
270
|
+
let { directory, importPathMatcher } = specifier;
|
|
289
271
|
return (0, dist.TW)`
|
|
290
272
|
async (path) => {
|
|
291
273
|
if (!${importPathMatcher}.exec(path)) {
|
|
@@ -302,17 +284,16 @@ function toImportFnPart(specifier) {
|
|
|
302
284
|
|
|
303
285
|
`;
|
|
304
286
|
}
|
|
305
|
-
__name(toImportFnPart, "toImportFnPart");
|
|
306
287
|
function toImportFn(stories, { needPipelinedImport } = {}) {
|
|
307
|
-
let pipelinedImport =
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
288
|
+
let pipelinedImport = "const pipeline = (x) => x();";
|
|
289
|
+
return (
|
|
290
|
+
needPipelinedImport &&
|
|
291
|
+
(pipelinedImport = `\n const importPipeline = ${importPipeline};\n const pipeline = importPipeline();\n `),
|
|
292
|
+
(0, dist.TW)`
|
|
312
293
|
${pipelinedImport}
|
|
313
294
|
|
|
314
295
|
const importers = [
|
|
315
|
-
${stories.map(toImportFnPart).join(
|
|
296
|
+
${stories.map(toImportFnPart).join(`,\n`)}
|
|
316
297
|
];
|
|
317
298
|
|
|
318
299
|
export async function importFn(path) {
|
|
@@ -323,23 +304,22 @@ function toImportFn(stories, { needPipelinedImport } = {}) {
|
|
|
323
304
|
}
|
|
324
305
|
}
|
|
325
306
|
}
|
|
326
|
-
|
|
307
|
+
`
|
|
308
|
+
);
|
|
327
309
|
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
310
|
+
var toRequireContext = (specifier) => {
|
|
311
|
+
let { directory, files } = specifier,
|
|
312
|
+
match = (0, common_namespaceObject.globToRegexp)(`./${files}`);
|
|
313
|
+
return {
|
|
314
|
+
path: directory,
|
|
315
|
+
recursive: files.includes("**") || files.split("/").length > 1,
|
|
316
|
+
match,
|
|
317
|
+
};
|
|
318
|
+
},
|
|
319
|
+
toRequireContextString = (specifier) => {
|
|
320
|
+
let { path: p, recursive: r, match: m } = toRequireContext(specifier);
|
|
321
|
+
return `require.context('${p}', ${r}, ${m})`;
|
|
336
322
|
};
|
|
337
|
-
}, "toRequireContext");
|
|
338
|
-
var toRequireContextString = __name((specifier) => {
|
|
339
|
-
const { path: p, recursive: r, match: m } = toRequireContext(specifier);
|
|
340
|
-
const result = `require.context('${p}', ${r}, ${m})`;
|
|
341
|
-
return result;
|
|
342
|
-
}, "toRequireContextString");
|
|
343
323
|
var __webpack_exports__checkWebpackVersion = __webpack_exports__.il;
|
|
344
324
|
var __webpack_exports__loadCustomWebpackConfig = __webpack_exports__.Tu;
|
|
345
325
|
var __webpack_exports__mergeConfigs = __webpack_exports__.SV;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@storybook/core-webpack","version":"10.
|
|
1
|
+
{"name":"@storybook/core-webpack","version":"10.1.2","funding":{"type":"opencollective","url":"https://opencollective.com/storybook"},"license":"MIT","types":"index.d.ts","type":"module"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_9f7479727fe3f3ec from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_9f7479727fe3f3ec from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_9f7479727fe3f3ec from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_9f7479727fe3f3ec.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_9f7479727fe3f3ec.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_9f7479727fe3f3ec.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_9f7479727fe3f3ec from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_9f7479727fe3f3ec from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_9f7479727fe3f3ec from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_9f7479727fe3f3ec.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_9f7479727fe3f3ec.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_9f7479727fe3f3ec.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
__commonJS,
|
|
14
14
|
__require,
|
|
15
15
|
__toESM
|
|
16
|
-
} from "./_node-chunks/chunk-
|
|
16
|
+
} from "./_node-chunks/chunk-IFQ2M2R3.js";
|
|
17
17
|
|
|
18
18
|
// ../../node_modules/.pnpm/pretty-hrtime@1.0.3/node_modules/pretty-hrtime/index.js
|
|
19
19
|
var require_pretty_hrtime = __commonJS({
|
|
@@ -46,16 +46,18 @@ import { logger as rsbuildLogger } from "@rsbuild/core";
|
|
|
46
46
|
import picocolors from "picocolors";
|
|
47
47
|
import { logger } from "storybook/internal/node-logger";
|
|
48
48
|
function overrideRsbuildLogger() {
|
|
49
|
-
let logWithPrefix = (fn) => (msg) => fn(
|
|
49
|
+
let logWithPrefix = (fn) => (msg) => fn(
|
|
50
|
+
`${picocolors.black(picocolors.bgBlueBright("Rsbuild"))} ${String(msg)}`
|
|
51
|
+
);
|
|
50
52
|
rsbuildLogger.override({
|
|
51
53
|
error: logWithPrefix(logger.error),
|
|
52
54
|
warn: logWithPrefix(logger.warn),
|
|
53
|
-
info: logWithPrefix(logger.
|
|
55
|
+
info: logWithPrefix((msg) => logger.log(msg, { spacing: 0 })),
|
|
56
|
+
start: logWithPrefix(logger.info),
|
|
57
|
+
ready: logWithPrefix(logger.info),
|
|
54
58
|
success: logWithPrefix(logger.info),
|
|
55
|
-
debug: logWithPrefix(logger.info),
|
|
56
59
|
log: logWithPrefix(logger.info),
|
|
57
|
-
|
|
58
|
-
start: logWithPrefix(logger.info)
|
|
60
|
+
debug: logWithPrefix(logger.debug)
|
|
59
61
|
});
|
|
60
62
|
}
|
|
61
63
|
|
|
@@ -201,14 +203,11 @@ var node_logger_namespaceObject = node_logger_x({
|
|
|
201
203
|
import.meta.url
|
|
202
204
|
), dist_dirname = external_node_path_namespaceObject.dirname(dist_filename), dist_require = external_node_module_namespaceObject.createRequire(
|
|
203
205
|
import.meta.url
|
|
204
|
-
),
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
),
|
|
210
|
-
"loadCustomWebpackConfig"
|
|
211
|
-
), checkWebpackVersion = __name((webpack, specifier, caption) => {
|
|
206
|
+
), webpackConfigs = ["webpack.config", "webpackfile"], loadCustomWebpackConfig = async (configDir) => (0, common_namespaceObject.serverRequire)(
|
|
207
|
+
webpackConfigs.map(
|
|
208
|
+
(configName) => (0, external_node_path_namespaceObject.resolve)(configDir, configName)
|
|
209
|
+
)
|
|
210
|
+
), checkWebpackVersion = (webpack, specifier, caption) => {
|
|
212
211
|
if (!webpack.version) {
|
|
213
212
|
node_logger_namespaceObject.logger.info(
|
|
214
213
|
"Skipping webpack version check, no version available"
|
|
@@ -224,27 +223,22 @@ var node_logger_namespaceObject = node_logger_x({
|
|
|
224
223
|
|
|
225
224
|
For more info about Webpack 5 support: https://gist.github.com/shilman/8856ea1786dcd247139b47b270912324#troubleshooting
|
|
226
225
|
`);
|
|
227
|
-
}
|
|
226
|
+
};
|
|
228
227
|
function mergePluginsField(defaultPlugins = [], customPlugins = []) {
|
|
229
228
|
return [...defaultPlugins, ...customPlugins];
|
|
230
229
|
}
|
|
231
|
-
__name(mergePluginsField, "mergePluginsField");
|
|
232
230
|
function mergeRulesField(defaultRules = [], customRules = []) {
|
|
233
231
|
return [...defaultRules, ...customRules];
|
|
234
232
|
}
|
|
235
|
-
__name(mergeRulesField, "mergeRulesField");
|
|
236
233
|
function mergeExtensionsField({ extensions: defaultExtensions = [] }, { extensions: customExtensions = [] }) {
|
|
237
234
|
return [...defaultExtensions, ...customExtensions];
|
|
238
235
|
}
|
|
239
|
-
__name(mergeExtensionsField, "mergeExtensionsField");
|
|
240
236
|
function mergeAliasField({ alias: defaultAlias = {} }, { alias: customAlias = {} }) {
|
|
241
237
|
return { ...defaultAlias, ...customAlias };
|
|
242
238
|
}
|
|
243
|
-
__name(mergeAliasField, "mergeAliasField");
|
|
244
239
|
function mergeModuleField(a, b) {
|
|
245
240
|
return { ...a, ...b, rules: mergeRulesField(a.rules || [], b.rules || []) };
|
|
246
241
|
}
|
|
247
|
-
__name(mergeModuleField, "mergeModuleField");
|
|
248
242
|
function mergeResolveField({ resolve: defaultResolve = {} }, { resolve: customResolve = {} }) {
|
|
249
243
|
return {
|
|
250
244
|
...defaultResolve,
|
|
@@ -253,11 +247,9 @@ function mergeResolveField({ resolve: defaultResolve = {} }, { resolve: customRe
|
|
|
253
247
|
extensions: mergeExtensionsField(defaultResolve, customResolve)
|
|
254
248
|
};
|
|
255
249
|
}
|
|
256
|
-
__name(mergeResolveField, "mergeResolveField");
|
|
257
250
|
function mergeOptimizationField({ optimization: defaultOptimization = {} }, { optimization: customOptimization = {} }) {
|
|
258
251
|
return { ...defaultOptimization, ...customOptimization };
|
|
259
252
|
}
|
|
260
|
-
__name(mergeOptimizationField, "mergeOptimizationField");
|
|
261
253
|
function mergeConfigs(config, customConfig) {
|
|
262
254
|
return {
|
|
263
255
|
...customConfig,
|
|
@@ -269,7 +261,6 @@ function mergeConfigs(config, customConfig) {
|
|
|
269
261
|
optimization: mergeOptimizationField(config, customConfig)
|
|
270
262
|
};
|
|
271
263
|
}
|
|
272
|
-
__name(mergeConfigs, "mergeConfigs");
|
|
273
264
|
function importPipeline() {
|
|
274
265
|
let importGate = Promise.resolve();
|
|
275
266
|
return async (importFn) => {
|
|
@@ -280,21 +271,16 @@ function importPipeline() {
|
|
|
280
271
|
}), moduleExportsPromise;
|
|
281
272
|
};
|
|
282
273
|
}
|
|
283
|
-
__name(importPipeline, "importPipeline");
|
|
284
274
|
function adjustRegexToExcludeNodeModules(originalRegex) {
|
|
285
275
|
let originalRegexString = originalRegex.source, startsWithCaret = originalRegexString.startsWith("^"), excludeNodeModulesPattern = startsWithCaret ? "(?!.*node_modules)" : "^(?!.*node_modules)", adjustedRegexString = startsWithCaret ? `^${excludeNodeModulesPattern}${originalRegexString.substring(1)}` : excludeNodeModulesPattern + originalRegexString;
|
|
286
276
|
return new RegExp(adjustedRegexString);
|
|
287
277
|
}
|
|
288
|
-
__name(adjustRegexToExcludeNodeModules, "adjustRegexToExcludeNodeModules");
|
|
289
278
|
function webpackIncludeRegexp(specifier) {
|
|
290
|
-
let { directory, files } = specifier, directoryWithoutLeadingDots = directory.replace(/^(\.+\/)+/, "/"), webpackIncludeGlob = [".", ".."].includes(directory) ? files : `${directoryWithoutLeadingDots}/${files}`, webpackIncludeRegexpWithCaret = webpackIncludeGlob.includes(
|
|
291
|
-
"node_modules"
|
|
292
|
-
) ? (0, common_namespaceObject.globToRegexp)(webpackIncludeGlob) : adjustRegexToExcludeNodeModules(
|
|
279
|
+
let { directory, files } = specifier, directoryWithoutLeadingDots = directory.replace(/^(\.+\/)+/, "/"), webpackIncludeGlob = [".", ".."].includes(directory) ? files : `${directoryWithoutLeadingDots}/${files}`, webpackIncludeRegexpWithCaret = webpackIncludeGlob.includes("node_modules") ? (0, common_namespaceObject.globToRegexp)(webpackIncludeGlob) : adjustRegexToExcludeNodeModules(
|
|
293
280
|
(0, common_namespaceObject.globToRegexp)(webpackIncludeGlob)
|
|
294
281
|
);
|
|
295
282
|
return new RegExp(webpackIncludeRegexpWithCaret.source.replace(/^\^/, ""));
|
|
296
283
|
}
|
|
297
|
-
__name(webpackIncludeRegexp, "webpackIncludeRegexp");
|
|
298
284
|
function toImportFnPart(specifier) {
|
|
299
285
|
let { directory, importPathMatcher } = specifier;
|
|
300
286
|
return (0, dist.TW)`
|
|
@@ -313,7 +299,6 @@ function toImportFnPart(specifier) {
|
|
|
313
299
|
|
|
314
300
|
`;
|
|
315
301
|
}
|
|
316
|
-
__name(toImportFnPart, "toImportFnPart");
|
|
317
302
|
function toImportFn(stories, { needPipelinedImport } = {}) {
|
|
318
303
|
let pipelinedImport = "const pipeline = (x) => x();";
|
|
319
304
|
return needPipelinedImport && (pipelinedImport = `
|
|
@@ -337,18 +322,17 @@ function toImportFn(stories, { needPipelinedImport } = {}) {
|
|
|
337
322
|
}
|
|
338
323
|
`;
|
|
339
324
|
}
|
|
340
|
-
|
|
341
|
-
var toRequireContext = __name((specifier) => {
|
|
325
|
+
var toRequireContext = (specifier) => {
|
|
342
326
|
let { directory, files } = specifier, match = (0, common_namespaceObject.globToRegexp)(`./${files}`);
|
|
343
327
|
return {
|
|
344
328
|
path: directory,
|
|
345
329
|
recursive: files.includes("**") || files.split("/").length > 1,
|
|
346
330
|
match
|
|
347
331
|
};
|
|
348
|
-
},
|
|
332
|
+
}, toRequireContextString = (specifier) => {
|
|
349
333
|
let { path: p, recursive: r, match: m } = toRequireContext(specifier);
|
|
350
334
|
return `require.context('${p}', ${r}, ${m})`;
|
|
351
|
-
},
|
|
335
|
+
}, __webpack_exports__checkWebpackVersion = __webpack_exports__.il, __webpack_exports__loadCustomWebpackConfig = __webpack_exports__.Tu, __webpack_exports__mergeConfigs = __webpack_exports__.SV, __webpack_exports__toImportFn = __webpack_exports__.T1, __webpack_exports__toImportFnPart = __webpack_exports__.i8, __webpack_exports__toRequireContext = __webpack_exports__.sg, __webpack_exports__toRequireContextString = __webpack_exports__.HO, __webpack_exports__webpackIncludeRegexp = __webpack_exports__.hO;
|
|
352
336
|
|
|
353
337
|
// src/preview/virtual-module-mapping.ts
|
|
354
338
|
var getVirtualModules = async (options) => {
|
|
@@ -408,7 +392,7 @@ var require2 = createRequire(import.meta.url), getAbsolutePath = (input) => {
|
|
|
408
392
|
".json",
|
|
409
393
|
".cjs"
|
|
410
394
|
], globalPath = maybeGetAbsolutePath("@storybook/global"), storybookPaths = {
|
|
411
|
-
// biome-ignore lint/complexity/useLiteralKeys:
|
|
395
|
+
// biome-ignore lint/complexity/useLiteralKeys: dynamic key required for conditional spread
|
|
412
396
|
...globalPath ? { "@storybook/global": globalPath } : {}
|
|
413
397
|
}, iframe_rsbuild_config_default = async (options, extraWebpackConfig) => {
|
|
414
398
|
let { rsbuildConfigPath, addonDocs } = await getBuilderOptions2(options), webpackConfigFromPresets = await options.presets.apply("webpack", {}, options);
|
|
@@ -567,7 +551,7 @@ var require2 = createRequire(import.meta.url), getAbsolutePath = (input) => {
|
|
|
567
551
|
swc: (config) => {
|
|
568
552
|
config.env ??= {}, config.env.bugfixes = !0;
|
|
569
553
|
},
|
|
570
|
-
rspack: (config, { addRules, rspack
|
|
554
|
+
rspack: (config, { addRules, rspack, mergeConfig }) => {
|
|
571
555
|
if (addRules({
|
|
572
556
|
test: /\.stories\.([tj])sx?$|(stories|story)\.mdx$/,
|
|
573
557
|
exclude: /node_modules/,
|
|
@@ -598,16 +582,16 @@ var require2 = createRequire(import.meta.url), getAbsolutePath = (input) => {
|
|
|
598
582
|
url: require2.resolve("url"),
|
|
599
583
|
fs: !1,
|
|
600
584
|
constants: require2.resolve("constants-browserify")
|
|
601
|
-
}, config.optimization ??= {}, config.optimization.runtimeChunk = !0, config.optimization.usedExports = options.build?.test?.disableTreeShaking ? !1 : isProd, config.optimization.moduleIds = "named", config.module ??= {}, config.module.parser ??= {}, config.module.parser.javascript ??= {}, config.module.parser.javascript.exportsPresence = !1, !
|
|
585
|
+
}, config.optimization ??= {}, config.optimization.runtimeChunk = !0, config.optimization.usedExports = options.build?.test?.disableTreeShaking ? !1 : isProd, config.optimization.moduleIds = "named", config.module ??= {}, config.module.parser ??= {}, config.module.parser.javascript ??= {}, config.module.parser.javascript.exportsPresence = !1, !rspack.experiments?.VirtualModulesPlugin)
|
|
602
586
|
throw new Error(
|
|
603
587
|
"rspack.experiments.VirtualModulesPlugin requires at least 1.5.0 version of @rsbuild/core, please upgrade or downgrade storybook-rsbuild-builder to lower version."
|
|
604
588
|
);
|
|
605
589
|
return config.plugins ??= [], config.plugins.push(
|
|
606
590
|
...[
|
|
607
|
-
Object.keys(virtualModuleMapping).length > 0 ? new
|
|
591
|
+
Object.keys(virtualModuleMapping).length > 0 ? new rspack.experiments.VirtualModulesPlugin(
|
|
608
592
|
virtualModuleMapping
|
|
609
593
|
) : null,
|
|
610
|
-
new
|
|
594
|
+
new rspack.ProvidePlugin({
|
|
611
595
|
process: require2.resolve("process/browser.js")
|
|
612
596
|
}),
|
|
613
597
|
new CaseSensitivePathsPlugin()
|
|
@@ -673,7 +657,7 @@ var getIsReactVersion18or19 = async (options) => {
|
|
|
673
657
|
await readFile(join3(reactDom, "package.json"), "utf-8")
|
|
674
658
|
);
|
|
675
659
|
return version.startsWith("18") || version.startsWith("19") || version.startsWith("0.0.0");
|
|
676
|
-
}, applyReactShims = async (
|
|
660
|
+
}, applyReactShims = async (_config, options) => await getIsReactVersion18or19(options) ? {} : {
|
|
677
661
|
resolve: {
|
|
678
662
|
alias: {
|
|
679
663
|
"@storybook/react-dom-shim": "@storybook/react-dom-shim/react-16"
|
|
@@ -737,8 +721,7 @@ var start = async ({
|
|
|
737
721
|
startTime,
|
|
738
722
|
options,
|
|
739
723
|
router,
|
|
740
|
-
server: storybookServer
|
|
741
|
-
channel
|
|
724
|
+
server: storybookServer
|
|
742
725
|
}) => {
|
|
743
726
|
overrideRsbuildLogger();
|
|
744
727
|
let { createRsbuild } = await executor.get(options), config = await getConfig(options), rsbuildBuild = await createRsbuild({
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_9f7479727fe3f3ec from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_9f7479727fe3f3ec from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_9f7479727fe3f3ec from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_9f7479727fe3f3ec.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_9f7479727fe3f3ec.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_9f7479727fe3f3ec.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 "../_node-chunks/chunk-
|
|
12
|
+
import "../_node-chunks/chunk-IFQ2M2R3.js";
|
|
13
13
|
|
|
14
14
|
// src/loaders/export-order-loader.ts
|
|
15
15
|
import assert from "node:assert";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import CJS_COMPAT_NODE_URL_9f7479727fe3f3ec from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_9f7479727fe3f3ec from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_9f7479727fe3f3ec from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_9f7479727fe3f3ec.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_9f7479727fe3f3ec.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_9f7479727fe3f3ec.createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
import "../_node-chunks/chunk-IFQ2M2R3.js";
|
|
13
|
+
|
|
14
|
+
// src/loaders/rsbuild-automock-loader.ts
|
|
15
|
+
import { babelParser, getAutomockCode } from "storybook/internal/mocking-utils";
|
|
16
|
+
function rsbuildAutomockLoader(source) {
|
|
17
|
+
let isSpy = this.getOptions().spy === "true";
|
|
18
|
+
return getAutomockCode(source, isSpy, babelParser).toString();
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
rsbuildAutomockLoader as default
|
|
22
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import CJS_COMPAT_NODE_URL_9f7479727fe3f3ec from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_9f7479727fe3f3ec from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_9f7479727fe3f3ec from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_9f7479727fe3f3ec.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_9f7479727fe3f3ec.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_9f7479727fe3f3ec.createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
import "../_node-chunks/chunk-IFQ2M2R3.js";
|
|
13
|
+
|
|
14
|
+
// src/loaders/storybook-mock-transform-loader.ts
|
|
15
|
+
import { rewriteSbMockImportCalls } from "storybook/internal/mocking-utils";
|
|
16
|
+
import { logger } from "storybook/internal/node-logger";
|
|
17
|
+
var storybookMockTransformLoader = function(source, sourceMap, meta) {
|
|
18
|
+
let callback = this.async();
|
|
19
|
+
try {
|
|
20
|
+
let result = rewriteSbMockImportCalls(source);
|
|
21
|
+
callback(null, result.code, result.map || void 0, meta);
|
|
22
|
+
} catch (error) {
|
|
23
|
+
logger.debug(
|
|
24
|
+
`Could not transform sb.mock(import(...)) calls in ${this.resourcePath}: ${error}`
|
|
25
|
+
), callback(null, source, sourceMap, meta);
|
|
26
|
+
}
|
|
27
|
+
}, storybook_mock_transform_loader_default = storybookMockTransformLoader;
|
|
28
|
+
export {
|
|
29
|
+
storybook_mock_transform_loader_default as default
|
|
30
|
+
};
|
package/dist/preview-preset.js
CHANGED
|
@@ -1,20 +1,171 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_9f7479727fe3f3ec from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_9f7479727fe3f3ec from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_9f7479727fe3f3ec from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_9f7479727fe3f3ec.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_9f7479727fe3f3ec.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_9f7479727fe3f3ec.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 "./_node-chunks/chunk-IFQ2M2R3.js";
|
|
13
|
+
|
|
14
|
+
// src/preview-preset.ts
|
|
15
|
+
import { createRequire } from "node:module";
|
|
16
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
17
|
+
import { findConfigFile } from "storybook/internal/common";
|
|
18
|
+
|
|
19
|
+
// src/plugins/rspack-inject-mocker-runtime-plugin.ts
|
|
20
|
+
import { getMockerRuntime } from "storybook/internal/mocking-utils";
|
|
21
|
+
var PLUGIN_NAME = "RspackInjectMockerRuntimePlugin", RspackInjectMockerRuntimePlugin = class {
|
|
22
|
+
getHtmlPlugin(compiler) {
|
|
23
|
+
try {
|
|
24
|
+
return compiler.options.plugins?.find((plugin) => {
|
|
25
|
+
let name = plugin?.constructor?.name;
|
|
26
|
+
return name === "HtmlRspackPlugin" || name === "HtmlWebpackPlugin";
|
|
27
|
+
})?.constructor;
|
|
28
|
+
} catch (error) {
|
|
29
|
+
return compiler.getInfrastructureLogger(PLUGIN_NAME).warn(
|
|
30
|
+
`Unable to locate HTML plugin for mock runtime injection: ${error}`
|
|
31
|
+
), null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
apply(compiler) {
|
|
35
|
+
let HtmlPlugin = this.getHtmlPlugin(compiler);
|
|
36
|
+
if (!HtmlPlugin || typeof HtmlPlugin.getHooks != "function") {
|
|
37
|
+
compiler.getInfrastructureLogger(PLUGIN_NAME).warn("HTML plugin is not available. Cannot inject mocker runtime.");
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
41
|
+
HtmlPlugin.getHooks(compilation).beforeAssetTagGeneration.tapAsync(
|
|
42
|
+
PLUGIN_NAME,
|
|
43
|
+
(data, cb) => {
|
|
44
|
+
try {
|
|
45
|
+
let runtimeScriptContent = getMockerRuntime(), runtimeAssetName = "./mocker-runtime-injected.js", Sources = compiler.webpack?.sources;
|
|
46
|
+
if (!Sources?.RawSource)
|
|
47
|
+
throw new Error(
|
|
48
|
+
"rspack sources is not available on compiler.webpack"
|
|
49
|
+
);
|
|
50
|
+
compilation.emitAsset(
|
|
51
|
+
runtimeAssetName,
|
|
52
|
+
new Sources.RawSource(runtimeScriptContent)
|
|
53
|
+
), data.assets.js.unshift(runtimeAssetName), cb(null, data);
|
|
54
|
+
} catch (error) {
|
|
55
|
+
cb(error);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// src/plugins/rspack-mock-plugin.ts
|
|
64
|
+
import { dirname, isAbsolute } from "node:path";
|
|
65
|
+
import { fileURLToPath } from "node:url";
|
|
66
|
+
import { rspack } from "@rsbuild/core";
|
|
67
|
+
import { findMockRedirect } from "@vitest/mocker/redirect";
|
|
12
68
|
import {
|
|
13
|
-
|
|
14
|
-
|
|
69
|
+
babelParser,
|
|
70
|
+
extractMockCalls,
|
|
71
|
+
getIsExternal,
|
|
72
|
+
resolveExternalModule,
|
|
73
|
+
resolveWithExtensions
|
|
74
|
+
} from "storybook/internal/mocking-utils";
|
|
75
|
+
var PLUGIN_NAME2 = "RspackMockPlugin";
|
|
76
|
+
function normalizePath(filePath) {
|
|
77
|
+
return filePath.replace(/\\/g, "/");
|
|
78
|
+
}
|
|
79
|
+
var RspackMockPlugin = class {
|
|
80
|
+
constructor(options) {
|
|
81
|
+
this.mockMap = /* @__PURE__ */ new Map();
|
|
82
|
+
if (!options.previewConfigPath)
|
|
83
|
+
throw new Error(`[${PLUGIN_NAME2}] \`previewConfigPath\` is required.`);
|
|
84
|
+
this.options = options;
|
|
85
|
+
}
|
|
86
|
+
apply(compiler) {
|
|
87
|
+
let logger = compiler.getInfrastructureLogger(PLUGIN_NAME2), updateMocks = () => {
|
|
88
|
+
this.mockMap = new Map(
|
|
89
|
+
this.extractAndResolveMocks(compiler).flatMap((mock) => [
|
|
90
|
+
[normalizePath(mock.absolutePath), mock],
|
|
91
|
+
[normalizePath(mock.absolutePath.replace(/\.[^.]+$/, "")), mock]
|
|
92
|
+
])
|
|
93
|
+
), logger.info(`Mock map updated with ${this.mockMap.size / 2} mocks.`);
|
|
94
|
+
};
|
|
95
|
+
compiler.hooks.beforeRun.tap(PLUGIN_NAME2, updateMocks), compiler.hooks.watchRun.tap(PLUGIN_NAME2, updateMocks), new rspack.NormalModuleReplacementPlugin(/.*/, (resource) => {
|
|
96
|
+
try {
|
|
97
|
+
let path = resource.request, importer = resource.context, absolutePath = getIsExternal(path, importer) ? resolveExternalModule(path, importer) : resolveWithExtensions(path, importer), normalizedAbsolutePath = normalizePath(absolutePath);
|
|
98
|
+
this.mockMap.has(normalizedAbsolutePath) && (resource.request = this.mockMap.get(
|
|
99
|
+
normalizedAbsolutePath
|
|
100
|
+
).replacementResource);
|
|
101
|
+
} catch {
|
|
102
|
+
logger.debug(`Could not resolve mock for "${resource.request}".`);
|
|
103
|
+
}
|
|
104
|
+
}).apply(compiler), compiler.hooks.afterCompile.tap(PLUGIN_NAME2, (compilation) => {
|
|
105
|
+
compilation.fileDependencies.add(this.options.previewConfigPath);
|
|
106
|
+
for (let mock of this.mockMap.values())
|
|
107
|
+
isAbsolute(mock.replacementResource) && mock.replacementResource.includes("__mocks__") && compilation.contextDependencies.add(dirname(mock.replacementResource));
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
extractAndResolveMocks(compiler) {
|
|
111
|
+
let { previewConfigPath, configDir } = this.options, logger = compiler.getInfrastructureLogger(PLUGIN_NAME2), mocks = extractMockCalls(
|
|
112
|
+
{
|
|
113
|
+
previewConfigPath,
|
|
114
|
+
configDir: configDir ?? dirname(previewConfigPath)
|
|
115
|
+
},
|
|
116
|
+
babelParser,
|
|
117
|
+
compiler.context,
|
|
118
|
+
findMockRedirect
|
|
119
|
+
), resolvedMocks = [];
|
|
120
|
+
for (let mock of mocks)
|
|
121
|
+
try {
|
|
122
|
+
let { absolutePath, redirectPath } = mock, replacementResource;
|
|
123
|
+
redirectPath ? replacementResource = redirectPath : replacementResource = `${fileURLToPath(
|
|
124
|
+
import.meta.resolve(
|
|
125
|
+
"storybook-builder-rsbuild/loaders/rsbuild-automock-loader"
|
|
126
|
+
)
|
|
127
|
+
)}?spy=${mock.spy}!${absolutePath}`, resolvedMocks.push({
|
|
128
|
+
...mock,
|
|
129
|
+
replacementResource
|
|
130
|
+
});
|
|
131
|
+
} catch {
|
|
132
|
+
logger.warn(
|
|
133
|
+
`Could not resolve mock for "${mock.path}". It will be ignored.`
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
return resolvedMocks;
|
|
137
|
+
}
|
|
138
|
+
};
|
|
15
139
|
|
|
16
140
|
// src/preview-preset.ts
|
|
17
|
-
var previewMainTemplate = () =>
|
|
141
|
+
var require2 = createRequire(import.meta.url), previewMainTemplate = () => require2.resolve("storybook-builder-rsbuild/templates/preview.ejs");
|
|
142
|
+
async function rsbuildFinal(config, options) {
|
|
143
|
+
let previewConfigPath = findConfigFile("preview", options.configDir);
|
|
144
|
+
if (!previewConfigPath)
|
|
145
|
+
return config;
|
|
146
|
+
let applyMocking = (rspackConfig, utils) => (utils.addRules({
|
|
147
|
+
test: /preview\.(t|j)sx?$/,
|
|
148
|
+
use: [
|
|
149
|
+
{
|
|
150
|
+
loader: fileURLToPath2(
|
|
151
|
+
import.meta.resolve(
|
|
152
|
+
"storybook-builder-rsbuild/loaders/storybook-mock-transform-loader"
|
|
153
|
+
)
|
|
154
|
+
)
|
|
155
|
+
}
|
|
156
|
+
]
|
|
157
|
+
}), rspackConfig.plugins ??= [], rspackConfig.plugins.push(new RspackMockPlugin({ previewConfigPath })), rspackConfig.plugins.push(new RspackInjectMockerRuntimePlugin()), rspackConfig);
|
|
158
|
+
return {
|
|
159
|
+
...config,
|
|
160
|
+
tools: {
|
|
161
|
+
...config.tools,
|
|
162
|
+
rspack: Array.isArray(config.tools?.rspack) ? [...config.tools.rspack, applyMocking] : [config.tools?.rspack, applyMocking].filter(
|
|
163
|
+
(v) => !!v
|
|
164
|
+
)
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
}
|
|
18
168
|
export {
|
|
19
|
-
previewMainTemplate
|
|
169
|
+
previewMainTemplate,
|
|
170
|
+
rsbuildFinal
|
|
20
171
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "storybook-builder-rsbuild",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "Rsbuild builder for Storybook",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook",
|
|
@@ -24,6 +24,8 @@
|
|
|
24
24
|
"default": "./dist/index.js"
|
|
25
25
|
},
|
|
26
26
|
"./loaders/export-order-loader": "./dist/loaders/export-order-loader.js",
|
|
27
|
+
"./loaders/rsbuild-automock-loader": "./dist/loaders/rsbuild-automock-loader.js",
|
|
28
|
+
"./loaders/storybook-mock-transform-loader": "./dist/loaders/storybook-mock-transform-loader.js",
|
|
27
29
|
"./package.json": "./package.json",
|
|
28
30
|
"./presets/preview-preset": "./dist/preview-preset.js",
|
|
29
31
|
"./templates/preview.ejs": "./templates/preview.ejs",
|
|
@@ -41,16 +43,17 @@
|
|
|
41
43
|
"!src/**/*"
|
|
42
44
|
],
|
|
43
45
|
"dependencies": {
|
|
44
|
-
"@rsbuild/plugin-type-check": "^1.2
|
|
46
|
+
"@rsbuild/plugin-type-check": "^1.3.2",
|
|
47
|
+
"@vitest/mocker": "3.2.4",
|
|
45
48
|
"browser-assert": "^1.2.1",
|
|
46
49
|
"case-sensitive-paths-webpack-plugin": "^2.4.0",
|
|
47
|
-
"cjs-module-lexer": "^1.
|
|
50
|
+
"cjs-module-lexer": "^2.1.1",
|
|
48
51
|
"constants-browserify": "^1.0.0",
|
|
49
52
|
"es-module-lexer": "^1.7.0",
|
|
50
53
|
"fs-extra": "^11.3.2",
|
|
51
54
|
"magic-string": "^0.30.21",
|
|
52
55
|
"path-browserify": "^1.0.1",
|
|
53
|
-
"picocolors": "^1.1.
|
|
56
|
+
"picocolors": "^1.1.1",
|
|
54
57
|
"process": "^0.11.10",
|
|
55
58
|
"rsbuild-plugin-html-minifier-terser": "^1.1.2",
|
|
56
59
|
"sirv": "^2.0.4",
|
|
@@ -60,24 +63,22 @@
|
|
|
60
63
|
"util-deprecate": "^1.0.2"
|
|
61
64
|
},
|
|
62
65
|
"devDependencies": {
|
|
63
|
-
"@rsbuild/core": "^1.6.
|
|
64
|
-
"@storybook/core-webpack": "
|
|
65
|
-
"@types/find-cache-dir": "^5.0.2",
|
|
66
|
+
"@rsbuild/core": "^1.6.13",
|
|
67
|
+
"@storybook/core-webpack": "10.1.2",
|
|
66
68
|
"@types/fs-extra": "^11.0.4",
|
|
67
69
|
"@types/node": "^22.0.0",
|
|
68
70
|
"@types/pretty-hrtime": "^1.0.3",
|
|
69
|
-
"find-cache-dir": "^5.0.0",
|
|
70
71
|
"prebundle": "^1.6.0",
|
|
71
72
|
"pretty-hrtime": "^1.0.3",
|
|
72
73
|
"slash": "^5.1.0",
|
|
73
|
-
"storybook": "10.
|
|
74
|
+
"storybook": "10.1.2",
|
|
74
75
|
"typescript": "^5.9.3"
|
|
75
76
|
},
|
|
76
77
|
"peerDependencies": {
|
|
77
78
|
"@rsbuild/core": "^1.5.0",
|
|
78
|
-
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
|
|
79
|
-
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
|
|
80
|
-
"storybook": "^10.
|
|
79
|
+
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
80
|
+
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
81
|
+
"storybook": "^10.1.0"
|
|
81
82
|
},
|
|
82
83
|
"peerDependenciesMeta": {
|
|
83
84
|
"react": {
|
|
@@ -97,7 +98,9 @@
|
|
|
97
98
|
"entries": [
|
|
98
99
|
"./src/index.ts",
|
|
99
100
|
"./src/preview-preset.ts",
|
|
100
|
-
"./src/loaders/export-order-loader.ts"
|
|
101
|
+
"./src/loaders/export-order-loader.ts",
|
|
102
|
+
"./src/loaders/storybook-mock-transform-loader.ts",
|
|
103
|
+
"./src/loaders/rsbuild-automock-loader.ts"
|
|
101
104
|
],
|
|
102
105
|
"platform": "node"
|
|
103
106
|
},
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
+
import { importFn } from '{{storiesFilename}}'
|
|
2
|
+
import { global } from '@storybook/global'
|
|
1
3
|
import { createBrowserChannel } from 'storybook/internal/channels'
|
|
2
4
|
import { STORY_HOT_UPDATED } from 'storybook/internal/core-events'
|
|
3
5
|
import { isPreview } from 'storybook/internal/csf'
|
|
4
|
-
|
|
5
|
-
import { global } from '@storybook/global'
|
|
6
|
-
|
|
7
|
-
import { PreviewWeb, addons, composeConfigs } from 'storybook/preview-api'
|
|
8
|
-
import { importFn } from '{{storiesFilename}}'
|
|
6
|
+
import { addons, composeConfigs, PreviewWeb } from 'storybook/preview-api'
|
|
9
7
|
|
|
10
8
|
const getProjectAnnotations = () => {
|
|
11
9
|
const previewAnnotations = ['{{previewAnnotations_requires}}']
|