@storybook/nextjs 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 (50) hide show
  1. package/dist/_browser-chunks/{chunk-KX5HHFXV.js → chunk-2SBZPHE7.js} +50 -100
  2. package/dist/_browser-chunks/chunk-RDMFII4N.js +22 -0
  3. package/dist/_browser-chunks/{chunk-L5NVL7MD.js → chunk-SL3VIQZ3.js} +7 -13
  4. package/dist/_browser-chunks/react-18-PYSEDAWB.js +43 -0
  5. package/dist/_node-chunks/chunk-KG2CEDQ6.js +76 -0
  6. package/dist/_node-chunks/chunk-NVSKNSJK.js +205 -0
  7. package/dist/_node-chunks/chunk-XVBKFOBF.js +57 -0
  8. package/dist/_node-chunks/configureNextFont-QR356EAI.js +28 -0
  9. package/dist/_node-chunks/{loader-WPDBQYKQ.js → loader-GUPXITUF.js} +11 -16
  10. package/dist/_node-chunks/{loader-UJGK53PP.js → loader-VIIL5HSY.js} +15 -25
  11. package/dist/_node-chunks/{utils-G77XBOCW.js → utils-GFLYVHHC.js} +8 -9
  12. package/dist/_node-chunks/webpack-A6CKSXQU.js +24 -0
  13. package/dist/_node-chunks/webpack-HDYOTQDH.js +23 -0
  14. package/dist/_node-chunks/{webpack-AIYB3HRJ.js → webpack-K7FNPCWL.js} +13 -19
  15. package/dist/_node-chunks/webpack-KEI74OHK.js +30 -0
  16. package/dist/_node-chunks/{webpack-QCUACIS6.js → webpack-O4VJM34G.js} +9 -12
  17. package/dist/_node-chunks/webpack-S3SWBOVU.js +97 -0
  18. package/dist/_node-chunks/webpack-YFKESEJQ.js +60 -0
  19. package/dist/_node-chunks/webpack-YOXZVRLP.js +23 -0
  20. package/dist/compatibility/draft-mode.compat.js +1 -1
  21. package/dist/export-mocks/cache/index.js +3 -6
  22. package/dist/export-mocks/headers/index.js +6 -29
  23. package/dist/export-mocks/index.js +9 -10
  24. package/dist/export-mocks/navigation/index.js +17 -41
  25. package/dist/export-mocks/router/index.js +20 -54
  26. package/dist/font/webpack/loader/storybook-nextjs-font-loader.js +38 -80
  27. package/dist/image-context.js +1 -1
  28. package/dist/images/next-image.js +5 -11
  29. package/dist/images/next-legacy-image.js +3 -6
  30. package/dist/index.js +2865 -8413
  31. package/dist/next-image-loader-stub.js +9 -16
  32. package/dist/node/index.js +6 -10
  33. package/dist/preset.js +183 -462
  34. package/dist/preview.js +2 -2
  35. package/dist/rsc/server-only.js +1 -1
  36. package/dist/swc/next-swc-loader-patch.js +46 -84
  37. package/package.json +6 -6
  38. package/dist/_browser-chunks/chunk-I5RFHXDS.js +0 -40
  39. package/dist/_browser-chunks/react-18-G7Q4PNHD.js +0 -71
  40. package/dist/_node-chunks/chunk-2ADK3PCH.js +0 -74
  41. package/dist/_node-chunks/chunk-EVMWO5FG.js +0 -102
  42. package/dist/_node-chunks/chunk-RSBRC6AY.js +0 -475
  43. package/dist/_node-chunks/chunk-Z2RESD5M.js +0 -17
  44. package/dist/_node-chunks/configureNextFont-ZETH4V45.js +0 -36
  45. package/dist/_node-chunks/webpack-4ZO2PLAG.js +0 -107
  46. package/dist/_node-chunks/webpack-6QTUYRFB.js +0 -30
  47. package/dist/_node-chunks/webpack-KRJ4EWQZ.js +0 -27
  48. package/dist/_node-chunks/webpack-L5YFG573.js +0 -38
  49. package/dist/_node-chunks/webpack-QPCUFYIY.js +0 -77
  50. package/dist/_node-chunks/webpack-R5RMXZWI.js +0 -26
package/dist/preset.js CHANGED
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_1wy8hqz8e24 from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_1wy8hqz8e24 from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_1wy8hqz8e24 from "node:module";
1
+ import CJS_COMPAT_NODE_URL_h9mxauk5xyo from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_h9mxauk5xyo from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_h9mxauk5xyo from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_1wy8hqz8e24.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_1wy8hqz8e24.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_1wy8hqz8e24.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_h9mxauk5xyo.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_h9mxauk5xyo.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_h9mxauk5xyo.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -13,11 +13,8 @@ import {
13
13
  addScopedAlias,
14
14
  isNextVersionGte,
15
15
  resolveNextConfig
16
- } from "./_node-chunks/chunk-EVMWO5FG.js";
17
- import "./_node-chunks/chunk-RSBRC6AY.js";
18
- import {
19
- __name
20
- } from "./_node-chunks/chunk-Z2RESD5M.js";
16
+ } from "./_node-chunks/chunk-KG2CEDQ6.js";
17
+ import "./_node-chunks/chunk-NVSKNSJK.js";
21
18
 
22
19
  // src/preset.ts
23
20
  import { existsSync } from "node:fs";
@@ -37,27 +34,14 @@ function AmpAttributePatcher() {
37
34
  return {
38
35
  visitor: {
39
36
  JSXOpeningElement(path) {
40
- const openingElement = path.node;
41
- const { name, attributes } = openingElement;
42
- if (!(name && name.type === "JSXIdentifier")) {
43
- return;
44
- }
45
- if (!name.name.startsWith("amp-")) {
46
- return;
47
- }
48
- for (const attribute of attributes) {
49
- if (attribute.type !== "JSXAttribute") {
50
- continue;
51
- }
52
- if (attribute.name.name === "className") {
53
- attribute.name.name = "class";
54
- }
55
- }
37
+ let openingElement = path.node, { name, attributes } = openingElement;
38
+ if (name && name.type === "JSXIdentifier" && name.name.startsWith("amp-"))
39
+ for (let attribute of attributes)
40
+ attribute.type === "JSXAttribute" && attribute.name.name === "className" && (attribute.name.name = "class");
56
41
  }
57
42
  }
58
43
  };
59
44
  }
60
- __name(AmpAttributePatcher, "AmpAttributePatcher");
61
45
 
62
46
  // src/babel/plugins/jsx-pragma.ts
63
47
  import jsx from "next/dist/compiled/babel/plugin-syntax-jsx.js";
