storybook-builder-rsbuild 2.0.1 → 2.0.3

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.js CHANGED
@@ -416,8 +416,6 @@ var iframe_rsbuild_config_default = async (options, extraWebpackConfig) => {
416
416
  } else {
417
417
  contentFromConfig = content;
418
418
  }
419
- contentFromConfig.source ??= {};
420
- contentFromConfig.source.entry = {};
421
419
  const resourceFilename = isProd ? "static/media/[name].[contenthash:8][ext]" : "static/media/[path][name][ext]";
422
420
  const rsbuildConfig = (0, import_core.mergeRsbuildConfig)(contentFromConfig, {
423
421
  output: {
@@ -459,10 +457,6 @@ var iframe_rsbuild_config_default = async (options, extraWebpackConfig) => {
459
457
  // TODO: Rspack doesn't support virtual modules yet, use cache dir instead
460
458
  // we needed to explicitly set the module in `node_modules` to be compiled
461
459
  include: [/[\\/]node_modules[\\/].*[\\/]storybook-config-entry\.js/],
462
- entry: {
463
- // to avoid `It's not allowed to load an initial chunk on demand. The chunk name "main" is already used by an entrypoint` of
464
- main: [...entries ?? [], ...dynamicEntries]
465
- },
466
460
  define: {
467
461
  ...(0, import_common2.stringifyProcessEnvs)(envs),
468
462
  NODE_ENV: JSON.stringify(process.env.NODE_ENV)
@@ -486,7 +480,41 @@ var iframe_rsbuild_config_default = async (options, extraWebpackConfig) => {
486
480
  removeScriptTypeAttributes: false,
487
481
  removeStyleLinkTypeAttributes: true,
488
482
  useShortDoctype: true
489
- }))
483
+ })),
484
+ {
485
+ name: "storybook-config-entry",
486
+ setup: (api) => {
487
+ api.modifyEnvironmentConfig({
488
+ handler: (config, { mergeEnvironmentConfig }) => {
489
+ const baseConfig = { ...config };
490
+ delete baseConfig.source.entry;
491
+ return mergeEnvironmentConfig(config, {
492
+ // Reset `config.source.entry` field, do not use provided entry
493
+ // see https://github.com/rspack-contrib/storybook-rsbuild/issues/43
494
+ source: {
495
+ entry: {
496
+ main: [...entries ?? [], ...dynamicEntries]
497
+ }
498
+ },
499
+ tools: {
500
+ rspack: {
501
+ experiments: {
502
+ outputModule: false
503
+ },
504
+ externalsType: "var",
505
+ output: {
506
+ module: false,
507
+ chunkFormat: "array-push",
508
+ chunkLoading: "jsonp"
509
+ }
510
+ }
511
+ }
512
+ });
513
+ },
514
+ order: "post"
515
+ });
516
+ }
517
+ }
490
518
  ].filter(Boolean),
