@storybook/preset-create-react-app 10.1.0-alpha.1 → 10.1.0-alpha.11
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 +236 -571
- package/package.json +5 -4
package/dist/index.js
CHANGED
|
@@ -1,62 +1,52 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_59tawqp21ll from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_59tawqp21ll from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_59tawqp21ll from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_59tawqp21ll.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_59tawqp21ll.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_59tawqp21ll.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
11
|
// ------------------------------------------------------------
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
15
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
12
|
+
var __require = /* @__PURE__ */ ((x) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(x, {
|
|
13
|
+
get: (a, b) => (typeof require < "u" ? require : a)[b]
|
|
16
14
|
}) : x)(function(x) {
|
|
17
|
-
if (typeof require
|
|
15
|
+
if (typeof require < "u") return require.apply(this, arguments);
|
|
18
16
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
19
17
|
});
|
|
20
18
|
|
|
21
19
|
// src/index.ts
|
|
20
|
+
import module from "node:module";
|
|
22
21
|
import { dirname as dirname2, join as join4, relative as relative2 } from "node:path";
|
|
23
22
|
import { logger as logger2 } from "storybook/internal/node-logger";
|
|
24
23
|
import PnpWebpackPlugin from "pnp-webpack-plugin";
|
|
25
24
|
|
|
26
25
|
// src/helpers/checkPresets.ts
|
|
27
26
|
import { logger } from "storybook/internal/node-logger";
|
|
28
|
-
var incompatiblePresets = ["@storybook/preset-scss", "@storybook/preset-typescript"]
|
|
29
|
-
|
|
30
|
-
const { presetsList } = options;
|
|
27
|
+
var incompatiblePresets = ["@storybook/preset-scss", "@storybook/preset-typescript"], checkPresets = (options) => {
|
|
28
|
+
let { presetsList } = options;
|
|
31
29
|
presetsList?.forEach((preset) => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
);
|
|
37
|
-
}
|
|
30
|
+
let presetName = typeof preset == "string" ? preset : preset.name;
|
|
31
|
+
incompatiblePresets.includes(presetName) && logger.warn(
|
|
32
|
+
`\`${presetName}\` may not be compatible with \`@storybook/preset-create-react-app\``
|
|
33
|
+
);
|
|
38
34
|
});
|
|
39
|
-
}
|
|
35
|
+
};
|
|
40
36
|
|
|
41
37
|
// src/helpers/getModulePath.ts
|
|
42
38
|
import { existsSync } from "node:fs";
|
|
43
39
|
import { join } from "node:path";
|
|
44
|
-
var JSCONFIG = "jsconfig.json"
|
|
45
|
-
var TSCONFIG = "tsconfig.json";
|
|
46
|
-
var getModulePath = /* @__PURE__ */ __name((appDirectory) => {
|
|
40
|
+
var JSCONFIG = "jsconfig.json", TSCONFIG = "tsconfig.json", getModulePath = (appDirectory) => {
|
|
47
41
|
let configName = "";
|
|
48
|
-
|
|
49
|
-
configName = TSCONFIG;
|
|
50
|
-
} else if (existsSync(join(appDirectory, JSCONFIG))) {
|
|
51
|
-
configName = JSCONFIG;
|
|
52
|
-
}
|
|
42
|
+
existsSync(join(appDirectory, TSCONFIG)) ? configName = TSCONFIG : existsSync(join(appDirectory, JSCONFIG)) && (configName = JSCONFIG);
|
|
53
43
|
try {
|
|
54
|
-
|
|
44
|
+
let { baseUrl } = __require(join(appDirectory, configName)).compilerOptions;
|
|
55
45
|
return baseUrl ? [baseUrl] : [];
|
|
56
|
-
} catch
|
|
46
|
+
} catch {
|
|
57
47
|
return [];
|
|
58
48
|
}
|
|
59
|
-
}
|
|
49
|
+
};
|
|
60
50
|
|
|
61
51
|
// src/helpers/getReactScriptsPath.ts
|
|
62
52
|
import { lstatSync, readFileSync, realpathSync } from "node:fs";
|
|
@@ -69,666 +59,343 @@ import { fileURLToPath, pathToFileURL } from "node:url";
|
|
|
69
59
|
import assert from "node:assert";
|
|
70
60
|
import v8 from "node:v8";
|
|
71
61
|
import { format, inspect } from "node:util";
|
|
72
|
-
var own$1 = {}.hasOwnProperty
|
|
73
|
-
var classRegExp = /^([A-Z][a-z\d]*)+$/;
|
|
74
|
-
var kTypes = /* @__PURE__ */ new Set([
|
|
62
|
+
var own$1 = {}.hasOwnProperty, classRegExp = /^([A-Z][a-z\d]*)+$/, kTypes = /* @__PURE__ */ new Set([
|
|
75
63
|
"string",
|
|
76
64
|
"function",
|
|
77
65
|
"number",
|
|
78
66
|
"object",
|
|
79
|
-
// Accept 'Function' and 'Object' as alternative to the lower cased version.
|
|
80
67
|
"Function",
|
|
81
68
|
"Object",
|
|
82
69
|
"boolean",
|
|
83
70
|
"bigint",
|
|
84
71
|
"symbol"
|
|
85
|
-
]);
|
|
86
|
-
var messages = /* @__PURE__ */ new Map();
|
|
87
|
-
var nodeInternalPrefix = "__node_internal_";
|
|
88
|
-
var userStackTraceLimit;
|
|
72
|
+
]), messages = /* @__PURE__ */ new Map(), nodeInternalPrefix = "__node_internal_", userStackTraceLimit;
|
|
89
73
|
function formatList(array, type = "and") {
|
|
90
74
|
return array.length < 3 ? array.join(` ${type} `) : `${array.slice(0, -1).join(", ")}, ${type} ${array.at(-1)}`;
|
|
91
75
|
}
|
|
92
|
-
__name(formatList, "formatList");
|
|
93
76
|
function createError(sym, value, constructor) {
|
|
94
|
-
messages.set(sym, value);
|
|
95
|
-
return makeNodeErrorWithCode(constructor, sym);
|
|
77
|
+
return messages.set(sym, value), makeNodeErrorWithCode(constructor, sym);
|
|
96
78
|
}
|
|
97
|
-
__name(createError, "createError");
|
|
98
79
|
function makeNodeErrorWithCode(Base, key) {
|
|
99
|
-
return
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
Object.defineProperties(error, {
|
|
106
|
-
// Note: no need to implement `kIsNodeError` symbol, would be hard,
|
|
107
|
-
// probably.
|
|
80
|
+
return function(...parameters) {
|
|
81
|
+
let limit = Error.stackTraceLimit;
|
|
82
|
+
isErrorStackTraceLimitWritable() && (Error.stackTraceLimit = 0);
|
|
83
|
+
let error = new Base();
|
|
84
|
+
isErrorStackTraceLimitWritable() && (Error.stackTraceLimit = limit);
|
|
85
|
+
let message = getMessage(key, parameters, error);
|
|
86
|
+
return Object.defineProperties(error, {
|
|
108
87
|
message: {
|
|
109
88
|
value: message,
|
|
110
|
-
enumerable:
|
|
111
|
-
writable:
|
|
112
|
-
configurable:
|
|
89
|
+
enumerable: !1,
|
|
90
|
+
writable: !0,
|
|
91
|
+
configurable: !0
|
|
113
92
|
},
|
|
114
93
|
toString: {
|
|
115
|
-
/** @this {Error} */
|
|
116
94
|
value() {
|
|
117
95
|
return `${this.name} [${key}]: ${this.message}`;
|
|
118
96
|
},
|
|
119
|
-
enumerable:
|
|
120
|
-
writable:
|
|
121
|
-
configurable:
|
|
97
|
+
enumerable: !1,
|
|
98
|
+
writable: !0,
|
|
99
|
+
configurable: !0
|
|
122
100
|
}
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
error.code = key;
|
|
126
|
-
return error;
|
|
127
|
-
}, "NodeError");
|
|
101
|
+
}), captureLargerStackTrace(error), error.code = key, error;
|
|
102
|
+
};
|
|
128
103
|
}
|
|
129
|
-
__name(makeNodeErrorWithCode, "makeNodeErrorWithCode");
|
|
130
104
|
function isErrorStackTraceLimitWritable() {
|
|
131
105
|
try {
|
|
132
|
-
if (v8.startupSnapshot.isBuildingSnapshot())
|
|
133
|
-
return false;
|
|
134
|
-
}
|
|
106
|
+
if (v8.startupSnapshot.isBuildingSnapshot()) return !1;
|
|
135
107
|
} catch {
|
|
136
108
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
return Object.isExtensible(Error);
|
|
140
|
-
}
|
|
141
|
-
return own$1.call(desc, "writable") && desc.writable !== void 0 ? desc.writable : desc.set !== void 0;
|
|
109
|
+
let desc = Object.getOwnPropertyDescriptor(Error, "stackTraceLimit");
|
|
110
|
+
return desc === void 0 ? Object.isExtensible(Error) : own$1.call(desc, "writable") && desc.writable !== void 0 ? desc.writable : desc.set !== void 0;
|
|
142
111
|
}
|
|
143
|
-
__name(isErrorStackTraceLimitWritable, "isErrorStackTraceLimitWritable");
|
|
144
112
|
function hideStackFrames(wrappedFunction) {
|
|
145
|
-
|
|
146
|
-
Object.defineProperty(wrappedFunction, "name", { value: hidden });
|
|
147
|
-
return wrappedFunction;
|
|
113
|
+
let hidden = nodeInternalPrefix + wrappedFunction.name;
|
|
114
|
+
return Object.defineProperty(wrappedFunction, "name", { value: hidden }), wrappedFunction;
|
|
148
115
|
}
|
|
149
|
-
__name(hideStackFrames, "hideStackFrames");
|
|
150
116
|
var captureLargerStackTrace = hideStackFrames(function(error) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
userStackTraceLimit = Error.stackTraceLimit;
|
|
154
|
-
Error.stackTraceLimit = Number.POSITIVE_INFINITY;
|
|
155
|
-
}
|
|
156
|
-
Error.captureStackTrace(error);
|
|
157
|
-
if (stackTraceLimitIsWritable) Error.stackTraceLimit = userStackTraceLimit;
|
|
158
|
-
return error;
|
|
117
|
+
let stackTraceLimitIsWritable = isErrorStackTraceLimitWritable();
|
|
118
|
+
return stackTraceLimitIsWritable && (userStackTraceLimit = Error.stackTraceLimit, Error.stackTraceLimit = Number.POSITIVE_INFINITY), Error.captureStackTrace(error), stackTraceLimitIsWritable && (Error.stackTraceLimit = userStackTraceLimit), error;
|
|
159
119
|
});
|
|
160
120
|
function getMessage(key, parameters, self) {
|
|
161
|
-
|
|
162
|
-
assert(message !== void 0, "expected `message` to be found")
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
`Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${message.length}).`
|
|
168
|
-
);
|
|
169
|
-
return Reflect.apply(message, self, parameters);
|
|
170
|
-
}
|
|
171
|
-
const regex = /%[dfijoOs]/g;
|
|
172
|
-
let expectedLength = 0;
|
|
173
|
-
while (regex.exec(message) !== null) expectedLength++;
|
|
174
|
-
assert(
|
|
175
|
-
expectedLength === parameters.length,
|
|
176
|
-
`Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${expectedLength}).`
|
|
177
|
-
);
|
|
178
|
-
if (parameters.length === 0) return message;
|
|
179
|
-
parameters.unshift(message);
|
|
180
|
-
return Reflect.apply(format, null, parameters);
|
|
121
|
+
let message = messages.get(key);
|
|
122
|
+
if (assert.ok(message !== void 0, "expected `message` to be found"), typeof message == "function")
|
|
123
|
+
return assert.ok(message.length <= parameters.length, `Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${message.length}).`), Reflect.apply(message, self, parameters);
|
|
124
|
+
let regex = /%[dfijoOs]/g, expectedLength = 0;
|
|
125
|
+
for (; regex.exec(message) !== null; ) expectedLength++;
|
|
126
|
+
return assert.ok(expectedLength === parameters.length, `Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${expectedLength}).`), parameters.length === 0 ? message : (parameters.unshift(message), Reflect.apply(format, null, parameters));
|
|
181
127
|
}
|
|
182
|
-
__name(getMessage, "getMessage");
|
|
183
128
|
function determineSpecificType(value) {
|
|
184
|
-
if (value
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
129
|
+
if (value == null) return String(value);
|
|
130
|
+
if (typeof value == "function" && value.name) return `function ${value.name}`;
|
|
131
|
+
if (typeof value == "object")
|
|
132
|
+
return value.constructor && value.constructor.name ? `an instance of ${value.constructor.name}` : `${inspect(value, { depth: -1 })}`;
|
|
133
|
+
let inspected = inspect(value, { colors: !1 });
|
|
134
|
+
return inspected.length > 28 && (inspected = `${inspected.slice(0, 25)}...`), `type ${typeof value} (${inspected})`;
|
|
135
|
+
}
|
|
136
|
+
var ERR_INVALID_ARG_TYPE = createError("ERR_INVALID_ARG_TYPE", (name, expected, actual) => {
|
|
137
|
+
assert.ok(typeof name == "string", "'name' must be a string"), Array.isArray(expected) || (expected = [expected]);
|
|
138
|
+
let message = "The ";
|
|
139
|
+
if (name.endsWith(" argument")) message += `${name} `;
|
|
140
|
+
else {
|
|
141
|
+
let type = name.includes(".") ? "property" : "argument";
|
|
142
|
+
message += `"${name}" ${type} `;
|
|
195
143
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
144
|
+
message += "must be ";
|
|
145
|
+
let types = [], instances = [], other = [];
|
|
146
|
+
for (let value of expected)
|
|
147
|
+
assert.ok(typeof value == "string", "All expected entries have to be of type string"), kTypes.has(value) ? types.push(value.toLowerCase()) : classRegExp.exec(value) === null ? (assert.ok(value !== "object", 'The value "object" should be written as "Object"'), other.push(value)) : instances.push(value);
|
|
148
|
+
if (instances.length > 0) {
|
|
149
|
+
let pos = types.indexOf("object");
|
|
150
|
+
pos !== -1 && (types.slice(pos, 1), instances.push("Object"));
|
|
199
151
|
}
|
|
200
|
-
return
|
|
201
|
-
}
|
|
202
|
-
__name(determineSpecificType, "determineSpecificType");
|
|
203
|
-
createError(
|
|
204
|
-
"ERR_INVALID_ARG_TYPE",
|
|
205
|
-
(name, expected, actual) => {
|
|
206
|
-
assert(typeof name === "string", "'name' must be a string");
|
|
207
|
-
if (!Array.isArray(expected)) {
|
|
208
|
-
expected = [expected];
|
|
209
|
-
}
|
|
210
|
-
let message = "The ";
|
|
211
|
-
if (name.endsWith(" argument")) {
|
|
212
|
-
message += `${name} `;
|
|
213
|
-
} else {
|
|
214
|
-
const type = name.includes(".") ? "property" : "argument";
|
|
215
|
-
message += `"${name}" ${type} `;
|
|
216
|
-
}
|
|
217
|
-
message += "must be ";
|
|
218
|
-
const types = [];
|
|
219
|
-
const instances = [];
|
|
220
|
-
const other = [];
|
|
221
|
-
for (const value of expected) {
|
|
222
|
-
assert(
|
|
223
|
-
typeof value === "string",
|
|
224
|
-
"All expected entries have to be of type string"
|
|
225
|
-
);
|
|
226
|
-
if (kTypes.has(value)) {
|
|
227
|
-
types.push(value.toLowerCase());
|
|
228
|
-
} else if (classRegExp.exec(value) === null) {
|
|
229
|
-
assert(
|
|
230
|
-
value !== "object",
|
|
231
|
-
'The value "object" should be written as "Object"'
|
|
232
|
-
);
|
|
233
|
-
other.push(value);
|
|
234
|
-
} else {
|
|
235
|
-
instances.push(value);
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
if (instances.length > 0) {
|
|
239
|
-
const pos = types.indexOf("object");
|
|
240
|
-
if (pos !== -1) {
|
|
241
|
-
types.slice(pos, 1);
|
|
242
|
-
instances.push("Object");
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
if (types.length > 0) {
|
|
246
|
-
message += `${types.length > 1 ? "one of type" : "of type"} ${formatList(
|
|
247
|
-
types,
|
|
248
|
-
"or"
|
|
249
|
-
)}`;
|
|
250
|
-
if (instances.length > 0 || other.length > 0) message += " or ";
|
|
251
|
-
}
|
|
252
|
-
if (instances.length > 0) {
|
|
253
|
-
message += `an instance of ${formatList(instances, "or")}`;
|
|
254
|
-
if (other.length > 0) message += " or ";
|
|
255
|
-
}
|
|
256
|
-
if (other.length > 0) {
|
|
257
|
-
if (other.length > 1) {
|
|
258
|
-
message += `one of ${formatList(other, "or")}`;
|
|
259
|
-
} else {
|
|
260
|
-
if (other[0]?.toLowerCase() !== other[0]) message += "an ";
|
|
261
|
-
message += `${other[0]}`;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
message += `. Received ${determineSpecificType(actual)}`;
|
|
265
|
-
return message;
|
|
266
|
-
},
|
|
267
|
-
TypeError
|
|
268
|
-
);
|
|
269
|
-
var ERR_INVALID_MODULE_SPECIFIER = createError(
|
|
152
|
+
return types.length > 0 && (message += `${types.length > 1 ? "one of type" : "of type"} ${formatList(types, "or")}`, (instances.length > 0 || other.length > 0) && (message += " or ")), instances.length > 0 && (message += `an instance of ${formatList(instances, "or")}`, other.length > 0 && (message += " or ")), other.length > 0 && (other.length > 1 ? message += `one of ${formatList(other, "or")}` : (other[0]?.toLowerCase() !== other[0] && (message += "an "), message += `${other[0]}`)), message += `. Received ${determineSpecificType(actual)}`, message;
|
|
153
|
+
}, TypeError), ERR_INVALID_MODULE_SPECIFIER = createError(
|
|
270
154
|
"ERR_INVALID_MODULE_SPECIFIER",
|
|
271
155
|
/**
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
(request, reason, base) => {
|
|
277
|
-
return `Invalid module "${request}" ${reason}${base ? ` imported from ${base}` : ""}`;
|
|
278
|
-
},
|
|
156
|
+
* @param {string} request
|
|
157
|
+
* @param {string} reason
|
|
158
|
+
* @param {string} [base]
|
|
159
|
+
*/
|
|
160
|
+
(request, reason, base) => `Invalid module "${request}" ${reason}${base ? ` imported from ${base}` : ""}`,
|
|
279
161
|
TypeError
|
|
280
|
-
)
|
|
281
|
-
|
|
282
|
-
"
|
|
283
|
-
|
|
284
|
-
return `Invalid package config ${path2}${base ? ` while importing ${base}` : ""}${message ? `. ${message}` : ""}`;
|
|
285
|
-
},
|
|
286
|
-
Error
|
|
287
|
-
);
|
|
288
|
-
var ERR_INVALID_PACKAGE_TARGET = createError(
|
|
289
|
-
"ERR_INVALID_PACKAGE_TARGET",
|
|
290
|
-
(packagePath, key, target, isImport = false, base) => {
|
|
291
|
-
const relatedError = typeof target === "string" && !isImport && target.length > 0 && !target.startsWith("./");
|
|
292
|
-
if (key === ".") {
|
|
293
|
-
assert(isImport === false);
|
|
294
|
-
return `Invalid "exports" main target ${JSON.stringify(target)} defined in the package config ${packagePath}package.json${base ? ` imported from ${base}` : ""}${relatedError ? '; targets must start with "./"' : ""}`;
|
|
295
|
-
}
|
|
296
|
-
return `Invalid "${isImport ? "imports" : "exports"}" target ${JSON.stringify(
|
|
297
|
-
target
|
|
298
|
-
)} defined for '${key}' in the package config ${packagePath}package.json${base ? ` imported from ${base}` : ""}${relatedError ? '; targets must start with "./"' : ""}`;
|
|
299
|
-
},
|
|
300
|
-
Error
|
|
301
|
-
);
|
|
302
|
-
var ERR_MODULE_NOT_FOUND = createError(
|
|
303
|
-
"ERR_MODULE_NOT_FOUND",
|
|
304
|
-
(path2, base, exactUrl = false) => {
|
|
305
|
-
return `Cannot find ${exactUrl ? "module" : "package"} '${path2}' imported from ${base}`;
|
|
306
|
-
},
|
|
307
|
-
Error
|
|
308
|
-
);
|
|
309
|
-
createError(
|
|
310
|
-
"ERR_NETWORK_IMPORT_DISALLOWED",
|
|
311
|
-
"import of '%s' by %s is not supported: %s",
|
|
312
|
-
Error
|
|
313
|
-
);
|
|
314
|
-
var ERR_PACKAGE_IMPORT_NOT_DEFINED = createError(
|
|
315
|
-
"ERR_PACKAGE_IMPORT_NOT_DEFINED",
|
|
316
|
-
(specifier, packagePath, base) => {
|
|
317
|
-
return `Package import specifier "${specifier}" is not defined${packagePath ? ` in package ${packagePath || ""}package.json` : ""} imported from ${base}`;
|
|
318
|
-
},
|
|
319
|
-
TypeError
|
|
320
|
-
);
|
|
321
|
-
var ERR_PACKAGE_PATH_NOT_EXPORTED = createError(
|
|
162
|
+
), ERR_INVALID_PACKAGE_CONFIG = createError("ERR_INVALID_PACKAGE_CONFIG", (path$1, base, message) => `Invalid package config ${path$1}${base ? ` while importing ${base}` : ""}${message ? `. ${message}` : ""}`, Error), ERR_INVALID_PACKAGE_TARGET = createError("ERR_INVALID_PACKAGE_TARGET", (packagePath, key, target, isImport = !1, base) => {
|
|
163
|
+
let relatedError = typeof target == "string" && !isImport && target.length > 0 && !target.startsWith("./");
|
|
164
|
+
return key === "." ? (assert.ok(isImport === !1), `Invalid "exports" main target ${JSON.stringify(target)} defined in the package config ${packagePath}package.json${base ? ` imported from ${base}` : ""}${relatedError ? '; targets must start with "./"' : ""}`) : `Invalid "${isImport ? "imports" : "exports"}" target ${JSON.stringify(target)} defined for '${key}' in the package config ${packagePath}package.json${base ? ` imported from ${base}` : ""}${relatedError ? '; targets must start with "./"' : ""}`;
|
|
165
|
+
}, Error), ERR_MODULE_NOT_FOUND = createError("ERR_MODULE_NOT_FOUND", (path$1, base, exactUrl = !1) => `Cannot find ${exactUrl ? "module" : "package"} '${path$1}' imported from ${base}`, Error), ERR_NETWORK_IMPORT_DISALLOWED = createError("ERR_NETWORK_IMPORT_DISALLOWED", "import of '%s' by %s is not supported: %s", Error), ERR_PACKAGE_IMPORT_NOT_DEFINED = createError("ERR_PACKAGE_IMPORT_NOT_DEFINED", (specifier, packagePath, base) => `Package import specifier "${specifier}" is not defined${packagePath ? ` in package ${packagePath || ""}package.json` : ""} imported from ${base}`, TypeError), ERR_PACKAGE_PATH_NOT_EXPORTED = createError(
|
|
322
166
|
"ERR_PACKAGE_PATH_NOT_EXPORTED",
|
|
323
167
|
/**
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
(packagePath, subpath, base) => {
|
|
329
|
-
if (subpath === ".")
|
|
330
|
-
return `No "exports" main defined in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`;
|
|
331
|
-
return `Package subpath '${subpath}' is not defined by "exports" in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`;
|
|
332
|
-
},
|
|
168
|
+
* @param {string} packagePath
|
|
169
|
+
* @param {string} subpath
|
|
170
|
+
* @param {string} [base]
|
|
171
|
+
*/
|
|
172
|
+
(packagePath, subpath, base) => subpath === "." ? `No "exports" main defined in ${packagePath}package.json${base ? ` imported from ${base}` : ""}` : `Package subpath '${subpath}' is not defined by "exports" in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`,
|
|
333
173
|
Error
|
|
334
|
-
)
|
|
335
|
-
|
|
336
|
-
"
|
|
337
|
-
|
|
338
|
-
Error
|
|
339
|
-
);
|
|
340
|
-
var ERR_UNSUPPORTED_RESOLVE_REQUEST = createError(
|
|
341
|
-
"ERR_UNSUPPORTED_RESOLVE_REQUEST",
|
|
342
|
-
'Failed to resolve module specifier "%s" from "%s": Invalid relative URL or base scheme is not hierarchical.',
|
|
343
|
-
TypeError
|
|
344
|
-
);
|
|
345
|
-
var ERR_UNKNOWN_FILE_EXTENSION = createError(
|
|
346
|
-
"ERR_UNKNOWN_FILE_EXTENSION",
|
|
347
|
-
(extension, path2) => {
|
|
348
|
-
return `Unknown file extension "${extension}" for ${path2}`;
|
|
349
|
-
},
|
|
350
|
-
TypeError
|
|
351
|
-
);
|
|
352
|
-
createError(
|
|
353
|
-
"ERR_INVALID_ARG_VALUE",
|
|
354
|
-
(name, value, reason = "is invalid") => {
|
|
355
|
-
let inspected = inspect(value);
|
|
356
|
-
if (inspected.length > 128) {
|
|
357
|
-
inspected = `${inspected.slice(0, 128)}...`;
|
|
358
|
-
}
|
|
359
|
-
const type = name.includes(".") ? "property" : "argument";
|
|
360
|
-
return `The ${type} '${name}' ${reason}. Received ${inspected}`;
|
|
361
|
-
},
|
|
362
|
-
TypeError
|
|
363
|
-
// Note: extra classes have been shaken out.
|
|
364
|
-
// , RangeError
|
|
365
|
-
);
|
|
366
|
-
var hasOwnProperty$1 = {}.hasOwnProperty;
|
|
174
|
+
), ERR_UNSUPPORTED_DIR_IMPORT = createError("ERR_UNSUPPORTED_DIR_IMPORT", "Directory import '%s' is not supported resolving ES modules imported from %s", Error), ERR_UNSUPPORTED_RESOLVE_REQUEST = createError("ERR_UNSUPPORTED_RESOLVE_REQUEST", 'Failed to resolve module specifier "%s" from "%s": Invalid relative URL or base scheme is not hierarchical.', TypeError), ERR_UNKNOWN_FILE_EXTENSION = createError("ERR_UNKNOWN_FILE_EXTENSION", (extension, path$1) => `Unknown file extension "${extension}" for ${path$1}`, TypeError), ERR_INVALID_ARG_VALUE = createError("ERR_INVALID_ARG_VALUE", (name, value, reason = "is invalid") => {
|
|
175
|
+
let inspected = inspect(value);
|
|
176
|
+
return inspected.length > 128 && (inspected = `${inspected.slice(0, 128)}...`), `The ${name.includes(".") ? "property" : "argument"} '${name}' ${reason}. Received ${inspected}`;
|
|
177
|
+
}, TypeError), hasOwnProperty$1 = {}.hasOwnProperty;
|
|
367
178
|
var hasOwnProperty = {}.hasOwnProperty;
|
|
368
|
-
var RegExpPrototypeSymbolReplace = RegExp.prototype[Symbol.replace];
|
|
369
|
-
var
|
|
370
|
-
var isWindows = (() => process.platform === "win32")();
|
|
371
|
-
var globalCache = (() => (
|
|
372
|
-
// eslint-disable-next-line unicorn/no-unreadable-iife
|
|
373
|
-
globalThis["__EXSOLVE_CACHE__"] ||= /* @__PURE__ */ new Map()
|
|
374
|
-
))();
|
|
179
|
+
var RegExpPrototypeSymbolReplace = RegExp.prototype[Symbol.replace], own = {}.hasOwnProperty;
|
|
180
|
+
var isWindows = process.platform === "win32", globalCache = globalThis.__EXSOLVE_CACHE__ ||= /* @__PURE__ */ new Map();
|
|
375
181
|
|
|
376
182
|
// ../../node_modules/pathe/dist/shared/pathe.ff20891b.mjs
|
|
377
183
|
var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
378
184
|
function normalizeWindowsPath(input = "") {
|
|
379
|
-
|
|
380
|
-
return input;
|
|
381
|
-
}
|
|
382
|
-
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
185
|
+
return input && input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
383
186
|
}
|
|
384
|
-
|
|
385
|
-
var
|
|
386
|
-
|
|
387
|
-
var _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
|
|
388
|
-
var normalize = /* @__PURE__ */ __name(function(path2) {
|
|
389
|
-
if (path2.length === 0) {
|
|
187
|
+
var _UNC_REGEX = /^[/\\]{2}/, _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/, _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
|
|
188
|
+
var normalize = function(path2) {
|
|
189
|
+
if (path2.length === 0)
|
|
390
190
|
return ".";
|
|
391
|
-
}
|
|
392
191
|
path2 = normalizeWindowsPath(path2);
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
if (path2.length === 0) {
|
|
398
|
-
if (isPathAbsolute) {
|
|
399
|
-
return "/";
|
|
400
|
-
}
|
|
401
|
-
return trailingSeparator ? "./" : ".";
|
|
402
|
-
}
|
|
403
|
-
if (trailingSeparator) {
|
|
404
|
-
path2 += "/";
|
|
405
|
-
}
|
|
406
|
-
if (_DRIVE_LETTER_RE.test(path2)) {
|
|
407
|
-
path2 += "/";
|
|
408
|
-
}
|
|
409
|
-
if (isUNCPath) {
|
|
410
|
-
if (!isPathAbsolute) {
|
|
411
|
-
return `//./${path2}`;
|
|
412
|
-
}
|
|
413
|
-
return `//${path2}`;
|
|
414
|
-
}
|
|
415
|
-
return isPathAbsolute && !isAbsolute(path2) ? `/${path2}` : path2;
|
|
416
|
-
}, "normalize");
|
|
417
|
-
var join2 = /* @__PURE__ */ __name(function(...arguments_) {
|
|
418
|
-
if (arguments_.length === 0) {
|
|
192
|
+
let isUNCPath = path2.match(_UNC_REGEX), isPathAbsolute = isAbsolute(path2), trailingSeparator = path2[path2.length - 1] === "/";
|
|
193
|
+
return path2 = normalizeString(path2, !isPathAbsolute), path2.length === 0 ? isPathAbsolute ? "/" : trailingSeparator ? "./" : "." : (trailingSeparator && (path2 += "/"), _DRIVE_LETTER_RE.test(path2) && (path2 += "/"), isUNCPath ? isPathAbsolute ? `//${path2}` : `//./${path2}` : isPathAbsolute && !isAbsolute(path2) ? `/${path2}` : path2);
|
|
194
|
+
}, join2 = function(...arguments_) {
|
|
195
|
+
if (arguments_.length === 0)
|
|
419
196
|
return ".";
|
|
420
|
-
}
|
|
421
197
|
let joined;
|
|
422
|
-
for (
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
} else {
|
|
427
|
-
joined += `/${argument}`;
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
if (joined === void 0) {
|
|
432
|
-
return ".";
|
|
433
|
-
}
|
|
434
|
-
return normalize(joined.replace(/\/\/+/g, "/"));
|
|
435
|
-
}, "join");
|
|
198
|
+
for (let argument of arguments_)
|
|
199
|
+
argument && argument.length > 0 && (joined === void 0 ? joined = argument : joined += `/${argument}`);
|
|
200
|
+
return joined === void 0 ? "." : normalize(joined.replace(/\/\/+/g, "/"));
|
|
201
|
+
};
|
|
436
202
|
function normalizeString(path2, allowAboveRoot) {
|
|
437
|
-
let res = "";
|
|
438
|
-
let lastSegmentLength = 0;
|
|
439
|
-
let lastSlash = -1;
|
|
440
|
-
let dots = 0;
|
|
441
|
-
let char = null;
|
|
203
|
+
let res = "", lastSegmentLength = 0, lastSlash = -1, dots = 0, char = null;
|
|
442
204
|
for (let index = 0; index <= path2.length; ++index) {
|
|
443
|
-
if (index < path2.length)
|
|
205
|
+
if (index < path2.length)
|
|
444
206
|
char = path2[index];
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
207
|
+
else {
|
|
208
|
+
if (char === "/")
|
|
209
|
+
break;
|
|
448
210
|
char = "/";
|
|
449
211
|
}
|
|
450
212
|
if (char === "/") {
|
|
451
|
-
if (lastSlash === index - 1 || dots === 1)
|
|
452
|
-
else if (dots === 2) {
|
|
213
|
+
if (!(lastSlash === index - 1 || dots === 1)) if (dots === 2) {
|
|
453
214
|
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
454
215
|
if (res.length > 2) {
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
res = "";
|
|
458
|
-
lastSegmentLength = 0;
|
|
459
|
-
} else {
|
|
460
|
-
res = res.slice(0, lastSlashIndex);
|
|
461
|
-
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
462
|
-
}
|
|
463
|
-
lastSlash = index;
|
|
464
|
-
dots = 0;
|
|
216
|
+
let lastSlashIndex = res.lastIndexOf("/");
|
|
217
|
+
lastSlashIndex === -1 ? (res = "", lastSegmentLength = 0) : (res = res.slice(0, lastSlashIndex), lastSegmentLength = res.length - 1 - res.lastIndexOf("/")), lastSlash = index, dots = 0;
|
|
465
218
|
continue;
|
|
466
219
|
} else if (res.length > 0) {
|
|
467
|
-
res = "";
|
|
468
|
-
lastSegmentLength = 0;
|
|
469
|
-
lastSlash = index;
|
|
470
|
-
dots = 0;
|
|
220
|
+
res = "", lastSegmentLength = 0, lastSlash = index, dots = 0;
|
|
471
221
|
continue;
|
|
472
222
|
}
|
|
473
223
|
}
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
if (res.length > 0) {
|
|
480
|
-
res += `/${path2.slice(lastSlash + 1, index)}`;
|
|
481
|
-
} else {
|
|
482
|
-
res = path2.slice(lastSlash + 1, index);
|
|
483
|
-
}
|
|
484
|
-
lastSegmentLength = index - lastSlash - 1;
|
|
485
|
-
}
|
|
486
|
-
lastSlash = index;
|
|
487
|
-
dots = 0;
|
|
488
|
-
} else if (char === "." && dots !== -1) {
|
|
489
|
-
++dots;
|
|
490
|
-
} else {
|
|
491
|
-
dots = -1;
|
|
492
|
-
}
|
|
224
|
+
allowAboveRoot && (res += res.length > 0 ? "/.." : "..", lastSegmentLength = 2);
|
|
225
|
+
} else
|
|
226
|
+
res.length > 0 ? res += `/${path2.slice(lastSlash + 1, index)}` : res = path2.slice(lastSlash + 1, index), lastSegmentLength = index - lastSlash - 1;
|
|
227
|
+
lastSlash = index, dots = 0;
|
|
228
|
+
} else char === "." && dots !== -1 ? ++dots : dots = -1;
|
|
493
229
|
}
|
|
494
230
|
return res;
|
|
495
231
|
}
|
|
496
|
-
|
|
497
|
-
var isAbsolute = /* @__PURE__ */ __name(function(p) {
|
|
232
|
+
var isAbsolute = function(p) {
|
|
498
233
|
return _IS_ABSOLUTE_RE.test(p);
|
|
499
|
-
}
|
|
500
|
-
var dirname =
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
}
|
|
505
|
-
return segments.join("/") || (isAbsolute(p) ? "/" : ".");
|
|
506
|
-
}, "dirname");
|
|
234
|
+
};
|
|
235
|
+
var dirname = function(p) {
|
|
236
|
+
let segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
|
|
237
|
+
return segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0]) && (segments[0] += "/"), segments.join("/") || (isAbsolute(p) ? "/" : ".");
|
|
238
|
+
};
|
|
507
239
|
|
|
508
240
|
// ../../core/src/shared/utils/module.ts
|
|
509
|
-
var importMetaResolve =
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
"importMetaResolve from within Storybook is being used in a Vitest test, but it shouldn't be. Please report this at https://github.com/storybookjs/storybook/issues/new?template=bug_report.yml"
|
|
513
|
-
);
|
|
514
|
-
return pathToFileURL(args[0]).href;
|
|
515
|
-
}
|
|
516
|
-
return import.meta.resolve(...args);
|
|
517
|
-
}, "importMetaResolve");
|
|
518
|
-
var resolvePackageDir = /* @__PURE__ */ __name((pkg, parent) => {
|
|
519
|
-
return dirname(fileURLToPath(importMetaResolve(join2(pkg, "package.json"), parent)));
|
|
520
|
-
}, "resolvePackageDir");
|
|
241
|
+
var importMetaResolve = (...args) => typeof import.meta.resolve != "function" && process.env.VITEST === "true" ? (console.warn(
|
|
242
|
+
"importMetaResolve from within Storybook is being used in a Vitest test, but it shouldn't be. Please report this at https://github.com/storybookjs/storybook/issues/new?template=bug_report.yml"
|
|
243
|
+
), pathToFileURL(args[0]).href) : import.meta.resolve(...args), resolvePackageDir = (pkg, parent) => dirname(fileURLToPath(importMetaResolve(join2(pkg, "package.json"), parent)));
|
|
521
244
|
|
|
522
245
|
// src/helpers/getReactScriptsPath.ts
|
|
523
|
-
var getReactScriptsPath =
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
if (process.platform === "win32") {
|
|
246
|
+
var getReactScriptsPath = () => {
|
|
247
|
+
let cwd = process.cwd(), scriptsBinPath = join3(cwd, "/node_modules/.bin/react-scripts");
|
|
248
|
+
if (process.platform === "win32")
|
|
527
249
|
try {
|
|
528
|
-
|
|
529
|
-
const packagePathMatch = content.match(
|
|
250
|
+
let packagePathMatch = readFileSync(scriptsBinPath, "utf8").match(
|
|
530
251
|
/"\$basedir[\\/](\S+?)[\\/]bin[\\/]react-scripts\.js"/i
|
|
531
252
|
);
|
|
532
|
-
if (packagePathMatch && packagePathMatch.length > 1)
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
}
|
|
536
|
-
} catch (e) {
|
|
253
|
+
if (packagePathMatch && packagePathMatch.length > 1)
|
|
254
|
+
return join3(cwd, "/node_modules/.bin/", packagePathMatch[1]);
|
|
255
|
+
} catch {
|
|
537
256
|
}
|
|
538
|
-
|
|
257
|
+
else
|
|
539
258
|
try {
|
|
540
|
-
|
|
541
|
-
if (scriptsBinPathStat.isSymbolicLink() ===
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
return scriptsPath;
|
|
545
|
-
}
|
|
546
|
-
if (scriptsBinPathStat.isFile() === true) {
|
|
547
|
-
const scriptsPath = join3(cwd, "/node_modules/react-scripts");
|
|
548
|
-
return scriptsPath;
|
|
259
|
+
let scriptsBinPathStat = lstatSync(scriptsBinPath);
|
|
260
|
+
if (scriptsBinPathStat.isSymbolicLink() === !0) {
|
|
261
|
+
let resolvedBinPath = realpathSync(scriptsBinPath);
|
|
262
|
+
return join3(resolvedBinPath, "..", "..");
|
|
549
263
|
}
|
|
550
|
-
|
|
264
|
+
if (scriptsBinPathStat.isFile() === !0)
|
|
265
|
+
return join3(cwd, "/node_modules/react-scripts");
|
|
266
|
+
} catch {
|
|
551
267
|
}
|
|
552
|
-
}
|
|
553
268
|
try {
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
} catch (e) {
|
|
269
|
+
return resolvePackageDir("react-scripts");
|
|
270
|
+
} catch {
|
|
557
271
|
}
|
|
558
272
|
return "";
|
|
559
|
-
}
|
|
273
|
+
};
|
|
560
274
|
|
|
561
275
|
// src/helpers/mergePlugins.ts
|
|
562
276
|
import ReactRefreshWebpackPlugin from "@pmmmwh/react-refresh-webpack-plugin";
|
|
563
|
-
var mergePlugins =
|
|
277
|
+
var mergePlugins = (...args) => args?.reduce((plugins, plugin) => {
|
|
564
278
|
if (plugins?.some(
|
|
565
279
|
(includedPlugin) => includedPlugin?.constructor.name === plugin?.constructor.name
|
|
566
|
-
) || plugin?.constructor.name === "WebpackManifestPlugin")
|
|
280
|
+
) || plugin?.constructor.name === "WebpackManifestPlugin")
|
|
567
281
|
return plugins;
|
|
568
|
-
}
|
|
569
282
|
let updatedPlugin = plugin;
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
}
|
|
577
|
-
return [...plugins ?? [], updatedPlugin];
|
|
578
|
-
}, []), "mergePlugins");
|
|
283
|
+
return plugin?.constructor.name === "ReactRefreshPlugin" && (updatedPlugin = new ReactRefreshWebpackPlugin({
|
|
284
|
+
overlay: {
|
|
285
|
+
sockIntegration: "whm"
|
|
286
|
+
}
|
|
287
|
+
})), [...plugins ?? [], updatedPlugin];
|
|
288
|
+
}, []);
|
|
579
289
|
|
|
580
290
|
// src/helpers/processCraConfig.ts
|
|
581
291
|
import { resolve as resolve2 } from "node:path";
|
|
582
292
|
import semver from "semver";
|
|
583
|
-
var isRegExp =
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
return false;
|
|
588
|
-
}
|
|
589
|
-
return Array.isArray(rule.test) ? rule.test.some((test) => isRegExp(test) && test.test(string)) : isRegExp(rule.test) && rule.test.test(string);
|
|
590
|
-
}, "testMatch");
|
|
591
|
-
var processCraConfig = /* @__PURE__ */ __name(async (craWebpackConfig, options) => {
|
|
592
|
-
const configDir = resolve2(options.configDir);
|
|
593
|
-
const storybookVersion = semver.coerce(options.packageJson?.version) || "";
|
|
594
|
-
const isStorybook530 = semver.gte(storybookVersion, "5.3.0");
|
|
595
|
-
const babelOptions = await options.presets.apply("babel");
|
|
596
|
-
if (!craWebpackConfig?.module?.rules) {
|
|
597
|
-
return [];
|
|
598
|
-
}
|
|
599
|
-
return craWebpackConfig.module.rules.reduce((rules, rule) => {
|
|
600
|
-
const { oneOf, include } = rule;
|
|
293
|
+
var isRegExp = (value) => value instanceof RegExp, isString = (value) => typeof value == "string", testMatch = (rule, string) => rule.test ? Array.isArray(rule.test) ? rule.test.some((test) => isRegExp(test) && test.test(string)) : isRegExp(rule.test) && rule.test.test(string) : !1, processCraConfig = async (craWebpackConfig, options) => {
|
|
294
|
+
let configDir = resolve2(options.configDir), storybookVersion = semver.coerce(options.packageJson?.version) || "", isStorybook530 = semver.gte(storybookVersion, "5.3.0"), babelOptions = await options.presets.apply("babel");
|
|
295
|
+
return craWebpackConfig?.module?.rules ? craWebpackConfig.module.rules.reduce((rules, rule) => {
|
|
296
|
+
let { oneOf, include } = rule;
|
|
601
297
|
if (testMatch(rule, ".jsx")) {
|
|
602
|
-
|
|
298
|
+
let newRule = {
|
|
603
299
|
...rule,
|
|
604
300
|
include: [include, configDir].filter(Boolean)
|
|
605
301
|
};
|
|
606
302
|
return [...rules, newRule];
|
|
607
303
|
}
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
if (
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
];
|
|
627
|
-
const excludeRegex = new RegExp(`\\.(${excludes.join("|")})$`);
|
|
628
|
-
return {
|
|
629
|
-
...oneOfRule,
|
|
630
|
-
exclude: [...oneOfRule.exclude, excludeRegex]
|
|
631
|
-
};
|
|
632
|
-
}
|
|
633
|
-
return {};
|
|
634
|
-
}
|
|
635
|
-
if (testMatch(oneOfRule, ".css")) {
|
|
636
|
-
return {
|
|
637
|
-
...oneOfRule,
|
|
638
|
-
include: isStorybook530 ? void 0 : [configDir],
|
|
639
|
-
exclude: [oneOfRule.exclude, /@storybook/]
|
|
640
|
-
};
|
|
641
|
-
}
|
|
642
|
-
const isBabelLoader = isString(oneOfRule.loader) && /[/\\]babel-loader[/\\]/.test(oneOfRule.loader);
|
|
643
|
-
if (isBabelLoader && isRegExp(oneOfRule.test) && oneOfRule.test.test(".jsx")) {
|
|
644
|
-
const { include: _include, options: ruleOptions } = oneOfRule;
|
|
645
|
-
const {
|
|
646
|
-
plugins: rulePlugins,
|
|
647
|
-
presets: rulePresets,
|
|
648
|
-
overrides: ruleOverrides
|
|
649
|
-
} = typeof ruleOptions === "object" ? ruleOptions : {};
|
|
650
|
-
const { extends: _extends, plugins, presets, overrides } = babelOptions;
|
|
304
|
+
return oneOf ? [
|
|
305
|
+
...rules,
|
|
306
|
+
{
|
|
307
|
+
// @ts-expect-error (broken typings from webpack)
|
|
308
|
+
oneOf: oneOf.map((oneOfRule) => {
|
|
309
|
+
if (oneOfRule.type === "asset/resource") {
|
|
310
|
+
if (isStorybook530) {
|
|
311
|
+
let excludes = [
|
|
312
|
+
"ejs",
|
|
313
|
+
// Used within Storybook.
|
|
314
|
+
"md",
|
|
315
|
+
// Used with Storybook Notes.
|
|
316
|
+
"mdx",
|
|
317
|
+
// Used with Storybook Docs.
|
|
318
|
+
"cjs",
|
|
319
|
+
// Used for CommonJS modules.
|
|
320
|
+
...options.craOverrides?.fileLoaderExcludes || []
|
|
321
|
+
], excludeRegex = new RegExp(`\\.(${excludes.join("|")})$`);
|
|
651
322
|
return {
|
|
652
323
|
...oneOfRule,
|
|
653
|
-
|
|
654
|
-
options: {
|
|
655
|
-
...ruleOptions,
|
|
656
|
-
extends: _extends,
|
|
657
|
-
plugins: [...plugins ?? [], ...rulePlugins ?? []],
|
|
658
|
-
presets: [...presets ?? [], ...rulePresets ?? []],
|
|
659
|
-
overrides: [...overrides ?? [], ...ruleOverrides ?? []]
|
|
660
|
-
}
|
|
324
|
+
exclude: [...oneOfRule.exclude, excludeRegex]
|
|
661
325
|
};
|
|
662
326
|
}
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
327
|
+
return {};
|
|
328
|
+
}
|
|
329
|
+
if (testMatch(oneOfRule, ".css"))
|
|
330
|
+
return {
|
|
331
|
+
...oneOfRule,
|
|
332
|
+
include: isStorybook530 ? void 0 : [configDir],
|
|
333
|
+
exclude: [oneOfRule.exclude, /@storybook/]
|
|
334
|
+
};
|
|
335
|
+
let isBabelLoader = isString(oneOfRule.loader) && /[/\\]babel-loader[/\\]/.test(oneOfRule.loader);
|
|
336
|
+
if (isBabelLoader && isRegExp(oneOfRule.test) && oneOfRule.test.test(".jsx")) {
|
|
337
|
+
let { include: _include, options: ruleOptions } = oneOfRule, {
|
|
338
|
+
plugins: rulePlugins,
|
|
339
|
+
presets: rulePresets,
|
|
340
|
+
overrides: ruleOverrides
|
|
341
|
+
} = typeof ruleOptions == "object" ? ruleOptions : {}, { extends: _extends, plugins, presets, overrides } = babelOptions;
|
|
342
|
+
return {
|
|
343
|
+
...oneOfRule,
|
|
344
|
+
include: [_include, configDir].filter(Boolean),
|
|
345
|
+
options: {
|
|
346
|
+
...ruleOptions,
|
|
347
|
+
extends: _extends,
|
|
348
|
+
plugins: [...plugins ?? [], ...rulePlugins ?? []],
|
|
349
|
+
presets: [...presets ?? [], ...rulePresets ?? []],
|
|
350
|
+
overrides: [...overrides ?? [], ...ruleOverrides ?? []]
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
return isBabelLoader && isRegExp(oneOfRule.test) && oneOfRule.test.test(".js") ? {
|
|
355
|
+
...oneOfRule,
|
|
356
|
+
include: [configDir]
|
|
357
|
+
} : oneOfRule;
|
|
358
|
+
})
|
|
359
|
+
}
|
|
360
|
+
] : [...rules, rule];
|
|
361
|
+
}, []) : [];
|
|
362
|
+
};
|
|
677
363
|
|
|
678
364
|
// src/index.ts
|
|
679
|
-
var CWD = process.cwd();
|
|
680
|
-
|
|
681
|
-
var OPTION_SCRIPTS_PACKAGE = "scriptsPackageName";
|
|
682
|
-
if (!process.env.PUBLIC_URL) {
|
|
683
|
-
process.env.PUBLIC_URL = ".";
|
|
684
|
-
}
|
|
365
|
+
var CWD = process.cwd(), REACT_SCRIPTS_PATH = getReactScriptsPath(), OPTION_SCRIPTS_PACKAGE = "scriptsPackageName";
|
|
366
|
+
process.env.PUBLIC_URL || (process.env.PUBLIC_URL = ".");
|
|
685
367
|
var resolveLoader = {
|
|
686
368
|
modules: ["node_modules", join4(REACT_SCRIPTS_PATH, "node_modules")],
|
|
687
369
|
// TODO: Remove in SB11
|
|
688
370
|
plugins: [PnpWebpackPlugin.moduleLoader(module)]
|
|
689
|
-
}
|
|
690
|
-
var core = /* @__PURE__ */ __name((existing) => ({
|
|
371
|
+
}, core = (existing) => ({
|
|
691
372
|
...existing,
|
|
692
|
-
disableWebpackDefaults:
|
|
693
|
-
}),
|
|
694
|
-
var webpack = /* @__PURE__ */ __name(async (webpackConfig = {}, options) => {
|
|
373
|
+
disableWebpackDefaults: !0
|
|
374
|
+
}), webpack = async (webpackConfig = {}, options) => {
|
|
695
375
|
let scriptsPath = REACT_SCRIPTS_PATH;
|
|
696
376
|
checkPresets(options);
|
|
697
|
-
|
|
698
|
-
if (typeof scriptsPackageName
|
|
377
|
+
let scriptsPackageName = options[OPTION_SCRIPTS_PACKAGE];
|
|
378
|
+
if (typeof scriptsPackageName == "string")
|
|
699
379
|
try {
|
|
700
380
|
scriptsPath = dirname2(
|
|
701
381
|
__require.resolve(`${scriptsPackageName}/package.json`, {
|
|
702
382
|
paths: [options.configDir]
|
|
703
383
|
})
|
|
704
384
|
);
|
|
705
|
-
} catch
|
|
385
|
+
} catch {
|
|
706
386
|
logger2.warn(`A \`${OPTION_SCRIPTS_PACKAGE}\` was provided, but couldn't be resolved.`);
|
|
707
387
|
}
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
const filteredRules = webpackConfig.module?.rules?.filter((rule) => {
|
|
716
|
-
if (typeof rule === "string") {
|
|
717
|
-
return false;
|
|
718
|
-
}
|
|
719
|
-
const { test } = rule;
|
|
388
|
+
if (!scriptsPath)
|
|
389
|
+
return logger2.error("Failed to resolve a `react-scripts` package."), webpackConfig;
|
|
390
|
+
logger2.info(`=> Loading Webpack configuration from \`${relative2(CWD, scriptsPath)}\``), logger2.info("=> Removing existing JavaScript and TypeScript rules.");
|
|
391
|
+
let filteredRules = webpackConfig.module?.rules?.filter((rule) => {
|
|
392
|
+
if (typeof rule == "string")
|
|
393
|
+
return !1;
|
|
394
|
+
let { test } = rule;
|
|
720
395
|
return !(test instanceof RegExp && (test?.test(".js") || test?.test(".ts")));
|
|
721
|
-
});
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
logger2.info(`=> Modifying Create React App rules.`);
|
|
725
|
-
const craRules = await processCraConfig(craWebpackConfig, options);
|
|
726
|
-
const isProd = webpackConfig.mode !== "development";
|
|
727
|
-
const coreOptions = await options.presets.apply("core");
|
|
728
|
-
const builder = coreOptions?.builder;
|
|
729
|
-
const builderOptions = typeof builder === "string" ? {} : builder?.options;
|
|
730
|
-
const cacheConfig = builderOptions?.fsCache ? { cache: { type: "filesystem" } } : {};
|
|
731
|
-
const lazyCompilationConfig = builderOptions?.lazyCompilation && !isProd ? { experiments: { lazyCompilation: { entries: false } } } : {};
|
|
396
|
+
}), craWebpackConfigPath = join4(scriptsPath, "config", "webpack.config"), craWebpackConfig = __require(craWebpackConfigPath)(webpackConfig.mode);
|
|
397
|
+
logger2.info("=> Modifying Create React App rules.");
|
|
398
|
+
let craRules = await processCraConfig(craWebpackConfig, options), isProd = webpackConfig.mode !== "development", builder = (await options.presets.apply("core"))?.builder, builderOptions = typeof builder == "string" ? {} : builder?.options, cacheConfig = builderOptions?.fsCache ? { cache: { type: "filesystem" } } : {}, lazyCompilationConfig = builderOptions?.lazyCompilation && !isProd ? { experiments: { lazyCompilation: { entries: !1 } } } : {};
|
|
732
399
|
return {
|
|
733
400
|
...webpackConfig,
|
|
734
401
|
...cacheConfig,
|
|
@@ -764,9 +431,7 @@ var webpack = /* @__PURE__ */ __name(async (webpackConfig = {}, options) => {
|
|
|
764
431
|
},
|
|
765
432
|
resolveLoader
|
|
766
433
|
};
|
|
767
|
-
},
|
|
768
|
-
var exportedCore = core;
|
|
769
|
-
var exportedWebpack = webpack;
|
|
434
|
+
}, exportedCore = core, exportedWebpack = webpack;
|
|
770
435
|
export {
|
|
771
436
|
exportedCore as core,
|
|
772
437
|
exportedWebpack as webpack
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/preset-create-react-app",
|
|
3
|
-
"version": "10.1.0-alpha.
|
|
3
|
+
"version": "10.1.0-alpha.11",
|
|
4
4
|
"description": "Storybook for Create React App preset",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook"
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
"type": "module",
|
|
23
23
|
"exports": {
|
|
24
24
|
"./index": "./dist/index.js",
|
|
25
|
-
"./package.json": "./package.json"
|
|
25
|
+
"./package.json": "./package.json",
|
|
26
|
+
"./preset": "./dist/index.js"
|
|
26
27
|
},
|
|
27
28
|
"files": [
|
|
28
29
|
"dist/**/*",
|
|
@@ -48,10 +49,10 @@
|
|
|
48
49
|
},
|
|
49
50
|
"peerDependencies": {
|
|
50
51
|
"react-scripts": ">=5.0.0",
|
|
51
|
-
"storybook": "^10.1.0-alpha.
|
|
52
|
+
"storybook": "^10.1.0-alpha.11"
|
|
52
53
|
},
|
|
53
54
|
"publishConfig": {
|
|
54
55
|
"access": "public"
|
|
55
56
|
},
|
|
56
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "a8e7fd8a655c69780bc20b9749d2699e45beae1l"
|
|
57
58
|
}
|