storybook-builder-rsbuild 1.0.0 → 1.0.2
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/index.d.ts +6 -1
- package/dist/index.js +25 -16
- package/dist/index.mjs +25 -16
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
@@ -29,7 +29,12 @@ type BuilderOptions = {
|
|
29
29
|
/**
|
30
30
|
* Enable Rspack's lazy compilation (experimental).
|
31
31
|
*/
|
32
|
-
lazyCompilation?:
|
32
|
+
lazyCompilation?: NonNullable<RsbuildConfig['performance']>['buildCache'];
|
33
|
+
/**
|
34
|
+
* Enable Rspack's [persistent cache(experimental)](https://rspack.dev/config/experiments#experimentscache).
|
35
|
+
* We continue to use the name `fsCache` here to maintain better compatibility with the webpack builder.
|
36
|
+
*/
|
37
|
+
fsCache?: boolean;
|
33
38
|
/**
|
34
39
|
* Which environment to use from the Rsbuild config.
|
35
40
|
*/
|
package/dist/index.js
CHANGED
@@ -133,7 +133,7 @@ var import_server_errors = require("storybook/internal/server-errors");
|
|
133
133
|
var import_node_path3 = require("path");
|
134
134
|
var import_core = require("@rsbuild/core");
|
135
135
|
var import_plugin_type_check = require("@rsbuild/plugin-type-check");
|
136
|
-
var import_preset = require("@storybook/addon-docs/
|
136
|
+
var import_preset = require("@storybook/addon-docs/preset");
|
137
137
|
var import_case_sensitive_paths_webpack_plugin = __toESM(require("case-sensitive-paths-webpack-plugin"));
|
138
138
|
var import_rsbuild_plugin_html_minifier_terser = require("rsbuild-plugin-html-minifier-terser");
|
139
139
|
var import_common2 = require("storybook/internal/common");
|
@@ -296,6 +296,15 @@ var maybeGetAbsolutePath = (input) => {
|
|
296
296
|
return false;
|
297
297
|
}
|
298
298
|
};
|
299
|
+
var builtInResolveExtensions = [
|
300
|
+
".mjs",
|
301
|
+
".js",
|
302
|
+
".jsx",
|
303
|
+
".ts",
|
304
|
+
".tsx",
|
305
|
+
".json",
|
306
|
+
".cjs"
|
307
|
+
];
|
299
308
|
var managerAPIPath = maybeGetAbsolutePath("@storybook/manager-api");
|
300
309
|
var componentsPath = maybeGetAbsolutePath("@storybook/components");
|
301
310
|
var globalPath = maybeGetAbsolutePath("@storybook/global");
|
@@ -361,6 +370,7 @@ var iframe_rsbuild_config_default = async (options, extraWebpackConfig) => {
|
|
361
370
|
const shouldCheckTs = typescriptOptions.check && !typescriptOptions.skipCompiler;
|
362
371
|
const tsCheckOptions = typescriptOptions.checkOptions || {};
|
363
372
|
const builderOptions = await (0, import_common2.getBuilderOptions)(options);
|
373
|
+
const cacheConfig = builderOptions.fsCache ? true : void 0;
|
364
374
|
const lazyCompilationConfig = builderOptions.lazyCompilation && !isProd ? {
|
365
375
|
lazyCompilation: { entries: false }
|
366
376
|
} : {};
|
@@ -472,7 +482,8 @@ var iframe_rsbuild_config_default = async (options, extraWebpackConfig) => {
|
|
472
482
|
splitChunks: {
|
473
483
|
chunks: "all"
|
474
484
|
}
|
475
|
-
}
|
485
|
+
},
|
486
|
+
buildCache: cacheConfig
|
476
487
|
},
|
477
488
|
plugins: [
|
478
489
|
shouldCheckTs ? (0, import_plugin_type_check.pluginTypeCheck)(tsCheckOptions) : null,
|
@@ -499,15 +510,12 @@ var iframe_rsbuild_config_default = async (options, extraWebpackConfig) => {
|
|
499
510
|
});
|
500
511
|
config.resolve ??= {};
|
501
512
|
config.resolve.symlinks = !(0, import_common2.isPreservingSymlinks)();
|
502
|
-
config.resolve.extensions =
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
".json",
|
509
|
-
".cjs"
|
510
|
-
];
|
513
|
+
config.resolve.extensions = Array.from(
|
514
|
+
/* @__PURE__ */ new Set([
|
515
|
+
...config.resolve.extensions ?? [],
|
516
|
+
...builtInResolveExtensions
|
517
|
+
])
|
518
|
+
);
|
511
519
|
config.watchOptions = {
|
512
520
|
ignored: /node_modules/
|
513
521
|
};
|
@@ -547,7 +555,7 @@ var iframe_rsbuild_config_default = async (options, extraWebpackConfig) => {
|
|
547
555
|
...config.experiments,
|
548
556
|
...lazyCompilationConfig
|
549
557
|
};
|
550
|
-
return mergeConfig(config, extraWebpackConfig, appliedDocsWebpack);
|
558
|
+
return mergeConfig(config, extraWebpackConfig || {}, appliedDocsWebpack);
|
551
559
|
},
|
552
560
|
htmlPlugin: {
|
553
561
|
filename: "iframe.html",
|
@@ -635,22 +643,23 @@ var rsbuild = async (_, options) => {
|
|
635
643
|
const { presets } = options;
|
636
644
|
const webpackAddons = await presets.apply("webpackAddons");
|
637
645
|
const resolvedWebpackAddons = (webpackAddons ?? []).map((preset) => {
|
638
|
-
const
|
646
|
+
const addonOptions = isObject(preset) ? preset.options || void 0 : void 0;
|
639
647
|
const name = isObject(preset) ? preset.name : preset;
|
640
|
-
return (0, import_common3.resolveAddonName)(
|
648
|
+
return (0, import_common3.resolveAddonName)(options.configDir, name, addonOptions);
|
641
649
|
}).filter(nonNullables);
|
642
650
|
const { apply } = await (0, import_common3.getPresets)(resolvedWebpackAddons, options);
|
643
651
|
const webpackAddonsConfig = await apply(
|
644
652
|
"webpackFinal",
|
645
653
|
// TODO: using empty webpack config as base for now. It's better to using the composed rspack
|
646
654
|
// config in `iframe-rsbuild.config.ts` as base config. But when `tools.rspack` is an async function,
|
647
|
-
// the following `tools.rspack` raise an `
|
655
|
+
// the following `tools.rspack` raise an `Promises are not supported` error.
|
648
656
|
{
|
649
657
|
output: {},
|
650
658
|
module: {},
|
651
659
|
plugins: [],
|
652
660
|
resolve: {},
|
653
|
-
|
661
|
+
// https://github.com/web-infra-dev/rsbuild/blob/8dc35dc1d1500d2f119875d46b6a07e27986d532/packages/core/src/provider/rspackConfig.ts#L167
|
662
|
+
devServer: void 0,
|
654
663
|
optimization: {},
|
655
664
|
performance: {},
|
656
665
|
externals: {},
|
package/dist/index.mjs
CHANGED
@@ -9,7 +9,7 @@ import { corePath } from 'storybook/core-path';
|
|
9
9
|
import { normalizeStories, loadPreviewOrConfigFile, getBuilderOptions, readTemplate, resolveAddonName, getPresets, stringifyProcessEnvs, isPreservingSymlinks } from 'storybook/internal/common';
|
10
10
|
import { WebpackInvocationError } from 'storybook/internal/server-errors';
|
11
11
|
import { pluginTypeCheck } from '@rsbuild/plugin-type-check';
|
12
|
-
import { webpack } from '@storybook/addon-docs/
|
12
|
+
import { webpack } from '@storybook/addon-docs/preset';
|
13
13
|
import CaseSensitivePathsPlugin from 'case-sensitive-paths-webpack-plugin';
|
14
14
|
import { pluginHtmlMinifierTerser } from 'rsbuild-plugin-html-minifier-terser';
|
15
15
|
import { globalsNameReferenceMap } from 'storybook/internal/preview/globals';
|
@@ -240,6 +240,15 @@ var maybeGetAbsolutePath = (input) => {
|
|
240
240
|
return false;
|
241
241
|
}
|
242
242
|
};
|
243
|
+
var builtInResolveExtensions = [
|
244
|
+
".mjs",
|
245
|
+
".js",
|
246
|
+
".jsx",
|
247
|
+
".ts",
|
248
|
+
".tsx",
|
249
|
+
".json",
|
250
|
+
".cjs"
|
251
|
+
];
|
243
252
|
var managerAPIPath = maybeGetAbsolutePath("@storybook/manager-api");
|
244
253
|
var componentsPath = maybeGetAbsolutePath("@storybook/components");
|
245
254
|
var globalPath = maybeGetAbsolutePath("@storybook/global");
|
@@ -305,6 +314,7 @@ var iframe_rsbuild_config_default = async (options, extraWebpackConfig) => {
|
|
305
314
|
const shouldCheckTs = typescriptOptions.check && !typescriptOptions.skipCompiler;
|
306
315
|
const tsCheckOptions = typescriptOptions.checkOptions || {};
|
307
316
|
const builderOptions = await getBuilderOptions(options);
|
317
|
+
const cacheConfig = builderOptions.fsCache ? true : void 0;
|
308
318
|
const lazyCompilationConfig = builderOptions.lazyCompilation && !isProd ? {
|
309
319
|
lazyCompilation: { entries: false }
|
310
320
|
} : {};
|
@@ -416,7 +426,8 @@ var iframe_rsbuild_config_default = async (options, extraWebpackConfig) => {
|
|
416
426
|
splitChunks: {
|
417
427
|
chunks: "all"
|
418
428
|
}
|
419
|
-
}
|
429
|
+
},
|
430
|
+
buildCache: cacheConfig
|
420
431
|
},
|
421
432
|
plugins: [
|
422
433
|
shouldCheckTs ? pluginTypeCheck(tsCheckOptions) : null,
|
@@ -445,15 +456,12 @@ var iframe_rsbuild_config_default = async (options, extraWebpackConfig) => {
|
|
445
456
|
});
|
446
457
|
config.resolve ??= {};
|
447
458
|
config.resolve.symlinks = !isPreservingSymlinks();
|
448
|
-
config.resolve.extensions =
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
".json",
|
455
|
-
".cjs"
|
456
|
-
];
|
459
|
+
config.resolve.extensions = Array.from(
|
460
|
+
/* @__PURE__ */ new Set([
|
461
|
+
...config.resolve.extensions ?? [],
|
462
|
+
...builtInResolveExtensions
|
463
|
+
])
|
464
|
+
);
|
457
465
|
config.watchOptions = {
|
458
466
|
ignored: /node_modules/
|
459
467
|
};
|
@@ -493,7 +501,7 @@ var iframe_rsbuild_config_default = async (options, extraWebpackConfig) => {
|
|
493
501
|
...config.experiments,
|
494
502
|
...lazyCompilationConfig
|
495
503
|
};
|
496
|
-
return mergeConfig(config, extraWebpackConfig, appliedDocsWebpack);
|
504
|
+
return mergeConfig(config, extraWebpackConfig || {}, appliedDocsWebpack);
|
497
505
|
},
|
498
506
|
htmlPlugin: {
|
499
507
|
filename: "iframe.html",
|
@@ -577,22 +585,23 @@ var rsbuild = async (_, options) => {
|
|
577
585
|
const { presets } = options;
|
578
586
|
const webpackAddons = await presets.apply("webpackAddons");
|
579
587
|
const resolvedWebpackAddons = (webpackAddons ?? []).map((preset) => {
|
580
|
-
const
|
588
|
+
const addonOptions = isObject(preset) ? preset.options || void 0 : void 0;
|
581
589
|
const name = isObject(preset) ? preset.name : preset;
|
582
|
-
return resolveAddonName(
|
590
|
+
return resolveAddonName(options.configDir, name, addonOptions);
|
583
591
|
}).filter(nonNullables);
|
584
592
|
const { apply } = await getPresets(resolvedWebpackAddons, options);
|
585
593
|
const webpackAddonsConfig = await apply(
|
586
594
|
"webpackFinal",
|
587
595
|
// TODO: using empty webpack config as base for now. It's better to using the composed rspack
|
588
596
|
// config in `iframe-rsbuild.config.ts` as base config. But when `tools.rspack` is an async function,
|
589
|
-
// the following `tools.rspack` raise an `
|
597
|
+
// the following `tools.rspack` raise an `Promises are not supported` error.
|
590
598
|
{
|
591
599
|
output: {},
|
592
600
|
module: {},
|
593
601
|
plugins: [],
|
594
602
|
resolve: {},
|
595
|
-
|
603
|
+
// https://github.com/web-infra-dev/rsbuild/blob/8dc35dc1d1500d2f119875d46b6a07e27986d532/packages/core/src/provider/rspackConfig.ts#L167
|
604
|
+
devServer: void 0,
|
596
605
|
optimization: {},
|
597
606
|
performance: {},
|
598
607
|
externals: {},
|
package/package.json
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
{
|
2
2
|
"name": "storybook-builder-rsbuild",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.2",
|
4
4
|
"description": "Rsbuild builder for Storybook",
|
5
5
|
"keywords": [
|
6
6
|
"storybook",
|
7
7
|
"rsbuild",
|
8
8
|
"rspack"
|
9
9
|
],
|
10
|
-
"homepage": "https://storybook
|
10
|
+
"homepage": "https://storybook.rsbuild.dev",
|
11
11
|
"bugs": {
|
12
12
|
"url": "https://github.com/rspack-contrib/storybook-rsbuild/issues"
|
13
13
|
},
|
@@ -57,9 +57,9 @@
|
|
57
57
|
"!src/**/*"
|
58
58
|
],
|
59
59
|
"dependencies": {
|
60
|
-
"@rsbuild/plugin-type-check": "^1.2.
|
61
|
-
"@storybook/addon-docs": "^8.
|
62
|
-
"@storybook/core-webpack": "^8.
|
60
|
+
"@rsbuild/plugin-type-check": "^1.2.2",
|
61
|
+
"@storybook/addon-docs": "^8.6.14",
|
62
|
+
"@storybook/core-webpack": "^8.6.14",
|
63
63
|
"browser-assert": "^1.2.1",
|
64
64
|
"case-sensitive-paths-webpack-plugin": "^2.4.0",
|
65
65
|
"cjs-module-lexer": "^1.4.3",
|
@@ -78,14 +78,14 @@
|
|
78
78
|
"util-deprecate": "^1.0.2"
|
79
79
|
},
|
80
80
|
"devDependencies": {
|
81
|
-
"@rsbuild/core": "^1.
|
81
|
+
"@rsbuild/core": "^1.3.22",
|
82
82
|
"@types/find-cache-dir": "^5.0.2",
|
83
83
|
"@types/fs-extra": "^11.0.4",
|
84
84
|
"@types/node": "^18.0.0",
|
85
85
|
"@types/pretty-hrtime": "^1.0.3",
|
86
86
|
"pretty-hrtime": "^1.0.3",
|
87
87
|
"slash": "^5.1.0",
|
88
|
-
"storybook": "8.
|
88
|
+
"storybook": "8.6.14",
|
89
89
|
"typescript": "^5.7.3"
|
90
90
|
},
|
91
91
|
"peerDependencies": {
|