storybook-builder-rsbuild 1.0.0 → 2.0.0-alpha.1
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 +27 -28
- package/dist/index.mjs +26 -27
- package/package.json +8 -8
package/dist/index.js
CHANGED
@@ -125,7 +125,6 @@ var rsbuildReal = __toESM(require("@rsbuild/core"));
|
|
125
125
|
var import_fs_extra = __toESM(require("fs-extra"));
|
126
126
|
var import_pretty_hrtime = __toESM(require_pretty_hrtime());
|
127
127
|
var import_sirv = __toESM(require("sirv"));
|
128
|
-
var import_core_path = require("storybook/core-path");
|
129
128
|
var import_common3 = require("storybook/internal/common");
|
130
129
|
var import_server_errors = require("storybook/internal/server-errors");
|
131
130
|
|
@@ -296,19 +295,19 @@ var maybeGetAbsolutePath = (input) => {
|
|
296
295
|
return false;
|
297
296
|
}
|
298
297
|
};
|
299
|
-
var
|
300
|
-
|
298
|
+
var builtInResolveExtensions = [
|
299
|
+
".mjs",
|
300
|
+
".js",
|
301
|
+
".jsx",
|
302
|
+
".ts",
|
303
|
+
".tsx",
|
304
|
+
".json",
|
305
|
+
".cjs"
|
306
|
+
];
|
301
307
|
var globalPath = maybeGetAbsolutePath("@storybook/global");
|
302
|
-
var routerPath = maybeGetAbsolutePath("@storybook/router");
|
303
|
-
var themingPath = maybeGetAbsolutePath("@storybook/theming");
|
304
308
|
var storybookPaths = {
|
305
|
-
|
306
|
-
|
307
|
-
} : {},
|
308
|
-
...componentsPath ? { "@storybook/components": componentsPath } : {},
|
309
|
-
...globalPath ? { "@storybook/global": globalPath } : {},
|
310
|
-
...routerPath ? { "@storybook/router": routerPath } : {},
|
311
|
-
...themingPath ? { "@storybook/theming": themingPath } : {}
|
309
|
+
// biome-ignore lint/complexity/useLiteralKeys: <explanation>
|
310
|
+
...globalPath ? { ["@storybook/global"]: globalPath } : {}
|
312
311
|
};
|
313
312
|
var iframe_rsbuild_config_default = async (options, extraWebpackConfig) => {
|
314
313
|
const { rsbuildConfigPath, addonDocs } = await (0, import_common2.getBuilderOptions)(options);
|
@@ -499,15 +498,12 @@ var iframe_rsbuild_config_default = async (options, extraWebpackConfig) => {
|
|
499
498
|
});
|
500
499
|
config.resolve ??= {};
|
501
500
|
config.resolve.symlinks = !(0, import_common2.isPreservingSymlinks)();
|
502
|
-
config.resolve.extensions =
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
".json",
|
509
|
-
".cjs"
|
510
|
-
];
|
501
|
+
config.resolve.extensions = Array.from(
|
502
|
+
/* @__PURE__ */ new Set([
|
503
|
+
...config.resolve.extensions ?? [],
|
504
|
+
...builtInResolveExtensions
|
505
|
+
])
|
506
|
+
);
|
511
507
|
config.watchOptions = {
|
512
508
|
ignored: /node_modules/
|
513
509
|
};
|
@@ -596,7 +592,8 @@ var getIsReactVersion18or19 = async (options) => {
|
|
596
592
|
"resolvedReact",
|
597
593
|
{}
|
598
594
|
);
|
599
|
-
|
595
|
+
let reactDom = "";
|
596
|
+
reactDom = resolvedReact.reactDom || (0, import_node_path4.dirname)(require.resolve("react-dom/package.json"));
|
600
597
|
if (!(0, import_node_path4.isAbsolute)(reactDom)) {
|
601
598
|
return false;
|
602
599
|
}
|
@@ -620,6 +617,7 @@ var applyReactShims = async (config, options) => {
|
|
620
617
|
};
|
621
618
|
|
622
619
|
// src/index.ts
|
620
|
+
var corePath = (0, import_node_path5.dirname)(require.resolve("storybook/package.json"));
|
623
621
|
var printDuration = (startTime) => (0, import_pretty_hrtime.default)(process.hrtime(startTime)).replace(" ms", " milliseconds").replace(" s", " seconds").replace(" m", " minutes");
|
624
622
|
var executor = {
|
625
623
|
get: async (options) => {
|
@@ -635,22 +633,23 @@ var rsbuild = async (_, options) => {
|
|
635
633
|
const { presets } = options;
|
636
634
|
const webpackAddons = await presets.apply("webpackAddons");
|
637
635
|
const resolvedWebpackAddons = (webpackAddons ?? []).map((preset) => {
|
638
|
-
const
|
636
|
+
const addonOptions = isObject(preset) ? preset.options || void 0 : void 0;
|
639
637
|
const name = isObject(preset) ? preset.name : preset;
|
640
|
-
return (0, import_common3.resolveAddonName)(
|
638
|
+
return (0, import_common3.resolveAddonName)(options.configDir, name, addonOptions);
|
641
639
|
}).filter(nonNullables);
|
642
640
|
const { apply } = await (0, import_common3.getPresets)(resolvedWebpackAddons, options);
|
643
641
|
const webpackAddonsConfig = await apply(
|
644
642
|
"webpackFinal",
|
645
643
|
// TODO: using empty webpack config as base for now. It's better to using the composed rspack
|
646
644
|
// config in `iframe-rsbuild.config.ts` as base config. But when `tools.rspack` is an async function,
|
647
|
-
// the following `tools.rspack` raise an `
|
645
|
+
// the following `tools.rspack` raise an `Promises are not supported` error.
|
648
646
|
{
|
649
647
|
output: {},
|
650
648
|
module: {},
|
651
649
|
plugins: [],
|
652
650
|
resolve: {},
|
653
|
-
|
651
|
+
// https://github.com/web-infra-dev/rsbuild/blob/8dc35dc1d1500d2f119875d46b6a07e27986d532/packages/core/src/provider/rspackConfig.ts#L167
|
652
|
+
devServer: void 0,
|
654
653
|
optimization: {},
|
655
654
|
performance: {},
|
656
655
|
externals: {},
|
@@ -726,7 +725,7 @@ var start = async ({
|
|
726
725
|
error: new Error("Missing Rsbuild build instance at runtime!")
|
727
726
|
});
|
728
727
|
}
|
729
|
-
const previewResolvedDir = (0, import_node_path5.join)(
|
728
|
+
const previewResolvedDir = (0, import_node_path5.join)(corePath, "dist/preview");
|
730
729
|
const previewDirOrigin = previewResolvedDir;
|
731
730
|
router.use(
|
732
731
|
"/sb-preview",
|
@@ -749,7 +748,7 @@ var build = async ({ options }) => {
|
|
749
748
|
cwd: process.cwd(),
|
750
749
|
rsbuildConfig: config
|
751
750
|
});
|
752
|
-
const previewResolvedDir = (0, import_node_path5.join)(
|
751
|
+
const previewResolvedDir = (0, import_node_path5.join)(corePath, "dist/preview");
|
753
752
|
const previewDirOrigin = previewResolvedDir;
|
754
753
|
const previewDirTarget = (0, import_node_path5.join)(options.outputDir || "", "sb-preview");
|
755
754
|
let stats;
|
package/dist/index.mjs
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
import { __commonJS, __toESM, __require } from './chunk-TTFRSOOU.mjs';
|
2
2
|
import { createServer } from 'net';
|
3
|
-
import path, { join, resolve, parse,
|
3
|
+
import path, { dirname, join, resolve, parse, isAbsolute } from 'path';
|
4
4
|
import * as rsbuildReal from '@rsbuild/core';
|
5
5
|
import { loadConfig, mergeRsbuildConfig } from '@rsbuild/core';
|
6
6
|
import fs2 from 'fs-extra';
|
7
7
|
import sirv from 'sirv';
|
8
|
-
import { corePath } from 'storybook/core-path';
|
9
8
|
import { normalizeStories, loadPreviewOrConfigFile, getBuilderOptions, readTemplate, resolveAddonName, getPresets, stringifyProcessEnvs, isPreservingSymlinks } from 'storybook/internal/common';
|
10
9
|
import { WebpackInvocationError } from 'storybook/internal/server-errors';
|
11
10
|
import { pluginTypeCheck } from '@rsbuild/plugin-type-check';
|
@@ -240,19 +239,19 @@ var maybeGetAbsolutePath = (input) => {
|
|
240
239
|
return false;
|
241
240
|
}
|
242
241
|
};
|
243
|
-
var
|
244
|
-
|
242
|
+
var builtInResolveExtensions = [
|
243
|
+
".mjs",
|
244
|
+
".js",
|
245
|
+
".jsx",
|
246
|
+
".ts",
|
247
|
+
".tsx",
|
248
|
+
".json",
|
249
|
+
".cjs"
|
250
|
+
];
|
245
251
|
var globalPath = maybeGetAbsolutePath("@storybook/global");
|
246
|
-
var routerPath = maybeGetAbsolutePath("@storybook/router");
|
247
|
-
var themingPath = maybeGetAbsolutePath("@storybook/theming");
|
248
252
|
var storybookPaths = {
|
249
|
-
|
250
|
-
|
251
|
-
} : {},
|
252
|
-
...componentsPath ? { "@storybook/components": componentsPath } : {},
|
253
|
-
...globalPath ? { "@storybook/global": globalPath } : {},
|
254
|
-
...routerPath ? { "@storybook/router": routerPath } : {},
|
255
|
-
...themingPath ? { "@storybook/theming": themingPath } : {}
|
253
|
+
// biome-ignore lint/complexity/useLiteralKeys: <explanation>
|
254
|
+
...globalPath ? { ["@storybook/global"]: globalPath } : {}
|
256
255
|
};
|
257
256
|
var iframe_rsbuild_config_default = async (options, extraWebpackConfig) => {
|
258
257
|
const { rsbuildConfigPath, addonDocs } = await getBuilderOptions(options);
|
@@ -445,15 +444,12 @@ var iframe_rsbuild_config_default = async (options, extraWebpackConfig) => {
|
|
445
444
|
});
|
446
445
|
config.resolve ??= {};
|
447
446
|
config.resolve.symlinks = !isPreservingSymlinks();
|
448
|
-
config.resolve.extensions =
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
".json",
|
455
|
-
".cjs"
|
456
|
-
];
|
447
|
+
config.resolve.extensions = Array.from(
|
448
|
+
/* @__PURE__ */ new Set([
|
449
|
+
...config.resolve.extensions ?? [],
|
450
|
+
...builtInResolveExtensions
|
451
|
+
])
|
452
|
+
);
|
457
453
|
config.watchOptions = {
|
458
454
|
ignored: /node_modules/
|
459
455
|
};
|
@@ -538,7 +534,8 @@ var getIsReactVersion18or19 = async (options) => {
|
|
538
534
|
"resolvedReact",
|
539
535
|
{}
|
540
536
|
);
|
541
|
-
|
537
|
+
let reactDom = "";
|
538
|
+
reactDom = resolvedReact.reactDom || dirname(__require.resolve("react-dom/package.json"));
|
542
539
|
if (!isAbsolute(reactDom)) {
|
543
540
|
return false;
|
544
541
|
}
|
@@ -562,6 +559,7 @@ var applyReactShims = async (config, options) => {
|
|
562
559
|
};
|
563
560
|
|
564
561
|
// src/index.ts
|
562
|
+
var corePath = dirname(__require.resolve("storybook/package.json"));
|
565
563
|
var printDuration = (startTime) => (0, import_pretty_hrtime.default)(process.hrtime(startTime)).replace(" ms", " milliseconds").replace(" s", " seconds").replace(" m", " minutes");
|
566
564
|
var executor = {
|
567
565
|
get: async (options) => {
|
@@ -577,22 +575,23 @@ var rsbuild = async (_, options) => {
|
|
577
575
|
const { presets } = options;
|
578
576
|
const webpackAddons = await presets.apply("webpackAddons");
|
579
577
|
const resolvedWebpackAddons = (webpackAddons ?? []).map((preset) => {
|
580
|
-
const
|
578
|
+
const addonOptions = isObject(preset) ? preset.options || void 0 : void 0;
|
581
579
|
const name = isObject(preset) ? preset.name : preset;
|
582
|
-
return resolveAddonName(
|
580
|
+
return resolveAddonName(options.configDir, name, addonOptions);
|
583
581
|
}).filter(nonNullables);
|
584
582
|
const { apply } = await getPresets(resolvedWebpackAddons, options);
|
585
583
|
const webpackAddonsConfig = await apply(
|
586
584
|
"webpackFinal",
|
587
585
|
// TODO: using empty webpack config as base for now. It's better to using the composed rspack
|
588
586
|
// config in `iframe-rsbuild.config.ts` as base config. But when `tools.rspack` is an async function,
|
589
|
-
// the following `tools.rspack` raise an `
|
587
|
+
// the following `tools.rspack` raise an `Promises are not supported` error.
|
590
588
|
{
|
591
589
|
output: {},
|
592
590
|
module: {},
|
593
591
|
plugins: [],
|
594
592
|
resolve: {},
|
595
|
-
|
593
|
+
// https://github.com/web-infra-dev/rsbuild/blob/8dc35dc1d1500d2f119875d46b6a07e27986d532/packages/core/src/provider/rspackConfig.ts#L167
|
594
|
+
devServer: void 0,
|
596
595
|
optimization: {},
|
597
596
|
performance: {},
|
598
597
|
externals: {},
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "storybook-builder-rsbuild",
|
3
|
-
"version": "
|
3
|
+
"version": "2.0.0-alpha.1",
|
4
4
|
"description": "Rsbuild builder for Storybook",
|
5
5
|
"keywords": [
|
6
6
|
"storybook",
|
@@ -58,8 +58,8 @@
|
|
58
58
|
],
|
59
59
|
"dependencies": {
|
60
60
|
"@rsbuild/plugin-type-check": "^1.2.1",
|
61
|
-
"@storybook/addon-docs": "^
|
62
|
-
"@storybook/core-webpack": "^
|
61
|
+
"@storybook/addon-docs": "^9.0.0-alpha.17",
|
62
|
+
"@storybook/core-webpack": "^9.0.0-alpha.17",
|
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,19 +78,19 @@
|
|
78
78
|
"util-deprecate": "^1.0.2"
|
79
79
|
},
|
80
80
|
"devDependencies": {
|
81
|
-
"@rsbuild/core": "^1.
|
81
|
+
"@rsbuild/core": "^1.2.19",
|
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": "
|
88
|
+
"storybook": "9.0.0-alpha.17",
|
89
89
|
"typescript": "^5.7.3"
|
90
90
|
},
|
91
91
|
"peerDependencies": {
|
92
92
|
"@rsbuild/core": "^1.0.1",
|
93
|
-
"storybook": "^
|
93
|
+
"storybook": "^9.0.0-alpha.17"
|
94
94
|
},
|
95
95
|
"peerDependenciesMeta": {
|
96
96
|
"typescript": {
|
@@ -110,7 +110,7 @@
|
|
110
110
|
},
|
111
111
|
"scripts": {
|
112
112
|
"build": "pnpm run prep --optimized",
|
113
|
-
"check": "
|
114
|
-
"prep": "
|
113
|
+
"check": "jiti ../../scripts/prepare/check.ts",
|
114
|
+
"prep": "jiti ../../scripts/prepare/bundle.ts"
|
115
115
|
}
|
116
116
|
}
|