next 15.2.1-canary.0 → 15.2.1-canary.2

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.

Potentially problematic release.


This version of next might be problematic. Click here for more details.

Files changed (114) hide show
  1. package/dist/bin/next +1 -1
  2. package/dist/build/handle-externals.d.ts +2 -3
  3. package/dist/build/handle-externals.js +4 -4
  4. package/dist/build/handle-externals.js.map +1 -1
  5. package/dist/build/index.js +2 -2
  6. package/dist/build/swc/index.js +1 -1
  7. package/dist/build/swc/options.d.ts +1 -0
  8. package/dist/build/swc/options.js +1 -0
  9. package/dist/build/swc/options.js.map +1 -1
  10. package/dist/build/webpack/plugins/build-manifest-plugin.js +3 -5
  11. package/dist/build/webpack/plugins/build-manifest-plugin.js.map +1 -1
  12. package/dist/build/webpack/plugins/css-minimizer-plugin.js +2 -2
  13. package/dist/build/webpack/plugins/css-minimizer-plugin.js.map +1 -1
  14. package/dist/build/webpack/plugins/minify-webpack-plugin/src/index.js +2 -2
  15. package/dist/build/webpack/plugins/minify-webpack-plugin/src/index.js.map +1 -1
  16. package/dist/build/webpack/plugins/next-trace-entrypoints-plugin.d.ts +1 -3
  17. package/dist/build/webpack/plugins/next-trace-entrypoints-plugin.js +5 -6
  18. package/dist/build/webpack/plugins/next-trace-entrypoints-plugin.js.map +1 -1
  19. package/dist/build/webpack/utils.d.ts +3 -1
  20. package/dist/build/webpack/utils.js +10 -0
  21. package/dist/build/webpack/utils.js.map +1 -1
  22. package/dist/build/webpack-config.js +2 -4
  23. package/dist/build/webpack-config.js.map +1 -1
  24. package/dist/client/app-bootstrap.js +1 -1
  25. package/dist/client/components/react-dev-overlay/server/shared.d.ts +0 -3
  26. package/dist/client/components/react-dev-overlay/server/shared.js.map +1 -1
  27. package/dist/client/components/react-dev-overlay/ui/components/errors/dialog/dialog.d.ts +1 -1
  28. package/dist/client/components/react-dev-overlay/ui/components/errors/dialog/dialog.js +1 -1
  29. package/dist/client/components/react-dev-overlay/ui/components/errors/dialog/dialog.js.map +1 -1
  30. package/dist/client/components/react-dev-overlay/ui/components/errors/error-overlay-bottom-stack/index.d.ts +1 -1
  31. package/dist/client/components/react-dev-overlay/ui/components/errors/error-overlay-bottom-stack/index.js +1 -1
  32. package/dist/client/components/react-dev-overlay/ui/components/errors/error-overlay-bottom-stack/index.js.map +1 -1
  33. package/dist/client/components/react-dev-overlay/ui/components/errors/error-overlay-layout/error-overlay-layout.d.ts +1 -1
  34. package/dist/client/components/react-dev-overlay/ui/dev-overlay.js +2 -0
  35. package/dist/client/components/react-dev-overlay/ui/dev-overlay.js.map +1 -1
  36. package/dist/client/components/react-dev-overlay/ui/storybook/with-shadow-portal.js +2 -0
  37. package/dist/client/components/react-dev-overlay/ui/storybook/with-shadow-portal.js.map +1 -1
  38. package/dist/client/components/react-dev-overlay/ui/styles/base.js +2 -14
  39. package/dist/client/components/react-dev-overlay/ui/styles/base.js.map +1 -1
  40. package/dist/client/components/react-dev-overlay/ui/styles/colors.js +2 -22
  41. package/dist/client/components/react-dev-overlay/ui/styles/colors.js.map +1 -1
  42. package/dist/client/components/react-dev-overlay/ui/styles/dark-theme.d.ts +1 -0
  43. package/dist/client/components/react-dev-overlay/ui/styles/dark-theme.js +41 -0
  44. package/dist/client/components/react-dev-overlay/ui/styles/dark-theme.js.map +1 -0
  45. package/dist/client/components/react-dev-overlay/utils/stack-frame.d.ts +11 -3
  46. package/dist/client/components/react-dev-overlay/utils/stack-frame.js +2 -5
  47. package/dist/client/components/react-dev-overlay/utils/stack-frame.js.map +1 -1
  48. package/dist/client/components/router-reducer/reducers/navigate-reducer.js +29 -9
  49. package/dist/client/components/router-reducer/reducers/navigate-reducer.js.map +1 -1
  50. package/dist/client/components/segment-cache/navigation.d.ts +5 -1
  51. package/dist/client/components/segment-cache/navigation.js +28 -19
  52. package/dist/client/components/segment-cache/navigation.js.map +1 -1
  53. package/dist/client/index.js +1 -1
  54. package/dist/compiled/next-server/app-page-experimental.runtime.dev.js +3 -3
  55. package/dist/compiled/next-server/app-page-experimental.runtime.dev.js.map +1 -1
  56. package/dist/compiled/next-server/app-page.runtime.dev.js +3 -3
  57. package/dist/compiled/next-server/app-page.runtime.dev.js.map +1 -1
  58. package/dist/esm/build/handle-externals.js +4 -4
  59. package/dist/esm/build/handle-externals.js.map +1 -1
  60. package/dist/esm/build/index.js +2 -2
  61. package/dist/esm/build/swc/index.js +1 -1
  62. package/dist/esm/build/swc/options.js +1 -0
  63. package/dist/esm/build/swc/options.js.map +1 -1
  64. package/dist/esm/build/webpack/plugins/build-manifest-plugin.js +3 -5
  65. package/dist/esm/build/webpack/plugins/build-manifest-plugin.js.map +1 -1
  66. package/dist/esm/build/webpack/plugins/css-minimizer-plugin.js +2 -2
  67. package/dist/esm/build/webpack/plugins/css-minimizer-plugin.js.map +1 -1
  68. package/dist/esm/build/webpack/plugins/minify-webpack-plugin/src/index.js +2 -2
  69. package/dist/esm/build/webpack/plugins/minify-webpack-plugin/src/index.js.map +1 -1
  70. package/dist/esm/build/webpack/plugins/next-trace-entrypoints-plugin.js +5 -6
  71. package/dist/esm/build/webpack/plugins/next-trace-entrypoints-plugin.js.map +1 -1
  72. package/dist/esm/build/webpack/utils.js +6 -0
  73. package/dist/esm/build/webpack/utils.js.map +1 -1
  74. package/dist/esm/build/webpack-config.js +2 -4
  75. package/dist/esm/build/webpack-config.js.map +1 -1
  76. package/dist/esm/client/app-bootstrap.js +1 -1
  77. package/dist/esm/client/components/react-dev-overlay/server/shared.js.map +1 -1
  78. package/dist/esm/client/components/react-dev-overlay/ui/components/errors/dialog/dialog.js +1 -1
  79. package/dist/esm/client/components/react-dev-overlay/ui/components/errors/dialog/dialog.js.map +1 -1
  80. package/dist/esm/client/components/react-dev-overlay/ui/components/errors/error-overlay-bottom-stack/index.js +1 -1
  81. package/dist/esm/client/components/react-dev-overlay/ui/components/errors/error-overlay-bottom-stack/index.js.map +1 -1
  82. package/dist/esm/client/components/react-dev-overlay/ui/dev-overlay.js +2 -0
  83. package/dist/esm/client/components/react-dev-overlay/ui/dev-overlay.js.map +1 -1
  84. package/dist/esm/client/components/react-dev-overlay/ui/storybook/with-shadow-portal.js +2 -0
  85. package/dist/esm/client/components/react-dev-overlay/ui/storybook/with-shadow-portal.js.map +1 -1
  86. package/dist/esm/client/components/react-dev-overlay/ui/styles/base.js +2 -14
  87. package/dist/esm/client/components/react-dev-overlay/ui/styles/base.js.map +1 -1
  88. package/dist/esm/client/components/react-dev-overlay/ui/styles/colors.js +2 -23
  89. package/dist/esm/client/components/react-dev-overlay/ui/styles/colors.js.map +1 -1
  90. package/dist/esm/client/components/react-dev-overlay/ui/styles/dark-theme.js +25 -0
  91. package/dist/esm/client/components/react-dev-overlay/ui/styles/dark-theme.js.map +1 -0
  92. package/dist/esm/client/components/react-dev-overlay/utils/stack-frame.js +2 -5
  93. package/dist/esm/client/components/react-dev-overlay/utils/stack-frame.js.map +1 -1
  94. package/dist/esm/client/components/router-reducer/reducers/navigate-reducer.js +29 -9
  95. package/dist/esm/client/components/router-reducer/reducers/navigate-reducer.js.map +1 -1
  96. package/dist/esm/client/components/segment-cache/navigation.js +28 -19
  97. package/dist/esm/client/components/segment-cache/navigation.js.map +1 -1
  98. package/dist/esm/client/index.js +1 -1
  99. package/dist/esm/lib/server-external-packages.json +4 -0
  100. package/dist/esm/server/config.js +1 -1
  101. package/dist/esm/server/dev/hot-reloader-turbopack.js +1 -1
  102. package/dist/esm/server/dev/hot-reloader-webpack.js +1 -1
  103. package/dist/esm/server/lib/app-info-log.js +1 -1
  104. package/dist/esm/server/lib/start-server.js +1 -1
  105. package/dist/lib/server-external-packages.json +4 -0
  106. package/dist/server/config.js +1 -1
  107. package/dist/server/dev/hot-reloader-turbopack.js +1 -1
  108. package/dist/server/dev/hot-reloader-webpack.js +1 -1
  109. package/dist/server/lib/app-info-log.js +1 -1
  110. package/dist/server/lib/start-server.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
