next 15.2.0-canary.28 → 15.2.0-canary.29

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 (144) hide show
  1. package/dist/bin/next +1 -1
  2. package/dist/build/index.js +2 -2
  3. package/dist/build/swc/index.js +1 -1
  4. package/dist/build/webpack/plugins/define-env-plugin.js +2 -1
  5. package/dist/build/webpack/plugins/define-env-plugin.js.map +1 -1
  6. package/dist/build/webpack/plugins/slow-module-detection-plugin.d.ts +12 -0
  7. package/dist/build/webpack/plugins/slow-module-detection-plugin.js +187 -0
  8. package/dist/build/webpack/plugins/slow-module-detection-plugin.js.map +1 -0
  9. package/dist/build/webpack-config.js +19 -4
  10. package/dist/build/webpack-config.js.map +1 -1
  11. package/dist/client/app-bootstrap.js +1 -1
  12. package/dist/client/components/errors/stitched-error.js +3 -3
  13. package/dist/client/components/errors/stitched-error.js.map +1 -1
  14. package/dist/client/components/react-dev-overlay/_experimental/app/react-dev-overlay.js +3 -3
  15. package/dist/client/components/react-dev-overlay/_experimental/app/react-dev-overlay.js.map +1 -1
  16. package/dist/client/components/react-dev-overlay/_experimental/internal/components/errors/dev-tools-indicator/dev-tools-indicator.d.ts +2 -2
  17. package/dist/client/components/react-dev-overlay/_experimental/internal/components/errors/dev-tools-indicator/dev-tools-indicator.js +273 -144
  18. package/dist/client/components/react-dev-overlay/_experimental/internal/components/errors/dev-tools-indicator/dev-tools-indicator.js.map +1 -1
  19. package/dist/client/components/react-dev-overlay/_experimental/internal/components/errors/dev-tools-indicator/dev-tools-indicator.stories.js +4 -4
  20. package/dist/client/components/react-dev-overlay/_experimental/internal/components/errors/dev-tools-indicator/dev-tools-indicator.stories.js.map +1 -1
  21. package/dist/client/components/react-dev-overlay/_experimental/internal/components/errors/dev-tools-indicator/internal/next-logo.d.ts +3 -3
  22. package/dist/client/components/react-dev-overlay/_experimental/internal/components/errors/dev-tools-indicator/internal/next-logo.js +9 -14
  23. package/dist/client/components/react-dev-overlay/_experimental/internal/components/errors/dev-tools-indicator/internal/next-logo.js.map +1 -1
  24. package/dist/client/components/react-dev-overlay/_experimental/internal/components/errors/dev-tools-indicator/styles.js +1 -1
  25. package/dist/client/components/react-dev-overlay/_experimental/internal/components/errors/dev-tools-indicator/styles.js.map +1 -1
  26. package/dist/client/components/react-dev-overlay/_experimental/internal/components/errors/error-overlay/error-overlay.js +1 -3
  27. package/dist/client/components/react-dev-overlay/_experimental/internal/components/errors/error-overlay/error-overlay.js.map +1 -1
  28. package/dist/client/components/react-dev-overlay/_experimental/internal/components/errors/error-overlay-footer/error-feedback/error-feedback.d.ts +2 -1
  29. package/dist/client/components/react-dev-overlay/_experimental/internal/components/errors/error-overlay-footer/error-feedback/error-feedback.js +2 -2
  30. package/dist/client/components/react-dev-overlay/_experimental/internal/components/errors/error-overlay-footer/error-feedback/error-feedback.js.map +1 -1
  31. package/dist/client/components/react-dev-overlay/_experimental/internal/components/errors/error-overlay-footer/error-overlay-footer.js +2 -1
  32. package/dist/client/components/react-dev-overlay/_experimental/internal/components/errors/error-overlay-footer/error-overlay-footer.js.map +1 -1
  33. package/dist/client/components/react-dev-overlay/_experimental/internal/container/errors.d.ts +1 -4
  34. package/dist/client/components/react-dev-overlay/_experimental/internal/container/errors.js +2 -3
  35. package/dist/client/components/react-dev-overlay/_experimental/internal/container/errors.js.map +1 -1
  36. package/dist/client/components/react-dev-overlay/_experimental/internal/container/errors.stories.js +111 -86
  37. package/dist/client/components/react-dev-overlay/_experimental/internal/container/errors.stories.js.map +1 -1
  38. package/dist/client/components/react-dev-overlay/_experimental/internal/container/runtime-error/use-error-hook.d.ts +4 -3
  39. package/dist/client/components/react-dev-overlay/_experimental/internal/container/runtime-error/use-error-hook.js +8 -2
  40. package/dist/client/components/react-dev-overlay/_experimental/internal/container/runtime-error/use-error-hook.js.map +1 -1
  41. package/dist/client/components/react-dev-overlay/_experimental/internal/helpers/merge-refs.d.ts +14 -0
  42. package/dist/client/components/react-dev-overlay/_experimental/internal/helpers/merge-refs.js +49 -0
  43. package/dist/client/components/react-dev-overlay/_experimental/internal/helpers/merge-refs.js.map +1 -0
  44. package/dist/client/components/react-dev-overlay/_experimental/internal/styles/base.js +8 -2
  45. package/dist/client/components/react-dev-overlay/_experimental/internal/styles/base.js.map +1 -1
  46. package/dist/client/components/react-dev-overlay/_experimental/pages/react-dev-overlay.js +3 -3
  47. package/dist/client/components/react-dev-overlay/_experimental/pages/react-dev-overlay.js.map +1 -1
  48. package/dist/client/components/react-dev-overlay/internal/styles/Base.js +8 -2
  49. package/dist/client/components/react-dev-overlay/internal/styles/Base.js.map +1 -1
  50. package/dist/client/index.js +1 -1
  51. package/dist/compiled/next-server/app-page-experimental.runtime.dev.js +2 -2
  52. package/dist/compiled/next-server/app-page-experimental.runtime.dev.js.map +1 -1
  53. package/dist/compiled/next-server/app-page.runtime.dev.js +2 -2
  54. package/dist/compiled/next-server/app-page.runtime.dev.js.map +1 -1
  55. package/dist/compiled/next-server/pages-turbo.runtime.prod.js +2 -2
  56. package/dist/compiled/next-server/pages-turbo.runtime.prod.js.map +1 -1
  57. package/dist/compiled/next-server/server.runtime.prod.js +1 -1
  58. package/dist/compiled/next-server/server.runtime.prod.js.map +1 -1
  59. package/dist/esm/build/index.js +2 -2
  60. package/dist/esm/build/swc/index.js +1 -1
  61. package/dist/esm/build/webpack/plugins/define-env-plugin.js +2 -1
  62. package/dist/esm/build/webpack/plugins/define-env-plugin.js.map +1 -1
  63. package/dist/esm/build/webpack/plugins/slow-module-detection-plugin.js +177 -0
  64. package/dist/esm/build/webpack/plugins/slow-module-detection-plugin.js.map +1 -0
  65. package/dist/esm/build/webpack-config.js +19 -4
  66. package/dist/esm/build/webpack-config.js.map +1 -1
  67. package/dist/esm/client/app-bootstrap.js +1 -1
  68. package/dist/esm/client/components/errors/stitched-error.js +3 -3
  69. package/dist/esm/client/components/errors/stitched-error.js.map +1 -1
  70. package/dist/esm/client/components/react-dev-overlay/_experimental/app/react-dev-overlay.js +3 -3
  71. package/dist/esm/client/components/react-dev-overlay/_experimental/app/react-dev-overlay.js.map +1 -1
  72. package/dist/esm/client/components/react-dev-overlay/_experimental/internal/components/errors/dev-tools-indicator/dev-tools-indicator.js +274 -146
  73. package/dist/esm/client/components/react-dev-overlay/_experimental/internal/components/errors/dev-tools-indicator/dev-tools-indicator.js.map +1 -1
  74. package/dist/esm/client/components/react-dev-overlay/_experimental/internal/components/errors/dev-tools-indicator/dev-tools-indicator.stories.js +4 -4
  75. package/dist/esm/client/components/react-dev-overlay/_experimental/internal/components/errors/dev-tools-indicator/dev-tools-indicator.stories.js.map +1 -1
  76. package/dist/esm/client/components/react-dev-overlay/_experimental/internal/components/errors/dev-tools-indicator/internal/next-logo.js +9 -15
  77. package/dist/esm/client/components/react-dev-overlay/_experimental/internal/components/errors/dev-tools-indicator/internal/next-logo.js.map +1 -1
  78. package/dist/esm/client/components/react-dev-overlay/_experimental/internal/components/errors/dev-tools-indicator/styles.js +1 -1
  79. package/dist/esm/client/components/react-dev-overlay/_experimental/internal/components/errors/dev-tools-indicator/styles.js.map +1 -1
  80. package/dist/esm/client/components/react-dev-overlay/_experimental/internal/components/errors/error-overlay/error-overlay.js +1 -3
  81. package/dist/esm/client/components/react-dev-overlay/_experimental/internal/components/errors/error-overlay/error-overlay.js.map +1 -1
  82. package/dist/esm/client/components/react-dev-overlay/_experimental/internal/components/errors/error-overlay-footer/error-feedback/error-feedback.js +2 -2
  83. package/dist/esm/client/components/react-dev-overlay/_experimental/internal/components/errors/error-overlay-footer/error-feedback/error-feedback.js.map +1 -1
  84. package/dist/esm/client/components/react-dev-overlay/_experimental/internal/components/errors/error-overlay-footer/error-overlay-footer.js +2 -1
  85. package/dist/esm/client/components/react-dev-overlay/_experimental/internal/components/errors/error-overlay-footer/error-overlay-footer.js.map +1 -1
  86. package/dist/esm/client/components/react-dev-overlay/_experimental/internal/container/errors.js +2 -3
  87. package/dist/esm/client/components/react-dev-overlay/_experimental/internal/container/errors.js.map +1 -1
  88. package/dist/esm/client/components/react-dev-overlay/_experimental/internal/container/errors.stories.js +111 -86
  89. package/dist/esm/client/components/react-dev-overlay/_experimental/internal/container/errors.stories.js.map +1 -1
  90. package/dist/esm/client/components/react-dev-overlay/_experimental/internal/container/runtime-error/use-error-hook.js +8 -2
  91. package/dist/esm/client/components/react-dev-overlay/_experimental/internal/container/runtime-error/use-error-hook.js.map +1 -1
  92. package/dist/esm/client/components/react-dev-overlay/_experimental/internal/helpers/merge-refs.js +33 -0
  93. package/dist/esm/client/components/react-dev-overlay/_experimental/internal/helpers/merge-refs.js.map +1 -0
  94. package/dist/esm/client/components/react-dev-overlay/_experimental/internal/styles/base.js +8 -2
  95. package/dist/esm/client/components/react-dev-overlay/_experimental/internal/styles/base.js.map +1 -1
  96. package/dist/esm/client/components/react-dev-overlay/_experimental/pages/react-dev-overlay.js +3 -3
  97. package/dist/esm/client/components/react-dev-overlay/_experimental/pages/react-dev-overlay.js.map +1 -1
  98. package/dist/esm/client/components/react-dev-overlay/internal/styles/Base.js +8 -2
  99. package/dist/esm/client/components/react-dev-overlay/internal/styles/Base.js.map +1 -1
  100. package/dist/esm/client/index.js +1 -1
  101. package/dist/esm/export/worker.js +9 -1
  102. package/dist/esm/export/worker.js.map +1 -1
  103. package/dist/esm/lib/turbopack-warning.js +2 -1
  104. package/dist/esm/lib/turbopack-warning.js.map +1 -1
  105. package/dist/esm/server/base-server.js +4 -4
  106. package/dist/esm/server/base-server.js.map +1 -1
  107. package/dist/esm/server/config-schema.js +4 -1
  108. package/dist/esm/server/config-schema.js.map +1 -1
  109. package/dist/esm/server/config-shared.js +2 -1
  110. package/dist/esm/server/config-shared.js.map +1 -1
  111. package/dist/esm/server/config.js +1 -1
  112. package/dist/esm/server/dev/hot-reloader-turbopack.js +1 -1
  113. package/dist/esm/server/dev/hot-reloader-webpack.js +1 -1
  114. package/dist/esm/server/lib/app-info-log.js +1 -1
  115. package/dist/esm/server/lib/start-server.js +1 -1
  116. package/dist/esm/server/server-utils.js +22 -19
  117. package/dist/esm/server/server-utils.js.map +1 -1
  118. package/dist/esm/server/web-server.js +2 -2
  119. package/dist/esm/server/web-server.js.map +1 -1
  120. package/dist/export/worker.js +9 -1
  121. package/dist/export/worker.js.map +1 -1
  122. package/dist/lib/turbopack-warning.js +2 -1
  123. package/dist/lib/turbopack-warning.js.map +1 -1
  124. package/dist/server/base-server.js +4 -4
  125. package/dist/server/base-server.js.map +1 -1
  126. package/dist/server/config-schema.js +4 -1
  127. package/dist/server/config-schema.js.map +1 -1
  128. package/dist/server/config-shared.d.ts +11 -0
  129. package/dist/server/config-shared.js +2 -1
  130. package/dist/server/config-shared.js.map +1 -1
  131. package/dist/server/config.js +1 -1
  132. package/dist/server/dev/hot-reloader-turbopack.js +1 -1
  133. package/dist/server/dev/hot-reloader-webpack.js +1 -1
  134. package/dist/server/lib/app-info-log.js +1 -1
  135. package/dist/server/lib/start-server.js +1 -1
  136. package/dist/server/server-utils.d.ts +4 -4
  137. package/dist/server/server-utils.js +22 -19
  138. package/dist/server/server-utils.js.map +1 -1
  139. package/dist/server/web-server.js +2 -2
  140. package/dist/server/web-server.js.map +1 -1
  141. package/dist/telemetry/anonymous-meta.js +1 -1
  142. package/dist/telemetry/events/session-stopped.js +2 -2
  143. package/dist/telemetry/events/version.js +2 -2
  144. package/package.json +15 -15
