next 16.0.2-canary.10 → 16.0.2-canary.12

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 (114) hide show
  1. package/dist/bin/next +1 -1
  2. package/dist/build/babel/loader/get-config.js +5 -0
  3. package/dist/build/babel/loader/get-config.js.map +1 -1
  4. package/dist/build/index.js +7 -4
  5. package/dist/build/index.js.map +1 -1
  6. package/dist/build/jest/jest.js +2 -1
  7. package/dist/build/jest/jest.js.map +1 -1
  8. package/dist/build/load-entrypoint.js +1 -2
  9. package/dist/build/load-entrypoint.js.map +1 -1
  10. package/dist/build/lockfile.d.ts +1 -1
  11. package/dist/build/lockfile.js +5 -9
  12. package/dist/build/lockfile.js.map +1 -1
  13. package/dist/build/next-config-ts/transpile-config.js +13 -3
  14. package/dist/build/next-config-ts/transpile-config.js.map +1 -1
  15. package/dist/build/swc/index.d.ts +4 -2
  16. package/dist/build/swc/index.js +54 -51
  17. package/dist/build/swc/index.js.map +1 -1
  18. package/dist/build/swc/install-bindings.d.ts +15 -0
  19. package/dist/build/swc/install-bindings.js +30 -0
  20. package/dist/build/swc/install-bindings.js.map +1 -0
  21. package/dist/build/templates/app-page.js +7 -1
  22. package/dist/build/templates/app-page.js.map +1 -1
  23. package/dist/build/turbopack-build/impl.js +9 -4
  24. package/dist/build/turbopack-build/impl.js.map +1 -1
  25. package/dist/build/webpack/loaders/lightningcss-loader/src/loader.js +7 -2
  26. package/dist/build/webpack/loaders/lightningcss-loader/src/loader.js.map +1 -1
  27. package/dist/build/webpack/loaders/lightningcss-loader/src/minify.js +2 -2
  28. package/dist/build/webpack/loaders/lightningcss-loader/src/minify.js.map +1 -1
  29. package/dist/build/webpack/loaders/next-app-loader/index.js +6 -0
  30. package/dist/build/webpack/loaders/next-app-loader/index.js.map +1 -1
  31. package/dist/build/webpack/loaders/next-barrel-loader.js +5 -0
  32. package/dist/build/webpack/loaders/next-barrel-loader.js.map +1 -1
  33. package/dist/build/webpack/loaders/next-metadata-image-loader.js +5 -0
  34. package/dist/build/webpack/loaders/next-metadata-image-loader.js.map +1 -1
  35. package/dist/build/webpack/loaders/next-metadata-route-loader.js +5 -0
  36. package/dist/build/webpack/loaders/next-metadata-route-loader.js.map +1 -1
  37. package/dist/build/webpack/loaders/next-swc-loader.js +10 -6
  38. package/dist/build/webpack/loaders/next-swc-loader.js.map +1 -1
  39. package/dist/build/webpack-build/impl.js +4 -1
  40. package/dist/build/webpack-build/impl.js.map +1 -1
  41. package/dist/build/webpack-config.js +2 -7
  42. package/dist/build/webpack-config.js.map +1 -1
  43. package/dist/cli/next-typegen.js +3 -0
  44. package/dist/cli/next-typegen.js.map +1 -1
  45. package/dist/client/app-bootstrap.js +1 -1
  46. package/dist/client/index.js +1 -1
  47. package/dist/compiled/@next/font/dist/google/font-data.json +63 -0
  48. package/dist/compiled/@next/font/dist/google/index.d.ts +40 -0
  49. package/dist/esm/build/babel/loader/get-config.js +5 -0
  50. package/dist/esm/build/babel/loader/get-config.js.map +1 -1
  51. package/dist/esm/build/index.js +7 -4
  52. package/dist/esm/build/index.js.map +1 -1
  53. package/dist/esm/build/load-entrypoint.js +2 -3
  54. package/dist/esm/build/load-entrypoint.js.map +1 -1
  55. package/dist/esm/build/lockfile.js +5 -9
  56. package/dist/esm/build/lockfile.js.map +1 -1
  57. package/dist/esm/build/next-config-ts/transpile-config.js +13 -3
  58. package/dist/esm/build/next-config-ts/transpile-config.js.map +1 -1
  59. package/dist/esm/build/swc/index.js +52 -49
  60. package/dist/esm/build/swc/index.js.map +1 -1
  61. package/dist/esm/build/swc/install-bindings.js +20 -0
  62. package/dist/esm/build/swc/install-bindings.js.map +1 -0
  63. package/dist/esm/build/templates/app-page.js +7 -1
  64. package/dist/esm/build/templates/app-page.js.map +1 -1
  65. package/dist/esm/build/turbopack-build/impl.js +10 -5
  66. package/dist/esm/build/turbopack-build/impl.js.map +1 -1
  67. package/dist/esm/build/webpack/loaders/lightningcss-loader/src/loader.js +7 -2
  68. package/dist/esm/build/webpack/loaders/lightningcss-loader/src/loader.js.map +1 -1
  69. package/dist/esm/build/webpack/loaders/lightningcss-loader/src/minify.js +2 -2
  70. package/dist/esm/build/webpack/loaders/lightningcss-loader/src/minify.js.map +1 -1
  71. package/dist/esm/build/webpack/loaders/next-app-loader/index.js +6 -0
  72. package/dist/esm/build/webpack/loaders/next-app-loader/index.js.map +1 -1
  73. package/dist/esm/build/webpack/loaders/next-barrel-loader.js +5 -0
  74. package/dist/esm/build/webpack/loaders/next-barrel-loader.js.map +1 -1
  75. package/dist/esm/build/webpack/loaders/next-metadata-image-loader.js +5 -0
  76. package/dist/esm/build/webpack/loaders/next-metadata-image-loader.js.map +1 -1
  77. package/dist/esm/build/webpack/loaders/next-metadata-route-loader.js +5 -0
  78. package/dist/esm/build/webpack/loaders/next-metadata-route-loader.js.map +1 -1
  79. package/dist/esm/build/webpack/loaders/next-swc-loader.js +11 -7
  80. package/dist/esm/build/webpack/loaders/next-swc-loader.js.map +1 -1
  81. package/dist/esm/build/webpack-build/impl.js +4 -1
  82. package/dist/esm/build/webpack-build/impl.js.map +1 -1
  83. package/dist/esm/build/webpack-config.js +2 -7
  84. package/dist/esm/build/webpack-config.js.map +1 -1
  85. package/dist/esm/client/app-bootstrap.js +1 -1
  86. package/dist/esm/client/index.js +1 -1
  87. package/dist/esm/server/config.js +2 -2
  88. package/dist/esm/server/config.js.map +1 -1
  89. package/dist/esm/server/dev/hot-reloader-turbopack.js +3 -4
  90. package/dist/esm/server/dev/hot-reloader-turbopack.js.map +1 -1
  91. package/dist/esm/server/dev/hot-reloader-webpack.js +1 -1
  92. package/dist/esm/server/lib/app-info-log.js +1 -1
  93. package/dist/esm/server/lib/router-utils/setup-dev-bundler.js +3 -0
  94. package/dist/esm/server/lib/router-utils/setup-dev-bundler.js.map +1 -1
  95. package/dist/esm/server/lib/start-server.js +1 -1
  96. package/dist/esm/server/lib/trace/tracer.js +6 -5
  97. package/dist/esm/server/lib/trace/tracer.js.map +1 -1
  98. package/dist/esm/shared/lib/errors/canary-only-config-error.js +1 -1
  99. package/dist/server/config.js +2 -2
  100. package/dist/server/config.js.map +1 -1
  101. package/dist/server/dev/hot-reloader-turbopack.js +2 -3
  102. package/dist/server/dev/hot-reloader-turbopack.js.map +1 -1
  103. package/dist/server/dev/hot-reloader-webpack.js +1 -1
  104. package/dist/server/lib/app-info-log.js +1 -1
  105. package/dist/server/lib/router-utils/setup-dev-bundler.js +3 -0
  106. package/dist/server/lib/router-utils/setup-dev-bundler.js.map +1 -1
  107. package/dist/server/lib/start-server.js +1 -1
  108. package/dist/server/lib/trace/tracer.js +6 -5
  109. package/dist/server/lib/trace/tracer.js.map +1 -1
  110. package/dist/shared/lib/errors/canary-only-config-error.js +1 -1
  111. package/dist/telemetry/anonymous-meta.js +1 -1
  112. package/dist/telemetry/events/session-stopped.js +2 -2
  113. package/dist/telemetry/events/version.js +2 -2
  114. package/package.json +15 -15