@@ -79,7 +79,7 @@ const program = new NextRootCommand();
79
79
  program.name('next').description('The Next.js CLI allows you to develop, build, start your application, and more.').configureHelp({
80
80
  formatHelp: (cmd, helper)=>(0, _formatclihelpoutput.formatCliHelpOutput)(cmd, helper),
81
81
  subcommandTerm: (cmd)=>`${cmd.name()} ${cmd.usage()}`
82
- }).helpCommand(false).helpOption('-h, --help', 'Displays this message.').version(`Next.js v${"15.2.1-canary.0"}`, '-v, --version', 'Outputs the Next.js version.');
82
+ }).helpCommand(false).helpOption('-h, --help', 'Displays this message.').version(`Next.js v${"15.2.1-canary.2"}`, '-v, --version', 'Outputs the Next.js version.');
83
83
  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('-d, --debug', 'Enables a more verbose build output.').option('--no-lint', 'Disables linting.').option('--no-mangling', 'Disables mangling.').option('--profile', 'Enables production profiling for React.').option('--experimental-app-only', 'Builds only App Router routes.').addOption(new _commander.Option('--experimental-turbo').hideHelp()).addOption(new _commander.Option('--experimental-build-mode [mode]', 'Uses an experimental build mode.').choices([
84
84
  'compile',
85
85
  'generate'
@@ -2,7 +2,7 @@ import type { WebpackLayerName } from '../lib/constants';
2
2
  import type { NextConfigComplete } from '../server/config-shared';
3
3
  import type { ResolveOptions } from 'webpack';
4
4
  export declare function isResourceInPackages(resource: string, packageNames?: string[], packageDirMapping?: Map<string, string>): boolean;
5
- export declare function resolveExternal(dir: string, esmExternalsConfig: NextConfigComplete['experimental']['esmExternals'], context: string, request: string, isEsmRequested: boolean, _optOutBundlingPackages: string[], getResolve: (options: ResolveOptions) => (resolveContext: string, resolveRequest: string) => Promise<[string | null, boolean]>, isLocalCallback?: (res: string) => any, baseResolveCheck?: boolean, esmResolveOptions?: any, nodeResolveOptions?: any, baseEsmResolveOptions?: any, baseResolveOptions?: any): Promise<{
5
+ export declare function resolveExternal(dir: string, esmExternalsConfig: NextConfigComplete['experimental']['esmExternals'], context: string, request: string, isEsmRequested: boolean, getResolve: (options: ResolveOptions) => (resolveContext: string, resolveRequest: string) => Promise<[string | null, boolean]>, isLocalCallback?: (res: string) => any, baseResolveCheck?: boolean, esmResolveOptions?: any, nodeResolveOptions?: any, baseEsmResolveOptions?: any, baseResolveOptions?: any): Promise<{
6
6
  localRes: any;
7
7
  res?: undefined;
8
8
  isEsm?: undefined;
@@ -11,9 +11,8 @@ export declare function resolveExternal(dir: string, esmExternalsConfig: NextCon
11
11
  isEsm: boolean;
12
12
  localRes?: undefined;
13
13
  }>;
14
- export declare function makeExternalHandler({ config, optOutBundlingPackages, optOutBundlingPackageRegex, transpiledPackages, dir, }: {
14
+ export declare function makeExternalHandler({ config, optOutBundlingPackageRegex, transpiledPackages, dir, }: {
15
15
  config: NextConfigComplete;
16
- optOutBundlingPackages: string[];
17
16
  optOutBundlingPackageRegex: RegExp;
18
17
  transpiledPackages: string[];
19
18
  dir: string;
@@ -46,7 +46,7 @@ function isResourceInPackages(resource, packageNames, packageDirMapping) {
46
46
  if (!packageNames) return false;
47
47
  return packageNames.some((p)=>packageDirMapping && packageDirMapping.has(p) ? resource.startsWith(packageDirMapping.get(p) + _path.default.sep) : resource.includes(_path.default.sep + _path.default.join('node_modules', p.replace(/\//g, _path.default.sep)) + _path.default.sep));
48
48
  }
49
- async function resolveExternal(dir, esmExternalsConfig, context, request, isEsmRequested, _optOutBundlingPackages, getResolve, isLocalCallback, baseResolveCheck = true, esmResolveOptions = _webpackconfig.NODE_ESM_RESOLVE_OPTIONS, nodeResolveOptions = _webpackconfig.NODE_RESOLVE_OPTIONS, baseEsmResolveOptions = _webpackconfig.NODE_BASE_ESM_RESOLVE_OPTIONS, baseResolveOptions = _webpackconfig.NODE_BASE_RESOLVE_OPTIONS) {
49
+ async function resolveExternal(dir, esmExternalsConfig, context, request, isEsmRequested, getResolve, isLocalCallback, baseResolveCheck = true, esmResolveOptions = _webpackconfig.NODE_ESM_RESOLVE_OPTIONS, nodeResolveOptions = _webpackconfig.NODE_RESOLVE_OPTIONS, baseEsmResolveOptions = _webpackconfig.NODE_BASE_ESM_RESOLVE_OPTIONS, baseResolveOptions = _webpackconfig.NODE_BASE_RESOLVE_OPTIONS) {
50
50
  const esmExternals = !!esmExternalsConfig;
51
51
  const looseEsmExternals = esmExternalsConfig === 'loose';
52
52
  let res = null;
@@ -113,7 +113,7 @@ async function resolveExternal(dir, esmExternalsConfig, context, request, isEsmR
113
113
  isEsm
114
114
  };
115
115
  }
116
- function makeExternalHandler({ config, optOutBundlingPackages, optOutBundlingPackageRegex, transpiledPackages, dir }) {
116
+ function makeExternalHandler({ config, optOutBundlingPackageRegex, transpiledPackages, dir }) {
117
117
  var _config_experimental;
118
118
  let resolvedExternalPackageDirs;
119
119
  const looseEsmExternals = ((_config_experimental = config.experimental) == null ? void 0 : _config_experimental.esmExternals) === 'loose';
@@ -187,7 +187,7 @@ function makeExternalHandler({ config, optOutBundlingPackages, optOutBundlingPac
187
187
  return resolveNextExternal(request);
188
188
  }
189
189
  // TODO-APP: Let's avoid this resolve call as much as possible, and eventually get rid of it.
190
- const resolveResult = await resolveExternal(dir, config.experimental.esmExternals, context, request, isEsmRequested, optOutBundlingPackages, getResolve, isLocal ? resolveNextExternal : undefined);
190
+ const resolveResult = await resolveExternal(dir, config.experimental.esmExternals, context, request, isEsmRequested, getResolve, isLocal ? resolveNextExternal : undefined);
191
191
  if ('localRes' in resolveResult) {
192
192
  return resolveResult.localRes;
193
193
  }
@@ -233,7 +233,7 @@ function makeExternalHandler({ config, optOutBundlingPackages, optOutBundlingPac
233
233
  resolvedExternalPackageDirs = new Map();
234
234
  // We need to resolve all the external package dirs initially.
235
235
  for (const pkg of transpiledPackages){
236
- const pkgRes = await resolveExternal(dir, config.experimental.esmExternals, context, pkg + '/package.json', isEsmRequested, optOutBundlingPackages, getResolve, isLocal ? resolveNextExternal : undefined);
236
+ const pkgRes = await resolveExternal(dir, config.experimental.esmExternals, context, pkg + '/package.json', isEsmRequested, getResolve, isLocal ? resolveNextExternal : undefined);
237
237
  if (pkgRes.res) {
238
238
  resolvedExternalPackageDirs.set(pkg, _path.default.dirname(pkgRes.res));
239
239
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/build/handle-externals.ts"],"sourcesContent":["import type { WebpackLayerName } from '../lib/constants'\nimport type { NextConfigComplete } from '../server/config-shared'\nimport type { ResolveOptions } from 'webpack'\nimport { defaultOverrides } from '../server/require-hook'\nimport { BARREL_OPTIMIZATION_PREFIX } from '../shared/lib/constants'\nimport path from '../shared/lib/isomorphic/path'\nimport {\n NODE_BASE_ESM_RESOLVE_OPTIONS,\n NODE_BASE_RESOLVE_OPTIONS,\n NODE_ESM_RESOLVE_OPTIONS,\n NODE_RESOLVE_OPTIONS,\n} from './webpack-config'\nimport { isWebpackBundledLayer, isWebpackServerOnlyLayer } from './utils'\nimport { normalizePathSep } from '../shared/lib/page-path/normalize-path-sep'\nconst reactPackagesRegex = /^(react|react-dom|react-server-dom-webpack)($|\\/)/\n\nconst pathSeparators = '[/\\\\\\\\]'\nconst optionalEsmPart = `((${pathSeparators}esm)?${pathSeparators})`\nconst externalFileEnd = '(\\\\.external(\\\\.js)?)$'\nconst nextDist = `next${pathSeparators}dist`\n\nconst externalPattern = new RegExp(\n `${nextDist}${optionalEsmPart}.*${externalFileEnd}`\n)\n\nconst nodeModulesRegex = /node_modules[/\\\\].*\\.[mc]?js$/\n\nexport function isResourceInPackages(\n resource: string,\n packageNames?: string[],\n packageDirMapping?: Map<string, string>\n): boolean {\n if (!packageNames) return false\n return packageNames.some((p: string) =>\n packageDirMapping && packageDirMapping.has(p)\n ? resource.startsWith(packageDirMapping.get(p)! + path.sep)\n : resource.includes(\n path.sep +\n path.join('node_modules', p.replace(/\\//g, path.sep)) +\n path.sep\n )\n )\n}\n\nexport async function resolveExternal(\n dir: string,\n esmExternalsConfig: NextConfigComplete['experimental']['esmExternals'],\n context: string,\n request: string,\n isEsmRequested: boolean,\n _optOutBundlingPackages: string[],\n getResolve: (\n options: ResolveOptions\n ) => (\n resolveContext: string,\n resolveRequest: string\n ) => Promise<[string | null, boolean]>,\n isLocalCallback?: (res: string) => any,\n baseResolveCheck = true,\n esmResolveOptions: any = NODE_ESM_RESOLVE_OPTIONS,\n nodeResolveOptions: any = NODE_RESOLVE_OPTIONS,\n baseEsmResolveOptions: any = NODE_BASE_ESM_RESOLVE_OPTIONS,\n baseResolveOptions: any = NODE_BASE_RESOLVE_OPTIONS\n) {\n const esmExternals = !!esmExternalsConfig\n const looseEsmExternals = esmExternalsConfig === 'loose'\n\n let res: string | null = null\n let isEsm: boolean = false\n\n const preferEsmOptions =\n esmExternals && isEsmRequested ? [true, false] : [false]\n\n for (const preferEsm of preferEsmOptions) {\n const resolveOptions = preferEsm ? esmResolveOptions : nodeResolveOptions\n\n const resolve = getResolve(resolveOptions)\n\n // Resolve the import with the webpack provided context, this\n // ensures we're resolving the correct version when multiple\n // exist.\n try {\n ;[res, isEsm] = await resolve(context, request)\n } catch (err) {\n res = null\n }\n\n if (!res) {\n continue\n }\n\n // ESM externals can only be imported (and not required).\n // Make an exception in loose mode.\n if (!isEsmRequested && isEsm && !looseEsmExternals) {\n continue\n }\n\n if (isLocalCallback) {\n return { localRes: isLocalCallback(res) }\n }\n\n // Bundled Node.js code is relocated without its node_modules tree.\n // This means we need to make sure its request resolves to the same\n // package that'll be available at runtime. If it's not identical,\n // we need to bundle the code (even if it _should_ be external).\n if (baseResolveCheck) {\n let baseRes: string | null\n let baseIsEsm: boolean\n try {\n const baseResolve = getResolve(\n isEsm ? baseEsmResolveOptions : baseResolveOptions\n )\n ;[baseRes, baseIsEsm] = await baseResolve(dir, request)\n } catch (err) {\n baseRes = null\n baseIsEsm = false\n }\n\n // Same as above: if the package, when required from the root,\n // would be different from what the real resolution would use, we\n // cannot externalize it.\n // if request is pointing to a symlink it could point to the same file,\n // the resolver will resolve symlinks so this is handled\n if (baseRes !== res || isEsm !== baseIsEsm) {\n res = null\n continue\n }\n }\n break\n }\n return { res, isEsm }\n}\n\nexport function makeExternalHandler({\n config,\n optOutBundlingPackages,\n optOutBundlingPackageRegex,\n transpiledPackages,\n dir,\n}: {\n config: NextConfigComplete\n optOutBundlingPackages: string[]\n optOutBundlingPackageRegex: RegExp\n transpiledPackages: string[]\n dir: string\n}) {\n let resolvedExternalPackageDirs: Map<string, string>\n const looseEsmExternals = config.experimental?.esmExternals === 'loose'\n\n return async function handleExternals(\n context: string,\n request: string,\n dependencyType: string,\n layer: WebpackLayerName | null,\n getResolve: (\n options: any\n ) => (\n resolveContext: string,\n resolveRequest: string\n ) => Promise<[string | null, boolean]>\n ) {\n // We need to externalize internal requests for files intended to\n // not be bundled.\n const isLocal: boolean =\n request.startsWith('.') ||\n // Always check for unix-style path, as webpack sometimes\n // normalizes as posix.\n path.posix.isAbsolute(request) ||\n // When on Windows, we also want to check for Windows-specific\n // absolute paths.\n (process.platform === 'win32' && path.win32.isAbsolute(request))\n\n // make sure import \"next\" shows a warning when imported\n // in pages/components\n if (request === 'next') {\n return `commonjs next/dist/lib/import-next-warning`\n }\n\n const isAppLayer = isWebpackBundledLayer(layer)\n\n // Relative requires don't need custom resolution, because they\n // are relative to requests we've already resolved here.\n // Absolute requires (require('/foo')) are extremely uncommon, but\n // also have no need for customization as they're already resolved.\n if (!isLocal) {\n if (/^next$/.test(request)) {\n return `commonjs ${request}`\n }\n\n if (reactPackagesRegex.test(request) && !isAppLayer) {\n return `commonjs ${request}`\n }\n\n const notExternalModules =\n /^(?:private-next-pages\\/|next\\/(?:dist\\/pages\\/|(?:app|document|link|form|image|legacy\\/image|constants|dynamic|script|navigation|headers|router)$)|string-hash|private-next-rsc-action-validate|private-next-rsc-action-client-wrapper|private-next-rsc-server-reference|private-next-rsc-cache-wrapper$)/\n if (notExternalModules.test(request)) {\n return\n }\n }\n\n // @swc/helpers should not be external as it would\n // require hoisting the package which we can't rely on\n if (request.includes('@swc/helpers')) {\n return\n }\n\n // BARREL_OPTIMIZATION_PREFIX is a special marker that tells Next.js to\n // optimize the import by removing unused exports. This has to be compiled.\n if (request.startsWith(BARREL_OPTIMIZATION_PREFIX)) {\n return\n }\n\n // When in esm externals mode, and using import, we resolve with\n // ESM resolving options.\n // Also disable esm request when appDir is enabled\n const isEsmRequested = dependencyType === 'esm'\n\n // Don't bundle @vercel/og nodejs bundle for nodejs runtime.\n // TODO-APP: bundle route.js with different layer that externals common node_module deps.\n // Make sure @vercel/og is loaded as ESM for Node.js runtime\n if (\n isWebpackServerOnlyLayer(layer) &&\n request === 'next/dist/compiled/@vercel/og/index.node.js'\n ) {\n return `module ${request}`\n }\n\n // Specific Next.js imports that should remain external\n // TODO-APP: Investigate if we can remove this.\n if (request.startsWith('next/dist/')) {\n // Non external that needs to be transpiled\n // Image loader needs to be transpiled\n if (/^next[\\\\/]dist[\\\\/]shared[\\\\/]lib[\\\\/]image-loader/.test(request)) {\n return\n }\n\n if (/^next[\\\\/]dist[\\\\/]compiled[\\\\/]next-server/.test(request)) {\n return `commonjs ${request}`\n }\n\n if (\n /^next[\\\\/]dist[\\\\/]shared[\\\\/](?!lib[\\\\/]router[\\\\/]router)/.test(\n request\n ) ||\n /^next[\\\\/]dist[\\\\/]compiled[\\\\/].*\\.c?js$/.test(request)\n ) {\n return `commonjs ${request}`\n }\n\n if (\n /^next[\\\\/]dist[\\\\/]esm[\\\\/]shared[\\\\/](?!lib[\\\\/]router[\\\\/]router)/.test(\n request\n ) ||\n /^next[\\\\/]dist[\\\\/]compiled[\\\\/].*\\.mjs$/.test(request)\n ) {\n return `module ${request}`\n }\n\n return resolveNextExternal(request)\n }\n\n // TODO-APP: Let's avoid this resolve call as much as possible, and eventually get rid of it.\n const resolveResult = await resolveExternal(\n dir,\n config.experimental.esmExternals,\n context,\n request,\n isEsmRequested,\n optOutBundlingPackages,\n getResolve,\n isLocal ? resolveNextExternal : undefined\n )\n\n if ('localRes' in resolveResult) {\n return resolveResult.localRes\n }\n\n // Forcedly resolve the styled-jsx installed by next.js,\n // since `resolveExternal` cannot find the styled-jsx dep with pnpm\n if (request === 'styled-jsx/style') {\n resolveResult.res = defaultOverrides['styled-jsx/style']\n }\n\n const { res, isEsm } = resolveResult\n\n // If the request cannot be resolved we need to have\n // webpack \"bundle\" it so it surfaces the not found error.\n if (!res) {\n return\n }\n\n const isOptOutBundling = optOutBundlingPackageRegex.test(res)\n // Apply bundling rules to all app layers.\n // Since handleExternals only handle the server layers, we don't need to exclude client here\n if (!isOptOutBundling && isAppLayer) {\n return\n }\n\n // ESM externals can only be imported (and not required).\n // Make an exception in loose mode.\n if (!isEsmRequested && isEsm && !looseEsmExternals && !isLocal) {\n throw new Error(\n `ESM packages (${request}) need to be imported. Use 'import' to reference the package instead. https://nextjs.org/docs/messages/import-esm-externals`\n )\n }\n\n const externalType = isEsm ? 'module' : 'commonjs'\n\n // Default pages have to be transpiled\n if (\n // This is the @babel/plugin-transform-runtime \"helpers: true\" option\n /node_modules[/\\\\]@babel[/\\\\]runtime[/\\\\]/.test(res)\n ) {\n return\n }\n\n // Webpack itself has to be compiled because it doesn't always use module relative paths\n if (\n /node_modules[/\\\\]webpack/.test(res) ||\n /node_modules[/\\\\]css-loader/.test(res)\n ) {\n return\n }\n\n // If a package should be transpiled by Next.js, we skip making it external.\n // It doesn't matter what the extension is, as we'll transpile it anyway.\n if (transpiledPackages && !resolvedExternalPackageDirs) {\n resolvedExternalPackageDirs = new Map()\n // We need to resolve all the external package dirs initially.\n for (const pkg of transpiledPackages) {\n const pkgRes = await resolveExternal(\n dir,\n config.experimental.esmExternals,\n context,\n pkg + '/package.json',\n isEsmRequested,\n optOutBundlingPackages,\n getResolve,\n isLocal ? resolveNextExternal : undefined\n )\n if (pkgRes.res) {\n resolvedExternalPackageDirs.set(pkg, path.dirname(pkgRes.res))\n }\n }\n }\n\n const resolvedBundlingOptOutRes = resolveBundlingOptOutPackages({\n resolvedRes: res,\n config,\n resolvedExternalPackageDirs,\n isAppLayer,\n externalType,\n isOptOutBundling,\n request,\n transpiledPackages,\n })\n if (resolvedBundlingOptOutRes) {\n return resolvedBundlingOptOutRes\n }\n\n // if here, we default to bundling the file\n return\n }\n}\n\nfunction resolveBundlingOptOutPackages({\n resolvedRes,\n config,\n resolvedExternalPackageDirs,\n isAppLayer,\n externalType,\n isOptOutBundling,\n request,\n transpiledPackages,\n}: {\n resolvedRes: string\n config: NextConfigComplete\n resolvedExternalPackageDirs: Map<string, string>\n isAppLayer: boolean\n externalType: string\n isOptOutBundling: boolean\n request: string\n transpiledPackages: string[]\n}) {\n if (nodeModulesRegex.test(resolvedRes)) {\n const shouldBundlePages =\n !isAppLayer && config.bundlePagesRouterDependencies && !isOptOutBundling\n\n const shouldBeBundled =\n shouldBundlePages ||\n isResourceInPackages(\n resolvedRes,\n transpiledPackages,\n resolvedExternalPackageDirs\n )\n\n if (!shouldBeBundled) {\n return `${externalType} ${request}` // Externalize if not bundled or opted out\n }\n }\n}\n\n/**\n * @param localRes the full path to the file\n * @returns the externalized path\n * @description returns an externalized path if the file is a Next.js file and ends with either `.shared-runtime.js` or `.external.js`\n * This is used to ensure that files used across the rendering runtime(s) and the user code are one and the same. The logic in this function\n * will rewrite the require to the correct bundle location depending on the layer at which the file is being used.\n */\nfunction resolveNextExternal(localRes: string) {\n const isExternal = externalPattern.test(localRes)\n\n // if the file ends with .external, we need to make it a commonjs require in all cases\n // this is used mainly to share the async local storage across the routing, rendering and user layers.\n if (isExternal) {\n // it's important we return the path that starts with `next/dist/` here instead of the absolute path\n // otherwise NFT will get tripped up\n return `commonjs ${normalizePathSep(\n localRes.replace(/.*?next[/\\\\]dist/, 'next/dist')\n )}`\n }\n}\n"],"names":["isResourceInPackages","makeExternalHandler","resolveExternal","reactPackagesRegex","pathSeparators","optionalEsmPart","externalFileEnd","nextDist","externalPattern","RegExp","nodeModulesRegex","resource","packageNames","packageDirMapping","some","p","has","startsWith","get","path","sep","includes","join","replace","dir","esmExternalsConfig","context","request","isEsmRequested","_optOutBundlingPackages","getResolve","isLocalCallback","baseResolveCheck","esmResolveOptions","NODE_ESM_RESOLVE_OPTIONS","nodeResolveOptions","NODE_RESOLVE_OPTIONS","baseEsmResolveOptions","NODE_BASE_ESM_RESOLVE_OPTIONS","baseResolveOptions","NODE_BASE_RESOLVE_OPTIONS","esmExternals","looseEsmExternals","res","isEsm","preferEsmOptions","preferEsm","resolveOptions","resolve","err","localRes","baseRes","baseIsEsm","baseResolve","config","optOutBundlingPackages","optOutBundlingPackageRegex","transpiledPackages","resolvedExternalPackageDirs","experimental","handleExternals","dependencyType","layer","isLocal","posix","isAbsolute","process","platform","win32","isAppLayer","isWebpackBundledLayer","test","notExternalModules","BARREL_OPTIMIZATION_PREFIX","isWebpackServerOnlyLayer","resolveNextExternal","resolveResult","undefined","defaultOverrides","isOptOutBundling","Error","externalType","Map","pkg","pkgRes","set","dirname","resolvedBundlingOptOutRes","resolveBundlingOptOutPackages","resolvedRes","shouldBundlePages","bundlePagesRouterDependencies","shouldBeBundled","isExternal","normalizePathSep"],"mappings":";;;;;;;;;;;;;;;;IA2BgBA,oBAAoB;eAApBA;;IA0GAC,mBAAmB;eAAnBA;;IAzFMC,eAAe;eAAfA;;;6BAzCW;2BACU;6DAC1B;+BAMV;uBACyD;kCAC/B;;;;;;AACjC,MAAMC,qBAAqB;AAE3B,MAAMC,iBAAiB;AACvB,MAAMC,kBAAkB,CAAC,EAAE,EAAED,eAAe,KAAK,EAAEA,eAAe,CAAC,CAAC;AACpE,MAAME,kBAAkB;AACxB,MAAMC,WAAW,CAAC,IAAI,EAAEH,eAAe,IAAI,CAAC;AAE5C,MAAMI,kBAAkB,IAAIC,OAC1B,GAAGF,WAAWF,gBAAgB,EAAE,EAAEC,iBAAiB;AAGrD,MAAMI,mBAAmB;AAElB,SAASV,qBACdW,QAAgB,EAChBC,YAAuB,EACvBC,iBAAuC;IAEvC,IAAI,CAACD,cAAc,OAAO;IAC1B,OAAOA,aAAa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C,IAAIO,OAAOzC,GAAG,EAAE;oBACde,4BAA4B2B,GAAG,CAACF,KAAKhE,aAAI,CAACmE,OAAO,CAACF,OAAOzC,GAAG;gBAC9D;YACF;QACF;QAEA,MAAM4C,4BAA4BC,8BAA8B;YAC9DC,aAAa9C;YACbW;YACAI;YACAW;YACAY;YACAF;YACApD;YACA8B;QACF;QACA,IAAI8B,2BAA2B;YAC7B,OAAOA;QACT;QAEA,2CAA2C;QAC3C;IACF;AACF;AAEA,SAASC,8BAA8B,EACrCC,WAAW,EACXnC,MAAM,EACNI,2BAA2B,EAC3BW,UAAU,EACVY,YAAY,EACZF,gBAAgB,EAChBpD,OAAO,EACP8B,kBAAkB,EAUnB;IACC,IAAI/C,iBAAiB6D,IAAI,CAACkB,cAAc;QACtC,MAAMC,oBACJ,CAACrB,cAAcf,OAAOqC,6BAA6B,IAAI,CAACZ;QAE1D,MAAMa,kBACJF,qBACA1F,qBACEyF,aACAhC,oBACAC;QAGJ,IAAI,CAACkC,iBAAiB;YACpB,OAAO,GAAGX,aAAa,CAAC,EAAEtD,SAAS,CAAC,0CAA0C;;QAChF;IACF;AACF;AAEA;;;;;;CAMC,GACD,SAASgD,oBAAoBzB,QAAgB;IAC3C,MAAM2C,aAAarF,gBAAgB+D,IAAI,CAACrB;IAExC,sFAAsF;IACtF,sGAAsG;IACtG,IAAI2C,YAAY;QACd,oGAAoG;QACpG,oCAAoC;QACpC,OAAO,CAAC,SAAS,EAAEC,IAAAA,kCAAgB,EACjC5C,SAAS3B,OAAO,CAAC,oBAAoB,eACpC;IACL;AACF"}
1
+ {"version":3,"sources":["../../src/build/handle-externals.ts"],"sourcesContent":["import type { WebpackLayerName } from '../lib/constants'\nimport type { NextConfigComplete } from '../server/config-shared'\nimport type { ResolveOptions } from 'webpack'\nimport { defaultOverrides } from '../server/require-hook'\nimport { BARREL_OPTIMIZATION_PREFIX } from '../shared/lib/constants'\nimport path from '../shared/lib/isomorphic/path'\nimport {\n NODE_BASE_ESM_RESOLVE_OPTIONS,\n NODE_BASE_RESOLVE_OPTIONS,\n NODE_ESM_RESOLVE_OPTIONS,\n NODE_RESOLVE_OPTIONS,\n} from './webpack-config'\nimport { isWebpackBundledLayer, isWebpackServerOnlyLayer } from './utils'\nimport { normalizePathSep } from '../shared/lib/page-path/normalize-path-sep'\nconst reactPackagesRegex = /^(react|react-dom|react-server-dom-webpack)($|\\/)/\n\nconst pathSeparators = '[/\\\\\\\\]'\nconst optionalEsmPart = `((${pathSeparators}esm)?${pathSeparators})`\nconst externalFileEnd = '(\\\\.external(\\\\.js)?)$'\nconst nextDist = `next${pathSeparators}dist`\n\nconst externalPattern = new RegExp(\n `${nextDist}${optionalEsmPart}.*${externalFileEnd}`\n)\n\nconst nodeModulesRegex = /node_modules[/\\\\].*\\.[mc]?js$/\n\nexport function isResourceInPackages(\n resource: string,\n packageNames?: string[],\n packageDirMapping?: Map<string, string>\n): boolean {\n if (!packageNames) return false\n return packageNames.some((p: string) =>\n packageDirMapping && packageDirMapping.has(p)\n ? resource.startsWith(packageDirMapping.get(p)! + path.sep)\n : resource.includes(\n path.sep +\n path.join('node_modules', p.replace(/\\//g, path.sep)) +\n path.sep\n )\n )\n}\n\nexport async function resolveExternal(\n dir: string,\n esmExternalsConfig: NextConfigComplete['experimental']['esmExternals'],\n context: string,\n request: string,\n isEsmRequested: boolean,\n getResolve: (\n options: ResolveOptions\n ) => (\n resolveContext: string,\n resolveRequest: string\n ) => Promise<[string | null, boolean]>,\n isLocalCallback?: (res: string) => any,\n baseResolveCheck = true,\n esmResolveOptions: any = NODE_ESM_RESOLVE_OPTIONS,\n nodeResolveOptions: any = NODE_RESOLVE_OPTIONS,\n baseEsmResolveOptions: any = NODE_BASE_ESM_RESOLVE_OPTIONS,\n baseResolveOptions: any = NODE_BASE_RESOLVE_OPTIONS\n) {\n const esmExternals = !!esmExternalsConfig\n const looseEsmExternals = esmExternalsConfig === 'loose'\n\n let res: string | null = null\n let isEsm: boolean = false\n\n const preferEsmOptions =\n esmExternals && isEsmRequested ? [true, false] : [false]\n\n for (const preferEsm of preferEsmOptions) {\n const resolveOptions = preferEsm ? esmResolveOptions : nodeResolveOptions\n\n const resolve = getResolve(resolveOptions)\n\n // Resolve the import with the webpack provided context, this\n // ensures we're resolving the correct version when multiple\n // exist.\n try {\n ;[res, isEsm] = await resolve(context, request)\n } catch (err) {\n res = null\n }\n\n if (!res) {\n continue\n }\n\n // ESM externals can only be imported (and not required).\n // Make an exception in loose mode.\n if (!isEsmRequested && isEsm && !looseEsmExternals) {\n continue\n }\n\n if (isLocalCallback) {\n return { localRes: isLocalCallback(res) }\n }\n\n // Bundled Node.js code is relocated without its node_modules tree.\n // This means we need to make sure its request resolves to the same\n // package that'll be available at runtime. If it's not identical,\n // we need to bundle the code (even if it _should_ be external).\n if (baseResolveCheck) {\n let baseRes: string | null\n let baseIsEsm: boolean\n try {\n const baseResolve = getResolve(\n isEsm ? baseEsmResolveOptions : baseResolveOptions\n )\n ;[baseRes, baseIsEsm] = await baseResolve(dir, request)\n } catch (err) {\n baseRes = null\n baseIsEsm = false\n }\n\n // Same as above: if the package, when required from the root,\n // would be different from what the real resolution would use, we\n // cannot externalize it.\n // if request is pointing to a symlink it could point to the same file,\n // the resolver will resolve symlinks so this is handled\n if (baseRes !== res || isEsm !== baseIsEsm) {\n res = null\n continue\n }\n }\n break\n }\n return { res, isEsm }\n}\n\nexport function makeExternalHandler({\n config,\n optOutBundlingPackageRegex,\n transpiledPackages,\n dir,\n}: {\n config: NextConfigComplete\n optOutBundlingPackageRegex: RegExp\n transpiledPackages: string[]\n dir: string\n}) {\n let resolvedExternalPackageDirs: Map<string, string>\n const looseEsmExternals = config.experimental?.esmExternals === 'loose'\n\n return async function handleExternals(\n context: string,\n request: string,\n dependencyType: string,\n layer: WebpackLayerName | null,\n getResolve: (\n options: any\n ) => (\n resolveContext: string,\n resolveRequest: string\n ) => Promise<[string | null, boolean]>\n ) {\n // We need to externalize internal requests for files intended to\n // not be bundled.\n const isLocal: boolean =\n request.startsWith('.') ||\n // Always check for unix-style path, as webpack sometimes\n // normalizes as posix.\n path.posix.isAbsolute(request) ||\n // When on Windows, we also want to check for Windows-specific\n // absolute paths.\n (process.platform === 'win32' && path.win32.isAbsolute(request))\n\n // make sure import \"next\" shows a warning when imported\n // in pages/components\n if (request === 'next') {\n return `commonjs next/dist/lib/import-next-warning`\n }\n\n const isAppLayer = isWebpackBundledLayer(layer)\n\n // Relative requires don't need custom resolution, because they\n // are relative to requests we've already resolved here.\n // Absolute requires (require('/foo')) are extremely uncommon, but\n // also have no need for customization as they're already resolved.\n if (!isLocal) {\n if (/^next$/.test(request)) {\n return `commonjs ${request}`\n }\n\n if (reactPackagesRegex.test(request) && !isAppLayer) {\n return `commonjs ${request}`\n }\n\n const notExternalModules =\n /^(?:private-next-pages\\/|next\\/(?:dist\\/pages\\/|(?:app|document|link|form|image|legacy\\/image|constants|dynamic|script|navigation|headers|router)$)|string-hash|private-next-rsc-action-validate|private-next-rsc-action-client-wrapper|private-next-rsc-server-reference|private-next-rsc-cache-wrapper$)/\n if (notExternalModules.test(request)) {\n return\n }\n }\n\n // @swc/helpers should not be external as it would\n // require hoisting the package which we can't rely on\n if (request.includes('@swc/helpers')) {\n return\n }\n\n // BARREL_OPTIMIZATION_PREFIX is a special marker that tells Next.js to\n // optimize the import by removing unused exports. This has to be compiled.\n if (request.startsWith(BARREL_OPTIMIZATION_PREFIX)) {\n return\n }\n\n // When in esm externals mode, and using import, we resolve with\n // ESM resolving options.\n // Also disable esm request when appDir is enabled\n const isEsmRequested = dependencyType === 'esm'\n\n // Don't bundle @vercel/og nodejs bundle for nodejs runtime.\n // TODO-APP: bundle route.js with different layer that externals common node_module deps.\n // Make sure @vercel/og is loaded as ESM for Node.js runtime\n if (\n isWebpackServerOnlyLayer(layer) &&\n request === 'next/dist/compiled/@vercel/og/index.node.js'\n ) {\n return `module ${request}`\n }\n\n // Specific Next.js imports that should remain external\n // TODO-APP: Investigate if we can remove this.\n if (request.startsWith('next/dist/')) {\n // Non external that needs to be transpiled\n // Image loader needs to be transpiled\n if (/^next[\\\\/]dist[\\\\/]shared[\\\\/]lib[\\\\/]image-loader/.test(request)) {\n return\n }\n\n if (/^next[\\\\/]dist[\\\\/]compiled[\\\\/]next-server/.test(request)) {\n return `commonjs ${request}`\n }\n\n if (\n /^next[\\\\/]dist[\\\\/]shared[\\\\/](?!lib[\\\\/]router[\\\\/]router)/.test(\n request\n ) ||\n /^next[\\\\/]dist[\\\\/]compiled[\\\\/].*\\.c?js$/.test(request)\n ) {\n return `commonjs ${request}`\n }\n\n if (\n /^next[\\\\/]dist[\\\\/]esm[\\\\/]shared[\\\\/](?!lib[\\\\/]router[\\\\/]router)/.test(\n request\n ) ||\n /^next[\\\\/]dist[\\\\/]compiled[\\\\/].*\\.mjs$/.test(request)\n ) {\n return `module ${request}`\n }\n\n return resolveNextExternal(request)\n }\n\n // TODO-APP: Let's avoid this resolve call as much as possible, and eventually get rid of it.\n const resolveResult = await resolveExternal(\n dir,\n config.experimental.esmExternals,\n context,\n request,\n isEsmRequested,\n getResolve,\n isLocal ? resolveNextExternal : undefined\n )\n\n if ('localRes' in resolveResult) {\n return resolveResult.localRes\n }\n\n // Forcedly resolve the styled-jsx installed by next.js,\n // since `resolveExternal` cannot find the styled-jsx dep with pnpm\n if (request === 'styled-jsx/style') {\n resolveResult.res = defaultOverrides['styled-jsx/style']\n }\n\n const { res, isEsm } = resolveResult\n\n // If the request cannot be resolved we need to have\n // webpack \"bundle\" it so it surfaces the not found error.\n if (!res) {\n return\n }\n\n const isOptOutBundling = optOutBundlingPackageRegex.test(res)\n // Apply bundling rules to all app layers.\n // Since handleExternals only handle the server layers, we don't need to exclude client here\n if (!isOptOutBundling && isAppLayer) {\n return\n }\n\n // ESM externals can only be imported (and not required).\n // Make an exception in loose mode.\n if (!isEsmRequested && isEsm && !looseEsmExternals && !isLocal) {\n throw new Error(\n `ESM packages (${request}) need to be imported. Use 'import' to reference the package instead. https://nextjs.org/docs/messages/import-esm-externals`\n )\n }\n\n const externalType = isEsm ? 'module' : 'commonjs'\n\n // Default pages have to be transpiled\n if (\n // This is the @babel/plugin-transform-runtime \"helpers: true\" option\n /node_modules[/\\\\]@babel[/\\\\]runtime[/\\\\]/.test(res)\n ) {\n return\n }\n\n // Webpack itself has to be compiled because it doesn't always use module relative paths\n if (\n /node_modules[/\\\\]webpack/.test(res) ||\n /node_modules[/\\\\]css-loader/.test(res)\n ) {\n return\n }\n\n // If a package should be transpiled by Next.js, we skip making it external.\n // It doesn't matter what the extension is, as we'll transpile it anyway.\n if (transpiledPackages && !resolvedExternalPackageDirs) {\n resolvedExternalPackageDirs = new Map()\n // We need to resolve all the external package dirs initially.\n for (const pkg of transpiledPackages) {\n const pkgRes = await resolveExternal(\n dir,\n config.experimental.esmExternals,\n context,\n pkg + '/package.json',\n isEsmRequested,\n getResolve,\n isLocal ? resolveNextExternal : undefined\n )\n if (pkgRes.res) {\n resolvedExternalPackageDirs.set(pkg, path.dirname(pkgRes.res))\n }\n }\n }\n\n const resolvedBundlingOptOutRes = resolveBundlingOptOutPackages({\n resolvedRes: res,\n config,\n resolvedExternalPackageDirs,\n isAppLayer,\n externalType,\n isOptOutBundling,\n request,\n transpiledPackages,\n })\n if (resolvedBundlingOptOutRes) {\n return resolvedBundlingOptOutRes\n }\n\n // if here, we default to bundling the file\n return\n }\n}\n\nfunction resolveBundlingOptOutPackages({\n resolvedRes,\n config,\n resolvedExternalPackageDirs,\n isAppLayer,\n externalType,\n isOptOutBundling,\n request,\n transpiledPackages,\n}: {\n resolvedRes: string\n config: NextConfigComplete\n resolvedExternalPackageDirs: Map<string, string>\n isAppLayer: boolean\n externalType: string\n isOptOutBundling: boolean\n request: string\n transpiledPackages: string[]\n}) {\n if (nodeModulesRegex.test(resolvedRes)) {\n const shouldBundlePages =\n !isAppLayer && config.bundlePagesRouterDependencies && !isOptOutBundling\n\n const shouldBeBundled =\n shouldBundlePages ||\n isResourceInPackages(\n resolvedRes,\n transpiledPackages,\n resolvedExternalPackageDirs\n )\n\n if (!shouldBeBundled) {\n return `${externalType} ${request}` // Externalize if not bundled or opted out\n }\n }\n}\n\n/**\n * @param localRes the full path to the file\n * @returns the externalized path\n * @description returns an externalized path if the file is a Next.js file and ends with either `.shared-runtime.js` or `.external.js`\n * This is used to ensure that files used across the rendering runtime(s) and the user code are one and the same. The logic in this function\n * will rewrite the require to the correct bundle location depending on the layer at which the file is being used.\n */\nfunction resolveNextExternal(localRes: string) {\n const isExternal = externalPattern.test(localRes)\n\n // if the file ends with .external, we need to make it a commonjs require in all cases\n // this is used mainly to share the async local storage across the routing, rendering and user layers.\n if (isExternal) {\n // it's important we return the path that starts with `next/dist/` here instead of the absolute path\n // otherwise NFT will get tripped up\n return `commonjs ${normalizePathSep(\n localRes.replace(/.*?next[/\\\\]dist/, 'next/dist')\n )}`\n }\n}\n"],"names":["isResourceInPackages","makeExternalHandler","resolveExternal","reactPackagesRegex","pathSeparators","optionalEsmPart","externalFileEnd","nextDist","externalPattern","RegExp","nodeModulesRegex","resource","packageNames","packageDirMapping","some","p","has","startsWith","get","path","sep","includes","join","replace","dir","esmExternalsConfig","context","request","isEsmRequested","getResolve","isLocalCallback","baseResolveCheck","esmResolveOptions","NODE_ESM_RESOLVE_OPTIONS","nodeResolveOptions","NODE_RESOLVE_OPTIONS","baseEsmResolveOptions","NODE_BASE_ESM_RESOLVE_OPTIONS","baseResolveOptions","NODE_BASE_RESOLVE_OPTIONS","esmExternals","looseEsmExternals","res","isEsm","preferEsmOptions","preferEsm","resolveOptions","resolve","err","localRes","baseRes","baseIsEsm","baseResolve","config","optOutBundlingPackageRegex","transpiledPackages","resolvedExternalPackageDirs","experimental","handleExternals","dependencyType","layer","isLocal","posix","isAbsolute","process","platform","win32","isAppLayer","isWebpackBundledLayer","test","notExternalModules","BARREL_OPTIMIZATION_PREFIX","isWebpackServerOnlyLayer","resolveNextExternal","resolveResult","undefined","defaultOverrides","isOptOutBundling","Error","externalType","Map","pkg","pkgRes","set","dirname","resolvedBundlingOptOutRes","resolveBundlingOptOutPackages","resolvedRes","shouldBundlePages","bundlePagesRouterDependencies","shouldBeBundled","isExternal","normalizePathSep"],"mappings":";;;;;;;;;;;;;;;;IA2BgBA,oBAAoB;eAApBA;;IAyGAC,mBAAmB;eAAnBA;;IAxFMC,eAAe;eAAfA;;;6BAzCW;2BACU;6DAC1B;+BAMV;uBACyD;kCAC/B;;;;;;AACjC,MAAMC,qBAAqB;AAE3B,MAAMC,iBAAiB;AACvB,MAAMC,kBAAkB,CAAC,EAAE,EAAED,eAAe,KAAK,EAAEA,eAAe,CAAC,CAAC;AACpE,MAAME,kBAAkB;AACxB,MAAMC,WAAW,CAAC,IAAI,EAAEH,eAAe,IAAI,CAAC;AAE5C,MAAMI,kBAAkB,IAAIC,OAC1B,GAAGF,WAAWF,gBAAgB,EAAE,EAAEC,iBAAiB;AAGrD,MAAMI,mBAAmB;AAElB,SAASV,qBACdW,QAAgB,EAChBC,YAAuB,EACvBC,iBAAuC;IAEvC,IAAI,CAACD,cAAc,OAAO;IAC1B,OAAOA,aAAaE,IAAI,CAAC,CAACC,IACxBF,qBAAqBA,kBAAkBG,GAAG,CAACD,KACvCJ,SAASM,UAAU,CAACJ,kBAAkBK,GAAG,CAACH,KAAMI,aAAI,CAACC,GAAG,IACxDT,SAASU,QAAQ,CACfF,aAAI,CAACC,GAAG,GACND,aAAI,CAACG,IAAI,CAAC,gBAAgBP,EAAEQ,OAAO,CAAC,OAAOJ,aAAI,CAACC,GAAG,KACnDD,aAAI,CAACC,GAAG;AAGpB;AAEO,eAAelB,gBACpBsB,GAAW,EACXC,kBAAsE,EACtEC,OAAe,EACfC,OAAe,EACfC,cAAuB,EACvBC,UAKsC,EACtCC,eAAsC,EACtCC,mBAAmB,IAAI,EACvBC,oBAAyBC,uCAAwB,EACjDC,qBAA0BC,mCAAoB,EAC9CC,wBAA6BC,4CAA6B,EAC1DC,qBAA0BC,wCAAyB;IAEnD,MAAMC,eAAe,CAAC,CAAC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iBAAiB;YACpB,OAAO,GAAGX,aAAa,CAAC,EAAEpD,SAAS,CAAC,0CAA0C;;QAChF;IACF;AACF;AAEA;;;;;;CAMC,GACD,SAAS8C,oBAAoBxB,QAAgB;IAC3C,MAAM0C,aAAanF,gBAAgB6D,IAAI,CAACpB;IAExC,sFAAsF;IACtF,sGAAsG;IACtG,IAAI0C,YAAY;QACd,oGAAoG;QACpG,oCAAoC;QACpC,OAAO,CAAC,SAAS,EAAEC,IAAAA,kCAAgB,EACjC3C,SAAS1B,OAAO,CAAC,oBAAoB,eACpC;IACL;AACF"}
@@ -364,7 +364,7 @@ async function build(dir, reactProductionProfiling = false, debugOutput = false,
364
364
  const nextBuildSpan = (0, _trace.trace)('next-build', undefined, {
365
365
  buildMode: experimentalBuildMode,
366
366
  isTurboBuild: String(turboNextBuild),
367
- version: "15.2.1-canary.0"
367
+ version: "15.2.1-canary.2"
368
368
  });
369
369
  _buildcontext.NextBuildContext.nextBuildSpan = nextBuildSpan;
370
370
  _buildcontext.NextBuildContext.dir = dir;
@@ -723,7 +723,7 @@ async function build(dir, reactProductionProfiling = false, debugOutput = false,
723
723
  // Files outside of the distDir can be "type": "module"
724
724
  await writeFileUtf8(_path.default.join(distDir, 'package.json'), '{"type": "commonjs"}');
725
725
  // These are written to distDir, so they need to come after creating and cleaning distDr.
726
- await (0, _builddiagnostics.recordFrameworkVersion)("15.2.1-canary.0");
726
+ await (0, _builddiagnostics.recordFrameworkVersion)("15.2.1-canary.2");
727
727
  await (0, _builddiagnostics.updateBuildDiagnostics)({
728
728
  buildStage: 'start'
729
729
  });
@@ -119,7 +119,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
119
119
  }
120
120
  return newObj;
121
121
  }
122
- const nextVersion = "15.2.1-canary.0";
122
+ const nextVersion = "15.2.1-canary.2";
123
123
  const ArchName = (0, _os.arch)();
124
124
  const PlatformName = (0, _os.platform)();
125
125
  function infoLog(...args) {
@@ -33,6 +33,7 @@ export declare function getJestSWCOptions({ isServer, filename, esm, modularizeI
33
33
  } | undefined;
34
34
  serverActions: {
35
35
  isReactServerLayer: boolean;
36
+ isDevelopment: boolean;
36
37
  useCacheEnabled: boolean | undefined;
37
38
  hashSalt: string;
38
39
  cacheKinds: string[];
@@ -161,6 +161,7 @@ function getBaseSWCOptions({ filename, jest, development, hasReactRefresh, globa
161
161
  } : undefined,
162
162
  serverActions: isAppRouterPagesLayer && !jest ? {
163
163
  isReactServerLayer,
164
+ isDevelopment: development,
164
165
  useCacheEnabled,
165
166
  hashSalt: serverReferenceHashSalt,
166
167
  cacheKinds: [
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/build/swc/options.ts"],"sourcesContent":["import path from 'path'\nimport { WEBPACK_LAYERS, type WebpackLayerName } from '../../lib/constants'\nimport type {\n NextConfig,\n ExperimentalConfig,\n EmotionConfig,\n StyledComponentsConfig,\n} from '../../server/config-shared'\nimport type { ResolvedBaseUrl } from '../load-jsconfig'\nimport { isWebpackServerOnlyLayer, isWebpackAppPagesLayer } from '../utils'\nimport { escapeStringRegexp } from '../../shared/lib/escape-regexp'\n\nconst nextDirname = path.dirname(require.resolve('next/package.json'))\n\nconst nextDistPath = new RegExp(\n `${escapeStringRegexp(nextDirname)}[\\\\/]dist[\\\\/](shared[\\\\/]lib|client|pages)`\n)\n\nconst nodeModulesPath = /[\\\\/]node_modules[\\\\/]/\n\nconst regeneratorRuntimePath = require.resolve(\n 'next/dist/compiled/regenerator-runtime'\n)\n\nfunction isTypeScriptFile(filename: string) {\n return filename.endsWith('.ts') || filename.endsWith('.tsx')\n}\n\nfunction isCommonJSFile(filename: string) {\n return filename.endsWith('.cjs')\n}\n\n// Ensure Next.js internals and .cjs files are output as CJS modules,\n// By default all modules are output as ESM or will treated as CJS if next-swc/auto-cjs plugin detects file is CJS.\nfunction shouldOutputCommonJs(filename: string) {\n return isCommonJSFile(filename) || nextDistPath.test(filename)\n}\n\nexport function getParserOptions({ filename, jsConfig, ...rest }: any) {\n const isTSFile = filename.endsWith('.ts')\n const hasTsSyntax = isTypeScriptFile(filename)\n const enableDecorators = Boolean(\n jsConfig?.compilerOptions?.experimentalDecorators\n )\n return {\n ...rest,\n syntax: hasTsSyntax ? 'typescript' : 'ecmascript',\n dynamicImport: true,\n decorators: enableDecorators,\n // Exclude regular TypeScript files from React transformation to prevent e.g. generic parameters and angle-bracket type assertion from being interpreted as JSX tags.\n [hasTsSyntax ? 'tsx' : 'jsx']: !isTSFile,\n importAssertions: true,\n }\n}\n\nfunction getBaseSWCOptions({\n filename,\n jest,\n development,\n hasReactRefresh,\n globalWindow,\n esm,\n modularizeImports,\n swcPlugins,\n compilerOptions,\n resolvedBaseUrl,\n jsConfig,\n swcCacheDir,\n serverComponents,\n serverReferenceHashSalt,\n bundleLayer,\n isDynamicIo,\n cacheHandlers,\n useCacheEnabled,\n}: {\n filename: string\n jest?: boolean\n development: boolean\n hasReactRefresh: boolean\n globalWindow: boolean\n esm: boolean\n modularizeImports?: NextConfig['modularizeImports']\n compilerOptions: NextConfig['compiler']\n swcPlugins: ExperimentalConfig['swcPlugins']\n resolvedBaseUrl?: ResolvedBaseUrl\n jsConfig: any\n swcCacheDir?: string\n serverComponents?: boolean\n serverReferenceHashSalt: string\n bundleLayer?: WebpackLayerName\n isDynamicIo?: boolean\n cacheHandlers?: ExperimentalConfig['cacheHandlers']\n useCacheEnabled?: boolean\n}) {\n const isReactServerLayer = isWebpackServerOnlyLayer(bundleLayer)\n const isAppRouterPagesLayer = isWebpackAppPagesLayer(bundleLayer)\n const parserConfig = getParserOptions({ filename, jsConfig })\n const paths = jsConfig?.compilerOptions?.paths\n const enableDecorators = Boolean(\n jsConfig?.compilerOptions?.experimentalDecorators\n )\n const emitDecoratorMetadata = Boolean(\n jsConfig?.compilerOptions?.emitDecoratorMetadata\n )\n const useDefineForClassFields = Boolean(\n jsConfig?.compilerOptions?.useDefineForClassFields\n )\n const plugins = (swcPlugins ?? [])\n .filter(Array.isArray)\n .map(([name, options]: any) => [require.resolve(name), options])\n\n return {\n jsc: {\n ...(resolvedBaseUrl && paths\n ? {\n baseUrl: resolvedBaseUrl.baseUrl,\n paths,\n }\n : {}),\n externalHelpers: !process.versions.pnp && !jest,\n parser: parserConfig,\n experimental: {\n keepImportAttributes: true,\n emitAssertForImportAttributes: true,\n plugins,\n cacheRoot: swcCacheDir,\n },\n transform: {\n // Enables https://github.com/swc-project/swc/blob/0359deb4841be743d73db4536d4a22ac797d7f65/crates/swc_ecma_ext_transforms/src/jest.rs\n ...(jest\n ? {\n hidden: {\n jest: true,\n },\n }\n : {}),\n legacyDecorator: enableDecorators,\n decoratorMetadata: emitDecoratorMetadata,\n useDefineForClassFields: useDefineForClassFields,\n react: {\n importSource:\n jsConfig?.compilerOptions?.jsxImportSource ??\n (compilerOptions?.emotion && !isReactServerLayer\n ? '@emotion/react'\n : 'react'),\n runtime: 'automatic',\n pragmaFrag: 'React.Fragment',\n throwIfNamespace: true,\n development: !!development,\n useBuiltins: true,\n refresh: !!hasReactRefresh,\n },\n optimizer: {\n simplify: false,\n globals: jest\n ? null\n : {\n typeofs: {\n window: globalWindow ? 'object' : 'undefined',\n },\n envs: {\n NODE_ENV: development ? '\"development\"' : '\"production\"',\n },\n // TODO: handle process.browser to match babel replacing as well\n },\n },\n regenerator: {\n importPath: regeneratorRuntimePath,\n },\n },\n },\n sourceMaps: jest ? 'inline' : undefined,\n removeConsole: compilerOptions?.removeConsole,\n // disable \"reactRemoveProperties\" when \"jest\" is true\n // otherwise the setting from next.config.js will be used\n reactRemoveProperties: jest\n ? false\n : compilerOptions?.reactRemoveProperties,\n // Map the k-v map to an array of pairs.\n modularizeImports: modularizeImports\n ? Object.fromEntries(\n Object.entries(modularizeImports).map(([mod, config]) => [\n mod,\n {\n ...config,\n transform:\n typeof config.transform === 'string'\n ? config.transform\n : Object.entries(config.transform).map(([key, value]) => [\n key,\n value,\n ]),\n },\n ])\n )\n : undefined,\n relay: compilerOptions?.relay,\n // Always transform styled-jsx and error when `client-only` condition is triggered\n styledJsx: {},\n // Disable css-in-js libs (without client-only integration) transform on server layer for server components\n ...(!isReactServerLayer && {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n emotion: getEmotionOptions(compilerOptions?.emotion, development),\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n styledComponents: getStyledComponentsOptions(\n compilerOptions?.styledComponents,\n development\n ),\n }),\n serverComponents:\n serverComponents && !jest\n ? {\n isReactServerLayer,\n dynamicIoEnabled: isDynamicIo,\n useCacheEnabled,\n }\n : undefined,\n serverActions:\n isAppRouterPagesLayer && !jest\n ? {\n isReactServerLayer,\n useCacheEnabled,\n hashSalt: serverReferenceHashSalt,\n cacheKinds: ['default', 'remote'].concat(\n cacheHandlers ? Object.keys(cacheHandlers) : []\n ),\n }\n : undefined,\n // For app router we prefer to bundle ESM,\n // On server side of pages router we prefer CJS.\n preferEsm: esm,\n lintCodemodComments: true,\n debugFunctionName: development,\n }\n}\n\nfunction getStyledComponentsOptions(\n styledComponentsConfig: undefined | boolean | StyledComponentsConfig,\n development: any\n) {\n if (!styledComponentsConfig) {\n return null\n } else if (typeof styledComponentsConfig === 'object') {\n return {\n ...styledComponentsConfig,\n displayName: styledComponentsConfig.displayName ?? Boolean(development),\n }\n } else {\n return {\n displayName: Boolean(development),\n }\n }\n}\n\nfunction getEmotionOptions(\n emotionConfig: undefined | boolean | EmotionConfig,\n development: boolean\n) {\n if (!emotionConfig) {\n return null\n }\n let autoLabel = !!development\n switch (typeof emotionConfig === 'object' && emotionConfig.autoLabel) {\n case 'never':\n autoLabel = false\n break\n case 'always':\n autoLabel = true\n break\n case 'dev-only':\n default:\n break\n }\n return {\n enabled: true,\n autoLabel,\n sourcemap: development,\n ...(typeof emotionConfig === 'object' && {\n importMap: emotionConfig.importMap,\n labelFormat: emotionConfig.labelFormat,\n sourcemap: development && emotionConfig.sourceMap,\n }),\n }\n}\n\nexport function getJestSWCOptions({\n isServer,\n filename,\n esm,\n modularizeImports,\n swcPlugins,\n compilerOptions,\n jsConfig,\n resolvedBaseUrl,\n pagesDir,\n serverReferenceHashSalt,\n}: {\n isServer: boolean\n filename: string\n esm: boolean\n modularizeImports?: NextConfig['modularizeImports']\n swcPlugins: ExperimentalConfig['swcPlugins']\n compilerOptions: NextConfig['compiler']\n jsConfig: any\n resolvedBaseUrl?: ResolvedBaseUrl\n pagesDir?: string\n serverComponents?: boolean\n serverReferenceHashSalt: string\n}) {\n let baseOptions = getBaseSWCOptions({\n filename,\n jest: true,\n development: false,\n hasReactRefresh: false,\n globalWindow: !isServer,\n modularizeImports,\n swcPlugins,\n compilerOptions,\n jsConfig,\n resolvedBaseUrl,\n esm,\n // Don't apply server layer transformations for Jest\n // Disable server / client graph assertions for Jest\n bundleLayer: undefined,\n serverComponents: false,\n serverReferenceHashSalt,\n })\n\n const useCjsModules = shouldOutputCommonJs(filename)\n return {\n ...baseOptions,\n env: {\n targets: {\n // Targets the current version of Node.js\n node: process.versions.node,\n },\n },\n module: {\n type: esm && !useCjsModules ? 'es6' : 'commonjs',\n },\n disableNextSsg: true,\n disablePageConfig: true,\n pagesDir,\n }\n}\n\nexport function getLoaderSWCOptions({\n // This is not passed yet as \"paths\" resolving is handled by webpack currently.\n // resolvedBaseUrl,\n filename,\n development,\n isServer,\n pagesDir,\n appDir,\n isPageFile,\n isDynamicIo,\n hasReactRefresh,\n modularizeImports,\n optimizeServerReact,\n optimizePackageImports,\n swcPlugins,\n compilerOptions,\n jsConfig,\n supportedBrowsers,\n swcCacheDir,\n relativeFilePathFromRoot,\n serverComponents,\n serverReferenceHashSalt,\n bundleLayer,\n esm,\n cacheHandlers,\n useCacheEnabled,\n}: {\n filename: string\n development: boolean\n isServer: boolean\n pagesDir?: string\n appDir?: string\n isPageFile: boolean\n hasReactRefresh: boolean\n optimizeServerReact?: boolean\n modularizeImports: NextConfig['modularizeImports']\n isDynamicIo?: boolean\n optimizePackageImports?: NonNullable<\n NextConfig['experimental']\n >['optimizePackageImports']\n swcPlugins: ExperimentalConfig['swcPlugins']\n compilerOptions: NextConfig['compiler']\n jsConfig: any\n supportedBrowsers: string[] | undefined\n swcCacheDir: string\n relativeFilePathFromRoot: string\n esm?: boolean\n serverComponents?: boolean\n serverReferenceHashSalt: string\n bundleLayer?: WebpackLayerName\n cacheHandlers: ExperimentalConfig['cacheHandlers']\n useCacheEnabled?: boolean\n}) {\n let baseOptions: any = getBaseSWCOptions({\n filename,\n development,\n globalWindow: !isServer,\n hasReactRefresh,\n modularizeImports,\n swcPlugins,\n compilerOptions,\n jsConfig,\n // resolvedBaseUrl,\n swcCacheDir,\n bundleLayer,\n serverComponents,\n serverReferenceHashSalt,\n esm: !!esm,\n isDynamicIo,\n cacheHandlers,\n useCacheEnabled,\n })\n baseOptions.fontLoaders = {\n fontLoaders: ['next/font/local', 'next/font/google'],\n relativeFilePathFromRoot,\n }\n baseOptions.cjsRequireOptimizer = {\n packages: {\n 'next/server': {\n transforms: {\n NextRequest: 'next/dist/server/web/spec-extension/request',\n NextResponse: 'next/dist/server/web/spec-extension/response',\n ImageResponse: 'next/dist/server/web/spec-extension/image-response',\n userAgentFromString: 'next/dist/server/web/spec-extension/user-agent',\n userAgent: 'next/dist/server/web/spec-extension/user-agent',\n },\n },\n },\n }\n\n if (optimizeServerReact && isServer && !development) {\n baseOptions.optimizeServerReact = {\n optimize_use_state: false,\n }\n }\n\n // Modularize import optimization for barrel files\n if (optimizePackageImports) {\n baseOptions.autoModularizeImports = {\n packages: optimizePackageImports,\n }\n }\n\n const isNodeModules = nodeModulesPath.test(filename)\n const isAppBrowserLayer = bundleLayer === WEBPACK_LAYERS.appPagesBrowser\n const moduleResolutionConfig = shouldOutputCommonJs(filename)\n ? {\n module: {\n type: 'commonjs',\n },\n }\n : {}\n\n let options: any\n if (isServer) {\n options = {\n ...baseOptions,\n ...moduleResolutionConfig,\n // Disables getStaticProps/getServerSideProps tree shaking on the server compilation for pages\n disableNextSsg: true,\n disablePageConfig: true,\n isDevelopment: development,\n isServerCompiler: isServer,\n pagesDir,\n appDir,\n preferEsm: !!esm,\n isPageFile,\n env: {\n targets: {\n // Targets the current version of Node.js\n node: process.versions.node,\n },\n },\n }\n } else {\n options = {\n ...baseOptions,\n ...moduleResolutionConfig,\n disableNextSsg: !isPageFile,\n isDevelopment: development,\n isServerCompiler: isServer,\n pagesDir,\n appDir,\n isPageFile,\n ...(supportedBrowsers && supportedBrowsers.length > 0\n ? {\n env: {\n targets: supportedBrowsers,\n },\n }\n : {}),\n }\n if (!options.env) {\n // Matches default @babel/preset-env behavior\n options.jsc.target = 'es5'\n }\n }\n\n // For node_modules in app browser layer, we don't need to do any server side transformation.\n // Only keep server actions transform to discover server actions from client components.\n if (isAppBrowserLayer && isNodeModules) {\n options.disableNextSsg = true\n options.disablePageConfig = true\n options.isPageFile = false\n options.optimizeServerReact = undefined\n options.cjsRequireOptimizer = undefined\n // Disable optimizer for node_modules in app browser layer, to avoid unnecessary replacement.\n // e.g. typeof window could result differently in js worker or browser.\n if (options.jsc.transform.optimizer.globals?.typeofs) {\n delete options.jsc.transform.optimizer.globals.typeofs.window\n }\n }\n\n return options\n}\n"],"names":["getJestSWCOptions","getLoaderSWCOptions","getParserOptions","nextDirname","path","dirname","require","resolve","nextDistPath","RegExp","escapeStringRegexp","nodeModulesPath","regeneratorRuntimePath","isTypeScriptFile","filename","endsWith","isCommonJSFile","shouldOutputCommonJs","test","jsConfig","rest","isTSFile","hasTsSyntax","enableDecorators","Boolean","compilerOptions","experimentalDecorators","syntax","dynamicImport","decorators","importAssertions","getBaseSWCOptions","jest","development","hasReactRefresh","globalWindow","esm","modularizeImports","swcPlugins","resolvedBaseUrl","swcCacheDir","serverComponents","serverReferenceHashSalt","bundleLayer","isDynamicIo","cacheHandlers","useCacheEnabled","isReactServerLayer","isWebpackServerOnlyLayer","isAppRouterPagesLayer","isWebpackAppPagesLayer","parserConfig","paths","emitDecoratorMetadata","useDefineForClassFields","plugins","filter","Array","isArray","map","name","options","jsc","baseUrl","externalHelpers","process","versions","pnp","parser","experimental","keepImportAttributes","emitAssertForImportAttributes","cacheRoot","transform","hidden","legacyDecorator","decoratorMetadata","react","importSource","jsxImportSource","emotion","runtime","pragmaFrag","throwIfNamespace","useBuiltins","refresh","optimizer","simplify","globals","typeofs","window","envs","NODE_ENV","regenerator","importPath","sourceMaps","undefined","removeConsole","reactRemoveProperties","Object","fromEntries","entries","mod","config","key","value","relay","styledJsx","getEmotionOptions","styledComponents","getStyledComponentsOptions","dynamicIoEnabled","serverActions","hashSalt","cacheKinds","concat","keys","preferEsm","lintCodemodComments","debugFunctionName","styledComponentsConfig","displayName","emotionConfig","autoLabel","enabled","sourcemap","importMap","labelFormat","sourceMap","isServer","pagesDir","baseOptions","useCjsModules","env","targets","node","module","type","disableNextSsg","disablePageConfig","appDir","isPageFile","optimizeServerReact","optimizePackageImports","supportedBrowsers","relativeFilePathFromRoot","fontLoaders","cjsRequireOptimizer","packages","transforms","NextRequest","NextResponse","ImageResponse","userAgentFromString","userAgent","optimize_use_state","autoModularizeImports","isNodeModules","isAppBrowserLayer","WEBPACK_LAYERS","appPagesBrowser","moduleResolutionConfig","isDevelopment","isServerCompiler","length","target"],"mappings":";;;;;;;;;;;;;;;;IA6RgBA,iBAAiB;eAAjBA;;IA6DAC,mBAAmB;eAAnBA;;IApTAC,gBAAgB;eAAhBA;;;6DAtCC;2BACqC;uBAQW;8BAC9B;;;;;;AAEnC,MAAMC,cAAcC,aAAI,CAACC,OAAO,CAACC,QAAQC,OAAO,CAAC;AAEjD,MAAMC,eAAe,IAAIC,OACvB,GAAGC,IAAAA,gCAAkB,EAACP,aAAa,2CAA2C,CAAC;AAGjF,MAAMQ,kBAAkB;AAExB,MAAMC,yBAAyBN,QAAQC,OAAO,CAC5C;AAGF,SAASM,iBAAiBC,QAAgB;IACxC,OAAOA,SAASC,QAAQ,CAAC,UAAUD,SAASC,QAAQ,CAAC;AACvD;AAEA,SAASC,eAAeF,QAAgB;IACtC,OAAOA,SAASC,QAAQ,CAAC;AAC3B;AAEA,qEAAqE;AACrE,m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5E;IACJ,IAAIoE,UAAU;QACZpE,UAAU;YACR,GAAGsE,WAAW;YACd,GAAG8B,sBAAsB;YACzB,8FAA8F;YAC9FvB,gBAAgB;YAChBC,mBAAmB;YACnBuB,eAAejI;YACfkI,kBAAkBlC;YAClBC;YACAU;YACAvB,WAAW,CAAC,CAACjF;YACbyG;YACAR,KAAK;gBACHC,SAAS;oBACP,yCAAyC;oBACzCC,MAAMtE,QAAQC,QAAQ,CAACqE,IAAI;gBAC7B;YACF;QACF;IACF,OAAO;QACL1E,UAAU;YACR,GAAGsE,WAAW;YACd,GAAG8B,sBAAsB;YACzBvB,gBAAgB,CAACG;YACjBqB,eAAejI;YACfkI,kBAAkBlC;YAClBC;YACAU;YACAC;YACA,GAAIG,qBAAqBA,kBAAkBoB,MAAM,GAAG,IAChD;gBACE/B,KAAK;oBACHC,SAASU;gBACX;YACF,IACA,CAAC,CAAC;QACR;QACA,IAAI,CAACnF,QAAQwE,GAAG,EAAE;YAChB,6CAA6C;YAC7CxE,QAAQC,GAAG,CAACuG,MAAM,GAAG;QACvB;IACF;IAEA,6FAA6F;IAC7F,wFAAwF;IACxF,IAAIP,qBAAqBD,eAAe;YAQlChG;QAPJA,QAAQ6E,cAAc,GAAG;QACzB7E,QAAQ8E,iBAAiB,GAAG;QAC5B9E,QAAQgF,UAAU,GAAG;QACrBhF,QAAQiF,mBAAmB,GAAG9C;QAC9BnC,QAAQsF,mBAAmB,GAAGnD;QAC9B,6FAA6F;QAC7F,uEAAuE;QACvE,KAAInC,2CAAAA,QAAQC,GAAG,CAACW,SAAS,CAACa,SAAS,CAACE,OAAO,qBAAvC3B,yCAAyC4B,OAAO,EAAE;YACpD,OAAO5B,QAAQC,GAAG,CAACW,SAAS,CAACa,SAAS,CAACE,OAAO,CAACC,OAAO,CAACC,MAAM;QAC/D;IACF;IAEA,OAAO7B;AACT"}
1
+ {"version":3,"sources":["../../../src/build/swc/options.ts"],"sourcesContent":["import path from 'path'\nimport { WEBPACK_LAYERS, type WebpackLayerName } from '../../lib/constants'\nimport type {\n NextConfig,\n ExperimentalConfig,\n EmotionConfig,\n StyledComponentsConfig,\n} from '../../server/config-shared'\nimport type { ResolvedBaseUrl } from '../load-jsconfig'\nimport { isWebpackServerOnlyLayer, isWebpackAppPagesLayer } from '../utils'\nimport { escapeStringRegexp } from '../../shared/lib/escape-regexp'\n\nconst nextDirname = path.dirname(require.resolve('next/package.json'))\n\nconst nextDistPath = new RegExp(\n `${escapeStringRegexp(nextDirname)}[\\\\/]dist[\\\\/](shared[\\\\/]lib|client|pages)`\n)\n\nconst nodeModulesPath = /[\\\\/]node_modules[\\\\/]/\n\nconst regeneratorRuntimePath = require.resolve(\n 'next/dist/compiled/regenerator-runtime'\n)\n\nfunction isTypeScriptFile(filename: string) {\n return filename.endsWith('.ts') || filename.endsWith('.tsx')\n}\n\nfunction isCommonJSFile(filename: string) {\n return filename.endsWith('.cjs')\n}\n\n// Ensure Next.js internals and .cjs files are output as CJS modules,\n// By default all modules are output as ESM or will treated as CJS if next-swc/auto-cjs plugin detects file is CJS.\nfunction shouldOutputCommonJs(filename: string) {\n return isCommonJSFile(filename) || nextDistPath.test(filename)\n}\n\nexport function getParserOptions({ filename, jsConfig, ...rest }: any) {\n const isTSFile = filename.endsWith('.ts')\n const hasTsSyntax = isTypeScriptFile(filename)\n const enableDecorators = Boolean(\n jsConfig?.compilerOptions?.experimentalDecorators\n )\n return {\n ...rest,\n syntax: hasTsSyntax ? 'typescript' : 'ecmascript',\n dynamicImport: true,\n decorators: enableDecorators,\n // Exclude regular TypeScript files from React transformation to prevent e.g. generic parameters and angle-bracket type assertion from being interpreted as JSX tags.\n [hasTsSyntax ? 'tsx' : 'jsx']: !isTSFile,\n importAssertions: true,\n }\n}\n\nfunction getBaseSWCOptions({\n filename,\n jest,\n development,\n hasReactRefresh,\n globalWindow,\n esm,\n modularizeImports,\n swcPlugins,\n compilerOptions,\n resolvedBaseUrl,\n jsConfig,\n swcCacheDir,\n serverComponents,\n serverReferenceHashSalt,\n bundleLayer,\n isDynamicIo,\n cacheHandlers,\n useCacheEnabled,\n}: {\n filename: string\n jest?: boolean\n development: boolean\n hasReactRefresh: boolean\n globalWindow: boolean\n esm: boolean\n modularizeImports?: NextConfig['modularizeImports']\n compilerOptions: NextConfig['compiler']\n swcPlugins: ExperimentalConfig['swcPlugins']\n resolvedBaseUrl?: ResolvedBaseUrl\n jsConfig: any\n swcCacheDir?: string\n serverComponents?: boolean\n serverReferenceHashSalt: string\n bundleLayer?: WebpackLayerName\n isDynamicIo?: boolean\n cacheHandlers?: ExperimentalConfig['cacheHandlers']\n useCacheEnabled?: boolean\n}) {\n const isReactServerLayer = isWebpackServerOnlyLayer(bundleLayer)\n const isAppRouterPagesLayer = isWebpackAppPagesLayer(bundleLayer)\n const parserConfig = getParserOptions({ filename, jsConfig })\n const paths = jsConfig?.compilerOptions?.paths\n const enableDecorators = Boolean(\n jsConfig?.compilerOptions?.experimentalDecorators\n )\n const emitDecoratorMetadata = Boolean(\n jsConfig?.compilerOptions?.emitDecoratorMetadata\n )\n const useDefineForClassFields = Boolean(\n jsConfig?.compilerOptions?.useDefineForClassFields\n )\n const plugins = (swcPlugins ?? [])\n .filter(Array.isArray)\n .map(([name, options]: any) => [require.resolve(name), options])\n\n return {\n jsc: {\n ...(resolvedBaseUrl && paths\n ? {\n baseUrl: resolvedBaseUrl.baseUrl,\n paths,\n }\n : {}),\n externalHelpers: !process.versions.pnp && !jest,\n parser: parserConfig,\n experimental: {\n keepImportAttributes: true,\n emitAssertForImportAttributes: true,\n plugins,\n cacheRoot: swcCacheDir,\n },\n transform: {\n // Enables https://github.com/swc-project/swc/blob/0359deb4841be743d73db4536d4a22ac797d7f65/crates/swc_ecma_ext_transforms/src/jest.rs\n ...(jest\n ? {\n hidden: {\n jest: true,\n },\n }\n : {}),\n legacyDecorator: enableDecorators,\n decoratorMetadata: emitDecoratorMetadata,\n useDefineForClassFields: useDefineForClassFields,\n react: {\n importSource:\n jsConfig?.compilerOptions?.jsxImportSource ??\n (compilerOptions?.emotion && !isReactServerLayer\n ? '@emotion/react'\n : 'react'),\n runtime: 'automatic',\n pragmaFrag: 'React.Fragment',\n throwIfNamespace: true,\n development: !!development,\n useBuiltins: true,\n refresh: !!hasReactRefresh,\n },\n optimizer: {\n simplify: false,\n globals: jest\n ? null\n : {\n typeofs: {\n window: globalWindow ? 'object' : 'undefined',\n },\n envs: {\n NODE_ENV: development ? '\"development\"' : '\"production\"',\n },\n // TODO: handle process.browser to match babel replacing as well\n },\n },\n regenerator: {\n importPath: regeneratorRuntimePath,\n },\n },\n },\n sourceMaps: jest ? 'inline' : undefined,\n removeConsole: compilerOptions?.removeConsole,\n // disable \"reactRemoveProperties\" when \"jest\" is true\n // otherwise the setting from next.config.js will be used\n reactRemoveProperties: jest\n ? false\n : compilerOptions?.reactRemoveProperties,\n // Map the k-v map to an array of pairs.\n modularizeImports: modularizeImports\n ? Object.fromEntries(\n Object.entries(modularizeImports).map(([mod, config]) => [\n mod,\n {\n ...config,\n transform:\n typeof config.transform === 'string'\n ? config.transform\n : Object.entries(config.transform).map(([key, value]) => [\n key,\n value,\n ]),\n },\n ])\n )\n : undefined,\n relay: compilerOptions?.relay,\n // Always transform styled-jsx and error when `client-only` condition is triggered\n styledJsx: {},\n // Disable css-in-js libs (without client-only integration) transform on server layer for server components\n ...(!isReactServerLayer && {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n emotion: getEmotionOptions(compilerOptions?.emotion, development),\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n styledComponents: getStyledComponentsOptions(\n compilerOptions?.styledComponents,\n development\n ),\n }),\n serverComponents:\n serverComponents && !jest\n ? {\n isReactServerLayer,\n dynamicIoEnabled: isDynamicIo,\n useCacheEnabled,\n }\n : undefined,\n serverActions:\n isAppRouterPagesLayer && !jest\n ? {\n isReactServerLayer,\n isDevelopment: development,\n useCacheEnabled,\n hashSalt: serverReferenceHashSalt,\n cacheKinds: ['default', 'remote'].concat(\n cacheHandlers ? Object.keys(cacheHandlers) : []\n ),\n }\n : undefined,\n // For app router we prefer to bundle ESM,\n // On server side of pages router we prefer CJS.\n preferEsm: esm,\n lintCodemodComments: true,\n debugFunctionName: development,\n }\n}\n\nfunction getStyledComponentsOptions(\n styledComponentsConfig: undefined | boolean | StyledComponentsConfig,\n development: any\n) {\n if (!styledComponentsConfig) {\n return null\n } else if (typeof styledComponentsConfig === 'object') {\n return {\n ...styledComponentsConfig,\n displayName: styledComponentsConfig.displayName ?? Boolean(development),\n }\n } else {\n return {\n displayName: Boolean(development),\n }\n }\n}\n\nfunction getEmotionOptions(\n emotionConfig: undefined | boolean | EmotionConfig,\n development: boolean\n) {\n if (!emotionConfig) {\n return null\n }\n let autoLabel = !!development\n switch (typeof emotionConfig === 'object' && emotionConfig.autoLabel) {\n case 'never':\n autoLabel = false\n break\n case 'always':\n autoLabel = true\n break\n case 'dev-only':\n default:\n break\n }\n return {\n enabled: true,\n autoLabel,\n sourcemap: development,\n ...(typeof emotionConfig === 'object' && {\n importMap: emotionConfig.importMap,\n labelFormat: emotionConfig.labelFormat,\n sourcemap: development && emotionConfig.sourceMap,\n }),\n }\n}\n\nexport function getJestSWCOptions({\n isServer,\n filename,\n esm,\n modularizeImports,\n swcPlugins,\n compilerOptions,\n jsConfig,\n resolvedBaseUrl,\n pagesDir,\n serverReferenceHashSalt,\n}: {\n isServer: boolean\n filename: string\n esm: boolean\n modularizeImports?: NextConfig['modularizeImports']\n swcPlugins: ExperimentalConfig['swcPlugins']\n compilerOptions: NextConfig['compiler']\n jsConfig: any\n resolvedBaseUrl?: ResolvedBaseUrl\n pagesDir?: string\n serverComponents?: boolean\n serverReferenceHashSalt: string\n}) {\n let baseOptions = getBaseSWCOptions({\n filename,\n jest: true,\n development: false,\n hasReactRefresh: false,\n globalWindow: !isServer,\n modularizeImports,\n swcPlugins,\n compilerOptions,\n jsConfig,\n resolvedBaseUrl,\n esm,\n // Don't apply server layer transformations for Jest\n // Disable server / client graph assertions for Jest\n bundleLayer: undefined,\n serverComponents: false,\n serverReferenceHashSalt,\n })\n\n const useCjsModules = shouldOutputCommonJs(filename)\n return {\n ...baseOptions,\n env: {\n targets: {\n // Targets the current version of Node.js\n node: process.versions.node,\n },\n },\n module: {\n type: esm && !useCjsModules ? 'es6' : 'commonjs',\n },\n disableNextSsg: true,\n disablePageConfig: true,\n pagesDir,\n }\n}\n\nexport function getLoaderSWCOptions({\n // This is not passed yet as \"paths\" resolving is handled by webpack currently.\n // resolvedBaseUrl,\n filename,\n development,\n isServer,\n pagesDir,\n appDir,\n isPageFile,\n isDynamicIo,\n hasReactRefresh,\n modularizeImports,\n optimizeServerReact,\n optimizePackageImports,\n swcPlugins,\n compilerOptions,\n jsConfig,\n supportedBrowsers,\n swcCacheDir,\n relativeFilePathFromRoot,\n serverComponents,\n serverReferenceHashSalt,\n bundleLayer,\n esm,\n cacheHandlers,\n useCacheEnabled,\n}: {\n filename: string\n development: boolean\n isServer: boolean\n pagesDir?: string\n appDir?: string\n isPageFile: boolean\n hasReactRefresh: boolean\n optimizeServerReact?: boolean\n modularizeImports: NextConfig['modularizeImports']\n isDynamicIo?: boolean\n optimizePackageImports?: NonNullable<\n NextConfig['experimental']\n >['optimizePackageImports']\n swcPlugins: ExperimentalConfig['swcPlugins']\n compilerOptions: NextConfig['compiler']\n jsConfig: any\n supportedBrowsers: string[] | undefined\n swcCacheDir: string\n relativeFilePathFromRoot: string\n esm?: boolean\n serverComponents?: boolean\n serverReferenceHashSalt: string\n bundleLayer?: WebpackLayerName\n cacheHandlers: ExperimentalConfig['cacheHandlers']\n useCacheEnabled?: boolean\n}) {\n let baseOptions: any = getBaseSWCOptions({\n filename,\n development,\n globalWindow: !isServer,\n hasReactRefresh,\n modularizeImports,\n swcPlugins,\n compilerOptions,\n jsConfig,\n // resolvedBaseUrl,\n swcCacheDir,\n bundleLayer,\n serverComponents,\n serverReferenceHashSalt,\n esm: !!esm,\n isDynamicIo,\n cacheHandlers,\n useCacheEnabled,\n })\n baseOptions.fontLoaders = {\n fontLoaders: ['next/font/local', 'next/font/google'],\n relativeFilePathFromRoot,\n }\n baseOptions.cjsRequireOptimizer = {\n packages: {\n 'next/server': {\n transforms: {\n NextRequest: 'next/dist/server/web/spec-extension/request',\n NextResponse: 'next/dist/server/web/spec-extension/response',\n ImageResponse: 'next/dist/server/web/spec-extension/image-response',\n userAgentFromString: 'next/dist/server/web/spec-extension/user-agent',\n userAgent: 'next/dist/server/web/spec-extension/user-agent',\n },\n },\n },\n }\n\n if (optimizeServerReact && isServer && !development) {\n baseOptions.optimizeServerReact = {\n optimize_use_state: false,\n }\n }\n\n // Modularize import optimization for barrel files\n if (optimizePackageImports) {\n baseOptions.autoModularizeImports = {\n packages: optimizePackageImports,\n }\n }\n\n const isNodeModules = nodeModulesPath.test(filename)\n const isAppBrowserLayer = bundleLayer === WEBPACK_LAYERS.appPagesBrowser\n const moduleResolutionConfig = shouldOutputCommonJs(filename)\n ? {\n module: {\n type: 'commonjs',\n },\n }\n : {}\n\n let options: any\n if (isServer) {\n options = {\n ...baseOptions,\n ...moduleResolutionConfig,\n // Disables getStaticProps/getServerSideProps tree shaking on the server compilation for pages\n disableNextSsg: true,\n disablePageConfig: true,\n isDevelopment: development,\n isServerCompiler: isServer,\n pagesDir,\n appDir,\n preferEsm: !!esm,\n isPageFile,\n env: {\n targets: {\n // Targets the current version of Node.js\n node: process.versions.node,\n },\n },\n }\n } else {\n options = {\n ...baseOptions,\n ...moduleResolutionConfig,\n disableNextSsg: !isPageFile,\n isDevelopment: development,\n isServerCompiler: isServer,\n pagesDir,\n appDir,\n isPageFile,\n ...(supportedBrowsers && supportedBrowsers.length > 0\n ? {\n env: {\n targets: supportedBrowsers,\n },\n }\n : {}),\n }\n if (!options.env) {\n // Matches default @babel/preset-env behavior\n options.jsc.target = 'es5'\n }\n }\n\n // For node_modules in app browser layer, we don't need to do any server side transformation.\n // Only keep server actions transform to discover server actions from client components.\n if (isAppBrowserLayer && isNodeModules) {\n options.disableNextSsg = true\n options.disablePageConfig = true\n options.isPageFile = false\n options.optimizeServerReact = undefined\n options.cjsRequireOptimizer = undefined\n // Disable optimizer for node_modules in app browser layer, to avoid unnecessary replacement.\n // e.g. typeof window could result differently in js worker or browser.\n if (options.jsc.transform.optimizer.globals?.typeofs) {\n delete options.jsc.transform.optimizer.globals.typeofs.window\n }\n }\n\n return options\n}\n"],"names":["getJestSWCOptions","getLoaderSWCOptions","getParserOptions","nextDirname","path","dirname","require","resolve","nextDistPath","RegExp","escapeStringRegexp","nodeModulesPath","regeneratorRuntimePath","isTypeScriptFile","filename","endsWith","isCommonJSFile","shouldOutputCommonJs","test","jsConfig","rest","isTSFile","hasTsSyntax","enableDecorators","Boolean","compilerOptions","experimentalDecorators","syntax","dynamicImport","decorators","importAssertions","getBaseSWCOptions","jest","development","hasReactRefresh","globalWindow","esm","modularizeImports","swcPlugins","resolvedBaseUrl","swcCacheDir","serverComponents","serverReferenceHashSalt","bundleLayer","isDynamicIo","cacheHandlers","useCacheEnabled","isReactServerLayer","isWebpackServerOnlyLayer","isAppRouterPagesLayer","isWebpackAppPagesLayer","parserConfig","paths","emitDecoratorMetadata","useDefineForClassFields","plugins","filter","Array","isArray","map","name","options","jsc","baseUrl","externalHelpers","process","versions","pnp","parser","experimental","keepImportAttributes","emitAssertForImportAttributes","cacheRoot","transform","hidden","legacyDecorator","decoratorMetadata","react","importSource","jsxImportSource","emotion","runtime","pragmaFrag","throwIfNamespace","useBuiltins","refresh","optimizer","simplify","globals","typeofs","window","envs","NODE_ENV","regenerator","importPath","sourceMaps","undefined","removeConsole","reactRemoveProperties","Object","fromEntries","entries","mod","config","key","value","relay","styledJsx","getEmotionOptions","styledComponents","getStyledComponentsOptions","dynamicIoEnabled","serverActions","isDevelopment","hashSalt","cacheKinds","concat","keys","preferEsm","lintCodemodComments","debugFunctionName","styledComponentsConfig","displayName","emotionConfig","autoLabel","enabled","sourcemap","importMap","labelFormat","sourceMap","isServer","pagesDir","baseOptions","useCjsModules","env","targets","node","module","type","disableNextSsg","disablePageConfig","appDir","isPageFile","optimizeServerReact","optimizePackageImports","supportedBrowsers","relativeFilePathFromRoot","fontLoaders","cjsRequireOptimizer","packages","transforms","NextRequest","NextResponse","ImageResponse","userAgentFromString","userAgent","optimize_use_state","autoModularizeImports","isNodeModules","isAppBrowserLayer","WEBPACK_LAYERS","appPagesBrowser","moduleResolutionConfig","isServerCompiler","length","target"],"mappings":";;;;;;;;;;;;;;;;IA8RgBA,iBAAiB;eAAjBA;;IA6DAC,mBAAmB;eAAnBA;;IArTAC,gBAAgB;eAAhBA;;;6DAtCC;2BACqC;uBAQW;8BAC9B;;;;;;AAEnC,MAAMC,cAAcC,aAAI,CAACC,OAAO,CAACC,QAAQC,OAAO,CAAC;AAEjD,MAAMC,eAAe,IAAIC,OACvB,GAAGC,IAAAA,gCAAkB,EAACP,aAAa,2CAA2C,CAAC;AAGjF,MAAMQ,kBAAkB;AAExB,MAAMC,yBAAyBN,QAAQC,OAAO,CAC5C;AAGF,SAASM,iBAAiBC,QAAgB;IACxC,OAAOA,SAASC,QAAQ,CAAC,UAAUD,SAASC,QAAQ,CAAC;AACvD;AAEA,SAASC,eAAeF,QAAgB;IACtC,OAAOA,SAASC,QAAQ,CAAC;AAC3B;AAEA,qEAAqE;AACrE,mHAAmH;AACnH,SAASE,qBAAqBH,QAAgB;IAC5C,OAAOE,eAAeF,aAAaN,aAAaU,IAAI,CAACJ;AACvD;AAEO,SAASZ,iBAAiB,EAAEY,QAAQ,EAAEK,QAAQ,EAAE,GAAGC,MAAW;QAIjED;IAHF,MAAME,WAAWP,SAASC,QAAQ,CAAC;IACnC,MAAMO,cAAcT,iBAAiBC;IACrC,MAAMS,mBAAmBC,QACvBL,6BAAAA,4BAAAA,SAAUM,eAAe,qBAAzBN,0BAA2BO,sBAAsB;IAEnD,OAAO;QACL,GAAGN,IAAI;QACPO,QAAQL,cAAc,eAAe;QACrCM,eAAe;QACfC,YAAYN;QACZ,qKAAqK;QACrK,CAACD,cAAc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AkBjC;YAClBC;YACAU;YACAC;YACA,GAAIG,qBAAqBA,kBAAkBmB,MAAM,GAAG,IAChD;gBACE9B,KAAK;oBACHC,SAASU;gBACX;YACF,IACA,CAAC,CAAC;QACR;QACA,IAAI,CAACpF,QAAQyE,GAAG,EAAE;YAChB,6CAA6C;YAC7CzE,QAAQC,GAAG,CAACuG,MAAM,GAAG;QACvB;IACF;IAEA,6FAA6F;IAC7F,wFAAwF;IACxF,IAAIN,qBAAqBD,eAAe;YAQlCjG;QAPJA,QAAQ8E,cAAc,GAAG;QACzB9E,QAAQ+E,iBAAiB,GAAG;QAC5B/E,QAAQiF,UAAU,GAAG;QACrBjF,QAAQkF,mBAAmB,GAAG/C;QAC9BnC,QAAQuF,mBAAmB,GAAGpD;QAC9B,6FAA6F;QAC7F,uEAAuE;QACvE,KAAInC,2CAAAA,QAAQC,GAAG,CAACW,SAAS,CAACa,SAAS,CAACE,OAAO,qBAAvC3B,yCAAyC4B,OAAO,EAAE;YACpD,OAAO5B,QAAQC,GAAG,CAACW,SAAS,CAACa,SAAS,CAACE,OAAO,CAACC,OAAO,CAACC,MAAM;QAC/D;IACF;IAEA,OAAO7B;AACT"}
@@ -44,15 +44,13 @@ const _constants = require("../../../shared/lib/constants");
44
44
  const _getroutefromentrypoint = /*#__PURE__*/ _interop_require_default(require("../../../server/get-route-from-entrypoint"));
45
45
  const _nextdropclientpageplugin = require("./next-drop-client-page-plugin");
46
46
  const _utils = require("../../../shared/lib/router/utils");
47
- const _profilingplugin = require("./profiling-plugin");
48
- const _rspackprofilingplugin = require("./rspack-profiling-plugin");
49
47
  const _trace = require("../../../trace");
48
+ const _utils1 = require("../utils");
50
49
  function _interop_require_default(obj) {
51
50
  return obj && obj.__esModule ? obj : {
52
51
  default: obj
53
52
  };
54
53
  }
55
- const compilationSpans = process.env.NEXT_RSPACK ? _rspackprofilingplugin.compilationSpans : _profilingplugin.spans;
56
54
  const srcEmptySsgManifest = `self.__SSG_MANIFEST=new Set;self.__SSG_MANIFEST_CB&&self.__SSG_MANIFEST_CB()`;
57
55
  // nodejs: '/static/<build id>/low-priority.js'
58
56
  function buildNodejsLowPriorityPath(filename, buildId) {
@@ -93,7 +91,7 @@ function normalizeRewritesForBuildManifest(rewrites) {
93
91
  };
94
92
  }
95
93
  function generateClientManifest(assetMap, rewrites, clientRouterFilters, compiler, compilation) {
96
- const compilationSpan = compilation ? compilationSpans.get(compilation) : compiler ? compilationSpans.get(compiler) : new _trace.Span({
94
+ const compilationSpan = compilation ? (0, _utils1.getCompilationSpan)(compilation) : compiler ? (0, _utils1.getCompilationSpan)(compiler) : new _trace.Span({
97
95
  name: 'client-manifest'
98
96
  });
99
97
  const genClientManifestSpan = compilationSpan == null ? void 0 : compilationSpan.traceChild('NextJsBuildManifest-generateClientManifest');
@@ -156,7 +154,7 @@ class BuildManifestPlugin {
156
154
  this.rewrites.fallback = options.rewrites.fallback.map(processRoute);
157
155
  }
158
156
  createAssets(compiler, compilation) {
159
- const compilationSpan = compilationSpans.get(compilation) ?? compilationSpans.get(compiler);
157
+ const compilationSpan = (0, _utils1.getCompilationSpan)(compilation) ?? (0, _utils1.getCompilationSpan)(compiler);
160
158
  if (!compilationSpan) {
161
159
  throw Object.defineProperty(new Error('No span found for compilation'), "__NEXT_ERROR_CODE", {
162
160
  value: "E646",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/build/webpack/plugins/build-manifest-plugin.ts"],"sourcesContent":["import type { BloomFilter } from '../../../shared/lib/bloom-filter'\nimport type { Rewrite, CustomRoutes } from '../../../lib/load-custom-routes'\nimport devalue from 'next/dist/compiled/devalue'\nimport { webpack, sources } from 'next/dist/compiled/webpack/webpack'\nimport {\n BUILD_MANIFEST,\n MIDDLEWARE_BUILD_MANIFEST,\n CLIENT_STATIC_FILES_PATH,\n CLIENT_STATIC_FILES_RUNTIME_MAIN,\n CLIENT_STATIC_FILES_RUNTIME_MAIN_APP,\n CLIENT_STATIC_FILES_RUNTIME_POLYFILLS_SYMBOL,\n CLIENT_STATIC_FILES_RUNTIME_REACT_REFRESH,\n CLIENT_STATIC_FILES_RUNTIME_AMP,\n SYSTEM_ENTRYPOINTS,\n} from '../../../shared/lib/constants'\nimport type { BuildManifest } from '../../../server/get-page-files'\nimport getRouteFromEntrypoint from '../../../server/get-route-from-entrypoint'\nimport { ampFirstEntryNamesMap } from './next-drop-client-page-plugin'\nimport { getSortedRoutes } from '../../../shared/lib/router/utils'\nimport { spans as webpackSpans } from './profiling-plugin'\nimport { compilationSpans as rspackSpans } from './rspack-profiling-plugin'\nimport { Span } from '../../../trace'\n\nconst compilationSpans = process.env.NEXT_RSPACK ? rspackSpans : webpackSpans\n\ntype DeepMutable<T> = { -readonly [P in keyof T]: DeepMutable<T[P]> }\n\nexport type ClientBuildManifest = {\n [key: string]: string[]\n}\n\n// Add the runtime ssg manifest file as a lazy-loaded file dependency.\n// We also stub this file out for development mode (when it is not\n// generated).\nexport const srcEmptySsgManifest = `self.__SSG_MANIFEST=new Set;self.__SSG_MANIFEST_CB&&self.__SSG_MANIFEST_CB()`\n\n// nodejs: '/static/<build id>/low-priority.js'\nfunction buildNodejsLowPriorityPath(filename: string, buildId: string) {\n return `${CLIENT_STATIC_FILES_PATH}/${buildId}/${filename}`\n}\n\nfunction createEdgeRuntimeManifest(originAssetMap: BuildManifest): string {\n const manifestFilenames = ['_buildManifest.js', '_ssgManifest.js']\n\n const assetMap: BuildManifest = {\n ...originAssetMap,\n lowPriorityFiles: [],\n }\n\n // we use globalThis here because middleware can be node\n // which doesn't have \"self\"\n const manifestDefCode = `globalThis.__BUILD_MANIFEST = ${JSON.stringify(\n assetMap,\n null,\n 2\n )};\\n`\n // edge lowPriorityFiles item: '\"/static/\" + process.env.__NEXT_BUILD_ID + \"/low-priority.js\"'.\n // Since lowPriorityFiles is not fixed and relying on `process.env.__NEXT_BUILD_ID`, we'll produce code creating it dynamically.\n const lowPriorityFilesCode =\n `globalThis.__BUILD_MANIFEST.lowPriorityFiles = [\\n` +\n manifestFilenames\n .map((filename) => {\n return `\"/static/\" + process.env.__NEXT_BUILD_ID + \"/${filename}\",\\n`\n })\n .join(',') +\n `\\n];`\n\n return manifestDefCode + lowPriorityFilesCode\n}\n\nfunction normalizeRewrite(item: {\n source: string\n destination: string\n has?: any\n}): CustomRoutes['rewrites']['beforeFiles'][0] {\n return {\n has: item.has,\n source: item.source,\n destination: item.destination,\n }\n}\n\nexport function normalizeRewritesForBuildManifest(\n rewrites: CustomRoutes['rewrites']\n): CustomRoutes['rewrites'] {\n return {\n afterFiles: rewrites.afterFiles\n ?.map(processRoute)\n ?.map((item) => normalizeRewrite(item)),\n beforeFiles: rewrites.beforeFiles\n ?.map(processRoute)\n ?.map((item) => normalizeRewrite(item)),\n fallback: rewrites.fallback\n ?.map(processRoute)\n ?.map((item) => normalizeRewrite(item)),\n }\n}\n\n// This function takes the asset map generated in BuildManifestPlugin and creates a\n// reduced version to send to the client.\nexport function generateClientManifest(\n assetMap: BuildManifest,\n rewrites: CustomRoutes['rewrites'],\n clientRouterFilters?: {\n staticFilter: ReturnType<BloomFilter['export']>\n dynamicFilter: ReturnType<BloomFilter['export']>\n },\n compiler?: any,\n compilation?: any\n): string | undefined {\n const compilationSpan = compilation\n ? compilationSpans.get(compilation)\n : compiler\n ? compilationSpans.get(compiler)\n : new Span({ name: 'client-manifest' })\n\n const genClientManifestSpan = compilationSpan?.traceChild(\n 'NextJsBuildManifest-generateClientManifest'\n )\n\n return genClientManifestSpan?.traceFn(() => {\n const clientManifest: ClientBuildManifest = {\n __rewrites: normalizeRewritesForBuildManifest(rewrites) as any,\n __routerFilterStatic: clientRouterFilters?.staticFilter as any,\n __routerFilterDynamic: clientRouterFilters?.dynamicFilter as any,\n }\n const appDependencies = new Set(assetMap.pages['/_app'])\n const sortedPageKeys = getSortedRoutes(Object.keys(assetMap.pages))\n\n sortedPageKeys.forEach((page) => {\n const dependencies = assetMap.pages[page]\n\n if (page === '/_app') return\n // Filter out dependencies in the _app entry, because those will have already\n // been loaded by the client prior to a navigation event\n const filteredDeps = dependencies.filter(\n (dep) => !appDependencies.has(dep)\n )\n\n // The manifest can omit the page if it has no requirements\n if (filteredDeps.length) {\n clientManifest[page] = filteredDeps\n }\n })\n // provide the sorted pages as an array so we don't rely on the object's keys\n // being in order and we don't slow down look-up time for page assets\n clientManifest.sortedPages = sortedPageKeys\n\n return devalue(clientManifest)\n })\n}\n\nexport function getEntrypointFiles(entrypoint: any): string[] {\n return (\n entrypoint\n ?.getFiles()\n .filter((file: string) => {\n // We don't want to include `.hot-update.js` files into the initial page\n return /(?<!\\.hot-update)\\.(js|css)($|\\?)/.test(file)\n })\n .map((file: string) => file.replace(/\\\\/g, '/')) ?? []\n )\n}\n\nexport const processRoute = (r: Rewrite) => {\n const rewrite = { ...r }\n\n // omit external rewrite destinations since these aren't\n // handled client-side\n if (!rewrite?.destination?.startsWith('/')) {\n delete (rewrite as any).destination\n }\n return rewrite\n}\n\n// This plugin creates a build-manifest.json for all assets that are being output\n// It has a mapping of \"entry\" filename to real filename. Because the real filename can be hashed in production\nexport default class BuildManifestPlugin {\n private buildId: string\n private rewrites: CustomRoutes['rewrites']\n private isDevFallback: boolean\n private appDirEnabled: boolean\n private clientRouterFilters?: Parameters<typeof generateClientManifest>[2]\n\n constructor(options: {\n buildId: string\n rewrites: CustomRoutes['rewrites']\n isDevFallback?: boolean\n appDirEnabled: boolean\n clientRouterFilters?: Parameters<typeof generateClientManifest>[2]\n }) {\n this.buildId = options.buildId\n this.isDevFallback = !!options.isDevFallback\n this.rewrites = {\n beforeFiles: [],\n afterFiles: [],\n fallback: [],\n }\n this.appDirEnabled = options.appDirEnabled\n this.clientRouterFilters = options.clientRouterFilters\n this.rewrites.beforeFiles = options.rewrites.beforeFiles.map(processRoute)\n this.rewrites.afterFiles = options.rewrites.afterFiles.map(processRoute)\n this.rewrites.fallback = options.rewrites.fallback.map(processRoute)\n }\n\n createAssets(compiler: any, compilation: any) {\n const compilationSpan =\n compilationSpans.get(compilation) ?? compilationSpans.get(compiler)\n if (!compilationSpan) {\n throw new Error('No span found for compilation')\n }\n\n const createAssetsSpan = compilationSpan.traceChild(\n 'NextJsBuildManifest-createassets'\n )\n\n return createAssetsSpan.traceFn(() => {\n const entrypoints: Map<string, any> = compilation.entrypoints\n const assetMap: DeepMutable<BuildManifest> = {\n polyfillFiles: [],\n devFiles: [],\n ampDevFiles: [],\n lowPriorityFiles: [],\n rootMainFiles: [],\n rootMainFilesTree: {},\n pages: { '/_app': [] },\n ampFirstPages: [],\n }\n\n const ampFirstEntryNames = ampFirstEntryNamesMap.get(compilation)\n if (ampFirstEntryNames) {\n for (const entryName of ampFirstEntryNames) {\n const pagePath = getRouteFromEntrypoint(entryName)\n if (!pagePath) {\n continue\n }\n\n assetMap.ampFirstPages.push(pagePath)\n }\n }\n\n const mainFiles = new Set(\n getEntrypointFiles(entrypoints.get(CLIENT_STATIC_FILES_RUNTIME_MAIN))\n )\n\n if (this.appDirEnabled) {\n assetMap.rootMainFiles = [\n ...new Set(\n getEntrypointFiles(\n entrypoints.get(CLIENT_STATIC_FILES_RUNTIME_MAIN_APP)\n )\n ),\n ]\n }\n\n const compilationAssets: {\n name: string\n source: typeof sources.RawSource\n info: object\n }[] = compilation.getAssets()\n\n assetMap.polyfillFiles = compilationAssets\n .filter((p) => {\n // Ensure only .js files are passed through\n if (!p.name.endsWith('.js')) {\n return false\n }\n\n return (\n p.info && CLIENT_STATIC_FILES_RUNTIME_POLYFILLS_SYMBOL in p.info\n )\n })\n .map((v) => v.name)\n\n assetMap.devFiles = getEntrypointFiles(\n entrypoints.get(CLIENT_STATIC_FILES_RUNTIME_REACT_REFRESH)\n ).filter((file) => !mainFiles.has(file))\n\n assetMap.ampDevFiles = getEntrypointFiles(\n entrypoints.get(CLIENT_STATIC_FILES_RUNTIME_AMP)\n )\n\n for (const entrypoint of compilation.entrypoints.values()) {\n if (SYSTEM_ENTRYPOINTS.has(entrypoint.name)) continue\n const pagePath = getRouteFromEntrypoint(entrypoint.name)\n\n if (!pagePath) {\n continue\n }\n\n const filesForPage = getEntrypointFiles(entrypoint)\n\n assetMap.pages[pagePath] = [...new Set([...mainFiles, ...filesForPage])]\n }\n\n if (!this.isDevFallback) {\n // Add the runtime build manifest file (generated later in this file)\n // as a dependency for the app. If the flag is false, the file won't be\n // downloaded by the client.\n const buildManifestPath = buildNodejsLowPriorityPath(\n '_buildManifest.js',\n this.buildId\n )\n const ssgManifestPath = buildNodejsLowPriorityPath(\n '_ssgManifest.js',\n this.buildId\n )\n assetMap.lowPriorityFiles.push(buildManifestPath, ssgManifestPath)\n compilation.emitAsset(\n ssgManifestPath,\n new sources.RawSource(srcEmptySsgManifest)\n )\n }\n\n assetMap.pages = Object.keys(assetMap.pages)\n .sort()\n .reduce(\n // eslint-disable-next-line\n (a, c) => ((a[c] = assetMap.pages[c]), a),\n {} as typeof assetMap.pages\n )\n\n let buildManifestName = BUILD_MANIFEST\n\n if (this.isDevFallback) {\n buildManifestName = `fallback-${BUILD_MANIFEST}`\n }\n\n compilation.emitAsset(\n buildManifestName,\n new sources.RawSource(JSON.stringify(assetMap, null, 2))\n )\n\n compilation.emitAsset(\n `server/${MIDDLEWARE_BUILD_MANIFEST}.js`,\n new sources.RawSource(`${createEdgeRuntimeManifest(assetMap)}`)\n )\n\n if (!this.isDevFallback) {\n compilation.emitAsset(\n `${CLIENT_STATIC_FILES_PATH}/${this.buildId}/_buildManifest.js`,\n new sources.RawSource(\n `self.__BUILD_MANIFEST = ${generateClientManifest(\n assetMap,\n this.rewrites,\n this.clientRouterFilters,\n compiler,\n compilation\n )};self.__BUILD_MANIFEST_CB && self.__BUILD_MANIFEST_CB()`\n )\n )\n }\n })\n }\n\n apply(compiler: webpack.Compiler) {\n compiler.hooks.make.tap('NextJsBuildManifest', (compilation: any) => {\n compilation.hooks.processAssets.tap(\n {\n name: 'NextJsBuildManifest',\n stage: webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,\n },\n () => {\n this.createAssets(compiler, compilation)\n }\n )\n })\n return\n }\n}\n"],"names":["BuildManifestPlugin","generateClientManifest","getEntrypointFiles","normalizeRewritesForBuildManifest","processRoute","srcEmptySsgManifest","compilationSpans","process","env","NEXT_RSPACK","rspackSpans","webpackSpans","buildNodejsLowPriorityPath","filename","buildId","CLIENT_STATIC_FILES_PATH","createEdgeRuntimeManifest","originAssetMap","manifestFilenames","assetMap","lowPriorityFiles","manifestDefCode","JSON","stringify","lowPriorityFilesCode","map","join","normalizeRewrite","item","has","source","destination","rewrites","afterFiles","beforeFiles","fallback","clientRouterFilters","compiler","compilation","compilationSpan","get","Span","name","genClientManifestSpan","traceChild","traceFn","clientManifest","__rewrites","__routerFilterStatic","staticFilter","__routerFilterDynamic","dynamicFilter","appDependencies","Set","pages","sortedPageKeys","getSortedRoutes","Object","keys","forEach","page","dependencies","filteredDeps","filter","dep","length","sortedPages","devalue","entrypoint","getFiles","file","test","replace","r","rewrite","startsWith","constructor","options","isDevFallback","appDirEnabled","createAssets","Error","createAssetsSpan","entrypoints","polyfillFiles","devFiles","ampDevFiles","rootMainFiles","rootMainFilesTree","ampFirstPages","ampFirstEntryNames","ampFirstEntryNamesMap","entryName","pagePath","getRouteFromEntrypoint","push","mainFiles","CLIENT_STATIC_FILES_RUNTIME_MAIN","CLIENT_STATIC_FILES_RUNTIME_MAIN_APP","compilationAssets","getAssets","p","endsWith","info","CLIENT_STATIC_FILES_RUNTIME_POLYFILLS_SYMBOL","v","CLIENT_STATIC_FILES_RUNTIME_REACT_REFRESH","CLIENT_STATIC_FILES_RUNTIME_AMP","values","SYSTEM_ENTRYPOINTS","filesForPage","buildManifestPath","ssgManifestPath","emitAsset","sources","RawSource","sort","reduce","a","c","buildManifestName","BUILD_MANIFEST","MIDDLEWARE_BUILD_MANIFEST","apply","hooks","make","tap","processAssets","stage","webpack","Compilation","PROCESS_ASSETS_STAGE_ADDITIONS"],"mappings":";;;;;;;;;;;;;;;;;;;IA+KA,iFAAiF;IACjF,+GAA+G;IAC/G,OAgMC;eAhMo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C,CAACC,EAAE,GAAGpG,SAASmC,KAAK,CAACiE,EAAE,EAAGD,CAAAA,GACvC,CAAC;YAGL,IAAIE,oBAAoBC,yBAAc;YAEtC,IAAI,IAAI,CAAC3C,aAAa,EAAE;gBACtB0C,oBAAoB,CAAC,SAAS,EAAEC,yBAAc,EAAE;YAClD;YAEAnF,YAAY2E,SAAS,CACnBO,mBACA,IAAIN,gBAAO,CAACC,SAAS,CAAC7F,KAAKC,SAAS,CAACJ,UAAU,MAAM;YAGvDmB,YAAY2E,SAAS,CACnB,CAAC,OAAO,EAAES,oCAAyB,CAAC,GAAG,CAAC,EACxC,IAAIR,gBAAO,CAACC,SAAS,CAAC,GAAGnG,0BAA0BG,WAAW;YAGhE,IAAI,CAAC,IAAI,CAAC2D,aAAa,EAAE;gBACvBxC,YAAY2E,SAAS,CACnB,GAAGlG,mCAAwB,CAAC,CAAC,EAAE,IAAI,CAACD,OAAO,CAAC,kBAAkB,CAAC,EAC/D,IAAIoG,gBAAO,CAACC,SAAS,CACnB,CAAC,wBAAwB,EAAElH,uBACzBkB,UACA,IAAI,CAACa,QAAQ,EACb,IAAI,CAACI,mBAAmB,EACxBC,UACAC,aACA,uDAAuD,CAAC;YAGhE;QACF;IACF;IAEAqF,MAAMtF,QAA0B,EAAE;QAChCA,SAASuF,KAAK,CAACC,IAAI,CAACC,GAAG,CAAC,uBAAuB,CAACxF;YAC9CA,YAAYsF,KAAK,CAACG,aAAa,CAACD,GAAG,CACjC;gBACEpF,MAAM;gBACNsF,OAAOC,gBAAO,CAACC,WAAW,CAACC,8BAA8B;YAC3D,GACA;gBACE,IAAI,CAACnD,YAAY,CAAC3C,UAAUC;YAC9B;QAEJ;QACA;IACF;AACF"}
1
+ {"version":3,"sources":["../../../../src/build/webpack/plugins/build-manifest-plugin.ts"],"sourcesContent":["import type { BloomFilter } from '../../../shared/lib/bloom-filter'\nimport type { Rewrite, CustomRoutes } from '../../../lib/load-custom-routes'\nimport devalue from 'next/dist/compiled/devalue'\nimport { webpack, sources } from 'next/dist/compiled/webpack/webpack'\nimport {\n BUILD_MANIFEST,\n MIDDLEWARE_BUILD_MANIFEST,\n CLIENT_STATIC_FILES_PATH,\n CLIENT_STATIC_FILES_RUNTIME_MAIN,\n CLIENT_STATIC_FILES_RUNTIME_MAIN_APP,\n CLIENT_STATIC_FILES_RUNTIME_POLYFILLS_SYMBOL,\n CLIENT_STATIC_FILES_RUNTIME_REACT_REFRESH,\n CLIENT_STATIC_FILES_RUNTIME_AMP,\n SYSTEM_ENTRYPOINTS,\n} from '../../../shared/lib/constants'\nimport type { BuildManifest } from '../../../server/get-page-files'\nimport getRouteFromEntrypoint from '../../../server/get-route-from-entrypoint'\nimport { ampFirstEntryNamesMap } from './next-drop-client-page-plugin'\nimport { getSortedRoutes } from '../../../shared/lib/router/utils'\nimport { Span } from '../../../trace'\nimport { getCompilationSpan } from '../utils'\n\ntype DeepMutable<T> = { -readonly [P in keyof T]: DeepMutable<T[P]> }\n\nexport type ClientBuildManifest = {\n [key: string]: string[]\n}\n\n// Add the runtime ssg manifest file as a lazy-loaded file dependency.\n// We also stub this file out for development mode (when it is not\n// generated).\nexport const srcEmptySsgManifest = `self.__SSG_MANIFEST=new Set;self.__SSG_MANIFEST_CB&&self.__SSG_MANIFEST_CB()`\n\n// nodejs: '/static/<build id>/low-priority.js'\nfunction buildNodejsLowPriorityPath(filename: string, buildId: string) {\n return `${CLIENT_STATIC_FILES_PATH}/${buildId}/${filename}`\n}\n\nfunction createEdgeRuntimeManifest(originAssetMap: BuildManifest): string {\n const manifestFilenames = ['_buildManifest.js', '_ssgManifest.js']\n\n const assetMap: BuildManifest = {\n ...originAssetMap,\n lowPriorityFiles: [],\n }\n\n // we use globalThis here because middleware can be node\n // which doesn't have \"self\"\n const manifestDefCode = `globalThis.__BUILD_MANIFEST = ${JSON.stringify(\n assetMap,\n null,\n 2\n )};\\n`\n // edge lowPriorityFiles item: '\"/static/\" + process.env.__NEXT_BUILD_ID + \"/low-priority.js\"'.\n // Since lowPriorityFiles is not fixed and relying on `process.env.__NEXT_BUILD_ID`, we'll produce code creating it dynamically.\n const lowPriorityFilesCode =\n `globalThis.__BUILD_MANIFEST.lowPriorityFiles = [\\n` +\n manifestFilenames\n .map((filename) => {\n return `\"/static/\" + process.env.__NEXT_BUILD_ID + \"/${filename}\",\\n`\n })\n .join(',') +\n `\\n];`\n\n return manifestDefCode + lowPriorityFilesCode\n}\n\nfunction normalizeRewrite(item: {\n source: string\n destination: string\n has?: any\n}): CustomRoutes['rewrites']['beforeFiles'][0] {\n return {\n has: item.has,\n source: item.source,\n destination: item.destination,\n }\n}\n\nexport function normalizeRewritesForBuildManifest(\n rewrites: CustomRoutes['rewrites']\n): CustomRoutes['rewrites'] {\n return {\n afterFiles: rewrites.afterFiles\n ?.map(processRoute)\n ?.map((item) => normalizeRewrite(item)),\n beforeFiles: rewrites.beforeFiles\n ?.map(processRoute)\n ?.map((item) => normalizeRewrite(item)),\n fallback: rewrites.fallback\n ?.map(processRoute)\n ?.map((item) => normalizeRewrite(item)),\n }\n}\n\n// This function takes the asset map generated in BuildManifestPlugin and creates a\n// reduced version to send to the client.\nexport function generateClientManifest(\n assetMap: BuildManifest,\n rewrites: CustomRoutes['rewrites'],\n clientRouterFilters?: {\n staticFilter: ReturnType<BloomFilter['export']>\n dynamicFilter: ReturnType<BloomFilter['export']>\n },\n compiler?: any,\n compilation?: any\n): string | undefined {\n const compilationSpan = compilation\n ? getCompilationSpan(compilation)\n : compiler\n ? getCompilationSpan(compiler)\n : new Span({ name: 'client-manifest' })\n\n const genClientManifestSpan = compilationSpan?.traceChild(\n 'NextJsBuildManifest-generateClientManifest'\n )\n\n return genClientManifestSpan?.traceFn(() => {\n const clientManifest: ClientBuildManifest = {\n __rewrites: normalizeRewritesForBuildManifest(rewrites) as any,\n __routerFilterStatic: clientRouterFilters?.staticFilter as any,\n __routerFilterDynamic: clientRouterFilters?.dynamicFilter as any,\n }\n const appDependencies = new Set(assetMap.pages['/_app'])\n const sortedPageKeys = getSortedRoutes(Object.keys(assetMap.pages))\n\n sortedPageKeys.forEach((page) => {\n const dependencies = assetMap.pages[page]\n\n if (page === '/_app') return\n // Filter out dependencies in the _app entry, because those will have already\n // been loaded by the client prior to a navigation event\n const filteredDeps = dependencies.filter(\n (dep) => !appDependencies.has(dep)\n )\n\n // The manifest can omit the page if it has no requirements\n if (filteredDeps.length) {\n clientManifest[page] = filteredDeps\n }\n })\n // provide the sorted pages as an array so we don't rely on the object's keys\n // being in order and we don't slow down look-up time for page assets\n clientManifest.sortedPages = sortedPageKeys\n\n return devalue(clientManifest)\n })\n}\n\nexport function getEntrypointFiles(entrypoint: any): string[] {\n return (\n entrypoint\n ?.getFiles()\n .filter((file: string) => {\n // We don't want to include `.hot-update.js` files into the initial page\n return /(?<!\\.hot-update)\\.(js|css)($|\\?)/.test(file)\n })\n .map((file: string) => file.replace(/\\\\/g, '/')) ?? []\n )\n}\n\nexport const processRoute = (r: Rewrite) => {\n const rewrite = { ...r }\n\n // omit external rewrite destinations since these aren't\n // handled client-side\n if (!rewrite?.destination?.startsWith('/')) {\n delete (rewrite as any).destination\n }\n return rewrite\n}\n\n// This plugin creates a build-manifest.json for all assets that are being output\n// It has a mapping of \"entry\" filename to real filename. Because the real filename can be hashed in production\nexport default class BuildManifestPlugin {\n private buildId: string\n private rewrites: CustomRoutes['rewrites']\n private isDevFallback: boolean\n private appDirEnabled: boolean\n private clientRouterFilters?: Parameters<typeof generateClientManifest>[2]\n\n constructor(options: {\n buildId: string\n rewrites: CustomRoutes['rewrites']\n isDevFallback?: boolean\n appDirEnabled: boolean\n clientRouterFilters?: Parameters<typeof generateClientManifest>[2]\n }) {\n this.buildId = options.buildId\n this.isDevFallback = !!options.isDevFallback\n this.rewrites = {\n beforeFiles: [],\n afterFiles: [],\n fallback: [],\n }\n this.appDirEnabled = options.appDirEnabled\n this.clientRouterFilters = options.clientRouterFilters\n this.rewrites.beforeFiles = options.rewrites.beforeFiles.map(processRoute)\n this.rewrites.afterFiles = options.rewrites.afterFiles.map(processRoute)\n this.rewrites.fallback = options.rewrites.fallback.map(processRoute)\n }\n\n createAssets(compiler: any, compilation: any) {\n const compilationSpan =\n getCompilationSpan(compilation) ?? getCompilationSpan(compiler)\n if (!compilationSpan) {\n throw new Error('No span found for compilation')\n }\n\n const createAssetsSpan = compilationSpan.traceChild(\n 'NextJsBuildManifest-createassets'\n )\n\n return createAssetsSpan.traceFn(() => {\n const entrypoints: Map<string, any> = compilation.entrypoints\n const assetMap: DeepMutable<BuildManifest> = {\n polyfillFiles: [],\n devFiles: [],\n ampDevFiles: [],\n lowPriorityFiles: [],\n rootMainFiles: [],\n rootMainFilesTree: {},\n pages: { '/_app': [] },\n ampFirstPages: [],\n }\n\n const ampFirstEntryNames = ampFirstEntryNamesMap.get(compilation)\n if (ampFirstEntryNames) {\n for (const entryName of ampFirstEntryNames) {\n const pagePath = getRouteFromEntrypoint(entryName)\n if (!pagePath) {\n continue\n }\n\n assetMap.ampFirstPages.push(pagePath)\n }\n }\n\n const mainFiles = new Set(\n getEntrypointFiles(entrypoints.get(CLIENT_STATIC_FILES_RUNTIME_MAIN))\n )\n\n if (this.appDirEnabled) {\n assetMap.rootMainFiles = [\n ...new Set(\n getEntrypointFiles(\n entrypoints.get(CLIENT_STATIC_FILES_RUNTIME_MAIN_APP)\n )\n ),\n ]\n }\n\n const compilationAssets: {\n name: string\n source: typeof sources.RawSource\n info: object\n }[] = compilation.getAssets()\n\n assetMap.polyfillFiles = compilationAssets\n .filter((p) => {\n // Ensure only .js files are passed through\n if (!p.name.endsWith('.js')) {\n return false\n }\n\n return (\n p.info && CLIENT_STATIC_FILES_RUNTIME_POLYFILLS_SYMBOL in p.info\n )\n })\n .map((v) => v.name)\n\n assetMap.devFiles = getEntrypointFiles(\n entrypoints.get(CLIENT_STATIC_FILES_RUNTIME_REACT_REFRESH)\n ).filter((file) => !mainFiles.has(file))\n\n assetMap.ampDevFiles = getEntrypointFiles(\n entrypoints.get(CLIENT_STATIC_FILES_RUNTIME_AMP)\n )\n\n for (const entrypoint of compilation.entrypoints.values()) {\n if (SYSTEM_ENTRYPOINTS.has(entrypoint.name)) continue\n const pagePath = getRouteFromEntrypoint(entrypoint.name)\n\n if (!pagePath) {\n continue\n }\n\n const filesForPage = getEntrypointFiles(entrypoint)\n\n assetMap.pages[pagePath] = [...new Set([...mainFiles, ...filesForPage])]\n }\n\n if (!this.isDevFallback) {\n // Add the runtime build manifest file (generated later in this file)\n // as a dependency for the app. If the flag is false, the file won't be\n // downloaded by the client.\n const buildManifestPath = buildNodejsLowPriorityPath(\n '_buildManifest.js',\n this.buildId\n )\n const ssgManifestPath = buildNodejsLowPriorityPath(\n '_ssgManifest.js',\n this.buildId\n )\n assetMap.lowPriorityFiles.push(buildManifestPath, ssgManifestPath)\n compilation.emitAsset(\n ssgManifestPath,\n new sources.RawSource(srcEmptySsgManifest)\n )\n }\n\n assetMap.pages = Object.keys(assetMap.pages)\n .sort()\n .reduce(\n // eslint-disable-next-line\n (a, c) => ((a[c] = assetMap.pages[c]), a),\n {} as typeof assetMap.pages\n )\n\n let buildManifestName = BUILD_MANIFEST\n\n if (this.isDevFallback) {\n buildManifestName = `fallback-${BUILD_MANIFEST}`\n }\n\n compilation.emitAsset(\n buildManifestName,\n new sources.RawSource(JSON.stringify(assetMap, null, 2))\n )\n\n compilation.emitAsset(\n `server/${MIDDLEWARE_BUILD_MANIFEST}.js`,\n new sources.RawSource(`${createEdgeRuntimeManifest(assetMap)}`)\n )\n\n if (!this.isDevFallback) {\n compilation.emitAsset(\n `${CLIENT_STATIC_FILES_PATH}/${this.buildId}/_buildManifest.js`,\n new sources.RawSource(\n `self.__BUILD_MANIFEST = ${generateClientManifest(\n assetMap,\n this.rewrites,\n this.clientRouterFilters,\n compiler,\n compilation\n )};self.__BUILD_MANIFEST_CB && self.__BUILD_MANIFEST_CB()`\n )\n )\n }\n })\n }\n\n apply(compiler: webpack.Compiler) {\n compiler.hooks.make.tap('NextJsBuildManifest', (compilation: any) => {\n compilation.hooks.processAssets.tap(\n {\n name: 'NextJsBuildManifest',\n stage: webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,\n },\n () => {\n this.createAssets(compiler, compilation)\n }\n )\n })\n return\n }\n}\n"],"names":["BuildManifestPlugin","generateClientManifest","getEntrypointFiles","normalizeRewritesForBuildManifest","processRoute","srcEmptySsgManifest","buildNodejsLowPriorityPath","filename","buildId","CLIENT_STATIC_FILES_PATH","createEdgeRuntimeManifest","originAssetMap","manifestFilenames","assetMap","lowPriorityFiles","manifestDefCode","JSON","stringify","lowPriorityFilesCode","map","join","normalizeRewrite","item","has","source","destination","rewrites","afterFiles","beforeFiles","fallback","clientRouterFilters","compiler","compilation","compilationSpan","getCompilationSpan","Span","name","genClientManifestSpan","traceChild","traceFn","clientManifest","__rewrites","__routerFilterStatic","staticFilter","__routerFilterDynamic","dynamicFilter","appDependencies","Set","pages","sortedPageKeys","getSortedRoutes","Object","keys","forEach","page","dependencies","filteredDeps","filter","dep","length","sortedPages","devalue","entrypoint","getFiles","file","test","replace","r","rewrite","startsWith","constructor","options","isDevFallback","appDirEnabled","createAssets","Error","createAssetsSpan","entrypoints","polyfillFiles","devFiles","ampDevFiles","rootMainFiles","rootMainFilesTree","ampFirstPages","ampFirstEntryNames","ampFirstEntryNamesMap","get","entryName","pagePath","getRouteFromEntrypoint","push","mainFiles","CLIENT_STATIC_FILES_RUNTIME_MAIN","CLIENT_STATIC_FILES_RUNTIME_MAIN_APP","compilationAssets","getAssets","p","endsWith","info","CLIENT_STATIC_FILES_RUNTIME_POLYFILLS_SYMBOL","v","CLIENT_STATIC_FILES_RUNTIME_REACT_REFRESH","CLIENT_STATIC_FILES_RUNTIME_AMP","values","SYSTEM_ENTRYPOINTS","filesForPage","buildManifestPath","ssgManifestPath","emitAsset","sources","RawSource","sort","reduce","a","c","buildManifestName","BUILD_MANIFEST","MIDDLEWARE_BUILD_MANIFEST","apply","hooks","make","tap","processAssets","stage","webpack","Compilation","PROCES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E,GAAGrG,SAASmC,KAAK,CAACkE,EAAE,EAAGD,CAAAA,GACvC,CAAC;YAGL,IAAIE,oBAAoBC,yBAAc;YAEtC,IAAI,IAAI,CAAC5C,aAAa,EAAE;gBACtB2C,oBAAoB,CAAC,SAAS,EAAEC,yBAAc,EAAE;YAClD;YAEApF,YAAY4E,SAAS,CACnBO,mBACA,IAAIN,gBAAO,CAACC,SAAS,CAAC9F,KAAKC,SAAS,CAACJ,UAAU,MAAM;YAGvDmB,YAAY4E,SAAS,CACnB,CAAC,OAAO,EAAES,oCAAyB,CAAC,GAAG,CAAC,EACxC,IAAIR,gBAAO,CAACC,SAAS,CAAC,GAAGpG,0BAA0BG,WAAW;YAGhE,IAAI,CAAC,IAAI,CAAC2D,aAAa,EAAE;gBACvBxC,YAAY4E,SAAS,CACnB,GAAGnG,mCAAwB,CAAC,CAAC,EAAE,IAAI,CAACD,OAAO,CAAC,kBAAkB,CAAC,EAC/D,IAAIqG,gBAAO,CAACC,SAAS,CACnB,CAAC,wBAAwB,EAAE7G,uBACzBY,UACA,IAAI,CAACa,QAAQ,EACb,IAAI,CAACI,mBAAmB,EACxBC,UACAC,aACA,uDAAuD,CAAC;YAGhE;QACF;IACF;IAEAsF,MAAMvF,QAA0B,EAAE;QAChCA,SAASwF,KAAK,CAACC,IAAI,CAACC,GAAG,CAAC,uBAAuB,CAACzF;YAC9CA,YAAYuF,KAAK,CAACG,aAAa,CAACD,GAAG,CACjC;gBACErF,MAAM;gBACNuF,OAAOC,gBAAO,CAACC,WAAW,CAACC,8BAA8B;YAC3D,GACA;gBACE,IAAI,CAACpD,YAAY,CAAC3C,UAAUC;YAC9B;QAEJ;QACA;IACF;AACF"}
@@ -12,7 +12,7 @@ const _cssnanosimple = /*#__PURE__*/ _interop_require_default(require("next/dist
12
12
  const _postcssscss = /*#__PURE__*/ _interop_require_default(require("next/dist/compiled/postcss-scss"));
13
13
  const _postcss = /*#__PURE__*/ _interop_require_default(require("postcss"));
14
14
  const _webpack = require("next/dist/compiled/webpack/webpack");
15
- const _profilingplugin = require("./profiling-plugin");
15
+ const _utils = require("../utils");
16
16
  function _interop_require_default(obj) {
17
17
  return obj && obj.__esModule ? obj : {
18
18
  default: obj
@@ -62,7 +62,7 @@ class CssMinimizerPlugin {
62
62
  name: 'CssMinimizerPlugin',
63
63
  stage: _webpack.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE
64
64
  }, async (assets)=>{
65
- const compilationSpan = _profilingplugin.spans.get(compilation) || _profilingplugin.spans.get(compiler);
65
+ const compilationSpan = (0, _utils.getCompilationSpan)(compilation) || (0, _utils.getCompilationSpan)(compiler);
66
66
  const cssMinimizerSpan = compilationSpan.traceChild('css-minimizer-plugin');
67
67
  return cssMinimizerSpan.traceAsyncFn(async ()=>{
68
68
  const files = Object.keys(assets);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/build/webpack/plugins/css-minimizer-plugin.ts"],"sourcesContent":["import cssnanoSimple from 'next/dist/compiled/cssnano-simple'\nimport postcssScss from 'next/dist/compiled/postcss-scss'\nimport postcss from 'postcss'\nimport type { Parser } from 'postcss'\nimport { webpack, sources } from 'next/dist/compiled/webpack/webpack'\nimport { spans } from './profiling-plugin'\n\n// https://github.com/NMFR/optimize-css-assets-webpack-plugin/blob/0a410a9bf28c7b0e81a3470a13748e68ca2f50aa/src/index.js#L20\nconst CSS_REGEX = /\\.css(\\?.*)?$/i\n\ntype CssMinimizerPluginOptions = {\n postcssOptions: {\n map: false | { prev?: string | false; inline: boolean; annotation: boolean }\n }\n}\n\nexport class CssMinimizerPlugin {\n __next_css_remove = true\n\n private options: CssMinimizerPluginOptions\n\n constructor(options: CssMinimizerPluginOptions) {\n this.options = options\n }\n\n optimizeAsset(file: string, asset: any) {\n const postcssOptions = {\n ...this.options.postcssOptions,\n to: file,\n from: file,\n\n // We don't actually add this parser to support Sass. It can also be used\n // for inline comment support. See the README:\n // https://github.com/postcss/postcss-scss/blob/master/README.md#2-inline-comments-for-postcss\n parser: postcssScss as any as Parser,\n }\n\n let input: string\n if (postcssOptions.map && asset.sourceAndMap) {\n const { source, map } = asset.sourceAndMap()\n input = source\n postcssOptions.map.prev = map ? map : false\n } else {\n input = asset.source()\n }\n\n return postcss([cssnanoSimple({ colormin: false }, postcss)])\n .process(input, postcssOptions)\n .then((res) => {\n if (res.map) {\n return new sources.SourceMapSource(res.css, file, res.map.toJSON())\n } else {\n return new sources.RawSource(res.css)\n }\n })\n }\n\n apply(compiler: webpack.Compiler) {\n compiler.hooks.compilation.tap('CssMinimizerPlugin', (compilation: any) => {\n const cache = compilation.getCache('CssMinimizerPlugin')\n compilation.hooks.processAssets.tapPromise(\n {\n name: 'CssMinimizerPlugin',\n stage: webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE,\n },\n async (assets: any) => {\n const compilationSpan = spans.get(compilation) || spans.get(compiler)\n const cssMinimizerSpan = compilationSpan!.traceChild(\n 'css-minimizer-plugin'\n )\n\n return cssMinimizerSpan.traceAsyncFn(async () => {\n const files = Object.keys(assets)\n await Promise.all(\n files\n .filter((file) => CSS_REGEX.test(file))\n .map(async (file) => {\n const assetSpan = cssMinimizerSpan.traceChild('minify-css')\n assetSpan.setAttribute('file', file)\n\n return assetSpan.traceAsyncFn(async () => {\n const assetSource = compilation.getAsset(file).source\n const etag = cache.getLazyHashedEtag(assetSource)\n const cachedResult = await cache.getPromise(file, etag)\n\n assetSpan.setAttribute(\n 'cache',\n cachedResult ? 'HIT' : 'MISS'\n )\n if (cachedResult) {\n compilation.updateAsset(file, cachedResult)\n return\n }\n\n const result = await this.optimizeAsset(file, assetSource)\n await cache.storePromise(file, etag, result)\n compilation.updateAsset(file, result)\n })\n })\n )\n })\n }\n )\n })\n }\n}\n"],"names":["CssMinimizerPlugin","CSS_REGEX","constructor","options","__next_css_remove","optimizeAsset","file","asset","postcssOptions","to","from","parser","postcssScss","input","map","sourceAndMap","source","prev","postcss","cssnanoSimple","colormin","process","then","res","sources","SourceMapSource","css","toJSON","RawSource","apply","compiler","hooks","compilation","tap","cache","getCache","processAssets","tapPromise","name","stage","webpack","Compilation","PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE","assets","compilationSpan","spans","get","cssMinimizerSpan","traceChild","traceAsyncFn","files","Object","keys","Promise","all","filter","test","assetSpan","setAttribute","assetSource","getAsset","etag","getLazyHashedEtag","cachedResult","getPromise","updateAsset","result","storePromise"],"mappings":";;;;+BAgBaA;;;eAAAA;;;sEAhBa;oEACF;gEACJ;yBAEa;iCACX;;;;;;AAEtB,4HAA4H;AAC5H,MAAMC,YAAY;AAQX,MAAMD;IAKXE,YAAYC,OAAkC,CAAE;aAJhDC,oBAAoB;QAKlB,IAAI,CAACD,OAAO,GAAGA;IACjB;IAEAE,cAAcC,IAAY,EAAEC,KAAU,EAAE;QACtC,MAAMC,iBAAiB;YACrB,GAAG,IAAI,CAACL,OAAO,CAACK,cAAc;YAC9BC,IAAIH;YACJI,MAAMJ;YAEN,yEAAyE;YACzE,8CAA8C;YAC9C,8FAA8F;YAC9FK,QAAQC,oBAAW;QACrB;QAEA,IAAIC;QACJ,IAAIL,eAAeM,GAAG,IAAIP,MAAMQ,YAAY,EAAE;YAC5C,MAAM,EAAEC,MAAM,EAAEF,GAAG,EAAE,GAAGP,MAAMQ,YAAY;YAC1CF,QAAQG;YACRR,eAAeM,GAAG,CAACG,IAAI,GAAGH,MAAMA,MAAM;QACxC,OAAO;YACLD,QAAQN,MAAMS,MAAM;QACtB;QAEA,OAAOE,IAAAA,gBAAO,EAAC;YAACC,IAAAA,sBAAa,EAAC;gBAAEC,UAAU;YAAM,GAAGF,gBAAO;SAAE,EACzDG,OAAO,CAACR,OAAOL,gBACfc,IAAI,CAAC,CAACC;YACL,IAAIA,IAAIT,GAAG,EAAE;gBACX,OAAO,IAAIU,gBAAO,CAACC,eAAe,CAACF,IAAIG,GAAG,EAAEpB,MAAMiB,IAAIT,GAAG,CAACa,MAAM;YAClE,OAAO;gBACL,OAAO,IAAIH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ACF;QAEJ;IACF;AACF"}
1
+ {"version":3,"sources":["../../../../src/build/webpack/plugins/css-minimizer-plugin.ts"],"sourcesContent":["import cssnanoSimple from 'next/dist/compiled/cssnano-simple'\nimport postcssScss from 'next/dist/compiled/postcss-scss'\nimport postcss from 'postcss'\nimport type { Parser } from 'postcss'\nimport { webpack, sources } from 'next/dist/compiled/webpack/webpack'\nimport { getCompilationSpan } from '../utils'\n\n// https://github.com/NMFR/optimize-css-assets-webpack-plugin/blob/0a410a9bf28c7b0e81a3470a13748e68ca2f50aa/src/index.js#L20\nconst CSS_REGEX = /\\.css(\\?.*)?$/i\n\ntype CssMinimizerPluginOptions = {\n postcssOptions: {\n map: false | { prev?: string | false; inline: boolean; annotation: boolean }\n }\n}\n\nexport class CssMinimizerPlugin {\n __next_css_remove = true\n\n private options: CssMinimizerPluginOptions\n\n constructor(options: CssMinimizerPluginOptions) {\n this.options = options\n }\n\n optimizeAsset(file: string, asset: any) {\n const postcssOptions = {\n ...this.options.postcssOptions,\n to: file,\n from: file,\n\n // We don't actually add this parser to support Sass. It can also be used\n // for inline comment support. See the README:\n // https://github.com/postcss/postcss-scss/blob/master/README.md#2-inline-comments-for-postcss\n parser: postcssScss as any as Parser,\n }\n\n let input: string\n if (postcssOptions.map && asset.sourceAndMap) {\n const { source, map } = asset.sourceAndMap()\n input = source\n postcssOptions.map.prev = map ? map : false\n } else {\n input = asset.source()\n }\n\n return postcss([cssnanoSimple({ colormin: false }, postcss)])\n .process(input, postcssOptions)\n .then((res) => {\n if (res.map) {\n return new sources.SourceMapSource(res.css, file, res.map.toJSON())\n } else {\n return new sources.RawSource(res.css)\n }\n })\n }\n\n apply(compiler: webpack.Compiler) {\n compiler.hooks.compilation.tap('CssMinimizerPlugin', (compilation: any) => {\n const cache = compilation.getCache('CssMinimizerPlugin')\n compilation.hooks.processAssets.tapPromise(\n {\n name: 'CssMinimizerPlugin',\n stage: webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE,\n },\n async (assets: any) => {\n const compilationSpan =\n getCompilationSpan(compilation) || getCompilationSpan(compiler)\n const cssMinimizerSpan = compilationSpan!.traceChild(\n 'css-minimizer-plugin'\n )\n\n return cssMinimizerSpan.traceAsyncFn(async () => {\n const files = Object.keys(assets)\n await Promise.all(\n files\n .filter((file) => CSS_REGEX.test(file))\n .map(async (file) => {\n const assetSpan = cssMinimizerSpan.traceChild('minify-css')\n assetSpan.setAttribute('file', file)\n\n return assetSpan.traceAsyncFn(async () => {\n const assetSource = compilation.getAsset(file).source\n const etag = cache.getLazyHashedEtag(assetSource)\n const cachedResult = await cache.getPromise(file, etag)\n\n assetSpan.setAttribute(\n 'cache',\n cachedResult ? 'HIT' : 'MISS'\n )\n if (cachedResult) {\n compilation.updateAsset(file, cachedResult)\n return\n }\n\n const result = await this.optimizeAsset(file, assetSource)\n await cache.storePromise(file, etag, result)\n compilation.updateAsset(file, result)\n })\n })\n )\n })\n }\n )\n })\n }\n}\n"],"names":["CssMinimizerPlugin","CSS_REGEX","constructor","options","__next_css_remove","optimizeAsset","file","asset","postcssOptions","to","from","parser","postcssScss","input","map","sourceAndMap","source","prev","postcss","cssnanoSimple","colormin","process","then","res","sources","SourceMapSource","css","toJSON","RawSource","apply","compiler","hooks","compilation","tap","cache","getCache","processAssets","tapPromise","name","stage","webpack","Compilation","PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE","assets","compilationSpan","getCompilationSpan","cssMinimizerSpan","traceChild","traceAsyncFn","files","Object","keys","Promise","all","filter","test","assetSpan","setAttribute","assetSource","getAsset","etag","getLazyHashedEtag","cachedResult","getPromise","updateAsset","result","storePromise"],"mappings":";;;;+BAgBaA;;;eAAAA;;;sEAhBa;oEACF;gEACJ;yBAEa;uBACE;;;;;;AAEnC,4HAA4H;AAC5H,MAAMC,YAAY;AAQX,MAAMD;IAKXE,YAAYC,OAAkC,CAAE;aAJhDC,oBAAoB;QAKlB,IAAI,CAACD,OAAO,GAAGA;IACjB;IAEAE,cAAcC,IAAY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AAMC,QAAQC,OAAOC,IAAI,CAACR;oBAC1B,MAAMS,QAAQC,GAAG,CACfJ,MACGK,MAAM,CAAC,CAAChD,OAASL,UAAUsD,IAAI,CAACjD,OAChCQ,GAAG,CAAC,OAAOR;wBACV,MAAMkD,YAAYV,iBAAiBC,UAAU,CAAC;wBAC9CS,UAAUC,YAAY,CAAC,QAAQnD;wBAE/B,OAAOkD,UAAUR,YAAY,CAAC;4BAC5B,MAAMU,cAAc1B,YAAY2B,QAAQ,CAACrD,MAAMU,MAAM;4BACrD,MAAM4C,OAAO1B,MAAM2B,iBAAiB,CAACH;4BACrC,MAAMI,eAAe,MAAM5B,MAAM6B,UAAU,CAACzD,MAAMsD;4BAElDJ,UAAUC,YAAY,CACpB,SACAK,eAAe,QAAQ;4BAEzB,IAAIA,cAAc;gCAChB9B,YAAYgC,WAAW,CAAC1D,MAAMwD;gCAC9B;4BACF;4BAEA,MAAMG,SAAS,MAAM,IAAI,CAAC5D,aAAa,CAACC,MAAMoD;4BAC9C,MAAMxB,MAAMgC,YAAY,CAAC5D,MAAMsD,MAAMK;4BACrCjC,YAAYgC,WAAW,CAAC1D,MAAM2D;wBAChC;oBACF;gBAEN;YACF;QAEJ;IACF;AACF"}
@@ -10,7 +10,7 @@ Object.defineProperty(exports, "MinifyPlugin", {
10
10
  });
11
11
  const _webpack = require("next/dist/compiled/webpack/webpack");
12
12
  const _plimit = /*#__PURE__*/ _interop_require_default(require("next/dist/compiled/p-limit"));
13
- const _profilingplugin = require("../../profiling-plugin");
13
+ const _utils = require("../../../utils");
14
14
  function _interop_require_default(obj) {
15
15
  return obj && obj.__esModule ? obj : {
16
16
  default: obj
@@ -32,7 +32,7 @@ class MinifyPlugin {
32
32
  }
33
33
  async optimize(compiler, compilation, assets, cache, { SourceMapSource, RawSource }) {
34
34
  const mangle = !this.options.noMangling;
35
- const compilationSpan = _profilingplugin.spans.get(compilation) || _profilingplugin.spans.get(compiler);
35
+ const compilationSpan = (0, _utils.getCompilationSpan)(compilation) || (0, _utils.getCompilationSpan)(compiler);
36
36
  const MinifierSpan = compilationSpan.traceChild('minify-webpack-plugin-optimize');
37
37
  if (compilation.name) {
38
38
  MinifierSpan.setAttribute('compilationName', compilation.name);