{"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\n}\n\nexport type BabelPlugin = unknown\nexport type BabelPluginPassList = ReadonlyArray\nexport type BabelPluginPasses = ReadonlyArray\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 {\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 | 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 {\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 = new Map()\nconst configFiles: Set = 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 {\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,mBAAmB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