package/dist/bin/next CHANGED
@@ -85,7 +85,7 @@ const program = new NextRootCommand();
85
85
  program.name('next').description('The Next.js CLI allows you to develop, build, start your application, and more.').configureHelp({
86
86
  formatHelp: (cmd, helper)=>(0, _formatclihelpoutput.formatCliHelpOutput)(cmd, helper),
87
87
  subcommandTerm: (cmd)=>`${cmd.name()} ${cmd.usage()}`
88
- }).helpCommand(false).helpOption('-h, --help', 'Displays this message.').version(`Next.js v${"16.0.2-canary.10"}`, '-v, --version', 'Outputs the Next.js version.');
88
+ }).helpCommand(false).helpOption('-h, --help', 'Displays this message.').version(`Next.js v${"16.0.2-canary.12"}`, '-v, --version', 'Outputs the Next.js version.');
89
89
  program.command('build').description('Creates an optimized production build of your application. The output displays information about each route.').argument('[directory]', `A directory on which to build the application. ${(0, _picocolors.italic)('If no directory is provided, the current directory will be used.')}`).option('--experimental-analyze', 'Analyze bundle output. Only compatible with Turbopack.').option('-d, --debug', 'Enables a more verbose build output.').option('--debug-prerender', 'Enables debug mode for prerendering. Not for production use!').option('--no-mangling', 'Disables mangling.').option('--profile', 'Enables production profiling for React.').option('--experimental-app-only', 'Builds only App Router routes.').option('--turbo', 'Builds using Turbopack.').option('--turbopack', 'Builds using Turbopack.').option('--webpack', 'Builds using webpack.').addOption(new _commander.Option('--experimental-build-mode [mode]', 'Uses an experimental build mode.').choices([
90
90
  'compile',
91
91
  'generate',
@@ -16,6 +16,7 @@ const _corelibconfig = /*#__PURE__*/ _interop_require_default(require("next/dist
16
16
  const _util = require("./util");
17
17
  const _log = /*#__PURE__*/ _interop_require_wildcard(require("../../output/log"));
18
18
  const _swc = require("../../swc");
19
+ const _installbindings = require("../../swc/install-bindings");
19
20
  function _interop_require_default(obj) {
20
21
  return obj && obj.__esModule ? obj : {
21
22
  default: obj
@@ -402,6 +403,10 @@ const configFiles = new Set();
402
403
  };
403
404
  }
404
405
  async function getConfig(ctx, { source, target, loaderOptions, filename, inputSourceMap }) {
406
+ // Install bindings early so they are definitely available to the loader.
407
+ // When run by webpack in next this is already done with correct configuration so this is a no-op.
408
+ // In turbopack loaders are run in a subprocess so it may or may not be done.
409
+ await (0, _installbindings.installBindings)();
405
410
  const cacheCharacteristics = await getCacheCharacteristics(loaderOptions, source, filename);
406
411
  if (loaderOptions.configFile) {
407
412
  // Ensures webpack invalidates the cache for this loader when the config file changes
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/build/babel/loader/get-config.ts"],"sourcesContent":["import { readFileSync } from 'node:fs'\nimport { inspect } from 'node:util'\nimport JSON5 from 'next/dist/compiled/json5'\n\nimport { createConfigItem, loadOptions } from 'next/dist/compiled/babel/core'\nimport loadFullConfig from 'next/dist/compiled/babel/core-lib-config'\n\nimport type {\n NextBabelLoaderOptionDefaultPresets,\n NextBabelLoaderOptions,\n NextJsLoaderContext,\n} from './types'\nimport {\n consumeIterator,\n type SourceMap,\n type BabelLoaderTransformOptions,\n} from './util'\nimport * as Log from '../../output/log'\nimport { isReactCompilerRequired } from '../../swc'\n\n/**\n * An internal (non-exported) type used by babel.\n */\nexport type ResolvedBabelConfig = {\n options: BabelLoaderTransformOptions\n passes: BabelPluginPasses\n externalDependencies: ReadonlyArray<string>\n}\n\nexport type BabelPlugin = unknown\nexport type BabelPluginPassList = ReadonlyArray<BabelPlugin>\nexport type BabelPluginPasses = ReadonlyArray<BabelPluginPassList>\n\nconst nextDistPath =\n /(next[\\\\/]dist[\\\\/]shared[\\\\/]lib)|(next[\\\\/]dist[\\\\/]client)|(next[\\\\/]dist[\\\\/]pages)/\n\n/**\n * The properties defined here are the conditions with which subsets of inputs\n * can be identified that are able to share a common Babel config. For example,\n * in dev mode, different transforms must be applied to a source file depending\n * on whether you're compiling for the client or for the server - thus `isServer`\n * is germane.\n *\n * However, these characteristics need not protect against circumstances that\n * will not be encountered in Next.js. For example, a source file may be\n * transformed differently depending on whether we're doing a production compile\n * or for HMR in dev mode. However, those two circumstances will never be\n * encountered within the context of a single V8 context (and, thus, shared\n * cache). Therefore, hasReactRefresh is _not_ germane to caching.\n *\n * NOTE: This approach does not support multiple `.babelrc` files in a\n * single project. A per-cache-key config will be generated once and,\n * if `.babelrc` is present, that config will be used for any subsequent\n * transformations.\n */\ninterface CharacteristicsGermaneToCaching {\n isStandalone: boolean\n isServer: boolean | undefined\n isPageFile: boolean | undefined\n isNextDist: boolean\n hasModuleExports: boolean\n hasReactCompiler: boolean\n fileExt: string\n configFilePath: string | undefined\n}\n\nfunction shouldSkipBabel(\n transformMode: 'standalone' | 'default',\n configFilePath: string | undefined,\n hasReactCompiler: boolean\n) {\n return (\n transformMode === 'standalone' &&\n configFilePath == null &&\n !hasReactCompiler\n )\n}\n\nconst fileExtensionRegex = /\\.([a-z]+)$/\nasync function getCacheCharacteristics(\n loaderOptions: NextBabelLoaderOptions,\n source: string,\n filename: string\n): Promise<CharacteristicsGermaneToCaching> {\n let isStandalone, isServer, pagesDir\n switch (loaderOptions.transformMode) {\n case 'default':\n isStandalone = false\n isServer = loaderOptions.isServer\n pagesDir = loaderOptions.pagesDir\n break\n case 'standalone':\n isStandalone = true\n break\n default:\n throw new Error(\n `unsupported transformMode in loader options: ${inspect(loaderOptions)}`\n )\n }\n\n const isPageFile = pagesDir != null && filename.startsWith(pagesDir)\n const isNextDist = nextDistPath.test(filename)\n const hasModuleExports = source.indexOf('module.exports') !== -1\n const fileExt = fileExtensionRegex.exec(filename)?.[1] || 'unknown'\n\n let {\n reactCompilerPlugins,\n reactCompilerExclude,\n configFile: configFilePath,\n transformMode,\n } = loaderOptions\n\n // Compute `hasReactCompiler` as part of the cache characteristics / key,\n // rather than inside of `getFreshConfig`:\n // - `isReactCompilerRequired` depends on the file contents\n // - `node_modules` and `reactCompilerExclude` depend on the file path, which\n // isn't part of the cache characteristics\n let hasReactCompiler =\n reactCompilerPlugins != null &&\n reactCompilerPlugins.length !== 0 &&\n !loaderOptions.isServer &&\n !/[/\\\\]node_modules[/\\\\]/.test(filename) &&\n // Assumption: `reactCompilerExclude` is cheap because it should only\n // operate on the file path and *not* the file contents (it's sync)\n !reactCompilerExclude?.(filename)\n\n // `isReactCompilerRequired` is expensive to run (parses/visits with SWC), so\n // only run it if there's a good chance we might be able to skip calling Babel\n // entirely (speculatively call `shouldSkipBabel`).\n //\n // Otherwise, we can let react compiler handle this logic for us. It should\n // behave equivalently.\n if (\n hasReactCompiler &&\n shouldSkipBabel(transformMode, configFilePath, /*hasReactCompiler*/ false)\n ) {\n hasReactCompiler &&= await isReactCompilerRequired(filename)\n }\n\n return {\n isStandalone,\n isServer,\n isPageFile,\n isNextDist,\n hasModuleExports,\n hasReactCompiler,\n fileExt,\n configFilePath,\n }\n}\n\n/**\n * Return an array of Babel plugins, conditioned upon loader options and\n * source file characteristics.\n */\nfunction getPlugins(\n loaderOptions: NextBabelLoaderOptionDefaultPresets,\n cacheCharacteristics: CharacteristicsGermaneToCaching\n) {\n const { isServer, isPageFile, isNextDist, hasModuleExports } =\n cacheCharacteristics\n\n const { development, hasReactRefresh } = loaderOptions\n\n const applyCommonJsItem = hasModuleExports\n ? createConfigItem(\n require('../plugins/commonjs') as typeof import('../plugins/commonjs'),\n { type: 'plugin' }\n )\n : null\n const reactRefreshItem = hasReactRefresh\n ? createConfigItem(\n [\n require('next/dist/compiled/react-refresh/babel') as typeof import('next/dist/compiled/react-refresh/babel'),\n { skipEnvCheck: true },\n ],\n { type: 'plugin' }\n )\n : null\n const pageConfigItem =\n !isServer && isPageFile\n ? createConfigItem(\n [\n require('../plugins/next-page-config') as typeof import('../plugins/next-page-config'),\n ],\n {\n type: 'plugin',\n }\n )\n : null\n const disallowExportAllItem =\n !isServer && isPageFile\n ? createConfigItem(\n [\n require('../plugins/next-page-disallow-re-export-all-exports') as typeof import('../plugins/next-page-disallow-re-export-all-exports'),\n ],\n { type: 'plugin' }\n )\n : null\n const transformDefineItem = createConfigItem(\n [\n require.resolve('next/dist/compiled/babel/plugin-transform-define'),\n {\n 'process.env.NODE_ENV': development ? 'development' : 'production',\n 'typeof window': isServer ? 'undefined' : 'object',\n 'process.browser': isServer ? false : true,\n },\n 'next-js-transform-define-instance',\n ],\n { type: 'plugin' }\n )\n const nextSsgItem =\n !isServer && isPageFile\n ? createConfigItem([require.resolve('../plugins/next-ssg-transform')], {\n type: 'plugin',\n })\n : null\n const commonJsItem = isNextDist\n ? createConfigItem(\n require('next/dist/compiled/babel/plugin-transform-modules-commonjs') as typeof import('next/dist/compiled/babel/plugin-transform-modules-commonjs'),\n { type: 'plugin' }\n )\n : null\n const nextFontUnsupported = createConfigItem(\n [\n require('../plugins/next-font-unsupported') as typeof import('../plugins/next-font-unsupported'),\n ],\n { type: 'plugin' }\n )\n\n return [\n reactRefreshItem,\n pageConfigItem,\n disallowExportAllItem,\n applyCommonJsItem,\n transformDefineItem,\n nextSsgItem,\n commonJsItem,\n nextFontUnsupported,\n ].filter(Boolean)\n}\n\nconst isJsonFile = /\\.(json|babelrc)$/\nconst isJsFile = /\\.js$/\n\n/**\n * While this function does block execution while reading from disk, it\n * should not introduce any issues. The function is only invoked when\n * generating a fresh config, and only a small handful of configs should\n * be generated during compilation.\n */\nfunction getCustomBabelConfig(configFilePath: string) {\n if (isJsonFile.exec(configFilePath)) {\n const babelConfigRaw = readFileSync(configFilePath, 'utf8')\n return JSON5.parse(babelConfigRaw)\n } else if (isJsFile.exec(configFilePath)) {\n return require(configFilePath)\n }\n throw new Error(\n 'The Next.js Babel loader does not support .mjs or .cjs config files.'\n )\n}\n\nlet babelConfigWarned = false\n/**\n * Check if custom babel configuration from user only contains options that\n * can be migrated into latest Next.js features supported by SWC.\n *\n * This raises soft warning messages only, not making any errors yet.\n */\nfunction checkCustomBabelConfigDeprecation(\n config: Record<string, any> | undefined\n) {\n if (!config || Object.keys(config).length === 0) {\n return\n }\n\n const { plugins, presets, ...otherOptions } = config\n if (Object.keys(otherOptions ?? {}).length > 0) {\n return\n }\n\n if (babelConfigWarned) {\n return\n }\n\n babelConfigWarned = true\n\n const isPresetReadyToDeprecate =\n !presets ||\n presets.length === 0 ||\n (presets.length === 1 && presets[0] === 'next/babel')\n const pluginReasons = []\n const unsupportedPlugins = []\n\n if (Array.isArray(plugins)) {\n for (const plugin of plugins) {\n const pluginName = Array.isArray(plugin) ? plugin[0] : plugin\n\n // [NOTE]: We cannot detect if the user uses babel-plugin-macro based transform plugins,\n // such as `styled-components/macro` in here.\n switch (pluginName) {\n case 'styled-components':\n case 'babel-plugin-styled-components':\n pluginReasons.push(\n `\\t- 'styled-components' can be enabled via 'compiler.styledComponents' in 'next.config.js'`\n )\n break\n case '@emotion/babel-plugin':\n pluginReasons.push(\n `\\t- '@emotion/babel-plugin' can be enabled via 'compiler.emotion' in 'next.config.js'`\n )\n break\n case 'babel-plugin-relay':\n pluginReasons.push(\n `\\t- 'babel-plugin-relay' can be enabled via 'compiler.relay' in 'next.config.js'`\n )\n break\n case 'react-remove-properties':\n pluginReasons.push(\n `\\t- 'react-remove-properties' can be enabled via 'compiler.reactRemoveProperties' in 'next.config.js'`\n )\n break\n case 'transform-remove-console':\n pluginReasons.push(\n `\\t- 'transform-remove-console' can be enabled via 'compiler.removeConsole' in 'next.config.js'`\n )\n break\n default:\n unsupportedPlugins.push(pluginName)\n break\n }\n }\n }\n\n if (isPresetReadyToDeprecate && unsupportedPlugins.length === 0) {\n Log.warn(\n `It looks like there is a custom Babel configuration that can be removed${\n pluginReasons.length > 0 ? ':' : '.'\n }`\n )\n\n if (pluginReasons.length > 0) {\n Log.warn(`Next.js supports the following features natively: `)\n Log.warn(pluginReasons.join(''))\n Log.warn(\n `For more details configuration options, please refer https://nextjs.org/docs/architecture/nextjs-compiler#supported-features`\n )\n }\n }\n}\n\n/**\n * Generate a new, flat Babel config, ready to be handed to Babel-traverse.\n * This config should have no unresolved overrides, presets, etc.\n *\n * The config returned by this function is cached, so the function should not\n * depend on file-specific configuration or configuration that could change\n * across invocations without a process restart.\n */\nasync function getFreshConfig(\n ctx: NextJsLoaderContext,\n cacheCharacteristics: CharacteristicsGermaneToCaching,\n loaderOptions: NextBabelLoaderOptions,\n target: string\n): Promise<ResolvedBabelConfig | null> {\n const { transformMode } = loaderOptions\n const { hasReactCompiler, configFilePath, fileExt } = cacheCharacteristics\n\n let customConfig = configFilePath && getCustomBabelConfig(configFilePath)\n if (shouldSkipBabel(transformMode, configFilePath, hasReactCompiler)) {\n // Optimization: There's nothing useful to do, bail out and skip babel on\n // this file\n return null\n }\n\n checkCustomBabelConfigDeprecation(customConfig)\n\n // We can assume that `reactCompilerPlugins` does not change without a process\n // restart (it's safe to cache), as it's specified in the `next.config.js`,\n // which always causes a full restart of `next dev` if changed.\n const reactCompilerPluginsIfEnabled = hasReactCompiler\n ? (loaderOptions.reactCompilerPlugins ?? [])\n : []\n\n let isServer, pagesDir, srcDir, development\n if (transformMode === 'default') {\n isServer = loaderOptions.isServer\n pagesDir = loaderOptions.pagesDir\n srcDir = loaderOptions.srcDir\n development = loaderOptions.development\n }\n\n let options: BabelLoaderTransformOptions = {\n babelrc: false,\n cloneInputAst: false,\n\n // Use placeholder file info. `updateBabelConfigWithFileDetails` will\n // replace this after caching.\n filename: `basename.${fileExt}`,\n inputSourceMap: undefined,\n sourceFileName: `basename.${fileExt}`,\n\n // Set the default sourcemap behavior based on Webpack's mapping flag,\n // but allow users to override if they want.\n sourceMaps:\n loaderOptions.sourceMaps === undefined\n ? ctx.sourceMap\n : loaderOptions.sourceMaps,\n }\n\n const baseCaller = {\n name: 'next-babel-turbo-loader',\n supportsStaticESM: true,\n supportsDynamicImport: true,\n\n // Provide plugins with insight into webpack target.\n // https://github.com/babel/babel-loader/issues/787\n target,\n\n // Webpack 5 supports TLA behind a flag. We enable it by default\n // for Babel, and then webpack will throw an error if the experimental\n // flag isn't enabled.\n supportsTopLevelAwait: true,\n\n isServer,\n srcDir,\n pagesDir,\n isDev: development,\n\n transformMode,\n\n ...loaderOptions.caller,\n }\n\n options.plugins = [\n ...(transformMode === 'default'\n ? getPlugins(loaderOptions, cacheCharacteristics)\n : []),\n ...reactCompilerPluginsIfEnabled,\n ...(customConfig?.plugins || []),\n ]\n\n // target can be provided in babelrc\n options.target = isServer ? undefined : customConfig?.target\n\n // env can be provided in babelrc\n options.env = customConfig?.env\n\n options.presets = (() => {\n // If presets is defined the user will have next/babel in their babelrc\n if (customConfig?.presets) {\n return customConfig.presets\n }\n\n // If presets is not defined the user will likely have \"env\" in their babelrc\n if (customConfig) {\n return undefined\n }\n\n // If no custom config is provided the default is to use next/babel\n return ['next/babel']\n })()\n\n options.overrides = loaderOptions.overrides\n\n options.caller = {\n ...baseCaller,\n hasJsxRuntime:\n transformMode === 'default' ? loaderOptions.hasJsxRuntime : undefined,\n }\n\n // Babel does strict checks on the config so undefined is not allowed\n if (typeof options.target === 'undefined') {\n delete options.target\n }\n\n Object.defineProperty(options.caller, 'onWarning', {\n enumerable: false,\n writable: false,\n value: (reason: any) => {\n if (!(reason instanceof Error)) {\n reason = new Error(reason)\n }\n ctx.emitWarning(reason)\n },\n })\n\n const loadedOptions = loadOptions(options)\n const config = consumeIterator(loadFullConfig(loadedOptions))\n\n return config\n}\n\n/**\n * Each key returned here corresponds with a Babel config that can be shared.\n * The conditions of permissible sharing between files is dependent on specific\n * file attributes and Next.js compiler states: `CharacteristicsGermaneToCaching`.\n */\nfunction getCacheKey(cacheCharacteristics: CharacteristicsGermaneToCaching) {\n const {\n isStandalone,\n isServer,\n isPageFile,\n isNextDist,\n hasModuleExports,\n hasReactCompiler,\n fileExt,\n configFilePath,\n } = cacheCharacteristics\n\n const flags =\n 0 |\n (isStandalone ? 0b000001 : 0) |\n (isServer ? 0b000010 : 0) |\n (isPageFile ? 0b000100 : 0) |\n (isNextDist ? 0b001000 : 0) |\n (hasModuleExports ? 0b010000 : 0) |\n (hasReactCompiler ? 0b100000 : 0)\n\n // separate strings with null bytes, assuming null bytes are not valid in file\n // paths\n return `${configFilePath || ''}\\x00${fileExt}\\x00${flags}`\n}\n\nconst configCache: Map<any, ResolvedBabelConfig | null> = new Map()\nconst configFiles: Set<string> = new Set()\n\n/**\n * Applies file-specific values to a potentially-cached configuration object.\n */\nfunction updateBabelConfigWithFileDetails(\n cachedConfig: ResolvedBabelConfig | null | undefined,\n loaderOptions: NextBabelLoaderOptions,\n filename: string,\n inputSourceMap: SourceMap | undefined\n): ResolvedBabelConfig | null {\n if (cachedConfig == null) {\n return null\n }\n return {\n ...cachedConfig,\n options: {\n ...cachedConfig.options,\n cwd: loaderOptions.cwd,\n root: loaderOptions.cwd,\n filename,\n inputSourceMap,\n // Ensure that Webpack will get a full absolute path in the sourcemap\n // so that it can properly map the module back to its internal cached\n // modules.\n sourceFileName: filename,\n },\n }\n}\n\nexport default async function getConfig(\n ctx: NextJsLoaderContext,\n {\n source,\n target,\n loaderOptions,\n filename,\n inputSourceMap,\n }: {\n source: string\n loaderOptions: NextBabelLoaderOptions\n target: string\n filename: string\n inputSourceMap?: SourceMap | undefined\n }\n): Promise<ResolvedBabelConfig | null> {\n const cacheCharacteristics = await getCacheCharacteristics(\n loaderOptions,\n source,\n filename\n )\n\n if (loaderOptions.configFile) {\n // Ensures webpack invalidates the cache for this loader when the config file changes\n ctx.addDependency(loaderOptions.configFile)\n }\n\n const cacheKey = getCacheKey(cacheCharacteristics)\n const cachedConfig = configCache.get(cacheKey)\n if (cachedConfig !== undefined) {\n return updateBabelConfigWithFileDetails(\n cachedConfig,\n loaderOptions,\n filename,\n inputSourceMap\n )\n }\n\n if (loaderOptions.configFile && !configFiles.has(loaderOptions.configFile)) {\n configFiles.add(loaderOptions.configFile)\n Log.info(\n `Using external babel configuration from ${loaderOptions.configFile}`\n )\n }\n\n const freshConfig = await getFreshConfig(\n ctx,\n cacheCharacteristics,\n loaderOptions,\n target\n )\n\n configCache.set(cacheKey, freshConfig)\n\n return updateBabelConfigWithFileDetails(\n freshConfig,\n loaderOptions,\n filename,\n inputSourceMap\n )\n}\n"],"names":["getConfig","nextDistPath","shouldSkipBabel","transformMode","configFilePath","hasReactCompiler","fileExtensionRegex","getCacheCharacteristics","loaderOptions","source","filename","isStandalone","isServer","pagesDir","Error","inspect","isPageFile","startsWith","isNextDist","test","hasModuleExports","indexOf","fileExt","exec","reactCompilerPlugins","reactCompilerExclude","configFile","length","isReactCompilerRequired","getPlugins","cacheCharacteristics","development","hasReactRefresh","applyCommonJsItem","createConfigItem","require","type","reactRefreshItem","skipEnvCheck","pageConfigItem","disallowExportAllItem","transformDefineItem","resolve","nextSsgItem","commonJsItem","nextFontUnsupported","filter","Boolean","isJsonFile","isJsFile","getCustomBabelConfig","babelConfigRaw","readFileSync","JSON5","parse","babelConfigWarned","checkCustomBabelConfigDeprecation","config","Object","keys","plugins","presets","otherOptions","isPresetReadyToDeprecate","pluginReasons","unsupportedPlugins","Array","isArray","plugin","pluginName","push","Log","warn","join","getFreshConfig","ctx","target","customConfig","reactCompilerPluginsIfEnabled","srcDir","options","babelrc","cloneInputAst","inputSourceMap","undefined","sourceFileName","sourceMaps","sourceMap","baseCaller","name","supportsStaticESM","supportsDynamicImport","supportsTopLevelAwait","isDev","caller","env","overrides","hasJsxRuntime","defineProperty","enumerable","writable","value","reason","emitWarning","loadedOptions","loadOptions","consumeIterator","loadFullConfig","getCacheKey","flags","configCache","Map","configFiles","Set","updateBabelConfigWithFileDetails","cachedConfig","cwd","root","addDependency","cacheKey","get","has","add","info","freshConfig","set"],"mappings":";;;;+BA4iBA;;;eAA8BA;;;wBA5iBD;0BACL;8DACN;sBAE4B;sEACnB;sBAWpB;6DACc;qBACmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAexC,MAAMC,eACJ;AAgCF,SAASC,gBACPC,aAAuC,EACvCC,cAAkC,EAClCC,gBAAyB;IAEzB,OACEF,kBAAkB,gBAClBC,kBAAkB,QAClB,CAACC;AAEL;AAEA,MAAMC,qBAAqB;AAC3B,eAAeC,wBACbC,aAAqC,EACrCC,MAAc,EACdC,QAAgB;QAqBAJ;IAnBhB,IAAIK,cAAcC,UAAUC;IAC5B,OAAQL,cAAcL,aAAa;QACjC,KAAK;YACHQ,eAAe;YACfC,WAAWJ,cAAcI,QAAQ;YACjCC,WAAWL,cAAcK,QAAQ;YACjC;QACF,KAAK;YACHF,eAAe;YACf;QACF;YACE,MAAM,qBAEL,CAFK,IAAIG,MACR,CAAC,6CAA6C,EAAEC,IAAAA,iBAAO,EAACP,gBAAgB,GADpE,qBAAA;uBAAA;4BAAA;8BAAA;YAEN;IACJ;IAEA,MAAMQ,aAAaH,YAAY,QAAQH,SAASO,UAAU,CAACJ;IAC3D,MAAMK,aAAajB,aAAakB,IAAI,CAACT;IACrC,MAAMU,mBAAmBX,OAAOY,OAAO,CAAC,sBAAsB,CAAC;IAC/D,MAAMC,UAAUhB,EAAAA,2BAAAA,mBAAmBiB,IAAI,CAACb,8BAAxBJ,wBAAmC,CAAC,EAAE,KAAI;IAE1D,IAAI,EACFkB,oBAAoB,EACpBC,oBAAoB,EACpBC,YAAYtB,cAAc,EAC1BD,aAAa,EACd,GAAGK;IAEJ,yEAAyE;IACzE,0CAA0C;IAC1C,2DAA2D;IAC3D,6EAA6E;IAC7E,4CAA4C;IAC5C,I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D,IAAI,CACN,CAAC,wCAAwC,EAAEnH,cAAckB,UAAU,EAAE;IAEzE;IAEA,MAAMkG,cAAc,MAAMlD,eACxBC,KACA7C,sBACAtB,eACAoE;IAGFkC,YAAYe,GAAG,CAACN,UAAUK;IAE1B,OAAOV,iCACLU,aACApH,eACAE,UACAyE;AAEJ","ignoreList":[0]}
1
+ {"version":3,"sources":["../../../../src/build/babel/loader/get-config.ts"],"sourcesContent":["import { readFileSync } from 'node:fs'\nimport { inspect } from 'node:util'\nimport JSON5 from 'next/dist/compiled/json5'\n\nimport { createConfigItem, loadOptions } from 'next/dist/compiled/babel/core'\nimport loadFullConfig from 'next/dist/compiled/babel/core-lib-config'\n\nimport type {\n NextBabelLoaderOptionDefaultPresets,\n NextBabelLoaderOptions,\n NextJsLoaderContext,\n} from './types'\nimport {\n consumeIterator,\n type SourceMap,\n type BabelLoaderTransformOptions,\n} from './util'\nimport * as Log from '../../output/log'\nimport { isReactCompilerRequired } from '../../swc'\nimport { installBindings } from '../../swc/install-bindings'\n\n/**\n * An internal (non-exported) type used by babel.\n */\nexport type ResolvedBabelConfig = {\n options: BabelLoaderTransformOptions\n passes: BabelPluginPasses\n externalDependencies: ReadonlyArray<string>\n}\n\nexport type BabelPlugin = unknown\nexport type BabelPluginPassList = ReadonlyArray<BabelPlugin>\nexport type BabelPluginPasses = ReadonlyArray<BabelPluginPassList>\n\nconst nextDistPath =\n /(next[\\\\/]dist[\\\\/]shared[\\\\/]lib)|(next[\\\\/]dist[\\\\/]client)|(next[\\\\/]dist[\\\\/]pages)/\n\n/**\n * The properties defined here are the conditions with which subsets of inputs\n * can be identified that are able to share a common Babel config. For example,\n * in dev mode, different transforms must be applied to a source file depending\n * on whether you're compiling for the client or for the server - thus `isServer`\n * is germane.\n *\n * However, these characteristics need not protect against circumstances that\n * will not be encountered in Next.js. For example, a source file may be\n * transformed differently depending on whether we're doing a production compile\n * or for HMR in dev mode. However, those two circumstances will never be\n * encountered within the context of a single V8 context (and, thus, shared\n * cache). Therefore, hasReactRefresh is _not_ germane to caching.\n *\n * NOTE: This approach does not support multiple `.babelrc` files in a\n * single project. A per-cache-key config will be generated once and,\n * if `.babelrc` is present, that config will be used for any subsequent\n * transformations.\n */\ninterface CharacteristicsGermaneToCaching {\n isStandalone: boolean\n isServer: boolean | undefined\n isPageFile: boolean | undefined\n isNextDist: boolean\n hasModuleExports: boolean\n hasReactCompiler: boolean\n fileExt: string\n configFilePath: string | undefined\n}\n\nfunction shouldSkipBabel(\n transformMode: 'standalone' | 'default',\n configFilePath: string | undefined,\n hasReactCompiler: boolean\n) {\n return (\n transformMode === 'standalone' &&\n configFilePath == null &&\n !hasReactCompiler\n )\n}\n\nconst fileExtensionRegex = /\\.([a-z]+)$/\nasync function getCacheCharacteristics(\n loaderOptions: NextBabelLoaderOptions,\n source: string,\n filename: string\n): Promise<CharacteristicsGermaneToCaching> {\n let isStandalone, isServer, pagesDir\n switch (loaderOptions.transformMode) {\n case 'default':\n isStandalone = false\n isServer = loaderOptions.isServer\n pagesDir = loaderOptions.pagesDir\n break\n case 'standalone':\n isStandalone = true\n break\n default:\n throw new Error(\n `unsupported transformMode in loader options: ${inspect(loaderOptions)}`\n )\n }\n\n const isPageFile = pagesDir != null && filename.startsWith(pagesDir)\n const isNextDist = nextDistPath.test(filename)\n const hasModuleExports = source.indexOf('module.exports') !== -1\n const fileExt = fileExtensionRegex.exec(filename)?.[1] || 'unknown'\n\n let {\n reactCompilerPlugins,\n reactCompilerExclude,\n configFile: configFilePath,\n transformMode,\n } = loaderOptions\n\n // Compute `hasReactCompiler` as part of the cache characteristics / key,\n // rather than inside of `getFreshConfig`:\n // - `isReactCompilerRequired` depends on the file contents\n // - `node_modules` and `reactCompilerExclude` depend on the file path, which\n // isn't part of the cache characteristics\n let hasReactCompiler =\n reactCompilerPlugins != null &&\n reactCompilerPlugins.length !== 0 &&\n !loaderOptions.isServer &&\n !/[/\\\\]node_modules[/\\\\]/.test(filename) &&\n // Assumption: `reactCompilerExclude` is cheap because it should only\n // operate on the file path and *not* the file contents (it's sync)\n !reactCompilerExclude?.(filename)\n\n // `isReactCompilerRequired` is expensive to run (parses/visits with SWC), so\n // only run it if there's a good chance we might be able to skip calling Babel\n // entirely (speculatively call `shouldSkipBabel`).\n //\n // Otherwise, we can let react compiler handle this logic for us. It should\n // behave equivalently.\n if (\n hasReactCompiler &&\n shouldSkipBabel(transformMode, configFilePath, /*hasReactCompiler*/ false)\n ) {\n hasReactCompiler &&= await isReactCompilerRequired(filename)\n }\n\n return {\n isStandalone,\n isServer,\n isPageFile,\n isNextDist,\n hasModuleExports,\n hasReactCompiler,\n fileExt,\n configFilePath,\n }\n}\n\n/**\n * Return an array of Babel plugins, conditioned upon loader options and\n * source file characteristics.\n */\nfunction getPlugins(\n loaderOptions: NextBabelLoaderOptionDefaultPresets,\n cacheCharacteristics: CharacteristicsGermaneToCaching\n) {\n const { isServer, isPageFile, isNextDist, hasModuleExports } =\n cacheCharacteristics\n\n const { development, hasReactRefresh } = loaderOptions\n\n const applyCommonJsItem = hasModuleExports\n ? createConfigItem(\n require('../plugins/commonjs') as typeof import('../plugins/commonjs'),\n { type: 'plugin' }\n )\n : null\n const reactRefreshItem = hasReactRefresh\n ? createConfigItem(\n [\n require('next/dist/compiled/react-refresh/babel') as typeof import('next/dist/compiled/react-refresh/babel'),\n { skipEnvCheck: true },\n ],\n { type: 'plugin' }\n )\n : null\n const pageConfigItem =\n !isServer && isPageFile\n ? createConfigItem(\n [\n require('../plugins/next-page-config') as typeof import('../plugins/next-page-config'),\n ],\n {\n type: 'plugin',\n }\n )\n : null\n const disallowExportAllItem =\n !isServer && isPageFile\n ? createConfigItem(\n [\n require('../plugins/next-page-disallow-re-export-all-exports') as typeof import('../plugins/next-page-disallow-re-export-all-exports'),\n ],\n { type: 'plugin' }\n )\n : null\n const transformDefineItem = createConfigItem(\n [\n require.resolve('next/dist/compiled/babel/plugin-transform-define'),\n {\n 'process.env.NODE_ENV': development ? 'development' : 'production',\n 'typeof window': isServer ? 'undefined' : 'object',\n 'process.browser': isServer ? false : true,\n },\n 'next-js-transform-define-instance',\n ],\n { type: 'plugin' }\n )\n const nextSsgItem =\n !isServer && isPageFile\n ? createConfigItem([require.resolve('../plugins/next-ssg-transform')], {\n type: 'plugin',\n })\n : null\n const commonJsItem = isNextDist\n ? createConfigItem(\n require('next/dist/compiled/babel/plugin-transform-modules-commonjs') as typeof import('next/dist/compiled/babel/plugin-transform-modules-commonjs'),\n { type: 'plugin' }\n )\n : null\n const nextFontUnsupported = createConfigItem(\n [\n require('../plugins/next-font-unsupported') as typeof import('../plugins/next-font-unsupported'),\n ],\n { type: 'plugin' }\n )\n\n return [\n reactRefreshItem,\n pageConfigItem,\n disallowExportAllItem,\n applyCommonJsItem,\n transformDefineItem,\n nextSsgItem,\n commonJsItem,\n nextFontUnsupported,\n ].filter(Boolean)\n}\n\nconst isJsonFile = /\\.(json|babelrc)$/\nconst isJsFile = /\\.js$/\n\n/**\n * While this function does block execution while reading from disk, it\n * should not introduce any issues. The function is only invoked when\n * generating a fresh config, and only a small handful of configs should\n * be generated during compilation.\n */\nfunction getCustomBabelConfig(configFilePath: string) {\n if (isJsonFile.exec(configFilePath)) {\n const babelConfigRaw = readFileSync(configFilePath, 'utf8')\n return JSON5.parse(babelConfigRaw)\n } else if (isJsFile.exec(configFilePath)) {\n return require(configFilePath)\n }\n throw new Error(\n 'The Next.js Babel loader does not support .mjs or .cjs config files.'\n )\n}\n\nlet babelConfigWarned = false\n/**\n * Check if custom babel configuration from user only contains options that\n * can be migrated into latest Next.js features supported by SWC.\n *\n * This raises soft warning messages only, not making any errors yet.\n */\nfunction checkCustomBabelConfigDeprecation(\n config: Record<string, any> | undefined\n) {\n if (!config || Object.keys(config).length === 0) {\n return\n }\n\n const { plugins, presets, ...otherOptions } = config\n if (Object.keys(otherOptions ?? {}).length > 0) {\n return\n }\n\n if (babelConfigWarned) {\n return\n }\n\n babelConfigWarned = true\n\n const isPresetReadyToDeprecate =\n !presets ||\n presets.length === 0 ||\n (presets.length === 1 && presets[0] === 'next/babel')\n const pluginReasons = []\n const unsupportedPlugins = []\n\n if (Array.isArray(plugins)) {\n for (const plugin of plugins) {\n const pluginName = Array.isArray(plugin) ? plugin[0] : plugin\n\n // [NOTE]: We cannot detect if the user uses babel-plugin-macro based transform plugins,\n // such as `styled-components/macro` in here.\n switch (pluginName) {\n case 'styled-components':\n case 'babel-plugin-styled-components':\n pluginReasons.push(\n `\\t- 'styled-components' can be enabled via 'compiler.styledComponents' in 'next.config.js'`\n )\n break\n case '@emotion/babel-plugin':\n pluginReasons.push(\n `\\t- '@emotion/babel-plugin' can be enabled via 'compiler.emotion' in 'next.config.js'`\n )\n break\n case 'babel-plugin-relay':\n pluginReasons.push(\n `\\t- 'babel-plugin-relay' can be enabled via 'compiler.relay' in 'next.config.js'`\n )\n break\n case 'react-remove-properties':\n pluginReasons.push(\n `\\t- 'react-remove-properties' can be enabled via 'compiler.reactRemoveProperties' in 'next.config.js'`\n )\n break\n case 'transform-remove-console':\n pluginReasons.push(\n `\\t- 'transform-remove-console' can be enabled via 'compiler.removeConsole' in 'next.config.js'`\n )\n break\n default:\n unsupportedPlugins.push(pluginName)\n break\n }\n }\n }\n\n if (isPresetReadyToDeprecate && unsupportedPlugins.length === 0) {\n Log.warn(\n `It looks like there is a custom Babel configuration that can be removed${\n pluginReasons.length > 0 ? ':' : '.'\n }`\n )\n\n if (pluginReasons.length > 0) {\n Log.warn(`Next.js supports the following features natively: `)\n Log.warn(pluginReasons.join(''))\n Log.warn(\n `For more details configuration options, please refer https://nextjs.org/docs/architecture/nextjs-compiler#supported-features`\n )\n }\n }\n}\n\n/**\n * Generate a new, flat Babel config, ready to be handed to Babel-traverse.\n * This config should have no unresolved overrides, presets, etc.\n *\n * The config returned by this function is cached, so the function should not\n * depend on file-specific configuration or configuration that could change\n * across invocations without a process restart.\n */\nasync function getFreshConfig(\n ctx: NextJsLoaderContext,\n cacheCharacteristics: CharacteristicsGermaneToCaching,\n loaderOptions: NextBabelLoaderOptions,\n target: string\n): Promise<ResolvedBabelConfig | null> {\n const { transformMode } = loaderOptions\n const { hasReactCompiler, configFilePath, fileExt } = cacheCharacteristics\n\n let customConfig = configFilePath && getCustomBabelConfig(configFilePath)\n if (shouldSkipBabel(transformMode, configFilePath, hasReactCompiler)) {\n // Optimization: There's nothing useful to do, bail out and skip babel on\n // this file\n return null\n }\n\n checkCustomBabelConfigDeprecation(customConfig)\n\n // We can assume that `reactCompilerPlugins` does not change without a process\n // restart (it's safe to cache), as it's specified in the `next.config.js`,\n // which always causes a full restart of `next dev` if changed.\n const reactCompilerPluginsIfEnabled = hasReactCompiler\n ? (loaderOptions.reactCompilerPlugins ?? [])\n : []\n\n let isServer, pagesDir, srcDir, development\n if (transformMode === 'default') {\n isServer = loaderOptions.isServer\n pagesDir = loaderOptions.pagesDir\n srcDir = loaderOptions.srcDir\n development = loaderOptions.development\n }\n\n let options: BabelLoaderTransformOptions = {\n babelrc: false,\n cloneInputAst: false,\n\n // Use placeholder file info. `updateBabelConfigWithFileDetails` will\n // replace this after caching.\n filename: `basename.${fileExt}`,\n inputSourceMap: undefined,\n sourceFileName: `basename.${fileExt}`,\n\n // Set the default sourcemap behavior based on Webpack's mapping flag,\n // but allow users to override if they want.\n sourceMaps:\n loaderOptions.sourceMaps === undefined\n ? ctx.sourceMap\n : loaderOptions.sourceMaps,\n }\n\n const baseCaller = {\n name: 'next-babel-turbo-loader',\n supportsStaticESM: true,\n supportsDynamicImport: true,\n\n // Provide plugins with insight into webpack target.\n // https://github.com/babel/babel-loader/issues/787\n target,\n\n // Webpack 5 supports TLA behind a flag. We enable it by default\n // for Babel, and then webpack will throw an error if the experimental\n // flag isn't enabled.\n supportsTopLevelAwait: true,\n\n isServer,\n srcDir,\n pagesDir,\n isDev: development,\n\n transformMode,\n\n ...loaderOptions.caller,\n }\n\n options.plugins = [\n ...(transformMode === 'default'\n ? getPlugins(loaderOptions, cacheCharacteristics)\n : []),\n ...reactCompilerPluginsIfEnabled,\n ...(customConfig?.plugins || []),\n ]\n\n // target can be provided in babelrc\n options.target = isServer ? undefined : customConfig?.target\n\n // env can be provided in babelrc\n options.env = customConfig?.env\n\n options.presets = (() => {\n // If presets is defined the user will have next/babel in their babelrc\n if (customConfig?.presets) {\n return customConfig.presets\n }\n\n // If presets is not defined the user will likely have \"env\" in their babelrc\n if (customConfig) {\n return undefined\n }\n\n // If no custom config is provided the default is to use next/babel\n return ['next/babel']\n })()\n\n options.overrides = loaderOptions.overrides\n\n options.caller = {\n ...baseCaller,\n hasJsxRuntime:\n transformMode === 'default' ? loaderOptions.hasJsxRuntime : undefined,\n }\n\n // Babel does strict checks on the config so undefined is not allowed\n if (typeof options.target === 'undefined') {\n delete options.target\n }\n\n Object.defineProperty(options.caller, 'onWarning', {\n enumerable: false,\n writable: false,\n value: (reason: any) => {\n if (!(reason instanceof Error)) {\n reason = new Error(reason)\n }\n ctx.emitWarning(reason)\n },\n })\n\n const loadedOptions = loadOptions(options)\n const config = consumeIterator(loadFullConfig(loadedOptions))\n\n return config\n}\n\n/**\n * Each key returned here corresponds with a Babel config that can be shared.\n * The conditions of permissible sharing between files is dependent on specific\n * file attributes and Next.js compiler states: `CharacteristicsGermaneToCaching`.\n */\nfunction getCacheKey(cacheCharacteristics: CharacteristicsGermaneToCaching) {\n const {\n isStandalone,\n isServer,\n isPageFile,\n isNextDist,\n hasModuleExports,\n hasReactCompiler,\n fileExt,\n configFilePath,\n } = cacheCharacteristics\n\n const flags =\n 0 |\n (isStandalone ? 0b000001 : 0) |\n (isServer ? 0b000010 : 0) |\n (isPageFile ? 0b000100 : 0) |\n (isNextDist ? 0b001000 : 0) |\n (hasModuleExports ? 0b010000 : 0) |\n (hasReactCompiler ? 0b100000 : 0)\n\n // separate strings with null bytes, assuming null bytes are not valid in file\n // paths\n return `${configFilePath || ''}\\x00${fileExt}\\x00${flags}`\n}\n\nconst configCache: Map<any, ResolvedBabelConfig | null> = new Map()\nconst configFiles: Set<string> = new Set()\n\n/**\n * Applies file-specific values to a potentially-cached configuration object.\n */\nfunction updateBabelConfigWithFileDetails(\n cachedConfig: ResolvedBabelConfig | null | undefined,\n loaderOptions: NextBabelLoaderOptions,\n filename: string,\n inputSourceMap: SourceMap | undefined\n): ResolvedBabelConfig | null {\n if (cachedConfig == null) {\n return null\n }\n return {\n ...cachedConfig,\n options: {\n ...cachedConfig.options,\n cwd: loaderOptions.cwd,\n root: loaderOptions.cwd,\n filename,\n inputSourceMap,\n // Ensure that Webpack will get a full absolute path in the sourcemap\n // so that it can properly map the module back to its internal cached\n // modules.\n sourceFileName: filename,\n },\n }\n}\n\nexport default async function getConfig(\n ctx: NextJsLoaderContext,\n {\n source,\n target,\n loaderOptions,\n filename,\n inputSourceMap,\n }: {\n source: string\n loaderOptions: NextBabelLoaderOptions\n target: string\n filename: string\n inputSourceMap?: SourceMap | undefined\n }\n): Promise<ResolvedBabelConfig | null> {\n // Install bindings early so they are definitely available to the loader.\n // When run by webpack in next this is already done with correct configuration so this is a no-op.\n // In turbopack loaders are run in a subprocess so it may or may not be done.\n await installBindings()\n const cacheCharacteristics = await getCacheCharacteristics(\n loaderOptions,\n source,\n filename\n )\n\n if (loaderOptions.configFile) {\n // Ensures webpack invalidates the cache for this loader when the config file changes\n ctx.addDependency(loaderOptions.configFile)\n }\n\n const cacheKey = getCacheKey(cacheCharacteristics)\n const cachedConfig = configCache.get(cacheKey)\n if (cachedConfig !== undefined) {\n return updateBabelConfigWithFileDetails(\n cachedConfig,\n loaderOptions,\n filename,\n inputSourceMap\n )\n }\n\n if (loaderOptions.configFile && !configFiles.has(loaderOptions.configFile)) {\n configFiles.add(loaderOptions.configFile)\n Log.info(\n `Using external babel configuration from ${loaderOptions.configFile}`\n )\n }\n\n const freshConfig = await getFreshConfig(\n ctx,\n cacheCharacteristics,\n loaderOptions,\n target\n )\n\n configCache.set(cacheKey, freshConfig)\n\n return updateBabelConfigWithFileDetails(\n freshConfig,\n loaderOptions,\n filename,\n inputSourceMap\n )\n}\n"],"names":["getConfig","nextDistPath","shouldSkipBabel","transformMode","configFilePath","hasReactCompiler","fileExtensionRegex","getCacheCharacteristics","loaderOptions","source","filename","isStandalone","isServer","pagesDir","Error","inspect","isPageFile","startsWith","isNextDist","test","hasModuleExports","indexOf","fileExt","exec","reactCompilerPlugins","reactCompilerExclude","configFile","length","isReactCompilerRequired","getPlugins","cacheCharacteristics","development","hasReactRefresh","applyCommonJsItem","createConfigItem","require","type","reactRefreshItem","skipEnvCheck","pageConfigItem","disallowExportAllItem","transformDefineItem","resolve","nextSsgItem","commonJsItem","nextFontUnsupported","filter","Boolean","isJsonFile","isJsFile","getCustomBabelConfig","babelConfigRaw","readFileSync","JSON5","parse","babelConfigWarned","checkCustomBabelConfigDeprecation","config","Object","keys","plugins","presets","otherOptions","isPresetReadyToDeprecate","pluginReasons","unsupportedPlugins","Array","isArray","plugin","pluginName","push","Log","warn","join","getFreshConfig","ctx","target","customConfig","reactCompilerPluginsIfEnabled","srcDir","options","babelrc","cloneInputAst","inputSourceMap","undefined","sourceFileName","sourceMaps","sourceMap","baseCaller","name","supportsStaticESM","supportsDynamicImport","supportsTopLevelAwait","isDev","caller","env","overrides","hasJsxRuntime","defineProperty","enumerable","writable","value","reason","emitWarning","loadedOptions","loadOptions","consumeIterator","loadFullConfig","getCacheKey","flags","configCache","Map","configFiles","Set","updateBabelConfigWithFileDetails","cachedConfig","cwd","root","installBindings","addDependency","cacheKey","get","has","add","info","freshConfig","set"],"mappings":";;;;+BA6iBA;;;eAA8BA;;;wBA7iBD;0BACL;8DACN;sBAE4B;sEACnB;sBAWpB;6DACc;qBACmB;iCACR;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAehC,MAAMC,eACJ;AAgCF,SAASC,gBACPC,aAAuC,EACvCC,cAAkC,EAClCC,gBAAyB;IAEzB,OACEF,kBAAkB,gBAClBC,kBAAkB,QAClB,CAACC;AAEL;AAEA,MAAMC,qBAAqB;AAC3B,eAAeC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B,MAAM;QACxB,OAAO;IACT;IACA,OAAO;QACL,GAAGA,YAAY;QACfnC,SAAS;YACP,GAAGmC,aAAanC,OAAO;YACvBoC,KAAK5G,cAAc4G,GAAG;YACtBC,MAAM7G,cAAc4G,GAAG;YACvB1G;YACAyE;YACA,qEAAqE;YACrE,qEAAqE;YACrE,WAAW;YACXE,gBAAgB3E;QAClB;IACF;AACF;AAEe,eAAeV,UAC5B2E,GAAwB,EACxB,EACElE,MAAM,EACNmE,MAAM,EACNpE,aAAa,EACbE,QAAQ,EACRyE,cAAc,EAOf;IAED,yEAAyE;IACzE,kGAAkG;IAClG,6EAA6E;IAC7E,MAAMmC,IAAAA,gCAAe;IACrB,MAAMxF,uBAAuB,MAAMvB,wBACjCC,eACAC,QACAC;IAGF,IAAIF,cAAckB,UAAU,EAAE;QAC5B,qFAAqF;QACrFiD,IAAI4C,aAAa,CAAC/G,cAAckB,UAAU;IAC5C;IAEA,MAAM8F,WAAWZ,YAAY9E;IAC7B,MAAMqF,eAAeL,YAAYW,GAAG,CAACD;IACrC,IAAIL,iBAAiB/B,WAAW;QAC9B,OAAO8B,iCACLC,cACA3G,eACAE,UACAyE;IAEJ;IAEA,IAAI3E,cAAckB,UAAU,IAAI,CAACsF,YAAYU,GAAG,CAAClH,cAAckB,UAAU,GAAG;QAC1EsF,YAAYW,GAAG,CAACnH,cAAckB,UAAU;QACxC6C,KAAIqD,IAAI,CACN,CAAC,wCAAwC,EAAEpH,cAAckB,UAAU,EAAE;IAEzE;IAEA,MAAMmG,cAAc,MAAMnD,eACxBC,KACA7C,sBACAtB,eACAoE;IAGFkC,YAAYgB,GAAG,CAACN,UAAUK;IAE1B,OAAOX,iCACLW,aACArH,eACAE,UACAyE;AAEJ","ignoreList":[0]}
@@ -66,6 +66,7 @@ const _iserror = /*#__PURE__*/ _interop_require_default(require("../lib/is-error
66
66
  const _isedgeruntime = require("../lib/is-edge-runtime");
67
67
  const _recursivecopy = require("../lib/recursive-copy");
68
68
  const _swc = require("./swc");
69
+ const _installbindings = require("./swc/install-bindings");
69
70
  const _routeregex = require("../shared/lib/router/utils/route-regex");
70
71
  const _getfilesindir = require("../lib/get-files-in-dir");
71
72
  const _swcplugins = require("../telemetry/events/swc-plugins");
@@ -376,7 +377,7 @@ async function build(dir, experimentalAnalyze = false, reactProductionProfiling
376
377
  try {
377
378
  const nextBuildSpan = (0, _trace.trace)('next-build', undefined, {
378
379
  buildMode: experimentalBuildMode,
379
- version: "16.0.2-canary.10"
380
+ version: "16.0.2-canary.12"
380
381
  });
381
382
  _buildcontext.NextBuildContext.nextBuildSpan = nextBuildSpan;
382
383
  _buildcontext.NextBuildContext.dir = dir;
@@ -385,7 +386,7 @@ async function build(dir, experimentalAnalyze = false, reactProductionProfiling
385
386
  _buildcontext.NextBuildContext.noMangling = noMangling;
386
387
  _buildcontext.NextBuildContext.debugPrerender = debugPrerender;
387
388
  await nextBuildSpan.traceAsyncFn(async ()=>{
388
- var _mappedPages_404, _mappedPages__error;
389
+ var _config_experimental, _mappedPages_404, _mappedPages__error;
389
390
  // attempt to load global env values so they are available in next.config.js
390
391
  const { loadedEnvFiles } = nextBuildSpan.traceChild('load-dotenv').traceFn(()=>(0, _env.loadEnvConfig)(dir, false, _log));
391
392
  _buildcontext.NextBuildContext.loadedEnvFiles = loadedEnvFiles;
@@ -400,6 +401,8 @@ async function build(dir, experimentalAnalyze = false, reactProductionProfiling
400
401
  // Reading the config can modify environment variables that influence the bundler selection.
401
402
  bundler = (0, _bundler.finalizeBundlerFromConfig)(bundler);
402
403
  nextBuildSpan.setAttribute('bundler', getBundlerForTelemetry(bundler));
404
+ // Install the native bindings early so we can have synchronous access later.
405
+ await (0, _installbindings.installBindings)((_config_experimental = config.experimental) == null ? void 0 : _config_experimental.useWasmBinary);
403
406
  process.env.NEXT_DEPLOYMENT_ID = config.deploymentId || '';
404
407
  _buildcontext.NextBuildContext.config = config;
405
408
  let configOutDir = 'out';
@@ -902,7 +905,7 @@ async function build(dir, experimentalAnalyze = false, reactProductionProfiling
902
905
  // Files outside of the distDir can be "type": "module"
903
906
  await writeFileUtf8(_path.default.join(distDir, 'package.json'), '{"type": "commonjs"}');
904
907
  // These are written to distDir, so they need to come after creating and cleaning distDr.
905
- await (0, _builddiagnostics.recordFrameworkVersion)("16.0.2-canary.10");
908
+ await (0, _builddiagnostics.recordFrameworkVersion)("16.0.2-canary.12");
906
909
  await (0, _builddiagnostics.updateBuildDiagnostics)({
907
910
  buildStage: 'start'
908
911
  });
@@ -2581,7 +2584,7 @@ async function build(dir, experimentalAnalyze = false, reactProductionProfiling
2581
2584
  configOutDir: _path.default.join(dir, configOutDir),
2582
2585
  staticPages,
2583
2586
  serverPropsPages,
2584
- nextVersion: "16.0.2-canary.10",
2587
+ nextVersion: "16.0.2-canary.12",
2585
2588
  tracingRoot: outputFileTracingRoot,
2586
2589
  hasNodeMiddleware,
2587
2590
  hasInstrumentationHook,