491
519
  tools: {
492
520
  rspack: (config, { addRules, appendPlugins, rspack, mergeConfig }) => {
@@ -664,18 +692,18 @@ var rsbuild = async (_, options) => {
664
692
  },
665
693
  options
666
694
  );
667
- let defaultConfig = await iframe_rsbuild_config_default(options, webpackAddonsConfig);
668
- const shimsConfig = await applyReactShims(defaultConfig, options);
669
- defaultConfig = rsbuildReal.mergeRsbuildConfig(
670
- defaultConfig,
695
+ let intrinsicRsbuildConfig = await iframe_rsbuild_config_default(options, webpackAddonsConfig);
696
+ const shimsConfig = await applyReactShims(intrinsicRsbuildConfig, options);
697
+ intrinsicRsbuildConfig = rsbuildReal.mergeRsbuildConfig(
698
+ intrinsicRsbuildConfig,
671
699
  shimsConfig
672
700
  );
673
- const finalDefaultConfig = await presets.apply(
701
+ const finalConfig = await presets.apply(
674
702
  "rsbuildFinal",
675
- defaultConfig,
703
+ intrinsicRsbuildConfig,
676
704
  options
677
705
  );
678
- return finalDefaultConfig;
706
+ return finalConfig;
679
707
  };
680
708
  var getConfig = async (options) => {
681
709
  const { presets } = options;
package/dist/index.mjs CHANGED
@@ -360,8 +360,6 @@ var iframe_rsbuild_config_default = async (options, extraWebpackConfig) => {
360
360
  } else {
361
361
  contentFromConfig = content;
362
362
  }
363
- contentFromConfig.source ??= {};
364
- contentFromConfig.source.entry = {};
365
363
  const resourceFilename = isProd ? "static/media/[name].[contenthash:8][ext]" : "static/media/[path][name][ext]";
366
364
  const rsbuildConfig = mergeRsbuildConfig(contentFromConfig, {
367
365
  output: {
@@ -403,10 +401,6 @@ var iframe_rsbuild_config_default = async (options, extraWebpackConfig) => {
403
401
  // TODO: Rspack doesn't support virtual modules yet, use cache dir instead
404
402
  // we needed to explicitly set the module in `node_modules` to be compiled
405
403
  include: [/[\\/]node_modules[\\/].*[\\/]storybook-config-entry\.js/],
406
- entry: {
407
- // to avoid `It's not allowed to load an initial chunk on demand. The chunk name "main" is already used by an entrypoint` of
408
- main: [...entries ?? [], ...dynamicEntries]
409
- },
410
404
  define: {
411
405
  ...stringifyProcessEnvs(envs),
412
406
  NODE_ENV: JSON.stringify(process.env.NODE_ENV)
@@ -430,7 +424,41 @@ var iframe_rsbuild_config_default = async (options, extraWebpackConfig) => {
430
424
  removeScriptTypeAttributes: false,
431
425
  removeStyleLinkTypeAttributes: true,
432
426
  useShortDoctype: true
433
- }))
427
+ })),
428
+ {
429
+ name: "storybook-config-entry",
430
+ setup: (api) => {
431
+ api.modifyEnvironmentConfig({
432
+ handler: (config, { mergeEnvironmentConfig }) => {
433
+ const baseConfig = { ...config };
434
+ delete baseConfig.source.entry;
435
+ return mergeEnvironmentConfig(config, {
436
+ // Reset `config.source.entry` field, do not use provided entry
437
+ // see https://github.com/rspack-contrib/storybook-rsbuild/issues/43
438
+ source: {
439
+ entry: {
440
+ main: [...entries ?? [], ...dynamicEntries]
441
+ }
442
+ },
443
+ tools: {
444
+ rspack: {
445
+ experiments: {
446
+ outputModule: false
447
+ },
448
+ externalsType: "var",
449
+ output: {
450
+ module: false,
451
+ chunkFormat: "array-push",
452
+ chunkLoading: "jsonp"
453
+ }
454
+ }
455
+ }
456
+ });
457
+ },
458
+ order: "post"
459
+ });
460
+ }
461
+ }
434
462
  ].filter(Boolean),
435
463
  tools: {
436
464
  rspack: (config, { addRules, appendPlugins, rspack, mergeConfig }) => {
@@ -606,18 +634,18 @@ var rsbuild = async (_, options) => {
606
634
  },
607
635
  options
608
636
  );
609
- let defaultConfig = await iframe_rsbuild_config_default(options, webpackAddonsConfig);
610
- const shimsConfig = await applyReactShims(defaultConfig, options);
611
- defaultConfig = rsbuildReal.mergeRsbuildConfig(
612
- defaultConfig,
637
+ let intrinsicRsbuildConfig = await iframe_rsbuild_config_default(options, webpackAddonsConfig);
638
+ const shimsConfig = await applyReactShims(intrinsicRsbuildConfig, options);
639
+ intrinsicRsbuildConfig = rsbuildReal.mergeRsbuildConfig(
640
+ intrinsicRsbuildConfig,
613
641
  shimsConfig
614
642
  );
615
- const finalDefaultConfig = await presets.apply(
643
+ const finalConfig = await presets.apply(
616
644
  "rsbuildFinal",
617
- defaultConfig,
645
+ intrinsicRsbuildConfig,
618
646
  options
619
647
  );
620
- return finalDefaultConfig;
648
+ return finalConfig;
621
649
  };
622
650
  var getConfig = async (options) => {
623
651
  const { presets } = options;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "storybook-builder-rsbuild",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "Rsbuild builder for Storybook",
5
5
  "keywords": [
6
6
  "storybook",
@@ -57,9 +57,9 @@
57
57
  "!src/**/*"
58
58
  ],
59
59
  "dependencies": {
60
- "@rsbuild/plugin-type-check": "^1.2.2",
61
- "@storybook/addon-docs": "^9.0.4",
62
- "@storybook/core-webpack": "^9.0.4",
60
+ "@rsbuild/plugin-type-check": "^1.2.3",
61
+ "@storybook/addon-docs": "^9.0.18",
62
+ "@storybook/core-webpack": "^9.0.18",
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.3.22",
81
+ "@rsbuild/core": "^1.4.11",
82
82
  "@types/find-cache-dir": "^5.0.2",
83
83
  "@types/fs-extra": "^11.0.4",
84
84
  "@types/node": "^18.19.110",
85
85
  "@types/pretty-hrtime": "^1.0.3",
86
86
  "pretty-hrtime": "^1.0.3",
87
87
  "slash": "^5.1.0",
88
- "storybook": "9.0.4",
88
+ "storybook": "9.0.18",
89
89
  "typescript": "^5.8.3"
90
90
  },
91
91
  "peerDependencies": {