next 15.4.2-canary.25 → 15.4.2-canary.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/bin/next +1 -1
  2. package/dist/build/handle-externals.js +4 -0
  3. package/dist/build/handle-externals.js.map +1 -1
  4. package/dist/build/index.js +2 -2
  5. package/dist/build/swc/index.js +1 -1
  6. package/dist/build/webpack/plugins/middleware-plugin.js +7 -3
  7. package/dist/build/webpack/plugins/middleware-plugin.js.map +1 -1
  8. package/dist/build/webpack-config.js +11 -2
  9. package/dist/build/webpack-config.js.map +1 -1
  10. package/dist/client/app-bootstrap.js +1 -1
  11. package/dist/client/index.js +1 -1
  12. package/dist/compiled/next-server/pages-api-turbo.runtime.dev.js +1 -1
  13. package/dist/compiled/next-server/pages-api-turbo.runtime.dev.js.map +1 -1
  14. package/dist/compiled/next-server/pages-api.runtime.prod.js +1 -1
  15. package/dist/compiled/next-server/pages-api.runtime.prod.js.map +1 -1
  16. package/dist/compiled/next-server/pages-turbo.runtime.dev.js +1 -1
  17. package/dist/compiled/next-server/pages-turbo.runtime.dev.js.map +1 -1
  18. package/dist/compiled/next-server/pages.runtime.prod.js +1 -1
  19. package/dist/compiled/next-server/pages.runtime.prod.js.map +1 -1
  20. package/dist/esm/build/handle-externals.js +4 -0
  21. package/dist/esm/build/handle-externals.js.map +1 -1
  22. package/dist/esm/build/index.js +2 -2
  23. package/dist/esm/build/swc/index.js +1 -1
  24. package/dist/esm/build/webpack/plugins/middleware-plugin.js +7 -3
  25. package/dist/esm/build/webpack/plugins/middleware-plugin.js.map +1 -1
  26. package/dist/esm/build/webpack-config.js +11 -2
  27. package/dist/esm/build/webpack-config.js.map +1 -1
  28. package/dist/esm/client/app-bootstrap.js +1 -1
  29. package/dist/esm/client/index.js +1 -1
  30. package/dist/esm/server/dev/hot-reloader-turbopack.js +1 -1
  31. package/dist/esm/server/dev/hot-reloader-webpack.js +1 -1
  32. package/dist/esm/server/lib/app-info-log.js +1 -1
  33. package/dist/esm/server/lib/start-server.js +1 -1
  34. package/dist/esm/shared/lib/canary-only.js +1 -1
  35. package/dist/server/dev/hot-reloader-turbopack.js +1 -1
  36. package/dist/server/dev/hot-reloader-webpack.js +1 -1
  37. package/dist/server/lib/app-info-log.js +1 -1
  38. package/dist/server/lib/start-server.js +1 -1
  39. package/dist/shared/lib/canary-only.js +1 -1
  40. package/dist/telemetry/anonymous-meta.js +1 -1
  41. package/dist/telemetry/events/session-stopped.js +2 -2
  42. package/dist/telemetry/events/version.js +2 -2
  43. package/package.json +15 -15
