next 16.0.2-canary.11 → 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.
- package/dist/bin/next +1 -1
- package/dist/build/babel/loader/get-config.js +5 -0
- package/dist/build/babel/loader/get-config.js.map +1 -1
- package/dist/build/index.js +7 -4
- package/dist/build/index.js.map +1 -1
- package/dist/build/jest/jest.js +2 -1
- package/dist/build/jest/jest.js.map +1 -1
- package/dist/build/load-entrypoint.js +1 -2
- package/dist/build/load-entrypoint.js.map +1 -1
- package/dist/build/lockfile.d.ts +1 -1
- package/dist/build/lockfile.js +5 -9
- package/dist/build/lockfile.js.map +1 -1
- package/dist/build/next-config-ts/transpile-config.js +13 -3
- package/dist/build/next-config-ts/transpile-config.js.map +1 -1
- package/dist/build/swc/index.d.ts +4 -2
- package/dist/build/swc/index.js +54 -51
- package/dist/build/swc/index.js.map +1 -1
- package/dist/build/swc/install-bindings.d.ts +15 -0
- package/dist/build/swc/install-bindings.js +30 -0
- package/dist/build/swc/install-bindings.js.map +1 -0
- package/dist/build/turbopack-build/impl.js +9 -4
- package/dist/build/turbopack-build/impl.js.map +1 -1
- package/dist/build/webpack/loaders/lightningcss-loader/src/loader.js +7 -2
- package/dist/build/webpack/loaders/lightningcss-loader/src/loader.js.map +1 -1
- package/dist/build/webpack/loaders/lightningcss-loader/src/minify.js +2 -2
- package/dist/build/webpack/loaders/lightningcss-loader/src/minify.js.map +1 -1
- package/dist/build/webpack/loaders/next-app-loader/index.js +6 -0
- package/dist/build/webpack/loaders/next-app-loader/index.js.map +1 -1
- package/dist/build/webpack/loaders/next-barrel-loader.js +5 -0
- package/dist/build/webpack/loaders/next-barrel-loader.js.map +1 -1
- package/dist/build/webpack/loaders/next-metadata-image-loader.js +5 -0
- package/dist/build/webpack/loaders/next-metadata-image-loader.js.map +1 -1
- package/dist/build/webpack/loaders/next-metadata-route-loader.js +5 -0
- package/dist/build/webpack/loaders/next-metadata-route-loader.js.map +1 -1
- package/dist/build/webpack/loaders/next-swc-loader.js +10 -6
- package/dist/build/webpack/loaders/next-swc-loader.js.map +1 -1
- package/dist/build/webpack-build/impl.js +4 -1
- package/dist/build/webpack-build/impl.js.map +1 -1
- package/dist/build/webpack-config.js +2 -7
- package/dist/build/webpack-config.js.map +1 -1
- package/dist/cli/next-typegen.js +3 -0
- package/dist/cli/next-typegen.js.map +1 -1
- package/dist/client/app-bootstrap.js +1 -1
- package/dist/client/index.js +1 -1
- package/dist/compiled/next-server/pages-api-turbo.runtime.dev.js +1 -1
- package/dist/compiled/next-server/pages-api-turbo.runtime.dev.js.map +1 -1
- package/dist/compiled/next-server/pages-api-turbo.runtime.prod.js +1 -1
- package/dist/compiled/next-server/pages-api-turbo.runtime.prod.js.map +1 -1
- package/dist/compiled/next-server/pages-api.runtime.dev.js +1 -1
- package/dist/compiled/next-server/pages-api.runtime.dev.js.map +1 -1
- package/dist/compiled/next-server/pages-turbo.runtime.dev.js +1 -1
- package/dist/compiled/next-server/pages-turbo.runtime.dev.js.map +1 -1
- package/dist/compiled/next-server/pages-turbo.runtime.prod.js +1 -1
- package/dist/compiled/next-server/pages-turbo.runtime.prod.js.map +1 -1
- package/dist/compiled/next-server/pages.runtime.dev.js +1 -1
- package/dist/compiled/next-server/pages.runtime.dev.js.map +1 -1
- package/dist/esm/build/babel/loader/get-config.js +5 -0
- package/dist/esm/build/babel/loader/get-config.js.map +1 -1
- package/dist/esm/build/index.js +7 -4
- package/dist/esm/build/index.js.map +1 -1
- package/dist/esm/build/load-entrypoint.js +2 -3
- package/dist/esm/build/load-entrypoint.js.map +1 -1
- package/dist/esm/build/lockfile.js +5 -9
- package/dist/esm/build/lockfile.js.map +1 -1
- package/dist/esm/build/next-config-ts/transpile-config.js +13 -3
- package/dist/esm/build/next-config-ts/transpile-config.js.map +1 -1
- package/dist/esm/build/swc/index.js +52 -49
- package/dist/esm/build/swc/index.js.map +1 -1
- package/dist/esm/build/swc/install-bindings.js +20 -0
- package/dist/esm/build/swc/install-bindings.js.map +1 -0
- package/dist/esm/build/turbopack-build/impl.js +10 -5
- package/dist/esm/build/turbopack-build/impl.js.map +1 -1
- package/dist/esm/build/webpack/loaders/lightningcss-loader/src/loader.js +7 -2
- package/dist/esm/build/webpack/loaders/lightningcss-loader/src/loader.js.map +1 -1
- package/dist/esm/build/webpack/loaders/lightningcss-loader/src/minify.js +2 -2
- package/dist/esm/build/webpack/loaders/lightningcss-loader/src/minify.js.map +1 -1
- package/dist/esm/build/webpack/loaders/next-app-loader/index.js +6 -0
- package/dist/esm/build/webpack/loaders/next-app-loader/index.js.map +1 -1
- package/dist/esm/build/webpack/loaders/next-barrel-loader.js +5 -0
- package/dist/esm/build/webpack/loaders/next-barrel-loader.js.map +1 -1
- package/dist/esm/build/webpack/loaders/next-metadata-image-loader.js +5 -0
- package/dist/esm/build/webpack/loaders/next-metadata-image-loader.js.map +1 -1
- package/dist/esm/build/webpack/loaders/next-metadata-route-loader.js +5 -0
- package/dist/esm/build/webpack/loaders/next-metadata-route-loader.js.map +1 -1
- package/dist/esm/build/webpack/loaders/next-swc-loader.js +11 -7
- package/dist/esm/build/webpack/loaders/next-swc-loader.js.map +1 -1
- package/dist/esm/build/webpack-build/impl.js +4 -1
- package/dist/esm/build/webpack-build/impl.js.map +1 -1
- package/dist/esm/build/webpack-config.js +2 -7
- package/dist/esm/build/webpack-config.js.map +1 -1
- package/dist/esm/client/app-bootstrap.js +1 -1
- package/dist/esm/client/index.js +1 -1
- package/dist/esm/server/config.js +2 -2
- package/dist/esm/server/config.js.map +1 -1
- package/dist/esm/server/dev/hot-reloader-turbopack.js +3 -4
- package/dist/esm/server/dev/hot-reloader-turbopack.js.map +1 -1
- package/dist/esm/server/dev/hot-reloader-webpack.js +1 -1
- package/dist/esm/server/lib/app-info-log.js +1 -1
- package/dist/esm/server/lib/router-utils/setup-dev-bundler.js +3 -0
- package/dist/esm/server/lib/router-utils/setup-dev-bundler.js.map +1 -1
- package/dist/esm/server/lib/start-server.js +1 -1
- package/dist/esm/shared/lib/errors/canary-only-config-error.js +1 -1
- package/dist/server/config.js +2 -2
- package/dist/server/config.js.map +1 -1
- package/dist/server/dev/hot-reloader-turbopack.js +2 -3
- package/dist/server/dev/hot-reloader-turbopack.js.map +1 -1
- package/dist/server/dev/hot-reloader-webpack.js +1 -1
- package/dist/server/lib/app-info-log.js +1 -1
- package/dist/server/lib/router-utils/setup-dev-bundler.js +3 -0
- package/dist/server/lib/router-utils/setup-dev-bundler.js.map +1 -1
- package/dist/server/lib/start-server.js +1 -1
- package/dist/shared/lib/errors/canary-only-config-error.js +1 -1
- package/dist/telemetry/anonymous-meta.js +1 -1
- package/dist/telemetry/events/session-stopped.js +2 -2
- package/dist/telemetry/events/version.js +2 -2
- package/package.json +15 -15
|
@@ -6,6 +6,7 @@ import loadFullConfig from 'next/dist/compiled/babel/core-lib-config';
|
|
|
6
6
|
import { consumeIterator } from './util';
|
|
7
7
|
import * as Log from '../../output/log';
|
|
8
8
|
import { isReactCompilerRequired } from '../../swc';
|
|
9
|
+
import { installBindings } from '../../swc/install-bindings';
|
|
9
10
|
const nextDistPath = /(next[\\/]dist[\\/]shared[\\/]lib)|(next[\\/]dist[\\/]client)|(next[\\/]dist[\\/]pages)/;
|
|
10
11
|
function shouldSkipBabel(transformMode, configFilePath, hasReactCompiler) {
|
|
11
12
|
return transformMode === 'standalone' && configFilePath == null && !hasReactCompiler;
|
|
@@ -346,6 +347,10 @@ const configFiles = new Set();
|
|
|
346
347
|
};
|
|
347
348
|
}
|
|
348
349
|
export default async function getConfig(ctx, { source, target, loaderOptions, filename, inputSourceMap }) {
|
|
350
|
+
// Install bindings early so they are definitely available to the loader.
|
|
351
|
+
// When run by webpack in next this is already done with correct configuration so this is a no-op.
|
|
352
|
+
// In turbopack loaders are run in a subprocess so it may or may not be done.
|
|
353
|
+
await installBindings();
|
|
349
354
|
const cacheCharacteristics = await getCacheCharacteristics(loaderOptions, source, filename);
|
|
350
355
|
if (loaderOptions.configFile) {
|
|
351
356
|
// 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":["readFileSync","inspect","JSON5","createConfigItem","loadOptions","loadFullConfig","consumeIterator","Log","isReactCompilerRequired","nextDistPath","shouldSkipBabel","transformMode","configFilePath","hasReactCompiler","fileExtensionRegex","getCacheCharacteristics","loaderOptions","source","filename","isStandalone","isServer","pagesDir","Error","isPageFile","startsWith","isNextDist","test","hasModuleExports","indexOf","fileExt","exec","reactCompilerPlugins","reactCompilerExclude","configFile","length","getPlugins","cacheCharacteristics","development","hasReactRefresh","applyCommonJsItem","require","type","reactRefreshItem","skipEnvCheck","pageConfigItem","disallowExportAllItem","transformDefineItem","resolve","nextSsgItem","commonJsItem","nextFontUnsupported","filter","Boolean","isJsonFile","isJsFile","getCustomBabelConfig","babelConfigRaw","parse","babelConfigWarned","checkCustomBabelConfigDeprecation","config","Object","keys","plugins","presets","otherOptions","isPresetReadyToDeprecate","pluginReasons","unsupportedPlugins","Array","isArray","plugin","pluginName","push","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","getCacheKey","flags","configCache","Map","configFiles","Set","updateBabelConfigWithFileDetails","cachedConfig","cwd","root","getConfig","addDependency","cacheKey","get","has","add","info","freshConfig","set"],"mappings":"AAAA,SAASA,YAAY,QAAQ,UAAS;AACtC,SAASC,OAAO,QAAQ,YAAW;AACnC,OAAOC,WAAW,2BAA0B;AAE5C,SAASC,gBAAgB,EAAEC,WAAW,QAAQ,gCAA+B;AAC7E,OAAOC,oBAAoB,2CAA0C;AAOrE,SACEC,eAAe,QAGV,SAAQ;AACf,YAAYC,SAAS,mBAAkB;AACvC,SAASC,uBAAuB,QAAQ,YAAW;AAenD,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,QA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cAAc,EAOf;IAED,MAAMjD,uBAAuB,MAAMrB,wBACjCC,eACAC,QACAC;IAGF,IAAIF,cAAciB,UAAU,EAAE;QAC5B,qFAAqF;QACrF4C,IAAIyC,aAAa,CAACtG,cAAciB,UAAU;IAC5C;IAEA,MAAMsF,WAAWZ,YAAYvE;IAC7B,MAAM8E,eAAeL,YAAYW,GAAG,CAACD;IACrC,IAAIL,iBAAiB5B,WAAW;QAC9B,OAAO2B,iCACLC,cACAlG,eACAE,UACAmE;IAEJ;IAEA,IAAIrE,cAAciB,UAAU,IAAI,CAAC8E,YAAYU,GAAG,CAACzG,cAAciB,UAAU,GAAG;QAC1E8E,YAAYW,GAAG,CAAC1G,cAAciB,UAAU;QACxC1B,IAAIoH,IAAI,CACN,CAAC,wCAAwC,EAAE3G,cAAciB,UAAU,EAAE;IAEzE;IAEA,MAAM2F,cAAc,MAAMhD,eACxBC,KACAzC,sBACApB,eACA8D;IAGF+B,YAAYgB,GAAG,CAACN,UAAUK;IAE1B,OAAOX,iCACLW,aACA5G,eACAE,UACAmE;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":["readFileSync","inspect","JSON5","createConfigItem","loadOptions","loadFullConfig","consumeIterator","Log","isReactCompilerRequired","installBindings","nextDistPath","shouldSkipBabel","transformMode","configFilePath","hasReactCompiler","fileExtensionRegex","getCacheCharacteristics","loaderOptions","source","filename","isStandalone","isServer","pagesDir","Error","isPageFile","startsWith","isNextDist","test","hasModuleExports","indexOf","fileExt","exec","reactCompilerPlugins","reactCompilerExclude","configFile","length","getPlugins","cacheCharacteristics","development","hasReactRefresh","applyCommonJsItem","require","type","reactRefreshItem","skipEnvCheck","pageConfigItem","disallowExportAllItem","transformDefineItem","resolve","nextSsgItem","commonJsItem","nextFontUnsupported","filter","Boolean","isJsonFile","isJsFile","getCustomBabelConfig","babelConfigRaw","parse","babelConfigWarned","checkCustomBabelConfigDeprecation","config","Object","keys","plugins","presets","otherOptions","isPresetReadyToDeprecate","pluginReasons","unsupportedPlugins","Array","isArray","plugin","pluginName","push","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","getCacheKey","flags","configCache","Map","configFiles","Set","updateBabelConfigWithFileDetails","cachedConfig","cwd","root","getConfig","addDependency","cacheKey","get","has","add","info","freshConfig","set"],"mappings":"AAAA,SAASA,YAAY,QAAQ,UAAS;AACtC,SAASC,OAAO,QAAQ,YAAW;AACnC,OAAOC,WAAW,2BAA0B;AAE5C,SAASC,gBAAgB,EAAEC,WAAW,QAAQ,gCAA+B;AAC7E,OAAOC,oBAAoB,2CAA0C;AAOrE,SACEC,eAAe,QAGV,SAAQ;AACf,YAAYC,SAAS,mBAAkB;AACvC,SAASC,uBAAuB,QAAQ,YAAW;AACnD,SAASC,eAAe,QAAQ,6BAA4B;AAe5D,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,EAAEtB,QAAQgB,gBAAgB,GADpE,qBAAA;uBAAA;4BAAA;8BAAA;YAEN;IACJ;IAEA,MAAMO,aAAaF,YAAY,QAAQH,SAASM,UAAU,CAACH;IAC3D,MAAMI,aAAahB,aAAaiB,IAAI,CAACR;IACrC,MAAMS,mBAAmBV,OAAOW,OAAO,CAAC,sBAAsB,CAAC;IAC/D,MAAMC,UAAUf,EAAAA,2BAAAA,mBAAmBgB,IAAI,CAACZ,8BAAxBJ,wBAAmC,CAAC,EAAE,KAAI;IAE1D,IAA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,GAAG;QAC1E8E,YAAYW,GAAG,CAAC1G,cAAciB,UAAU;QACxC3B,IAAIqH,IAAI,CACN,CAAC,wCAAwC,EAAE3G,cAAciB,UAAU,EAAE;IAEzE;IAEA,MAAM2F,cAAc,MAAMhD,eACxBC,KACAzC,sBACApB,eACA8D;IAGF+B,YAAYgB,GAAG,CAACN,UAAUK;IAE1B,OAAOX,iCACLW,aACA5G,eACAE,UACAmE;AAEJ","ignoreList":[0]}
|
package/dist/esm/build/index.js
CHANGED
|
@@ -44,6 +44,7 @@ import isError from '../lib/is-error';
|
|
|
44
44
|
import { isEdgeRuntime } from '../lib/is-edge-runtime';
|
|
45
45
|
import { recursiveCopy } from '../lib/recursive-copy';
|
|
46
46
|
import { lockfilePatchPromise, teardownTraceSubscriber } from './swc';
|
|
47
|
+
import { installBindings } from './swc/install-bindings';
|
|
47
48
|
import { getNamedRouteRegex } from '../shared/lib/router/utils/route-regex';
|
|
48
49
|
import { getFilesInDir } from '../lib/get-files-in-dir';
|
|
49
50
|
import { eventSwcPlugins } from '../telemetry/events/swc-plugins';
|
|
@@ -308,7 +309,7 @@ export default async function build(dir, experimentalAnalyze = false, reactProdu
|
|
|
308
309
|
try {
|
|
309
310
|
const nextBuildSpan = trace('next-build', undefined, {
|
|
310
311
|
buildMode: experimentalBuildMode,
|
|
311
|
-
version: "16.0.2-canary.
|
|
312
|
+
version: "16.0.2-canary.12"
|
|
312
313
|
});
|
|
313
314
|
NextBuildContext.nextBuildSpan = nextBuildSpan;
|
|
314
315
|
NextBuildContext.dir = dir;
|
|
@@ -317,7 +318,7 @@ export default async function build(dir, experimentalAnalyze = false, reactProdu
|
|
|
317
318
|
NextBuildContext.noMangling = noMangling;
|
|
318
319
|
NextBuildContext.debugPrerender = debugPrerender;
|
|
319
320
|
await nextBuildSpan.traceAsyncFn(async ()=>{
|
|
320
|
-
var _mappedPages_404, _mappedPages__error;
|
|
321
|
+
var _config_experimental, _mappedPages_404, _mappedPages__error;
|
|
321
322
|
// attempt to load global env values so they are available in next.config.js
|
|
322
323
|
const { loadedEnvFiles } = nextBuildSpan.traceChild('load-dotenv').traceFn(()=>loadEnvConfig(dir, false, Log));
|
|
323
324
|
NextBuildContext.loadedEnvFiles = loadedEnvFiles;
|
|
@@ -332,6 +333,8 @@ export default async function build(dir, experimentalAnalyze = false, reactProdu
|
|
|
332
333
|
// Reading the config can modify environment variables that influence the bundler selection.
|
|
333
334
|
bundler = finalizeBundlerFromConfig(bundler);
|
|
334
335
|
nextBuildSpan.setAttribute('bundler', getBundlerForTelemetry(bundler));
|
|
336
|
+
// Install the native bindings early so we can have synchronous access later.
|
|
337
|
+
await installBindings((_config_experimental = config.experimental) == null ? void 0 : _config_experimental.useWasmBinary);
|
|
335
338
|
process.env.NEXT_DEPLOYMENT_ID = config.deploymentId || '';
|
|
336
339
|
NextBuildContext.config = config;
|
|
337
340
|
let configOutDir = 'out';
|
|
@@ -834,7 +837,7 @@ export default async function build(dir, experimentalAnalyze = false, reactProdu
|
|
|
834
837
|
// Files outside of the distDir can be "type": "module"
|
|
835
838
|
await writeFileUtf8(path.join(distDir, 'package.json'), '{"type": "commonjs"}');
|
|
836
839
|
// These are written to distDir, so they need to come after creating and cleaning distDr.
|
|
837
|
-
await recordFrameworkVersion("16.0.2-canary.
|
|
840
|
+
await recordFrameworkVersion("16.0.2-canary.12");
|
|
838
841
|
await updateBuildDiagnostics({
|
|
839
842
|
buildStage: 'start'
|
|
840
843
|
});
|
|
@@ -2513,7 +2516,7 @@ export default async function build(dir, experimentalAnalyze = false, reactProdu
|
|
|
2513
2516
|
configOutDir: path.join(dir, configOutDir),
|
|
2514
2517
|
staticPages,
|
|
2515
2518
|
serverPropsPages,
|
|
2516
|
-
nextVersion: "16.0.2-canary.
|
|
2519
|
+
nextVersion: "16.0.2-canary.12",
|
|
2517
2520
|
tracingRoot: outputFileTracingRoot,
|
|
2518
2521
|
hasNodeMiddleware,
|
|
2519
2522
|
hasInstrumentationHook,
|