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.
- package/dist/bin/next +1 -1
- package/dist/build/handle-externals.js +4 -0
- package/dist/build/handle-externals.js.map +1 -1
- package/dist/build/index.js +2 -2
- package/dist/build/swc/index.js +1 -1
- package/dist/build/webpack/plugins/middleware-plugin.js +7 -3
- package/dist/build/webpack/plugins/middleware-plugin.js.map +1 -1
- package/dist/build/webpack-config.js +11 -2
- package/dist/build/webpack-config.js.map +1 -1
- package/dist/client/app-bootstrap.js +1 -1
- package/dist/client/index.js +1 -1
- package/dist/compiled/next-server/pages-api-turbo.runtime.dev.js +1 -1
- package/dist/compiled/next-server/pages-api-turbo.runtime.dev.js.map +1 -1
- package/dist/compiled/next-server/pages-api.runtime.prod.js +1 -1
- package/dist/compiled/next-server/pages-api.runtime.prod.js.map +1 -1
- package/dist/compiled/next-server/pages-turbo.runtime.dev.js +1 -1
- package/dist/compiled/next-server/pages-turbo.runtime.dev.js.map +1 -1
- package/dist/compiled/next-server/pages.runtime.prod.js +1 -1
- package/dist/compiled/next-server/pages.runtime.prod.js.map +1 -1
- package/dist/esm/build/handle-externals.js +4 -0
- package/dist/esm/build/handle-externals.js.map +1 -1
- package/dist/esm/build/index.js +2 -2
- package/dist/esm/build/swc/index.js +1 -1
- package/dist/esm/build/webpack/plugins/middleware-plugin.js +7 -3
- package/dist/esm/build/webpack/plugins/middleware-plugin.js.map +1 -1
- package/dist/esm/build/webpack-config.js +11 -2
- package/dist/esm/build/webpack-config.js.map +1 -1
- package/dist/esm/client/app-bootstrap.js +1 -1
- package/dist/esm/client/index.js +1 -1
- package/dist/esm/server/dev/hot-reloader-turbopack.js +1 -1
- package/dist/esm/server/dev/hot-reloader-webpack.js +1 -1
- package/dist/esm/server/lib/app-info-log.js +1 -1
- package/dist/esm/server/lib/start-server.js +1 -1
- package/dist/esm/shared/lib/canary-only.js +1 -1
- package/dist/server/dev/hot-reloader-turbopack.js +1 -1
- package/dist/server/dev/hot-reloader-webpack.js +1 -1
- package/dist/server/lib/app-info-log.js +1 -1
- package/dist/server/lib/start-server.js +1 -1
- package/dist/shared/lib/canary-only.js +1 -1
- package/dist/telemetry/anonymous-meta.js +1 -1
- package/dist/telemetry/events/session-stopped.js +2 -2
- package/dist/telemetry/events/version.js +2 -2
- package/package.json +15 -15
package/dist/bin/next
CHANGED
@@ -79,7 +79,7 @@ const program = new NextRootCommand();
|
|
79
79
|
program.name('next').description('The Next.js CLI allows you to develop, build, start your application, and more.').configureHelp({
|
80
80
|
formatHelp: (cmd, helper)=>(0, _formatclihelpoutput.formatCliHelpOutput)(cmd, helper),
|
81
81
|
subcommandTerm: (cmd)=>`${cmd.name()} ${cmd.usage()}`
|
82
|
-
}).helpCommand(false).helpOption('-h, --help', 'Displays this message.').version(`Next.js v${"15.4.2-canary.
|
82
|
+
}).helpCommand(false).helpOption('-h, --help', 'Displays this message.').version(`Next.js v${"15.4.2-canary.26"}`, '-v, --version', 'Outputs the Next.js version.');
|
83
83
|
program.command('build').description('Creates an optimized production build of your application. The output displays information about each route.').argument('[directory]', `A directory on which to build the application. ${(0, _picocolors.italic)('If no directory is provided, the current directory will be used.')}`).option('-d, --debug', 'Enables a more verbose build output.').option('--debug-prerender', 'Enables debug mode for prerendering. Not for production use!').option('--no-lint', 'Disables linting.').option('--no-mangling', 'Disables mangling.').option('--profile', 'Enables production profiling for React.').option('--experimental-app-only', 'Builds only App Router routes.').option('--turbo', 'Starts development mode using Turbopack.').option('--turbopack', 'Starts development mode using Turbopack.').addOption(new _commander.Option('--experimental-build-mode [mode]', 'Uses an experimental build mode.').choices([
|
84
84
|
'compile',
|
85
85
|
'generate',
|
@@ -142,6 +142,10 @@ function makeExternalHandler({ config, optOutBundlingPackageRegex, transpiledPac
|
|
142
142
|
if (reactPackagesRegex.test(request) && !isAppLayer) {
|
143
143
|
return `commonjs ${request}`;
|
144
144
|
}
|
145
|
+
// Handle Bun builtins as external modules
|
146
|
+
if (request === 'bun' || request.startsWith('bun:')) {
|
147
|
+
return `commonjs ${request}`;
|
148
|
+
}
|
145
149
|
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$)/;
|
146
150
|
if (notExternalModules.test(request)) {
|
147
151
|
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":["isResourceInPackages","makeExternalHandler","resolveExternal","reactPackagesRegex","pathSeparators","optionalEsmPart","externalFileEnd","nextDist","externalPattern","RegExp","nodeModulesRegex","resource","packageNames","packageDirMapping","some","p","has","startsWith","get","path","sep","includes","join","replace","dir","esmExternalsConfig","context","request","isEsmRequested","getResolve","isLocalCallback","baseResolveCheck","esmResolveOptions","NODE_ESM_RESOLVE_OPTIONS","nodeResolveOptions","NODE_RESOLVE_OPTIONS","baseEsmResolveOptions","NODE_BASE_ESM_RESOLVE_OPTIONS","baseResolveOptions","NODE_BASE_RESOLVE_OPTIONS","esmExternals","looseEsmExternals","res","isEsm","preferEsmOptions","preferEsm","resolveOptions","resolve","err","localRes","baseRes","baseIsEsm","baseResolve","config","optOutBundlingPackageRegex","transpiledPackages","resolvedExternalPackageDirs","experimental","handleExternals","dependencyType","layer","isLocal","posix","isAbsolute","process","platform","win32","isAppLayer","isWebpackBundledLayer","test","notExternalModules","BARREL_OPTIMIZATION_PREFIX","shouldUseReactServerCondition","resolveNextExternal","resolveResult","undefined","defaultOverrides","isOptOutBundling","Error","externalType","Map","pkg","pkgRes","set","dirname","resolvedBundlingOptOutRes","resolveBundlingOptOutPackages","resolvedRes","shouldBundlePages","bundlePagesRouterDependencies","shouldBeBundled","isExternal","normalizePathSep"],"mappings":";;;;;;;;;;;;;;;;IA2BgBA,oBAAoB;eAApBA;;IAyGAC,mBAAmB;eAAnBA;;IAxFMC,eAAe;eAAfA;;;6BAzCW;2BACU;6DAC1B;+BAMV;uBAC8D;kCACpC;;;;;;AACjC,MAAMC,qBAAqB;AAE3B,MAAMC,iBAAiB;AACvB,MAAMC,kBAAkB,CAAC,EAAE,EAAED,eAAe,KAAK,EAAEA,eAAe,CAAC,CAAC;AACpE,MAAME,kBAAkB;AACxB,MAAMC,WAAW,CAAC,IAAI,EAAEH,eAAe,IAAI,CAAC;AAE5C,MAAMI,kBAAkB,IAAIC,OAC1B,GAAGF,WAAWF,gBAAgB,EAAE,EAAEC,iBAAiB;AAGrD,MAAMI,mBAAmB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D,MAAM,iBACNrD,gBACAC,YACAgC,UAAUY,sBAAsBE;gBAElC,IAAIO,OAAOxC,GAAG,EAAE;oBACdc,4BAA4B2B,GAAG,CAACF,KAAK9D,aAAI,CAACiE,OAAO,CAACF,OAAOxC,GAAG;gBAC9D;YACF;QACF;QAEA,MAAM2C,4BAA4BC,8BAA8B;YAC9DC,aAAa7C;YACbW;YACAG;YACAW;YACAY;YACAF;YACAlD;YACA4B;QACF;QACA,IAAI8B,2BAA2B;YAC7B,OAAOA;QACT;QAEA,2CAA2C;QAC3C;IACF;AACF;AAEA,SAASC,8BAA8B,EACrCC,WAAW,EACXlC,MAAM,EACNG,2BAA2B,EAC3BW,UAAU,EACVY,YAAY,EACZF,gBAAgB,EAChBlD,OAAO,EACP4B,kBAAkB,EAUnB;IACC,IAAI7C,iBAAiB2D,IAAI,CAACkB,cAAc;QACtC,MAAMC,oBACJ,CAACrB,cAAcd,OAAOoC,6BAA6B,IAAI,CAACZ;QAE1D,MAAMa,kBACJF,qBACAxF,qBACEuF,aACAhC,oBACAC;QAGJ,IAAI,CAACkC,iBAAiB;YACpB,OAAO,GAAGX,aAAa,CAAC,EAAEpD,SAAS,CAAC,0CAA0C;;QAChF;IACF;AACF;AAEA;;;;;;CAMC,GACD,SAAS8C,oBAAoBxB,QAAgB;IAC3C,MAAM0C,aAAanF,gBAAgB6D,IAAI,CAACpB;IAExC,sFAAsF;IACtF,sGAAsG;IACtG,IAAI0C,YAAY;QACd,oGAAoG;QACpG,oCAAoC;QACpC,OAAO,CAAC,SAAS,EAAEC,IAAAA,kCAAgB,EACjC3C,SAAS1B,OAAO,CAAC,oBAAoB,eACpC;IACL;AACF","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":["isResourceInPackages","makeExternalHandler","resolveExternal","reactPackagesRegex","pathSeparators","optionalEsmPart","externalFileEnd","nextDist","externalPattern","RegExp","nodeModulesRegex","resource","packageNames","packageDirMapping","some","p","has","startsWith","get","path","sep","includes","join","replace","dir","esmExternalsConfig","context","request","isEsmRequested","getResolve","isLocalCallback","baseResolveCheck","esmResolveOptions","NODE_ESM_RESOLVE_OPTIONS","nodeResolveOptions","NODE_RESOLVE_OPTIONS","baseEsmResolveOptions","NODE_BASE_ESM_RESOLVE_OPTIONS","baseResolveOptions","NODE_BASE_RESOLVE_OPTIONS","esmExternals","looseEsmExternals","res","isEsm","preferEsmOptions","preferEsm","resolveOptions","resolve","err","localRes","baseRes","baseIsEsm","baseResolve","config","optOutBundlingPackageRegex","transpiledPackages","resolvedExternalPackageDirs","experimental","handleExternals","dependencyType","layer","isLocal","posix","isAbsolute","process","platform","win32","isAppLayer","isWebpackBundledLayer","test","notExternalModules","BARREL_OPTIMIZATION_PREFIX","shouldUseReactServerCondition","resolveNextExternal","resolveResult","undefined","defaultOverrides","isOptOutBundling","Error","externalType","Map","pkg","pkgRes","set","dirname","resolvedBundlingOptOutRes","resolveBundlingOptOutPackages","resolvedRes","shouldBundlePages","bundlePagesRouterDependencies","shouldBeBundled","isExternal","normalizePathSep"],"mappings":";;;;;;;;;;;;;;;;IA2BgBA,oBAAoB;eAApBA;;IAyGAC,mBAAmB;eAAnBA;;IAxFMC,eAAe;eAAfA;;;6BAzCW;2BACU;6DAC1B;+BAMV;uBAC8D;kCACpC;;;;;;AACjC,MAAMC,qBAAqB;AAE3B,MAAMC,iBAAiB;AACvB,MAAMC,kBAAkB,CAAC,EAAE,EAAED,eAAe,KAAK,EAAEA,eAAe,CAAC,CAAC;AACpE,MAAME,kBAAkB;AACxB,MAAMC,WAAW,CAAC,IAAI,EAAEH,eAAe,IAAI,CAAC;AAE5C,MAAMI,kBAAkB,IAAIC,OAC1B,GAAGF,WAAWF,gBAAgB,EAAE,EAAEC,iBAAiB;AAGrD,MAAMI,mBAAmB;AAElB,SAASV,qBACdW,QAAgB,EAChBC,YAAuB,EACvBC,iBAAuC;IAEvC,IAAI,CAACD,cAAc,OAAO;IAC1B,OAAOA,aAAaE,IAAI,CAAC,CAACC,IACxBF,qBAAqBA,kBAAkBG,GAAG,CAACD,KACvCJ,SAASM,UAAU,CAACJ,kBAAkBK,GAAG,CAACH,KAAMI,aAAI,CAACC,GAAG,IACxDT,SAASU,QAAQ,CACfF,aAAI,CAACC,GAAG,GACND,aAAI,CAACG,IAAI,CAAC,gBAAgBP,EAAEQ,OAAO,CAAC,OAAOJ,aAAI,CAACC,GAAG,KACnDD,aAAI,CAACC,GAAG;AAGpB;AAEO,eAAelB,gBACpBsB,GAAW,EACXC,kBAAsE,EACtEC,OAAe,EACfC,OAAe,EACfC,cAAuB,EACvBC,UAK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ACXlC,MAAM,EACNG,2BAA2B,EAC3BW,UAAU,EACVY,YAAY,EACZF,gBAAgB,EAChBlD,OAAO,EACP4B,kBAAkB,EAUnB;IACC,IAAI7C,iBAAiB2D,IAAI,CAACkB,cAAc;QACtC,MAAMC,oBACJ,CAACrB,cAAcd,OAAOoC,6BAA6B,IAAI,CAACZ;QAE1D,MAAMa,kBACJF,qBACAxF,qBACEuF,aACAhC,oBACAC;QAGJ,IAAI,CAACkC,iBAAiB;YACpB,OAAO,GAAGX,aAAa,CAAC,EAAEpD,SAAS,CAAC,0CAA0C;;QAChF;IACF;AACF;AAEA;;;;;;CAMC,GACD,SAAS8C,oBAAoBxB,QAAgB;IAC3C,MAAM0C,aAAanF,gBAAgB6D,IAAI,CAACpB;IAExC,sFAAsF;IACtF,sGAAsG;IACtG,IAAI0C,YAAY;QACd,oGAAoG;QACpG,oCAAoC;QACpC,OAAO,CAAC,SAAS,EAAEC,IAAAA,kCAAgB,EACjC3C,SAAS1B,OAAO,CAAC,oBAAoB,eACpC;IACL;AACF","ignoreList":[0]}
|
package/dist/build/index.js
CHANGED
@@ -394,7 +394,7 @@ async function build(dir, reactProductionProfiling = false, debugOutput = false,
|
|
394
394
|
const nextBuildSpan = (0, _trace.trace)('next-build', undefined, {
|
395
395
|
buildMode: experimentalBuildMode,
|
396
396
|
isTurboBuild: String(isTurbopack),
|
397
|
-
version: "15.4.2-canary.
|
397
|
+
version: "15.4.2-canary.26"
|
398
398
|
});
|
399
399
|
_buildcontext.NextBuildContext.nextBuildSpan = nextBuildSpan;
|
400
400
|
_buildcontext.NextBuildContext.dir = dir;
|
@@ -781,7 +781,7 @@ async function build(dir, reactProductionProfiling = false, debugOutput = false,
|
|
781
781
|
// Files outside of the distDir can be "type": "module"
|
782
782
|
await writeFileUtf8(_path.default.join(distDir, 'package.json'), '{"type": "commonjs"}');
|
783
783
|
// These are written to distDir, so they need to come after creating and cleaning distDr.
|
784
|
-
await (0, _builddiagnostics.recordFrameworkVersion)("15.4.2-canary.
|
784
|
+
await (0, _builddiagnostics.recordFrameworkVersion)("15.4.2-canary.26");
|
785
785
|
await (0, _builddiagnostics.updateBuildDiagnostics)({
|
786
786
|
buildStage: 'start'
|
787
787
|
});
|
package/dist/build/swc/index.js
CHANGED
@@ -131,7 +131,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
131
131
|
}
|
132
132
|
return newObj;
|
133
133
|
}
|
134
|
-
const nextVersion = "15.4.2-canary.
|
134
|
+
const nextVersion = "15.4.2-canary.26";
|
135
135
|
const ArchName = (0, _os.arch)();
|
136
136
|
const PlatformName = (0, _os.platform)();
|
137
137
|
function infoLog(...args) {
|
@@ -171,6 +171,9 @@ function isInMiddlewareLayer(parser) {
|
|
171
171
|
function isNodeJsModule(moduleName) {
|
172
172
|
return require('module').builtinModules.includes(moduleName);
|
173
173
|
}
|
174
|
+
function isBunModule(moduleName) {
|
175
|
+
return moduleName === 'bun' || moduleName.startsWith('bun:');
|
176
|
+
}
|
174
177
|
function isDynamicCodeEvaluationAllowed(fileName, middlewareConfig, rootDir) {
|
175
178
|
// Some packages are known to use `eval` but are safe to use in the Edge
|
176
179
|
// Runtime because the dynamic code will never be executed.
|
@@ -328,9 +331,10 @@ function getCodeAnalyzer(params) {
|
|
328
331
|
},
|
329
332
|
sourceContent: source.toString()
|
330
333
|
});
|
331
|
-
if (!dev && isNodeJsModule(importedModule) && !SUPPORTED_NATIVE_MODULES.includes(importedModule)) {
|
334
|
+
if (!dev && (isNodeJsModule(importedModule) || isBunModule(importedModule)) && !SUPPORTED_NATIVE_MODULES.includes(importedModule)) {
|
335
|
+
const isBun = isBunModule(importedModule);
|
332
336
|
compilation.warnings.push(buildWebpackError({
|
333
|
-
message: `A Node.js module is loaded ('${importedModule}' at line ${node.loc.start.line}) which is not supported in the Edge Runtime.
|
337
|
+
message: `A ${isBun ? 'Bun' : 'Node.js'} module is loaded ('${importedModule}' at line ${node.loc.start.line}) which is not supported in the Edge Runtime.
|
334
338
|
Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`,
|
335
339
|
compilation,
|
336
340
|
parser,
|
@@ -594,7 +598,7 @@ function getEdgePolyfilledModules() {
|
|
594
598
|
return records;
|
595
599
|
}
|
596
600
|
async function handleWebpackExternalForEdgeRuntime({ request, context, contextInfo, getResolve }) {
|
597
|
-
if ((contextInfo.issuerLayer === _constants1.WEBPACK_LAYERS.middleware || contextInfo.issuerLayer === _constants1.WEBPACK_LAYERS.apiEdge) && isNodeJsModule(request) && !supportedEdgePolyfills.has(request)) {
|
601
|
+
if ((contextInfo.issuerLayer === _constants1.WEBPACK_LAYERS.middleware || contextInfo.issuerLayer === _constants1.WEBPACK_LAYERS.apiEdge) && (isNodeJsModule(request) || isBunModule(request)) && !supportedEdgePolyfills.has(request)) {
|
598
602
|
// allows user to provide and use their polyfills, as we do with buffer.
|
599
603
|
try {
|
600
604
|
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":["SUPPORTED_NATIVE_MODULES","MiddlewarePlugin","getEdgePolyfilledModules","handleWebpackExternalForEdgeRuntime","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","SERVER_REFERENCE_MANIFEST","sriEnabled","SUBRESOURCE_INTEGRITY_MANIFEST","filter","file","startsWith","endsWith","map","replace","CLIENT_REFERENCE_MANIFEST","dev","isAppDir","DYNAMIC_CSS_MANIFEST","MIDDLEWARE_BUILD_MANIFEST","MIDDLEWARE_REACT_LOADABLE_MANIFEST","NEXT_FONT_MANIFEST","INTERCEPTION_ROUTE_REWRITE_MANIFEST","INSTRUMENTATION_HOOK_FILENAME","getCreateAssets","params","compilation","metadataByEntry","middlewareManifest","version","middleware","functions","sortedMiddleware","entrypoints","has","interceptionRewrites","JSON","stringify","rewrites","beforeFiles","isInterceptionRouteRewrite","emitAsset","sources","RawSource","entrypoint","values","metadata","name","get","page","edgeMiddleware","edgeApiFunction","matcherSource","normalizeAppPath","catchAll","namedRegex","getNamedMiddlewareRegex","matchers","regexp","originalSource","isEdgeFunction","edgeFunctionDefinition","getFiles","wasm","Array","from","wasmBindings","filePath","assets","assetBindings","env","edgeEnvironments","regions","getSortedRoutes","Object","keys","MIDDLEWARE_MANIFEST","buildWebpackError","message","loc","entryModule","parser","error","compiler","webpack","WebpackError","state","current","isInMiddlewareLayer","layer","WEBPACK_LAYERS","apiEdge","isNodeJsModule","moduleName","builtinModules","includes","isDynamicCodeEvaluationAllowed","fileName","middlewareConfig","rootDir","some","pkg","path","sep","picomatch","unstable_allowDynamic","dot","buildUnsupportedApiError","apiName","rest","start","line","registerUnsupportedApiHooks","expression","EDGE_UNSUPPORTED_NODE_APIS","warnForUnsupportedApi","node","warnings","hooks","call","for","tap","callMemberChain","expressionMemberChain","warnForUnsupportedProcessApi","callee","getCodeAnalyzer","handleExpression","optimize","InnerGraph","onUsage","used","buildInfo","getModuleBuildInfo","Set","handleWrapExpression","expr","ConstDependency","dependencies","dep1","range","addPresentationalDependency","dep2","handleWrapWasmCompileExpression","handleWrapWasmInstantiateExpression","handleImport","source","value","importLocByPath","Map","importedModule","toString","set","sourcePosition","identifier","sourceContent","skip","undefined","prefix","new","importCall","import","codeAnalyzerBySwc","modules","binding","constructor","normalModule","type","diagnostics","warnForEdgeRuntime","diagnostic","webpackError","severity","errors","getExtractMetadata","clear","telemetry","traceGlobals","entryName","entry","entries","route","options","EDGE_RUNTIME_WEBPACK","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","getDynamicCodeEvaluationError","nextEdgeSSR","nextEdgeMiddleware","nextEdgeApiFunction","nextWasmMiddlewareBinding","nextAssetMiddlewareBinding","conn","getModuleReferencesInOrder","EVENT_BUILD_FEATURE_USAGE","featureName","invocationCount","apply","process","NEXT_RSPACK","finishModules","tapPromise","normalModuleFactory","codeAnalyzer","processAssets","stage","Compilation","PROCESS_ASSETS_STAGE_ADDITIONS","supportedEdgePolyfills","records","mod","request","context","contextInfo","getResolve","issuerLayer"],"mappings":";;;;;;;;;;;;;;;;;IA03BaA,wBAAwB;eAAxBA;;IAzEb,OAuEC;eAvEoBC;;IAmFLC,wBAAwB;eAAxBA;;IASMC,mCAAmC;eAAnCA;;;4BAv4BkB;oCACL;uBACH;yBACC;kEACX;6DACL;2BAaV;wBAGsB;wBACa;0BACT;4BAI1B;oDAEoC;iDACG;wBACH;;;;;;AAE3C,MAAMC,8BACJC,QAAQ;AA6BV,MAAMC,OAAO;AACb,MAAMC,mBAAmB;AAEzB;;;;CAIC,GACD,SAASC,oCAAoCC,IAM5C;IACC,MAAM,EAAEC,WAAW,EAAEC,OAAO,EAAEC,QAAAA,OAAM,EAAEC,iBAAiB,EAAEC,EAAE,EAAE,GAAGL;IAChE,IAAI,OAAOI,sBAAsB,WAAW;QAC1C,OAAOA;IACT;IAEA,MAAME,cAAcL,YAAYM,cAAc,CAACJ;IAC/C,KAAK,MAAMK,cAAcJ,kBAAmB;QAC1C,IAAIE,YAAYG,OAAO,CAACD,YAAYN,aAAaG,GAAGK,UAAU,CAACC,MAAM,EAAE;YACrE,OAAO;QACT;IACF;IAEA,OAAO;AACT;AAEA,SAASC,cACPC,UAAoB,EACpBC,IAAmB,EACnBC,sBAA+B,EAC/BC,IAAa;IAEb,MAAMC,QAAkB,EAAE;IAC1B,IAAIH,KAAKI,OAAO,EAAE;QAChB,IAAIJ,KAAKI,OAAO,CAACC,iBAAiB,EAAE;YAClCF,MAAMG,IAAI,CAAC,CAAC,OAAO,EAAEC,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AOjJ,gBAAO,CAACkJ,WAAW,CAACC,8BAA8B;YAC3D,GACA/M,gBAAgB;gBACdE;gBACAC;gBACA1B,MAAM;oBACJM,YAAY,IAAI,CAACA,UAAU;oBAC3B+B,UAAU,IAAI,CAACA,QAAQ;oBACvBiC,kBAAkB,IAAI,CAACA,gBAAgB;oBACvCvD,KAAK,IAAI,CAACA,GAAG;gBACf;YACF;QAEJ;IACF;AACF;AAEO,MAAMxC,2BAA2B;IACtC;IACA;IACA;IACA;IACA;CACD;AAED,MAAMgQ,yBAAyB,IAAIlG,IAAY9J;AAExC,SAASE;IACd,MAAM+P,UAAkC,CAAC;IACzC,KAAK,MAAMC,OAAOlQ,yBAA0B;QAC1CiQ,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;AAEO,eAAe9P,oCAAoC,EACxDgQ,OAAO,EACPC,OAAO,EACPC,WAAW,EACXC,UAAU,EAMX;IACC,IACE,AAACD,CAAAA,YAAYE,WAAW,KAAKrJ,0BAAc,CAAC5D,UAAU,IACpD+M,YAAYE,WAAW,KAAKrJ,0BAAc,CAACC,OAAO,AAAD,KACnDC,eAAe+I,YACf,CAACH,uBAAuBtM,GAAG,CAACyM,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]}
|
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":["SUPPORTED_NATIVE_MODULES","MiddlewarePlugin","getEdgePolyfilledModules","handleWebpackExternalForEdgeRuntime","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","SERVER_REFERENCE_MANIFEST","sriEnabled","SUBRESOURCE_INTEGRITY_MANIFEST","filter","file","startsWith","endsWith","map","replace","CLIENT_REFERENCE_MANIFEST","dev","isAppDir","DYNAMIC_CSS_MANIFEST","MIDDLEWARE_BUILD_MANIFEST","MIDDLEWARE_REACT_LOADABLE_MANIFEST","NEXT_FONT_MANIFEST","INTERCEPTION_ROUTE_REWRITE_MANIFEST","INSTRUMENTATION_HOOK_FILENAME","getCreateAssets","params","compilation","metadataByEntry","middlewareManifest","version","middleware","functions","sortedMiddleware","entrypoints","has","interceptionRewrites","JSON","stringify","rewrites","beforeFiles","isInterceptionRouteRewrite","emitAsset","sources","RawSource","entrypoint","values","metadata","name","get","page","edgeMiddleware","edgeApiFunction","matcherSource","normalizeAppPath","catchAll","namedRegex","getNamedMiddlewareRegex","matchers","regexp","originalSource","isEdgeFunction","edgeFunctionDefinition","getFiles","wasm","Array","from","wasmBindings","filePath","assets","assetBindings","env","edgeEnvironments","regions","getSortedRoutes","Object","keys","MIDDLEWARE_MANIFEST","buildWebpackError","message","loc","entryModule","parser","error","compiler","webpack","WebpackError","state","current","isInMiddlewareLayer","layer","WEBPACK_LAYERS","apiEdge","isNodeJsModule","moduleName","builtinModules","includes","isBunModule","isDynamicCodeEvaluationAllowed","fileName","middlewareConfig","rootDir","some","pkg","path","sep","picomatch","unstable_allowDynamic","dot","buildUnsupportedApiError","apiName","rest","start","line","registerUnsupportedApiHooks","expression","EDGE_UNSUPPORTED_NODE_APIS","warnForUnsupportedApi","node","warnings","hooks","call","for","tap","callMemberChain","expressionMemberChain","warnForUnsupportedProcessApi","callee","getCodeAnalyzer","handleExpression","optimize","InnerGraph","onUsage","used","buildInfo","getModuleBuildInfo","Set","handleWrapExpression","expr","ConstDependency","dependencies","dep1","range","addPresentationalDependency","dep2","handleWrapWasmCompileExpression","handleWrapWasmInstantiateExpression","handleImport","source","value","importLocByPath","Map","importedModule","toString","set","sourcePosition","identifier","sourceContent","isBun","skip","undefined","prefix","new","importCall","import","codeAnalyzerBySwc","modules","binding","constructor","normalModule","type","diagnostics","warnForEdgeRuntime","diagnostic","webpackError","severity","errors","getExtractMetadata","clear","telemetry","traceGlobals","entryName","entry","entries","route","options","EDGE_RUNTIME_WEBPACK","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","getDynamicCodeEvaluationError","nextEdgeSSR","nextEdgeMiddleware","nextEdgeApiFunction","nextWasmMiddlewareBinding","nextAssetMiddlewareBinding","conn","getModuleReferencesInOrder","EVENT_BUILD_FEATURE_USAGE","featureName","invocationCount","apply","process","NEXT_RSPACK","finishModules","tapPromise","normalModuleFactory","codeAnalyzer","processAssets","stage","Compilation","PROCESS_ASSETS_STAGE_ADDITIONS","supportedEdgePolyfills","records","mod","request","context","contextInfo","getResolve","issuerLayer"],"mappings":";;;;;;;;;;;;;;;;;IA+3BaA,wBAAwB;eAAxBA;;IAzEb,OAuEC;eAvEoBC;;IAmFLC,wBAAwB;eAAxBA;;IASMC,mCAAmC;eAAnCA;;;4BA54BkB;oCACL;uBACH;yBACC;kEACX;6DACL;2BAaV;wBAGsB;wBACa;0BACT;4BAI1B;oDAEoC;iDACG;wBACH;;;;;;AAE3C,MAAMC,8BACJC,QAAQ;AA6BV,MAAMC,OAAO;AACb,MAAMC,mBAAmB;AAEzB;;;;CAIC,GACD,SAASC,oCAAoCC,I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AG,CAAC,cAAc,EAAEA,KAAK;QACrCD,OAAO,CAAC,CAAC,KAAK,EAAEC,KAAK,CAAC,GAAG,CAAC,cAAc,EAAEA,KAAK;IACjD;IACA,OAAOD;AACT;AAEO,eAAehQ,oCAAoC,EACxDkQ,OAAO,EACPC,OAAO,EACPC,WAAW,EACXC,UAAU,EAMX;IACC,IACE,AAACD,CAAAA,YAAYE,WAAW,KAAKvJ,0BAAc,CAAC5D,UAAU,IACpDiN,YAAYE,WAAW,KAAKvJ,0BAAc,CAACC,OAAO,AAAD,KAClDC,CAAAA,eAAeiJ,YAAY7I,YAAY6I,QAAO,KAC/C,CAACH,uBAAuBxM,GAAG,CAAC2M,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]}
|
@@ -691,6 +691,14 @@ async function getBaseWebpackConfig(dir, { buildId, encryptionKey, config, compi
|
|
691
691
|
pageExtensionsRegex
|
692
692
|
];
|
693
693
|
const builtinModules = require('module').builtinModules;
|
694
|
+
const bunExternals = [
|
695
|
+
'bun:ffi',
|
696
|
+
'bun:jsc',
|
697
|
+
'bun:sqlite',
|
698
|
+
'bun:test',
|
699
|
+
'bun:wrap',
|
700
|
+
'bun'
|
701
|
+
];
|
694
702
|
const shouldEnableSlowModuleDetection = !!config.experimental.slowModuleDetection && dev;
|
695
703
|
const getParallelism = ()=>{
|
696
704
|
const override = Number(process.env.NEXT_WEBPACK_PARALLELISM);
|
@@ -780,6 +788,7 @@ async function getBaseWebpackConfig(dir, { buildId, encryptionKey, config, compi
|
|
780
788
|
] : []
|
781
789
|
] : [
|
782
790
|
...builtinModules,
|
791
|
+
...bunExternals,
|
783
792
|
({ context, request, dependencyType, contextInfo, getResolve })=>handleExternals(context, request, dependencyType, contextInfo.issuerLayer, (options)=>{
|
784
793
|
const resolveFunction = getResolve(options);
|
785
794
|
return (resolveContext, requestToResolve)=>new Promise((resolve, reject)=>{
|
@@ -1703,7 +1712,7 @@ async function getBaseWebpackConfig(dir, { buildId, encryptionKey, config, compi
|
|
1703
1712
|
isClient && new _copyfileplugin.CopyFilePlugin({
|
1704
1713
|
// file path to build output of `@next/polyfill-nomodule`
|
1705
1714
|
filePath: require.resolve('./polyfills/polyfill-nomodule'),
|
1706
|
-
cacheKey: "15.4.2-canary.
|
1715
|
+
cacheKey: "15.4.2-canary.26",
|
1707
1716
|
name: `static/chunks/polyfills${dev ? '' : '-[hash]'}.js`,
|
1708
1717
|
minimize: false,
|
1709
1718
|
info: {
|
@@ -1883,7 +1892,7 @@ async function getBaseWebpackConfig(dir, { buildId, encryptionKey, config, compi
|
|
1883
1892
|
// - Next.js location on disk (some loaders use absolute paths and some resolve options depend on absolute paths)
|
1884
1893
|
// - Next.js version
|
1885
1894
|
// - next.config.js keys that affect compilation
|
1886
|
-
version: `${__dirname}|${"15.4.2-canary.
|
1895
|
+
version: `${__dirname}|${"15.4.2-canary.26"}|${configVars}`,
|
1887
1896
|
cacheDirectory: _path.default.join(distDir, 'cache', 'webpack'),
|
1888
1897
|
// For production builds, it's more efficient to compress all cache files together instead of compression each one individually.
|
1889
1898
|
// So we disable compression here and allow the build runner to take care of compressing the cache as a whole.
|