@@ -111,6 +111,10 @@ export function makeExternalHandler({ config, optOutBundlingPackageRegex, transp
111
111
  if (reactPackagesRegex.test(request) && !isAppLayer) {
112
112
  return `commonjs ${request}`;
113
113
  }
114
+ // Handle Bun builtins as external modules
115
+ if (request === 'bun' || request.startsWith('bun:')) {
116
+ return `commonjs ${request}`;
117
+ }
114
118
  const notExternalModules = /^(?:private-next-pages\/|next\/(?:dist\/pages\/|(?:app|cache|document|link|form|head|image|legacy\/image|constants|dynamic|script|navigation|headers|router|compat\/router|server)$)|string-hash|private-next-rsc-action-validate|private-next-rsc-action-client-wrapper|private-next-rsc-server-reference|private-next-rsc-cache-wrapper|private-next-rsc-track-dynamic-import$)/;
115
119
  if (notExternalModules.test(request)) {
116
120
  return;
@@ -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, shouldUseReactServerCondition } 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|cache|document|link|form|head|image|legacy\\/image|constants|dynamic|script|navigation|headers|router|compat\\/router|server)$)|string-hash|private-next-rsc-action-validate|private-next-rsc-action-client-wrapper|private-next-rsc-server-reference|private-next-rsc-cache-wrapper|private-next-rsc-track-dynamic-import$)/\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 shouldUseReactServerCondition(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":["defaultOverrides","BARREL_OPTIMIZATION_PREFIX","path","NODE_BASE_ESM_RESOLVE_OPTIONS","NODE_BASE_RESOLVE_OPTIONS","NODE_ESM_RESOLVE_OPTIONS","NODE_RESOLVE_OPTIONS","isWebpackBundledLayer","shouldUseReactServerCondition","normalizePathSep","reactPackagesRegex","pathSeparators","optionalEsmPart","externalFileEnd","nextDist","externalPattern","RegExp","nodeModulesRegex","isResourceInPackages","resource","packageNames","packageDirMapping","some","p","has","startsWith","get","sep","includes","join","replace","resolveExternal","dir","esmExternalsConfig","context","request","isEsmRequested","getResolve","isLocalCallback","baseResolveCheck","esmResolveOptions","nodeResolveOptions","baseEsmResolveOptions","baseResolveOptions","esmExternals","looseEsmExternals","res","isEsm","preferEsmOptions","preferEsm","resolveOptions","resolve","err","localRes","baseRes","baseIsEsm","baseResolve","makeExternalHandler","config","optOutBundlingPackageRegex","transpiledPackages","resolvedExternalPackageDirs","experimental","handleExternals","dependencyType","layer","isLocal","posix","isAbsolute","process","platform","win32","isAppLayer","test","notExternalModules","resolveNextExternal","resolveResult","undefined","isOptOutBundling","Error","externalType","Map","pkg","pkgRes","set","dirname","resolvedBundlingOptOutRes","resolveBundlingOptOutPackages","resolvedRes","shouldBundlePages","bundlePagesRouterDependencies","shouldBeB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AAO,GAAGX,aAAa,CAAC,EAAE7C,SAAS,CAAC,0CAA0C;;QAChF;IACF;AACF;AAEA;;;;;;CAMC,GACD,SAASwC,oBAAoBtB,QAAgB;IAC3C,MAAMuC,aAAa7E,gBAAgB0D,IAAI,CAACpB;IAExC,sFAAsF;IACtF,sGAAsG;IACtG,IAAIuC,YAAY;QACd,oGAAoG;QACpG,oCAAoC;QACpC,OAAO,CAAC,SAAS,EAAEnF,iBACjB4C,SAASvB,OAAO,CAAC,oBAAoB,eACpC;IACL;AACF","ignoreList":[0]}
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, shouldUseReactServerCondition } 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 // Handle Bun builtins as external modules\n if (request === 'bun' || request.startsWith('bun:')) {\n return `commonjs ${request}`\n }\n\n const notExternalModules =\n /^(?:private-next-pages\\/|next\\/(?:dist\\/pages\\/|(?:app|cache|document|link|form|head|image|legacy\\/image|constants|dynamic|script|navigation|headers|router|compat\\/router|server)$)|string-hash|private-next-rsc-action-validate|private-next-rsc-action-client-wrapper|private-next-rsc-server-reference|private-next-rsc-cache-wrapper|private-next-rsc-track-dynamic-import$)/\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 shouldUseReactServerCondition(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":["defaultOverrides","BARREL_OPTIMIZATION_PREFIX","path","NODE_BASE_ESM_RESOLVE_OPTIONS","NODE_BASE_RESOLVE_OPTIONS","NODE_ESM_RESOLVE_OPTIONS","NODE_RESOLVE_OPTIONS","isWebpackBundledLayer","shouldUseReactServerCondition","normalizePathSep","reactPackagesRegex","pathSeparators","optionalEsmPart","externalFileEnd","nextDist","externalPattern","RegExp","nodeModulesRegex","isResourceInPackages","resource","packageNames","packageDirMapping","some","p","has","startsWith","get","sep","includes","join","replace","resolveExternal","dir","esmExternalsConfig","context","request","isEsmRequested","getResolve","isLocalCallback","baseResolveCheck","esmResolveOptions","nodeResolveOptions","baseEsmResolveOptions","baseResolveOptions","esmExternals","looseEsmExternals","res","isEsm","preferEsmOptions","preferEsm","resolveOptions","resolve","err","localRes","baseRes","baseIsEsm","baseResolve","makeExternalHandler","config","optOutBundlingPackageRegex","transpiledPackages","resolvedExternalPackageDirs","experimental","handleExternals","dependencyType","layer","isLocal","posix","isAbsolute","process","platform","win32","isAppLayer","test","notExternalModules","resolveNextExternal","resolveResult","undefined","isOptOutBundling","Error","externalType","Map","pkg","pkgRes","set","dirname","resolvedBundlingOptOutRes","resolveBundlingOptOutPackages","resolvedRes","shouldBundlePages","bundlePagesRouterDependencies","shouldBeBundled","isExternal"],"mappings":"AAGA,SAASA,gBAAgB,QAAQ,yBAAwB;AACzD,SAASC,0BAA0B,QAAQ,0BAAyB;AACpE,OAAOC,UAAU,gCAA+B;AAChD,SACEC,6BAA6B,EAC7BC,yBAAyB,EACzBC,wBAAwB,EACxBC,oBAAoB,QACf,mBAAkB;AACzB,SAASC,qBAAqB,EAAEC,6BAA6B,QAAQ,UAAS;AAC9E,SAASC,gBAAgB,QAAQ,6CAA4C;AAC7E,MAAMC,qBAAqB;AAE3B,MAAMC,iBAAiB;AACvB,MAAMC,kBAAkB,CAAC,EAAE,EAAED,eAAe,KAAK,EAAEA,eAAe,CAAC,CAAC;AACpE,MAAME,kBAAkB;AACxB,MA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F","ignoreList":[0]}
@@ -322,7 +322,7 @@ export default async function build(dir, reactProductionProfiling = false, debug
322
322
  const nextBuildSpan = trace('next-build', undefined, {
323
323
  buildMode: experimentalBuildMode,
324
324
  isTurboBuild: String(isTurbopack),
325
- version: "15.4.2-canary.25"
325
+ version: "15.4.2-canary.26"
326
326
  });
327
327
  NextBuildContext.nextBuildSpan = nextBuildSpan;
328
328
  NextBuildContext.dir = dir;
@@ -709,7 +709,7 @@ export default async function build(dir, reactProductionProfiling = false, debug
709
709
  // Files outside of the distDir can be "type": "module"
710
710
  await writeFileUtf8(path.join(distDir, 'package.json'), '{"type": "commonjs"}');
711
711
  // These are written to distDir, so they need to come after creating and cleaning distDr.
712
- await recordFrameworkVersion("15.4.2-canary.25");
712
+ await recordFrameworkVersion("15.4.2-canary.26");
713
713
  await updateBuildDiagnostics({
714
714
  buildStage: 'start'
715
715
  });
@@ -11,7 +11,7 @@ import { isDeepStrictEqual } from 'util';
11
11
  import { getDefineEnv } from '../define-env';
12
12
  import { getReactCompilerLoader } from '../get-babel-loader-config';
13
13
  import { throwTurbopackInternalError } from '../../shared/lib/turbopack/internal-error';
14
- const nextVersion = "15.4.2-canary.25";
14
+ const nextVersion = "15.4.2-canary.26";
15
15
  const ArchName = arch();
16
16
  const PlatformName = platform();
17
17
  function infoLog(...args) {
@@ -136,6 +136,9 @@ function isInMiddlewareLayer(parser) {
136
136
  function isNodeJsModule(moduleName) {
137
137
  return require('module').builtinModules.includes(moduleName);
138
138
  }
139
+ function isBunModule(moduleName) {
140
+ return moduleName === 'bun' || moduleName.startsWith('bun:');
141
+ }
139
142
  function isDynamicCodeEvaluationAllowed(fileName, middlewareConfig, rootDir) {
140
143
  // Some packages are known to use `eval` but are safe to use in the Edge
141
144
  // Runtime because the dynamic code will never be executed.
@@ -293,9 +296,10 @@ function getCodeAnalyzer(params) {
293
296
  },
294
297
  sourceContent: source.toString()
295
298
  });
296
- if (!dev && isNodeJsModule(importedModule) && !SUPPORTED_NATIVE_MODULES.includes(importedModule)) {
299
+ if (!dev && (isNodeJsModule(importedModule) || isBunModule(importedModule)) && !SUPPORTED_NATIVE_MODULES.includes(importedModule)) {
300
+ const isBun = isBunModule(importedModule);
297
301
  compilation.warnings.push(buildWebpackError({
298
- message: `A Node.js module is loaded ('${importedModule}' at line ${node.loc.start.line}) which is not supported in the Edge Runtime.
302
+ message: `A ${isBun ? 'Bun' : 'Node.js'} module is loaded ('${importedModule}' at line ${node.loc.start.line}) which is not supported in the Edge Runtime.
299
303
  Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`,
300
304
  compilation,
301
305
  parser,
@@ -559,7 +563,7 @@ export function getEdgePolyfilledModules() {
559
563
  return records;
560
564
  }
561
565
  export async function handleWebpackExternalForEdgeRuntime({ request, context, contextInfo, getResolve }) {
562
- if ((contextInfo.issuerLayer === WEBPACK_LAYERS.middleware || contextInfo.issuerLayer === WEBPACK_LAYERS.apiEdge) && isNodeJsModule(request) && !supportedEdgePolyfills.has(request)) {
566
+ if ((contextInfo.issuerLayer === WEBPACK_LAYERS.middleware || contextInfo.issuerLayer === WEBPACK_LAYERS.apiEdge) && (isNodeJsModule(request) || isBunModule(request)) && !supportedEdgePolyfills.has(request)) {
563
567
  // allows user to provide and use their polyfills, as we do with buffer.
564
568
  try {
565
569
  await getResolve()(context, request);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/build/webpack/plugins/middleware-plugin.ts"],"sourcesContent":["import type {\n AssetBinding,\n EdgeMiddlewareMeta,\n} from '../loaders/get-module-build-info'\nimport type { EdgeSSRMeta } from '../loaders/get-module-build-info'\nimport type { MiddlewareMatcher } from '../../analysis/get-page-static-info'\nimport { getNamedMiddlewareRegex } from '../../../shared/lib/router/utils/route-regex'\nimport { getModuleBuildInfo } from '../loaders/get-module-build-info'\nimport { getSortedRoutes } from '../../../shared/lib/router/utils'\nimport { webpack, sources } from 'next/dist/compiled/webpack/webpack'\nimport picomatch from 'next/dist/compiled/picomatch'\nimport path from 'path'\nimport {\n EDGE_RUNTIME_WEBPACK,\n EDGE_UNSUPPORTED_NODE_APIS,\n MIDDLEWARE_BUILD_MANIFEST,\n CLIENT_REFERENCE_MANIFEST,\n MIDDLEWARE_MANIFEST,\n MIDDLEWARE_REACT_LOADABLE_MANIFEST,\n SUBRESOURCE_INTEGRITY_MANIFEST,\n NEXT_FONT_MANIFEST,\n SERVER_REFERENCE_MANIFEST,\n INTERCEPTION_ROUTE_REWRITE_MANIFEST,\n DYNAMIC_CSS_MANIFEST,\n} from '../../../shared/lib/constants'\nimport type { MiddlewareConfig } from '../../analysis/get-page-static-info'\nimport type { Telemetry } from '../../../telemetry/storage'\nimport { traceGlobals } from '../../../trace/shared'\nimport { EVENT_BUILD_FEATURE_USAGE } from '../../../telemetry/events'\nimport { normalizeAppPath } from '../../../shared/lib/router/utils/app-paths'\nimport {\n INSTRUMENTATION_HOOK_FILENAME,\n WEBPACK_LAYERS,\n} from '../../../lib/constants'\nimport type { CustomRoutes } from '../../../lib/load-custom-routes'\nimport { isInterceptionRouteRewrite } from '../../../lib/generate-interception-routes-rewrites'\nimport { getDynamicCodeEvaluationError } from './wellknown-errors-plugin/parse-dynamic-code-evaluation-error'\nimport { getModuleReferencesInOrder } from '../utils'\n\nconst KNOWN_SAFE_DYNAMIC_PACKAGES =\n require('../../../lib/known-edge-safe-packages.json') as string[]\n\nexport interface EdgeFunctionDefinition {\n files: string[]\n name: string\n page: string\n matchers: MiddlewareMatcher[]\n env: Record<string, string>\n wasm?: AssetBinding[]\n assets?: AssetBinding[]\n regions?: string[] | string\n}\n\nexport interface MiddlewareManifest {\n version: 3\n sortedMiddleware: string[]\n middleware: { [page: string]: EdgeFunctionDefinition }\n functions: { [page: string]: EdgeFunctionDefinition }\n}\n\ninterface EntryMetadata {\n edgeMiddleware?: EdgeMiddlewareMeta\n edgeApiFunction?: EdgeMiddlewareMeta\n edgeSSR?: EdgeSSRMeta\n wasmBindings: Map<string, string>\n assetBindings: Map<string, string>\n regions?: string[] | string\n}\n\nconst NAME = 'MiddlewarePlugin'\nconst MANIFEST_VERSION = 3\n\n/**\n * Checks the value of usingIndirectEval and when it is a set of modules it\n * check if any of the modules is actually being used. If the value is\n * simply truthy it will return true.\n */\nfunction isUsingIndirectEvalAndUsedByExports(args: {\n module: webpack.Module\n moduleGraph: webpack.ModuleGraph\n runtime: any\n usingIndirectEval: true | Set<string>\n wp: typeof webpack\n}): boolean {\n const { moduleGraph, runtime, module, usingIndirectEval, wp } = args\n if (typeof usingIndirectEval === 'boolean') {\n return usingIndirectEval\n }\n\n const exportsInfo = moduleGraph.getExportsInfo(module)\n for (const exportName of usingIndirectEval) {\n if (exportsInfo.getUsed(exportName, runtime) !== wp.UsageState.Unused) {\n return true\n }\n }\n\n return false\n}\n\nfunction getEntryFiles(\n entryFiles: string[],\n meta: EntryMetadata,\n hasInstrumentationHook: boolean,\n opts: Options\n) {\n const files: string[] = []\n if (meta.edgeSSR) {\n if (meta.edgeSSR.isServerComponent) {\n files.push(`server/${SERVER_REFERENCE_MANIFEST}.js`)\n if (opts.sriEnabled) {\n files.push(`server/${SUBRESOURCE_INTEGRITY_MANIFEST}.js`)\n }\n files.push(\n ...entryFiles\n .filter(\n (file) =>\n file.startsWith('app/') && !file.endsWith('.hot-update.js')\n )\n .map(\n (file) =>\n 'server/' +\n file.replace(/\\.js$/, '_' + CLIENT_REFERENCE_MANIFEST + '.js')\n )\n )\n }\n if (!opts.dev && !meta.edgeSSR.isAppDir) {\n files.push(`server/${DYNAMIC_CSS_MANIFEST}.js`)\n }\n\n files.push(\n `server/${MIDDLEWARE_BUILD_MANIFEST}.js`,\n `server/${MIDDLEWARE_REACT_LOADABLE_MANIFEST}.js`,\n `server/${NEXT_FONT_MANIFEST}.js`,\n `server/${INTERCEPTION_ROUTE_REWRITE_MANIFEST}.js`\n )\n }\n\n if (hasInstrumentationHook) {\n files.push(`server/edge-${INSTRUMENTATION_HOOK_FILENAME}.js`)\n }\n\n files.push(\n ...entryFiles\n .filter((file) => !file.endsWith('.hot-update.js'))\n .map((file) => 'server/' + file)\n )\n\n return files\n}\n\nfunction getCreateAssets(params: {\n compilation: webpack.Compilation\n metadataByEntry: Map<string, EntryMetadata>\n opts: Options\n}) {\n const { compilation, metadataByEntry, opts } = params\n return () => {\n const middlewareManifest: MiddlewareManifest = {\n version: MANIFEST_VERSION,\n middleware: {},\n functions: {},\n sortedMiddleware: [],\n }\n\n const hasInstrumentationHook = compilation.entrypoints.has(\n INSTRUMENTATION_HOOK_FILENAME\n )\n\n // we only emit this entry for the edge runtime since it doesn't have access to a routes manifest\n // and we don't need to provide the entire route manifest, just the interception routes.\n const interceptionRewrites = JSON.stringify(\n opts.rewrites.beforeFiles.filter(isInterceptionRouteRewrite)\n )\n compilation.emitAsset(\n `${INTERCEPTION_ROUTE_REWRITE_MANIFEST}.js`,\n new sources.RawSource(\n `self.__INTERCEPTION_ROUTE_REWRITE_MANIFEST=${JSON.stringify(\n interceptionRewrites\n )}`\n ) as unknown as webpack.sources.RawSource\n )\n\n for (const entrypoint of compilation.entrypoints.values()) {\n if (!entrypoint.name) {\n continue\n }\n\n // There should always be metadata for the entrypoint.\n const metadata = metadataByEntry.get(entrypoint.name)\n const page =\n metadata?.edgeMiddleware?.page ||\n metadata?.edgeSSR?.page ||\n metadata?.edgeApiFunction?.page\n if (!page) {\n continue\n }\n\n const matcherSource = metadata.edgeSSR?.isAppDir\n ? normalizeAppPath(page)\n : page\n\n const catchAll = !metadata.edgeSSR && !metadata.edgeApiFunction\n\n const { namedRegex } = getNamedMiddlewareRegex(matcherSource, {\n catchAll,\n })\n const matchers = metadata?.edgeMiddleware?.matchers ?? [\n {\n regexp: namedRegex,\n originalSource: page === '/' && catchAll ? '/:path*' : matcherSource,\n },\n ]\n\n const isEdgeFunction = !!(metadata.edgeApiFunction || metadata.edgeSSR)\n const edgeFunctionDefinition: EdgeFunctionDefinition = {\n files: getEntryFiles(\n entrypoint.getFiles(),\n metadata,\n hasInstrumentationHook,\n opts\n ),\n name: entrypoint.name,\n page: page,\n matchers,\n wasm: Array.from(metadata.wasmBindings, ([name, filePath]) => ({\n name,\n filePath,\n })),\n assets: Array.from(metadata.assetBindings, ([name, filePath]) => ({\n name,\n filePath,\n })),\n env: opts.edgeEnvironments,\n ...(metadata.regions && { regions: metadata.regions }),\n }\n\n if (isEdgeFunction) {\n middlewareManifest.functions[page] = edgeFunctionDefinition\n } else {\n middlewareManifest.middleware[page] = edgeFunctionDefinition\n }\n }\n\n middlewareManifest.sortedMiddleware = getSortedRoutes(\n Object.keys(middlewareManifest.middleware)\n )\n\n compilation.emitAsset(\n MIDDLEWARE_MANIFEST,\n new sources.RawSource(\n JSON.stringify(middlewareManifest, null, 2)\n ) as unknown as webpack.sources.RawSource\n )\n }\n}\n\nfunction buildWebpackError({\n message,\n loc,\n compilation,\n entryModule,\n parser,\n}: {\n message: string\n loc?: any\n compilation: webpack.Compilation\n entryModule?: webpack.Module\n parser?: webpack.javascript.JavascriptParser\n}) {\n const error = new compilation.compiler.webpack.WebpackError(message)\n error.name = NAME\n const module = entryModule ?? parser?.state.current\n if (module) {\n error.module = module\n }\n error.loc = loc\n return error\n}\n\nfunction isInMiddlewareLayer(parser: webpack.javascript.JavascriptParser) {\n const layer = parser.state.module?.layer\n return layer === WEBPACK_LAYERS.middleware || layer === WEBPACK_LAYERS.apiEdge\n}\n\nfunction isNodeJsModule(moduleName: string) {\n return (require('module') as typeof import('module')).builtinModules.includes(\n moduleName\n )\n}\n\nfunction isDynamicCodeEvaluationAllowed(\n fileName: string,\n middlewareConfig?: MiddlewareConfig,\n rootDir?: string\n) {\n // Some packages are known to use `eval` but are safe to use in the Edge\n // Runtime because the dynamic code will never be executed.\n if (\n KNOWN_SAFE_DYNAMIC_PACKAGES.some((pkg) =>\n fileName.includes(`/node_modules/${pkg}/`.replace(/\\//g, path.sep))\n )\n ) {\n return true\n }\n\n const name = fileName.replace(rootDir ?? '', '')\n\n return picomatch(middlewareConfig?.unstable_allowDynamic ?? [], {\n dot: true,\n })(name)\n}\n\nfunction buildUnsupportedApiError({\n apiName,\n loc,\n ...rest\n}: {\n apiName: string\n loc: any\n compilation: webpack.Compilation\n parser: webpack.javascript.JavascriptParser\n}) {\n return buildWebpackError({\n message: `A Node.js API is used (${apiName} at line: ${loc.start.line}) which is not supported in the Edge Runtime.\nLearn more: https://nextjs.org/docs/api-reference/edge-runtime`,\n loc,\n ...rest,\n })\n}\n\nfunction registerUnsupportedApiHooks(\n parser: webpack.javascript.JavascriptParser,\n compilation: webpack.Compilation\n) {\n for (const expression of EDGE_UNSUPPORTED_NODE_APIS) {\n const warnForUnsupportedApi = (node: any) => {\n if (!isInMiddlewareLayer(parser)) {\n return\n }\n compilation.warnings.push(\n buildUnsupportedApiError({\n compilation,\n parser,\n apiName: expression,\n ...node,\n })\n )\n return true\n }\n parser.hooks.call.for(expression).tap(NAME, warnForUnsupportedApi)\n parser.hooks.expression.for(expression).tap(NAME, warnForUnsupportedApi)\n parser.hooks.callMemberChain\n .for(expression)\n .tap(NAME, warnForUnsupportedApi)\n parser.hooks.expressionMemberChain\n .for(expression)\n .tap(NAME, warnForUnsupportedApi)\n }\n\n const warnForUnsupportedProcessApi = (node: any, [callee]: string[]) => {\n if (!isInMiddlewareLayer(parser) || callee === 'env') {\n return\n }\n compilation.warnings.push(\n buildUnsupportedApiError({\n compilation,\n parser,\n apiName: `process.${callee}`,\n ...node,\n })\n )\n return true\n }\n\n parser.hooks.callMemberChain\n .for('process')\n .tap(NAME, warnForUnsupportedProcessApi)\n parser.hooks.expressionMemberChain\n .for('process')\n .tap(NAME, warnForUnsupportedProcessApi)\n}\n\nfunction getCodeAnalyzer(params: {\n dev: boolean\n compiler: webpack.Compiler\n compilation: webpack.Compilation\n}) {\n return (parser: webpack.javascript.JavascriptParser) => {\n const {\n dev,\n compiler: { webpack: wp },\n compilation,\n } = params\n const { hooks } = parser\n\n /**\n * For an expression this will check the graph to ensure it is being used\n * by exports. Then it will store in the module buildInfo a boolean to\n * express that it contains dynamic code and, if it is available, the\n * module path that is using it.\n */\n const handleExpression = () => {\n if (!isInMiddlewareLayer(parser)) {\n return\n }\n\n wp.optimize.InnerGraph.onUsage(parser.state, (used = true) => {\n const buildInfo = getModuleBuildInfo(parser.state.module)\n if (buildInfo.usingIndirectEval === true || used === false) {\n return\n }\n\n if (!buildInfo.usingIndirectEval || used === true) {\n buildInfo.usingIndirectEval = used\n return\n }\n\n buildInfo.usingIndirectEval = new Set([\n ...Array.from(buildInfo.usingIndirectEval),\n ...Array.from(used),\n ])\n })\n }\n\n /**\n * This expression handler allows to wrap a dynamic code expression with a\n * function call where we can warn about dynamic code not being allowed\n * but actually execute the expression.\n */\n const handleWrapExpression = (expr: any) => {\n if (!isInMiddlewareLayer(parser)) {\n return\n }\n\n const { ConstDependency } = wp.dependencies\n const dep1 = new ConstDependency(\n '__next_eval__(function() { return ',\n expr.range[0]\n )\n dep1.loc = expr.loc\n parser.state.module.addPresentationalDependency(dep1)\n const dep2 = new ConstDependency('})', expr.range[1])\n dep2.loc = expr.loc\n parser.state.module.addPresentationalDependency(dep2)\n\n handleExpression()\n return true\n }\n\n /**\n * This expression handler allows to wrap a WebAssembly.compile invocation with a\n * function call where we can warn about WASM code generation not being allowed\n * but actually execute the expression.\n */\n const handleWrapWasmCompileExpression = (expr: any) => {\n if (!isInMiddlewareLayer(parser)) {\n return\n }\n\n const { ConstDependency } = wp.dependencies\n const dep1 = new ConstDependency(\n '__next_webassembly_compile__(function() { return ',\n expr.range[0]\n )\n dep1.loc = expr.loc\n parser.state.module.addPresentationalDependency(dep1)\n const dep2 = new ConstDependency('})', expr.range[1])\n dep2.loc = expr.loc\n parser.state.module.addPresentationalDependency(dep2)\n\n handleExpression()\n }\n\n /**\n * This expression handler allows to wrap a WebAssembly.instatiate invocation with a\n * function call where we can warn about WASM code generation not being allowed\n * but actually execute the expression.\n *\n * Note that we don't update `usingIndirectEval`, i.e. we don't abort a production build\n * since we can't determine statically if the first parameter is a module (legit use) or\n * a buffer (dynamic code generation).\n */\n const handleWrapWasmInstantiateExpression = (expr: any) => {\n if (!isInMiddlewareLayer(parser)) {\n return\n }\n\n if (dev) {\n const { ConstDependency } = wp.dependencies\n const dep1 = new ConstDependency(\n '__next_webassembly_instantiate__(function() { return ',\n expr.range[0]\n )\n dep1.loc = expr.loc\n parser.state.module.addPresentationalDependency(dep1)\n const dep2 = new ConstDependency('})', expr.range[1])\n dep2.loc = expr.loc\n parser.state.module.addPresentationalDependency(dep2)\n }\n }\n\n /**\n * Handler to store original source location of static and dynamic imports into module's buildInfo.\n */\n const handleImport = (node: any) => {\n if (isInMiddlewareLayer(parser) && node.source?.value && node?.loc) {\n const { module, source } = parser.state\n const buildInfo = getModuleBuildInfo(module)\n if (!buildInfo.importLocByPath) {\n buildInfo.importLocByPath = new Map()\n }\n\n const importedModule = node.source.value?.toString()\n buildInfo.importLocByPath.set(importedModule, {\n sourcePosition: {\n ...node.loc.start,\n source: module.identifier(),\n },\n sourceContent: source.toString(),\n })\n\n if (\n !dev &&\n isNodeJsModule(importedModule) &&\n !SUPPORTED_NATIVE_MODULES.includes(importedModule)\n ) {\n compilation.warnings.push(\n buildWebpackError({\n message: `A Node.js module is loaded ('${importedModule}' at line ${node.loc.start.line}) which is not supported in the Edge Runtime.\nLearn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`,\n compilation,\n parser,\n ...node,\n })\n )\n }\n }\n }\n\n /**\n * A noop handler to skip analyzing some cases.\n * Order matters: for it to work, it must be registered first\n */\n const skip = () => (isInMiddlewareLayer(parser) ? true : undefined)\n\n for (const prefix of ['', 'global.']) {\n hooks.expression.for(`${prefix}Function.prototype`).tap(NAME, skip)\n hooks.expression.for(`${prefix}Function.bind`).tap(NAME, skip)\n hooks.call.for(`${prefix}eval`).tap(NAME, handleWrapExpression)\n hooks.call.for(`${prefix}Function`).tap(NAME, handleWrapExpression)\n hooks.new.for(`${prefix}Function`).tap(NAME, handleWrapExpression)\n hooks.call\n .for(`${prefix}WebAssembly.compile`)\n .tap(NAME, handleWrapWasmCompileExpression)\n hooks.call\n .for(`${prefix}WebAssembly.instantiate`)\n .tap(NAME, handleWrapWasmInstantiateExpression)\n }\n\n hooks.importCall.tap(NAME, handleImport)\n hooks.import.tap(NAME, handleImport)\n\n if (!dev) {\n // do not issue compilation warning on dev: invoking code will provide details\n registerUnsupportedApiHooks(parser, compilation)\n }\n }\n}\n\nasync function codeAnalyzerBySwc(\n compilation: webpack.Compilation,\n modules: Iterable<webpack.Module>,\n dev: boolean\n) {\n const binding = require('../../swc') as typeof import('../../swc')\n for (const module of modules) {\n if (\n module.layer !== WEBPACK_LAYERS.middleware &&\n module.layer !== WEBPACK_LAYERS.apiEdge\n ) {\n continue\n }\n if (module.constructor.name !== 'NormalModule') {\n continue\n }\n const normalModule = module as webpack.NormalModule\n if (!normalModule.type.startsWith('javascript')) {\n // Only analyze JavaScript modules\n continue\n }\n const originalSource = normalModule.originalSource()\n if (!originalSource) {\n continue\n }\n const source = originalSource.source()\n if (typeof source !== 'string') {\n continue\n }\n const diagnostics = await binding.warnForEdgeRuntime(source, !dev)\n for (const diagnostic of diagnostics) {\n const webpackError = buildWebpackError({\n message: diagnostic.message,\n loc: diagnostic.loc,\n compilation,\n entryModule: module,\n })\n if (diagnostic.severity === 'Warning') {\n compilation.warnings.push(webpackError)\n } else {\n compilation.errors.push(webpackError)\n }\n }\n }\n}\n\nfunction getExtractMetadata(params: {\n compilation: webpack.Compilation\n compiler: webpack.Compiler\n dev: boolean\n metadataByEntry: Map<string, EntryMetadata>\n}): () => Promise<void> {\n const { dev, compilation, metadataByEntry, compiler } = params\n const { webpack: wp } = compiler\n return async () => {\n metadataByEntry.clear()\n const telemetry: Telemetry | undefined = traceGlobals.get('telemetry')\n\n for (const [entryName, entry] of compilation.entries) {\n if (entry.options.runtime !== EDGE_RUNTIME_WEBPACK) {\n // Only process edge runtime entries\n continue\n }\n const entryDependency = entry.dependencies?.[0]\n const resolvedModule =\n compilation.moduleGraph.getResolvedModule(entryDependency)\n if (!resolvedModule) {\n continue\n }\n const { rootDir, route } = getModuleBuildInfo(resolvedModule)\n\n const { moduleGraph } = compilation\n const modules = new Set<webpack.NormalModule>()\n const addEntriesFromDependency = (dependency: any) => {\n const module = moduleGraph.getModule(dependency)\n if (module) {\n modules.add(module as webpack.NormalModule)\n }\n }\n\n entry.dependencies.forEach(addEntriesFromDependency)\n entry.includeDependencies.forEach(addEntriesFromDependency)\n\n const entryMetadata: EntryMetadata = {\n wasmBindings: new Map(),\n assetBindings: new Map(),\n }\n\n if (route?.middlewareConfig?.regions) {\n entryMetadata.regions = route.middlewareConfig.regions\n }\n\n if (route?.preferredRegion) {\n const preferredRegion = route.preferredRegion\n entryMetadata.regions =\n // Ensures preferredRegion is always an array in the manifest.\n typeof preferredRegion === 'string'\n ? [preferredRegion]\n : preferredRegion\n }\n\n let ogImageGenerationCount = 0\n\n for (const module of modules) {\n const buildInfo = getModuleBuildInfo(module)\n\n /**\n * Check if it uses the image generation feature.\n */\n if (!dev) {\n const resource = module.resource\n const hasOGImageGeneration =\n resource &&\n /[\\\\/]node_modules[\\\\/]@vercel[\\\\/]og[\\\\/]dist[\\\\/]index\\.(edge|node)\\.js$|[\\\\/]next[\\\\/]dist[\\\\/](esm[\\\\/])?server[\\\\/]og[\\\\/]image-response\\.js$/.test(\n resource\n )\n\n if (hasOGImageGeneration) {\n ogImageGenerationCount++\n }\n }\n\n /**\n * When building for production checks if the module is using `eval`\n * and in such case produces a compilation error. The module has to\n * be in use.\n */\n if (\n !dev &&\n buildInfo.usingIndirectEval &&\n isUsingIndirectEvalAndUsedByExports({\n module,\n moduleGraph,\n runtime: wp.util.runtime.getEntryRuntime(compilation, entryName),\n usingIndirectEval: buildInfo.usingIndirectEval,\n wp,\n })\n ) {\n const id = module.identifier()\n if (/node_modules[\\\\/]regenerator-runtime[\\\\/]runtime\\.js/.test(id)) {\n continue\n }\n if (route?.middlewareConfig?.unstable_allowDynamic) {\n telemetry?.record({\n eventName: 'NEXT_EDGE_ALLOW_DYNAMIC_USED',\n payload: {\n file: route?.absolutePagePath.replace(rootDir ?? '', ''),\n config: route?.middlewareConfig,\n fileWithDynamicCode: module.userRequest.replace(\n rootDir ?? '',\n ''\n ),\n },\n })\n }\n if (\n !isDynamicCodeEvaluationAllowed(\n module.userRequest,\n route?.middlewareConfig,\n rootDir\n )\n ) {\n const message = `Dynamic Code Evaluation (e. g. 'eval', 'new Function', 'WebAssembly.compile') not allowed in Edge Runtime ${\n typeof buildInfo.usingIndirectEval !== 'boolean'\n ? `\\nUsed by ${Array.from(buildInfo.usingIndirectEval).join(\n ', '\n )}`\n : ''\n }\\nLearn More: https://nextjs.org/docs/messages/edge-dynamic-code-evaluation`\n compilation.errors.push(\n getDynamicCodeEvaluationError(\n message,\n module,\n compilation,\n compiler\n )\n )\n }\n }\n\n /**\n * The entry module has to be either a page or a middleware and hold\n * the corresponding metadata.\n */\n if (buildInfo?.nextEdgeSSR) {\n entryMetadata.edgeSSR = buildInfo.nextEdgeSSR\n } else if (buildInfo?.nextEdgeMiddleware) {\n entryMetadata.edgeMiddleware = buildInfo.nextEdgeMiddleware\n } else if (buildInfo?.nextEdgeApiFunction) {\n entryMetadata.edgeApiFunction = buildInfo.nextEdgeApiFunction\n }\n\n /**\n * If the module is a WASM module we read the binding information and\n * append it to the entry wasm bindings.\n */\n if (buildInfo?.nextWasmMiddlewareBinding) {\n entryMetadata.wasmBindings.set(\n buildInfo.nextWasmMiddlewareBinding.name,\n buildInfo.nextWasmMiddlewareBinding.filePath\n )\n }\n\n if (buildInfo?.nextAssetMiddlewareBinding) {\n entryMetadata.assetBindings.set(\n buildInfo.nextAssetMiddlewareBinding.name,\n buildInfo.nextAssetMiddlewareBinding.filePath\n )\n }\n\n /**\n * Append to the list of modules to process outgoingConnections from\n * the module that is being processed.\n */\n for (const conn of getModuleReferencesInOrder(module, moduleGraph)) {\n if (conn.module) {\n modules.add(conn.module as webpack.NormalModule)\n }\n }\n }\n\n telemetry?.record({\n eventName: EVENT_BUILD_FEATURE_USAGE,\n payload: {\n featureName: 'vercelImageGeneration',\n invocationCount: ogImageGenerationCount,\n },\n })\n metadataByEntry.set(entryName, entryMetadata)\n }\n }\n}\n\n// These values will be replaced again in edge runtime deployment build.\n// `buildId` represents BUILD_ID to be externalized in env vars.\n// `encryptionKey` represents server action encryption key to be externalized in env vars.\ntype EdgeRuntimeEnvironments = Record<string, string> & {\n __NEXT_BUILD_ID: string\n NEXT_SERVER_ACTIONS_ENCRYPTION_KEY: string\n}\n\ninterface Options {\n dev: boolean\n sriEnabled: boolean\n rewrites: CustomRoutes['rewrites']\n edgeEnvironments: EdgeRuntimeEnvironments\n}\n\nexport default class MiddlewarePlugin {\n private readonly dev: Options['dev']\n private readonly sriEnabled: Options['sriEnabled']\n private readonly rewrites: Options['rewrites']\n private readonly edgeEnvironments: EdgeRuntimeEnvironments\n\n constructor({ dev, sriEnabled, rewrites, edgeEnvironments }: Options) {\n this.dev = dev\n this.sriEnabled = sriEnabled\n this.rewrites = rewrites\n this.edgeEnvironments = edgeEnvironments\n }\n\n public apply(compiler: webpack.Compiler) {\n compiler.hooks.compilation.tap(NAME, (compilation, params) => {\n // parser hooks aren't available in rspack\n if (process.env.NEXT_RSPACK) {\n compilation.hooks.finishModules.tapPromise(NAME, async (modules) => {\n await codeAnalyzerBySwc(compilation, modules, this.dev)\n })\n } else {\n const { hooks } = params.normalModuleFactory\n /**\n * This is the static code analysis phase.\n */\n const codeAnalyzer = getCodeAnalyzer({\n dev: this.dev,\n compiler,\n compilation,\n })\n\n hooks.parser.for('javascript/auto').tap(NAME, codeAnalyzer)\n hooks.parser.for('javascript/dynamic').tap(NAME, codeAnalyzer)\n hooks.parser.for('javascript/esm').tap(NAME, codeAnalyzer)\n }\n\n /**\n * Extract all metadata for the entry points in a Map object.\n */\n const metadataByEntry = new Map<string, EntryMetadata>()\n compilation.hooks.finishModules.tapPromise(\n NAME,\n getExtractMetadata({\n compilation,\n compiler,\n dev: this.dev,\n metadataByEntry,\n })\n )\n\n /**\n * Emit the middleware manifest.\n */\n compilation.hooks.processAssets.tap(\n {\n name: 'NextJsMiddlewareManifest',\n stage: webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,\n },\n getCreateAssets({\n compilation,\n metadataByEntry,\n opts: {\n sriEnabled: this.sriEnabled,\n rewrites: this.rewrites,\n edgeEnvironments: this.edgeEnvironments,\n dev: this.dev,\n },\n })\n )\n })\n }\n}\n\nexport const SUPPORTED_NATIVE_MODULES = [\n 'buffer',\n 'events',\n 'assert',\n 'util',\n 'async_hooks',\n] as const\n\nconst supportedEdgePolyfills = new Set<string>(SUPPORTED_NATIVE_MODULES)\n\nexport function getEdgePolyfilledModules() {\n const records: Record<string, string> = {}\n for (const mod of SUPPORTED_NATIVE_MODULES) {\n records[mod] = `commonjs node:${mod}`\n records[`node:${mod}`] = `commonjs node:${mod}`\n }\n return records\n}\n\nexport async function handleWebpackExternalForEdgeRuntime({\n request,\n context,\n contextInfo,\n getResolve,\n}: {\n request: string\n context: string\n contextInfo: any\n getResolve: () => any\n}) {\n if (\n (contextInfo.issuerLayer === WEBPACK_LAYERS.middleware ||\n contextInfo.issuerLayer === WEBPACK_LAYERS.apiEdge) &&\n isNodeJsModule(request) &&\n !supportedEdgePolyfills.has(request)\n ) {\n // allows user to provide and use their polyfills, as we do with buffer.\n try {\n await getResolve()(context, request)\n } catch {\n return `root globalThis.__import_unsupported('${request}')`\n }\n }\n}\n"],"names":["getNamedMiddlewareRegex","getModuleBuildInfo","getSortedRoutes","webpack","sources","picomatch","path","EDGE_RUNTIME_WEBPACK","EDGE_UNSUPPORTED_NODE_APIS","MIDDLEWARE_BUILD_MANIFEST","CLIENT_REFERENCE_MANIFEST","MIDDLEWARE_MANIFEST","MIDDLEWARE_REACT_LOADABLE_MANIFEST","SUBRESOURCE_INTEGRITY_MANIFEST","NEXT_FONT_MANIFEST","SERVER_REFERENCE_MANIFEST","INTERCEPTION_ROUTE_REWRITE_MANIFEST","DYNAMIC_CSS_MANIFEST","traceGlobals","EVENT_BUILD_FEATURE_USAGE","normalizeAppPath","INSTRUMENTATION_HOOK_FILENAME","WEBPACK_LAYERS","isInterceptionRouteRewrite","getDynamicCodeEvaluationError","getModuleReferencesInOrder","KNOWN_SAFE_DYNAMIC_PACKAGES","require","NAME","MANIFEST_VERSION","isUsingIndirectEvalAndUsedByExports","args","moduleGraph","runtime","module","usingIndirectEval","wp","exportsInfo","getExportsInfo","exportName","getUsed","UsageState","Unused","getEntryFiles","entryFiles","meta","hasInstrumentationHook","opts","files","edgeSSR","isServerComponent","push","sriEnabled","filter","file","startsWith","endsWith","map","replace","dev","isAppDir","getCreateAssets","params","compilation","metadataByEntry","middlewareManifest","version","middleware","functions","sortedMiddleware","entrypoints","has","interceptionRewrites","JSON","stringify","rewrites","beforeFiles","emitAsset","RawSource","entrypoint","values","metadata","name","get","page","edgeMiddleware","edgeApiFunction","matcherSource","catchAll","namedRegex","matchers","regexp","originalSource","isEdgeFunction","edgeFunctionDefinition","getFiles","wasm","Array","from","wasmBindings","filePath","assets","assetBindings","env","edgeEnvironments","regions","Object","keys","buildWebpackError","message","loc","entryModule","parser","error","compiler","WebpackError","state","current","isInMiddlewareLayer","layer","apiEdge","isNodeJsModule","moduleName","builtinModules","includes","isDynamicCodeEvaluationAllowed","fileName","middlewareConfig","rootDir","some","pkg","sep","unstable_allowDynamic","dot","buildUnsupportedApiError","apiName","rest","start","line","registerUnsupportedApiHooks","expression","warnForUnsupportedApi","node","warnings","hooks","call","for","tap","callMemberChain","expressionMemberChain","warnForUnsupportedProcessApi","callee","getCodeAnalyzer","handleExpression","optimize","InnerGraph","onUsage","used","buildInfo","Set","handleWrapExpression","expr","ConstDependency","dependencies","dep1","range","addPresentationalDependency","dep2","handleWrapWasmCompileExpression","handleWrapWasmInstantiateExpression","handleImport","source","value","importLocByPath","Map","importedModule","toString","set","sourcePosition","identifier","sourceContent","SUPPORTED_NATIVE_MODULES","skip","undefined","prefix","new","importCall","import","codeAnalyzerBySwc","modules","binding","constructor","normalModule","type","diagnostics","warnForEdgeRuntime","diagnostic","webpackError","severity","errors","getExtractMetadata","clear","telemetry","entryName","entry","entries","route","options","entryDependency","resolvedModule","getResolvedModule","addEntriesFromDependency","dependency","getModule","add","forEach","includeDependencies","entryMetadata","preferredRegion","ogImageGenerationCount","resource","hasOGImageGeneration","test","util","getEntryRuntime","id","record","eventName","payload","absolutePagePath","config","fileWithDynamicCode","userRequest","join","nextEdgeSSR","nextEdgeMiddleware","nextEdgeApiFunction","nextWasmMiddlewareBinding","nextAssetMiddlewareBinding","conn","featureName","invocationCount","MiddlewarePlugin","apply","process","NEXT_RSPACK","finishModules","tapPromise","normalModuleFactory","codeAnalyzer","processAssets","stage","Compilation","PROCESS_ASSETS_STAGE_ADDITIONS","supportedEdgePolyfills","getEdgePolyfilledModules","records","mod","handleWebpackExternalForEdgeRuntime","request","context","contextInfo","getResolve","issuerLayer"],"mappings":"AAMA,SAASA,uBAAuB,QAAQ,+CAA8C;AACtF,SAASC,kBAAkB,QAAQ,mCAAkC;AACrE,SAASC,eAAe,QAAQ,mCAAkC;AAClE,SAASC,OAAO,EAAEC,OAAO,QAAQ,qCAAoC;AACrE,OAAOC,eAAe,+BAA8B;AACpD,OAAOC,UAAU,OAAM;AACvB,SACEC,oBAAoB,EACpBC,0BAA0B,EAC1BC,yBAAyB,EACzBC,yBAAyB,EACzBC,mBAAmB,EACnBC,kCAAkC,EAClCC,8BAA8B,EAC9BC,kBAAkB,EAClBC,yBAAyB,EACzBC,mCAAmC,EACnCC,oBAAoB,QACf,gCAA+B;AAGtC,SAASC,YAAY,QAAQ,wBAAuB;AACpD,SAASC,yBAAyB,QAAQ,4BAA2B;AACrE,SAASC,gBAAgB,QAAQ,6CAA4C;AAC7E,SACEC,6BAA6B,EAC7BC,cAAc,QACT,yBAAwB;AAE/B,SAASC,0BAA0B,QAAQ,qDAAoD;AAC/F,SAASC,6BAA6B,QAAQ,gEAA+D;AAC7G,SAASC,0BAA0B,QAAQ,WAAU;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AI;YACF,MAAMG,aAAaF,SAASD;QAC9B,EAAE,OAAM;YACN,OAAO,CAAC,sCAAsC,EAAEA,QAAQ,EAAE,CAAC;QAC7D;IACF;AACF","ignoreList":[0]}
1
+ {"version":3,"sources":["../../../../src/build/webpack/plugins/middleware-plugin.ts"],"sourcesContent":["import type {\n AssetBinding,\n EdgeMiddlewareMeta,\n} from '../loaders/get-module-build-info'\nimport type { EdgeSSRMeta } from '../loaders/get-module-build-info'\nimport type { MiddlewareMatcher } from '../../analysis/get-page-static-info'\nimport { getNamedMiddlewareRegex } from '../../../shared/lib/router/utils/route-regex'\nimport { getModuleBuildInfo } from '../loaders/get-module-build-info'\nimport { getSortedRoutes } from '../../../shared/lib/router/utils'\nimport { webpack, sources } from 'next/dist/compiled/webpack/webpack'\nimport picomatch from 'next/dist/compiled/picomatch'\nimport path from 'path'\nimport {\n EDGE_RUNTIME_WEBPACK,\n EDGE_UNSUPPORTED_NODE_APIS,\n MIDDLEWARE_BUILD_MANIFEST,\n CLIENT_REFERENCE_MANIFEST,\n MIDDLEWARE_MANIFEST,\n MIDDLEWARE_REACT_LOADABLE_MANIFEST,\n SUBRESOURCE_INTEGRITY_MANIFEST,\n NEXT_FONT_MANIFEST,\n SERVER_REFERENCE_MANIFEST,\n INTERCEPTION_ROUTE_REWRITE_MANIFEST,\n DYNAMIC_CSS_MANIFEST,\n} from '../../../shared/lib/constants'\nimport type { MiddlewareConfig } from '../../analysis/get-page-static-info'\nimport type { Telemetry } from '../../../telemetry/storage'\nimport { traceGlobals } from '../../../trace/shared'\nimport { EVENT_BUILD_FEATURE_USAGE } from '../../../telemetry/events'\nimport { normalizeAppPath } from '../../../shared/lib/router/utils/app-paths'\nimport {\n INSTRUMENTATION_HOOK_FILENAME,\n WEBPACK_LAYERS,\n} from '../../../lib/constants'\nimport type { CustomRoutes } from '../../../lib/load-custom-routes'\nimport { isInterceptionRouteRewrite } from '../../../lib/generate-interception-routes-rewrites'\nimport { getDynamicCodeEvaluationError } from './wellknown-errors-plugin/parse-dynamic-code-evaluation-error'\nimport { getModuleReferencesInOrder } from '../utils'\n\nconst KNOWN_SAFE_DYNAMIC_PACKAGES =\n require('../../../lib/known-edge-safe-packages.json') as string[]\n\nexport interface EdgeFunctionDefinition {\n files: string[]\n name: string\n page: string\n matchers: MiddlewareMatcher[]\n env: Record<string, string>\n wasm?: AssetBinding[]\n assets?: AssetBinding[]\n regions?: string[] | string\n}\n\nexport interface MiddlewareManifest {\n version: 3\n sortedMiddleware: string[]\n middleware: { [page: string]: EdgeFunctionDefinition }\n functions: { [page: string]: EdgeFunctionDefinition }\n}\n\ninterface EntryMetadata {\n edgeMiddleware?: EdgeMiddlewareMeta\n edgeApiFunction?: EdgeMiddlewareMeta\n edgeSSR?: EdgeSSRMeta\n wasmBindings: Map<string, string>\n assetBindings: Map<string, string>\n regions?: string[] | string\n}\n\nconst NAME = 'MiddlewarePlugin'\nconst MANIFEST_VERSION = 3\n\n/**\n * Checks the value of usingIndirectEval and when it is a set of modules it\n * check if any of the modules is actually being used. If the value is\n * simply truthy it will return true.\n */\nfunction isUsingIndirectEvalAndUsedByExports(args: {\n module: webpack.Module\n moduleGraph: webpack.ModuleGraph\n runtime: any\n usingIndirectEval: true | Set<string>\n wp: typeof webpack\n}): boolean {\n const { moduleGraph, runtime, module, usingIndirectEval, wp } = args\n if (typeof usingIndirectEval === 'boolean') {\n return usingIndirectEval\n }\n\n const exportsInfo = moduleGraph.getExportsInfo(module)\n for (const exportName of usingIndirectEval) {\n if (exportsInfo.getUsed(exportName, runtime) !== wp.UsageState.Unused) {\n return true\n }\n }\n\n return false\n}\n\nfunction getEntryFiles(\n entryFiles: string[],\n meta: EntryMetadata,\n hasInstrumentationHook: boolean,\n opts: Options\n) {\n const files: string[] = []\n if (meta.edgeSSR) {\n if (meta.edgeSSR.isServerComponent) {\n files.push(`server/${SERVER_REFERENCE_MANIFEST}.js`)\n if (opts.sriEnabled) {\n files.push(`server/${SUBRESOURCE_INTEGRITY_MANIFEST}.js`)\n }\n files.push(\n ...entryFiles\n .filter(\n (file) =>\n file.startsWith('app/') && !file.endsWith('.hot-update.js')\n )\n .map(\n (file) =>\n 'server/' +\n file.replace(/\\.js$/, '_' + CLIENT_REFERENCE_MANIFEST + '.js')\n )\n )\n }\n if (!opts.dev && !meta.edgeSSR.isAppDir) {\n files.push(`server/${DYNAMIC_CSS_MANIFEST}.js`)\n }\n\n files.push(\n `server/${MIDDLEWARE_BUILD_MANIFEST}.js`,\n `server/${MIDDLEWARE_REACT_LOADABLE_MANIFEST}.js`,\n `server/${NEXT_FONT_MANIFEST}.js`,\n `server/${INTERCEPTION_ROUTE_REWRITE_MANIFEST}.js`\n )\n }\n\n if (hasInstrumentationHook) {\n files.push(`server/edge-${INSTRUMENTATION_HOOK_FILENAME}.js`)\n }\n\n files.push(\n ...entryFiles\n .filter((file) => !file.endsWith('.hot-update.js'))\n .map((file) => 'server/' + file)\n )\n\n return files\n}\n\nfunction getCreateAssets(params: {\n compilation: webpack.Compilation\n metadataByEntry: Map<string, EntryMetadata>\n opts: Options\n}) {\n const { compilation, metadataByEntry, opts } = params\n return () => {\n const middlewareManifest: MiddlewareManifest = {\n version: MANIFEST_VERSION,\n middleware: {},\n functions: {},\n sortedMiddleware: [],\n }\n\n const hasInstrumentationHook = compilation.entrypoints.has(\n INSTRUMENTATION_HOOK_FILENAME\n )\n\n // we only emit this entry for the edge runtime since it doesn't have access to a routes manifest\n // and we don't need to provide the entire route manifest, just the interception routes.\n const interceptionRewrites = JSON.stringify(\n opts.rewrites.beforeFiles.filter(isInterceptionRouteRewrite)\n )\n compilation.emitAsset(\n `${INTERCEPTION_ROUTE_REWRITE_MANIFEST}.js`,\n new sources.RawSource(\n `self.__INTERCEPTION_ROUTE_REWRITE_MANIFEST=${JSON.stringify(\n interceptionRewrites\n )}`\n ) as unknown as webpack.sources.RawSource\n )\n\n for (const entrypoint of compilation.entrypoints.values()) {\n if (!entrypoint.name) {\n continue\n }\n\n // There should always be metadata for the entrypoint.\n const metadata = metadataByEntry.get(entrypoint.name)\n const page =\n metadata?.edgeMiddleware?.page ||\n metadata?.edgeSSR?.page ||\n metadata?.edgeApiFunction?.page\n if (!page) {\n continue\n }\n\n const matcherSource = metadata.edgeSSR?.isAppDir\n ? normalizeAppPath(page)\n : page\n\n const catchAll = !metadata.edgeSSR && !metadata.edgeApiFunction\n\n const { namedRegex } = getNamedMiddlewareRegex(matcherSource, {\n catchAll,\n })\n const matchers = metadata?.edgeMiddleware?.matchers ?? [\n {\n regexp: namedRegex,\n originalSource: page === '/' && catchAll ? '/:path*' : matcherSource,\n },\n ]\n\n const isEdgeFunction = !!(metadata.edgeApiFunction || metadata.edgeSSR)\n const edgeFunctionDefinition: EdgeFunctionDefinition = {\n files: getEntryFiles(\n entrypoint.getFiles(),\n metadata,\n hasInstrumentationHook,\n opts\n ),\n name: entrypoint.name,\n page: page,\n matchers,\n wasm: Array.from(metadata.wasmBindings, ([name, filePath]) => ({\n name,\n filePath,\n })),\n assets: Array.from(metadata.assetBindings, ([name, filePath]) => ({\n name,\n filePath,\n })),\n env: opts.edgeEnvironments,\n ...(metadata.regions && { regions: metadata.regions }),\n }\n\n if (isEdgeFunction) {\n middlewareManifest.functions[page] = edgeFunctionDefinition\n } else {\n middlewareManifest.middleware[page] = edgeFunctionDefinition\n }\n }\n\n middlewareManifest.sortedMiddleware = getSortedRoutes(\n Object.keys(middlewareManifest.middleware)\n )\n\n compilation.emitAsset(\n MIDDLEWARE_MANIFEST,\n new sources.RawSource(\n JSON.stringify(middlewareManifest, null, 2)\n ) as unknown as webpack.sources.RawSource\n )\n }\n}\n\nfunction buildWebpackError({\n message,\n loc,\n compilation,\n entryModule,\n parser,\n}: {\n message: string\n loc?: any\n compilation: webpack.Compilation\n entryModule?: webpack.Module\n parser?: webpack.javascript.JavascriptParser\n}) {\n const error = new compilation.compiler.webpack.WebpackError(message)\n error.name = NAME\n const module = entryModule ?? parser?.state.current\n if (module) {\n error.module = module\n }\n error.loc = loc\n return error\n}\n\nfunction isInMiddlewareLayer(parser: webpack.javascript.JavascriptParser) {\n const layer = parser.state.module?.layer\n return layer === WEBPACK_LAYERS.middleware || layer === WEBPACK_LAYERS.apiEdge\n}\n\nfunction isNodeJsModule(moduleName: string) {\n return (require('module') as typeof import('module')).builtinModules.includes(\n moduleName\n )\n}\n\nfunction isBunModule(moduleName: string) {\n return moduleName === 'bun' || moduleName.startsWith('bun:')\n}\n\nfunction isDynamicCodeEvaluationAllowed(\n fileName: string,\n middlewareConfig?: MiddlewareConfig,\n rootDir?: string\n) {\n // Some packages are known to use `eval` but are safe to use in the Edge\n // Runtime because the dynamic code will never be executed.\n if (\n KNOWN_SAFE_DYNAMIC_PACKAGES.some((pkg) =>\n fileName.includes(`/node_modules/${pkg}/`.replace(/\\//g, path.sep))\n )\n ) {\n return true\n }\n\n const name = fileName.replace(rootDir ?? '', '')\n\n return picomatch(middlewareConfig?.unstable_allowDynamic ?? [], {\n dot: true,\n })(name)\n}\n\nfunction buildUnsupportedApiError({\n apiName,\n loc,\n ...rest\n}: {\n apiName: string\n loc: any\n compilation: webpack.Compilation\n parser: webpack.javascript.JavascriptParser\n}) {\n return buildWebpackError({\n message: `A Node.js API is used (${apiName} at line: ${loc.start.line}) which is not supported in the Edge Runtime.\nLearn more: https://nextjs.org/docs/api-reference/edge-runtime`,\n loc,\n ...rest,\n })\n}\n\nfunction registerUnsupportedApiHooks(\n parser: webpack.javascript.JavascriptParser,\n compilation: webpack.Compilation\n) {\n for (const expression of EDGE_UNSUPPORTED_NODE_APIS) {\n const warnForUnsupportedApi = (node: any) => {\n if (!isInMiddlewareLayer(parser)) {\n return\n }\n compilation.warnings.push(\n buildUnsupportedApiError({\n compilation,\n parser,\n apiName: expression,\n ...node,\n })\n )\n return true\n }\n parser.hooks.call.for(expression).tap(NAME, warnForUnsupportedApi)\n parser.hooks.expression.for(expression).tap(NAME, warnForUnsupportedApi)\n parser.hooks.callMemberChain\n .for(expression)\n .tap(NAME, warnForUnsupportedApi)\n parser.hooks.expressionMemberChain\n .for(expression)\n .tap(NAME, warnForUnsupportedApi)\n }\n\n const warnForUnsupportedProcessApi = (node: any, [callee]: string[]) => {\n if (!isInMiddlewareLayer(parser) || callee === 'env') {\n return\n }\n compilation.warnings.push(\n buildUnsupportedApiError({\n compilation,\n parser,\n apiName: `process.${callee}`,\n ...node,\n })\n )\n return true\n }\n\n parser.hooks.callMemberChain\n .for('process')\n .tap(NAME, warnForUnsupportedProcessApi)\n parser.hooks.expressionMemberChain\n .for('process')\n .tap(NAME, warnForUnsupportedProcessApi)\n}\n\nfunction getCodeAnalyzer(params: {\n dev: boolean\n compiler: webpack.Compiler\n compilation: webpack.Compilation\n}) {\n return (parser: webpack.javascript.JavascriptParser) => {\n const {\n dev,\n compiler: { webpack: wp },\n compilation,\n } = params\n const { hooks } = parser\n\n /**\n * For an expression this will check the graph to ensure it is being used\n * by exports. Then it will store in the module buildInfo a boolean to\n * express that it contains dynamic code and, if it is available, the\n * module path that is using it.\n */\n const handleExpression = () => {\n if (!isInMiddlewareLayer(parser)) {\n return\n }\n\n wp.optimize.InnerGraph.onUsage(parser.state, (used = true) => {\n const buildInfo = getModuleBuildInfo(parser.state.module)\n if (buildInfo.usingIndirectEval === true || used === false) {\n return\n }\n\n if (!buildInfo.usingIndirectEval || used === true) {\n buildInfo.usingIndirectEval = used\n return\n }\n\n buildInfo.usingIndirectEval = new Set([\n ...Array.from(buildInfo.usingIndirectEval),\n ...Array.from(used),\n ])\n })\n }\n\n /**\n * This expression handler allows to wrap a dynamic code expression with a\n * function call where we can warn about dynamic code not being allowed\n * but actually execute the expression.\n */\n const handleWrapExpression = (expr: any) => {\n if (!isInMiddlewareLayer(parser)) {\n return\n }\n\n const { ConstDependency } = wp.dependencies\n const dep1 = new ConstDependency(\n '__next_eval__(function() { return ',\n expr.range[0]\n )\n dep1.loc = expr.loc\n parser.state.module.addPresentationalDependency(dep1)\n const dep2 = new ConstDependency('})', expr.range[1])\n dep2.loc = expr.loc\n parser.state.module.addPresentationalDependency(dep2)\n\n handleExpression()\n return true\n }\n\n /**\n * This expression handler allows to wrap a WebAssembly.compile invocation with a\n * function call where we can warn about WASM code generation not being allowed\n * but actually execute the expression.\n */\n const handleWrapWasmCompileExpression = (expr: any) => {\n if (!isInMiddlewareLayer(parser)) {\n return\n }\n\n const { ConstDependency } = wp.dependencies\n const dep1 = new ConstDependency(\n '__next_webassembly_compile__(function() { return ',\n expr.range[0]\n )\n dep1.loc = expr.loc\n parser.state.module.addPresentationalDependency(dep1)\n const dep2 = new ConstDependency('})', expr.range[1])\n dep2.loc = expr.loc\n parser.state.module.addPresentationalDependency(dep2)\n\n handleExpression()\n }\n\n /**\n * This expression handler allows to wrap a WebAssembly.instatiate invocation with a\n * function call where we can warn about WASM code generation not being allowed\n * but actually execute the expression.\n *\n * Note that we don't update `usingIndirectEval`, i.e. we don't abort a production build\n * since we can't determine statically if the first parameter is a module (legit use) or\n * a buffer (dynamic code generation).\n */\n const handleWrapWasmInstantiateExpression = (expr: any) => {\n if (!isInMiddlewareLayer(parser)) {\n return\n }\n\n if (dev) {\n const { ConstDependency } = wp.dependencies\n const dep1 = new ConstDependency(\n '__next_webassembly_instantiate__(function() { return ',\n expr.range[0]\n )\n dep1.loc = expr.loc\n parser.state.module.addPresentationalDependency(dep1)\n const dep2 = new ConstDependency('})', expr.range[1])\n dep2.loc = expr.loc\n parser.state.module.addPresentationalDependency(dep2)\n }\n }\n\n /**\n * Handler to store original source location of static and dynamic imports into module's buildInfo.\n */\n const handleImport = (node: any) => {\n if (isInMiddlewareLayer(parser) && node.source?.value && node?.loc) {\n const { module, source } = parser.state\n const buildInfo = getModuleBuildInfo(module)\n if (!buildInfo.importLocByPath) {\n buildInfo.importLocByPath = new Map()\n }\n\n const importedModule = node.source.value?.toString()\n buildInfo.importLocByPath.set(importedModule, {\n sourcePosition: {\n ...node.loc.start,\n source: module.identifier(),\n },\n sourceContent: source.toString(),\n })\n\n if (\n !dev &&\n (isNodeJsModule(importedModule) || isBunModule(importedModule)) &&\n !SUPPORTED_NATIVE_MODULES.includes(importedModule)\n ) {\n const isBun = isBunModule(importedModule)\n compilation.warnings.push(\n buildWebpackError({\n message: `A ${isBun ? 'Bun' : 'Node.js'} module is loaded ('${importedModule}' at line ${node.loc.start.line}) which is not supported in the Edge Runtime.\nLearn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`,\n compilation,\n parser,\n ...node,\n })\n )\n }\n }\n }\n\n /**\n * A noop handler to skip analyzing some cases.\n * Order matters: for it to work, it must be registered first\n */\n const skip = () => (isInMiddlewareLayer(parser) ? true : undefined)\n\n for (const prefix of ['', 'global.']) {\n hooks.expression.for(`${prefix}Function.prototype`).tap(NAME, skip)\n hooks.expression.for(`${prefix}Function.bind`).tap(NAME, skip)\n hooks.call.for(`${prefix}eval`).tap(NAME, handleWrapExpression)\n hooks.call.for(`${prefix}Function`).tap(NAME, handleWrapExpression)\n hooks.new.for(`${prefix}Function`).tap(NAME, handleWrapExpression)\n hooks.call\n .for(`${prefix}WebAssembly.compile`)\n .tap(NAME, handleWrapWasmCompileExpression)\n hooks.call\n .for(`${prefix}WebAssembly.instantiate`)\n .tap(NAME, handleWrapWasmInstantiateExpression)\n }\n\n hooks.importCall.tap(NAME, handleImport)\n hooks.import.tap(NAME, handleImport)\n\n if (!dev) {\n // do not issue compilation warning on dev: invoking code will provide details\n registerUnsupportedApiHooks(parser, compilation)\n }\n }\n}\n\nasync function codeAnalyzerBySwc(\n compilation: webpack.Compilation,\n modules: Iterable<webpack.Module>,\n dev: boolean\n) {\n const binding = require('../../swc') as typeof import('../../swc')\n for (const module of modules) {\n if (\n module.layer !== WEBPACK_LAYERS.middleware &&\n module.layer !== WEBPACK_LAYERS.apiEdge\n ) {\n continue\n }\n if (module.constructor.name !== 'NormalModule') {\n continue\n }\n const normalModule = module as webpack.NormalModule\n if (!normalModule.type.startsWith('javascript')) {\n // Only analyze JavaScript modules\n continue\n }\n const originalSource = normalModule.originalSource()\n if (!originalSource) {\n continue\n }\n const source = originalSource.source()\n if (typeof source !== 'string') {\n continue\n }\n const diagnostics = await binding.warnForEdgeRuntime(source, !dev)\n for (const diagnostic of diagnostics) {\n const webpackError = buildWebpackError({\n message: diagnostic.message,\n loc: diagnostic.loc,\n compilation,\n entryModule: module,\n })\n if (diagnostic.severity === 'Warning') {\n compilation.warnings.push(webpackError)\n } else {\n compilation.errors.push(webpackError)\n }\n }\n }\n}\n\nfunction getExtractMetadata(params: {\n compilation: webpack.Compilation\n compiler: webpack.Compiler\n dev: boolean\n metadataByEntry: Map<string, EntryMetadata>\n}): () => Promise<void> {\n const { dev, compilation, metadataByEntry, compiler } = params\n const { webpack: wp } = compiler\n return async () => {\n metadataByEntry.clear()\n const telemetry: Telemetry | undefined = traceGlobals.get('telemetry')\n\n for (const [entryName, entry] of compilation.entries) {\n if (entry.options.runtime !== EDGE_RUNTIME_WEBPACK) {\n // Only process edge runtime entries\n continue\n }\n const entryDependency = entry.dependencies?.[0]\n const resolvedModule =\n compilation.moduleGraph.getResolvedModule(entryDependency)\n if (!resolvedModule) {\n continue\n }\n const { rootDir, route } = getModuleBuildInfo(resolvedModule)\n\n const { moduleGraph } = compilation\n const modules = new Set<webpack.NormalModule>()\n const addEntriesFromDependency = (dependency: any) => {\n const module = moduleGraph.getModule(dependency)\n if (module) {\n modules.add(module as webpack.NormalModule)\n }\n }\n\n entry.dependencies.forEach(addEntriesFromDependency)\n entry.includeDependencies.forEach(addEntriesFromDependency)\n\n const entryMetadata: EntryMetadata = {\n wasmBindings: new Map(),\n assetBindings: new Map(),\n }\n\n if (route?.middlewareConfig?.regions) {\n entryMetadata.regions = route.middlewareConfig.regions\n }\n\n if (route?.preferredRegion) {\n const preferredRegion = route.preferredRegion\n entryMetadata.regions =\n // Ensures preferredRegion is always an array in the manifest.\n typeof preferredRegion === 'string'\n ? [preferredRegion]\n : preferredRegion\n }\n\n let ogImageGenerationCount = 0\n\n for (const module of modules) {\n const buildInfo = getModuleBuildInfo(module)\n\n /**\n * Check if it uses the image generation feature.\n */\n if (!dev) {\n const resource = module.resource\n const hasOGImageGeneration =\n resource &&\n /[\\\\/]node_modules[\\\\/]@vercel[\\\\/]og[\\\\/]dist[\\\\/]index\\.(edge|node)\\.js$|[\\\\/]next[\\\\/]dist[\\\\/](esm[\\\\/])?server[\\\\/]og[\\\\/]image-response\\.js$/.test(\n resource\n )\n\n if (hasOGImageGeneration) {\n ogImageGenerationCount++\n }\n }\n\n /**\n * When building for production checks if the module is using `eval`\n * and in such case produces a compilation error. The module has to\n * be in use.\n */\n if (\n !dev &&\n buildInfo.usingIndirectEval &&\n isUsingIndirectEvalAndUsedByExports({\n module,\n moduleGraph,\n runtime: wp.util.runtime.getEntryRuntime(compilation, entryName),\n usingIndirectEval: buildInfo.usingIndirectEval,\n wp,\n })\n ) {\n const id = module.identifier()\n if (/node_modules[\\\\/]regenerator-runtime[\\\\/]runtime\\.js/.test(id)) {\n continue\n }\n if (route?.middlewareConfig?.unstable_allowDynamic) {\n telemetry?.record({\n eventName: 'NEXT_EDGE_ALLOW_DYNAMIC_USED',\n payload: {\n file: route?.absolutePagePath.replace(rootDir ?? '', ''),\n config: route?.middlewareConfig,\n fileWithDynamicCode: module.userRequest.replace(\n rootDir ?? '',\n ''\n ),\n },\n })\n }\n if (\n !isDynamicCodeEvaluationAllowed(\n module.userRequest,\n route?.middlewareConfig,\n rootDir\n )\n ) {\n const message = `Dynamic Code Evaluation (e. g. 'eval', 'new Function', 'WebAssembly.compile') not allowed in Edge Runtime ${\n typeof buildInfo.usingIndirectEval !== 'boolean'\n ? `\\nUsed by ${Array.from(buildInfo.usingIndirectEval).join(\n ', '\n )}`\n : ''\n }\\nLearn More: https://nextjs.org/docs/messages/edge-dynamic-code-evaluation`\n compilation.errors.push(\n getDynamicCodeEvaluationError(\n message,\n module,\n compilation,\n compiler\n )\n )\n }\n }\n\n /**\n * The entry module has to be either a page or a middleware and hold\n * the corresponding metadata.\n */\n if (buildInfo?.nextEdgeSSR) {\n entryMetadata.edgeSSR = buildInfo.nextEdgeSSR\n } else if (buildInfo?.nextEdgeMiddleware) {\n entryMetadata.edgeMiddleware = buildInfo.nextEdgeMiddleware\n } else if (buildInfo?.nextEdgeApiFunction) {\n entryMetadata.edgeApiFunction = buildInfo.nextEdgeApiFunction\n }\n\n /**\n * If the module is a WASM module we read the binding information and\n * append it to the entry wasm bindings.\n */\n if (buildInfo?.nextWasmMiddlewareBinding) {\n entryMetadata.wasmBindings.set(\n buildInfo.nextWasmMiddlewareBinding.name,\n buildInfo.nextWasmMiddlewareBinding.filePath\n )\n }\n\n if (buildInfo?.nextAssetMiddlewareBinding) {\n entryMetadata.assetBindings.set(\n buildInfo.nextAssetMiddlewareBinding.name,\n buildInfo.nextAssetMiddlewareBinding.filePath\n )\n }\n\n /**\n * Append to the list of modules to process outgoingConnections from\n * the module that is being processed.\n */\n for (const conn of getModuleReferencesInOrder(module, moduleGraph)) {\n if (conn.module) {\n modules.add(conn.module as webpack.NormalModule)\n }\n }\n }\n\n telemetry?.record({\n eventName: EVENT_BUILD_FEATURE_USAGE,\n payload: {\n featureName: 'vercelImageGeneration',\n invocationCount: ogImageGenerationCount,\n },\n })\n metadataByEntry.set(entryName, entryMetadata)\n }\n }\n}\n\n// These values will be replaced again in edge runtime deployment build.\n// `buildId` represents BUILD_ID to be externalized in env vars.\n// `encryptionKey` represents server action encryption key to be externalized in env vars.\ntype EdgeRuntimeEnvironments = Record<string, string> & {\n __NEXT_BUILD_ID: string\n NEXT_SERVER_ACTIONS_ENCRYPTION_KEY: string\n}\n\ninterface Options {\n dev: boolean\n sriEnabled: boolean\n rewrites: CustomRoutes['rewrites']\n edgeEnvironments: EdgeRuntimeEnvironments\n}\n\nexport default class MiddlewarePlugin {\n private readonly dev: Options['dev']\n private readonly sriEnabled: Options['sriEnabled']\n private readonly rewrites: Options['rewrites']\n private readonly edgeEnvironments: EdgeRuntimeEnvironments\n\n constructor({ dev, sriEnabled, rewrites, edgeEnvironments }: Options) {\n this.dev = dev\n this.sriEnabled = sriEnabled\n this.rewrites = rewrites\n this.edgeEnvironments = edgeEnvironments\n }\n\n public apply(compiler: webpack.Compiler) {\n compiler.hooks.compilation.tap(NAME, (compilation, params) => {\n // parser hooks aren't available in rspack\n if (process.env.NEXT_RSPACK) {\n compilation.hooks.finishModules.tapPromise(NAME, async (modules) => {\n await codeAnalyzerBySwc(compilation, modules, this.dev)\n })\n } else {\n const { hooks } = params.normalModuleFactory\n /**\n * This is the static code analysis phase.\n */\n const codeAnalyzer = getCodeAnalyzer({\n dev: this.dev,\n compiler,\n compilation,\n })\n\n hooks.parser.for('javascript/auto').tap(NAME, codeAnalyzer)\n hooks.parser.for('javascript/dynamic').tap(NAME, codeAnalyzer)\n hooks.parser.for('javascript/esm').tap(NAME, codeAnalyzer)\n }\n\n /**\n * Extract all metadata for the entry points in a Map object.\n */\n const metadataByEntry = new Map<string, EntryMetadata>()\n compilation.hooks.finishModules.tapPromise(\n NAME,\n getExtractMetadata({\n compilation,\n compiler,\n dev: this.dev,\n metadataByEntry,\n })\n )\n\n /**\n * Emit the middleware manifest.\n */\n compilation.hooks.processAssets.tap(\n {\n name: 'NextJsMiddlewareManifest',\n stage: webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,\n },\n getCreateAssets({\n compilation,\n metadataByEntry,\n opts: {\n sriEnabled: this.sriEnabled,\n rewrites: this.rewrites,\n edgeEnvironments: this.edgeEnvironments,\n dev: this.dev,\n },\n })\n )\n })\n }\n}\n\nexport const SUPPORTED_NATIVE_MODULES = [\n 'buffer',\n 'events',\n 'assert',\n 'util',\n 'async_hooks',\n] as const\n\nconst supportedEdgePolyfills = new Set<string>(SUPPORTED_NATIVE_MODULES)\n\nexport function getEdgePolyfilledModules() {\n const records: Record<string, string> = {}\n for (const mod of SUPPORTED_NATIVE_MODULES) {\n records[mod] = `commonjs node:${mod}`\n records[`node:${mod}`] = `commonjs node:${mod}`\n }\n return records\n}\n\nexport async function handleWebpackExternalForEdgeRuntime({\n request,\n context,\n contextInfo,\n getResolve,\n}: {\n request: string\n context: string\n contextInfo: any\n getResolve: () => any\n}) {\n if (\n (contextInfo.issuerLayer === WEBPACK_LAYERS.middleware ||\n contextInfo.issuerLayer === WEBPACK_LAYERS.apiEdge) &&\n (isNodeJsModule(request) || isBunModule(request)) &&\n !supportedEdgePolyfills.has(request)\n ) {\n // allows user to provide and use their polyfills, as we do with buffer.\n try {\n await getResolve()(context, request)\n } catch {\n return `root globalThis.__import_unsupported('${request}')`\n }\n }\n}\n"],"names":["getNamedMiddlewareRegex","getModuleBuildInfo","getSortedRoutes","webpack","sources","picomatch","path","EDGE_RUNTIME_WEBPACK","EDGE_UNSUPPORTED_NODE_APIS","MIDDLEWARE_BUILD_MANIFEST","CLIENT_REFERENCE_MANIFEST","MIDDLEWARE_MANIFEST","MIDDLEWARE_REACT_LOADABLE_MANIFEST","SUBRESOURCE_INTEGRITY_MANIFEST","NEXT_FONT_MANIFEST","SERVER_REFERENCE_MANIFEST","INTERCEPTION_ROUTE_REWRITE_MANIFEST","DYNAMIC_CSS_MANIFEST","traceGlobals","EVENT_BUILD_FEATURE_USAGE","normalizeAppPath","INSTRUMENTATION_HOOK_FILENAME","WEBPACK_LAYERS","isInterceptionRouteRewrite","getDynamicCodeEvaluationError","getModuleReferencesInOrder","KNOWN_SAFE_DYNAMIC_PACKAGES","require","NAME","MANIFEST_VERSION","isUsingIndirectEvalAndUsedByExports","args","moduleGraph","runtime","module","usingIndirectEval","wp","exportsInfo","getExportsInfo","exportName","getUsed","UsageState","Unused","getEntryFiles","entryFiles","meta","hasInstrumentationHook","opts","files","edgeSSR","isServerComponent","push","sriEnabled","filter","file","startsWith","endsWith","map","replace","dev","isAppDir","getCreateAssets","params","compilation","metadataByEntry","middlewareManifest","version","middleware","functions","sortedMiddleware","entrypoints","has","interceptionRewrites","JSON","stringify","rewrites","beforeFiles","emitAsset","RawSource","entrypoint","values","metadata","name","get","page","edgeMiddleware","edgeApiFunction","matcherSource","catchAll","namedRegex","matchers","regexp","originalSource","isEdgeFunction","edgeFunctionDefinition","getFiles","wasm","Array","from","wasmBindings","filePath","assets","assetBindings","env","edgeEnvironments","regions","Object","keys","buildWebpackError","message","loc","entryModule","parser","error","compiler","WebpackError","state","current","isInMiddlewareLayer","layer","apiEdge","isNodeJsModule","moduleName","builtinModules","includes","isBunModule","isDynamicCodeEvaluationAllowed","fileName","middlewareConfig","rootDir","some","pkg","sep","unstable_allowDynamic","dot","buildUnsupportedApiError","apiName","rest","start","line","registerUnsupportedApiHooks","expression","warnForUnsupportedApi","node","warnings","hooks","call","for","tap","callMemberChain","expressionMemberChain","warnForUnsupportedProcessApi","callee","getCodeAnalyzer","handleExpression","optimize","InnerGraph","onUsage","used","buildInfo","Set","handleWrapExpression","expr","ConstDependency","dependencies","dep1","range","addPresentationalDependency","dep2","handleWrapWasmCompileExpression","handleWrapWasmInstantiateExpression","handleImport","source","value","importLocByPath","Map","importedModule","toString","set","sourcePosition","identifier","sourceContent","SUPPORTED_NATIVE_MODULES","isBun","skip","undefined","prefix","new","importCall","import","codeAnalyzerBySwc","modules","binding","constructor","normalModule","type","diagnostics","warnForEdgeRuntime","diagnostic","webpackError","severity","errors","getExtractMetadata","clear","telemetry","entryName","entry","entries","route","options","entryDependency","resolvedModule","getResolvedModule","addEntriesFromDependency","dependency","getModule","add","forEach","includeDependencies","entryMetadata","preferredRegion","ogImageGenerationCount","resource","hasOGImageGeneration","test","util","getEntryRuntime","id","record","eventName","payload","absolutePagePath","config","fileWithDynamicCode","userRequest","join","nextEdgeSSR","nextEdgeMiddleware","nextEdgeApiFunction","nextWasmMiddlewareBinding","nextAssetMiddlewareBinding","conn","featureName","invocationCount","MiddlewarePlugin","apply","process","NEXT_RSPACK","finishModules","tapPromise","normalModuleFactory","codeAnalyzer","processAssets","stage","Compilation","PROCESS_ASSETS_STAGE_ADDITIONS","supportedEdgePolyfills","getEdgePolyfilledModules","records","mod","handleWebpackExternalForEdgeRuntime","request","context","contextInfo","getResolve","issuer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AW,CAACC,8BAA8B;YAC3D,GACAlM,gBAAgB;gBACdE;gBACAC;gBACAjB,MAAM;oBACJK,YAAY,IAAI,CAACA,UAAU;oBAC3BuB,UAAU,IAAI,CAACA,QAAQ;oBACvB6B,kBAAkB,IAAI,CAACA,gBAAgB;oBACvC7C,KAAK,IAAI,CAACA,GAAG;gBACf;YACF;QAEJ;IACF;AACF;AAEA,OAAO,MAAM2H,2BAA2B;IACtC;IACA;IACA;IACA;IACA;CACD,CAAS;AAEV,MAAM0E,yBAAyB,IAAIhG,IAAYsB;AAE/C,OAAO,SAAS2E;IACd,MAAMC,UAAkC,CAAC;IACzC,KAAK,MAAMC,OAAO7E,yBAA0B;QAC1C4E,OAAO,CAACC,IAAI,GAAG,CAAC,cAAc,EAAEA,KAAK;QACrCD,OAAO,CAAC,CAAC,KAAK,EAAEC,KAAK,CAAC,GAAG,CAAC,cAAc,EAAEA,KAAK;IACjD;IACA,OAAOD;AACT;AAEA,OAAO,eAAeE,oCAAoC,EACxDC,OAAO,EACPC,OAAO,EACPC,WAAW,EACXC,UAAU,EAMX;IACC,IACE,AAACD,CAAAA,YAAYE,WAAW,KAAKnP,eAAe6C,UAAU,IACpDoM,YAAYE,WAAW,KAAKnP,eAAekG,OAAO,AAAD,KAClDC,CAAAA,eAAe4I,YAAYxI,YAAYwI,QAAO,KAC/C,CAACL,uBAAuBzL,GAAG,CAAC8L,UAC5B;QACA,wEAAwE;QACxE,IAAI;YACF,MAAMG,aAAaF,SAASD;QAC9B,EAAE,OAAM;YACN,OAAO,CAAC,sCAAsC,EAAEA,QAAQ,EAAE,CAAC;QAC7D;IACF;AACF","ignoreList":[0]}
@@ -588,6 +588,14 @@ export default async function getBaseWebpackConfig(dir, { buildId, encryptionKey
588
588
  pageExtensionsRegex
589
589
  ];
590
590
  const builtinModules = require('module').builtinModules;
591
+ const bunExternals = [
592
+ 'bun:ffi',
593
+ 'bun:jsc',
594
+ 'bun:sqlite',
595
+ 'bun:test',
596
+ 'bun:wrap',
597
+ 'bun'
598
+ ];
591
599
  const shouldEnableSlowModuleDetection = !!config.experimental.slowModuleDetection && dev;
592
600
  const getParallelism = ()=>{
593
601
  const override = Number(process.env.NEXT_WEBPACK_PARALLELISM);
@@ -677,6 +685,7 @@ export default async function getBaseWebpackConfig(dir, { buildId, encryptionKey
677
685
  ] : []
678
686
  ] : [
679
687
  ...builtinModules,
688
+ ...bunExternals,
680
689
  ({ context, request, dependencyType, contextInfo, getResolve })=>handleExternals(context, request, dependencyType, contextInfo.issuerLayer, (options)=>{
681
690
  const resolveFunction = getResolve(options);
682
691
  return (resolveContext, requestToResolve)=>new Promise((resolve, reject)=>{
@@ -1600,7 +1609,7 @@ export default async function getBaseWebpackConfig(dir, { buildId, encryptionKey
1600
1609
  isClient && new CopyFilePlugin({
1601
1610
  // file path to build output of `@next/polyfill-nomodule`
1602
1611
  filePath: require.resolve('./polyfills/polyfill-nomodule'),
1603
- cacheKey: "15.4.2-canary.25",
1612
+ cacheKey: "15.4.2-canary.26",
1604
1613
  name: `static/chunks/polyfills${dev ? '' : '-[hash]'}.js`,
1605
1614
  minimize: false,
1606
1615
  info: {
@@ -1780,7 +1789,7 @@ export default async function getBaseWebpackConfig(dir, { buildId, encryptionKey
1780
1789
  // - Next.js location on disk (some loaders use absolute paths and some resolve options depend on absolute paths)
1781
1790
  // - Next.js version
1782
1791
  // - next.config.js keys that affect compilation
1783
- version: `${__dirname}|${"15.4.2-canary.25"}|${configVars}`,
1792
+ version: `${__dirname}|${"15.4.2-canary.26"}|${configVars}`,
1784
1793
  cacheDirectory: path.join(distDir, 'cache', 'webpack'),
1785
1794
  // For production builds, it's more efficient to compress all cache files together instead of compression each one individually.
1786
1795
  // So we disable compression here and allow the build runner to take care of compressing the cache as a whole.