@@ -66,44 +50,33 @@ function jsxPragma({ types: t }) {
66
50
  inherits: jsx,
67
51
  visitor: {
68
52
  JSXElement(_path, state) {
69
- state.set("jsx", true);
53
+ state.set("jsx", !0);
70
54
  },
71
55
  // Fragment syntax is still JSX since it compiles to createElement(),
72
56
  // but JSXFragment is not a JSXElement
73
57
  JSXFragment(_path, state) {
74
- state.set("jsx", true);
58
+ state.set("jsx", !0);
75
59
  },
76
60
  Program: {
77
61
  exit(path, state) {
78
62
  if (state.get("jsx")) {
79
- const pragma = t.identifier(state.opts.pragma);
80
- let importAs = pragma;
81
- const existingBinding = state.opts.reuseImport !== false && state.opts.importAs && path.scope.getBinding(state.opts.importAs);
63
+ let pragma = t.identifier(state.opts.pragma), importAs = pragma, existingBinding = state.opts.reuseImport !== !1 && state.opts.importAs && path.scope.getBinding(state.opts.importAs);
82
64
  if (state.opts.property) {
83
- if (state.opts.importAs) {
84
- importAs = t.identifier(state.opts.importAs);
85
- } else {
86
- importAs = path.scope.generateUidIdentifier("pragma");
87
- }
88
- const mapping = t.variableDeclaration("var", [
65
+ state.opts.importAs ? importAs = t.identifier(state.opts.importAs) : importAs = path.scope.generateUidIdentifier("pragma");
66
+ let mapping = t.variableDeclaration("var", [
89
67
  t.variableDeclarator(
90
68
  pragma,
91
69
  t.memberExpression(importAs, t.identifier(state.opts.property))
92
70
  )
93
- ]);
94
- let newPath;
95
- if (existingBinding && t.isVariableDeclarator(existingBinding.path.node) && t.isCallExpression(existingBinding.path.node.init) && t.isIdentifier(existingBinding.path.node.init.callee) && existingBinding.path.node.init.callee.name === "require") {
96
- [newPath] = existingBinding.path.parentPath.insertAfter(mapping);
97
- } else {
98
- [newPath] = path.unshiftContainer("body", mapping);
99
- }
100
- for (const declar of newPath.get("declarations")) {
101
- const kind = ["var", "let", "const"].find((k) => newPath.node.kind === k) || "const";
71
+ ]), newPath;
72
+ existingBinding && t.isVariableDeclarator(existingBinding.path.node) && t.isCallExpression(existingBinding.path.node.init) && t.isIdentifier(existingBinding.path.node.init.callee) && existingBinding.path.node.init.callee.name === "require" ? [newPath] = existingBinding.path.parentPath.insertAfter(mapping) : [newPath] = path.unshiftContainer("body", mapping);
73
+ for (let declar of newPath.get("declarations")) {
74
+ let kind = ["var", "let", "const"].find((k) => newPath.node.kind === k) || "const";
102
75
  path.scope.registerBinding(kind, declar);
103
76
  }
104
77
  }
105
78
  if (!existingBinding) {
106
- const importSpecifier = t.importDeclaration(
79
+ let importSpecifier = t.importDeclaration(
107
80
  [
108
81
  state.opts.import ? (
109
82
  // import { $import as _pragma } from '$module'
@@ -114,11 +87,9 @@ function jsxPragma({ types: t }) {
114
87
  )
115
88
  ],
116
89
  t.stringLiteral(state.opts.module || "react")
117
- );
118
- const [newPath] = path.unshiftContainer("body", importSpecifier);
119
- for (const specifier of newPath.get("specifiers")) {
90
+ ), [newPath] = path.unshiftContainer("body", importSpecifier);
91
+ for (let specifier of newPath.get("specifiers"))
120
92
  path.scope.registerBinding("module", specifier);
121
- }
122
93
  }
123
94
  }
124
95
  }
@@ -126,46 +97,29 @@ function jsxPragma({ types: t }) {
126
97
  }
127
98
  };
128
99
  }
129
- __name(jsxPragma, "jsxPragma");
130
100
 
131
101
  // src/babel/plugins/optimize-hook-destructuring.ts
132
- var isHook = /^use[A-Z]/;
133
- var isBuiltInHook = /^use(Callback|Context|DebugValue|Effect|ImperativeHandle|LayoutEffect|Memo|Reducer|Ref|State)$/;
102
+ var isHook = /^use[A-Z]/, isBuiltInHook = /^use(Callback|Context|DebugValue|Effect|ImperativeHandle|LayoutEffect|Memo|Reducer|Ref|State)$/;
134
103
  function optimizeHookDestructuring({
135
104
  types: t
136
105
  }) {
137
- const visitor = {
106
+ let visitor = {
138
107
  CallExpression(path, state) {
139
- const { onlyBuiltIns } = state.opts;
140
- const libs = state.opts.lib && (state.opts.lib === true ? ["react", "preact/hooks"] : [].concat(state.opts.lib));
141
- if (!t.isVariableDeclarator(path.parent)) {
108
+ let { onlyBuiltIns } = state.opts, libs = state.opts.lib && (state.opts.lib === !0 ? ["react", "preact/hooks"] : [].concat(state.opts.lib));
109
+ if (!t.isVariableDeclarator(path.parent) || !t.isArrayPattern(path.parent.id))
142
110
  return;
143
- }
144
- if (!t.isArrayPattern(path.parent.id)) {
145
- return;
146
- }
147
- const hookName = path.node.callee.name;
111
+ let hookName = path.node.callee.name;
148
112
  if (libs) {
149
- const binding = path.scope.getBinding(hookName);
150
- if (!binding || binding.kind !== "module") {
113
+ let binding = path.scope.getBinding(hookName);
114
+ if (!binding || binding.kind !== "module")
151
115
  return;
152
- }
153
- const specifier = binding.path.parent.source.value;
154
- if (!libs.some((lib) => lib === specifier)) {
116
+ let specifier = binding.path.parent.source.value;
117
+ if (!libs.some((lib) => lib === specifier))
155
118
  return;
156
- }
157
- }
158
- if (!(onlyBuiltIns ? isBuiltInHook : isHook).test(hookName)) {
159
- return;
160
119
  }
161
- path.parent.id = t.objectPattern(
162
- path.parent.id.elements.reduce((patterns, element, i) => {
163
- if (element === null) {
164
- return patterns;
165
- }
166
- return patterns.concat(t.objectProperty(t.numericLiteral(i), element));
167
- }, [])
168
- );
120
+ (onlyBuiltIns ? isBuiltInHook : isHook).test(hookName) && (path.parent.id = t.objectPattern(
121
+ path.parent.id.elements.reduce((patterns, element, i) => element === null ? patterns : patterns.concat(t.objectProperty(t.numericLiteral(i), element)), [])
122
+ ));
169
123
  }
170
124
  };
171
125
  return {
@@ -178,7 +132,6 @@ function optimizeHookDestructuring({
178
132
  }
179
133
  };
180
134
  }
181
- __name(optimizeHookDestructuring, "optimizeHookDestructuring");
182
135
 
183
136
  // src/babel/plugins/react-loadable-plugin.ts
184
137
  import { relative as relativePath } from "node:path";
@@ -186,95 +139,46 @@ function react_loadable_plugin_default({ types: t }) {
186
139
  return {
187
140
  visitor: {
188
141
  ImportDeclaration(path, state) {
189
- const source = path.node.source.value;
190
- if (source !== "next/dynamic") {
191
- return;
192
- }
193
- const defaultSpecifier = path.get("specifiers").find((specifier) => {
194
- return specifier.isImportDefaultSpecifier();
195
- });
196
- if (!defaultSpecifier) {
142
+ if (path.node.source.value !== "next/dynamic")
197
143
  return;
198
- }
199
- const bindingName = defaultSpecifier.node.local.name;
200
- const binding = path.scope.getBinding(bindingName);
201
- if (!binding) {
144
+ let defaultSpecifier = path.get("specifiers").find((specifier) => specifier.isImportDefaultSpecifier());
145
+ if (!defaultSpecifier)
202
146
  return;
203
- }
204
- binding.referencePaths.forEach((refPath) => {
147
+ let bindingName = defaultSpecifier.node.local.name, binding = path.scope.getBinding(bindingName);
148
+ binding && binding.referencePaths.forEach((refPath) => {
205
149
  let callExpression = refPath.parentPath;
206
- if (callExpression.isMemberExpression() && callExpression.node.computed === false) {
207
- const property = callExpression.get("property");
208
- if (!Array.isArray(property) && property.isIdentifier({ name: "Map" })) {
209
- callExpression = callExpression.parentPath;
210
- }
150
+ if (callExpression.isMemberExpression() && callExpression.node.computed === !1) {
151
+ let property = callExpression.get("property");
152
+ !Array.isArray(property) && property.isIdentifier({ name: "Map" }) && (callExpression = callExpression.parentPath);
211
153
  }
212
- if (!callExpression.isCallExpression()) {
154
+ if (!callExpression.isCallExpression())
213
155
  return;
214
- }
215
- const callExpression_ = callExpression;
216
- let args = callExpression_.get("arguments");
217
- if (args.length > 2) {
156
+ let callExpression_ = callExpression, args = callExpression_.get("arguments");
157
+ if (args.length > 2)
218
158
  throw callExpression_.buildCodeFrameError("next/dynamic only accepts 2 arguments");
219
- }
220
- if (!args[0]) {
159
+ if (!args[0])
221
160
  return;
222
- }
223
- let loader;
224
- let options;
225
- if (args[0].isObjectExpression()) {
226
- options = args[0];
227
- } else {
228
- if (!args[1]) {
229
- callExpression_.node.arguments.push(t.objectExpression([]));
230
- }
231
- args = callExpression_.get("arguments");
232
- loader = args[0];
233
- options = args[1];
234
- }
235
- if (!options.isObjectExpression()) {
161
+ let loader, options;
162
+ if (args[0].isObjectExpression() ? options = args[0] : (args[1] || callExpression_.node.arguments.push(t.objectExpression([])), args = callExpression_.get("arguments"), loader = args[0], options = args[1]), !options.isObjectExpression())
236
163
  return;
237
- }
238
- const options_ = options;
239
- const properties = options_.get("properties");
240
- const propertiesMap = {};
241
- properties.forEach((property) => {
242
- const key = property.get("key");
164
+ let properties = options.get("properties"), propertiesMap = {};
165
+ if (properties.forEach((property) => {
166
+ let key = property.get("key");
243
167
  propertiesMap[key.node.name] = property;
244
- });
245
- if (propertiesMap.loadableGenerated) {
246
- return;
247
- }
248
- if (propertiesMap.loader) {
249
- loader = propertiesMap.loader.get("value");
250
- }
251
- if (propertiesMap.modules) {
252
- loader = propertiesMap.modules.get("value");
253
- }
254
- if (!loader || Array.isArray(loader)) {
168
+ }), propertiesMap.loadableGenerated || (propertiesMap.loader && (loader = propertiesMap.loader.get("value")), propertiesMap.modules && (loader = propertiesMap.modules.get("value")), !loader || Array.isArray(loader)))
255
169
  return;
256
- }
257
- const dynamicImports = [];
258
- const dynamicKeys = [];
170
+ let dynamicImports = [], dynamicKeys = [];
259
171
  if (propertiesMap.ssr) {
260
- const ssr = propertiesMap.ssr.get("value");
261
- const nodePath = Array.isArray(ssr) ? void 0 : ssr;
262
- if (nodePath) {
263
- const nonSSR = nodePath.node.type === "BooleanLiteral" && nodePath.node.value === false;
264
- if (nonSSR && loader && state.file.opts.caller?.isServer) {
265
- loader.replaceWith(t.arrowFunctionExpression([], t.nullLiteral(), true));
266
- }
267
- }
172
+ let ssr = propertiesMap.ssr.get("value"), nodePath = Array.isArray(ssr) ? void 0 : ssr;
173
+ nodePath && nodePath.node.type === "BooleanLiteral" && nodePath.node.value === !1 && loader && state.file.opts.caller?.isServer && loader.replaceWith(t.arrowFunctionExpression([], t.nullLiteral(), !0));
268
174
  }
269
- loader.traverse({
175
+ if (loader.traverse({
270
176
  Import(importPath) {
271
- const importArguments = importPath.parentPath.get("arguments");
272
- if (!Array.isArray(importArguments)) {
177
+ let importArguments = importPath.parentPath.get("arguments");
178
+ if (!Array.isArray(importArguments))
273
179
  return;
274
- }
275
- const { node } = importArguments[0];
276
- dynamicImports.push(node);
277
- dynamicKeys.push(
180
+ let { node } = importArguments[0];
181
+ dynamicImports.push(node), dynamicKeys.push(
278
182
  t.binaryExpression(
279
183
  "+",
280
184
  t.stringLiteral(
@@ -284,11 +188,7 @@ function react_loadable_plugin_default({ types: t }) {
284
188
  )
285
189
  );
286
190
  }
287
- });
288
- if (!dynamicImports.length) {
289
- return;
290
- }
291
- options.node.properties.push(
191
+ }), !!dynamicImports.length && (options.node.properties.push(
292
192
  t.objectProperty(
293
193
  t.identifier("loadableGenerated"),
294
194
  t.objectExpression(
@@ -298,24 +198,21 @@ function react_loadable_plugin_default({ types: t }) {
298
198
  t.arrowFunctionExpression(
299
199
  [],
300
200
  t.arrayExpression(
301
- dynamicImports.map((dynamicImport) => {
302
- return t.callExpression(
303
- t.memberExpression(
304
- t.identifier("require"),
305
- t.identifier("resolveWeak")
306
- ),
307
- [dynamicImport]
308
- );
309
- })
201
+ dynamicImports.map((dynamicImport) => t.callExpression(
202
+ t.memberExpression(
203
+ t.identifier("require"),
204
+ t.identifier("resolveWeak")
205
+ ),
206
+ [dynamicImport]
207
+ ))
310
208
  )
311
209
  )
312
210
  )
313
211
  ]
314
212
  )
315
213
  )
316
- );
317
- if (loader.isCallExpression()) {
318
- const arrowFunction = t.arrowFunctionExpression([], loader.node);
214
+ ), loader.isCallExpression())) {
215
+ let arrowFunction = t.arrowFunctionExpression([], loader.node);
319
216
  loader.replaceWith(arrowFunction);
320
217
  }
321
218
  });
@@ -323,48 +220,30 @@ function react_loadable_plugin_default({ types: t }) {
323
220
  }
324
221
  };
325
222
  }
326
- __name(react_loadable_plugin_default, "default");
327
223
 
328
224
  // src/babel/preset.ts
329
- var isLoadIntentTest = process.env.NODE_ENV === "test";
330
- var isLoadIntentDevelopment = process.env.NODE_ENV === "development";
331
- var require2 = createRequire(import.meta.url);
225
+ var isLoadIntentTest = process.env.NODE_ENV === "test", isLoadIntentDevelopment = process.env.NODE_ENV === "development", require2 = createRequire(import.meta.url);
332
226
  function styledJsxOptions(options) {
333
- options = options || {};
334
- options.styleModule = "styled-jsx/style";
335
- if (!Array.isArray(options.plugins)) {
336
- return options;
337
- }
338
- options.plugins = options.plugins.map((plugin) => {
227
+ return options = options || {}, options.styleModule = "styled-jsx/style", Array.isArray(options.plugins) && (options.plugins = options.plugins.map((plugin) => {
339
228
  if (Array.isArray(plugin)) {
340
- const [name, pluginOptions] = plugin;
229
+ let [name, pluginOptions] = plugin;
341
230
  return [require2.resolve(name), pluginOptions];
342
231
  }
343
232
  return require2.resolve(plugin);
344
- });
345
- return options;
233
+ })), options;
346
234
  }
347
- __name(styledJsxOptions, "styledJsxOptions");
348
235
  function supportsStaticESM(caller) {
349
236
  return !!caller?.supportsStaticESM;
350
237
  }
351
- __name(supportsStaticESM, "supportsStaticESM");
352
- var preset_default = /* @__PURE__ */ __name((api, options = {}) => {
353
- const supportsESM = api.caller(supportsStaticESM);
354
- const isServer = api.caller((caller) => !!caller && caller.isServer);
355
- const isCallerDevelopment = api.caller((caller) => caller?.isDev);
356
- const isTest = isCallerDevelopment == null && isLoadIntentTest;
357
- const isDevelopment = isCallerDevelopment === true || isCallerDevelopment == null && isLoadIntentDevelopment;
358
- const isBabelLoader = api.caller(
238
+ var preset_default = (api, options = {}) => {
239
+ let supportsESM = api.caller(supportsStaticESM), isServer = api.caller((caller) => !!caller && caller.isServer), isCallerDevelopment = api.caller((caller) => caller?.isDev), isTest = isCallerDevelopment == null && isLoadIntentTest, isDevelopment = isCallerDevelopment === !0 || isCallerDevelopment == null && isLoadIntentDevelopment, isBabelLoader = api.caller(
359
240
  (caller) => !!caller && (caller.name === "babel-loader" || caller.name === "next-babel-turbo-loader")
360
- );
361
- const useJsxRuntime = options["preset-react"]?.runtime === "automatic" || Boolean(api.caller((caller) => !!caller && caller.hasJsxRuntime)) && options["preset-react"]?.runtime !== "classic";
362
- const presetEnvConfig = {
241
+ ), useJsxRuntime = options["preset-react"]?.runtime === "automatic" || !!api.caller((caller) => !!caller && caller.hasJsxRuntime) && options["preset-react"]?.runtime !== "classic", presetEnvConfig = {
363
242
  // In the test environment `modules` is often needed to be set to true, babel figures that out by itself using the `'auto'` option
364
243
  // In production/development this option is set to `false` so that webpack can handle import/export with tree-shaking
365
244
  modules: "auto",
366
245
  exclude: ["transform-typeof-symbol"],
367
- bugfixes: true,
246
+ bugfixes: !0,
368
247
  targets: {
369
248
  chrome: 100,
370
249
  safari: 15,
@@ -372,15 +251,12 @@ var preset_default = /* @__PURE__ */ __name((api, options = {}) => {
372
251
  },
373
252
  ...options["preset-env"]
374
253
  };
375
- if ((isServer || isTest) && (!presetEnvConfig.targets || !(typeof presetEnvConfig.targets === "object" && "node" in presetEnvConfig.targets))) {
376
- presetEnvConfig.targets = {
377
- // Targets the current process' version of Node. This requires apps be
378
- // built and deployed on the same version of Node.
379
- // This is the same as using "current" but explicit
380
- node: process.versions.node
381
- };
382
- }
383
- return {
254
+ return (isServer || isTest) && (!presetEnvConfig.targets || !(typeof presetEnvConfig.targets == "object" && "node" in presetEnvConfig.targets)) && (presetEnvConfig.targets = {
255
+ // Targets the current process' version of Node. This requires apps be
256
+ // built and deployed on the same version of Node.
257
+ // This is the same as using "current" but explicit
258
+ node: process.versions.node
259
+ }), {
384
260
  sourceType: "unambiguous",
385
261
  presets: [
386
262
  [require2("@babel/preset-env"), presetEnvConfig],
@@ -396,7 +272,7 @@ var preset_default = /* @__PURE__ */ __name((api, options = {}) => {
396
272
  ],
397
273
  [
398
274
  require2("@babel/preset-typescript"),
399
- { allowNamespaces: true, ...options["preset-typescript"] }
275
+ { allowNamespaces: !0, ...options["preset-typescript"] }
400
276
  ]
401
277
  ],
402
278
  plugins: [
@@ -417,7 +293,7 @@ var preset_default = /* @__PURE__ */ __name((api, options = {}) => {
417
293
  optimizeHookDestructuring,
418
294
  {
419
295
  // only optimize hook functions imported from React/Preact
420
- lib: true
296
+ lib: !0
421
297
  }
422
298
  ],
423
299
  require2("@babel/plugin-syntax-dynamic-import"),
@@ -427,15 +303,15 @@ var preset_default = /* @__PURE__ */ __name((api, options = {}) => {
427
303
  [
428
304
  require2("@babel/plugin-transform-object-rest-spread"),
429
305
  {
430
- useBuiltIns: true
306
+ useBuiltIns: !0
431
307
  }
432
308
  ],
433
309
  !isServer && [
434
310
  require2("@babel/plugin-transform-runtime"),
435
311
  {
436
- corejs: false,
437
- helpers: true,
438
- regenerator: true,
312
+ corejs: !1,
313
+ helpers: !0,
314
+ regenerator: !0,
439
315
  useESModules: supportsESM && presetEnvConfig.modules !== "commonjs",
440
316
  absoluteRuntime: isBabelLoader ? dirname(require2.resolve("@babel/runtime/package.json")) : void 0,
441
317
  ...options["transform-runtime"]
@@ -453,206 +329,128 @@ var preset_default = /* @__PURE__ */ __name((api, options = {}) => {
453
329
  require2("@babel/plugin-transform-export-namespace-from")
454
330
  ].filter(Boolean)
455
331
  };
456
- }, "default");
332
+ };
457
333
 
458
334
  // src/config/webpack.ts
459
335
  import { fileURLToPath } from "node:url";
460
- var isNext16orNewer = isNextVersionGte("16.0.0");
461
- var tryResolve = /* @__PURE__ */ __name((path) => {
336
+ var isNext16orNewer = isNextVersionGte("16.0.0"), tryResolve = (path) => {
462
337
  try {
463
- return fileURLToPath(import.meta.resolve(path)) || false;
464
- } catch (err) {
465
- return false;
338
+ return fileURLToPath(import.meta.resolve(path)) || !1;
339
+ } catch {
340
+ return !1;
466
341
  }
467
- }, "tryResolve");
468
- var configureConfig = /* @__PURE__ */ __name(async ({
342
+ }, configureConfig = async ({
469
343
  baseConfig,
470
344
  nextConfigPath
471
345
  }) => {
472
- const nextConfig = await resolveNextConfig({ nextConfigPath });
473
- if (!isNext16orNewer) {
474
- addScopedAlias(baseConfig, "next/config");
475
- }
476
- if (baseConfig.resolve?.alias?.["react-dom"]) {
477
- delete baseConfig.resolve.alias?.["react-dom"];
478
- }
479
- if (tryResolve("next/dist/compiled/react")) {
480
- addScopedAlias(baseConfig, "react", "next/dist/compiled/react");
481
- }
482
- if (tryResolve("next/dist/compiled/react-dom/cjs/react-dom-test-utils.production.js")) {
483
- addScopedAlias(
484
- baseConfig,
485
- "react-dom/test-utils",
486
- "next/dist/compiled/react-dom/cjs/react-dom-test-utils.production.js"
487
- );
488
- }
489
- if (tryResolve("next/dist/compiled/react-dom")) {
490
- addScopedAlias(baseConfig, "react-dom$", "next/dist/compiled/react-dom");
491
- addScopedAlias(baseConfig, "react-dom/client", "next/dist/compiled/react-dom/client");
492
- addScopedAlias(baseConfig, "react-dom/server", "next/dist/compiled/react-dom/server");
493
- }
494
- await setupRuntimeConfig(baseConfig, nextConfig);
495
- return nextConfig;
496
- }, "configureConfig");
497
- var setupRuntimeConfig = /* @__PURE__ */ __name(async (baseConfig, nextConfig) => {
498
- const definePluginConfig = {};
499
- if (!isNext16orNewer) {
500
- definePluginConfig["process.env.__NEXT_RUNTIME_CONFIG"] = JSON.stringify({
501
- serverRuntimeConfig: {},
502
- publicRuntimeConfig: nextConfig.publicRuntimeConfig
503
- });
504
- }
505
- const newNextLinkBehavior = nextConfig.experimental?.newNextLinkBehavior;
506
- definePluginConfig["process.env.__NEXT_NEW_LINK_BEHAVIOR"] = newNextLinkBehavior;
507
- baseConfig.plugins?.push(new (await import("webpack")).default.DefinePlugin(definePluginConfig));
508
- }, "setupRuntimeConfig");
346
+ let nextConfig = await resolveNextConfig({ nextConfigPath });
347
+ return isNext16orNewer || addScopedAlias(baseConfig, "next/config"), baseConfig.resolve?.alias?.["react-dom"] && delete baseConfig.resolve.alias?.["react-dom"], tryResolve("next/dist/compiled/react") && addScopedAlias(baseConfig, "react", "next/dist/compiled/react"), tryResolve("next/dist/compiled/react-dom/cjs/react-dom-test-utils.production.js") && addScopedAlias(
348
+ baseConfig,
349
+ "react-dom/test-utils",
350
+ "next/dist/compiled/react-dom/cjs/react-dom-test-utils.production.js"
351
+ ), tryResolve("next/dist/compiled/react-dom") && (addScopedAlias(baseConfig, "react-dom$", "next/dist/compiled/react-dom"), addScopedAlias(baseConfig, "react-dom/client", "next/dist/compiled/react-dom/client"), addScopedAlias(baseConfig, "react-dom/server", "next/dist/compiled/react-dom/server")), await setupRuntimeConfig(baseConfig, nextConfig), nextConfig;
352
+ }, setupRuntimeConfig = async (baseConfig, nextConfig) => {
353
+ let definePluginConfig = {};
354
+ isNext16orNewer || (definePluginConfig["process.env.__NEXT_RUNTIME_CONFIG"] = JSON.stringify({
355
+ serverRuntimeConfig: {},
356
+ publicRuntimeConfig: nextConfig.publicRuntimeConfig
357
+ }));
358
+ let newNextLinkBehavior = nextConfig.experimental?.newNextLinkBehavior;
359
+ definePluginConfig["process.env.__NEXT_NEW_LINK_BEHAVIOR"] = newNextLinkBehavior, baseConfig.plugins?.push(new (await import("webpack")).default.DefinePlugin(definePluginConfig));
360
+ };
509
361
 
510
362
  // src/font/babel/helpers.ts
511
363
  function convertNodeToJSON(types, node) {
512
- if (types.isBooleanLiteral(node) || types.isStringLiteral(node) || types.isNumericLiteral(node)) {
364
+ if (types.isBooleanLiteral(node) || types.isStringLiteral(node) || types.isNumericLiteral(node))
513
365
  return node.value;
514
- }
515
- if (node.name === "undefined" && !node.value) {
516
- return void 0;
517
- }
518
- if (types.isNullLiteral(node)) {
519
- return null;
520
- }
521
- if (types.isObjectExpression(node)) {
522
- return computeProps(types, node.properties);
523
- }
524
- if (types.isArrayExpression(node)) {
525
- return node.elements.reduce(
366
+ if (!(node.name === "undefined" && !node.value))
367
+ return types.isNullLiteral(node) ? null : types.isObjectExpression(node) ? computeProps(types, node.properties) : types.isArrayExpression(node) ? node.elements.reduce(
526
368
  (acc, element) => [
527
369
  ...acc,
528
370
  ...element?.type === "SpreadElement" ? convertNodeToJSON(types, element.argument) : [convertNodeToJSON(types, element)]
529
371
  ],
530
372
  []
531
- );
532
- }
533
- return {};
373
+ ) : {};
534
374
  }
535
- __name(convertNodeToJSON, "convertNodeToJSON");
536
375
  function computeProps(types, props) {
537
376
  return props.reduce((acc, prop) => {
538
- if (prop.type === "SpreadElement") {
377
+ if (prop.type === "SpreadElement")
539
378
  return {
540
379
  ...acc,
541
380
  ...convertNodeToJSON(types, prop.argument)
542
381
  };
543
- }
544
382
  if (prop.type !== "ObjectMethod") {
545
- const val = convertNodeToJSON(types, prop.value);
546
- if (val !== void 0 && types.isIdentifier(prop.key)) {
383
+ let val = convertNodeToJSON(types, prop.value);
384
+ if (val !== void 0 && types.isIdentifier(prop.key))
547
385
  return {
548
386
  ...acc,
549
387
  [prop.key.name]: val
550
388
  };
551
- }
552
389
  }
553
390
  return acc;
554
391
  }, {});
555
392
  }
556
- __name(computeProps, "computeProps");
557
393
  function isDefined(value) {
558
394
  return value !== void 0;
559
395
  }
560
- __name(isDefined, "isDefined");
561
396
  function removeTransformedVariableDeclarations(path, types, metas) {
562
397
  path.parentPath.traverse({
563
398
  ExportNamedDeclaration(declaratorPath) {
564
- if (!declaratorPath.parentPath?.isProgram()) {
565
- return;
566
- }
567
- metas.forEach((meta) => {
568
- if (types.isVariableDeclaration(declaratorPath.node.declaration) && declaratorPath.node.declaration.declarations.length === 1 && types.isVariableDeclarator(declaratorPath.node.declaration.declarations[0]) && types.isIdentifier(declaratorPath.node.declaration.declarations[0].id) && meta.identifierName === declaratorPath.node.declaration.declarations[0].id.name) {
569
- declaratorPath.replaceWith(
570
- types.exportNamedDeclaration(null, [
571
- types.exportSpecifier(
572
- types.identifier(meta.identifierName),
573
- types.identifier(meta.identifierName)
574
- )
575
- ])
576
- );
577
- }
399
+ declaratorPath.parentPath?.isProgram() && metas.forEach((meta) => {
400
+ types.isVariableDeclaration(declaratorPath.node.declaration) && declaratorPath.node.declaration.declarations.length === 1 && types.isVariableDeclarator(declaratorPath.node.declaration.declarations[0]) && types.isIdentifier(declaratorPath.node.declaration.declarations[0].id) && meta.identifierName === declaratorPath.node.declaration.declarations[0].id.name && declaratorPath.replaceWith(
401
+ types.exportNamedDeclaration(null, [
402
+ types.exportSpecifier(
403
+ types.identifier(meta.identifierName),
404
+ types.identifier(meta.identifierName)
405
+ )
406
+ ])
407
+ );
578
408
  });
579
409
  },
580
410
  VariableDeclarator(declaratorPath) {
581
- if (!declaratorPath.parentPath.parentPath?.isProgram()) {
582
- return;
583
- }
584
- if (metas.some(
411
+ declaratorPath.parentPath.parentPath?.isProgram() && metas.some(
585
412
  (meta) => types.isIdentifier(declaratorPath.node.id) && meta.identifierName === declaratorPath.node.id.name
586
- )) {
587
- declaratorPath.remove();
588
- }
413
+ ) && declaratorPath.remove();
589
414
  }
590
415
  });
591
416
  }
592
- __name(removeTransformedVariableDeclarations, "removeTransformedVariableDeclarations");
593
417
  function replaceImportWithParameterImport(path, types, source, metas, filename) {
594
418
  path.replaceWithMultiple([
595
- ...metas.map((meta) => {
596
- return types.importDeclaration(
597
- [types.importDefaultSpecifier(types.identifier(meta.identifierName))],
598
- types.stringLiteral(
599
- `storybook-nextjs-font-loader?${JSON.stringify({
600
- source: source.value,
601
- props: meta.properties,
602
- fontFamily: meta.functionName,
603
- filename
604
- })}!${source.value}`
605
- )
606
- );
607
- })
419
+ ...metas.map((meta) => types.importDeclaration(
420
+ [types.importDefaultSpecifier(types.identifier(meta.identifierName))],
421
+ types.stringLiteral(
422
+ `storybook-nextjs-font-loader?${JSON.stringify({
423
+ source: source.value,
424
+ props: meta.properties,
425
+ fontFamily: meta.functionName,
426
+ filename
427
+ })}!${source.value}`
428
+ )
429
+ ))
608
430
  ]);
609
431
  }
610
- __name(replaceImportWithParameterImport, "replaceImportWithParameterImport");
611
432
  function getVariableMetasBySpecifier(program, types, specifier) {
612
433
  return program.node.body.map((statement) => {
613
- if (!types.isVariableDeclaration(statement) && !types.isExportNamedDeclaration(statement)) {
614
- return void 0;
615
- }
616
- const exportedNamedDeclaration = !types.isVariableDeclaration(statement) && types.isVariableDeclaration(statement.declaration) && statement.declaration.declarations.length === 1 ? statement.declaration.declarations[0] : null;
617
- const declaration = types.isVariableDeclaration(statement) ? statement.declarations[0] : exportedNamedDeclaration;
618
- if (!declaration) {
619
- return void 0;
620
- }
621
- if (!types.isIdentifier(declaration.id)) {
622
- return void 0;
623
- }
624
- if (!types.isCallExpression(declaration.init)) {
625
- return void 0;
626
- }
627
- if (!types.isIdentifier(declaration.init.callee)) {
628
- return void 0;
629
- }
630
- if ((specifier.type !== "ImportSpecifier" || specifier.imported.type !== "Identifier" || declaration.init.callee.name !== specifier.imported.name && declaration.init.callee.name !== specifier.local.name) && (specifier.type !== "ImportDefaultSpecifier" || declaration.init.callee.name !== specifier.local.name)) {
631
- return void 0;
632
- }
633
- const options = declaration.init.arguments[0];
634
- if (!types.isObjectExpression(options)) {
434
+ if (!types.isVariableDeclaration(statement) && !types.isExportNamedDeclaration(statement))
435
+ return;
436
+ let exportedNamedDeclaration = !types.isVariableDeclaration(statement) && types.isVariableDeclaration(statement.declaration) && statement.declaration.declarations.length === 1 ? statement.declaration.declarations[0] : null, declaration = types.isVariableDeclaration(statement) ? statement.declarations[0] : exportedNamedDeclaration;
437
+ if (!declaration || !types.isIdentifier(declaration.id) || !types.isCallExpression(declaration.init) || !types.isIdentifier(declaration.init.callee) || (specifier.type !== "ImportSpecifier" || specifier.imported.type !== "Identifier" || declaration.init.callee.name !== specifier.imported.name && declaration.init.callee.name !== specifier.local.name) && (specifier.type !== "ImportDefaultSpecifier" || declaration.init.callee.name !== specifier.local.name))
438
+ return;
439
+ let options = declaration.init.arguments[0];
440
+ if (!types.isObjectExpression(options))
635
441
  throw program.buildCodeFrameError(
636
442
  "Please pass an options object to the call expression of next/font functions"
637
443
  );
638
- }
639
444
  options.properties.forEach((property) => {
640
- if (types.isSpreadElement(property)) {
445
+ if (types.isSpreadElement(property))
641
446
  throw program.buildCodeFrameError(
642
447
  "Please do not use spread elements in the options object in next/font function calls"
643
448
  );
644
- }
645
449
  });
646
- const identifierName = declaration.id.name;
647
- const properties = convertNodeToJSON(types, options);
648
- let functionName = declaration.init.callee.name;
649
- if (specifier.type === "ImportSpecifier" && specifier.imported && specifier.imported.type === "Identifier" && declaration.init.callee.name !== specifier.imported.name) {
650
- functionName = specifier.imported.name;
651
- }
652
- return { identifierName, properties, functionName };
450
+ let identifierName = declaration.id.name, properties = convertNodeToJSON(types, options), functionName = declaration.init.callee.name;
451
+ return specifier.type === "ImportSpecifier" && specifier.imported && specifier.imported.type === "Identifier" && declaration.init.callee.name !== specifier.imported.name && (functionName = specifier.imported.name), { identifierName, properties, functionName };
653
452
  }).filter(isDefined);
654
453
  }
655
- __name(getVariableMetasBySpecifier, "getVariableMetasBySpecifier");
656
454
 
657
455
  // src/font/babel/index.ts
658
456
  function TransformFontImports({ types }) {
@@ -660,101 +458,66 @@ function TransformFontImports({ types }) {
660
458
  name: "storybook-nextjs-font-imports",
661
459
  visitor: {
662
460
  ImportDeclaration(path, state) {
663
- const { node } = path;
664
- const { source } = node;
665
- const { filename = "" } = state;
461
+ let { node } = path, { source } = node, { filename = "" } = state;
666
462
  if (source.value === "next/font/local" || source.value === "@next/font/local") {
667
- const { specifiers } = node;
668
- const specifier = specifiers[0];
669
- if (!path.parentPath.isProgram()) {
463
+ let { specifiers } = node, specifier = specifiers[0];
464
+ if (!path.parentPath.isProgram())
670
465
  return;
671
- }
672
- const program = path.parentPath;
673
- const variableMetas = getVariableMetasBySpecifier(program, types, specifier);
674
- removeTransformedVariableDeclarations(path, types, variableMetas);
675
- replaceImportWithParameterImport(path, types, source, variableMetas, filename);
466
+ let program = path.parentPath, variableMetas = getVariableMetasBySpecifier(program, types, specifier);
467
+ removeTransformedVariableDeclarations(path, types, variableMetas), replaceImportWithParameterImport(path, types, source, variableMetas, filename);
676
468
  }
677
469
  if (source.value === "next/font/google" || source.value === "@next/font/google") {
678
- const { specifiers } = node;
679
- const variableMetas = specifiers.flatMap((specifier) => {
680
- if (!path.parentPath.isProgram()) {
470
+ let { specifiers } = node, variableMetas = specifiers.flatMap((specifier) => {
471
+ if (!path.parentPath.isProgram())
681
472
  return [];
682
- }
683
- const program = path.parentPath;
473
+ let program = path.parentPath;
684
474
  return getVariableMetasBySpecifier(program, types, specifier);
685
475
  }).filter(isDefined);
686
- removeTransformedVariableDeclarations(path, types, variableMetas);
687
- replaceImportWithParameterImport(path, types, source, variableMetas, filename);
476
+ removeTransformedVariableDeclarations(path, types, variableMetas), replaceImportWithParameterImport(path, types, source, variableMetas, filename);
688
477
  }
689
478
  }
690
479
  }
691
480
  };
692
481
  }
693
- __name(TransformFontImports, "TransformFontImports");
694
482
 
695
483
  // src/preset.ts
696
484
  var addons = [
697
485
  fileURLToPath2(import.meta.resolve("@storybook/preset-react-webpack"))
698
- ];
699
- var core = /* @__PURE__ */ __name(async (config, options) => {
700
- const framework = await options.presets.apply("framework");
701
- await configureConfig({
486
+ ], core = async (config, options) => {
487
+ let framework = await options.presets.apply("framework");
488
+ return await configureConfig({
702
489
  // Pass in a dummy webpack config object for now, since we don't want to
703
490
  // modify the real one yet. We pass in the real one in webpackFinal.
704
491
  baseConfig: {},
705
- nextConfigPath: typeof framework === "string" ? void 0 : framework.options.nextConfigPath
706
- });
707
- return {
492
+ nextConfigPath: typeof framework == "string" ? void 0 : framework.options.nextConfigPath
493
+ }), {
708
494
  ...config,
709
495
  builder: {
710
496
  name: fileURLToPath2(import.meta.resolve("@storybook/builder-webpack5")),
711
497
  options: {
712
- ...typeof framework === "string" ? {} : framework.options.builder || {}
498
+ ...typeof framework == "string" ? {} : framework.options.builder || {}
713
499
  }
714
500
  },
715
501
  renderer: fileURLToPath2(import.meta.resolve("@storybook/react/preset"))
716
502
  };
717
- }, "core");
718
- var previewAnnotations = /* @__PURE__ */ __name((entry = []) => {
719
- const annotations = [...entry, fileURLToPath2(import.meta.resolve("@storybook/nextjs/preview"))];
720
- const isNext16orNewer2 = isNextVersionGte("16.0.0");
721
- if (!isNext16orNewer2) {
722
- annotations.push(fileURLToPath2(import.meta.resolve("@storybook/nextjs/config/preview")));
723
- }
724
- return annotations;
725
- }, "previewAnnotations");
726
- var babel = /* @__PURE__ */ __name(async (baseConfig) => {
727
- const configPartial = loadPartialConfig({
503
+ }, previewAnnotations = (entry = []) => {
504
+ let annotations = [...entry, fileURLToPath2(import.meta.resolve("@storybook/nextjs/preview"))];
505
+ return isNextVersionGte("16.0.0") || annotations.push(fileURLToPath2(import.meta.resolve("@storybook/nextjs/config/preview"))), annotations;
506
+ }, babel = async (baseConfig) => {
507
+ let options = loadPartialConfig({
728
508
  ...baseConfig,
729
509
  filename: `${getProjectRoot()}/__fake__.js`
730
- });
731
- const options = configPartial?.options;
732
- const isPresetConfigItem = /* @__PURE__ */ __name((preset) => {
733
- return typeof preset === "object" && preset !== null && "file" in preset;
734
- }, "isPresetConfigItem");
735
- const isNextBabelConfig = /* @__PURE__ */ __name((preset) => Array.isArray(preset) && preset[0] === "next/babel" || preset === "next/babel" || isPresetConfigItem(preset) && preset.file?.request === "next/babel", "isNextBabelConfig");
736
- const hasNextBabelConfig = options?.presets?.find(isNextBabelConfig);
737
- const presets = options?.presets?.filter(
510
+ })?.options, isPresetConfigItem = (preset) => typeof preset == "object" && preset !== null && "file" in preset, isNextBabelConfig = (preset) => Array.isArray(preset) && preset[0] === "next/babel" || preset === "next/babel" || isPresetConfigItem(preset) && preset.file?.request === "next/babel", hasNextBabelConfig = options?.presets?.find(isNextBabelConfig), presets = options?.presets?.filter(
738
511
  (preset) => !(isPresetConfigItem(preset) && preset.file?.request === fileURLToPath2(import.meta.resolve("@babel/preset-react")) || isNextBabelConfig(preset))
739
512
  ) ?? [];
740
- if (hasNextBabelConfig) {
741
- if (Array.isArray(hasNextBabelConfig) && hasNextBabelConfig[1]) {
742
- presets.push([preset_default, hasNextBabelConfig[1]]);
743
- } else if (isPresetConfigItem(hasNextBabelConfig) && hasNextBabelConfig.file?.request === "next/babel") {
744
- presets.push([preset_default, hasNextBabelConfig.options]);
745
- } else {
746
- presets.push(preset_default);
747
- }
748
- } else {
749
- presets.push(preset_default);
750
- }
751
- const plugins = [...options?.plugins ?? [], TransformFontImports];
513
+ hasNextBabelConfig ? Array.isArray(hasNextBabelConfig) && hasNextBabelConfig[1] ? presets.push([preset_default, hasNextBabelConfig[1]]) : isPresetConfigItem(hasNextBabelConfig) && hasNextBabelConfig.file?.request === "next/babel" ? presets.push([preset_default, hasNextBabelConfig.options]) : presets.push(preset_default) : presets.push(preset_default);
514
+ let plugins = [...options?.plugins ?? [], TransformFontImports];
752
515
  return {
753
516
  ...options,
754
517
  plugins,
755
518
  presets,
756
- babelrc: false,
757
- configFile: false,
519
+ babelrc: !1,
520
+ configFile: !1,
758
521
  overrides: [
759
522
  ...options?.overrides ?? [],
760
523
  // We need to re-apply the default storybook babel override from:
@@ -767,7 +530,7 @@ var babel = /* @__PURE__ */ __name(async (baseConfig) => {
767
530
  [
768
531
  "next/dist/compiled/babel/preset-env",
769
532
  {
770
- bugfixes: true,
533
+ bugfixes: !0,
771
534
  targets: {
772
535
  chrome: 100,
773
536
  safari: 15,
@@ -779,55 +542,13 @@ var babel = /* @__PURE__ */ __name(async (baseConfig) => {
779
542
  }
780
543
  ]
781
544
  };
782
- }, "babel");
783
- var webpackFinal = /* @__PURE__ */ __name(async (baseConfig, options) => {
784
- const { nextConfigPath } = await options.presets.apply("frameworkOptions");
785
- const nextConfig = await configureConfig({
545
+ }, webpackFinal = async (baseConfig, options) => {
546
+ let { nextConfigPath } = await options.presets.apply("frameworkOptions"), nextConfig = await configureConfig({
786
547
  baseConfig,
787
548
  nextConfigPath
788
- });
789
- const { configureNextFont } = await import("./_node-chunks/configureNextFont-ZETH4V45.js");
790
- const { configureRuntimeNextjsVersionResolution, getNextjsVersion } = await import("./_node-chunks/utils-G77XBOCW.js");
791
- const { configureImports } = await import("./_node-chunks/webpack-L5YFG573.js");
792
- const { configureCss } = await import("./_node-chunks/webpack-4ZO2PLAG.js");
793
- const { configureImages } = await import("./_node-chunks/webpack-QPCUFYIY.js");
794
- const { configureStyledJsx } = await import("./_node-chunks/webpack-R5RMXZWI.js");
795
- const { configureNodePolyfills } = await import("./_node-chunks/webpack-6QTUYRFB.js");
796
- const { configureAliases } = await import("./_node-chunks/webpack-AIYB3HRJ.js");
797
- const { configureFastRefresh } = await import("./_node-chunks/webpack-QCUACIS6.js");
798
- const { configureRSC } = await import("./_node-chunks/webpack-KRJ4EWQZ.js");
799
- const { configureSWCLoader } = await import("./_node-chunks/loader-UJGK53PP.js");
800
- const { configureBabelLoader } = await import("./_node-chunks/loader-WPDBQYKQ.js");
801
- const babelRCPath = join(getProjectRoot(), ".babelrc");
802
- const babelConfigPath = join(getProjectRoot(), "babel.config.js");
803
- const hasBabelConfig = existsSync(babelRCPath) || existsSync(babelConfigPath);
804
- const nextjsVersion = getNextjsVersion();
805
- const isDevelopment = options.configType !== "PRODUCTION";
806
- const isNext14orNewer = semver.gte(nextjsVersion, "14.0.0");
807
- const useSWC = isNext14orNewer && (nextConfig.experimental?.forceSwcTransforms || !hasBabelConfig);
808
- configureNextFont(baseConfig, useSWC);
809
- configureRuntimeNextjsVersionResolution(baseConfig);
810
- configureImports({ baseConfig, configDir: options.configDir });
811
- configureCss(baseConfig, nextConfig);
812
- configureImages(baseConfig, nextConfig);
813
- configureStyledJsx(baseConfig);
814
- configureNodePolyfills(baseConfig);
815
- configureAliases(baseConfig);
816
- if (isDevelopment) {
817
- configureFastRefresh(baseConfig);
818
- }
819
- if (options.features?.experimentalRSC) {
820
- configureRSC(baseConfig);
821
- }
822
- if (useSWC) {
823
- logger.info("=> Using SWC as compiler");
824
- await configureSWCLoader(baseConfig, options, nextConfig);
825
- } else {
826
- logger.info("=> Using Babel as compiler");
827
- await configureBabelLoader(baseConfig, options, nextConfig);
828
- }
829
- return baseConfig;
830
- }, "webpackFinal");
549
+ }), { configureNextFont } = await import("./_node-chunks/configureNextFont-QR356EAI.js"), { configureRuntimeNextjsVersionResolution, getNextjsVersion } = await import("./_node-chunks/utils-GFLYVHHC.js"), { configureImports } = await import("./_node-chunks/webpack-KEI74OHK.js"), { configureCss } = await import("./_node-chunks/webpack-S3SWBOVU.js"), { configureImages } = await import("./_node-chunks/webpack-YFKESEJQ.js"), { configureStyledJsx } = await import("./_node-chunks/webpack-HDYOTQDH.js"), { configureNodePolyfills } = await import("./_node-chunks/webpack-YOXZVRLP.js"), { configureAliases } = await import("./_node-chunks/webpack-K7FNPCWL.js"), { configureFastRefresh } = await import("./_node-chunks/webpack-O4VJM34G.js"), { configureRSC } = await import("./_node-chunks/webpack-A6CKSXQU.js"), { configureSWCLoader } = await import("./_node-chunks/loader-VIIL5HSY.js"), { configureBabelLoader } = await import("./_node-chunks/loader-GUPXITUF.js"), babelRCPath = join(getProjectRoot(), ".babelrc"), babelConfigPath = join(getProjectRoot(), "babel.config.js"), hasBabelConfig = existsSync(babelRCPath) || existsSync(babelConfigPath), nextjsVersion = getNextjsVersion(), isDevelopment = options.configType !== "PRODUCTION", useSWC = semver.gte(nextjsVersion, "14.0.0") && (nextConfig.experimental?.forceSwcTransforms || !hasBabelConfig);
550
+ return configureNextFont(baseConfig, useSWC), configureRuntimeNextjsVersionResolution(baseConfig), configureImports({ baseConfig, configDir: options.configDir }), configureCss(baseConfig, nextConfig), configureImages(baseConfig, nextConfig), configureStyledJsx(baseConfig), configureNodePolyfills(baseConfig), configureAliases(baseConfig), isDevelopment && configureFastRefresh(baseConfig), options.features?.experimentalRSC && configureRSC(baseConfig), useSWC ? (logger.info("=> Using SWC as compiler"), await configureSWCLoader(baseConfig, options, nextConfig)) : (logger.info("=> Using Babel as compiler"), await configureBabelLoader(baseConfig, options, nextConfig)), baseConfig;
551
+ };
831
552
  export {
832
553
  addons,
833
554
  babel,