storybook-builder-rsbuild 0.0.1-beta.0 → 0.0.1-beta.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/README.md +1 -11
- package/dist/chunk-GYZG6JM4.mjs +3 -0
- package/dist/index.d.ts +44 -2
- package/dist/index.js +10 -1
- package/dist/index.mjs +11 -2
- package/dist/loaders/export-order-loader.d.ts +5 -2
- package/dist/preview-preset.d.ts +3 -2
- package/package.json +6 -4
- package/dist/presets/custom-rsbuild-preset.d.ts +0 -2
- package/dist/presets/custom-rsbuild-preset.js +0 -56
- package/dist/presets/preview-preset.d.ts +0 -2
- package/dist/presets/preview-preset.js +0 -427
package/README.md
CHANGED
@@ -1,11 +1 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
Builder implemented with `webpack5` and `webpack5`-compatible loaders/plugins/config, used by `@storybook/core-server` to build the preview iframe.
|
4
|
-
|
5
|
-
```js
|
6
|
-
export default {
|
7
|
-
core: {
|
8
|
-
builder: '@storybook/builder-webpack5',
|
9
|
-
},
|
10
|
-
};
|
11
|
-
```
|
1
|
+
# storybook-builder-rsbuild
|
@@ -0,0 +1,3 @@
|
|
1
|
+
var __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty;var __require=(x=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(x,{get:(a,b)=>(typeof require<"u"?require:a)[b]}):x)(function(x){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+x+'" is not supported')});var __commonJS=(cb,mod)=>function(){return mod||(0, cb[__getOwnPropNames(cb)[0]])((mod={exports:{}}).exports,mod),mod.exports};var __copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:!0}):target,mod));
|
2
|
+
|
3
|
+
export { __commonJS, __require, __toESM };
|
package/dist/index.d.ts
CHANGED
@@ -1,2 +1,44 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
import * as rsbuildReal from '@rsbuild/core';
|
2
|
+
import { RsbuildConfig } from '@rsbuild/core';
|
3
|
+
import { Builder, Options, NormalizedStoriesSpecifier } from '@storybook/types';
|
4
|
+
|
5
|
+
type RsbuildStats = {
|
6
|
+
toJson: () => any;
|
7
|
+
};
|
8
|
+
type RsbuildBuilder = Builder<RsbuildConfig, RsbuildStats>;
|
9
|
+
type RsbuildFinal = (config: RsbuildConfig, options: Options) => RsbuildConfig | Promise<RsbuildConfig>;
|
10
|
+
type StorybookConfigRsbuild = {
|
11
|
+
rsbuildFinal?: RsbuildFinal;
|
12
|
+
};
|
13
|
+
type BuilderOptions = {
|
14
|
+
/**
|
15
|
+
* Path to rsbuild.config file, relative to CWD.
|
16
|
+
*/
|
17
|
+
rsbuildConfigPath?: string;
|
18
|
+
};
|
19
|
+
|
20
|
+
declare const getVirtualModules: (options: Options) => Promise<{
|
21
|
+
virtualModules: Record<string, string>;
|
22
|
+
entries: string[];
|
23
|
+
}>;
|
24
|
+
declare function toImportFnPart(specifier: NormalizedStoriesSpecifier): string;
|
25
|
+
declare function toImportFn(stories: NormalizedStoriesSpecifier[], relativeOffset: string, { needPipelinedImport }?: {
|
26
|
+
needPipelinedImport?: boolean;
|
27
|
+
}): string;
|
28
|
+
type ModuleExports = Record<string, any>;
|
29
|
+
declare function importPipeline(): (importFn: () => Promise<ModuleExports>) => Promise<ModuleExports>;
|
30
|
+
|
31
|
+
declare const printDuration: (startTime: [number, number]) => string;
|
32
|
+
type BuilderStartOptions = Parameters<RsbuildBuilder['start']>['0'];
|
33
|
+
declare const executor: {
|
34
|
+
get: (options: Options) => Promise<typeof rsbuildReal>;
|
35
|
+
};
|
36
|
+
declare const rsbuild: (_: unknown, options: Options) => Promise<rsbuildReal.RsbuildConfig>;
|
37
|
+
declare const getConfig: RsbuildBuilder['getConfig'];
|
38
|
+
declare function bail(): Promise<void>;
|
39
|
+
declare const start: RsbuildBuilder['start'];
|
40
|
+
declare const build: ({ options }: BuilderStartOptions) => Promise<void>;
|
41
|
+
declare const corePresets: string[];
|
42
|
+
declare const previewMainTemplate: () => string;
|
43
|
+
|
44
|
+
export { BuilderOptions, RsbuildBuilder, RsbuildFinal, StorybookConfigRsbuild, bail, build, corePresets, executor, getConfig, getVirtualModules, importPipeline, previewMainTemplate, printDuration, rsbuild, start, toImportFn, toImportFnPart };
|
package/dist/index.js
CHANGED
@@ -454,7 +454,16 @@ var iframe_rsbuild_config_default = async (options) => {
|
|
454
454
|
new rspack.ProvidePlugin({
|
455
455
|
process: require.resolve("process/browser.js")
|
456
456
|
}),
|
457
|
-
new import_case_sensitive_paths_webpack_plugin.default()
|
457
|
+
new import_case_sensitive_paths_webpack_plugin.default(),
|
458
|
+
new rspack.IgnorePlugin({
|
459
|
+
checkResource: (resource, context) => {
|
460
|
+
const absPathHasExt = (0, import_path3.extname)(resource);
|
461
|
+
if (absPathHasExt === ".md") {
|
462
|
+
return true;
|
463
|
+
}
|
464
|
+
return false;
|
465
|
+
}
|
466
|
+
})
|
458
467
|
].filter(Boolean)
|
459
468
|
);
|
460
469
|
return mergeConfig(config, appliedDocsWebpack);
|
package/dist/index.mjs
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { __commonJS, __toESM, __require } from './chunk-TTFRSOOU.mjs';
|
2
2
|
import * as rsbuildReal from '@rsbuild/core';
|
3
3
|
import { loadConfig, mergeRsbuildConfig } from '@rsbuild/core';
|
4
|
-
import path, { join, resolve, parse, dirname } from 'path';
|
4
|
+
import path, { join, resolve, parse, dirname, extname } from 'path';
|
5
5
|
import express from 'express';
|
6
6
|
import fs2 from 'fs-extra';
|
7
7
|
import { WebpackInvocationError, NoStatsForViteDevError } from '@storybook/core-events/server-errors';
|
@@ -395,7 +395,16 @@ var iframe_rsbuild_config_default = async (options) => {
|
|
395
395
|
new rspack.ProvidePlugin({
|
396
396
|
process: __require.resolve("process/browser.js")
|
397
397
|
}),
|
398
|
-
new CaseSensitivePathsPlugin()
|
398
|
+
new CaseSensitivePathsPlugin(),
|
399
|
+
new rspack.IgnorePlugin({
|
400
|
+
checkResource: (resource, context) => {
|
401
|
+
const absPathHasExt = extname(resource);
|
402
|
+
if (absPathHasExt === ".md") {
|
403
|
+
return true;
|
404
|
+
}
|
405
|
+
return false;
|
406
|
+
}
|
407
|
+
})
|
399
408
|
].filter(Boolean)
|
400
409
|
);
|
401
410
|
return mergeConfig(config, appliedDocsWebpack);
|
package/dist/preview-preset.d.ts
CHANGED
@@ -1,2 +1,3 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
declare const previewMainTemplate: () => string;
|
2
|
+
|
3
|
+
export { previewMainTemplate };
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "storybook-builder-rsbuild",
|
3
|
-
"version": "0.0.1-beta.
|
3
|
+
"version": "0.0.1-beta.1",
|
4
4
|
"description": "Rsbuild builder for Storybook",
|
5
5
|
"keywords": [
|
6
6
|
"storybook",
|
@@ -48,8 +48,6 @@
|
|
48
48
|
"!src/**/*"
|
49
49
|
],
|
50
50
|
"dependencies": {
|
51
|
-
"@rsbuild/core": "0.6.15",
|
52
|
-
"@rsbuild/shared": "0.6.15",
|
53
51
|
"@storybook/addon-docs": "8.0.10",
|
54
52
|
"@storybook/channels": "8.0.10",
|
55
53
|
"@storybook/client-logger": "8.0.10",
|
@@ -79,6 +77,7 @@
|
|
79
77
|
"util-deprecate": "^1.0.2"
|
80
78
|
},
|
81
79
|
"devDependencies": {
|
80
|
+
"@rsbuild/core": "0.6.15",
|
82
81
|
"@types/node": "^18.0.0",
|
83
82
|
"@types/express": "^4.17.21",
|
84
83
|
"@types/fs-extra": "^11.0.4",
|
@@ -88,6 +87,10 @@
|
|
88
87
|
"slash": "^5.0.0",
|
89
88
|
"typescript": "^5.3.2"
|
90
89
|
},
|
90
|
+
"peerDependencies": {
|
91
|
+
"@rsbuild/core": ">= 0.6.15",
|
92
|
+
"vite": "^4.0.0 || ^5.0.0"
|
93
|
+
},
|
91
94
|
"peerDependenciesMeta": {
|
92
95
|
"typescript": {
|
93
96
|
"optional": true
|
@@ -99,7 +102,6 @@
|
|
99
102
|
"bundler": {
|
100
103
|
"entries": [
|
101
104
|
"./src/index.ts",
|
102
|
-
"./src/presets/custom-rsbuild-preset.ts",
|
103
105
|
"./src/preview-preset.ts",
|
104
106
|
"./src/loaders/export-order-loader.ts"
|
105
107
|
],
|
@@ -1,56 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __create = Object.create;
|
3
|
-
var __defProp = Object.defineProperty;
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
-
var __export = (target, all) => {
|
9
|
-
for (var name in all)
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
11
|
-
};
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
-
for (let key of __getOwnPropNames(from))
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
17
|
-
}
|
18
|
-
return to;
|
19
|
-
};
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
-
mod
|
27
|
-
));
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
-
|
30
|
-
// src/presets/custom-rsbuild-preset.ts
|
31
|
-
var custom_rsbuild_preset_exports = {};
|
32
|
-
__export(custom_rsbuild_preset_exports, {
|
33
|
-
rsbuild: () => rsbuild,
|
34
|
-
rsbuildInstance: () => rsbuildInstance,
|
35
|
-
rsbuildVersion: () => rsbuildVersion
|
36
|
-
});
|
37
|
-
module.exports = __toCommonJS(custom_rsbuild_preset_exports);
|
38
|
-
var rsbuildReal = __toESM(require("@rsbuild/core"));
|
39
|
-
async function rsbuild(config, options) {
|
40
|
-
const { presets } = options;
|
41
|
-
let defaultConfig = config;
|
42
|
-
const finalDefaultConfig = await presets.apply(
|
43
|
-
"rsbuildFinal",
|
44
|
-
defaultConfig,
|
45
|
-
options
|
46
|
-
);
|
47
|
-
return finalDefaultConfig;
|
48
|
-
}
|
49
|
-
var rsbuildInstance = async () => rsbuildReal;
|
50
|
-
var rsbuildVersion = async () => "0.7";
|
51
|
-
// Annotate the CommonJS export names for ESM import in node:
|
52
|
-
0 && (module.exports = {
|
53
|
-
rsbuild,
|
54
|
-
rsbuildInstance,
|
55
|
-
rsbuildVersion
|
56
|
-
});
|
@@ -1,427 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __create = Object.create;
|
3
|
-
var __defProp = Object.defineProperty;
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
-
var __export = (target, all) => {
|
9
|
-
for (var name in all)
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
11
|
-
};
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
-
for (let key of __getOwnPropNames(from))
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
17
|
-
}
|
18
|
-
return to;
|
19
|
-
};
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
-
mod
|
27
|
-
));
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
-
|
30
|
-
// src/presets/preview-preset.ts
|
31
|
-
var preview_preset_exports = {};
|
32
|
-
__export(preview_preset_exports, {
|
33
|
-
entries: () => entries,
|
34
|
-
previewMainTemplate: () => previewMainTemplate,
|
35
|
-
rsbuild: () => rsbuild
|
36
|
-
});
|
37
|
-
module.exports = __toCommonJS(preview_preset_exports);
|
38
|
-
|
39
|
-
// src/preview/iframe-rsbuild.config.ts
|
40
|
-
var import_path3 = require("path");
|
41
|
-
var import_case_sensitive_paths_webpack_plugin = __toESM(require("case-sensitive-paths-webpack-plugin"));
|
42
|
-
var import_globals = require("@storybook/preview/globals");
|
43
|
-
var import_core_common2 = require("@storybook/core-common");
|
44
|
-
var import_ts_dedent2 = require("ts-dedent");
|
45
|
-
|
46
|
-
// src/preview/virtual-module-mapping.ts
|
47
|
-
var import_path = __toESM(require("path"));
|
48
|
-
var import_fs = __toESM(require("fs"));
|
49
|
-
var import_path2 = require("path");
|
50
|
-
var import_core_common = require("@storybook/core-common");
|
51
|
-
|
52
|
-
// ../../node_modules/.pnpm/slash@5.1.0/node_modules/slash/index.js
|
53
|
-
function slash(path2) {
|
54
|
-
const isExtendedLengthPath = path2.startsWith("\\\\?\\");
|
55
|
-
if (isExtendedLengthPath) {
|
56
|
-
return path2;
|
57
|
-
}
|
58
|
-
return path2.replace(/\\/g, "/");
|
59
|
-
}
|
60
|
-
|
61
|
-
// src/preview/virtual-module-mapping.ts
|
62
|
-
var import_core_webpack = require("@storybook/core-webpack");
|
63
|
-
var import_ts_dedent = require("ts-dedent");
|
64
|
-
var getVirtualModules = async (options) => {
|
65
|
-
const virtualModules = {};
|
66
|
-
const cwd = process.cwd();
|
67
|
-
const workingDir = options.cache?.basePath || process.cwd();
|
68
|
-
const isProd = options.configType === "PRODUCTION";
|
69
|
-
const nonNormalizedStories = await options.presets.apply("stories", []);
|
70
|
-
const entries2 = [];
|
71
|
-
const stories = (0, import_core_common.normalizeStories)(nonNormalizedStories, {
|
72
|
-
configDir: options.configDir,
|
73
|
-
workingDir
|
74
|
-
});
|
75
|
-
const realPathRelativeToCwd = import_path.default.relative(workingDir, cwd);
|
76
|
-
const previewAnnotations = [
|
77
|
-
...(await options.presets.apply(
|
78
|
-
"previewAnnotations",
|
79
|
-
[],
|
80
|
-
options
|
81
|
-
)).map((entry) => {
|
82
|
-
if (typeof entry === "object") {
|
83
|
-
return entry.absolute;
|
84
|
-
}
|
85
|
-
return slash(entry);
|
86
|
-
}),
|
87
|
-
(0, import_core_common.loadPreviewOrConfigFile)(options)
|
88
|
-
].filter(Boolean);
|
89
|
-
const storiesFilename = "storybook-stories.js";
|
90
|
-
const storiesPath = (0, import_path2.resolve)((0, import_path2.join)(workingDir, storiesFilename));
|
91
|
-
const needPipelinedImport = !isProd;
|
92
|
-
virtualModules[storiesPath] = toImportFn(stories, realPathRelativeToCwd, {
|
93
|
-
needPipelinedImport
|
94
|
-
});
|
95
|
-
const configEntryPath = (0, import_path2.resolve)((0, import_path2.join)(workingDir, "storybook-config-entry.js"));
|
96
|
-
virtualModules[configEntryPath] = (0, import_core_common.handlebars)(
|
97
|
-
await (0, import_core_common.readTemplate)(
|
98
|
-
require.resolve("@storybook/builder-rsbuild/templates/virtualModuleModernEntry.js.handlebars")
|
99
|
-
),
|
100
|
-
{
|
101
|
-
storiesFilename,
|
102
|
-
previewAnnotations
|
103
|
-
}
|
104
|
-
// We need to double escape `\` for webpack. We may have some in windows paths
|
105
|
-
).replace(/\\/g, "\\\\");
|
106
|
-
entries2.push(configEntryPath);
|
107
|
-
Object.entries(virtualModules).forEach(([key, value]) => {
|
108
|
-
import_fs.default.writeFileSync(key, value);
|
109
|
-
});
|
110
|
-
return {
|
111
|
-
virtualModules,
|
112
|
-
entries: entries2
|
113
|
-
};
|
114
|
-
};
|
115
|
-
function toImportFnPart(specifier) {
|
116
|
-
const { directory, importPathMatcher } = specifier;
|
117
|
-
return import_ts_dedent.dedent`
|
118
|
-
async (path) => {
|
119
|
-
if (!${importPathMatcher}.exec(path)) {
|
120
|
-
return;
|
121
|
-
}
|
122
|
-
|
123
|
-
const pathRemainder = path.substring(${directory.length + 1});
|
124
|
-
return import(
|
125
|
-
/* webpackChunkName: "[request]" */
|
126
|
-
/* webpackInclude: ${(0, import_core_webpack.webpackIncludeRegexp)(specifier)} */
|
127
|
-
'${directory}/' + pathRemainder
|
128
|
-
);
|
129
|
-
}
|
130
|
-
|
131
|
-
`;
|
132
|
-
}
|
133
|
-
function toImportFn(stories, relativeOffset, { needPipelinedImport } = {}) {
|
134
|
-
let pipelinedImport = `const pipeline = (x) => x();`;
|
135
|
-
if (needPipelinedImport) {
|
136
|
-
pipelinedImport = `
|
137
|
-
const importPipeline = ${importPipeline};
|
138
|
-
const pipeline = importPipeline();
|
139
|
-
`;
|
140
|
-
}
|
141
|
-
return import_ts_dedent.dedent`
|
142
|
-
${pipelinedImport}
|
143
|
-
|
144
|
-
const importers = [
|
145
|
-
${stories.map(toImportFnPart).join(",\n")}
|
146
|
-
];
|
147
|
-
|
148
|
-
export async function importFn(path) {
|
149
|
-
const offset = '${relativeOffset}';
|
150
|
-
|
151
|
-
for (let i = 0; i < importers.length; i++) {
|
152
|
-
const pathWithOffset = buildPath(offset, path)
|
153
|
-
|
154
|
-
const moduleExports = await pipeline(() => importers[i](pathWithOffset));
|
155
|
-
if (moduleExports) {
|
156
|
-
return moduleExports;
|
157
|
-
}
|
158
|
-
}
|
159
|
-
}
|
160
|
-
|
161
|
-
function buildPath(offset, path) {
|
162
|
-
if(path.startsWith('./')) {
|
163
|
-
return offset + '/' + path.substring(2);
|
164
|
-
} else {
|
165
|
-
return offset + '/' + path;
|
166
|
-
}
|
167
|
-
}
|
168
|
-
`;
|
169
|
-
}
|
170
|
-
function importPipeline() {
|
171
|
-
let importGate = Promise.resolve();
|
172
|
-
return async (importFn) => {
|
173
|
-
await importGate;
|
174
|
-
const moduleExportsPromise = importFn();
|
175
|
-
importGate = importGate.then(async () => {
|
176
|
-
await moduleExportsPromise;
|
177
|
-
});
|
178
|
-
return moduleExportsPromise;
|
179
|
-
};
|
180
|
-
}
|
181
|
-
|
182
|
-
// src/preview/iframe-rsbuild.config.ts
|
183
|
-
var import_core = require("@rsbuild/core");
|
184
|
-
var import_preset = require("@storybook/addon-docs/dist/preset");
|
185
|
-
var getAbsolutePath = (input) => (0, import_path3.dirname)(require.resolve((0, import_path3.join)(input, "package.json")));
|
186
|
-
var maybeGetAbsolutePath = (input) => {
|
187
|
-
try {
|
188
|
-
return getAbsolutePath(input);
|
189
|
-
} catch (e) {
|
190
|
-
return false;
|
191
|
-
}
|
192
|
-
};
|
193
|
-
var managerAPIPath = maybeGetAbsolutePath(`@storybook/manager-api`);
|
194
|
-
var componentsPath = maybeGetAbsolutePath(`@storybook/components`);
|
195
|
-
var globalPath = maybeGetAbsolutePath(`@storybook/global`);
|
196
|
-
var routerPath = maybeGetAbsolutePath(`@storybook/router`);
|
197
|
-
var themingPath = maybeGetAbsolutePath(`@storybook/theming`);
|
198
|
-
var storybookPaths = {
|
199
|
-
...managerAPIPath ? {
|
200
|
-
[`@storybook/manager-api`]: managerAPIPath
|
201
|
-
} : {},
|
202
|
-
...componentsPath ? { [`@storybook/components`]: componentsPath } : {},
|
203
|
-
...globalPath ? { [`@storybook/global`]: globalPath } : {},
|
204
|
-
...routerPath ? { [`@storybook/router`]: routerPath } : {},
|
205
|
-
...themingPath ? { [`@storybook/theming`]: themingPath } : {}
|
206
|
-
};
|
207
|
-
var iframe_rsbuild_config_default = async (options) => {
|
208
|
-
const appliedDocsWebpack = await (0, import_preset.webpack)({}, options);
|
209
|
-
const {
|
210
|
-
outputDir = (0, import_path3.join)(".", "public"),
|
211
|
-
quiet,
|
212
|
-
packageJson,
|
213
|
-
configType,
|
214
|
-
presets,
|
215
|
-
previewUrl,
|
216
|
-
// typescriptOptions,
|
217
|
-
features
|
218
|
-
} = options;
|
219
|
-
const isProd = configType === "PRODUCTION";
|
220
|
-
const workingDir = process.cwd();
|
221
|
-
const [
|
222
|
-
coreOptions,
|
223
|
-
frameworkOptions,
|
224
|
-
envs,
|
225
|
-
logLevel,
|
226
|
-
headHtmlSnippet,
|
227
|
-
bodyHtmlSnippet,
|
228
|
-
template,
|
229
|
-
docsOptions,
|
230
|
-
entries2,
|
231
|
-
nonNormalizedStories,
|
232
|
-
// modulesCount = 1000,
|
233
|
-
build,
|
234
|
-
tagsOptions
|
235
|
-
] = await Promise.all([
|
236
|
-
presets.apply("core"),
|
237
|
-
presets.apply("frameworkOptions1"),
|
238
|
-
presets.apply("env"),
|
239
|
-
presets.apply("logLevel", void 0),
|
240
|
-
presets.apply("previewHead"),
|
241
|
-
presets.apply("previewBody"),
|
242
|
-
presets.apply("previewMainTemplate"),
|
243
|
-
presets.apply("docs"),
|
244
|
-
presets.apply("entries", []),
|
245
|
-
presets.apply("stories", []),
|
246
|
-
options.cache?.get("modulesCount").catch(() => {
|
247
|
-
}),
|
248
|
-
options.presets.apply("build"),
|
249
|
-
presets.apply("tags", {})
|
250
|
-
]);
|
251
|
-
const stories = (0, import_core_common2.normalizeStories)(nonNormalizedStories, {
|
252
|
-
configDir: options.configDir,
|
253
|
-
workingDir
|
254
|
-
});
|
255
|
-
if (!template) {
|
256
|
-
throw new Error(import_ts_dedent2.dedent`
|
257
|
-
Storybook's Webpack5 builder requires a template to be specified.
|
258
|
-
Somehow you've ended up with a falsy value for the template option.
|
259
|
-
|
260
|
-
Please file an issue at https://github.com/storybookjs/storybook with a reproduction.
|
261
|
-
`);
|
262
|
-
}
|
263
|
-
const externals = import_globals.globalsNameReferenceMap;
|
264
|
-
if (build?.test?.disableBlocks) {
|
265
|
-
externals["@storybook/blocks"] = "__STORYBOOK_BLOCKS_EMPTY_MODULE__";
|
266
|
-
}
|
267
|
-
const { virtualModules: _virtualModules, entries: dynamicEntries } = await getVirtualModules(options);
|
268
|
-
if (!options.cache) {
|
269
|
-
throw new Error("Cache is required");
|
270
|
-
}
|
271
|
-
const { content } = await (0, import_core.loadConfig)({
|
272
|
-
cwd: workingDir
|
273
|
-
});
|
274
|
-
const resourceFilename = isProd ? "static/media/[name].[contenthash:8][ext]" : "static/media/[path][name][ext]";
|
275
|
-
const merged = (0, import_core.mergeRsbuildConfig)(content, {
|
276
|
-
output: {
|
277
|
-
cleanDistPath: false,
|
278
|
-
dataUriLimit: {
|
279
|
-
media: 1e4
|
280
|
-
},
|
281
|
-
sourceMap: {
|
282
|
-
js: options.build?.test?.disableSourcemaps ? false : "cheap-module-source-map",
|
283
|
-
css: options.build?.test?.disableSourcemaps ? false : true
|
284
|
-
},
|
285
|
-
distPath: {
|
286
|
-
root: (0, import_path3.resolve)(process.cwd(), outputDir)
|
287
|
-
},
|
288
|
-
filename: {
|
289
|
-
js: isProd ? "[name].[contenthash:8].iframe.bundle.js" : "[name].iframe.bundle.js",
|
290
|
-
image: resourceFilename,
|
291
|
-
font: resourceFilename,
|
292
|
-
media: resourceFilename
|
293
|
-
},
|
294
|
-
assetPrefix: "/",
|
295
|
-
externals
|
296
|
-
},
|
297
|
-
dev: {
|
298
|
-
assetPrefix: "",
|
299
|
-
progressBar: !quiet
|
300
|
-
},
|
301
|
-
source: {
|
302
|
-
alias: {
|
303
|
-
...storybookPaths
|
304
|
-
// '@storybook/react-dom-shim': '@storybook/react-dom-shim/dist/react-16',
|
305
|
-
},
|
306
|
-
entry: {
|
307
|
-
// to avoid `It's not allowed to load an initial chunk on demand. The chunk name "main" is already used by an entrypoint` of
|
308
|
-
main: [...entries2 ?? [], ...dynamicEntries]
|
309
|
-
},
|
310
|
-
define: {
|
311
|
-
...(0, import_core_common2.stringifyProcessEnvs)(envs),
|
312
|
-
NODE_ENV: JSON.stringify(process.env.NODE_ENV)
|
313
|
-
}
|
314
|
-
},
|
315
|
-
performance: {
|
316
|
-
chunkSplit: {
|
317
|
-
strategy: "custom",
|
318
|
-
splitChunks: {
|
319
|
-
chunks: "all"
|
320
|
-
}
|
321
|
-
}
|
322
|
-
},
|
323
|
-
tools: {
|
324
|
-
rspack: (config, { addRules, appendPlugins, rspack, mergeConfig }) => {
|
325
|
-
addRules({
|
326
|
-
test: /\.stories\.([tj])sx?$|(stories|story)\.mdx$/,
|
327
|
-
exclude: /node_modules/,
|
328
|
-
enforce: "post",
|
329
|
-
use: [
|
330
|
-
{
|
331
|
-
loader: require.resolve("@storybook/builder-rsbuild/loaders/export-order-loader")
|
332
|
-
}
|
333
|
-
]
|
334
|
-
});
|
335
|
-
config.resolve ??= {};
|
336
|
-
config.resolve.symlinks = !(0, import_core_common2.isPreservingSymlinks)();
|
337
|
-
config.watchOptions = {
|
338
|
-
ignored: /node_modules/
|
339
|
-
};
|
340
|
-
config.output = config.output || {};
|
341
|
-
config.output.publicPath = "";
|
342
|
-
config.ignoreWarnings = [
|
343
|
-
...config.ignoreWarnings || [],
|
344
|
-
/export '\S+' was not found in 'global'/,
|
345
|
-
/export '\S+' was not found in '@storybook\/global'/
|
346
|
-
];
|
347
|
-
config.resolve ??= {};
|
348
|
-
config.resolve.fallback ??= {
|
349
|
-
stream: false,
|
350
|
-
path: require.resolve("path-browserify"),
|
351
|
-
assert: require.resolve("browser-assert"),
|
352
|
-
util: require.resolve("util"),
|
353
|
-
url: require.resolve("url"),
|
354
|
-
fs: false,
|
355
|
-
constants: require.resolve("constants-browserify")
|
356
|
-
};
|
357
|
-
config.optimization ??= {};
|
358
|
-
config.optimization.runtimeChunk = true;
|
359
|
-
config.optimization.usedExports = options.build?.test?.disableTreeShaking ? false : isProd;
|
360
|
-
config.optimization.moduleIds = "named";
|
361
|
-
appendPlugins(
|
362
|
-
[
|
363
|
-
new rspack.ProvidePlugin({
|
364
|
-
process: require.resolve("process/browser.js")
|
365
|
-
}),
|
366
|
-
new import_case_sensitive_paths_webpack_plugin.default()
|
367
|
-
].filter(Boolean)
|
368
|
-
);
|
369
|
-
console.log("\u{1F919}", appliedDocsWebpack);
|
370
|
-
return mergeConfig(config, appliedDocsWebpack);
|
371
|
-
},
|
372
|
-
htmlPlugin: {
|
373
|
-
filename: `iframe.html`,
|
374
|
-
// FIXME: `none` isn't a known option
|
375
|
-
chunksSortMode: "none",
|
376
|
-
alwaysWriteToDisk: true,
|
377
|
-
inject: false,
|
378
|
-
template,
|
379
|
-
templateParameters: {
|
380
|
-
version: packageJson.version,
|
381
|
-
globals: {
|
382
|
-
CONFIG_TYPE: configType,
|
383
|
-
LOGLEVEL: logLevel,
|
384
|
-
FRAMEWORK_OPTIONS: frameworkOptions,
|
385
|
-
CHANNEL_OPTIONS: coreOptions.channelOptions,
|
386
|
-
FEATURES: features,
|
387
|
-
PREVIEW_URL: previewUrl,
|
388
|
-
STORIES: stories.map((specifier) => ({
|
389
|
-
...specifier,
|
390
|
-
importPathMatcher: specifier.importPathMatcher.source
|
391
|
-
})),
|
392
|
-
DOCS_OPTIONS: docsOptions,
|
393
|
-
TAGS_OPTIONS: tagsOptions,
|
394
|
-
...build?.test?.disableBlocks ? { __STORYBOOK_BLOCKS_EMPTY_MODULE__: {} } : {}
|
395
|
-
},
|
396
|
-
headHtmlSnippet,
|
397
|
-
bodyHtmlSnippet
|
398
|
-
},
|
399
|
-
minify: {
|
400
|
-
collapseWhitespace: true,
|
401
|
-
removeComments: true,
|
402
|
-
removeRedundantAttributes: true,
|
403
|
-
removeScriptTypeAttributes: false,
|
404
|
-
removeStyleLinkTypeAttributes: true,
|
405
|
-
useShortDoctype: true
|
406
|
-
}
|
407
|
-
}
|
408
|
-
}
|
409
|
-
});
|
410
|
-
return merged;
|
411
|
-
};
|
412
|
-
|
413
|
-
// src/presets/preview-preset.ts
|
414
|
-
var rsbuild = async (_, options) => {
|
415
|
-
return iframe_rsbuild_config_default(options);
|
416
|
-
};
|
417
|
-
var entries = async (_, options) => {
|
418
|
-
let result = [];
|
419
|
-
return result;
|
420
|
-
};
|
421
|
-
var previewMainTemplate = () => require.resolve("@storybook/builder-rsbuild/templates/preview.ejs");
|
422
|
-
// Annotate the CommonJS export names for ESM import in node:
|
423
|
-
0 && (module.exports = {
|
424
|
-
entries,
|
425
|
-
previewMainTemplate,
|
426
|
-
rsbuild
|
427
|
-
});
|