storybook-builder-rsbuild 2.1.6 → 3.0.0-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/compiled/@storybook/core-webpack/index.d.ts +4 -3066
- package/compiled/@storybook/core-webpack/index.js +323 -281
- package/compiled/@storybook/core-webpack/package.json +1 -1
- package/dist/_node-chunks/chunk-MIMCYZFR.js +45 -0
- package/dist/index.d.ts +3 -72
- package/dist/index.js +423 -650
- package/dist/loaders/export-order-loader.js +31 -52
- package/dist/preview-preset.js +17 -39
- package/package.json +17 -30
- package/dist/chunk-TTFRSOOU.mjs +0 -34
- package/dist/index.mjs +0 -947
- package/dist/loaders/export-order-loader.d.ts +0 -5
- package/dist/loaders/export-order-loader.mjs +0 -49
- package/dist/preview-preset.d.ts +0 -3
package/dist/index.js
CHANGED
|
@@ -1,157 +1,201 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
for (let key of __getOwnPropNames(from))
|
|
18
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
-
}
|
|
21
|
-
return to;
|
|
22
|
-
};
|
|
23
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
-
mod
|
|
30
|
-
));
|
|
31
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
import CJS_COMPAT_NODE_URL_c7aef05d0183c9d0 from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_c7aef05d0183c9d0 from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_c7aef05d0183c9d0 from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_c7aef05d0183c9d0.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_c7aef05d0183c9d0.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_c7aef05d0183c9d0.createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
import {
|
|
13
|
+
__commonJS,
|
|
14
|
+
__require,
|
|
15
|
+
__toESM
|
|
16
|
+
} from "./_node-chunks/chunk-MIMCYZFR.js";
|
|
32
17
|
|
|
33
18
|
// ../../node_modules/.pnpm/pretty-hrtime@1.0.3/node_modules/pretty-hrtime/index.js
|
|
34
19
|
var require_pretty_hrtime = __commonJS({
|
|
35
|
-
"../../node_modules/.pnpm/pretty-hrtime@1.0.3/node_modules/pretty-hrtime/index.js"(exports,
|
|
20
|
+
"../../node_modules/.pnpm/pretty-hrtime@1.0.3/node_modules/pretty-hrtime/index.js"(exports, module) {
|
|
36
21
|
"use strict";
|
|
37
|
-
var minimalDesc = ["h", "min", "s", "ms", "\u03BCs", "ns"];
|
|
38
|
-
|
|
39
|
-
var convert = [60 * 60, 60, 1, 1e6, 1e3, 1];
|
|
40
|
-
module2.exports = function(source, opts) {
|
|
22
|
+
var minimalDesc = ["h", "min", "s", "ms", "\u03BCs", "ns"], verboseDesc = ["hour", "minute", "second", "millisecond", "microsecond", "nanosecond"], convert = [3600, 60, 1, 1e6, 1e3, 1];
|
|
23
|
+
module.exports = function(source, opts) {
|
|
41
24
|
var verbose, precise, i, spot, sourceAtStep, valAtStep, decimals, strAtStep, results, totalSeconds;
|
|
42
|
-
verbose =
|
|
43
|
-
precise = false;
|
|
44
|
-
if (opts) {
|
|
45
|
-
verbose = opts.verbose || false;
|
|
46
|
-
precise = opts.precise || false;
|
|
47
|
-
}
|
|
48
|
-
if (!Array.isArray(source) || source.length !== 2) {
|
|
49
|
-
return "";
|
|
50
|
-
}
|
|
51
|
-
if (typeof source[0] !== "number" || typeof source[1] !== "number") {
|
|
25
|
+
if (verbose = !1, precise = !1, opts && (verbose = opts.verbose || !1, precise = opts.precise || !1), !Array.isArray(source) || source.length !== 2 || typeof source[0] != "number" || typeof source[1] != "number")
|
|
52
26
|
return "";
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
totalSeconds = source[0] + source[1] / 1e9;
|
|
56
|
-
source[0] = parseInt(totalSeconds);
|
|
57
|
-
source[1] = parseFloat((totalSeconds % 1).toPrecision(9)) * 1e9;
|
|
58
|
-
}
|
|
59
|
-
results = "";
|
|
60
|
-
for (i = 0; i < 6; i++) {
|
|
61
|
-
spot = i < 3 ? 0 : 1;
|
|
62
|
-
sourceAtStep = source[spot];
|
|
63
|
-
if (i !== 3 && i !== 0) {
|
|
64
|
-
sourceAtStep = sourceAtStep % convert[i - 1];
|
|
65
|
-
}
|
|
66
|
-
if (i === 2) {
|
|
67
|
-
sourceAtStep += source[1] / 1e9;
|
|
68
|
-
}
|
|
69
|
-
valAtStep = sourceAtStep / convert[i];
|
|
70
|
-
if (valAtStep >= 1) {
|
|
71
|
-
if (verbose) {
|
|
72
|
-
valAtStep = Math.floor(valAtStep);
|
|
73
|
-
}
|
|
74
|
-
if (!precise) {
|
|
75
|
-
decimals = valAtStep >= 10 ? 0 : 2;
|
|
76
|
-
strAtStep = valAtStep.toFixed(decimals);
|
|
77
|
-
} else {
|
|
78
|
-
strAtStep = valAtStep.toString();
|
|
79
|
-
}
|
|
80
|
-
if (strAtStep.indexOf(".") > -1 && strAtStep[strAtStep.length - 1] === "0") {
|
|
81
|
-
strAtStep = strAtStep.replace(/\.?0+$/, "");
|
|
82
|
-
}
|
|
83
|
-
if (results) {
|
|
84
|
-
results += " ";
|
|
85
|
-
}
|
|
86
|
-
results += strAtStep;
|
|
87
|
-
if (verbose) {
|
|
88
|
-
results += " " + verboseDesc[i];
|
|
89
|
-
if (strAtStep !== "1") {
|
|
90
|
-
results += "s";
|
|
91
|
-
}
|
|
92
|
-
} else {
|
|
93
|
-
results += " " + minimalDesc[i];
|
|
94
|
-
}
|
|
95
|
-
if (!verbose) {
|
|
96
|
-
break;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
27
|
+
for (source[1] < 0 && (totalSeconds = source[0] + source[1] / 1e9, source[0] = parseInt(totalSeconds), source[1] = parseFloat((totalSeconds % 1).toPrecision(9)) * 1e9), results = "", i = 0; i < 6 && (spot = i < 3 ? 0 : 1, sourceAtStep = source[spot], i !== 3 && i !== 0 && (sourceAtStep = sourceAtStep % convert[i - 1]), i === 2 && (sourceAtStep += source[1] / 1e9), valAtStep = sourceAtStep / convert[i], !(valAtStep >= 1 && (verbose && (valAtStep = Math.floor(valAtStep)), precise ? strAtStep = valAtStep.toString() : (decimals = valAtStep >= 10 ? 0 : 2, strAtStep = valAtStep.toFixed(decimals)), strAtStep.indexOf(".") > -1 && strAtStep[strAtStep.length - 1] === "0" && (strAtStep = strAtStep.replace(/\.?0+$/, "")), results && (results += " "), results += strAtStep, verbose ? (results += " " + verboseDesc[i], strAtStep !== "1" && (results += "s")) : results += " " + minimalDesc[i], !verbose))); i++)
|
|
28
|
+
;
|
|
100
29
|
return results;
|
|
101
30
|
};
|
|
102
31
|
}
|
|
103
32
|
});
|
|
104
33
|
|
|
34
|
+
// src/index.ts
|
|
35
|
+
var import_pretty_hrtime = __toESM(require_pretty_hrtime(), 1);
|
|
36
|
+
import { createServer } from "node:net";
|
|
37
|
+
import { dirname as dirname3, join as join4, parse } from "node:path";
|
|
38
|
+
import * as rsbuildReal from "@rsbuild/core";
|
|
39
|
+
import fs from "fs-extra";
|
|
40
|
+
import sirv from "sirv";
|
|
41
|
+
import { getPresets, resolveAddonName } from "storybook/internal/common";
|
|
42
|
+
import { WebpackInvocationError } from "storybook/internal/server-errors";
|
|
43
|
+
|
|
44
|
+
// src/preview/iframe-rsbuild.config.ts
|
|
45
|
+
import { dirname, join as join2, resolve as resolve2 } from "node:path";
|
|
46
|
+
import { loadConfig, mergeRsbuildConfig } from "@rsbuild/core";
|
|
47
|
+
import { pluginTypeCheck } from "@rsbuild/plugin-type-check";
|
|
48
|
+
import CaseSensitivePathsPlugin from "case-sensitive-paths-webpack-plugin";
|
|
49
|
+
import { pluginHtmlMinifierTerser } from "rsbuild-plugin-html-minifier-terser";
|
|
50
|
+
import {
|
|
51
|
+
getBuilderOptions as getBuilderOptions2,
|
|
52
|
+
isPreservingSymlinks,
|
|
53
|
+
normalizeStories as normalizeStories2,
|
|
54
|
+
stringifyProcessEnvs
|
|
55
|
+
} from "storybook/internal/common";
|
|
56
|
+
import { globalsNameReferenceMap } from "storybook/internal/preview/globals";
|
|
57
|
+
import { dedent } from "ts-dedent";
|
|
58
|
+
|
|
59
|
+
// src/preview/virtual-module-mapping.ts
|
|
60
|
+
import { join, resolve } from "node:path";
|
|
61
|
+
|
|
62
|
+
// ../../node_modules/.pnpm/slash@5.1.0/node_modules/slash/index.js
|
|
63
|
+
function slash(path) {
|
|
64
|
+
return path.startsWith("\\\\?\\") ? path : path.replace(/\\/g, "/");
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// src/preview/virtual-module-mapping.ts
|
|
68
|
+
import {
|
|
69
|
+
getBuilderOptions,
|
|
70
|
+
loadPreviewOrConfigFile,
|
|
71
|
+
normalizeStories,
|
|
72
|
+
readTemplate
|
|
73
|
+
} from "storybook/internal/common";
|
|
74
|
+
|
|
105
75
|
// compiled/@storybook/core-webpack/index.js
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
76
|
+
import { createRequire as __WEBPACK_EXTERNAL_createRequire } from "module";
|
|
77
|
+
import * as __WEBPACK_EXTERNAL_MODULE_storybook_internal_common_7991bda6__ from "storybook/internal/common";
|
|
78
|
+
import * as __WEBPACK_EXTERNAL_MODULE_storybook_internal_node_logger_87de4309__ from "storybook/internal/node-logger";
|
|
79
|
+
var __webpack_modules__ = {
|
|
80
|
+
980: (__unused_webpack_module, exports) => {
|
|
81
|
+
var __webpack_unused_export__;
|
|
82
|
+
__webpack_unused_export__ = { value: !0 }, exports.TW = void 0;
|
|
83
|
+
function dedent2(templ) {
|
|
84
|
+
for (var values = [], _i = 1; _i < arguments.length; _i++)
|
|
85
|
+
values[_i - 1] = arguments[_i];
|
|
86
|
+
var strings = Array.from(typeof templ == "string" ? [templ] : templ);
|
|
87
|
+
strings[strings.length - 1] = strings[strings.length - 1].replace(
|
|
88
|
+
/\r?\n([\t ]*)$/,
|
|
89
|
+
""
|
|
90
|
+
);
|
|
91
|
+
var indentLengths = strings.reduce(function(arr, str) {
|
|
92
|
+
var matches = str.match(/\n([\t ]+|(?!\s).)/g);
|
|
93
|
+
return matches ? arr.concat(
|
|
94
|
+
matches.map(function(match) {
|
|
95
|
+
var _a, _b;
|
|
96
|
+
return (_b = (_a = match.match(/[\t ]/g)) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
|
97
|
+
})
|
|
98
|
+
) : arr;
|
|
99
|
+
}, []);
|
|
100
|
+
if (indentLengths.length) {
|
|
101
|
+
var pattern_1 = new RegExp(
|
|
102
|
+
`
|
|
103
|
+
[ ]{` + Math.min.apply(Math, indentLengths) + "}",
|
|
104
|
+
"g"
|
|
105
|
+
);
|
|
106
|
+
strings = strings.map(function(str) {
|
|
107
|
+
return str.replace(pattern_1, `
|
|
108
|
+
`);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
strings[0] = strings[0].replace(/^\r?\n/, "");
|
|
112
|
+
var string = strings[0];
|
|
113
|
+
return values.forEach(function(value, i) {
|
|
114
|
+
var endentations = string.match(/(?:^|\n)( *)$/), endentation = endentations ? endentations[1] : "", indentedValue = value;
|
|
115
|
+
typeof value == "string" && value.includes(`
|
|
116
|
+
`) && (indentedValue = String(value).split(`
|
|
117
|
+
`).map(function(str, i2) {
|
|
118
|
+
return i2 === 0 ? str : "" + endentation + str;
|
|
119
|
+
}).join(`
|
|
120
|
+
`)), string += indentedValue + strings[i + 1];
|
|
121
|
+
}), string;
|
|
122
|
+
}
|
|
123
|
+
exports.TW = dedent2, __webpack_unused_export__ = dedent2;
|
|
124
|
+
}
|
|
125
|
+
}, __webpack_module_cache__ = {};
|
|
126
|
+
function __nccwpck_require__(moduleId) {
|
|
127
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
128
|
+
if (cachedModule !== void 0)
|
|
129
|
+
return cachedModule.exports;
|
|
130
|
+
var module = __webpack_module_cache__[moduleId] = { exports: {} }, threw = !0;
|
|
131
|
+
try {
|
|
132
|
+
__webpack_modules__[moduleId](module, module.exports, __nccwpck_require__), threw = !1;
|
|
133
|
+
} finally {
|
|
134
|
+
threw && delete __webpack_module_cache__[moduleId];
|
|
135
|
+
}
|
|
136
|
+
return module.exports;
|
|
137
|
+
}
|
|
138
|
+
__nccwpck_require__.d = (exports, definition) => {
|
|
139
|
+
for (var key in definition)
|
|
140
|
+
__nccwpck_require__.o(definition, key) && !__nccwpck_require__.o(exports, key) && Object.defineProperty(exports, key, {
|
|
141
|
+
enumerable: !0,
|
|
142
|
+
get: definition[key]
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
__nccwpck_require__.o = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
|
|
146
|
+
typeof __nccwpck_require__ < "u" && (__nccwpck_require__.ab = new URL(".", import.meta.url).pathname.slice(
|
|
147
|
+
import.meta.url.match(/^file:\/\/\/\w:/) ? 1 : 0,
|
|
148
|
+
-1
|
|
149
|
+
) + "/");
|
|
150
|
+
var __webpack_exports__ = {};
|
|
151
|
+
__nccwpck_require__.d(__webpack_exports__, {
|
|
152
|
+
il: () => checkWebpackVersion,
|
|
153
|
+
Tu: () => loadCustomWebpackConfig,
|
|
154
|
+
SV: () => mergeConfigs,
|
|
155
|
+
T1: () => toImportFn,
|
|
156
|
+
i8: () => toImportFnPart,
|
|
157
|
+
sg: () => toRequireContext,
|
|
158
|
+
HO: () => toRequireContextString,
|
|
159
|
+
hO: () => webpackIncludeRegexp
|
|
160
|
+
});
|
|
161
|
+
var external_node_url_namespaceObject = __WEBPACK_EXTERNAL_createRequire(
|
|
162
|
+
import.meta.url
|
|
163
|
+
)("node:url"), external_node_path_namespaceObject = __WEBPACK_EXTERNAL_createRequire(
|
|
164
|
+
import.meta.url
|
|
165
|
+
)("node:path"), external_node_module_namespaceObject = __WEBPACK_EXTERNAL_createRequire(
|
|
166
|
+
import.meta.url
|
|
167
|
+
)("node:module"), x = (y) => {
|
|
168
|
+
var x2 = {};
|
|
169
|
+
return __nccwpck_require__.d(x2, y), x2;
|
|
170
|
+
};
|
|
171
|
+
var common_namespaceObject = x({
|
|
172
|
+
globToRegexp: () => __WEBPACK_EXTERNAL_MODULE_storybook_internal_common_7991bda6__.globToRegexp,
|
|
173
|
+
serverRequire: () => __WEBPACK_EXTERNAL_MODULE_storybook_internal_common_7991bda6__.serverRequire
|
|
174
|
+
}), node_logger_x = (y) => {
|
|
175
|
+
var x2 = {};
|
|
176
|
+
return __nccwpck_require__.d(x2, y), x2;
|
|
177
|
+
};
|
|
178
|
+
var node_logger_namespaceObject = node_logger_x({
|
|
179
|
+
logger: () => __WEBPACK_EXTERNAL_MODULE_storybook_internal_node_logger_87de4309__.logger
|
|
180
|
+
}), dist = __nccwpck_require__(980), dist_filename = external_node_url_namespaceObject.fileURLToPath(
|
|
181
|
+
import.meta.url
|
|
182
|
+
), dist_dirname = external_node_path_namespaceObject.dirname(dist_filename), dist_require = external_node_module_namespaceObject.createRequire(
|
|
183
|
+
import.meta.url
|
|
184
|
+
), __defProp = Object.defineProperty, __name = (target, value) => __defProp(target, "name", { value, configurable: !0 }), webpackConfigs = ["webpack.config", "webpackfile"], loadCustomWebpackConfig = __name(
|
|
185
|
+
async (configDir) => (0, common_namespaceObject.serverRequire)(
|
|
186
|
+
webpackConfigs.map(
|
|
187
|
+
(configName) => (0, external_node_path_namespaceObject.resolve)(configDir, configName)
|
|
188
|
+
)
|
|
189
|
+
),
|
|
190
|
+
"loadCustomWebpackConfig"
|
|
191
|
+
), checkWebpackVersion = __name((webpack, specifier, caption) => {
|
|
192
|
+
if (!webpack.version) {
|
|
193
|
+
node_logger_namespaceObject.logger.info(
|
|
194
|
+
"Skipping webpack version check, no version available"
|
|
195
|
+
);
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
webpack.version !== specifier && node_logger_namespaceObject.logger.warn((0, dist.TW)`
|
|
155
199
|
Unexpected webpack version in ${caption}:
|
|
156
200
|
- Received '${webpack.version}'
|
|
157
201
|
- Expected '${specifier}'
|
|
@@ -160,79 +204,80 @@ var require_core_webpack = __commonJS({
|
|
|
160
204
|
|
|
161
205
|
For more info about Webpack 5 support: https://gist.github.com/shilman/8856ea1786dcd247139b47b270912324#troubleshooting
|
|
162
206
|
`);
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
207
|
+
}, "checkWebpackVersion");
|
|
208
|
+
function mergePluginsField(defaultPlugins = [], customPlugins = []) {
|
|
209
|
+
return [...defaultPlugins, ...customPlugins];
|
|
210
|
+
}
|
|
211
|
+
__name(mergePluginsField, "mergePluginsField");
|
|
212
|
+
function mergeRulesField(defaultRules = [], customRules = []) {
|
|
213
|
+
return [...defaultRules, ...customRules];
|
|
214
|
+
}
|
|
215
|
+
__name(mergeRulesField, "mergeRulesField");
|
|
216
|
+
function mergeExtensionsField({ extensions: defaultExtensions = [] }, { extensions: customExtensions = [] }) {
|
|
217
|
+
return [...defaultExtensions, ...customExtensions];
|
|
218
|
+
}
|
|
219
|
+
__name(mergeExtensionsField, "mergeExtensionsField");
|
|
220
|
+
function mergeAliasField({ alias: defaultAlias = {} }, { alias: customAlias = {} }) {
|
|
221
|
+
return { ...defaultAlias, ...customAlias };
|
|
222
|
+
}
|
|
223
|
+
__name(mergeAliasField, "mergeAliasField");
|
|
224
|
+
function mergeModuleField(a, b) {
|
|
225
|
+
return { ...a, ...b, rules: mergeRulesField(a.rules || [], b.rules || []) };
|
|
226
|
+
}
|
|
227
|
+
__name(mergeModuleField, "mergeModuleField");
|
|
228
|
+
function mergeResolveField({ resolve: defaultResolve = {} }, { resolve: customResolve = {} }) {
|
|
229
|
+
return {
|
|
230
|
+
...defaultResolve,
|
|
231
|
+
...customResolve,
|
|
232
|
+
alias: mergeAliasField(defaultResolve, customResolve),
|
|
233
|
+
extensions: mergeExtensionsField(defaultResolve, customResolve)
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
__name(mergeResolveField, "mergeResolveField");
|
|
237
|
+
function mergeOptimizationField({ optimization: defaultOptimization = {} }, { optimization: customOptimization = {} }) {
|
|
238
|
+
return { ...defaultOptimization, ...customOptimization };
|
|
239
|
+
}
|
|
240
|
+
__name(mergeOptimizationField, "mergeOptimizationField");
|
|
241
|
+
function mergeConfigs(config, customConfig) {
|
|
242
|
+
return {
|
|
243
|
+
...customConfig,
|
|
244
|
+
...config,
|
|
245
|
+
devtool: customConfig.devtool || config.devtool,
|
|
246
|
+
plugins: mergePluginsField(config.plugins, customConfig.plugins),
|
|
247
|
+
module: mergeModuleField(config.module || {}, customConfig.module || {}),
|
|
248
|
+
resolve: mergeResolveField(config, customConfig),
|
|
249
|
+
optimization: mergeOptimizationField(config, customConfig)
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
__name(mergeConfigs, "mergeConfigs");
|
|
253
|
+
function importPipeline() {
|
|
254
|
+
let importGate = Promise.resolve();
|
|
255
|
+
return async (importFn) => {
|
|
256
|
+
await importGate;
|
|
257
|
+
let moduleExportsPromise = importFn();
|
|
258
|
+
return importGate = importGate.then(async () => {
|
|
259
|
+
await moduleExportsPromise;
|
|
260
|
+
}), moduleExportsPromise;
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
__name(importPipeline, "importPipeline");
|
|
264
|
+
function adjustRegexToExcludeNodeModules(originalRegex) {
|
|
265
|
+
let originalRegexString = originalRegex.source, startsWithCaret = originalRegexString.startsWith("^"), excludeNodeModulesPattern = startsWithCaret ? "(?!.*node_modules)" : "^(?!.*node_modules)", adjustedRegexString = startsWithCaret ? `^${excludeNodeModulesPattern}${originalRegexString.substring(1)}` : excludeNodeModulesPattern + originalRegexString;
|
|
266
|
+
return new RegExp(adjustedRegexString);
|
|
267
|
+
}
|
|
268
|
+
__name(adjustRegexToExcludeNodeModules, "adjustRegexToExcludeNodeModules");
|
|
269
|
+
function webpackIncludeRegexp(specifier) {
|
|
270
|
+
let { directory, files } = specifier, directoryWithoutLeadingDots = directory.replace(/^(\.+\/)+/, "/"), webpackIncludeGlob = [".", ".."].includes(directory) ? files : `${directoryWithoutLeadingDots}/${files}`, webpackIncludeRegexpWithCaret = webpackIncludeGlob.includes(
|
|
271
|
+
"node_modules"
|
|
272
|
+
) ? (0, common_namespaceObject.globToRegexp)(webpackIncludeGlob) : adjustRegexToExcludeNodeModules(
|
|
273
|
+
(0, common_namespaceObject.globToRegexp)(webpackIncludeGlob)
|
|
274
|
+
);
|
|
275
|
+
return new RegExp(webpackIncludeRegexpWithCaret.source.replace(/^\^/, ""));
|
|
276
|
+
}
|
|
277
|
+
__name(webpackIncludeRegexp, "webpackIncludeRegexp");
|
|
278
|
+
function toImportFnPart(specifier) {
|
|
279
|
+
let { directory, importPathMatcher } = specifier;
|
|
280
|
+
return (0, dist.TW)`
|
|
236
281
|
async (path) => {
|
|
237
282
|
if (!${importPathMatcher}.exec(path)) {
|
|
238
283
|
return;
|
|
@@ -247,13 +292,14 @@ var require_core_webpack = __commonJS({
|
|
|
247
292
|
}
|
|
248
293
|
|
|
249
294
|
`;
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
295
|
+
}
|
|
296
|
+
__name(toImportFnPart, "toImportFnPart");
|
|
297
|
+
function toImportFn(stories, { needPipelinedImport } = {}) {
|
|
298
|
+
let pipelinedImport = "const pipeline = (x) => x();";
|
|
299
|
+
return needPipelinedImport && (pipelinedImport = `
|
|
254
300
|
const importPipeline = ${importPipeline};
|
|
255
301
|
const pipeline = importPipeline();
|
|
256
|
-
`),
|
|
302
|
+
`), (0, dist.TW)`
|
|
257
303
|
${pipelinedImport}
|
|
258
304
|
|
|
259
305
|
const importers = [
|
|
@@ -270,215 +316,61 @@ var require_core_webpack = __commonJS({
|
|
|
270
316
|
}
|
|
271
317
|
}
|
|
272
318
|
`;
|
|
273
|
-
}
|
|
274
|
-
var import_common32 = __nccwpck_require__2(253), toRequireContext = (specifier) => {
|
|
275
|
-
let { directory, files } = specifier, match = (0, import_common32.globToRegexp)(`./${files}`);
|
|
276
|
-
return {
|
|
277
|
-
path: directory,
|
|
278
|
-
recursive: files.includes("**") || files.split("/").length > 1,
|
|
279
|
-
match
|
|
280
|
-
};
|
|
281
|
-
}, toRequireContextString = (specifier) => {
|
|
282
|
-
let { path: p, recursive: r, match: m } = toRequireContext(specifier);
|
|
283
|
-
return `require.context('${p}', ${r}, ${m})`;
|
|
284
|
-
};
|
|
285
|
-
},
|
|
286
|
-
980: (__unused_webpack_module, exports2) => {
|
|
287
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
288
|
-
exports2.dedent = void 0;
|
|
289
|
-
function dedent2(templ) {
|
|
290
|
-
var values = [];
|
|
291
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
292
|
-
values[_i - 1] = arguments[_i];
|
|
293
|
-
}
|
|
294
|
-
var strings = Array.from(typeof templ === "string" ? [templ] : templ);
|
|
295
|
-
strings[strings.length - 1] = strings[strings.length - 1].replace(
|
|
296
|
-
/\r?\n([\t ]*)$/,
|
|
297
|
-
""
|
|
298
|
-
);
|
|
299
|
-
var indentLengths = strings.reduce(function(arr, str) {
|
|
300
|
-
var matches = str.match(/\n([\t ]+|(?!\s).)/g);
|
|
301
|
-
if (matches) {
|
|
302
|
-
return arr.concat(
|
|
303
|
-
matches.map(function(match) {
|
|
304
|
-
var _a, _b;
|
|
305
|
-
return (_b = (_a = match.match(/[\t ]/g)) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
|
306
|
-
})
|
|
307
|
-
);
|
|
308
|
-
}
|
|
309
|
-
return arr;
|
|
310
|
-
}, []);
|
|
311
|
-
if (indentLengths.length) {
|
|
312
|
-
var pattern_1 = new RegExp(
|
|
313
|
-
"\n[ ]{" + Math.min.apply(Math, indentLengths) + "}",
|
|
314
|
-
"g"
|
|
315
|
-
);
|
|
316
|
-
strings = strings.map(function(str) {
|
|
317
|
-
return str.replace(pattern_1, "\n");
|
|
318
|
-
});
|
|
319
|
-
}
|
|
320
|
-
strings[0] = strings[0].replace(/^\r?\n/, "");
|
|
321
|
-
var string = strings[0];
|
|
322
|
-
values.forEach(function(value, i) {
|
|
323
|
-
var endentations = string.match(/(?:^|\n)( *)$/);
|
|
324
|
-
var endentation = endentations ? endentations[1] : "";
|
|
325
|
-
var indentedValue = value;
|
|
326
|
-
if (typeof value === "string" && value.includes("\n")) {
|
|
327
|
-
indentedValue = String(value).split("\n").map(function(str, i2) {
|
|
328
|
-
return i2 === 0 ? str : "" + endentation + str;
|
|
329
|
-
}).join("\n");
|
|
330
|
-
}
|
|
331
|
-
string += indentedValue + strings[i + 1];
|
|
332
|
-
});
|
|
333
|
-
return string;
|
|
334
|
-
}
|
|
335
|
-
exports2.dedent = dedent2;
|
|
336
|
-
exports2["default"] = dedent2;
|
|
337
|
-
},
|
|
338
|
-
928: (module3) => {
|
|
339
|
-
module3.exports = require("path");
|
|
340
|
-
},
|
|
341
|
-
253: (module3) => {
|
|
342
|
-
module3.exports = require("storybook/internal/common");
|
|
343
|
-
},
|
|
344
|
-
519: (module3) => {
|
|
345
|
-
module3.exports = require("storybook/internal/node-logger");
|
|
346
|
-
}
|
|
347
|
-
};
|
|
348
|
-
var __webpack_module_cache__ = {};
|
|
349
|
-
function __nccwpck_require__(moduleId) {
|
|
350
|
-
var cachedModule = __webpack_module_cache__[moduleId];
|
|
351
|
-
if (cachedModule !== void 0) {
|
|
352
|
-
return cachedModule.exports;
|
|
353
|
-
}
|
|
354
|
-
var module3 = __webpack_module_cache__[moduleId] = { exports: {} };
|
|
355
|
-
var threw = true;
|
|
356
|
-
try {
|
|
357
|
-
__webpack_modules__[moduleId](
|
|
358
|
-
module3,
|
|
359
|
-
module3.exports,
|
|
360
|
-
__nccwpck_require__
|
|
361
|
-
);
|
|
362
|
-
threw = false;
|
|
363
|
-
} finally {
|
|
364
|
-
if (threw)
|
|
365
|
-
delete __webpack_module_cache__[moduleId];
|
|
366
|
-
}
|
|
367
|
-
return module3.exports;
|
|
368
|
-
}
|
|
369
|
-
if (typeof __nccwpck_require__ !== "undefined")
|
|
370
|
-
__nccwpck_require__.ab = __dirname + "/";
|
|
371
|
-
var __webpack_exports__ = __nccwpck_require__(830);
|
|
372
|
-
module2.exports = __webpack_exports__;
|
|
373
|
-
})();
|
|
374
|
-
}
|
|
375
|
-
});
|
|
376
|
-
|
|
377
|
-
// src/index.ts
|
|
378
|
-
var src_exports = {};
|
|
379
|
-
__export(src_exports, {
|
|
380
|
-
bail: () => bail,
|
|
381
|
-
build: () => build,
|
|
382
|
-
corePresets: () => corePresets,
|
|
383
|
-
executor: () => executor,
|
|
384
|
-
getConfig: () => getConfig,
|
|
385
|
-
getVirtualModules: () => getVirtualModules,
|
|
386
|
-
previewMainTemplate: () => previewMainTemplate,
|
|
387
|
-
printDuration: () => printDuration,
|
|
388
|
-
start: () => start
|
|
389
|
-
});
|
|
390
|
-
module.exports = __toCommonJS(src_exports);
|
|
391
|
-
var import_node_net = require("net");
|
|
392
|
-
var import_node_path4 = require("path");
|
|
393
|
-
var rsbuildReal = __toESM(require("@rsbuild/core"));
|
|
394
|
-
var import_fs_extra = __toESM(require("fs-extra"));
|
|
395
|
-
var import_pretty_hrtime = __toESM(require_pretty_hrtime());
|
|
396
|
-
var import_sirv = __toESM(require("sirv"));
|
|
397
|
-
var import_common3 = require("storybook/internal/common");
|
|
398
|
-
var import_server_errors = require("storybook/internal/server-errors");
|
|
399
|
-
|
|
400
|
-
// src/preview/iframe-rsbuild.config.ts
|
|
401
|
-
var import_node_path2 = require("path");
|
|
402
|
-
var import_core = require("@rsbuild/core");
|
|
403
|
-
var import_plugin_type_check = require("@rsbuild/plugin-type-check");
|
|
404
|
-
var import_case_sensitive_paths_webpack_plugin = __toESM(require("case-sensitive-paths-webpack-plugin"));
|
|
405
|
-
var import_rsbuild_plugin_html_minifier_terser = require("rsbuild-plugin-html-minifier-terser");
|
|
406
|
-
var import_common2 = require("storybook/internal/common");
|
|
407
|
-
var import_globals = require("storybook/internal/preview/globals");
|
|
408
|
-
var import_ts_dedent = require("ts-dedent");
|
|
409
|
-
|
|
410
|
-
// src/preview/virtual-module-mapping.ts
|
|
411
|
-
var import_node_path = require("path");
|
|
412
|
-
|
|
413
|
-
// ../../node_modules/.pnpm/slash@5.1.0/node_modules/slash/index.js
|
|
414
|
-
function slash(path) {
|
|
415
|
-
const isExtendedLengthPath = path.startsWith("\\\\?\\");
|
|
416
|
-
if (isExtendedLengthPath) {
|
|
417
|
-
return path;
|
|
418
|
-
}
|
|
419
|
-
return path.replace(/\\/g, "/");
|
|
420
319
|
}
|
|
320
|
+
__name(toImportFn, "toImportFn");
|
|
321
|
+
var toRequireContext = __name((specifier) => {
|
|
322
|
+
let { directory, files } = specifier, match = (0, common_namespaceObject.globToRegexp)(`./${files}`);
|
|
323
|
+
return {
|
|
324
|
+
path: directory,
|
|
325
|
+
recursive: files.includes("**") || files.split("/").length > 1,
|
|
326
|
+
match
|
|
327
|
+
};
|
|
328
|
+
}, "toRequireContext"), toRequireContextString = __name((specifier) => {
|
|
329
|
+
let { path: p, recursive: r, match: m } = toRequireContext(specifier);
|
|
330
|
+
return `require.context('${p}', ${r}, ${m})`;
|
|
331
|
+
}, "toRequireContextString"), __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;
|
|
421
332
|
|
|
422
333
|
// src/preview/virtual-module-mapping.ts
|
|
423
|
-
var import_common = require("storybook/internal/common");
|
|
424
|
-
var import_core_webpack = __toESM(require_core_webpack());
|
|
425
334
|
var getVirtualModules = async (options) => {
|
|
426
|
-
|
|
427
|
-
const builderOptions = await (0, import_common.getBuilderOptions)(options);
|
|
428
|
-
const workingDir = process.cwd();
|
|
429
|
-
const isProd = options.configType === "PRODUCTION";
|
|
430
|
-
const nonNormalizedStories = await options.presets.apply("stories", []);
|
|
431
|
-
const entries = [];
|
|
432
|
-
const stories = (0, import_common.normalizeStories)(nonNormalizedStories, {
|
|
335
|
+
let virtualModules = {}, builderOptions = await getBuilderOptions(options), workingDir = process.cwd(), isProd = options.configType === "PRODUCTION", nonNormalizedStories = await options.presets.apply("stories", []), entries = [], stories = normalizeStories(nonNormalizedStories, {
|
|
433
336
|
configDir: options.configDir,
|
|
434
337
|
workingDir
|
|
435
|
-
})
|
|
436
|
-
const previewAnnotations = [
|
|
338
|
+
}), previewAnnotations = [
|
|
437
339
|
...(await options.presets.apply(
|
|
438
340
|
"previewAnnotations",
|
|
439
341
|
[],
|
|
440
342
|
options
|
|
441
|
-
)).map((entry) =>
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
return slash(entry);
|
|
446
|
-
}),
|
|
447
|
-
(0, import_common.loadPreviewOrConfigFile)(options)
|
|
448
|
-
].filter(Boolean);
|
|
449
|
-
const storiesFilename = "storybook-stories.js";
|
|
450
|
-
const storiesPath = (0, import_node_path.resolve)((0, import_node_path.join)(workingDir, storiesFilename));
|
|
451
|
-
const needPipelinedImport = !!builderOptions.lazyCompilation && !isProd;
|
|
452
|
-
virtualModules[storiesPath] = (0, import_core_webpack.toImportFn)(stories, {
|
|
343
|
+
)).map((entry) => typeof entry == "object" ? entry.absolute : slash(entry)),
|
|
344
|
+
loadPreviewOrConfigFile(options)
|
|
345
|
+
].filter(Boolean), storiesFilename = "storybook-stories.js", storiesPath = resolve(join(workingDir, storiesFilename)), needPipelinedImport = !!builderOptions.lazyCompilation && !isProd;
|
|
346
|
+
virtualModules[storiesPath] = __webpack_exports__toImportFn(stories, {
|
|
453
347
|
needPipelinedImport
|
|
454
348
|
});
|
|
455
|
-
|
|
456
|
-
virtualModules[configEntryPath] = (await
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
349
|
+
let configEntryPath = resolve(join(workingDir, "storybook-config-entry.js"));
|
|
350
|
+
return virtualModules[configEntryPath] = (await readTemplate(
|
|
351
|
+
__require.resolve(
|
|
352
|
+
"storybook-builder-rsbuild/templates/virtualModuleModernEntry.js"
|
|
353
|
+
)
|
|
354
|
+
)).replaceAll("'{{storiesFilename}}'", `'./${storiesFilename}'`).replaceAll(
|
|
355
|
+
"'{{previewAnnotations}}'",
|
|
460
356
|
previewAnnotations.filter(Boolean).map((entry) => `'${entry}'`).join(",")
|
|
461
357
|
).replaceAll(
|
|
462
|
-
|
|
358
|
+
"'{{previewAnnotations_requires}}'",
|
|
463
359
|
previewAnnotations.filter(Boolean).map((entry) => `require('${entry}')`).join(",")
|
|
464
|
-
).replace(/\\/g, "\\\\")
|
|
465
|
-
entries.push(configEntryPath);
|
|
466
|
-
return {
|
|
360
|
+
).replace(/\\/g, "\\\\"), entries.push(configEntryPath), {
|
|
467
361
|
virtualModules,
|
|
468
362
|
entries
|
|
469
363
|
};
|
|
470
364
|
};
|
|
471
365
|
|
|
472
366
|
// src/preview/iframe-rsbuild.config.ts
|
|
473
|
-
var getAbsolutePath = (input) =>
|
|
474
|
-
var maybeGetAbsolutePath = (input) => {
|
|
367
|
+
var getAbsolutePath = (input) => dirname(__require.resolve(join2(input, "package.json"))), maybeGetAbsolutePath = (input) => {
|
|
475
368
|
try {
|
|
476
369
|
return getAbsolutePath(input);
|
|
477
|
-
} catch
|
|
478
|
-
return
|
|
370
|
+
} catch {
|
|
371
|
+
return !1;
|
|
479
372
|
}
|
|
480
|
-
}
|
|
481
|
-
var builtInResolveExtensions = [
|
|
373
|
+
}, builtInResolveExtensions = [
|
|
482
374
|
".mjs",
|
|
483
375
|
".js",
|
|
484
376
|
".jsx",
|
|
@@ -486,22 +378,16 @@ var builtInResolveExtensions = [
|
|
|
486
378
|
".tsx",
|
|
487
379
|
".json",
|
|
488
380
|
".cjs"
|
|
489
|
-
]
|
|
490
|
-
var globalPath = maybeGetAbsolutePath("@storybook/global");
|
|
491
|
-
var storybookPaths = {
|
|
381
|
+
], globalPath = maybeGetAbsolutePath("@storybook/global"), storybookPaths = {
|
|
492
382
|
// biome-ignore lint/complexity/useLiteralKeys: <explanation>
|
|
493
|
-
...globalPath ? {
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
);
|
|
502
|
-
}
|
|
503
|
-
const {
|
|
504
|
-
outputDir = (0, import_node_path2.join)(".", "public"),
|
|
383
|
+
...globalPath ? { "@storybook/global": globalPath } : {}
|
|
384
|
+
}, iframe_rsbuild_config_default = async (options, extraWebpackConfig) => {
|
|
385
|
+
let { rsbuildConfigPath, addonDocs } = await getBuilderOptions2(options), webpackConfigFromPresets = await options.presets.apply("webpack", {}, options);
|
|
386
|
+
addonDocs && console.warn(
|
|
387
|
+
"`addonDocs` option is deprecated and will be removed in future versions. Please use `@storybook/addon-docs` option instead."
|
|
388
|
+
);
|
|
389
|
+
let {
|
|
390
|
+
outputDir = join2(".", "public"),
|
|
505
391
|
quiet,
|
|
506
392
|
packageJson,
|
|
507
393
|
configType,
|
|
@@ -509,10 +395,7 @@ var iframe_rsbuild_config_default = async (options, extraWebpackConfig) => {
|
|
|
509
395
|
previewUrl,
|
|
510
396
|
typescriptOptions,
|
|
511
397
|
features
|
|
512
|
-
} = options
|
|
513
|
-
const isProd = configType === "PRODUCTION";
|
|
514
|
-
const workingDir = process.cwd();
|
|
515
|
-
const [
|
|
398
|
+
} = options, isProd = configType === "PRODUCTION", workingDir = process.cwd(), [
|
|
516
399
|
coreOptions,
|
|
517
400
|
frameworkOptions,
|
|
518
401
|
envs,
|
|
@@ -540,84 +423,68 @@ var iframe_rsbuild_config_default = async (options, extraWebpackConfig) => {
|
|
|
540
423
|
options.cache?.get("modulesCount", 1e3),
|
|
541
424
|
options.presets.apply("build"),
|
|
542
425
|
presets.apply("tags", {})
|
|
543
|
-
])
|
|
544
|
-
const stories = (0, import_common2.normalizeStories)(nonNormalizedStories, {
|
|
426
|
+
]), stories = normalizeStories2(nonNormalizedStories, {
|
|
545
427
|
configDir: options.configDir,
|
|
546
428
|
workingDir
|
|
547
|
-
})
|
|
548
|
-
|
|
549
|
-
const tsCheckOptions = typescriptOptions.checkOptions || {};
|
|
550
|
-
const builderOptions = await (0, import_common2.getBuilderOptions)(options);
|
|
551
|
-
const cacheConfig = builderOptions.fsCache ? true : void 0;
|
|
552
|
-
const lazyCompilationConfig = builderOptions.lazyCompilation && !isProd ? {
|
|
553
|
-
lazyCompilation: { entries: false }
|
|
429
|
+
}), shouldCheckTs = typescriptOptions.check && !typescriptOptions.skipCompiler, tsCheckOptions = typescriptOptions.checkOptions || {}, builderOptions = await getBuilderOptions2(options), cacheConfig = builderOptions.fsCache ? !0 : void 0, lazyCompilationConfig = builderOptions.lazyCompilation && !isProd ? {
|
|
430
|
+
lazyCompilation: { entries: !1 }
|
|
554
431
|
} : {};
|
|
555
|
-
if (!template)
|
|
556
|
-
throw new Error(
|
|
432
|
+
if (!template)
|
|
433
|
+
throw new Error(dedent`
|
|
557
434
|
Storybook's Webpack5 builder requires a template to be specified.
|
|
558
435
|
Somehow you've ended up with a falsy value for the template option.
|
|
559
436
|
|
|
560
437
|
Please file an issue at https://github.com/storybookjs/storybook with a reproduction.
|
|
561
438
|
`);
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
}
|
|
567
|
-
const { virtualModules: virtualModuleMapping, entries: dynamicEntries } = await getVirtualModules(options);
|
|
568
|
-
if (!options.cache) {
|
|
439
|
+
let externals = globalsNameReferenceMap;
|
|
440
|
+
build2?.test?.disableBlocks && (externals["@storybook/blocks"] = "__STORYBOOK_BLOCKS_EMPTY_MODULE__");
|
|
441
|
+
let { virtualModules: virtualModuleMapping, entries: dynamicEntries } = await getVirtualModules(options);
|
|
442
|
+
if (!options.cache)
|
|
569
443
|
throw new Error("Cache is required");
|
|
570
|
-
}
|
|
571
|
-
let contentFromConfig = {};
|
|
572
|
-
const { content } = await (0, import_core.loadConfig)({
|
|
444
|
+
let contentFromConfig = {}, { content } = await loadConfig({
|
|
573
445
|
cwd: workingDir,
|
|
574
446
|
path: rsbuildConfigPath
|
|
575
|
-
});
|
|
576
|
-
const { environments, ...withoutEnv } = content;
|
|
447
|
+
}), { environments, ...withoutEnv } = content;
|
|
577
448
|
if (content.environments) {
|
|
578
|
-
|
|
579
|
-
if (envCount === 0)
|
|
449
|
+
let envCount = Object.keys(content.environments).length;
|
|
450
|
+
if (envCount === 0)
|
|
580
451
|
contentFromConfig = withoutEnv;
|
|
581
|
-
|
|
582
|
-
contentFromConfig =
|
|
452
|
+
else if (envCount === 1)
|
|
453
|
+
contentFromConfig = mergeRsbuildConfig(
|
|
583
454
|
withoutEnv,
|
|
584
455
|
content.environments[0]
|
|
585
456
|
);
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
if (typeof userEnv
|
|
457
|
+
else {
|
|
458
|
+
let userEnv = builderOptions.environment;
|
|
459
|
+
if (typeof userEnv != "string")
|
|
589
460
|
throw new Error(
|
|
590
461
|
"You must specify an environment when there are multiple environments in the Rsbuild config."
|
|
591
462
|
);
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
contentFromConfig = (0, import_core.mergeRsbuildConfig)(
|
|
463
|
+
if (Object.keys(content.environments).includes(userEnv))
|
|
464
|
+
contentFromConfig = mergeRsbuildConfig(
|
|
595
465
|
withoutEnv,
|
|
596
466
|
content.environments[userEnv]
|
|
597
467
|
);
|
|
598
|
-
|
|
468
|
+
else
|
|
599
469
|
throw new Error(
|
|
600
470
|
`The specified environment "${userEnv}" is not found in the Rsbuild config.`
|
|
601
471
|
);
|
|
602
|
-
}
|
|
603
472
|
}
|
|
604
|
-
} else
|
|
473
|
+
} else
|
|
605
474
|
contentFromConfig = content;
|
|
606
|
-
|
|
607
|
-
const resourceFilename = isProd ? "static/media/[name].[contenthash:8][ext]" : "static/media/[path][name][ext]";
|
|
608
|
-
const rsbuildConfig = (0, import_core.mergeRsbuildConfig)(contentFromConfig, {
|
|
475
|
+
let resourceFilename = isProd ? "static/media/[name].[contenthash:8][ext]" : "static/media/[path][name][ext]", rsbuildConfig = mergeRsbuildConfig(contentFromConfig, {
|
|
609
476
|
output: {
|
|
610
|
-
cleanDistPath:
|
|
477
|
+
cleanDistPath: !1,
|
|
611
478
|
assetPrefix: "/",
|
|
612
479
|
dataUriLimit: {
|
|
613
480
|
media: 1e4
|
|
614
481
|
},
|
|
615
482
|
sourceMap: {
|
|
616
|
-
js: options.build?.test?.disableSourcemaps ?
|
|
483
|
+
js: options.build?.test?.disableSourcemaps ? !1 : "cheap-module-source-map",
|
|
617
484
|
css: !options.build?.test?.disableSourcemaps
|
|
618
485
|
},
|
|
619
486
|
distPath: {
|
|
620
|
-
root: (
|
|
487
|
+
root: resolve2(process.cwd(), outputDir)
|
|
621
488
|
},
|
|
622
489
|
filename: {
|
|
623
490
|
js: isProd ? "[name].[contenthash:8].iframe.bundle.js" : "[name].iframe.bundle.js",
|
|
@@ -630,7 +497,7 @@ var iframe_rsbuild_config_default = async (options, extraWebpackConfig) => {
|
|
|
630
497
|
server: {
|
|
631
498
|
// Storybook will handle public directory itself, disable Rsbuild's public dir
|
|
632
499
|
// feature to prevent overwriting Storybook's public directory.
|
|
633
|
-
publicDir:
|
|
500
|
+
publicDir: !1
|
|
634
501
|
},
|
|
635
502
|
dev: {
|
|
636
503
|
assetPrefix: "/",
|
|
@@ -643,7 +510,7 @@ var iframe_rsbuild_config_default = async (options, extraWebpackConfig) => {
|
|
|
643
510
|
},
|
|
644
511
|
source: {
|
|
645
512
|
define: {
|
|
646
|
-
...
|
|
513
|
+
...stringifyProcessEnvs(envs),
|
|
647
514
|
NODE_ENV: JSON.stringify(process.env.NODE_ENV)
|
|
648
515
|
}
|
|
649
516
|
},
|
|
@@ -657,95 +524,66 @@ var iframe_rsbuild_config_default = async (options, extraWebpackConfig) => {
|
|
|
657
524
|
buildCache: cacheConfig
|
|
658
525
|
},
|
|
659
526
|
plugins: [
|
|
660
|
-
shouldCheckTs ?
|
|
661
|
-
|
|
662
|
-
collapseWhitespace:
|
|
663
|
-
removeComments:
|
|
664
|
-
removeRedundantAttributes:
|
|
665
|
-
removeScriptTypeAttributes:
|
|
666
|
-
removeStyleLinkTypeAttributes:
|
|
667
|
-
useShortDoctype:
|
|
527
|
+
shouldCheckTs ? pluginTypeCheck(tsCheckOptions) : null,
|
|
528
|
+
pluginHtmlMinifierTerser(() => ({
|
|
529
|
+
collapseWhitespace: !0,
|
|
530
|
+
removeComments: !0,
|
|
531
|
+
removeRedundantAttributes: !0,
|
|
532
|
+
removeScriptTypeAttributes: !1,
|
|
533
|
+
removeStyleLinkTypeAttributes: !0,
|
|
534
|
+
useShortDoctype: !0
|
|
668
535
|
}))
|
|
669
536
|
].filter(Boolean),
|
|
670
537
|
tools: {
|
|
671
538
|
rspack: (config, { addRules, rspack: rspack2, mergeConfig }) => {
|
|
672
|
-
addRules({
|
|
539
|
+
if (addRules({
|
|
673
540
|
test: /\.stories\.([tj])sx?$|(stories|story)\.mdx$/,
|
|
674
541
|
exclude: /node_modules/,
|
|
675
542
|
enforce: "post",
|
|
676
543
|
use: [
|
|
677
544
|
{
|
|
678
|
-
loader:
|
|
545
|
+
loader: __require.resolve(
|
|
546
|
+
"storybook-builder-rsbuild/loaders/export-order-loader"
|
|
547
|
+
)
|
|
679
548
|
}
|
|
680
549
|
]
|
|
681
|
-
})
|
|
682
|
-
config.module ??= {};
|
|
683
|
-
config.module.parser ??= {};
|
|
684
|
-
config.module.parser.javascript ??= {};
|
|
685
|
-
config.module.parser.javascript.unknownContextCritical = false;
|
|
686
|
-
config.resolve ??= {};
|
|
687
|
-
config.resolve.symlinks = !(0, import_common2.isPreservingSymlinks)();
|
|
688
|
-
config.resolve.extensions = Array.from(
|
|
550
|
+
}), config.module ??= {}, config.module.parser ??= {}, config.module.parser.javascript ??= {}, config.module.parser.javascript.unknownContextCritical = !1, config.resolve ??= {}, config.resolve.symlinks = !isPreservingSymlinks(), config.resolve.extensions = Array.from(
|
|
689
551
|
/* @__PURE__ */ new Set([
|
|
690
552
|
...config.resolve.extensions ?? [],
|
|
691
553
|
...builtInResolveExtensions
|
|
692
554
|
])
|
|
693
|
-
)
|
|
694
|
-
config.watchOptions = {
|
|
555
|
+
), config.watchOptions = {
|
|
695
556
|
ignored: /node_modules/
|
|
696
|
-
}
|
|
697
|
-
config.ignoreWarnings = [
|
|
557
|
+
}, config.ignoreWarnings = [
|
|
698
558
|
...config.ignoreWarnings || [],
|
|
699
559
|
/export '\S+' was not found in 'global'/,
|
|
700
560
|
/export '\S+' was not found in '@storybook\/global'/
|
|
701
|
-
]
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
constants: require.resolve("constants-browserify")
|
|
711
|
-
};
|
|
712
|
-
config.optimization ??= {};
|
|
713
|
-
config.optimization.runtimeChunk = true;
|
|
714
|
-
config.optimization.usedExports = options.build?.test?.disableTreeShaking ? false : isProd;
|
|
715
|
-
config.optimization.moduleIds = "named";
|
|
716
|
-
config.module ??= {};
|
|
717
|
-
config.module.parser ??= {};
|
|
718
|
-
config.module.parser.javascript ??= {};
|
|
719
|
-
config.module.parser.javascript.exportsPresence = false;
|
|
720
|
-
if (!rspack2.experiments?.VirtualModulesPlugin) {
|
|
561
|
+
], config.resolve ??= {}, config.resolve.fallback ??= {
|
|
562
|
+
stream: !1,
|
|
563
|
+
path: __require.resolve("path-browserify"),
|
|
564
|
+
assert: __require.resolve("browser-assert"),
|
|
565
|
+
util: __require.resolve("util"),
|
|
566
|
+
url: __require.resolve("url"),
|
|
567
|
+
fs: !1,
|
|
568
|
+
constants: __require.resolve("constants-browserify")
|
|
569
|
+
}, 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, !rspack2.experiments?.VirtualModulesPlugin)
|
|
721
570
|
throw new Error(
|
|
722
571
|
"rspack.experiments.VirtualModulesPlugin requires at least 1.5.0 version of @rsbuild/core, please upgrade or downgrade storybook-rsbuild-builder to lower version."
|
|
723
572
|
);
|
|
724
|
-
|
|
725
|
-
config.plugins ??= [];
|
|
726
|
-
config.plugins.push(
|
|
573
|
+
return config.plugins ??= [], config.plugins.push(
|
|
727
574
|
...[
|
|
728
575
|
Object.keys(virtualModuleMapping).length > 0 ? new rspack2.experiments.VirtualModulesPlugin(
|
|
729
576
|
virtualModuleMapping
|
|
730
577
|
) : null,
|
|
731
578
|
new rspack2.ProvidePlugin({
|
|
732
|
-
process:
|
|
579
|
+
process: __require.resolve("process/browser.js")
|
|
733
580
|
}),
|
|
734
|
-
new
|
|
581
|
+
new CaseSensitivePathsPlugin()
|
|
735
582
|
].filter(Boolean)
|
|
736
|
-
)
|
|
737
|
-
config.experiments ??= {};
|
|
738
|
-
config.experiments.outputModule = false;
|
|
739
|
-
config.externalsType = "var";
|
|
740
|
-
config.output ??= {};
|
|
741
|
-
config.output.module = false;
|
|
742
|
-
config.output.chunkFormat = "array-push";
|
|
743
|
-
config.output.chunkLoading = "jsonp";
|
|
744
|
-
config.experiments = {
|
|
583
|
+
), config.experiments ??= {}, config.experiments.outputModule = !1, config.externalsType = "var", config.output ??= {}, config.output.module = !1, config.output.chunkFormat = "array-push", config.output.chunkLoading = "jsonp", config.experiments = {
|
|
745
584
|
...config.experiments,
|
|
746
585
|
...lazyCompilationConfig
|
|
747
|
-
}
|
|
748
|
-
return mergeConfig(
|
|
586
|
+
}, mergeConfig(
|
|
749
587
|
config,
|
|
750
588
|
extraWebpackConfig || {},
|
|
751
589
|
webpackConfigFromPresets
|
|
@@ -755,8 +593,8 @@ var iframe_rsbuild_config_default = async (options, extraWebpackConfig) => {
|
|
|
755
593
|
filename: "iframe.html",
|
|
756
594
|
// FIXME: `none` isn't a known option
|
|
757
595
|
chunksSortMode: "none",
|
|
758
|
-
alwaysWriteToDisk:
|
|
759
|
-
inject:
|
|
596
|
+
alwaysWriteToDisk: !0,
|
|
597
|
+
inject: !1,
|
|
760
598
|
template,
|
|
761
599
|
templateParameters: {
|
|
762
600
|
version: packageJson?.version ?? "0.0.0-storybook-rsbuild-unknown-version",
|
|
@@ -781,74 +619,50 @@ var iframe_rsbuild_config_default = async (options, extraWebpackConfig) => {
|
|
|
781
619
|
}
|
|
782
620
|
}
|
|
783
621
|
});
|
|
784
|
-
rsbuildConfig.source ??= {}
|
|
785
|
-
rsbuildConfig.source.entry = {
|
|
622
|
+
return rsbuildConfig.source ??= {}, rsbuildConfig.source.entry = {
|
|
786
623
|
main: [...entries ?? [], ...dynamicEntries]
|
|
787
|
-
};
|
|
788
|
-
return rsbuildConfig;
|
|
624
|
+
}, rsbuildConfig;
|
|
789
625
|
};
|
|
790
626
|
|
|
791
627
|
// src/react-shims.ts
|
|
792
|
-
|
|
793
|
-
|
|
628
|
+
import { readFile } from "node:fs/promises";
|
|
629
|
+
import { dirname as dirname2, isAbsolute, join as join3 } from "node:path";
|
|
794
630
|
var getIsReactVersion18or19 = async (options) => {
|
|
795
|
-
|
|
631
|
+
let { legacyRootApi } = await options.presets.apply(
|
|
796
632
|
"frameworkOptions"
|
|
797
633
|
) || {};
|
|
798
|
-
if (legacyRootApi)
|
|
799
|
-
return
|
|
800
|
-
|
|
801
|
-
const resolvedReact = await options.presets.apply(
|
|
634
|
+
if (legacyRootApi)
|
|
635
|
+
return !1;
|
|
636
|
+
let resolvedReact = await options.presets.apply(
|
|
802
637
|
"resolvedReact",
|
|
803
638
|
{}
|
|
804
|
-
);
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
}
|
|
810
|
-
const { version } = JSON.parse(
|
|
811
|
-
await (0, import_promises.readFile)((0, import_node_path3.join)(reactDom, "package.json"), "utf-8")
|
|
639
|
+
), reactDom = "";
|
|
640
|
+
if (reactDom = resolvedReact.reactDom || dirname2(__require.resolve("react-dom/package.json")), !isAbsolute(reactDom))
|
|
641
|
+
return !1;
|
|
642
|
+
let { version } = JSON.parse(
|
|
643
|
+
await readFile(join3(reactDom, "package.json"), "utf-8")
|
|
812
644
|
);
|
|
813
645
|
return version.startsWith("18") || version.startsWith("19") || version.startsWith("0.0.0");
|
|
814
|
-
}
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
return {};
|
|
819
|
-
}
|
|
820
|
-
return {
|
|
821
|
-
resolve: {
|
|
822
|
-
alias: {
|
|
823
|
-
"@storybook/react-dom-shim": "@storybook/react-dom-shim/dist/react-16"
|
|
824
|
-
}
|
|
646
|
+
}, applyReactShims = async (config, options) => await getIsReactVersion18or19(options) ? {} : {
|
|
647
|
+
resolve: {
|
|
648
|
+
alias: {
|
|
649
|
+
"@storybook/react-dom-shim": "@storybook/react-dom-shim/react-16"
|
|
825
650
|
}
|
|
826
|
-
}
|
|
651
|
+
}
|
|
827
652
|
};
|
|
828
653
|
|
|
829
654
|
// src/index.ts
|
|
830
|
-
var corePath = (0,
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
get: async (options) => {
|
|
834
|
-
const rsbuildInstance = await options.presets.apply("rsbuildInstance") || rsbuildReal;
|
|
835
|
-
return rsbuildInstance;
|
|
836
|
-
}
|
|
837
|
-
};
|
|
838
|
-
var isObject = (val) => val != null && typeof val === "object" && Array.isArray(val) === false;
|
|
655
|
+
var corePath = dirname3(__require.resolve("storybook/package.json")), printDuration = (startTime) => (0, import_pretty_hrtime.default)(process.hrtime(startTime)).replace(" ms", " milliseconds").replace(" s", " seconds").replace(" m", " minutes"), executor = {
|
|
656
|
+
get: async (options) => await options.presets.apply("rsbuildInstance") || rsbuildReal
|
|
657
|
+
}, isObject = (val) => val != null && typeof val == "object" && Array.isArray(val) === !1;
|
|
839
658
|
function nonNullables(value) {
|
|
840
659
|
return value !== void 0;
|
|
841
660
|
}
|
|
842
661
|
var rsbuild = async (_, options) => {
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
const name = isObject(preset) ? preset.name : preset;
|
|
848
|
-
return (0, import_common3.resolveAddonName)(options.configDir, name, addonOptions);
|
|
849
|
-
}).filter(nonNullables);
|
|
850
|
-
const { apply } = await (0, import_common3.getPresets)(resolvedWebpackAddons, options);
|
|
851
|
-
const webpackAddonsConfig = await apply(
|
|
662
|
+
let { presets } = options, resolvedWebpackAddons = (await presets.apply("webpackAddons") ?? []).map((preset) => {
|
|
663
|
+
let addonOptions = isObject(preset) && preset.options || void 0, name = isObject(preset) ? preset.name : preset;
|
|
664
|
+
return resolveAddonName(options.configDir, name, addonOptions);
|
|
665
|
+
}).filter(nonNullables), { apply } = await getPresets(resolvedWebpackAddons, options), webpackAddonsConfig = await apply(
|
|
852
666
|
"webpackFinal",
|
|
853
667
|
// TODO: using empty webpack config as base for now. It's better to using the composed rspack
|
|
854
668
|
// config in `iframe-rsbuild.config.ts` as base config. But when `tools.rspack` is an async function,
|
|
@@ -869,31 +683,23 @@ var rsbuild = async (_, options) => {
|
|
|
869
683
|
entry: {}
|
|
870
684
|
},
|
|
871
685
|
options
|
|
872
|
-
);
|
|
873
|
-
|
|
874
|
-
const shimsConfig = await applyReactShims(intrinsicRsbuildConfig, options);
|
|
875
|
-
intrinsicRsbuildConfig = rsbuildReal.mergeRsbuildConfig(
|
|
686
|
+
), intrinsicRsbuildConfig = await iframe_rsbuild_config_default(options, webpackAddonsConfig), shimsConfig = await applyReactShims(intrinsicRsbuildConfig, options);
|
|
687
|
+
return intrinsicRsbuildConfig = rsbuildReal.mergeRsbuildConfig(
|
|
876
688
|
intrinsicRsbuildConfig,
|
|
877
689
|
shimsConfig
|
|
878
|
-
)
|
|
879
|
-
const finalConfig = await presets.apply(
|
|
690
|
+
), await presets.apply(
|
|
880
691
|
"rsbuildFinal",
|
|
881
692
|
intrinsicRsbuildConfig,
|
|
882
693
|
options
|
|
883
694
|
);
|
|
884
|
-
|
|
885
|
-
};
|
|
886
|
-
var getConfig = async (options) => {
|
|
887
|
-
const { presets } = options;
|
|
888
|
-
const typescriptOptions = await presets.apply("typescript", {}, options);
|
|
889
|
-
const frameworkOptions = await presets.apply("frameworkOptions");
|
|
695
|
+
}, getConfig = async (options) => {
|
|
696
|
+
let { presets } = options, typescriptOptions = await presets.apply("typescript", {}, options), frameworkOptions = await presets.apply("frameworkOptions");
|
|
890
697
|
return rsbuild({}, {
|
|
891
698
|
...options,
|
|
892
699
|
typescriptOptions,
|
|
893
700
|
frameworkOptions
|
|
894
701
|
});
|
|
895
|
-
};
|
|
896
|
-
var server;
|
|
702
|
+
}, server;
|
|
897
703
|
async function bail() {
|
|
898
704
|
return server?.close();
|
|
899
705
|
}
|
|
@@ -904,9 +710,7 @@ var start = async ({
|
|
|
904
710
|
server: storybookServer,
|
|
905
711
|
channel
|
|
906
712
|
}) => {
|
|
907
|
-
|
|
908
|
-
const config = await getConfig(options);
|
|
909
|
-
const rsbuildBuild = await createRsbuild({
|
|
713
|
+
let { createRsbuild } = await executor.get(options), config = await getConfig(options), rsbuildBuild = await createRsbuild({
|
|
910
714
|
cwd: process.cwd(),
|
|
911
715
|
rsbuildConfig: {
|
|
912
716
|
...config,
|
|
@@ -914,90 +718,59 @@ var start = async ({
|
|
|
914
718
|
...config.server,
|
|
915
719
|
port: await getRandomPort(options.host),
|
|
916
720
|
host: options.host,
|
|
917
|
-
htmlFallback:
|
|
918
|
-
printUrls:
|
|
721
|
+
htmlFallback: !1,
|
|
722
|
+
printUrls: !1
|
|
919
723
|
}
|
|
920
724
|
}
|
|
921
|
-
})
|
|
922
|
-
const rsbuildServer = await rsbuildBuild.createDevServer();
|
|
923
|
-
const waitFirstCompileDone = new Promise((resolve3) => {
|
|
725
|
+
}), rsbuildServer = await rsbuildBuild.createDevServer(), waitFirstCompileDone = new Promise((resolve3) => {
|
|
924
726
|
rsbuildBuild.onDevCompileDone(({ stats: stats2, isFirstCompile }) => {
|
|
925
|
-
|
|
926
|
-
return;
|
|
927
|
-
}
|
|
928
|
-
resolve3(stats2);
|
|
727
|
+
isFirstCompile && resolve3(stats2);
|
|
929
728
|
});
|
|
930
729
|
});
|
|
931
|
-
server = rsbuildServer
|
|
932
|
-
|
|
933
|
-
throw new import_server_errors.WebpackInvocationError({
|
|
730
|
+
if (server = rsbuildServer, !rsbuildBuild)
|
|
731
|
+
throw new WebpackInvocationError({
|
|
934
732
|
// eslint-disable-next-line local-rules/no-uncategorized-errors
|
|
935
733
|
error: new Error("Missing Rsbuild build instance at runtime!")
|
|
936
734
|
});
|
|
937
|
-
|
|
938
|
-
const previewResolvedDir = (0, import_node_path4.join)(corePath, "dist/preview");
|
|
939
|
-
const previewDirOrigin = previewResolvedDir;
|
|
735
|
+
let previewDirOrigin = join4(corePath, "dist/preview");
|
|
940
736
|
router.use(
|
|
941
737
|
"/sb-preview",
|
|
942
|
-
(
|
|
943
|
-
);
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
const stats = await waitFirstCompileDone;
|
|
947
|
-
await server.afterListen();
|
|
948
|
-
return {
|
|
738
|
+
sirv(previewDirOrigin, { maxAge: 3e5, dev: !0, immutable: !0 })
|
|
739
|
+
), router.use(rsbuildServer.middlewares), rsbuildServer.connectWebSocket({ server: storybookServer });
|
|
740
|
+
let stats = await waitFirstCompileDone;
|
|
741
|
+
return await server.afterListen(), {
|
|
949
742
|
bail,
|
|
950
743
|
stats,
|
|
951
744
|
totalTime: process.hrtime(startTime)
|
|
952
745
|
};
|
|
953
|
-
}
|
|
954
|
-
|
|
955
|
-
const { createRsbuild } = await executor.get(options);
|
|
956
|
-
const config = await getConfig(options);
|
|
957
|
-
const rsbuildBuild = await createRsbuild({
|
|
746
|
+
}, build = async ({ options }) => {
|
|
747
|
+
let { createRsbuild } = await executor.get(options), config = await getConfig(options), rsbuildBuild = await createRsbuild({
|
|
958
748
|
cwd: process.cwd(),
|
|
959
749
|
rsbuildConfig: config
|
|
960
|
-
});
|
|
961
|
-
const previewResolvedDir = (0, import_node_path4.join)(corePath, "dist/preview");
|
|
962
|
-
const previewDirOrigin = previewResolvedDir;
|
|
963
|
-
const previewDirTarget = (0, import_node_path4.join)(options.outputDir || "", "sb-preview");
|
|
964
|
-
let stats;
|
|
750
|
+
}), previewDirOrigin = join4(corePath, "dist/preview"), previewDirTarget = join4(options.outputDir || "", "sb-preview"), stats;
|
|
965
751
|
rsbuildBuild.onAfterBuild((params) => {
|
|
966
752
|
stats = params.stats;
|
|
967
753
|
});
|
|
968
|
-
|
|
754
|
+
let previewFiles = fs.copy(previewDirOrigin, previewDirTarget, {
|
|
969
755
|
filter: (src) => {
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
return ext === ".js";
|
|
973
|
-
}
|
|
974
|
-
return true;
|
|
756
|
+
let { ext } = parse(src);
|
|
757
|
+
return ext ? ext === ".js" : !0;
|
|
975
758
|
}
|
|
976
|
-
});
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
});
|
|
980
|
-
const [{ close }] = await Promise.all([rsbuildBuild.build(), previewFiles]);
|
|
981
|
-
await close();
|
|
982
|
-
return stats;
|
|
983
|
-
};
|
|
984
|
-
var corePresets = [(0, import_node_path4.join)(__dirname, "./preview-preset.js")];
|
|
985
|
-
var previewMainTemplate = () => require.resolve("storybook-builder-rsbuild/templates/preview.ejs");
|
|
759
|
+
}), [{ close }] = await Promise.all([rsbuildBuild.build(), previewFiles]);
|
|
760
|
+
return await close(), stats;
|
|
761
|
+
}, corePresets = [join4(__dirname, "./preview-preset.js")], previewMainTemplate = () => __require.resolve("storybook-builder-rsbuild/templates/preview.ejs");
|
|
986
762
|
function getRandomPort(host) {
|
|
987
763
|
return new Promise((resolve3, reject) => {
|
|
988
|
-
|
|
989
|
-
server2.unref()
|
|
990
|
-
|
|
991
|
-
server2.listen({ port: 0, host }, () => {
|
|
992
|
-
const { port } = server2.address();
|
|
764
|
+
let server2 = createServer();
|
|
765
|
+
server2.unref(), server2.on("error", reject), server2.listen({ port: 0, host }, () => {
|
|
766
|
+
let { port } = server2.address();
|
|
993
767
|
server2.close(() => {
|
|
994
768
|
resolve3(port);
|
|
995
769
|
});
|
|
996
770
|
});
|
|
997
771
|
});
|
|
998
772
|
}
|
|
999
|
-
|
|
1000
|
-
0 && (module.exports = {
|
|
773
|
+
export {
|
|
1001
774
|
bail,
|
|
1002
775
|
build,
|
|
1003
776
|
corePresets,
|
|
@@ -1007,4 +780,4 @@ function getRandomPort(host) {
|
|
|
1007
780
|
previewMainTemplate,
|
|
1008
781
|
printDuration,
|
|
1009
782
|
start
|
|
1010
|
-
}
|
|
783
|
+
};
|