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