@@ -294,7 +294,7 @@ export default async function build(dir, reactProductionProfiling = false, debug
294
294
  const nextBuildSpan = trace('next-build', undefined, {
295
295
  buildMode: experimentalBuildMode,
296
296
  isTurboBuild: String(turboNextBuild),
297
- version: "15.2.0-canary.28"
297
+ version: "15.2.0-canary.29"
298
298
  });
299
299
  NextBuildContext.nextBuildSpan = nextBuildSpan;
300
300
  NextBuildContext.dir = dir;
@@ -654,7 +654,7 @@ export default async function build(dir, reactProductionProfiling = false, debug
654
654
  // Files outside of the distDir can be "type": "module"
655
655
  await writeFileUtf8(path.join(distDir, 'package.json'), '{"type": "commonjs"}');
656
656
  // These are written to distDir, so they need to come after creating and cleaning distDr.
657
- await recordFrameworkVersion("15.2.0-canary.28");
657
+ await recordFrameworkVersion("15.2.0-canary.29");
658
658
  await updateBuildDiagnostics({
659
659
  buildStage: 'start'
660
660
  });
@@ -11,7 +11,7 @@ import { isDeepStrictEqual } from 'util';
11
11
  import { getDefineEnv } from '../webpack/plugins/define-env-plugin';
12
12
  import { getReactCompilerLoader } from '../get-babel-loader-config';
13
13
  import { TurbopackInternalError } from '../../shared/lib/turbopack/utils';
14
- const nextVersion = "15.2.0-canary.28";
14
+ const nextVersion = "15.2.0-canary.29";
15
15
  const ArchName = arch();
16
16
  const PlatformName = platform();
17
17
  function infoLog(...args) {
@@ -161,7 +161,8 @@ export function getDefineEnv({ isTurbopack, clientRouterFilters, config, dev, di
161
161
  } : undefined,
162
162
  'process.env.__NEXT_EXPERIMENTAL_NEW_DEV_OVERLAY': // When `__NEXT_EXPERIMENTAL_NEW_DEV_OVERLAY` is set on CI,
163
163
  // we need to pass it here so it can be enabled.
164
- process.env.__NEXT_EXPERIMENTAL_NEW_DEV_OVERLAY === 'true' || config.experimental.newDevOverlay || false
164
+ process.env.__NEXT_EXPERIMENTAL_NEW_DEV_OVERLAY === 'true' || config.experimental.newDevOverlay || false,
165
+ 'process.env.__NEXT_REACT_OWNER_STACK': config.experimental.reactOwnerStack ?? false
165
166
  };
166
167
  const userDefines = ((_config_compiler = config.compiler) == null ? void 0 : _config_compiler.define) ?? {};
167
168
  for(const key in userDefines){
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/build/webpack/plugins/define-env-plugin.ts"],"sourcesContent":["import type {\n I18NDomains,\n NextConfigComplete,\n} from '../../../server/config-shared'\nimport type { MiddlewareMatcher } from '../../analysis/get-page-static-info'\nimport { webpack } from 'next/dist/compiled/webpack/webpack'\nimport { needsExperimentalReact } from '../../../lib/needs-experimental-react'\nimport { checkIsAppPPREnabled } from '../../../server/lib/experimental/ppr'\n\nfunction errorIfEnvConflicted(config: NextConfigComplete, key: string) {\n const isPrivateKey = /^(?:NODE_.+)|^(?:__.+)$/i.test(key)\n const hasNextRuntimeKey = key === 'NEXT_RUNTIME'\n\n if (isPrivateKey || hasNextRuntimeKey) {\n throw new Error(\n `The key \"${key}\" under \"env\" in ${config.configFileName} is not allowed. https://nextjs.org/docs/messages/env-key-not-allowed`\n )\n }\n}\n\ntype BloomFilter = ReturnType<\n import('../../../shared/lib/bloom-filter').BloomFilter['export']\n>\n\nexport interface DefineEnvPluginOptions {\n isTurbopack: boolean\n clientRouterFilters?: {\n staticFilter: BloomFilter\n dynamicFilter: BloomFilter\n }\n config: NextConfigComplete\n dev: boolean\n distDir: string\n fetchCacheKeyPrefix: string | undefined\n hasRewrites: boolean\n isClient: boolean\n isEdgeServer: boolean\n isNodeOrEdgeCompilation: boolean\n isNodeServer: boolean\n middlewareMatchers: MiddlewareMatcher[] | undefined\n}\n\ninterface DefineEnv {\n [key: string]:\n | string\n | string[]\n | boolean\n | MiddlewareMatcher[]\n | BloomFilter\n | Partial<NextConfigComplete['images']>\n | I18NDomains\n}\n\ninterface SerializedDefineEnv {\n [key: string]: string\n}\n\n/**\n * Collects all environment variables that are using the `NEXT_PUBLIC_` prefix.\n */\nexport function getNextPublicEnvironmentVariables(): DefineEnv {\n const defineEnv: DefineEnv = {}\n for (const key in process.env) {\n if (key.startsWith('NEXT_PUBLIC_')) {\n const value = process.env[key]\n if (value != null) {\n defineEnv[`process.env.${key}`] = value\n }\n }\n }\n return defineEnv\n}\n\n/**\n * Collects the `env` config value from the Next.js config.\n */\nexport function getNextConfigEnv(config: NextConfigComplete): DefineEnv {\n // Refactored code below to use for-of\n const defineEnv: DefineEnv = {}\n const env = config.env\n for (const key in env) {\n const value = env[key]\n if (value != null) {\n errorIfEnvConflicted(config, key)\n defineEnv[`process.env.${key}`] = value\n }\n }\n return defineEnv\n}\n\n/**\n * Serializes the DefineEnv config so that it can be inserted into the code by Webpack/Turbopack, JSON stringifies each value.\n */\nfunction serializeDefineEnv(defineEnv: DefineEnv): SerializedDefineEnv {\n const defineEnvStringified: SerializedDefineEnv = {}\n for (const key in defineEnv) {\n const value = defineEnv[key]\n defineEnvStringified[key] = JSON.stringify(value)\n }\n\n return defineEnvStringified\n}\n\nfunction getImageConfig(\n config: NextConfigComplete,\n dev: boolean\n): { 'process.env.__NEXT_IMAGE_OPTS': Partial<NextConfigComplete['images']> } {\n return {\n 'process.env.__NEXT_IMAGE_OPTS': {\n deviceSizes: config.images.deviceSizes,\n imageSizes: config.images.imageSizes,\n qualities: config.images.qualities,\n path: config.images.path,\n loader: config.images.loader,\n dangerouslyAllowSVG: config.images.dangerouslyAllowSVG,\n unoptimized: config?.images?.unoptimized,\n ...(dev\n ? {\n // additional config in dev to allow validating on the client\n domains: config.images.domains,\n remotePatterns: config.images?.remotePatterns,\n localPatterns: config.images?.localPatterns,\n output: config.output,\n }\n : {}),\n },\n }\n}\n\nexport function getDefineEnv({\n isTurbopack,\n clientRouterFilters,\n config,\n dev,\n distDir,\n fetchCacheKeyPrefix,\n hasRewrites,\n isClient,\n isEdgeServer,\n isNodeOrEdgeCompilation,\n isNodeServer,\n middlewareMatchers,\n}: DefineEnvPluginOptions): SerializedDefineEnv {\n const nextPublicEnv = getNextPublicEnvironmentVariables()\n const nextConfigEnv = getNextConfigEnv(config)\n\n const isPPREnabled = checkIsAppPPREnabled(config.experimental.ppr)\n const isDynamicIOEnabled = !!config.experimental.dynamicIO\n const isUseCacheEnabled = !!config.experimental.useCache\n\n const defineEnv: DefineEnv = {\n // internal field to identify the plugin config\n __NEXT_DEFINE_ENV: true,\n\n ...nextPublicEnv,\n ...nextConfigEnv,\n ...(!isEdgeServer\n ? {}\n : {\n EdgeRuntime:\n /**\n * Cloud providers can set this environment variable to allow users\n * and library authors to have different implementations based on\n * the runtime they are running with, if it's not using `edge-runtime`\n */\n process.env.NEXT_EDGE_RUNTIME_PROVIDER ?? 'edge-runtime',\n\n // process should be only { env: {...} } for edge runtime.\n // For ignore avoid warn on `process.emit` usage but directly omit it.\n 'process.emit': false,\n }),\n 'process.turbopack': isTurbopack,\n 'process.env.TURBOPACK': isTurbopack,\n // TODO: enforce `NODE_ENV` on `process.env`, and add a test:\n 'process.env.NODE_ENV':\n dev || config.experimental.allowDevelopmentBuild\n ? 'development'\n : 'production',\n 'process.env.NEXT_RUNTIME': isEdgeServer\n ? 'edge'\n : isNodeServer\n ? 'nodejs'\n : '',\n 'process.env.NEXT_MINIMAL': '',\n 'process.env.__NEXT_APP_NAV_FAIL_HANDLING': Boolean(\n config.experimental.appNavFailHandling\n ),\n 'process.env.__NEXT_APP_ISR_INDICATOR': Boolean(\n config.devIndicators.appIsrStatus\n ),\n 'process.env.__NEXT_PPR': isPPREnabled,\n 'process.env.__NEXT_DYNAMIC_IO': isDynamicIOEnabled,\n 'process.env.__NEXT_USE_CACHE': isUseCacheEnabled,\n 'process.env.NEXT_DEPLOYMENT_ID': config.deploymentId || false,\n 'process.env.__NEXT_FETCH_CACHE_KEY_PREFIX': fetchCacheKeyPrefix ?? '',\n ...(isTurbopack\n ? {}\n : {\n 'process.env.__NEXT_MIDDLEWARE_MATCHERS': middlewareMatchers ?? [],\n }),\n 'process.env.__NEXT_MANUAL_CLIENT_BASE_PATH':\n config.experimental.manualClientBasePath ?? false,\n 'process.env.__NEXT_CLIENT_ROUTER_DYNAMIC_STALETIME': JSON.stringify(\n isNaN(Number(config.experimental.staleTimes?.dynamic))\n ? 0\n : config.experimental.staleTimes?.dynamic\n ),\n 'process.env.__NEXT_CLIENT_ROUTER_STATIC_STALETIME': JSON.stringify(\n isNaN(Number(config.experimental.staleTimes?.static))\n ? 5 * 60 // 5 minutes\n : config.experimental.staleTimes?.static\n ),\n 'process.env.__NEXT_CLIENT_ROUTER_FILTER_ENABLED':\n config.experimental.clientRouterFilter ?? true,\n 'process.env.__NEXT_CLIENT_ROUTER_S_FILTER':\n clientRouterFilters?.staticFilter ?? false,\n 'process.env.__NEXT_CLIENT_ROUTER_D_FILTER':\n clientRouterFilters?.dynamicFilter ?? false,\n 'process.env.__NEXT_CLIENT_SEGMENT_CACHE': Boolean(\n config.experimental.clientSegmentCache\n ),\n 'process.env.__NEXT_OPTIMISTIC_CLIENT_CACHE':\n config.experimental.optimisticClientCache ?? true,\n 'process.env.__NEXT_MIDDLEWARE_PREFETCH':\n config.experimental.middlewarePrefetch ?? 'flexible',\n 'process.env.__NEXT_CROSS_ORIGIN': config.crossOrigin,\n 'process.browser': isClient,\n 'process.env.__NEXT_TEST_MODE': process.env.__NEXT_TEST_MODE ?? false,\n // This is used in client/dev-error-overlay/hot-dev-client.js to replace the dist directory\n ...(dev && (isClient ?? isEdgeServer)\n ? {\n 'process.env.__NEXT_DIST_DIR': distDir,\n }\n : {}),\n 'process.env.__NEXT_TRAILING_SLASH': config.trailingSlash,\n 'process.env.__NEXT_BUILD_INDICATOR':\n config.devIndicators.buildActivity ?? true,\n 'process.env.__NEXT_BUILD_INDICATOR_POSITION':\n config.devIndicators.buildActivityPosition ?? 'bottom-right',\n 'process.env.__NEXT_STRICT_MODE':\n config.reactStrictMode === null ? false : config.reactStrictMode,\n 'process.env.__NEXT_STRICT_MODE_APP':\n // When next.config.js does not have reactStrictMode it's enabled by default.\n config.reactStrictMode === null ? true : config.reactStrictMode,\n 'process.env.__NEXT_OPTIMIZE_CSS':\n (config.experimental.optimizeCss && !dev) ?? false,\n 'process.env.__NEXT_SCRIPT_WORKERS':\n (config.experimental.nextScriptWorkers && !dev) ?? false,\n 'process.env.__NEXT_SCROLL_RESTORATION':\n config.experimental.scrollRestoration ?? false,\n ...getImageConfig(config, dev),\n 'process.env.__NEXT_ROUTER_BASEPATH': config.basePath,\n 'process.env.__NEXT_STRICT_NEXT_HEAD':\n config.experimental.strictNextHead ?? true,\n 'process.env.__NEXT_HAS_REWRITES': hasRewrites,\n 'process.env.__NEXT_CONFIG_OUTPUT': config.output,\n 'process.env.__NEXT_I18N_SUPPORT': !!config.i18n,\n 'process.env.__NEXT_I18N_DOMAINS': config.i18n?.domains ?? false,\n 'process.env.__NEXT_NO_MIDDLEWARE_URL_NORMALIZE':\n config.skipMiddlewareUrlNormalize,\n 'process.env.__NEXT_EXTERNAL_MIDDLEWARE_REWRITE_RESOLVE':\n config.experimental.externalMiddlewareRewritesResolve ?? false,\n 'process.env.__NEXT_MANUAL_TRAILING_SLASH':\n config.skipTrailingSlashRedirect,\n 'process.env.__NEXT_HAS_WEB_VITALS_ATTRIBUTION':\n (config.experimental.webVitalsAttribution &&\n config.experimental.webVitalsAttribution.length > 0) ??\n false,\n 'process.env.__NEXT_WEB_VITALS_ATTRIBUTION':\n config.experimental.webVitalsAttribution ?? false,\n 'process.env.__NEXT_LINK_NO_TOUCH_START':\n config.experimental.linkNoTouchStart ?? false,\n 'process.env.__NEXT_ASSET_PREFIX': config.assetPrefix,\n 'process.env.__NEXT_EXPERIMENTAL_AUTH_INTERRUPTS':\n !!config.experimental.authInterrupts,\n ...(isNodeOrEdgeCompilation\n ? {\n // Fix bad-actors in the npm ecosystem (e.g. `node-formidable`)\n // This is typically found in unmaintained modules from the\n // pre-webpack era (common in server-side code)\n 'global.GENTLY': false,\n }\n : undefined),\n ...(isNodeOrEdgeCompilation\n ? {\n 'process.env.__NEXT_EXPERIMENTAL_REACT':\n needsExperimentalReact(config),\n }\n : undefined),\n 'process.env.__NEXT_EXPERIMENTAL_NEW_DEV_OVERLAY':\n // When `__NEXT_EXPERIMENTAL_NEW_DEV_OVERLAY` is set on CI,\n // we need to pass it here so it can be enabled.\n process.env.__NEXT_EXPERIMENTAL_NEW_DEV_OVERLAY === 'true' ||\n config.experimental.newDevOverlay ||\n false,\n }\n\n const userDefines = config.compiler?.define ?? {}\n for (const key in userDefines) {\n if (defineEnv.hasOwnProperty(key)) {\n throw new Error(\n `The \\`compiler.define\\` option is configured to replace the \\`${key}\\` variable. This variable is either part of a Next.js built-in or is already configured via the \\`env\\` option.`\n )\n }\n defineEnv[key] = userDefines[key]\n }\n\n return serializeDefineEnv(defineEnv)\n}\n\nexport function getDefineEnvPlugin(options: DefineEnvPluginOptions) {\n return new webpack.DefinePlugin(getDefineEnv(options))\n}\n"],"names":["webpack","needsExperimentalReact","checkIsAppPPREnabled","errorIfEnvConflicted","config","key","isPrivateKey","test","hasNextRuntimeKey","Error","configFileName","getNextPublicEnvironmentVariables","defineEnv","process","env","startsWith","value","getNextConfigEnv","serializeDefineEnv","defineEnvStringified","JSON","stringify","getImageConfig","dev","deviceSizes","images","imageSizes","qualities","path","loader","dangerouslyAllowSVG","unoptimized","domains","remotePatterns","localPatterns","output","getDefineEnv","isTurbopack","clientRouterFilters","distDir","fetchCacheKeyPrefix","hasRewrites","isClient","isEdgeServer","isNodeOrEdgeCompilation","isNodeServer","middlewareMatchers","nextPublicEnv","nextConfigEnv","isPPREnabled","experimental","ppr","isDynamicIOEnabled","dynamicIO","isUseCacheEnabled","useCache","__NEXT_DEFINE_ENV","EdgeRuntime","NEXT_EDGE_RUNTIME_PROVIDER","allowDevelopmentBuild","Boolean","appNavFailHandling","devIndicators","appIsrStatus","deploymentId","manualClientBasePath","isNaN","Number","staleTimes","dynamic","static","clientRouterFilter","staticFilter","dynamicFilter","clientSegmentCache","optimisticClientCache","middlewarePrefetch","crossOrigin","__NEXT_TEST_MODE","trailingSlash","buildActivity","buildActivityPosition","reactStrictMode","optimizeCss","nextScriptWorkers","scrollRestoration","basePath","strictNextHead","i18n","skipMiddlewareUrlNormalize","externalMiddlewareRewritesResolve","skipTrailingSlashRedirect","webVitalsAttribution","length","linkNoTouchStart","assetPrefix","authInterrupts","undefined","__NEXT_EXPERIMENTAL_NEW_DEV_OVERLAY","newDevOverlay","userDefines","compiler","define","hasOwnProperty","getDefineEnvPlugin","options","DefinePlugin"],"mappings":"AAKA,SAASA,OAAO,QAAQ,qCAAoC;AAC5D,SAASC,sBAAsB,QAAQ,wCAAuC;AAC9E,SAASC,oBAAoB,QAAQ,uCAAsC;AAE3E,SAASC,qBAAqBC,MAA0B,EAAEC,GAAW;IACnE,MAAMC,eAA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O8C,YAAY,CAAC0C,oBAAoB,IACvCxF,OAAO8C,YAAY,CAAC0C,oBAAoB,CAACC,MAAM,GAAG,CAAA,KACpD;QACF,6CACEzF,OAAO8C,YAAY,CAAC0C,oBAAoB,IAAI;QAC9C,0CACExF,OAAO8C,YAAY,CAAC4C,gBAAgB,IAAI;QAC1C,mCAAmC1F,OAAO2F,WAAW;QACrD,mDACE,CAAC,CAAC3F,OAAO8C,YAAY,CAAC8C,cAAc;QACtC,GAAIpD,0BACA;YACE,+DAA+D;YAC/D,2DAA2D;YAC3D,+CAA+C;YAC/C,iBAAiB;QACnB,IACAqD,SAAS;QACb,GAAIrD,0BACA;YACE,yCACE3C,uBAAuBG;QAC3B,IACA6F,SAAS;QACb,mDACE,2DAA2D;QAC3D,gDAAgD;QAChDpF,QAAQC,GAAG,CAACoF,mCAAmC,KAAK,UACpD9F,OAAO8C,YAAY,CAACiD,aAAa,IACjC;IACJ;IAEA,MAAMC,cAAchG,EAAAA,mBAAAA,OAAOiG,QAAQ,qBAAfjG,iBAAiBkG,MAAM,KAAI,CAAC;IAChD,IAAK,MAAMjG,OAAO+F,YAAa;QAC7B,IAAIxF,UAAU2F,cAAc,CAAClG,MAAM;YACjC,MAAM,qBAEL,CAFK,IAAII,MACR,CAAC,8DAA8D,EAAEJ,IAAI,gHAAgH,CAAC,GADlL,qBAAA;uBAAA;4BAAA;YAEN;QACF;QACAO,SAAS,CAACP,IAAI,GAAG+F,WAAW,CAAC/F,IAAI;IACnC;IAEA,OAAOa,mBAAmBN;AAC5B;AAEA,OAAO,SAAS4F,mBAAmBC,OAA+B;IAChE,OAAO,IAAIzG,QAAQ0G,YAAY,CAACtE,aAAaqE;AAC/C"}
1
+ {"version":3,"sources":["../../../../src/build/webpack/plugins/define-env-plugin.ts"],"sourcesContent":["import type {\n I18NDomains,\n NextConfigComplete,\n} from '../../../server/config-shared'\nimport type { MiddlewareMatcher } from '../../analysis/get-page-static-info'\nimport { webpack } from 'next/dist/compiled/webpack/webpack'\nimport { needsExperimentalReact } from '../../../lib/needs-experimental-react'\nimport { checkIsAppPPREnabled } from '../../../server/lib/experimental/ppr'\n\nfunction errorIfEnvConflicted(config: NextConfigComplete, key: string) {\n const isPrivateKey = /^(?:NODE_.+)|^(?:__.+)$/i.test(key)\n const hasNextRuntimeKey = key === 'NEXT_RUNTIME'\n\n if (isPrivateKey || hasNextRuntimeKey) {\n throw new Error(\n `The key \"${key}\" under \"env\" in ${config.configFileName} is not allowed. https://nextjs.org/docs/messages/env-key-not-allowed`\n )\n }\n}\n\ntype BloomFilter = ReturnType<\n import('../../../shared/lib/bloom-filter').BloomFilter['export']\n>\n\nexport interface DefineEnvPluginOptions {\n isTurbopack: boolean\n clientRouterFilters?: {\n staticFilter: BloomFilter\n dynamicFilter: BloomFilter\n }\n config: NextConfigComplete\n dev: boolean\n distDir: string\n fetchCacheKeyPrefix: string | undefined\n hasRewrites: boolean\n isClient: boolean\n isEdgeServer: boolean\n isNodeOrEdgeCompilation: boolean\n isNodeServer: boolean\n middlewareMatchers: MiddlewareMatcher[] | undefined\n}\n\ninterface DefineEnv {\n [key: string]:\n | string\n | string[]\n | boolean\n | MiddlewareMatcher[]\n | BloomFilter\n | Partial<NextConfigComplete['images']>\n | I18NDomains\n}\n\ninterface SerializedDefineEnv {\n [key: string]: string\n}\n\n/**\n * Collects all environment variables that are using the `NEXT_PUBLIC_` prefix.\n */\nexport function getNextPublicEnvironmentVariables(): DefineEnv {\n const defineEnv: DefineEnv = {}\n for (const key in process.env) {\n if (key.startsWith('NEXT_PUBLIC_')) {\n const value = process.env[key]\n if (value != null) {\n defineEnv[`process.env.${key}`] = value\n }\n }\n }\n return defineEnv\n}\n\n/**\n * Collects the `env` config value from the Next.js config.\n */\nexport function getNextConfigEnv(config: NextConfigComplete): DefineEnv {\n // Refactored code below to use for-of\n const defineEnv: DefineEnv = {}\n const env = config.env\n for (const key in env) {\n const value = env[key]\n if (value != null) {\n errorIfEnvConflicted(config, key)\n defineEnv[`process.env.${key}`] = value\n }\n }\n return defineEnv\n}\n\n/**\n * Serializes the DefineEnv config so that it can be inserted into the code by Webpack/Turbopack, JSON stringifies each value.\n */\nfunction serializeDefineEnv(defineEnv: DefineEnv): SerializedDefineEnv {\n const defineEnvStringified: SerializedDefineEnv = {}\n for (const key in defineEnv) {\n const value = defineEnv[key]\n defineEnvStringified[key] = JSON.stringify(value)\n }\n\n return defineEnvStringified\n}\n\nfunction getImageConfig(\n config: NextConfigComplete,\n dev: boolean\n): { 'process.env.__NEXT_IMAGE_OPTS': Partial<NextConfigComplete['images']> } {\n return {\n 'process.env.__NEXT_IMAGE_OPTS': {\n deviceSizes: config.images.deviceSizes,\n imageSizes: config.images.imageSizes,\n qualities: config.images.qualities,\n path: config.images.path,\n loader: config.images.loader,\n dangerouslyAllowSVG: config.images.dangerouslyAllowSVG,\n unoptimized: config?.images?.unoptimized,\n ...(dev\n ? {\n // additional config in dev to allow validating on the client\n domains: config.images.domains,\n remotePatterns: config.images?.remotePatterns,\n localPatterns: config.images?.localPatterns,\n output: config.output,\n }\n : {}),\n },\n }\n}\n\nexport function getDefineEnv({\n isTurbopack,\n clientRouterFilters,\n config,\n dev,\n distDir,\n fetchCacheKeyPrefix,\n hasRewrites,\n isClient,\n isEdgeServer,\n isNodeOrEdgeCompilation,\n isNodeServer,\n middlewareMatchers,\n}: DefineEnvPluginOptions): SerializedDefineEnv {\n const nextPublicEnv = getNextPublicEnvironmentVariables()\n const nextConfigEnv = getNextConfigEnv(config)\n\n const isPPREnabled = checkIsAppPPREnabled(config.experimental.ppr)\n const isDynamicIOEnabled = !!config.experimental.dynamicIO\n const isUseCacheEnabled = !!config.experimental.useCache\n\n const defineEnv: DefineEnv = {\n // internal field to identify the plugin config\n __NEXT_DEFINE_ENV: true,\n\n ...nextPublicEnv,\n ...nextConfigEnv,\n ...(!isEdgeServer\n ? {}\n : {\n EdgeRuntime:\n /**\n * Cloud providers can set this environment variable to allow users\n * and library authors to have different implementations based on\n * the runtime they are running with, if it's not using `edge-runtime`\n */\n process.env.NEXT_EDGE_RUNTIME_PROVIDER ?? 'edge-runtime',\n\n // process should be only { env: {...} } for edge runtime.\n // For ignore avoid warn on `process.emit` usage but directly omit it.\n 'process.emit': false,\n }),\n 'process.turbopack': isTurbopack,\n 'process.env.TURBOPACK': isTurbopack,\n // TODO: enforce `NODE_ENV` on `process.env`, and add a test:\n 'process.env.NODE_ENV':\n dev || config.experimental.allowDevelopmentBuild\n ? 'development'\n : 'production',\n 'process.env.NEXT_RUNTIME': isEdgeServer\n ? 'edge'\n : isNodeServer\n ? 'nodejs'\n : '',\n 'process.env.NEXT_MINIMAL': '',\n 'process.env.__NEXT_APP_NAV_FAIL_HANDLING': Boolean(\n config.experimental.appNavFailHandling\n ),\n 'process.env.__NEXT_APP_ISR_INDICATOR': Boolean(\n config.devIndicators.appIsrStatus\n ),\n 'process.env.__NEXT_PPR': isPPREnabled,\n 'process.env.__NEXT_DYNAMIC_IO': isDynamicIOEnabled,\n 'process.env.__NEXT_USE_CACHE': isUseCacheEnabled,\n 'process.env.NEXT_DEPLOYMENT_ID': config.deploymentId || false,\n 'process.env.__NEXT_FETCH_CACHE_KEY_PREFIX': fetchCacheKeyPrefix ?? '',\n ...(isTurbopack\n ? {}\n : {\n 'process.env.__NEXT_MIDDLEWARE_MATCHERS': middlewareMatchers ?? [],\n }),\n 'process.env.__NEXT_MANUAL_CLIENT_BASE_PATH':\n config.experimental.manualClientBasePath ?? false,\n 'process.env.__NEXT_CLIENT_ROUTER_DYNAMIC_STALETIME': JSON.stringify(\n isNaN(Number(config.experimental.staleTimes?.dynamic))\n ? 0\n : config.experimental.staleTimes?.dynamic\n ),\n 'process.env.__NEXT_CLIENT_ROUTER_STATIC_STALETIME': JSON.stringify(\n isNaN(Number(config.experimental.staleTimes?.static))\n ? 5 * 60 // 5 minutes\n : config.experimental.staleTimes?.static\n ),\n 'process.env.__NEXT_CLIENT_ROUTER_FILTER_ENABLED':\n config.experimental.clientRouterFilter ?? true,\n 'process.env.__NEXT_CLIENT_ROUTER_S_FILTER':\n clientRouterFilters?.staticFilter ?? false,\n 'process.env.__NEXT_CLIENT_ROUTER_D_FILTER':\n clientRouterFilters?.dynamicFilter ?? false,\n 'process.env.__NEXT_CLIENT_SEGMENT_CACHE': Boolean(\n config.experimental.clientSegmentCache\n ),\n 'process.env.__NEXT_OPTIMISTIC_CLIENT_CACHE':\n config.experimental.optimisticClientCache ?? true,\n 'process.env.__NEXT_MIDDLEWARE_PREFETCH':\n config.experimental.middlewarePrefetch ?? 'flexible',\n 'process.env.__NEXT_CROSS_ORIGIN': config.crossOrigin,\n 'process.browser': isClient,\n 'process.env.__NEXT_TEST_MODE': process.env.__NEXT_TEST_MODE ?? false,\n // This is used in client/dev-error-overlay/hot-dev-client.js to replace the dist directory\n ...(dev && (isClient ?? isEdgeServer)\n ? {\n 'process.env.__NEXT_DIST_DIR': distDir,\n }\n : {}),\n 'process.env.__NEXT_TRAILING_SLASH': config.trailingSlash,\n 'process.env.__NEXT_BUILD_INDICATOR':\n config.devIndicators.buildActivity ?? true,\n 'process.env.__NEXT_BUILD_INDICATOR_POSITION':\n config.devIndicators.buildActivityPosition ?? 'bottom-right',\n 'process.env.__NEXT_STRICT_MODE':\n config.reactStrictMode === null ? false : config.reactStrictMode,\n 'process.env.__NEXT_STRICT_MODE_APP':\n // When next.config.js does not have reactStrictMode it's enabled by default.\n config.reactStrictMode === null ? true : config.reactStrictMode,\n 'process.env.__NEXT_OPTIMIZE_CSS':\n (config.experimental.optimizeCss && !dev) ?? false,\n 'process.env.__NEXT_SCRIPT_WORKERS':\n (config.experimental.nextScriptWorkers && !dev) ?? false,\n 'process.env.__NEXT_SCROLL_RESTORATION':\n config.experimental.scrollRestoration ?? false,\n ...getImageConfig(config, dev),\n 'process.env.__NEXT_ROUTER_BASEPATH': config.basePath,\n 'process.env.__NEXT_STRICT_NEXT_HEAD':\n config.experimental.strictNextHead ?? true,\n 'process.env.__NEXT_HAS_REWRITES': hasRewrites,\n 'process.env.__NEXT_CONFIG_OUTPUT': config.output,\n 'process.env.__NEXT_I18N_SUPPORT': !!config.i18n,\n 'process.env.__NEXT_I18N_DOMAINS': config.i18n?.domains ?? false,\n 'process.env.__NEXT_NO_MIDDLEWARE_URL_NORMALIZE':\n config.skipMiddlewareUrlNormalize,\n 'process.env.__NEXT_EXTERNAL_MIDDLEWARE_REWRITE_RESOLVE':\n config.experimental.externalMiddlewareRewritesResolve ?? false,\n 'process.env.__NEXT_MANUAL_TRAILING_SLASH':\n config.skipTrailingSlashRedirect,\n 'process.env.__NEXT_HAS_WEB_VITALS_ATTRIBUTION':\n (config.experimental.webVitalsAttribution &&\n config.experimental.webVitalsAttribution.length > 0) ??\n false,\n 'process.env.__NEXT_WEB_VITALS_ATTRIBUTION':\n config.experimental.webVitalsAttribution ?? false,\n 'process.env.__NEXT_LINK_NO_TOUCH_START':\n config.experimental.linkNoTouchStart ?? false,\n 'process.env.__NEXT_ASSET_PREFIX': config.assetPrefix,\n 'process.env.__NEXT_EXPERIMENTAL_AUTH_INTERRUPTS':\n !!config.experimental.authInterrupts,\n ...(isNodeOrEdgeCompilation\n ? {\n // Fix bad-actors in the npm ecosystem (e.g. `node-formidable`)\n // This is typically found in unmaintained modules from the\n // pre-webpack era (common in server-side code)\n 'global.GENTLY': false,\n }\n : undefined),\n ...(isNodeOrEdgeCompilation\n ? {\n 'process.env.__NEXT_EXPERIMENTAL_REACT':\n needsExperimentalReact(config),\n }\n : undefined),\n 'process.env.__NEXT_EXPERIMENTAL_NEW_DEV_OVERLAY':\n // When `__NEXT_EXPERIMENTAL_NEW_DEV_OVERLAY` is set on CI,\n // we need to pass it here so it can be enabled.\n process.env.__NEXT_EXPERIMENTAL_NEW_DEV_OVERLAY === 'true' ||\n config.experimental.newDevOverlay ||\n false,\n 'process.env.__NEXT_REACT_OWNER_STACK':\n config.experimental.reactOwnerStack ?? false,\n }\n\n const userDefines = config.compiler?.define ?? {}\n for (const key in userDefines) {\n if (defineEnv.hasOwnProperty(key)) {\n throw new Error(\n `The \\`compiler.define\\` option is configured to replace the \\`${key}\\` variable. This variable is either part of a Next.js built-in or is already configured via the \\`env\\` option.`\n )\n }\n defineEnv[key] = userDefines[key]\n }\n\n return serializeDefineEnv(defineEnv)\n}\n\nexport function getDefineEnvPlugin(options: DefineEnvPluginOptions) {\n return new webpack.DefinePlugin(getDefineEnv(options))\n}\n"],"names":["webpack","needsExperimentalReact","checkIsAppPPREnabled","errorIfEnvConflicted","config","key","isPrivateKey","test","hasNextRuntimeKey","Error","configFileName","getNextPublicEnvironmentVariables","defineEnv","process","env","startsWith","value","getNextConfigEnv","serializeDefineEnv","defineEnvStringified","JSON","stringify","getImageConfig","dev","deviceSizes","images","imageSizes","qualities","path","loader","dangerouslyAllowSVG","unoptimized","domains","remotePatterns","localPatterns","output","getDefineEnv","isTurbopack","clientRouterFilters","distDir","fetchCacheKeyPrefix","hasRewrites","isClient","isEdgeServer","isNodeOrEdgeCompilation","isNodeServer","middlewareMatchers","nextPublicEnv","nextConfigEnv","isPPREnabled","experimental","ppr","isDynamicIOEnabled","dynamicIO","isUseCacheEnabled","useCache","__NEXT_DEFINE_ENV","EdgeRuntime","NEXT_EDGE_RUNTIME_PROVIDER","allowDevelopmentBuild","Boolean","appNavFailHandling","devIndicators","appIsrStatus","deploymentId","manualClientBasePath","isNaN","Number","staleTimes","dynamic","static","clientRouterFilter","staticFilter","dynamicFilter","clientSegmentCache","optimisticClientCache","middlewarePrefetch","crossOrigin","__NEXT_TEST_MODE","trailingSlash","buildActivity","buildActivityPosition","reactStrictMode","optimizeCss","nextScriptWorkers","scrollRestoration","basePath","strictNextHead","i18n","skipMiddlewareUrlNormalize","externalMiddlewareRewritesResolve","skipTrailingSlashRedirect","webVitalsAttribution","length","linkNoTouchStart","assetPrefix","authInterrupts","undefined","__NEXT_EXPERIMENTAL_NEW_DEV_OVERLAY","newDevOverlay","reactOwnerStack","userDefines","compiler","define","hasOwnProperty","getDefineEnvPlugin","options","DefinePlugin"],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QAAQ2G,YAAY,CAACvE,aAAasE;AAC/C"}
@@ -0,0 +1,177 @@
1
+ import { yellow, green, blue } from '../../../lib/picocolors';
2
+ const PLUGIN_NAME = 'SlowModuleDetectionPlugin';
3
+ const TreeSymbols = {
4
+ VERTICAL_LINE: '│ ',
5
+ BRANCH: '├─ '
6
+ };
7
+ const PATH_TRUNCATION_LENGTH = 120;
8
+ // Matches node_modules paths, including pnpm-style paths
9
+ const NODE_MODULES_PATH_PATTERN = /node_modules(?:\/\.pnpm)?\/(.*)/;
10
+ const getModuleIdentifier = (module)=>{
11
+ const debugId = module.debugId;
12
+ return String(debugId);
13
+ };
14
+ const getModuleDisplayName = (module)=>{
15
+ const resourcePath = 'resource' in module && typeof module.resource === 'string' ? module.resource : undefined;
16
+ if (!resourcePath) {
17
+ return undefined;
18
+ }
19
+ let displayPath = resourcePath.replace(process.cwd(), '.');
20
+ const nodeModulesMatch = displayPath.match(NODE_MODULES_PATH_PATTERN);
21
+ if (nodeModulesMatch) {
22
+ return nodeModulesMatch[1];
23
+ }
24
+ return displayPath;
25
+ };
26
+ /**
27
+ * Truncates a path to a maximum length. If the path exceeds this length,
28
+ * it will be truncated in the middle and replaced with '...'.
29
+ */ function truncatePath(path, maxLength) {
30
+ // If the path length is within the limit, return it as is
31
+ if (path.length <= maxLength) return path;
32
+ // Calculate the available length for the start and end segments after accounting for '...'
33
+ const availableLength = maxLength - 3;
34
+ const startSegmentLength = Math.ceil(availableLength / 2);
35
+ const endSegmentLength = Math.floor(availableLength / 2);
36
+ // Extract the start and end segments of the path
37
+ const startSegment = path.slice(0, startSegmentLength);
38
+ const endSegment = path.slice(-endSegmentLength);
39
+ // Return the truncated path with '...' in the middle
40
+ return `${startSegment}...${endSegment}`;
41
+ }
42
+ class ModuleBuildTimeAnalyzer {
43
+ constructor(options){
44
+ this.options = options;
45
+ this.pendingModules = [];
46
+ this.modules = new Map();
47
+ this.moduleParents = new Map();
48
+ this.moduleChildren = new Map();
49
+ this.isFinalized = false;
50
+ this.moduleBuildTimes = new WeakMap();
51
+ this.buildTimeThresholdMs = options.buildTimeThresholdMs;
52
+ }
53
+ recordModuleBuildTime(module, duration) {
54
+ // Webpack guarantees that no more modules will be built after finishModules hook is called,
55
+ // where we generate the report. This check is just a defensive measure.
56
+ if (this.isFinalized) {
57
+ throw Object.defineProperty(new Error(`Invariant (SlowModuleDetectionPlugin): Module is recorded after the report is generated. This is a Next.js internal bug.`), "__NEXT_ERROR_CODE", {
58
+ value: "E630",
59
+ enumerable: false
60
+ });
61
+ }
62
+ if (duration < this.buildTimeThresholdMs) {
63
+ return; // Skip fast modules
64
+ }
65
+ this.moduleBuildTimes.set(module, duration);
66
+ this.pendingModules.push(module);
67
+ }
68
+ /**
69
+ * For each slow module, traverses up the dependency chain to find all ancestor modules.
70
+ * Builds a directed graph where:
71
+ * 1. Each slow module and its ancestors become nodes
72
+ * 2. Edges represent "imported by" relationships
73
+ * 3. Root nodes are entry points with no parents
74
+ *
75
+ * The resulting graph allows us to visualize the import chains that led to slow builds.
76
+ */ prepareReport(compilation) {
77
+ for (const module of this.pendingModules){
78
+ const chain = new Set();
79
+ // Walk up the module graph until we hit a root module (no issuer) to populate the chain
80
+ {
81
+ let currentModule = module;
82
+ chain.add(currentModule);
83
+ while(true){
84
+ const issuerModule = compilation.moduleGraph.getIssuer(currentModule);
85
+ if (!issuerModule) break;
86
+ if (chain.has(issuerModule)) {
87
+ throw Object.defineProperty(new Error(`Invariant (SlowModuleDetectionPlugin): Circular dependency detected in module graph. This is a Next.js internal bug.`), "__NEXT_ERROR_CODE", {
88
+ value: "E631",
89
+ enumerable: false
90
+ });
91
+ }
92
+ chain.add(issuerModule);
93
+ currentModule = issuerModule;
94
+ }
95
+ }
96
+ // Add all visited modules to our graph and create parent-child relationships
97
+ let previousModule = null;
98
+ for (const currentModule of chain){
99
+ const moduleId = getModuleIdentifier(currentModule);
100
+ if (!this.modules.has(moduleId)) {
101
+ this.modules.set(moduleId, currentModule);
102
+ }
103
+ if (previousModule) {
104
+ this.moduleParents.set(previousModule, currentModule);
105
+ let parentChildren = this.moduleChildren.get(currentModule);
106
+ if (!parentChildren) {
107
+ parentChildren = new Map();
108
+ this.moduleChildren.set(currentModule, parentChildren);
109
+ }
110
+ parentChildren.set(getModuleIdentifier(previousModule), previousModule);
111
+ }
112
+ previousModule = currentModule;
113
+ }
114
+ }
115
+ this.isFinalized = true;
116
+ }
117
+ generateReport(compilation) {
118
+ if (!this.isFinalized) {
119
+ this.prepareReport(compilation);
120
+ }
121
+ // Find root modules (those with no parents)
122
+ const rootModules = [
123
+ ...this.modules.values()
124
+ ].filter((node)=>!this.moduleParents.has(node));
125
+ const formatModuleNode = (node, depth)=>{
126
+ const moduleName = getModuleDisplayName(node) || '';
127
+ if (!moduleName) {
128
+ return formatChildModules(node, depth);
129
+ }
130
+ const prefix = ' ' + TreeSymbols.VERTICAL_LINE.repeat(depth) + TreeSymbols.BRANCH;
131
+ const moduleText = blue(truncatePath(moduleName, PATH_TRUNCATION_LENGTH - prefix.length));
132
+ const buildTimeMs = this.moduleBuildTimes.get(node);
133
+ const duration = buildTimeMs ? yellow(` (${Math.ceil(buildTimeMs)}ms)`) : '';
134
+ return prefix + moduleText + duration + '\n' + formatChildModules(node, depth + 1);
135
+ };
136
+ const formatChildModules = (node, depth)=>{
137
+ const children = this.moduleChildren.get(node);
138
+ if (!children) return '';
139
+ return [
140
+ ...children
141
+ ].map(([_, child])=>formatModuleNode(child, depth)).join('');
142
+ };
143
+ const report = rootModules.map((root)=>formatModuleNode(root, 0)).join('');
144
+ if (report) {
145
+ console.log(green(`🐌 Detected slow modules while compiling ${this.options.compilerType}:`) + '\n' + report);
146
+ }
147
+ }
148
+ }
149
+ export default class SlowModuleDetectionPlugin {
150
+ constructor(options){
151
+ this.options = options;
152
+ this.apply = (compiler)=>{
153
+ compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation)=>{
154
+ const analyzer = new ModuleBuildTimeAnalyzer(this.options);
155
+ const moduleBuildStartTimes = new WeakMap();
156
+ compilation.hooks.buildModule.tap(PLUGIN_NAME, (module)=>{
157
+ moduleBuildStartTimes.set(module, performance.now());
158
+ });
159
+ compilation.hooks.succeedModule.tap(PLUGIN_NAME, (module)=>{
160
+ const startTime = moduleBuildStartTimes.get(module);
161
+ if (!startTime) {
162
+ throw Object.defineProperty(new Error(`Invariant (SlowModuleDetectionPlugin): Unable to find the start time for a module build. This is a Next.js internal bug.`), "__NEXT_ERROR_CODE", {
163
+ value: "E629",
164
+ enumerable: false
165
+ });
166
+ }
167
+ analyzer.recordModuleBuildTime(module, performance.now() - startTime);
168
+ });
169
+ compilation.hooks.finishModules.tap(PLUGIN_NAME, ()=>{
170
+ analyzer.generateReport(compilation);
171
+ });
172
+ });
173
+ };
174
+ }
175
+ }
176
+
177
+ //# sourceMappingURL=slow-module-detection-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/build/webpack/plugins/slow-module-detection-plugin.ts"],"sourcesContent":["import type { Compiler, Module, Compilation } from 'webpack'\nimport type { CompilerNameValues } from '../../../shared/lib/constants'\nimport { yellow, green, blue } from '../../../lib/picocolors'\n\nconst PLUGIN_NAME = 'SlowModuleDetectionPlugin'\n\nconst TreeSymbols = {\n VERTICAL_LINE: '│ ',\n BRANCH: '├─ ',\n} as const\n\nconst PATH_TRUNCATION_LENGTH = 120\n\n// Matches node_modules paths, including pnpm-style paths\nconst NODE_MODULES_PATH_PATTERN = /node_modules(?:\\/\\.pnpm)?\\/(.*)/\n\ninterface ModuleBuildTimeAnalyzerOptions {\n compilerType: CompilerNameValues\n buildTimeThresholdMs: number\n}\n\nconst getModuleIdentifier = (module: Module): string => {\n const debugId = module.debugId\n return String(debugId)\n}\n\nconst getModuleDisplayName = (module: Module): string | undefined => {\n const resourcePath =\n 'resource' in module && typeof module.resource === 'string'\n ? module.resource\n : undefined\n\n if (!resourcePath) {\n return undefined\n }\n\n let displayPath = resourcePath.replace(process.cwd(), '.')\n\n const nodeModulesMatch = displayPath.match(NODE_MODULES_PATH_PATTERN)\n if (nodeModulesMatch) {\n return nodeModulesMatch[1]\n }\n\n return displayPath\n}\n\n/**\n * Truncates a path to a maximum length. If the path exceeds this length,\n * it will be truncated in the middle and replaced with '...'.\n */\nfunction truncatePath(path: string, maxLength: number): string {\n // If the path length is within the limit, return it as is\n if (path.length <= maxLength) return path\n\n // Calculate the available length for the start and end segments after accounting for '...'\n const availableLength = maxLength - 3\n const startSegmentLength = Math.ceil(availableLength / 2)\n const endSegmentLength = Math.floor(availableLength / 2)\n\n // Extract the start and end segments of the path\n const startSegment = path.slice(0, startSegmentLength)\n const endSegment = path.slice(-endSegmentLength)\n\n // Return the truncated path with '...' in the middle\n return `${startSegment}...${endSegment}`\n}\n\nclass ModuleBuildTimeAnalyzer {\n private pendingModules: Module[] = []\n private modules = new Map<string, Module>()\n private moduleParents = new Map<Module, Module>()\n private moduleChildren = new Map<Module, Map<string, Module>>()\n private isFinalized = false\n private buildTimeThresholdMs: number\n private moduleBuildTimes = new WeakMap<Module, number>()\n\n constructor(private options: ModuleBuildTimeAnalyzerOptions) {\n this.buildTimeThresholdMs = options.buildTimeThresholdMs\n }\n\n recordModuleBuildTime(module: Module, duration: number) {\n // Webpack guarantees that no more modules will be built after finishModules hook is called,\n // where we generate the report. This check is just a defensive measure.\n if (this.isFinalized) {\n throw new Error(\n `Invariant (SlowModuleDetectionPlugin): Module is recorded after the report is generated. This is a Next.js internal bug.`\n )\n }\n\n if (duration < this.buildTimeThresholdMs) {\n return // Skip fast modules\n }\n\n this.moduleBuildTimes.set(module, duration)\n this.pendingModules.push(module)\n }\n\n /**\n * For each slow module, traverses up the dependency chain to find all ancestor modules.\n * Builds a directed graph where:\n * 1. Each slow module and its ancestors become nodes\n * 2. Edges represent \"imported by\" relationships\n * 3. Root nodes are entry points with no parents\n *\n * The resulting graph allows us to visualize the import chains that led to slow builds.\n */\n private prepareReport(compilation: Compilation) {\n for (const module of this.pendingModules) {\n const chain = new Set<Module>()\n\n // Walk up the module graph until we hit a root module (no issuer) to populate the chain\n {\n let currentModule = module\n chain.add(currentModule)\n while (true) {\n const issuerModule = compilation.moduleGraph.getIssuer(currentModule)\n if (!issuerModule) break\n if (chain.has(issuerModule)) {\n throw new Error(\n `Invariant (SlowModuleDetectionPlugin): Circular dependency detected in module graph. This is a Next.js internal bug.`\n )\n }\n chain.add(issuerModule)\n currentModule = issuerModule\n }\n }\n\n // Add all visited modules to our graph and create parent-child relationships\n let previousModule: Module | null = null\n for (const currentModule of chain) {\n const moduleId = getModuleIdentifier(currentModule)\n if (!this.modules.has(moduleId)) {\n this.modules.set(moduleId, currentModule)\n }\n\n if (previousModule) {\n this.moduleParents.set(previousModule, currentModule)\n\n let parentChildren = this.moduleChildren.get(currentModule)\n if (!parentChildren) {\n parentChildren = new Map()\n this.moduleChildren.set(currentModule, parentChildren)\n }\n parentChildren.set(\n getModuleIdentifier(previousModule),\n previousModule\n )\n }\n\n previousModule = currentModule\n }\n }\n this.isFinalized = true\n }\n\n generateReport(compilation: Compilation) {\n if (!this.isFinalized) {\n this.prepareReport(compilation)\n }\n\n // Find root modules (those with no parents)\n const rootModules = [...this.modules.values()].filter(\n (node) => !this.moduleParents.has(node)\n )\n\n const formatModuleNode = (node: Module, depth: number): string => {\n const moduleName = getModuleDisplayName(node) || ''\n\n if (!moduleName) {\n return formatChildModules(node, depth)\n }\n\n const prefix =\n ' ' + TreeSymbols.VERTICAL_LINE.repeat(depth) + TreeSymbols.BRANCH\n\n const moduleText = blue(\n truncatePath(moduleName, PATH_TRUNCATION_LENGTH - prefix.length)\n )\n\n const buildTimeMs = this.moduleBuildTimes.get(node)\n const duration = buildTimeMs\n ? yellow(` (${Math.ceil(buildTimeMs)}ms)`)\n : ''\n\n return (\n prefix +\n moduleText +\n duration +\n '\\n' +\n formatChildModules(node, depth + 1)\n )\n }\n\n const formatChildModules = (node: Module, depth: number): string => {\n const children = this.moduleChildren.get(node)\n if (!children) return ''\n\n return [...children]\n .map(([_, child]) => formatModuleNode(child, depth))\n .join('')\n }\n\n const report = rootModules.map((root) => formatModuleNode(root, 0)).join('')\n\n if (report) {\n console.log(\n green(\n `🐌 Detected slow modules while compiling ${this.options.compilerType}:`\n ) +\n '\\n' +\n report\n )\n }\n }\n}\n\nexport default class SlowModuleDetectionPlugin {\n constructor(private options: ModuleBuildTimeAnalyzerOptions) {}\n\n apply = (compiler: Compiler) => {\n compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {\n const analyzer = new ModuleBuildTimeAnalyzer(this.options)\n const moduleBuildStartTimes = new WeakMap<Module, number>()\n\n compilation.hooks.buildModule.tap(PLUGIN_NAME, (module) => {\n moduleBuildStartTimes.set(module, performance.now())\n })\n\n compilation.hooks.succeedModule.tap(PLUGIN_NAME, (module) => {\n const startTime = moduleBuildStartTimes.get(module)\n if (!startTime) {\n throw new Error(\n `Invariant (SlowModuleDetectionPlugin): Unable to find the start time for a module build. This is a Next.js internal bug.`\n )\n }\n analyzer.recordModuleBuildTime(module, performance.now() - startTime)\n })\n\n compilation.hooks.finishModules.tap(PLUGIN_NAME, () => {\n analyzer.generateReport(compilation)\n })\n })\n }\n}\n"],"names":["yellow","green","blue","PLUGIN_NAME","TreeSymbols","VERTICAL_LINE","BRANCH","PATH_TRUNCATION_LENGTH","NODE_MODULES_PATH_PATTERN","getModuleIdentifier","module","debugId","String","getModuleDisplayName","resourcePath","resource","undefined","displayPath","replace","process","cwd","nodeModulesMatch","match","truncatePath","path","maxLength","length","availableLength","startSegmentLength","Math","ceil","endSegmentLength","floor","startSegment","slice","endSegment","ModuleBuildTimeAnalyzer","constructor","options","pendingModules","modules","Map","moduleParents","moduleChildren","isFinalized","moduleBuildTimes","WeakMap","buildTimeThresholdMs","recordModuleBuildTime","duration","Error","set","push","prepareReport","compilation","chain","Set","currentModule","add","issuerModule","moduleGraph","getIssuer","has","previousModule","moduleId","parentChildren","get","generateReport","rootModules","values","filter","node","formatModuleNode","depth","moduleName","formatChildModules","prefix","repeat","moduleText","buildTimeMs","children","map","_","child","join","report","root","console","log","compilerType","SlowModuleDetectionPlugin","apply","compiler","hooks","tap","analyzer","moduleBuildStartTimes","buildModule","performance","now","succeedModule","startTime","finishModules"],"mappings":"AAEA,SAASA,MAAM,EAAEC,KAAK,EAAEC,IAAI,QAAQ,0BAAyB;AAE7D,MAAMC,cAAc;AAEpB,MAAMC,cAAc;IAClBC,eAAe;IACfC,QAAQ;AACV;AAEA,MAAMC,yBAAyB;AAE/B,yDAAyD;AACzD,MAAMC,4BAA4B;AAOlC,MAAMC,sBAAsB,CAACC;IAC3B,MAAMC,UAAUD,OAAOC,OAAO;IAC9B,OAAOC,OAAOD;AAChB;AAEA,MAAME,uBAAuB,CAACH;IAC5B,MAAMI,eACJ,cAAcJ,UAAU,OAAOA,OAAOK,QAAQ,KAAK,WAC/CL,OAAOK,QAAQ,GACfC;IAEN,IAAI,CAACF,cAAc;QACjB,OAAOE;IACT;IAEA,IAAIC,cAAcH,aAAaI,OAAO,CAACC,QAAQC,GAAG,IAAI;IAEtD,MAAMC,mBAAmBJ,YAAYK,KAAK,CAACd;IAC3C,IAAIa,kBAAkB;QACpB,OAAOA,gBAAgB,CAAC,EAAE;IAC5B;IAEA,OAAOJ;AACT;AAEA;;;CAGC,GACD,SAASM,aAAaC,IAAY,EAAEC,SAAiB;IACnD,0DAA0D;IAC1D,IAAID,KAAKE,MAAM,IAAID,WAAW,OAAOD;IAErC,2FAA2F;IAC3F,MAAMG,kBAAkBF,YAAY;IACpC,MAAMG,qBAAqBC,KAAKC,IAAI,CAACH,kBAAkB;IACvD,MAAMI,mBAAmBF,KAAKG,KAAK,CAACL,kBAAkB;IAEtD,iDAAiD;IACjD,MAAMM,eAAeT,KAAKU,KAAK,CAAC,GAAGN;IACnC,MAAMO,aAAaX,KAAKU,KAAK,CAAC,CAACH;IAE/B,qDAAqD;IACrD,OAAO,GAAGE,aAAa,GAAG,EAAEE,YAAY;AAC1C;AAEA,MAAMC;IASJC,YAAY,AAAQC,OAAuC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AAa,CAACR,GAAG,CAAC3F,aAAa;oBAC/C4F,SAAS5B,cAAc,CAACb;gBAC1B;YACF;QACF;IAzB8D;AA0BhE"}
@@ -530,8 +530,19 @@ export default async function getBaseWebpackConfig(dir, { buildId, encryptionKey
530
530
  pageExtensionsRegex
531
531
  ];
532
532
  const builtinModules = require('module').builtinModules;
533
+ const shouldEnableSlowModuleDetection = !!config.experimental.slowModuleDetection && dev;
534
+ const getParallelism = ()=>{
535
+ const override = Number(process.env.NEXT_WEBPACK_PARALLELISM);
536
+ if (shouldEnableSlowModuleDetection) {
537
+ if (override) {
538
+ console.warn('NEXT_WEBPACK_PARALLELISM is specified but will be ignored due to experimental.slowModuleDetection being enabled.');
539
+ }
540
+ return 1;
541
+ }
542
+ return override || undefined;
543
+ };
533
544
  let webpackConfig = {
534
- parallelism: Number(process.env.NEXT_WEBPACK_PARALLELISM) || undefined,
545
+ parallelism: getParallelism(),
535
546
  ...isNodeServer ? {
536
547
  externalsPresets: {
537
548
  node: true
@@ -1400,7 +1411,7 @@ export default async function getBaseWebpackConfig(dir, { buildId, encryptionKey
1400
1411
  isClient && new CopyFilePlugin({
1401
1412
  // file path to build output of `@next/polyfill-nomodule`
1402
1413
  filePath: require.resolve('./polyfills/polyfill-nomodule'),
1403
- cacheKey: "15.2.0-canary.28",
1414
+ cacheKey: "15.2.0-canary.29",
1404
1415
  name: `static/chunks/polyfills${dev ? '' : '-[hash]'}.js`,
1405
1416
  minimize: false,
1406
1417
  info: {
@@ -1495,7 +1506,11 @@ export default async function getBaseWebpackConfig(dir, { buildId, encryptionKey
1495
1506
  ],
1496
1507
  SWCBinaryTarget
1497
1508
  ].filter(Boolean))),
1498
- !dev && isNodeServer && new (require('./webpack/plugins/telemetry-plugin/telemetry-plugin')).TelemetryPlugin(new Map())
1509
+ !dev && isNodeServer && new (require('./webpack/plugins/telemetry-plugin/telemetry-plugin')).TelemetryPlugin(new Map()),
1510
+ shouldEnableSlowModuleDetection && new (require('./webpack/plugins/slow-module-detection-plugin')).default({
1511
+ compilerType,
1512
+ ...config.experimental.slowModuleDetection
1513
+ })
1499
1514
  ].filter(Boolean)
1500
1515
  };
1501
1516
  // Support tsconfig and jsconfig baseUrl
@@ -1629,7 +1644,7 @@ export default async function getBaseWebpackConfig(dir, { buildId, encryptionKey
1629
1644
  // - Next.js location on disk (some loaders use absolute paths and some resolve options depend on absolute paths)
1630
1645
  // - Next.js version
1631
1646
  // - next.config.js keys that affect compilation
1632
- version: `${__dirname}|${"15.2.0-canary.28"}|${configVars}`,
1647
+ version: `${__dirname}|${"15.2.0-canary.29"}|${configVars}`,
1633
1648
  cacheDirectory: path.join(distDir, 'cache', 'webpack'),
1634
1649
  // For production builds, it's more efficient to compress all cache files together instead of compression each one individually.
1635
1650
  // So we disable compression here and allow the build runner to take care of compressing the cache as a whole.