From 44e571cc70f9c88a7e56cb01490ca65560e5cc70 Mon Sep 17 00:00:00 2001 From: Luke Sandberg Date: Wed, 16 Jul 2025 15:11:32 -0700 Subject: [PATCH 1/8] Is it this easy --- .../js/src/nodejs/runtime.ts | 32 +++++-------------- 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/turbopack/crates/turbopack-ecmascript-runtime/js/src/nodejs/runtime.ts b/turbopack/crates/turbopack-ecmascript-runtime/js/src/nodejs/runtime.ts index 78ae34d848020..5ab4457c75ce0 100644 --- a/turbopack/crates/turbopack-ecmascript-runtime/js/src/nodejs/runtime.ts +++ b/turbopack/crates/turbopack-ecmascript-runtime/js/src/nodejs/runtime.ts @@ -86,9 +86,9 @@ function createResolvePathFromModule( function loadChunk(chunkData: ChunkData, source?: SourceInfo): void { if (typeof chunkData === 'string') { - return loadChunkPath(chunkData, source) + loadChunkPath(chunkData, source) } else { - return loadChunkPath(chunkData.path, source) + loadChunkPath(chunkData.path, source) } } @@ -119,7 +119,7 @@ function loadChunkPath(chunkPath: ChunkPath, source?: SourceInfo): void { for (const [moduleId, moduleFactory] of Object.entries(chunkModules)) { if (!moduleFactories[moduleId]) { if (Array.isArray(moduleFactory)) { - let [moduleFactoryFn, otherIds] = moduleFactory + const [moduleFactoryFn, otherIds] = moduleFactory moduleFactories[moduleId] = moduleFactoryFn for (const otherModuleId of otherIds) { moduleFactories[otherModuleId] = moduleFactoryFn @@ -150,30 +150,14 @@ async function loadChunkAsyncUncached( const resolved = path.resolve(RUNTIME_ROOT, chunkPath) try { - const contents = await fs.readFile(resolved, 'utf-8') - - const localRequire = (id: string) => { - let resolvedId = require.resolve(id, { paths: [path.dirname(resolved)] }) - return require(resolvedId) - } - const module = { - exports: {}, - } - // TODO: Use vm.runInThisContext once our minimal supported Node.js version includes https://github.com/nodejs/node/pull/52153 - // eslint-disable-next-line no-eval -- Can't use vm.runInThisContext due to https://github.com/nodejs/node/issues/52102 - ;(0, eval)( - '(function(module, exports, require, __dirname, __filename) {' + - contents + - '\n})' + - '\n//# sourceURL=' + - url.pathToFileURL(resolved) - )(module, module.exports, localRequire, path.dirname(resolved), resolved) - - const chunkModules: CompressedModuleFactories = module.exports + // use await to ensure that evaluation happens in another microtask + // Because we are using a resolved absolute path require shouldn't waste time probing node_modules. + const exports = await require(resolved) + const chunkModules: CompressedModuleFactories = exports for (const [moduleId, moduleFactory] of Object.entries(chunkModules)) { if (!moduleFactories[moduleId]) { if (Array.isArray(moduleFactory)) { - let [moduleFactoryFn, otherIds] = moduleFactory + const [moduleFactoryFn, otherIds] = moduleFactory moduleFactories[moduleId] = moduleFactoryFn for (const otherModuleId of otherIds) { moduleFactories[otherModuleId] = moduleFactoryFn From 4b2dbac7607add1d7030b40c45bdcbf2b10679ad Mon Sep 17 00:00:00 2001 From: Luke Sandberg Date: Wed, 16 Jul 2025 15:29:17 -0700 Subject: [PATCH 2/8] snapshots --- .../output/[turbopack]_runtime.js | 26 ++++++------------- .../output/[turbopack]_runtime.js.map | 2 +- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/turbopack/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js b/turbopack/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js index afa053fe14221..3b2be8c7e0afa 100644 --- a/turbopack/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js +++ b/turbopack/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js @@ -490,9 +490,9 @@ const moduleCache = Object.create(null); } function loadChunk(chunkData, source) { if (typeof chunkData === 'string') { - return loadChunkPath(chunkData, source); + loadChunkPath(chunkData, source); } else { - return loadChunkPath(chunkData.path, source); + loadChunkPath(chunkData.path, source); } } const loadedChunks = new Set(); @@ -517,7 +517,7 @@ function loadChunkPath(chunkPath, source) { for (const [moduleId, moduleFactory] of Object.entries(chunkModules)){ if (!moduleFactories[moduleId]) { if (Array.isArray(moduleFactory)) { - let [moduleFactoryFn, otherIds] = moduleFactory; + const [moduleFactoryFn, otherIds] = moduleFactory; moduleFactories[moduleId] = moduleFactoryFn; for (const otherModuleId of otherIds){ moduleFactories[otherModuleId] = moduleFactoryFn; @@ -541,24 +541,14 @@ function loadChunkPath(chunkPath, source) { async function loadChunkAsyncUncached(source, chunkPath) { const resolved = path.resolve(RUNTIME_ROOT, chunkPath); try { - const contents = await fs.readFile(resolved, 'utf-8'); - const localRequire = (id)=>{ - let resolvedId = require.resolve(id, { - paths: [ - path.dirname(resolved) - ] - }); - return require(resolvedId); - }; - const module1 = { - exports: {} - }; - (0, eval)('(function(module, exports, require, __dirname, __filename) {' + contents + '\n})' + '\n//# sourceURL=' + url.pathToFileURL(resolved))(module1, module1.exports, localRequire, path.dirname(resolved), resolved); - const chunkModules = module1.exports; + // use await to ensure that evaluation happens in another microtask + // Because we are using a resolved absolute path require shouldn't waste time probing node_modules. + const exports = await require(resolved); + const chunkModules = exports; for (const [moduleId, moduleFactory] of Object.entries(chunkModules)){ if (!moduleFactories[moduleId]) { if (Array.isArray(moduleFactory)) { - let [moduleFactoryFn, otherIds] = moduleFactory; + const [moduleFactoryFn, otherIds] = moduleFactory; moduleFactories[moduleId] = moduleFactoryFn; for (const otherModuleId of otherIds){ moduleFactories[otherModuleId] = moduleFactoryFn; diff --git a/turbopack/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js.map b/turbopack/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js.map index 1dbc80b964bb7..6fe835c5fba36 100644 --- a/turbopack/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js.map +++ b/turbopack/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js.map @@ -6,5 +6,5 @@ {"offset": {"line": 367, "column": 0}, "map": {"version":3,"sources":["turbopack:///[turbopack]/shared-node/base-externals-utils.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\n\n/// \n\n/// A 'base' utilities to support runtime can have externals.\n/// Currently this is for node.js / edge runtime both.\n/// If a fn requires node.js specific behavior, it should be placed in `node-external-utils` instead.\n\nasync function externalImport(id: DependencySpecifier) {\n let raw\n try {\n raw = await import(id)\n } catch (err) {\n // TODO(alexkirsz) This can happen when a client-side module tries to load\n // an external module we don't provide a shim for (e.g. querystring, url).\n // For now, we fail semi-silently, but in the future this should be a\n // compilation error.\n throw new Error(`Failed to load external module ${id}: ${err}`)\n }\n\n if (raw && raw.__esModule && raw.default && 'default' in raw.default) {\n return interopEsm(raw.default, createNS(raw), true)\n }\n\n return raw\n}\n\nfunction externalRequire(\n id: ModuleId,\n thunk: () => any,\n esm: boolean = false\n): Exports | EsmNamespaceObject {\n let raw\n try {\n raw = thunk()\n } catch (err) {\n // TODO(alexkirsz) This can happen when a client-side module tries to load\n // an external module we don't provide a shim for (e.g. querystring, url).\n // For now, we fail semi-silently, but in the future this should be a\n // compilation error.\n throw new Error(`Failed to load external module ${id}: ${err}`)\n }\n\n if (!esm || raw.__esModule) {\n return raw\n }\n\n return interopEsm(raw, createNS(raw), true)\n}\n\nexternalRequire.resolve = (\n id: string,\n options?: {\n paths?: string[]\n }\n) => {\n return require.resolve(id, options)\n}\n"],"names":[],"mappings":"AAAA,oDAAoD,GAEpD,mDAAmD;AAEnD,6DAA6D;AAC7D,sDAAsD;AACtD,qGAAqG;AAErG,eAAe,eAAe,EAAuB;IACnD,IAAI;IACJ,IAAI;QACF,MAAM,MAAM,MAAM,CAAC;IACrB,EAAE,OAAO,KAAK;QACZ,0EAA0E;QAC1E,0EAA0E;QAC1E,qEAAqE;QACrE,qBAAqB;QACrB,MAAM,IAAI,MAAM,CAAC,+BAA+B,EAAE,GAAG,EAAE,EAAE,KAAK;IAChE;IAEA,IAAI,OAAO,IAAI,UAAU,IAAI,IAAI,OAAO,IAAI,aAAa,IAAI,OAAO,EAAE;QACpE,OAAO,WAAW,IAAI,OAAO,EAAE,SAAS,MAAM;IAChD;IAEA,OAAO;AACT;AAEA,SAAS,gBACP,EAAY,EACZ,KAAgB,EAChB,MAAe,KAAK;IAEpB,IAAI;IACJ,IAAI;QACF,MAAM;IACR,EAAE,OAAO,KAAK;QACZ,0EAA0E;QAC1E,0EAA0E;QAC1E,qEAAqE;QACrE,qBAAqB;QACrB,MAAM,IAAI,MAAM,CAAC,+BAA+B,EAAE,GAAG,EAAE,EAAE,KAAK;IAChE;IAEA,IAAI,CAAC,OAAO,IAAI,UAAU,EAAE;QAC1B,OAAO;IACT;IAEA,OAAO,WAAW,KAAK,SAAS,MAAM;AACxC;AAEA,gBAAgB,OAAO,GAAG,CACxB,IACA;IAIA,OAAO,QAAQ,OAAO,CAAC,IAAI;AAC7B","ignoreList":[0]}}, {"offset": {"line": 406, "column": 0}, "map": {"version":3,"sources":["turbopack:///[turbopack]/shared-node/node-externals-utils.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\n\ndeclare var RUNTIME_PUBLIC_PATH: string\ndeclare var RELATIVE_ROOT_PATH: string\ndeclare var ASSET_PREFIX: string\n\nconst path = require('path')\n\nconst relativePathToRuntimeRoot = path.relative(RUNTIME_PUBLIC_PATH, '.')\n// Compute the relative path to the `distDir`.\nconst relativePathToDistRoot = path.join(\n relativePathToRuntimeRoot,\n RELATIVE_ROOT_PATH\n)\nconst RUNTIME_ROOT = path.resolve(__filename, relativePathToRuntimeRoot)\n// Compute the absolute path to the root, by stripping distDir from the absolute path to this file.\nconst ABSOLUTE_ROOT = path.resolve(__filename, relativePathToDistRoot)\n\n/**\n * Returns an absolute path to the given module path.\n * Module path should be relative, either path to a file or a directory.\n *\n * This fn allows to calculate an absolute path for some global static values, such as\n * `__dirname` or `import.meta.url` that Turbopack will not embeds in compile time.\n * See ImportMetaBinding::code_generation for the usage.\n */\nfunction resolveAbsolutePath(modulePath?: string): string {\n if (modulePath) {\n return path.join(ABSOLUTE_ROOT, modulePath)\n }\n return ABSOLUTE_ROOT\n}\n"],"names":[],"mappings":"AAAA,oDAAoD,GAMpD,MAAM,OAAO,QAAQ;AAErB,MAAM,4BAA4B,KAAK,QAAQ,CAAC,qBAAqB;AACrE,8CAA8C;AAC9C,MAAM,yBAAyB,KAAK,IAAI,CACtC,2BACA;AAEF,MAAM,eAAe,KAAK,OAAO,CAAC,YAAY;AAC9C,mGAAmG;AACnG,MAAM,gBAAgB,KAAK,OAAO,CAAC,YAAY;AAE/C;;;;;;;CAOC,GACD,SAAS,oBAAoB,UAAmB;IAC9C,IAAI,YAAY;QACd,OAAO,KAAK,IAAI,CAAC,eAAe;IAClC;IACA,OAAO;AACT","ignoreList":[0]}}, {"offset": {"line": 426, "column": 0}, "map": {"version":3,"sources":["turbopack:///[turbopack]/shared-node/node-wasm-utils.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\n\n/// \n\nfunction readWebAssemblyAsResponse(path: string) {\n const { createReadStream } = require('fs') as typeof import('fs')\n const { Readable } = require('stream') as typeof import('stream')\n\n const stream = createReadStream(path)\n\n // @ts-ignore unfortunately there's a slight type mismatch with the stream.\n return new Response(Readable.toWeb(stream), {\n headers: {\n 'content-type': 'application/wasm',\n },\n })\n}\n\nasync function compileWebAssemblyFromPath(\n path: string\n): Promise {\n const response = readWebAssemblyAsResponse(path)\n\n return await WebAssembly.compileStreaming(response)\n}\n\nasync function instantiateWebAssemblyFromPath(\n path: string,\n importsObj: WebAssembly.Imports\n): Promise {\n const response = readWebAssemblyAsResponse(path)\n\n const { instance } = await WebAssembly.instantiateStreaming(\n response,\n importsObj\n )\n\n return instance.exports\n}\n"],"names":[],"mappings":"AAAA,oDAAoD,GAEpD,mDAAmD;AAEnD,SAAS,0BAA0B,IAAY;IAC7C,MAAM,EAAE,gBAAgB,EAAE,GAAG,QAAQ;IACrC,MAAM,EAAE,QAAQ,EAAE,GAAG,QAAQ;IAE7B,MAAM,SAAS,iBAAiB;IAEhC,2EAA2E;IAC3E,OAAO,IAAI,SAAS,SAAS,KAAK,CAAC,SAAS;QAC1C,SAAS;YACP,gBAAgB;QAClB;IACF;AACF;AAEA,eAAe,2BACb,IAAY;IAEZ,MAAM,WAAW,0BAA0B;IAE3C,OAAO,MAAM,YAAY,gBAAgB,CAAC;AAC5C;AAEA,eAAe,+BACb,IAAY,EACZ,UAA+B;IAE/B,MAAM,WAAW,0BAA0B;IAE3C,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,YAAY,oBAAoB,CACzD,UACA;IAGF,OAAO,SAAS,OAAO;AACzB","ignoreList":[0]}}, - {"offset": {"line": 447, "column": 0}, "map": {"version":3,"sources":["turbopack:///[turbopack]/nodejs/runtime.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\n\n/// \n/// \n/// \n/// \n\nenum SourceType {\n /**\n * The module was instantiated because it was included in an evaluated chunk's\n * runtime.\n */\n Runtime = 0,\n /**\n * The module was instantiated because a parent module imported it.\n */\n Parent = 1,\n}\n\ntype SourceInfo =\n | {\n type: SourceType.Runtime\n chunkPath: ChunkPath\n }\n | {\n type: SourceType.Parent\n parentId: ModuleId\n }\n\nprocess.env.TURBOPACK = '1'\n\nfunction stringifySourceInfo(source: SourceInfo): string {\n switch (source.type) {\n case SourceType.Runtime:\n return `runtime for chunk ${source.chunkPath}`\n case SourceType.Parent:\n return `parent module ${source.parentId}`\n default:\n invariant(source, (source) => `Unknown source type: ${source?.type}`)\n }\n}\n\ntype ExternalRequire = (\n id: ModuleId,\n thunk: () => any,\n esm?: boolean\n) => Exports | EsmNamespaceObject\ntype ExternalImport = (id: ModuleId) => Promise\n\ninterface TurbopackNodeBuildContext extends TurbopackBaseContext {\n R: ResolvePathFromModule\n x: ExternalRequire\n y: ExternalImport\n}\n\ntype ModuleFactory = (\n this: Module['exports'],\n context: TurbopackNodeBuildContext\n) => unknown\n\nconst url = require('url') as typeof import('url')\nconst fs = require('fs/promises') as typeof import('fs/promises')\n\nconst moduleFactories: ModuleFactories = Object.create(null)\nconst moduleCache: ModuleCache = Object.create(null)\n\n/**\n * Returns an absolute path to the given module's id.\n */\nfunction createResolvePathFromModule(\n resolver: (moduleId: string) => Exports\n): (moduleId: string) => string {\n return function resolvePathFromModule(moduleId: string): string {\n const exported = resolver(moduleId)\n const exportedPath = exported?.default ?? exported\n if (typeof exportedPath !== 'string') {\n return exported as any\n }\n\n const strippedAssetPrefix = exportedPath.slice(ASSET_PREFIX.length)\n const resolved = path.resolve(RUNTIME_ROOT, strippedAssetPrefix)\n\n return url.pathToFileURL(resolved).href\n }\n}\n\nfunction loadChunk(chunkData: ChunkData, source?: SourceInfo): void {\n if (typeof chunkData === 'string') {\n return loadChunkPath(chunkData, source)\n } else {\n return loadChunkPath(chunkData.path, source)\n }\n}\n\nconst loadedChunks = new Set()\nconst unsupportedLoadChunk = Promise.resolve(undefined)\nconst loadedChunk = Promise.resolve(undefined)\nconst chunkCache = new Map | typeof loadedChunk>()\n\nfunction clearChunkCache() {\n chunkCache.clear()\n}\n\nfunction loadChunkPath(chunkPath: ChunkPath, source?: SourceInfo): void {\n if (!isJs(chunkPath)) {\n // We only support loading JS chunks in Node.js.\n // This branch can be hit when trying to load a CSS chunk.\n return\n }\n\n if (loadedChunks.has(chunkPath)) {\n return\n }\n\n try {\n const resolved = path.resolve(RUNTIME_ROOT, chunkPath)\n const chunkModules: CompressedModuleFactories = require(resolved)\n\n for (const [moduleId, moduleFactory] of Object.entries(chunkModules)) {\n if (!moduleFactories[moduleId]) {\n if (Array.isArray(moduleFactory)) {\n let [moduleFactoryFn, otherIds] = moduleFactory\n moduleFactories[moduleId] = moduleFactoryFn\n for (const otherModuleId of otherIds) {\n moduleFactories[otherModuleId] = moduleFactoryFn\n }\n } else {\n moduleFactories[moduleId] = moduleFactory\n }\n }\n }\n loadedChunks.add(chunkPath)\n } catch (e) {\n let errorMessage = `Failed to load chunk ${chunkPath}`\n\n if (source) {\n errorMessage += ` from ${stringifySourceInfo(source)}`\n }\n\n throw new Error(errorMessage, {\n cause: e,\n })\n }\n}\n\nasync function loadChunkAsyncUncached(\n source: SourceInfo,\n chunkPath: ChunkPath\n): Promise {\n const resolved = path.resolve(RUNTIME_ROOT, chunkPath)\n\n try {\n const contents = await fs.readFile(resolved, 'utf-8')\n\n const localRequire = (id: string) => {\n let resolvedId = require.resolve(id, { paths: [path.dirname(resolved)] })\n return require(resolvedId)\n }\n const module = {\n exports: {},\n }\n // TODO: Use vm.runInThisContext once our minimal supported Node.js version includes https://github.com/nodejs/node/pull/52153\n // eslint-disable-next-line no-eval -- Can't use vm.runInThisContext due to https://github.com/nodejs/node/issues/52102\n ;(0, eval)(\n '(function(module, exports, require, __dirname, __filename) {' +\n contents +\n '\\n})' +\n '\\n//# sourceURL=' +\n url.pathToFileURL(resolved)\n )(module, module.exports, localRequire, path.dirname(resolved), resolved)\n\n const chunkModules: CompressedModuleFactories = module.exports\n for (const [moduleId, moduleFactory] of Object.entries(chunkModules)) {\n if (!moduleFactories[moduleId]) {\n if (Array.isArray(moduleFactory)) {\n let [moduleFactoryFn, otherIds] = moduleFactory\n moduleFactories[moduleId] = moduleFactoryFn\n for (const otherModuleId of otherIds) {\n moduleFactories[otherModuleId] = moduleFactoryFn\n }\n } else {\n moduleFactories[moduleId] = moduleFactory\n }\n }\n }\n } catch (e) {\n let errorMessage = `Failed to load chunk ${chunkPath}`\n\n if (source) {\n errorMessage += ` from ${stringifySourceInfo(source)}`\n }\n\n throw new Error(errorMessage, {\n cause: e,\n })\n }\n}\n\nfunction loadChunkAsync(\n source: SourceInfo,\n chunkData: ChunkData\n): Promise {\n const chunkPath = typeof chunkData === 'string' ? chunkData : chunkData.path\n if (!isJs(chunkPath)) {\n // We only support loading JS chunks in Node.js.\n // This branch can be hit when trying to load a CSS chunk.\n return unsupportedLoadChunk\n }\n\n let entry = chunkCache.get(chunkPath)\n if (entry === undefined) {\n const resolve = chunkCache.set.bind(chunkCache, chunkPath, loadedChunk)\n // A new Promise ensures callers that don't handle rejection will still trigger one unhandled rejection.\n // Handling the rejection will not trigger unhandled rejections.\n entry = loadChunkAsyncUncached(source, chunkPath).then(resolve)\n chunkCache.set(chunkPath, entry)\n }\n // TODO: Return an instrumented Promise that React can use instead of relying on referential equality.\n return entry\n}\n\nfunction loadChunkAsyncByUrl(source: SourceInfo, chunkUrl: string) {\n const path = url.fileURLToPath(new URL(chunkUrl, RUNTIME_ROOT)) as ChunkPath\n return loadChunkAsync(source, path)\n}\n\nfunction loadWebAssembly(\n chunkPath: ChunkPath,\n _edgeModule: () => WebAssembly.Module,\n imports: WebAssembly.Imports\n) {\n const resolved = path.resolve(RUNTIME_ROOT, chunkPath)\n\n return instantiateWebAssemblyFromPath(resolved, imports)\n}\n\nfunction loadWebAssemblyModule(\n chunkPath: ChunkPath,\n _edgeModule: () => WebAssembly.Module\n) {\n const resolved = path.resolve(RUNTIME_ROOT, chunkPath)\n\n return compileWebAssemblyFromPath(resolved)\n}\n\nfunction getWorkerBlobURL(_chunks: ChunkPath[]): string {\n throw new Error('Worker blobs are not implemented yet for Node.js')\n}\n\nfunction instantiateModule(id: ModuleId, source: SourceInfo): Module {\n const moduleFactory = moduleFactories[id]\n if (typeof moduleFactory !== 'function') {\n // This can happen if modules incorrectly handle HMR disposes/updates,\n // e.g. when they keep a `setTimeout` around which still executes old code\n // and contains e.g. a `require(\"something\")` call.\n let instantiationReason\n switch (source.type) {\n case SourceType.Runtime:\n instantiationReason = `as a runtime entry of chunk ${source.chunkPath}`\n break\n case SourceType.Parent:\n instantiationReason = `because it was required from module ${source.parentId}`\n break\n default:\n invariant(source, (source) => `Unknown source type: ${source?.type}`)\n }\n throw new Error(\n `Module ${id} was instantiated ${instantiationReason}, but the module factory is not available. It might have been deleted in an HMR update.`\n )\n }\n\n const module: Module = {\n exports: {},\n error: undefined,\n loaded: false,\n id,\n namespaceObject: undefined,\n }\n moduleCache[id] = module\n\n // NOTE(alexkirsz) This can fail when the module encounters a runtime error.\n try {\n const r = commonJsRequire.bind(null, module)\n moduleFactory.call(module.exports, {\n a: asyncModule.bind(null, module),\n e: module.exports,\n r,\n t: runtimeRequire,\n x: externalRequire,\n y: externalImport,\n f: moduleContext,\n i: esmImport.bind(null, module),\n s: esmExport.bind(null, module, module.exports, moduleCache),\n j: dynamicExport.bind(null, module, module.exports, moduleCache),\n v: exportValue.bind(null, module, moduleCache),\n n: exportNamespace.bind(null, module, moduleCache),\n m: module,\n c: moduleCache,\n M: moduleFactories,\n l: loadChunkAsync.bind(null, { type: SourceType.Parent, parentId: id }),\n L: loadChunkAsyncByUrl.bind(null, {\n type: SourceType.Parent,\n parentId: id,\n }),\n C: clearChunkCache,\n w: loadWebAssembly,\n u: loadWebAssemblyModule,\n P: resolveAbsolutePath,\n U: relativeURL,\n R: createResolvePathFromModule(r),\n b: getWorkerBlobURL,\n z: requireStub,\n })\n } catch (error) {\n module.error = error as any\n throw error\n }\n\n module.loaded = true\n if (module.namespaceObject && module.exports !== module.namespaceObject) {\n // in case of a circular dependency: cjs1 -> esm2 -> cjs1\n interopEsm(module.exports, module.namespaceObject)\n }\n\n return module\n}\n\n/**\n * Retrieves a module from the cache, or instantiate it if it is not cached.\n */\n// @ts-ignore\nfunction getOrInstantiateModuleFromParent(\n id: ModuleId,\n sourceModule: Module\n): Module {\n const module = moduleCache[id]\n\n if (module) {\n return module\n }\n\n return instantiateModule(id, {\n type: SourceType.Parent,\n parentId: sourceModule.id,\n })\n}\n\n/**\n * Instantiates a runtime module.\n */\nfunction instantiateRuntimeModule(\n moduleId: ModuleId,\n chunkPath: ChunkPath\n): Module {\n return instantiateModule(moduleId, { type: SourceType.Runtime, chunkPath })\n}\n\n/**\n * Retrieves a module from the cache, or instantiate it as a runtime module if it is not cached.\n */\n// @ts-ignore TypeScript doesn't separate this module space from the browser runtime\nfunction getOrInstantiateRuntimeModule(\n moduleId: ModuleId,\n chunkPath: ChunkPath\n): Module {\n const module = moduleCache[moduleId]\n if (module) {\n if (module.error) {\n throw module.error\n }\n return module\n }\n\n return instantiateRuntimeModule(moduleId, chunkPath)\n}\n\nconst regexJsUrl = /\\.js(?:\\?[^#]*)?(?:#.*)?$/\n/**\n * Checks if a given path/URL ends with .js, optionally followed by ?query or #fragment.\n */\nfunction isJs(chunkUrlOrPath: ChunkUrl | ChunkPath): boolean {\n return regexJsUrl.test(chunkUrlOrPath)\n}\n\nmodule.exports = {\n getOrInstantiateRuntimeModule,\n loadChunk,\n}\n"],"names":[],"mappings":"AAAA,oDAAoD,GAEpD,mDAAmD;AACnD,+DAA+D;AAC/D,+DAA+D;AAC/D,0DAA0D;AAE1D,IAAA,AAAK,oCAAA;IACH;;;GAGC;IAED;;GAEC;WARE;EAAA;AAsBL,QAAQ,GAAG,CAAC,SAAS,GAAG;AAExB,SAAS,oBAAoB,MAAkB;IAC7C,OAAQ,OAAO,IAAI;QACjB;YACE,OAAO,CAAC,kBAAkB,EAAE,OAAO,SAAS,EAAE;QAChD;YACE,OAAO,CAAC,cAAc,EAAE,OAAO,QAAQ,EAAE;QAC3C;YACE,UAAU,QAAQ,CAAC,SAAW,CAAC,qBAAqB,EAAE,QAAQ,MAAM;IACxE;AACF;AAoBA,MAAM,MAAM,QAAQ;AACpB,MAAM,KAAK,QAAQ;AAEnB,MAAM,kBAAmC,OAAO,MAAM,CAAC;AACvD,MAAM,cAAmC,OAAO,MAAM,CAAC;AAEvD;;CAEC,GACD,SAAS,4BACP,QAAuC;IAEvC,OAAO,SAAS,sBAAsB,QAAgB;QACpD,MAAM,WAAW,SAAS;QAC1B,MAAM,eAAe,UAAU,WAAW;QAC1C,IAAI,OAAO,iBAAiB,UAAU;YACpC,OAAO;QACT;QAEA,MAAM,sBAAsB,aAAa,KAAK,CAAC,aAAa,MAAM;QAClE,MAAM,WAAW,KAAK,OAAO,CAAC,cAAc;QAE5C,OAAO,IAAI,aAAa,CAAC,UAAU,IAAI;IACzC;AACF;AAEA,SAAS,UAAU,SAAoB,EAAE,MAAmB;IAC1D,IAAI,OAAO,cAAc,UAAU;QACjC,OAAO,cAAc,WAAW;IAClC,OAA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AAS;IACpC,IAAI,SAAQ;QACV,IAAI,QAAO,KAAK,EAAE;YAChB,MAAM,QAAO,KAAK;QACpB;QACA,OAAO;IACT;IAEA,OAAO,yBAAyB,UAAU;AAC5C;AAEA,MAAM,aAAa;AACnB;;CAEC,GACD,SAAS,KAAK,cAAoC;IAChD,OAAO,WAAW,IAAI,CAAC;AACzB;AAEA,OAAO,OAAO,GAAG;IACf;IACA;AACF","ignoreList":[0]}}] + {"offset": {"line": 447, "column": 0}, "map": {"version":3,"sources":["turbopack:///[turbopack]/nodejs/runtime.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\n\n/// \n/// \n/// \n/// \n\nenum SourceType {\n /**\n * The module was instantiated because it was included in an evaluated chunk's\n * runtime.\n */\n Runtime = 0,\n /**\n * The module was instantiated because a parent module imported it.\n */\n Parent = 1,\n}\n\ntype SourceInfo =\n | {\n type: SourceType.Runtime\n chunkPath: ChunkPath\n }\n | {\n type: SourceType.Parent\n parentId: ModuleId\n }\n\nprocess.env.TURBOPACK = '1'\n\nfunction stringifySourceInfo(source: SourceInfo): string {\n switch (source.type) {\n case SourceType.Runtime:\n return `runtime for chunk ${source.chunkPath}`\n case SourceType.Parent:\n return `parent module ${source.parentId}`\n default:\n invariant(source, (source) => `Unknown source type: ${source?.type}`)\n }\n}\n\ntype ExternalRequire = (\n id: ModuleId,\n thunk: () => any,\n esm?: boolean\n) => Exports | EsmNamespaceObject\ntype ExternalImport = (id: ModuleId) => Promise\n\ninterface TurbopackNodeBuildContext extends TurbopackBaseContext {\n R: ResolvePathFromModule\n x: ExternalRequire\n y: ExternalImport\n}\n\ntype ModuleFactory = (\n this: Module['exports'],\n context: TurbopackNodeBuildContext\n) => unknown\n\nconst url = require('url') as typeof import('url')\nconst fs = require('fs/promises') as typeof import('fs/promises')\n\nconst moduleFactories: ModuleFactories = Object.create(null)\nconst moduleCache: ModuleCache = Object.create(null)\n\n/**\n * Returns an absolute path to the given module's id.\n */\nfunction createResolvePathFromModule(\n resolver: (moduleId: string) => Exports\n): (moduleId: string) => string {\n return function resolvePathFromModule(moduleId: string): string {\n const exported = resolver(moduleId)\n const exportedPath = exported?.default ?? exported\n if (typeof exportedPath !== 'string') {\n return exported as any\n }\n\n const strippedAssetPrefix = exportedPath.slice(ASSET_PREFIX.length)\n const resolved = path.resolve(RUNTIME_ROOT, strippedAssetPrefix)\n\n return url.pathToFileURL(resolved).href\n }\n}\n\nfunction loadChunk(chunkData: ChunkData, source?: SourceInfo): void {\n if (typeof chunkData === 'string') {\n loadChunkPath(chunkData, source)\n } else {\n loadChunkPath(chunkData.path, source)\n }\n}\n\nconst loadedChunks = new Set()\nconst unsupportedLoadChunk = Promise.resolve(undefined)\nconst loadedChunk = Promise.resolve(undefined)\nconst chunkCache = new Map | typeof loadedChunk>()\n\nfunction clearChunkCache() {\n chunkCache.clear()\n}\n\nfunction loadChunkPath(chunkPath: ChunkPath, source?: SourceInfo): void {\n if (!isJs(chunkPath)) {\n // We only support loading JS chunks in Node.js.\n // This branch can be hit when trying to load a CSS chunk.\n return\n }\n\n if (loadedChunks.has(chunkPath)) {\n return\n }\n\n try {\n const resolved = path.resolve(RUNTIME_ROOT, chunkPath)\n const chunkModules: CompressedModuleFactories = require(resolved)\n\n for (const [moduleId, moduleFactory] of Object.entries(chunkModules)) {\n if (!moduleFactories[moduleId]) {\n if (Array.isArray(moduleFactory)) {\n const [moduleFactoryFn, otherIds] = moduleFactory\n moduleFactories[moduleId] = moduleFactoryFn\n for (const otherModuleId of otherIds) {\n moduleFactories[otherModuleId] = moduleFactoryFn\n }\n } else {\n moduleFactories[moduleId] = moduleFactory\n }\n }\n }\n loadedChunks.add(chunkPath)\n } catch (e) {\n let errorMessage = `Failed to load chunk ${chunkPath}`\n\n if (source) {\n errorMessage += ` from ${stringifySourceInfo(source)}`\n }\n\n throw new Error(errorMessage, {\n cause: e,\n })\n }\n}\n\nasync function loadChunkAsyncUncached(\n source: SourceInfo,\n chunkPath: ChunkPath\n): Promise {\n const resolved = path.resolve(RUNTIME_ROOT, chunkPath)\n\n try {\n // use await to ensure that evaluation happens in another microtask\n // Because we are using a resolved absolute path require shouldn't waste time probing node_modules.\n const exports = await require(resolved)\n const chunkModules: CompressedModuleFactories = exports\n for (const [moduleId, moduleFactory] of Object.entries(chunkModules)) {\n if (!moduleFactories[moduleId]) {\n if (Array.isArray(moduleFactory)) {\n const [moduleFactoryFn, otherIds] = moduleFactory\n moduleFactories[moduleId] = moduleFactoryFn\n for (const otherModuleId of otherIds) {\n moduleFactories[otherModuleId] = moduleFactoryFn\n }\n } else {\n moduleFactories[moduleId] = moduleFactory\n }\n }\n }\n } catch (e) {\n let errorMessage = `Failed to load chunk ${chunkPath}`\n\n if (source) {\n errorMessage += ` from ${stringifySourceInfo(source)}`\n }\n\n throw new Error(errorMessage, {\n cause: e,\n })\n }\n}\n\nfunction loadChunkAsync(\n source: SourceInfo,\n chunkData: ChunkData\n): Promise {\n const chunkPath = typeof chunkData === 'string' ? chunkData : chunkData.path\n if (!isJs(chunkPath)) {\n // We only support loading JS chunks in Node.js.\n // This branch can be hit when trying to load a CSS chunk.\n return unsupportedLoadChunk\n }\n\n let entry = chunkCache.get(chunkPath)\n if (entry === undefined) {\n const resolve = chunkCache.set.bind(chunkCache, chunkPath, loadedChunk)\n // A new Promise ensures callers that don't handle rejection will still trigger one unhandled rejection.\n // Handling the rejection will not trigger unhandled rejections.\n entry = loadChunkAsyncUncached(source, chunkPath).then(resolve)\n chunkCache.set(chunkPath, entry)\n }\n // TODO: Return an instrumented Promise that React can use instead of relying on referential equality.\n return entry\n}\n\nfunction loadChunkAsyncByUrl(source: SourceInfo, chunkUrl: string) {\n const path = url.fileURLToPath(new URL(chunkUrl, RUNTIME_ROOT)) as ChunkPath\n return loadChunkAsync(source, path)\n}\n\nfunction loadWebAssembly(\n chunkPath: ChunkPath,\n _edgeModule: () => WebAssembly.Module,\n imports: WebAssembly.Imports\n) {\n const resolved = path.resolve(RUNTIME_ROOT, chunkPath)\n\n return instantiateWebAssemblyFromPath(resolved, imports)\n}\n\nfunction loadWebAssemblyModule(\n chunkPath: ChunkPath,\n _edgeModule: () => WebAssembly.Module\n) {\n const resolved = path.resolve(RUNTIME_ROOT, chunkPath)\n\n return compileWebAssemblyFromPath(resolved)\n}\n\nfunction getWorkerBlobURL(_chunks: ChunkPath[]): string {\n throw new Error('Worker blobs are not implemented yet for Node.js')\n}\n\nfunction instantiateModule(id: ModuleId, source: SourceInfo): Module {\n const moduleFactory = moduleFactories[id]\n if (typeof moduleFactory !== 'function') {\n // This can happen if modules incorrectly handle HMR disposes/updates,\n // e.g. when they keep a `setTimeout` around which still executes old code\n // and contains e.g. a `require(\"something\")` call.\n let instantiationReason\n switch (source.type) {\n case SourceType.Runtime:\n instantiationReason = `as a runtime entry of chunk ${source.chunkPath}`\n break\n case SourceType.Parent:\n instantiationReason = `because it was required from module ${source.parentId}`\n break\n default:\n invariant(source, (source) => `Unknown source type: ${source?.type}`)\n }\n throw new Error(\n `Module ${id} was instantiated ${instantiationReason}, but the module factory is not available. It might have been deleted in an HMR update.`\n )\n }\n\n const module: Module = {\n exports: {},\n error: undefined,\n loaded: false,\n id,\n namespaceObject: undefined,\n }\n moduleCache[id] = module\n\n // NOTE(alexkirsz) This can fail when the module encounters a runtime error.\n try {\n const r = commonJsRequire.bind(null, module)\n moduleFactory.call(module.exports, {\n a: asyncModule.bind(null, module),\n e: module.exports,\n r,\n t: runtimeRequire,\n x: externalRequire,\n y: externalImport,\n f: moduleContext,\n i: esmImport.bind(null, module),\n s: esmExport.bind(null, module, module.exports, moduleCache),\n j: dynamicExport.bind(null, module, module.exports, moduleCache),\n v: exportValue.bind(null, module, moduleCache),\n n: exportNamespace.bind(null, module, moduleCache),\n m: module,\n c: moduleCache,\n M: moduleFactories,\n l: loadChunkAsync.bind(null, { type: SourceType.Parent, parentId: id }),\n L: loadChunkAsyncByUrl.bind(null, {\n type: SourceType.Parent,\n parentId: id,\n }),\n C: clearChunkCache,\n w: loadWebAssembly,\n u: loadWebAssemblyModule,\n P: resolveAbsolutePath,\n U: relativeURL,\n R: createResolvePathFromModule(r),\n b: getWorkerBlobURL,\n z: requireStub,\n })\n } catch (error) {\n module.error = error as any\n throw error\n }\n\n module.loaded = true\n if (module.namespaceObject && module.exports !== module.namespaceObject) {\n // in case of a circular dependency: cjs1 -> esm2 -> cjs1\n interopEsm(module.exports, module.namespaceObject)\n }\n\n return module\n}\n\n/**\n * Retrieves a module from the cache, or instantiate it if it is not cached.\n */\n// @ts-ignore\nfunction getOrInstantiateModuleFromParent(\n id: ModuleId,\n sourceModule: Module\n): Module {\n const module = moduleCache[id]\n\n if (module) {\n return module\n }\n\n return instantiateModule(id, {\n type: SourceType.Parent,\n parentId: sourceModule.id,\n })\n}\n\n/**\n * Instantiates a runtime module.\n */\nfunction instantiateRuntimeModule(\n moduleId: ModuleId,\n chunkPath: ChunkPath\n): Module {\n return instantiateModule(moduleId, { type: SourceType.Runtime, chunkPath })\n}\n\n/**\n * Retrieves a module from the cache, or instantiate it as a runtime module if it is not cached.\n */\n// @ts-ignore TypeScript doesn't separate this module space from the browser runtime\nfunction getOrInstantiateRuntimeModule(\n moduleId: ModuleId,\n chunkPath: ChunkPath\n): Module {\n const module = moduleCache[moduleId]\n if (module) {\n if (module.error) {\n throw module.error\n }\n return module\n }\n\n return instantiateRuntimeModule(moduleId, chunkPath)\n}\n\nconst regexJsUrl = /\\.js(?:\\?[^#]*)?(?:#.*)?$/\n/**\n * Checks if a given path/URL ends with .js, optionally followed by ?query or #fragment.\n */\nfunction isJs(chunkUrlOrPath: ChunkUrl | ChunkPath): boolean {\n return regexJsUrl.test(chunkUrlOrPath)\n}\n\nmodule.exports = {\n getOrInstantiateRuntimeModule,\n loadChunk,\n}\n"],"names":[],"mappings":"AAAA,oDAAoD,GAEpD,mDAAmD;AACnD,+DAA+D;AAC/D,+DAA+D;AAC/D,0DAA0D;AAE1D,IAAA,AAAK,oCAAA;IACH;;;GAGC;IAED;;GAEC;WARE;E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AK,QAAO,eAAe,EAAE;QACvE,yDAAyD;QACzD,WAAW,QAAO,OAAO,EAAE,QAAO,eAAe;IACnD;IAEA,OAAO;AACT;AAEA;;CAEC,GACD,aAAa;AACb,SAAS,iCACP,EAAY,EACZ,YAAoB;IAEpB,MAAM,UAAS,WAAW,CAAC,GAAG;IAE9B,IAAI,SAAQ;QACV,OAAO;IACT;IAEA,OAAO,kBAAkB,IAAI;QAC3B,IAAI;QACJ,UAAU,aAAa,EAAE;IAC3B;AACF;AAEA;;CAEC,GACD,SAAS,yBACP,QAAkB,EAClB,SAAoB;IAEpB,OAAO,kBAAkB,UAAU;QAAE,IAAI;QAAsB;IAAU;AAC3E;AAEA;;CAEC,GACD,oFAAoF;AACpF,SAAS,8BACP,QAAkB,EAClB,SAAoB;IAEpB,MAAM,UAAS,WAAW,CAAC,SAAS;IACpC,IAAI,SAAQ;QACV,IAAI,QAAO,KAAK,EAAE;YAChB,MAAM,QAAO,KAAK;QACpB;QACA,OAAO;IACT;IAEA,OAAO,yBAAyB,UAAU;AAC5C;AAEA,MAAM,aAAa;AACnB;;CAEC,GACD,SAAS,KAAK,cAAoC;IAChD,OAAO,WAAW,IAAI,CAAC;AACzB;AAEA,OAAO,OAAO,GAAG;IACf;IACA;AACF","ignoreList":[0]}}] } \ No newline at end of file From 5f4bef0790669faaf3d3c781c00f2b21befb598e Mon Sep 17 00:00:00 2001 From: Luke Sandberg Date: Thu, 17 Jul 2025 10:51:35 -0700 Subject: [PATCH 3/8] update test snapshots --- .../cache-components-errors.test.ts | 42 ++++++++++--------- .../server-source-maps.test.ts | 7 ++-- .../build-output-prerender.test.ts | 9 ++-- 3 files changed, 31 insertions(+), 27 deletions(-) diff --git a/test/e2e/app-dir/cache-components-errors/cache-components-errors.test.ts b/test/e2e/app-dir/cache-components-errors/cache-components-errors.test.ts index 74cacf9621f84..935d66155d305 100644 --- a/test/e2e/app-dir/cache-components-errors/cache-components-errors.test.ts +++ b/test/e2e/app-dir/cache-components-errors/cache-components-errors.test.ts @@ -657,14 +657,16 @@ describe('Cache Components Errors', () => { } else { expect(output).toMatchInlineSnapshot(` "Error: Route "/dynamic-root": A component accessed data, headers, params, searchParams, or a short-lived cache without a Suspense boundary nor a "use cache" above it. See more info: https://nextjs.org/docs/messages/next-prerender-missing-suspense - at c (turbopack:///[project]/app/dynamic-root/indirection.tsx:9:1) + at c (turbopack:///[project]/app/dynamic-root/indirection.tsx:7:41) at main () at body () at html () - 7 | export function IndirectionTwo({ children }) { + 5 | } + 6 | + > 7 | export function IndirectionTwo({ children }) { + | ^ 8 | return children - > 9 | } - | ^ + 9 | } 10 | To get a more detailed stack trace and pinpoint the issue, try one of the following: - Start the app in development mode by running \`next dev\`, then open "/dynamic-root" in your browser to investigate the error. @@ -1680,14 +1682,14 @@ describe('Cache Components Errors', () => { } else { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-attribution/guarded-async-unguarded-clientsync" used \`new Date()\` inside a Client Component without a Suspense boundary above it. See more info here: https://nextjs.org/docs/messages/next-prerender-current-time-client - at c (turbopack:///[project]/app/sync-attribution/guarded-async-unguarded-clientsync/client.tsx:9:7) - 7 | return ( - 8 |
- > 9 |

Sync IO Access

- | ^ - 10 |

Current date and time: {data}

- 11 |
- 12 | ) + at c (turbopack:///[project]/app/sync-attribution/guarded-async-unguarded-clientsync/client.tsx:5:15) + 3 | export function SyncIO() { + 4 | // This is a sync IO access that should not cause an error + > 5 | const data = new Date().toISOString() + | ^ + 6 | + 7 | return ( + 8 |
To get a more detailed stack trace and pinpoint the issue, try one of the following: - Start the app in development mode by running \`next dev\`, then open "/sync-attribution/guarded-async-unguarded-clientsync" in your browser to investigate the error. - Rerun the production build with \`next build --debug-prerender\` to generate better stack traces. @@ -1989,14 +1991,14 @@ describe('Cache Components Errors', () => { } else { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-attribution/unguarded-async-unguarded-clientsync" used \`new Date()\` inside a Client Component without a Suspense boundary above it. See more info here: https://nextjs.org/docs/messages/next-prerender-current-time-client - at c (turbopack:///[project]/app/sync-attribution/unguarded-async-unguarded-clientsync/client.tsx:9:7) - 7 | return ( - 8 |
- > 9 |

Sync IO Access

- | ^ - 10 |

Current date and time: {data}

- 11 |
- 12 | ) + at c (turbopack:///[project]/app/sync-attribution/unguarded-async-unguarded-clientsync/client.tsx:5:15) + 3 | export function SyncIO() { + 4 | // This is a sync IO access that should not cause an error + > 5 | const data = new Date().toISOString() + | ^ + 6 | + 7 | return ( + 8 |
To get a more detailed stack trace and pinpoint the issue, try one of the following: - Start the app in development mode by running \`next dev\`, then open "/sync-attribution/unguarded-async-unguarded-clientsync" in your browser to investigate the error. - Rerun the production build with \`next build --debug-prerender\` to generate better stack traces. diff --git a/test/e2e/app-dir/server-source-maps/server-source-maps.test.ts b/test/e2e/app-dir/server-source-maps/server-source-maps.test.ts index 0e2773834e2a1..8cfa002c2ad0e 100644 --- a/test/e2e/app-dir/server-source-maps/server-source-maps.test.ts +++ b/test/e2e/app-dir/server-source-maps/server-source-maps.test.ts @@ -230,14 +230,15 @@ describe('app-dir - server source maps', () => { } } else { if (isTurbopack) { - // TODO(veil): Sourcemapping line off // TODO(veil): Sourcemap names // TODO(veil): relative paths expect(normalizeCliOutput(next.cliOutput)).toContain( - '(bundler:///app/ssr-error-log-ignore-listed/page.js:23:5)' + '(bundler:///app/ssr-error-log-ignore-listed/page.js:9:16)' ) expect(normalizeCliOutput(next.cliOutput)).toContain( - '\n> 23 | })\n | ^' + '\n' + + "> 9 | const error = new Error('ssr-error-log-ignore-listed')\n" + + ' | ^\n' ) } else { // TODO(veil): line/column numbers are flaky in Webpack diff --git a/test/production/app-dir/build-output-prerender/build-output-prerender.test.ts b/test/production/app-dir/build-output-prerender/build-output-prerender.test.ts index 50c7369827237..9af95171560ab 100644 --- a/test/production/app-dir/build-output-prerender/build-output-prerender.test.ts +++ b/test/production/app-dir/build-output-prerender/build-output-prerender.test.ts @@ -82,11 +82,12 @@ describe('build-output-prerender', () => { // TODO(veil): Why is the location incomplete unless we enable --no-mangling? expect(getPrerenderOutput(next.cliOutput)).toMatchInlineSnapshot(` "Error: Route "/client" used \`new Date()\` inside a Client Component without a Suspense boundary above it. See more info here: https://nextjs.org/docs/messages/next-prerender-current-time-client - at c (bundler:///app/client/page.tsx:5:1) + at c (turbopack:///[project]/app/client/page.tsx:4:27) + 2 | 3 | export default function Page() { - 4 | return

Current time: {new Date().toISOString()}

- > 5 | } - | ^ + > 4 | return

Current time: {new Date().toISOString()}

+ | ^ + 5 | } 6 | To get a more detailed stack trace and pinpoint the issue, try one of the following: - Start the app in development mode by running \`next dev\`, then open "/client" in your browser to investigate the error. From 86d1eb9a8c09bf66926abd94779ca221a5436363 Mon Sep 17 00:00:00 2001 From: Luke Sandberg Date: Thu, 17 Jul 2025 11:38:30 -0700 Subject: [PATCH 4/8] fix merge mistakes --- .../cache-components-errors.test.ts | 12 ++++++------ .../server-source-maps/server-source-maps.test.ts | 4 ++-- .../build-output-prerender.test.ts | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/test/e2e/app-dir/cache-components-errors/cache-components-errors.test.ts b/test/e2e/app-dir/cache-components-errors/cache-components-errors.test.ts index 935d66155d305..f697828587546 100644 --- a/test/e2e/app-dir/cache-components-errors/cache-components-errors.test.ts +++ b/test/e2e/app-dir/cache-components-errors/cache-components-errors.test.ts @@ -657,14 +657,14 @@ describe('Cache Components Errors', () => { } else { expect(output).toMatchInlineSnapshot(` "Error: Route "/dynamic-root": A component accessed data, headers, params, searchParams, or a short-lived cache without a Suspense boundary nor a "use cache" above it. See more info: https://nextjs.org/docs/messages/next-prerender-missing-suspense - at c (turbopack:///[project]/app/dynamic-root/indirection.tsx:7:41) + at c (turbopack:///[project]/app/dynamic-root/indirection.tsx:7:34) at main () at body () at html () 5 | } 6 | > 7 | export function IndirectionTwo({ children }) { - | ^ + | ^ 8 | return children 9 | } 10 | @@ -1682,11 +1682,11 @@ describe('Cache Components Errors', () => { } else { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-attribution/guarded-async-unguarded-clientsync" used \`new Date()\` inside a Client Component without a Suspense boundary above it. See more info here: https://nextjs.org/docs/messages/next-prerender-current-time-client - at c (turbopack:///[project]/app/sync-attribution/guarded-async-unguarded-clientsync/client.tsx:5:15) + at c (turbopack:///[project]/app/sync-attribution/guarded-async-unguarded-clientsync/client.tsx:5:16) 3 | export function SyncIO() { 4 | // This is a sync IO access that should not cause an error > 5 | const data = new Date().toISOString() - | ^ + | ^ 6 | 7 | return ( 8 |
@@ -1991,11 +1991,11 @@ describe('Cache Components Errors', () => { } else { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-attribution/unguarded-async-unguarded-clientsync" used \`new Date()\` inside a Client Component without a Suspense boundary above it. See more info here: https://nextjs.org/docs/messages/next-prerender-current-time-client - at c (turbopack:///[project]/app/sync-attribution/unguarded-async-unguarded-clientsync/client.tsx:5:15) + at c (turbopack:///[project]/app/sync-attribution/unguarded-async-unguarded-clientsync/client.tsx:5:16) 3 | export function SyncIO() { 4 | // This is a sync IO access that should not cause an error > 5 | const data = new Date().toISOString() - | ^ + | ^ 6 | 7 | return ( 8 |
diff --git a/test/e2e/app-dir/server-source-maps/server-source-maps.test.ts b/test/e2e/app-dir/server-source-maps/server-source-maps.test.ts index 8cfa002c2ad0e..11966499bcbaa 100644 --- a/test/e2e/app-dir/server-source-maps/server-source-maps.test.ts +++ b/test/e2e/app-dir/server-source-maps/server-source-maps.test.ts @@ -233,12 +233,12 @@ describe('app-dir - server source maps', () => { // TODO(veil): Sourcemap names // TODO(veil): relative paths expect(normalizeCliOutput(next.cliOutput)).toContain( - '(bundler:///app/ssr-error-log-ignore-listed/page.js:9:16)' + '(bundler:///app/ssr-error-log-ignore-listed/page.js:9:17)' ) expect(normalizeCliOutput(next.cliOutput)).toContain( '\n' + "> 9 | const error = new Error('ssr-error-log-ignore-listed')\n" + - ' | ^\n' + ' | ^\n' ) } else { // TODO(veil): line/column numbers are flaky in Webpack diff --git a/test/production/app-dir/build-output-prerender/build-output-prerender.test.ts b/test/production/app-dir/build-output-prerender/build-output-prerender.test.ts index 9af95171560ab..b9776f8fee6c4 100644 --- a/test/production/app-dir/build-output-prerender/build-output-prerender.test.ts +++ b/test/production/app-dir/build-output-prerender/build-output-prerender.test.ts @@ -82,11 +82,11 @@ describe('build-output-prerender', () => { // TODO(veil): Why is the location incomplete unless we enable --no-mangling? expect(getPrerenderOutput(next.cliOutput)).toMatchInlineSnapshot(` "Error: Route "/client" used \`new Date()\` inside a Client Component without a Suspense boundary above it. See more info here: https://nextjs.org/docs/messages/next-prerender-current-time-client - at c (turbopack:///[project]/app/client/page.tsx:4:27) + at c (bundler:///app/client/page.tsx:4:28) 2 | 3 | export default function Page() { > 4 | return

Current time: {new Date().toISOString()}

- | ^ + | ^ 5 | } 6 | To get a more detailed stack trace and pinpoint the issue, try one of the following: From b429008f1727f58fe8fd210576eb92f2b8ef30a0 Mon Sep 17 00:00:00 2001 From: Luke Sandberg Date: Thu, 17 Jul 2025 14:55:08 -0700 Subject: [PATCH 5/8] Make loadChunkAsync load chunks synchronously We still return a promise to satisfy our call signatures but resolution is now synchronously performed by `require` --- .../js/src/nodejs/runtime.ts | 68 +++++++++---------- 1 file changed, 32 insertions(+), 36 deletions(-) diff --git a/turbopack/crates/turbopack-ecmascript-runtime/js/src/nodejs/runtime.ts b/turbopack/crates/turbopack-ecmascript-runtime/js/src/nodejs/runtime.ts index 5ab4457c75ce0..12a94c3e95bed 100644 --- a/turbopack/crates/turbopack-ecmascript-runtime/js/src/nodejs/runtime.ts +++ b/turbopack/crates/turbopack-ecmascript-runtime/js/src/nodejs/runtime.ts @@ -94,8 +94,8 @@ function loadChunk(chunkData: ChunkData, source?: SourceInfo): void { const loadedChunks = new Set() const unsupportedLoadChunk = Promise.resolve(undefined) -const loadedChunk = Promise.resolve(undefined) -const chunkCache = new Map | typeof loadedChunk>() +const loadedChunk: Promise = Promise.resolve(undefined) +const chunkCache = new Map>() function clearChunkCache() { chunkCache.clear() @@ -143,47 +143,30 @@ function loadChunkPath(chunkPath: ChunkPath, source?: SourceInfo): void { } } -async function loadChunkAsyncUncached( - source: SourceInfo, - chunkPath: ChunkPath -): Promise { +function loadChunkUncached(chunkPath: ChunkPath) { + // resolve to an absolute path to simplify `require` handling const resolved = path.resolve(RUNTIME_ROOT, chunkPath) - try { - // use await to ensure that evaluation happens in another microtask - // Because we are using a resolved absolute path require shouldn't waste time probing node_modules. - const exports = await require(resolved) - const chunkModules: CompressedModuleFactories = exports - for (const [moduleId, moduleFactory] of Object.entries(chunkModules)) { - if (!moduleFactories[moduleId]) { - if (Array.isArray(moduleFactory)) { - const [moduleFactoryFn, otherIds] = moduleFactory - moduleFactories[moduleId] = moduleFactoryFn - for (const otherModuleId of otherIds) { - moduleFactories[otherModuleId] = moduleFactoryFn - } - } else { - moduleFactories[moduleId] = moduleFactory + const chunkModules: CompressedModuleFactories = require(resolved) + for (const [moduleId, moduleFactory] of Object.entries(chunkModules)) { + if (!moduleFactories[moduleId]) { + if (Array.isArray(moduleFactory)) { + const [moduleFactoryFn, otherIds] = moduleFactory + moduleFactories[moduleId] = moduleFactoryFn + for (const otherModuleId of otherIds) { + moduleFactories[otherModuleId] = moduleFactoryFn } + } else { + moduleFactories[moduleId] = moduleFactory } } - } catch (e) { - let errorMessage = `Failed to load chunk ${chunkPath}` - - if (source) { - errorMessage += ` from ${stringifySourceInfo(source)}` - } - - throw new Error(errorMessage, { - cause: e, - }) } } function loadChunkAsync( source: SourceInfo, chunkData: ChunkData -): Promise { +): Promise { const chunkPath = typeof chunkData === 'string' ? chunkData : chunkData.path if (!isJs(chunkPath)) { // We only support loading JS chunks in Node.js. @@ -193,10 +176,23 @@ function loadChunkAsync( let entry = chunkCache.get(chunkPath) if (entry === undefined) { - const resolve = chunkCache.set.bind(chunkCache, chunkPath, loadedChunk) - // A new Promise ensures callers that don't handle rejection will still trigger one unhandled rejection. - // Handling the rejection will not trigger unhandled rejections. - entry = loadChunkAsyncUncached(source, chunkPath).then(resolve) + try { + // Load the chunk synchronously + loadChunkUncached(chunkPath) + entry = loadedChunk + } catch (e) { + let errorMessage = `Failed to load chunk ${chunkPath}` + if (source) { + errorMessage += ` from ${stringifySourceInfo(source)}` + } + + // Cache the failure promise, future requests will also get this same rejection + entry = Promise.reject( + new Error(errorMessage, { + cause: e, + }) + ) + } chunkCache.set(chunkPath, entry) } // TODO: Return an instrumented Promise that React can use instead of relying on referential equality. From b563eef06c9d793ab11b19a140f1d632dbeeaf7d Mon Sep 17 00:00:00 2001 From: Luke Sandberg Date: Thu, 17 Jul 2025 16:50:38 -0700 Subject: [PATCH 6/8] touch runtime-> update snapshot --- .../output/[turbopack]_runtime.js | 54 +++++++++---------- .../output/[turbopack]_runtime.js.map | 2 +- 2 files changed, 27 insertions(+), 29 deletions(-) diff --git a/turbopack/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js b/turbopack/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js index 3b2be8c7e0afa..a62bb338e4d5a 100644 --- a/turbopack/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js +++ b/turbopack/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js @@ -538,34 +538,22 @@ function loadChunkPath(chunkPath, source) { }); } } -async function loadChunkAsyncUncached(source, chunkPath) { +function loadChunkUncached(chunkPath) { + // resolve to an absolute path to simplify `require` handling const resolved = path.resolve(RUNTIME_ROOT, chunkPath); - try { - // use await to ensure that evaluation happens in another microtask - // Because we are using a resolved absolute path require shouldn't waste time probing node_modules. - const exports = await require(resolved); - const chunkModules = exports; - for (const [moduleId, moduleFactory] of Object.entries(chunkModules)){ - if (!moduleFactories[moduleId]) { - if (Array.isArray(moduleFactory)) { - const [moduleFactoryFn, otherIds] = moduleFactory; - moduleFactories[moduleId] = moduleFactoryFn; - for (const otherModuleId of otherIds){ - moduleFactories[otherModuleId] = moduleFactoryFn; - } - } else { - moduleFactories[moduleId] = moduleFactory; + const chunkModules = require(resolved); + for (const [moduleId, moduleFactory] of Object.entries(chunkModules)){ + if (!moduleFactories[moduleId]) { + if (Array.isArray(moduleFactory)) { + const [moduleFactoryFn, otherIds] = moduleFactory; + moduleFactories[moduleId] = moduleFactoryFn; + for (const otherModuleId of otherIds){ + moduleFactories[otherModuleId] = moduleFactoryFn; } + } else { + moduleFactories[moduleId] = moduleFactory; } } - } catch (e) { - let errorMessage = `Failed to load chunk ${chunkPath}`; - if (source) { - errorMessage += ` from ${stringifySourceInfo(source)}`; - } - throw new Error(errorMessage, { - cause: e - }); } } function loadChunkAsync(source, chunkData) { @@ -577,10 +565,20 @@ function loadChunkAsync(source, chunkData) { } let entry = chunkCache.get(chunkPath); if (entry === undefined) { - const resolve = chunkCache.set.bind(chunkCache, chunkPath, loadedChunk); - // A new Promise ensures callers that don't handle rejection will still trigger one unhandled rejection. - // Handling the rejection will not trigger unhandled rejections. - entry = loadChunkAsyncUncached(source, chunkPath).then(resolve); + try { + // Load the chunk synchronously + loadChunkUncached(chunkPath); + entry = loadedChunk; + } catch (e) { + let errorMessage = `Failed to load chunk ${chunkPath}`; + if (source) { + errorMessage += ` from ${stringifySourceInfo(source)}`; + } + // Cache the failure promise, future requests will also get this same rejection + entry = Promise.reject(new Error(errorMessage, { + cause: e + })); + } chunkCache.set(chunkPath, entry); } // TODO: Return an instrumented Promise that React can use instead of relying on referential equality. diff --git a/turbopack/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js.map b/turbopack/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js.map index 6fe835c5fba36..bf1177c6e777f 100644 --- a/turbopack/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js.map +++ b/turbopack/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js.map @@ -6,5 +6,5 @@ {"offset": {"line": 367, "column": 0}, "map": {"version":3,"sources":["turbopack:///[turbopack]/shared-node/base-externals-utils.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\n\n/// \n\n/// A 'base' utilities to support runtime can have externals.\n/// Currently this is for node.js / edge runtime both.\n/// If a fn requires node.js specific behavior, it should be placed in `node-external-utils` instead.\n\nasync function externalImport(id: DependencySpecifier) {\n let raw\n try {\n raw = await import(id)\n } catch (err) {\n // TODO(alexkirsz) This can happen when a client-side module tries to load\n // an external module we don't provide a shim for (e.g. querystring, url).\n // For now, we fail semi-silently, but in the future this should be a\n // compilation error.\n throw new Error(`Failed to load external module ${id}: ${err}`)\n }\n\n if (raw && raw.__esModule && raw.default && 'default' in raw.default) {\n return interopEsm(raw.default, createNS(raw), true)\n }\n\n return raw\n}\n\nfunction externalRequire(\n id: ModuleId,\n thunk: () => any,\n esm: boolean = false\n): Exports | EsmNamespaceObject {\n let raw\n try {\n raw = thunk()\n } catch (err) {\n // TODO(alexkirsz) This can happen when a client-side module tries to load\n // an external module we don't provide a shim for (e.g. querystring, url).\n // For now, we fail semi-silently, but in the future this should be a\n // compilation error.\n throw new Error(`Failed to load external module ${id}: ${err}`)\n }\n\n if (!esm || raw.__esModule) {\n return raw\n }\n\n return interopEsm(raw, createNS(raw), true)\n}\n\nexternalRequire.resolve = (\n id: string,\n options?: {\n paths?: string[]\n }\n) => {\n return require.resolve(id, options)\n}\n"],"names":[],"mappings":"AAAA,oDAAoD,GAEpD,mDAAmD;AAEnD,6DAA6D;AAC7D,sDAAsD;AACtD,qGAAqG;AAErG,eAAe,eAAe,EAAuB;IACnD,IAAI;IACJ,IAAI;QACF,MAAM,MAAM,MAAM,CAAC;IACrB,EAAE,OAAO,KAAK;QACZ,0EAA0E;QAC1E,0EAA0E;QAC1E,qEAAqE;QACrE,qBAAqB;QACrB,MAAM,IAAI,MAAM,CAAC,+BAA+B,EAAE,GAAG,EAAE,EAAE,KAAK;IAChE;IAEA,IAAI,OAAO,IAAI,UAAU,IAAI,IAAI,OAAO,IAAI,aAAa,IAAI,OAAO,EAAE;QACpE,OAAO,WAAW,IAAI,OAAO,EAAE,SAAS,MAAM;IAChD;IAEA,OAAO;AACT;AAEA,SAAS,gBACP,EAAY,EACZ,KAAgB,EAChB,MAAe,KAAK;IAEpB,IAAI;IACJ,IAAI;QACF,MAAM;IACR,EAAE,OAAO,KAAK;QACZ,0EAA0E;QAC1E,0EAA0E;QAC1E,qEAAqE;QACrE,qBAAqB;QACrB,MAAM,IAAI,MAAM,CAAC,+BAA+B,EAAE,GAAG,EAAE,EAAE,KAAK;IAChE;IAEA,IAAI,CAAC,OAAO,IAAI,UAAU,EAAE;QAC1B,OAAO;IACT;IAEA,OAAO,WAAW,KAAK,SAAS,MAAM;AACxC;AAEA,gBAAgB,OAAO,GAAG,CACxB,IACA;IAIA,OAAO,QAAQ,OAAO,CAAC,IAAI;AAC7B","ignoreList":[0]}}, {"offset": {"line": 406, "column": 0}, "map": {"version":3,"sources":["turbopack:///[turbopack]/shared-node/node-externals-utils.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\n\ndeclare var RUNTIME_PUBLIC_PATH: string\ndeclare var RELATIVE_ROOT_PATH: string\ndeclare var ASSET_PREFIX: string\n\nconst path = require('path')\n\nconst relativePathToRuntimeRoot = path.relative(RUNTIME_PUBLIC_PATH, '.')\n// Compute the relative path to the `distDir`.\nconst relativePathToDistRoot = path.join(\n relativePathToRuntimeRoot,\n RELATIVE_ROOT_PATH\n)\nconst RUNTIME_ROOT = path.resolve(__filename, relativePathToRuntimeRoot)\n// Compute the absolute path to the root, by stripping distDir from the absolute path to this file.\nconst ABSOLUTE_ROOT = path.resolve(__filename, relativePathToDistRoot)\n\n/**\n * Returns an absolute path to the given module path.\n * Module path should be relative, either path to a file or a directory.\n *\n * This fn allows to calculate an absolute path for some global static values, such as\n * `__dirname` or `import.meta.url` that Turbopack will not embeds in compile time.\n * See ImportMetaBinding::code_generation for the usage.\n */\nfunction resolveAbsolutePath(modulePath?: string): string {\n if (modulePath) {\n return path.join(ABSOLUTE_ROOT, modulePath)\n }\n return ABSOLUTE_ROOT\n}\n"],"names":[],"mappings":"AAAA,oDAAoD,GAMpD,MAAM,OAAO,QAAQ;AAErB,MAAM,4BAA4B,KAAK,QAAQ,CAAC,qBAAqB;AACrE,8CAA8C;AAC9C,MAAM,yBAAyB,KAAK,IAAI,CACtC,2BACA;AAEF,MAAM,eAAe,KAAK,OAAO,CAAC,YAAY;AAC9C,mGAAmG;AACnG,MAAM,gBAAgB,KAAK,OAAO,CAAC,YAAY;AAE/C;;;;;;;CAOC,GACD,SAAS,oBAAoB,UAAmB;IAC9C,IAAI,YAAY;QACd,OAAO,KAAK,IAAI,CAAC,eAAe;IAClC;IACA,OAAO;AACT","ignoreList":[0]}}, {"offset": {"line": 426, "column": 0}, "map": {"version":3,"sources":["turbopack:///[turbopack]/shared-node/node-wasm-utils.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\n\n/// \n\nfunction readWebAssemblyAsResponse(path: string) {\n const { createReadStream } = require('fs') as typeof import('fs')\n const { Readable } = require('stream') as typeof import('stream')\n\n const stream = createReadStream(path)\n\n // @ts-ignore unfortunately there's a slight type mismatch with the stream.\n return new Response(Readable.toWeb(stream), {\n headers: {\n 'content-type': 'application/wasm',\n },\n })\n}\n\nasync function compileWebAssemblyFromPath(\n path: string\n): Promise {\n const response = readWebAssemblyAsResponse(path)\n\n return await WebAssembly.compileStreaming(response)\n}\n\nasync function instantiateWebAssemblyFromPath(\n path: string,\n importsObj: WebAssembly.Imports\n): Promise {\n const response = readWebAssemblyAsResponse(path)\n\n const { instance } = await WebAssembly.instantiateStreaming(\n response,\n importsObj\n )\n\n return instance.exports\n}\n"],"names":[],"mappings":"AAAA,oDAAoD,GAEpD,mDAAmD;AAEnD,SAAS,0BAA0B,IAAY;IAC7C,MAAM,EAAE,gBAAgB,EAAE,GAAG,QAAQ;IACrC,MAAM,EAAE,QAAQ,EAAE,GAAG,QAAQ;IAE7B,MAAM,SAAS,iBAAiB;IAEhC,2EAA2E;IAC3E,OAAO,IAAI,SAAS,SAAS,KAAK,CAAC,SAAS;QAC1C,SAAS;YACP,gBAAgB;QAClB;IACF;AACF;AAEA,eAAe,2BACb,IAAY;IAEZ,MAAM,WAAW,0BAA0B;IAE3C,OAAO,MAAM,YAAY,gBAAgB,CAAC;AAC5C;AAEA,eAAe,+BACb,IAAY,EACZ,UAA+B;IAE/B,MAAM,WAAW,0BAA0B;IAE3C,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,YAAY,oBAAoB,CACzD,UACA;IAGF,OAAO,SAAS,OAAO;AACzB","ignoreList":[0]}}, - {"offset": {"line": 447, "column": 0}, "map": {"version":3,"sources":["turbopack:///[turbopack]/nodejs/runtime.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\n\n/// \n/// \n/// \n/// \n\nenum SourceType {\n /**\n * The module was instantiated because it was included in an evaluated chunk's\n * runtime.\n */\n Runtime = 0,\n /**\n * The module was instantiated because a parent module imported it.\n */\n Parent = 1,\n}\n\ntype SourceInfo =\n | {\n type: SourceType.Runtime\n chunkPath: ChunkPath\n }\n | {\n type: SourceType.Parent\n parentId: ModuleId\n }\n\nprocess.env.TURBOPACK = '1'\n\nfunction stringifySourceInfo(source: SourceInfo): string {\n switch (source.type) {\n case SourceType.Runtime:\n return `runtime for chunk ${source.chunkPath}`\n case SourceType.Parent:\n return `parent module ${source.parentId}`\n default:\n invariant(source, (source) => `Unknown source type: ${source?.type}`)\n }\n}\n\ntype ExternalRequire = (\n id: ModuleId,\n thunk: () => any,\n esm?: boolean\n) => Exports | EsmNamespaceObject\ntype ExternalImport = (id: ModuleId) => Promise\n\ninterface TurbopackNodeBuildContext extends TurbopackBaseContext {\n R: ResolvePathFromModule\n x: ExternalRequire\n y: ExternalImport\n}\n\ntype ModuleFactory = (\n this: Module['exports'],\n context: TurbopackNodeBuildContext\n) => unknown\n\nconst url = require('url') as typeof import('url')\nconst fs = require('fs/promises') as typeof import('fs/promises')\n\nconst moduleFactories: ModuleFactories = Object.create(null)\nconst moduleCache: ModuleCache = Object.create(null)\n\n/**\n * Returns an absolute path to the given module's id.\n */\nfunction createResolvePathFromModule(\n resolver: (moduleId: string) => Exports\n): (moduleId: string) => string {\n return function resolvePathFromModule(moduleId: string): string {\n const exported = resolver(moduleId)\n const exportedPath = exported?.default ?? exported\n if (typeof exportedPath !== 'string') {\n return exported as any\n }\n\n const strippedAssetPrefix = exportedPath.slice(ASSET_PREFIX.length)\n const resolved = path.resolve(RUNTIME_ROOT, strippedAssetPrefix)\n\n return url.pathToFileURL(resolved).href\n }\n}\n\nfunction loadChunk(chunkData: ChunkData, source?: SourceInfo): void {\n if (typeof chunkData === 'string') {\n loadChunkPath(chunkData, source)\n } else {\n loadChunkPath(chunkData.path, source)\n }\n}\n\nconst loadedChunks = new Set()\nconst unsupportedLoadChunk = Promise.resolve(undefined)\nconst loadedChunk = Promise.resolve(undefined)\nconst chunkCache = new Map | typeof loadedChunk>()\n\nfunction clearChunkCache() {\n chunkCache.clear()\n}\n\nfunction loadChunkPath(chunkPath: ChunkPath, source?: SourceInfo): void {\n if (!isJs(chunkPath)) {\n // We only support loading JS chunks in Node.js.\n // This branch can be hit when trying to load a CSS chunk.\n return\n }\n\n if (loadedChunks.has(chunkPath)) {\n return\n }\n\n try {\n const resolved = path.resolve(RUNTIME_ROOT, chunkPath)\n const chunkModules: CompressedModuleFactories = require(resolved)\n\n for (const [moduleId, moduleFactory] of Object.entries(chunkModules)) {\n if (!moduleFactories[moduleId]) {\n if (Array.isArray(moduleFactory)) {\n const [moduleFactoryFn, otherIds] = moduleFactory\n moduleFactories[moduleId] = moduleFactoryFn\n for (const otherModuleId of otherIds) {\n moduleFactories[otherModuleId] = moduleFactoryFn\n }\n } else {\n moduleFactories[moduleId] = moduleFactory\n }\n }\n }\n loadedChunks.add(chunkPath)\n } catch (e) {\n let errorMessage = `Failed to load chunk ${chunkPath}`\n\n if (source) {\n errorMessage += ` from ${stringifySourceInfo(source)}`\n }\n\n throw new Error(errorMessage, {\n cause: e,\n })\n }\n}\n\nasync function loadChunkAsyncUncached(\n source: SourceInfo,\n chunkPath: ChunkPath\n): Promise {\n const resolved = path.resolve(RUNTIME_ROOT, chunkPath)\n\n try {\n // use await to ensure that evaluation happens in another microtask\n // Because we are using a resolved absolute path require shouldn't waste time probing node_modules.\n const exports = await require(resolved)\n const chunkModules: CompressedModuleFactories = exports\n for (const [moduleId, moduleFactory] of Object.entries(chunkModules)) {\n if (!moduleFactories[moduleId]) {\n if (Array.isArray(moduleFactory)) {\n const [moduleFactoryFn, otherIds] = moduleFactory\n moduleFactories[moduleId] = moduleFactoryFn\n for (const otherModuleId of otherIds) {\n moduleFactories[otherModuleId] = moduleFactoryFn\n }\n } else {\n moduleFactories[moduleId] = moduleFactory\n }\n }\n }\n } catch (e) {\n let errorMessage = `Failed to load chunk ${chunkPath}`\n\n if (source) {\n errorMessage += ` from ${stringifySourceInfo(source)}`\n }\n\n throw new Error(errorMessage, {\n cause: e,\n })\n }\n}\n\nfunction loadChunkAsync(\n source: SourceInfo,\n chunkData: ChunkData\n): Promise {\n const chunkPath = typeof chunkData === 'string' ? chunkData : chunkData.path\n if (!isJs(chunkPath)) {\n // We only support loading JS chunks in Node.js.\n // This branch can be hit when trying to load a CSS chunk.\n return unsupportedLoadChunk\n }\n\n let entry = chunkCache.get(chunkPath)\n if (entry === undefined) {\n const resolve = chunkCache.set.bind(chunkCache, chunkPath, loadedChunk)\n // A new Promise ensures callers that don't handle rejection will still trigger one unhandled rejection.\n // Handling the rejection will not trigger unhandled rejections.\n entry = loadChunkAsyncUncached(source, chunkPath).then(resolve)\n chunkCache.set(chunkPath, entry)\n }\n // TODO: Return an instrumented Promise that React can use instead of relying on referential equality.\n return entry\n}\n\nfunction loadChunkAsyncByUrl(source: SourceInfo, chunkUrl: string) {\n const path = url.fileURLToPath(new URL(chunkUrl, RUNTIME_ROOT)) as ChunkPath\n return loadChunkAsync(source, path)\n}\n\nfunction loadWebAssembly(\n chunkPath: ChunkPath,\n _edgeModule: () => WebAssembly.Module,\n imports: WebAssembly.Imports\n) {\n const resolved = path.resolve(RUNTIME_ROOT, chunkPath)\n\n return instantiateWebAssemblyFromPath(resolved, imports)\n}\n\nfunction loadWebAssemblyModule(\n chunkPath: ChunkPath,\n _edgeModule: () => WebAssembly.Module\n) {\n const resolved = path.resolve(RUNTIME_ROOT, chunkPath)\n\n return compileWebAssemblyFromPath(resolved)\n}\n\nfunction getWorkerBlobURL(_chunks: ChunkPath[]): string {\n throw new Error('Worker blobs are not implemented yet for Node.js')\n}\n\nfunction instantiateModule(id: ModuleId, source: SourceInfo): Module {\n const moduleFactory = moduleFactories[id]\n if (typeof moduleFactory !== 'function') {\n // This can happen if modules incorrectly handle HMR disposes/updates,\n // e.g. when they keep a `setTimeout` around which still executes old code\n // and contains e.g. a `require(\"something\")` call.\n let instantiationReason\n switch (source.type) {\n case SourceType.Runtime:\n instantiationReason = `as a runtime entry of chunk ${source.chunkPath}`\n break\n case SourceType.Parent:\n instantiationReason = `because it was required from module ${source.parentId}`\n break\n default:\n invariant(source, (source) => `Unknown source type: ${source?.type}`)\n }\n throw new Error(\n `Module ${id} was instantiated ${instantiationReason}, but the module factory is not available. It might have been deleted in an HMR update.`\n )\n }\n\n const module: Module = {\n exports: {},\n error: undefined,\n loaded: false,\n id,\n namespaceObject: undefined,\n }\n moduleCache[id] = module\n\n // NOTE(alexkirsz) This can fail when the module encounters a runtime error.\n try {\n const r = commonJsRequire.bind(null, module)\n moduleFactory.call(module.exports, {\n a: asyncModule.bind(null, module),\n e: module.exports,\n r,\n t: runtimeRequire,\n x: externalRequire,\n y: externalImport,\n f: moduleContext,\n i: esmImport.bind(null, module),\n s: esmExport.bind(null, module, module.exports, moduleCache),\n j: dynamicExport.bind(null, module, module.exports, moduleCache),\n v: exportValue.bind(null, module, moduleCache),\n n: exportNamespace.bind(null, module, moduleCache),\n m: module,\n c: moduleCache,\n M: moduleFactories,\n l: loadChunkAsync.bind(null, { type: SourceType.Parent, parentId: id }),\n L: loadChunkAsyncByUrl.bind(null, {\n type: SourceType.Parent,\n parentId: id,\n }),\n C: clearChunkCache,\n w: loadWebAssembly,\n u: loadWebAssemblyModule,\n P: resolveAbsolutePath,\n U: relativeURL,\n R: createResolvePathFromModule(r),\n b: getWorkerBlobURL,\n z: requireStub,\n })\n } catch (error) {\n module.error = error as any\n throw error\n }\n\n module.loaded = true\n if (module.namespaceObject && module.exports !== module.namespaceObject) {\n // in case of a circular dependency: cjs1 -> esm2 -> cjs1\n interopEsm(module.exports, module.namespaceObject)\n }\n\n return module\n}\n\n/**\n * Retrieves a module from the cache, or instantiate it if it is not cached.\n */\n// @ts-ignore\nfunction getOrInstantiateModuleFromParent(\n id: ModuleId,\n sourceModule: Module\n): Module {\n const module = moduleCache[id]\n\n if (module) {\n return module\n }\n\n return instantiateModule(id, {\n type: SourceType.Parent,\n parentId: sourceModule.id,\n })\n}\n\n/**\n * Instantiates a runtime module.\n */\nfunction instantiateRuntimeModule(\n moduleId: ModuleId,\n chunkPath: ChunkPath\n): Module {\n return instantiateModule(moduleId, { type: SourceType.Runtime, chunkPath })\n}\n\n/**\n * Retrieves a module from the cache, or instantiate it as a runtime module if it is not cached.\n */\n// @ts-ignore TypeScript doesn't separate this module space from the browser runtime\nfunction getOrInstantiateRuntimeModule(\n moduleId: ModuleId,\n chunkPath: ChunkPath\n): Module {\n const module = moduleCache[moduleId]\n if (module) {\n if (module.error) {\n throw module.error\n }\n return module\n }\n\n return instantiateRuntimeModule(moduleId, chunkPath)\n}\n\nconst regexJsUrl = /\\.js(?:\\?[^#]*)?(?:#.*)?$/\n/**\n * Checks if a given path/URL ends with .js, optionally followed by ?query or #fragment.\n */\nfunction isJs(chunkUrlOrPath: ChunkUrl | ChunkPath): boolean {\n return regexJsUrl.test(chunkUrlOrPath)\n}\n\nmodule.exports = {\n getOrInstantiateRuntimeModule,\n loadChunk,\n}\n"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G;YACH,GAAG;QACL;IACF,EAAE,OAAO,OAAO;QACd,QAAO,KAAK,GAAG;QACf,MAAM;IACR;IAEA,QAAO,MAAM,GAAG;IAChB,IAAI,QAAO,eAAe,IAAI,QAAO,OAAO,KAAK,QAAO,eAAe,EAAE;QACvE,yDAAyD;QACzD,WAAW,QAAO,OAAO,EAAE,QAAO,eAAe;IACnD;IAEA,OAAO;AACT;AAEA;;CAEC,GACD,aAAa;AACb,SAAS,iCACP,EAAY,EACZ,YAAoB;IAEpB,MAAM,UAAS,WAAW,CAAC,GAAG;IAE9B,IAAI,SAAQ;QACV,OAAO;IACT;IAEA,OAAO,kBAAkB,IAAI;QAC3B,IAAI;QACJ,UAAU,aAAa,EAAE;IAC3B;AACF;AAEA;;CAEC,GACD,SAAS,yBACP,QAAkB,EAClB,SAAoB;IAEpB,OAAO,kBAAkB,UAAU;QAAE,IAAI;QAAsB;IAAU;AAC3E;AAEA;;CAEC,GACD,oFAAoF;AACpF,SAAS,8BACP,QAAkB,EAClB,SAAoB;IAEpB,MAAM,UAAS,WAAW,CAAC,SAAS;IACpC,IAAI,SAAQ;QACV,IAAI,QAAO,KAAK,EAAE;YAChB,MAAM,QAAO,KAAK;QACpB;QACA,OAAO;IACT;IAEA,OAAO,yBAAyB,UAAU;AAC5C;AAEA,MAAM,aAAa;AACnB;;CAEC,GACD,SAAS,KAAK,cAAoC;IAChD,OAAO,WAAW,IAAI,CAAC;AACzB;AAEA,OAAO,OAAO,GAAG;IACf;IACA;AACF","ignoreList":[0]}}] + {"offset": {"line": 447, "column": 0}, "map": {"version":3,"sources":["turbopack:///[turbopack]/nodejs/runtime.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\n\n/// \n/// \n/// \n/// \n\nenum SourceType {\n /**\n * The module was instantiated because it was included in an evaluated chunk's\n * runtime.\n */\n Runtime = 0,\n /**\n * The module was instantiated because a parent module imported it.\n */\n Parent = 1,\n}\n\ntype SourceInfo =\n | {\n type: SourceType.Runtime\n chunkPath: ChunkPath\n }\n | {\n type: SourceType.Parent\n parentId: ModuleId\n }\n\nprocess.env.TURBOPACK = '1'\n\nfunction stringifySourceInfo(source: SourceInfo): string {\n switch (source.type) {\n case SourceType.Runtime:\n return `runtime for chunk ${source.chunkPath}`\n case SourceType.Parent:\n return `parent module ${source.parentId}`\n default:\n invariant(source, (source) => `Unknown source type: ${source?.type}`)\n }\n}\n\ntype ExternalRequire = (\n id: ModuleId,\n thunk: () => any,\n esm?: boolean\n) => Exports | EsmNamespaceObject\ntype ExternalImport = (id: ModuleId) => Promise\n\ninterface TurbopackNodeBuildContext extends TurbopackBaseContext {\n R: ResolvePathFromModule\n x: ExternalRequire\n y: ExternalImport\n}\n\ntype ModuleFactory = (\n this: Module['exports'],\n context: TurbopackNodeBuildContext\n) => unknown\n\nconst url = require('url') as typeof import('url')\nconst fs = require('fs/promises') as typeof import('fs/promises')\n\nconst moduleFactories: ModuleFactories = Object.create(null)\nconst moduleCache: ModuleCache = Object.create(null)\n\n/**\n * Returns an absolute path to the given module's id.\n */\nfunction createResolvePathFromModule(\n resolver: (moduleId: string) => Exports\n): (moduleId: string) => string {\n return function resolvePathFromModule(moduleId: string): string {\n const exported = resolver(moduleId)\n const exportedPath = exported?.default ?? exported\n if (typeof exportedPath !== 'string') {\n return exported as any\n }\n\n const strippedAssetPrefix = exportedPath.slice(ASSET_PREFIX.length)\n const resolved = path.resolve(RUNTIME_ROOT, strippedAssetPrefix)\n\n return url.pathToFileURL(resolved).href\n }\n}\n\nfunction loadChunk(chunkData: ChunkData, source?: SourceInfo): void {\n if (typeof chunkData === 'string') {\n loadChunkPath(chunkData, source)\n } else {\n loadChunkPath(chunkData.path, source)\n }\n}\n\nconst loadedChunks = new Set()\nconst unsupportedLoadChunk = Promise.resolve(undefined)\nconst loadedChunk: Promise = Promise.resolve(undefined)\nconst chunkCache = new Map>()\n\nfunction clearChunkCache() {\n chunkCache.clear()\n}\n\nfunction loadChunkPath(chunkPath: ChunkPath, source?: SourceInfo): void {\n if (!isJs(chunkPath)) {\n // We only support loading JS chunks in Node.js.\n // This branch can be hit when trying to load a CSS chunk.\n return\n }\n\n if (loadedChunks.has(chunkPath)) {\n return\n }\n\n try {\n const resolved = path.resolve(RUNTIME_ROOT, chunkPath)\n const chunkModules: CompressedModuleFactories = require(resolved)\n\n for (const [moduleId, moduleFactory] of Object.entries(chunkModules)) {\n if (!moduleFactories[moduleId]) {\n if (Array.isArray(moduleFactory)) {\n const [moduleFactoryFn, otherIds] = moduleFactory\n moduleFactories[moduleId] = moduleFactoryFn\n for (const otherModuleId of otherIds) {\n moduleFactories[otherModuleId] = moduleFactoryFn\n }\n } else {\n moduleFactories[moduleId] = moduleFactory\n }\n }\n }\n loadedChunks.add(chunkPath)\n } catch (e) {\n let errorMessage = `Failed to load chunk ${chunkPath}`\n\n if (source) {\n errorMessage += ` from ${stringifySourceInfo(source)}`\n }\n\n throw new Error(errorMessage, {\n cause: e,\n })\n }\n}\n\nfunction loadChunkUncached(chunkPath: ChunkPath) {\n // resolve to an absolute path to simplify `require` handling\n const resolved = path.resolve(RUNTIME_ROOT, chunkPath)\n\n const chunkModules: CompressedModuleFactories = require(resolved)\n for (const [moduleId, moduleFactory] of Object.entries(chunkModules)) {\n if (!moduleFactories[moduleId]) {\n if (Array.isArray(moduleFactory)) {\n const [moduleFactoryFn, otherIds] = moduleFactory\n moduleFactories[moduleId] = moduleFactoryFn\n for (const otherModuleId of otherIds) {\n moduleFactories[otherModuleId] = moduleFactoryFn\n }\n } else {\n moduleFactories[moduleId] = moduleFactory\n }\n }\n }\n}\n\nfunction loadChunkAsync(\n source: SourceInfo,\n chunkData: ChunkData\n): Promise {\n const chunkPath = typeof chunkData === 'string' ? chunkData : chunkData.path\n if (!isJs(chunkPath)) {\n // We only support loading JS chunks in Node.js.\n // This branch can be hit when trying to load a CSS chunk.\n return unsupportedLoadChunk\n }\n\n let entry = chunkCache.get(chunkPath)\n if (entry === undefined) {\n try {\n // Load the chunk synchronously\n loadChunkUncached(chunkPath)\n entry = loadedChunk\n } catch (e) {\n let errorMessage = `Failed to load chunk ${chunkPath}`\n if (source) {\n errorMessage += ` from ${stringifySourceInfo(source)}`\n }\n\n // Cache the failure promise, future requests will also get this same rejection\n entry = Promise.reject(\n new Error(errorMessage, {\n cause: e,\n })\n )\n }\n chunkCache.set(chunkPath, entry)\n }\n // TODO: Return an instrumented Promise that React can use instead of relying on referential equality.\n return entry\n}\n\nfunction loadChunkAsyncByUrl(source: SourceInfo, chunkUrl: string) {\n const path = url.fileURLToPath(new URL(chunkUrl, RUNTIME_ROOT)) as ChunkPath\n return loadChunkAsync(source, path)\n}\n\nfunction loadWebAssembly(\n chunkPath: ChunkPath,\n _edgeModule: () => WebAssembly.Module,\n imports: WebAssembly.Imports\n) {\n const resolved = path.resolve(RUNTIME_ROOT, chunkPath)\n\n return instantiateWebAssemblyFromPath(resolved, imports)\n}\n\nfunction loadWebAssemblyModule(\n chunkPath: ChunkPath,\n _edgeModule: () => WebAssembly.Module\n) {\n const resolved = path.resolve(RUNTIME_ROOT, chunkPath)\n\n return compileWebAssemblyFromPath(resolved)\n}\n\nfunction getWorkerBlobURL(_chunks: ChunkPath[]): string {\n throw new Error('Worker blobs are not implemented yet for Node.js')\n}\n\nfunction instantiateModule(id: ModuleId, source: SourceInfo): Module {\n const moduleFactory = moduleFactories[id]\n if (typeof moduleFactory !== 'function') {\n // This can happen if modules incorrectly handle HMR disposes/updates,\n // e.g. when they keep a `setTimeout` around which still executes old code\n // and contains e.g. a `require(\"something\")` call.\n let instantiationReason\n switch (source.type) {\n case SourceType.Runtime:\n instantiationReason = `as a runtime entry of chunk ${source.chunkPath}`\n break\n case SourceType.Parent:\n instantiationReason = `because it was required from module ${source.parentId}`\n break\n default:\n invariant(source, (source) => `Unknown source type: ${source?.type}`)\n }\n throw new Error(\n `Module ${id} was instantiated ${instantiationReason}, but the module factory is not available. It might have been deleted in an HMR update.`\n )\n }\n\n const module: Module = {\n exports: {},\n error: undefined,\n loaded: false,\n id,\n namespaceObject: undefined,\n }\n moduleCache[id] = module\n\n // NOTE(alexkirsz) This can fail when the module encounters a runtime error.\n try {\n const r = commonJsRequire.bind(null, module)\n moduleFactory.call(module.exports, {\n a: asyncModule.bind(null, module),\n e: module.exports,\n r,\n t: runtimeRequire,\n x: externalRequire,\n y: externalImport,\n f: moduleContext,\n i: esmImport.bind(null, module),\n s: esmExport.bind(null, module, module.exports, moduleCache),\n j: dynamicExport.bind(null, module, module.exports, moduleCache),\n v: exportValue.bind(null, module, moduleCache),\n n: exportNamespace.bind(null, module, moduleCache),\n m: module,\n c: moduleCache,\n M: moduleFactories,\n l: loadChunkAsync.bind(null, { type: SourceType.Parent, parentId: id }),\n L: loadChunkAsyncByUrl.bind(null, {\n type: SourceType.Parent,\n parentId: id,\n }),\n C: clearChunkCache,\n w: loadWebAssembly,\n u: loadWebAssemblyModule,\n P: resolveAbsolutePath,\n U: relativeURL,\n R: createResolvePathFromModule(r),\n b: getWorkerBlobURL,\n z: requireStub,\n })\n } catch (error) {\n module.error = error as any\n throw error\n }\n\n module.loaded = true\n if (module.namespaceObject && module.exports !== module.namespaceObject) {\n // in case of a circular dependency: cjs1 -> esm2 -> cjs1\n interopEsm(module.exports, module.namespaceObject)\n }\n\n return module\n}\n\n/**\n * Retrieves a module from the cache, or instantiate it if it is not cached.\n */\n// @ts-ignore\nfunction getOrInstantiateModuleFromParent(\n id: ModuleId,\n sourceModule: Module\n): Module {\n const module = moduleCache[id]\n\n if (module) {\n return module\n }\n\n return instantiateModule(id, {\n type: SourceType.Parent,\n parentId: sourceModule.id,\n })\n}\n\n/**\n * Instantiates a runtime module.\n */\nfunction instantiateRuntimeModule(\n moduleId: ModuleId,\n chunkPath: ChunkPath\n): Module {\n return instantiateModule(moduleId, { type: SourceType.Runtime, chunkPath })\n}\n\n/**\n * Retrieves a module from the cache, or instantiate it as a runtime module if it is not cached.\n */\n// @ts-ignore TypeScript doesn't separate this module space from the browser runtime\nfunction getOrInstantiateRuntimeModule(\n moduleId: ModuleId,\n chunkPath: ChunkPath\n): Module {\n const module = moduleCache[moduleId]\n if (module) {\n if (module.error) {\n throw module.error\n }\n return module\n }\n\n return instantiateRuntimeModule(moduleId, chunkPath)\n}\n\nconst regexJsUrl = /\\.js(?:\\?[^#]*)?(?:#.*)?$/\n/**\n * Checks if a given path/URL ends with .js, optionally followed by ?query or #fragment.\n */\nfunction isJs(chunkUrlOrPath: ChunkUrl | ChunkPath): boolean {\n return regexJsUrl.test(chunkUrlOrPath)\n}\n\nmodule.exports = {\n getOrInstantiateRuntimeModule,\n loadChunk,\n}\n"],"names":[],"mappings":"AAAA,oDAAoD,GAEpD,mDAAmD;AACnD,+DAA+D;AAC/D,+DAA+D;AAC/D,0DAA0D;AAE1D,IAAA,AAAK,oCAAA;IACH;;;GAGC;IAED;;GAEC;WARE;EAAA;AAsBL,QAAQ,GAAG,CAAC,SAAS,GAAG;AAExB,SAAS,oBAAoB,MAAkB;IAC7C,OAAQ,OAAO,IAAI;QACjB;YACE,OAAO,CAAC,kBAAkB,EAAE,OAAO,SAAS,EAAE;QAChD;YACE,OAAO,CAAC,cAAc,EAAE,OAAO,QAAQ,EAAE;QAC3C;YACE,UAAU,QAAQ,CAAC,SAAW,CAAC,qBAAqB,EAAE,QAAQ,MAAM;IACxE;AACF;AAoBA,MAAM,MAAM,QAAQ;AACpB,MAAM,KAAK,QAAQ;AAEnB,MAAM,kBAAmC,OAAO,MAAM,CAAC;AACvD,MAAM,cAAmC,OAAO,MAAM,CAAC;AAEvD;;CAEC,GACD,SAAS,4BACP,QAAuC;IAEvC,OAAO,SAAS,sBAAsB,QAAgB;QACpD,MAAM,WAAW,SAAS;QAC1B,MAAM,eAAe,UAAU,WAAW;QAC1C,IAAI,OAAO,iBAAiB,UAAU;YACpC,OAAO;QACT;QAEA,MAAM,sBAAsB,aAAa,KAAK,CAAC,aAAa,MAAM;QAClE,MAAM,WAAW,KAAK,OAAO,CAAC,cAAc;QAE5C,OAAO,IAAI,aA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b9f31478647bfa5c51e010b7929f Mon Sep 17 00:00:00 2001 From: Luke Sandberg Date: Fri, 18 Jul 2025 12:10:27 -0700 Subject: [PATCH 7/8] leave a comment about dynamic import --- .../js/src/nodejs/runtime.ts | 2 ++ .../Error evaluating Node.js code-4a1dc5.txt | 32 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 turbopack/crates/turbopack-tests/tests/execution/turbopack/chunking/multiple-paths-evaluated-once/issues/Error evaluating Node.js code-4a1dc5.txt diff --git a/turbopack/crates/turbopack-ecmascript-runtime/js/src/nodejs/runtime.ts b/turbopack/crates/turbopack-ecmascript-runtime/js/src/nodejs/runtime.ts index 12a94c3e95bed..512db06dc17a7 100644 --- a/turbopack/crates/turbopack-ecmascript-runtime/js/src/nodejs/runtime.ts +++ b/turbopack/crates/turbopack-ecmascript-runtime/js/src/nodejs/runtime.ts @@ -147,6 +147,8 @@ function loadChunkUncached(chunkPath: ChunkPath) { // resolve to an absolute path to simplify `require` handling const resolved = path.resolve(RUNTIME_ROOT, chunkPath) + // TODO: consider switching to `import()` to enable concurrent chunk loading and async file io + // However this is incompatible with hot reloading (since `import` doesn't use the require cache) const chunkModules: CompressedModuleFactories = require(resolved) for (const [moduleId, moduleFactory] of Object.entries(chunkModules)) { if (!moduleFactories[moduleId]) { diff --git a/turbopack/crates/turbopack-tests/tests/execution/turbopack/chunking/multiple-paths-evaluated-once/issues/Error evaluating Node.js code-4a1dc5.txt b/turbopack/crates/turbopack-tests/tests/execution/turbopack/chunking/multiple-paths-evaluated-once/issues/Error evaluating Node.js code-4a1dc5.txt new file mode 100644 index 0000000000000..38237e9655fec --- /dev/null +++ b/turbopack/crates/turbopack-tests/tests/execution/turbopack/chunking/multiple-paths-evaluated-once/issues/Error evaluating Node.js code-4a1dc5.txt @@ -0,0 +1,32 @@ +error - [transform] /turbopack/crates/turbopack-tests/tests/execution/turbopack/chunking/multiple-paths-evaluated-once/input/index.js Error evaluating Node.js code + + Error: Could not parse module '[project]/turbopack/crates/turbopack-tests/tests/execution/turbopack/chunking/multiple-paths-evaluated-once/input/index.js' + [at [project]/turbopack/crates/turbopack-tests/tests/execution/turbopack/chunking/multiple-paths-evaluated-once/input/index.js [test] (ecmascript) (WORKSPACE_ROOT/turbopack/crates/turbopack-tests/tests/execution/turbopack/chunking/multiple-paths-evaluated-once/output/457d9_execution_turbopack_chunking_multiple-paths-evaluated-once_input_index_990ab784.js:7:11)] + at instantiateModule (turbopack:///[turbopack]/nodejs/runtime.ts:266:19) [WORKSPACE_ROOT/turbopack/crates/turbopack-tests/tests/execution/turbopack/chunking/multiple-paths-evaluated-once/output/[turbopack]_runtime.js:634:23] + at getOrInstantiateModuleFromParent (turbopack:///[turbopack]/nodejs/runtime.ts:324:10) [WORKSPACE_ROOT/turbopack/crates/turbopack-tests/tests/execution/turbopack/chunking/multiple-paths-evaluated-once/output/[turbopack]_runtime.js:686:12] + at esmImport (turbopack:///[turbopack]/shared/runtime-utils.ts:264:18) [WORKSPACE_ROOT/turbopack/crates/turbopack-tests/tests/execution/turbopack/chunking/multiple-paths-evaluated-once/output/[turbopack]_runtime.js:162:20] + at (turbopack/crates/turbopack-tests/js/jest-entry.ts:64:1) [WORKSPACE_ROOT/turbopack/crates/turbopack-tests/tests/execution/turbopack/chunking/multiple-paths-evaluated-once/output/[root-of-the-server]__e6c7098d._.js:83:16] + 60 | jestResult, + 61 | uncaughtExceptions, + 62 | unhandledRejections, + 63 | } + | v + 64 + } + | ^ + 65 | + + [at process.processTicksAndRejections (node:internal/process/task_queues:95:5)] + at async run (turbopack/crates/turbopack-tests/js/jest-entry.ts:36:3) [WORKSPACE_ROOT/turbopack/crates/turbopack-tests/tests/execution/turbopack/chunking/multiple-paths-evaluated-once/output/[root-of-the-server]__e6c7098d._.js:52:5] + 32 | + 33 | export default async function run() { + 34 | setupGlobals() + 35 | + | v + 36 + await import('TESTS') + | ^ + 37 | + 38 | let jestResult = await jest.run() + 39 | // Jest test results can contain references to arbitrary objects. + 40 | // Defensively remove circular references to avoid breaking our serialization protocol. + + at async run (turbopack:///[turbopack-node]/ipc/evaluate.ts:92:23) [WORKSPACE_ROOT/turbopack/crates/turbopack-tests/tests/execution/turbopack/chunking/multiple-paths-evaluated-once/output/[turbopack-node]__b5ff6c9f._.js:411:31] \ No newline at end of file From b2d1d0db0ef6b2fbf9aec8016480c3047ab59bc7 Mon Sep 17 00:00:00 2001 From: Luke Sandberg Date: Fri, 18 Jul 2025 12:17:43 -0700 Subject: [PATCH 8/8] snappy snap snap --- .../Error evaluating Node.js code-4a1dc5.txt | 32 ------------------- .../output/[turbopack]_runtime.js | 2 ++ .../output/[turbopack]_runtime.js.map | 2 +- 3 files changed, 3 insertions(+), 33 deletions(-) delete mode 100644 turbopack/crates/turbopack-tests/tests/execution/turbopack/chunking/multiple-paths-evaluated-once/issues/Error evaluating Node.js code-4a1dc5.txt diff --git a/turbopack/crates/turbopack-tests/tests/execution/turbopack/chunking/multiple-paths-evaluated-once/issues/Error evaluating Node.js code-4a1dc5.txt b/turbopack/crates/turbopack-tests/tests/execution/turbopack/chunking/multiple-paths-evaluated-once/issues/Error evaluating Node.js code-4a1dc5.txt deleted file mode 100644 index 38237e9655fec..0000000000000 --- a/turbopack/crates/turbopack-tests/tests/execution/turbopack/chunking/multiple-paths-evaluated-once/issues/Error evaluating Node.js code-4a1dc5.txt +++ /dev/null @@ -1,32 +0,0 @@ -error - [transform] /turbopack/crates/turbopack-tests/tests/execution/turbopack/chunking/multiple-paths-evaluated-once/input/index.js Error evaluating Node.js code - - Error: Could not parse module '[project]/turbopack/crates/turbopack-tests/tests/execution/turbopack/chunking/multiple-paths-evaluated-once/input/index.js' - [at [project]/turbopack/crates/turbopack-tests/tests/execution/turbopack/chunking/multiple-paths-evaluated-once/input/index.js [test] (ecmascript) (WORKSPACE_ROOT/turbopack/crates/turbopack-tests/tests/execution/turbopack/chunking/multiple-paths-evaluated-once/output/457d9_execution_turbopack_chunking_multiple-paths-evaluated-once_input_index_990ab784.js:7:11)] - at instantiateModule (turbopack:///[turbopack]/nodejs/runtime.ts:266:19) [WORKSPACE_ROOT/turbopack/crates/turbopack-tests/tests/execution/turbopack/chunking/multiple-paths-evaluated-once/output/[turbopack]_runtime.js:634:23] - at getOrInstantiateModuleFromParent (turbopack:///[turbopack]/nodejs/runtime.ts:324:10) [WORKSPACE_ROOT/turbopack/crates/turbopack-tests/tests/execution/turbopack/chunking/multiple-paths-evaluated-once/output/[turbopack]_runtime.js:686:12] - at esmImport (turbopack:///[turbopack]/shared/runtime-utils.ts:264:18) [WORKSPACE_ROOT/turbopack/crates/turbopack-tests/tests/execution/turbopack/chunking/multiple-paths-evaluated-once/output/[turbopack]_runtime.js:162:20] - at (turbopack/crates/turbopack-tests/js/jest-entry.ts:64:1) [WORKSPACE_ROOT/turbopack/crates/turbopack-tests/tests/execution/turbopack/chunking/multiple-paths-evaluated-once/output/[root-of-the-server]__e6c7098d._.js:83:16] - 60 | jestResult, - 61 | uncaughtExceptions, - 62 | unhandledRejections, - 63 | } - | v - 64 + } - | ^ - 65 | - - [at process.processTicksAndRejections (node:internal/process/task_queues:95:5)] - at async run (turbopack/crates/turbopack-tests/js/jest-entry.ts:36:3) [WORKSPACE_ROOT/turbopack/crates/turbopack-tests/tests/execution/turbopack/chunking/multiple-paths-evaluated-once/output/[root-of-the-server]__e6c7098d._.js:52:5] - 32 | - 33 | export default async function run() { - 34 | setupGlobals() - 35 | - | v - 36 + await import('TESTS') - | ^ - 37 | - 38 | let jestResult = await jest.run() - 39 | // Jest test results can contain references to arbitrary objects. - 40 | // Defensively remove circular references to avoid breaking our serialization protocol. - - at async run (turbopack:///[turbopack-node]/ipc/evaluate.ts:92:23) [WORKSPACE_ROOT/turbopack/crates/turbopack-tests/tests/execution/turbopack/chunking/multiple-paths-evaluated-once/output/[turbopack-node]__b5ff6c9f._.js:411:31] \ No newline at end of file diff --git a/turbopack/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js b/turbopack/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js index a62bb338e4d5a..70523406cb670 100644 --- a/turbopack/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js +++ b/turbopack/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js @@ -541,6 +541,8 @@ function loadChunkPath(chunkPath, source) { function loadChunkUncached(chunkPath) { // resolve to an absolute path to simplify `require` handling const resolved = path.resolve(RUNTIME_ROOT, chunkPath); + // TODO: consider switching to `import()` to enable concurrent chunk loading and async file io + // However this is incompatible with hot reloading (since `import` doesn't use the require cache) const chunkModules = require(resolved); for (const [moduleId, moduleFactory] of Object.entries(chunkModules)){ if (!moduleFactories[moduleId]) { diff --git a/turbopack/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js.map b/turbopack/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js.map index bf1177c6e777f..d59f7c2e3deb8 100644 --- a/turbopack/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js.map +++ b/turbopack/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js.map @@ -6,5 +6,5 @@ {"offset": {"line": 367, "column": 0}, "map": {"version":3,"sources":["turbopack:///[turbopack]/shared-node/base-externals-utils.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\n\n/// \n\n/// A 'base' utilities to support runtime can have externals.\n/// Currently this is for node.js / edge runtime both.\n/// If a fn requires node.js specific behavior, it should be placed in `node-external-utils` instead.\n\nasync function externalImport(id: DependencySpecifier) {\n let raw\n try {\n raw = await import(id)\n } catch (err) {\n // TODO(alexkirsz) This can happen when a client-side module tries to load\n // an external module we don't provide a shim for (e.g. querystring, url).\n // For now, we fail semi-silently, but in the future this should be a\n // compilation error.\n throw new Error(`Failed to load external module ${id}: ${err}`)\n }\n\n if (raw && raw.__esModule && raw.default && 'default' in raw.default) {\n return interopEsm(raw.default, createNS(raw), true)\n }\n\n return raw\n}\n\nfunction externalRequire(\n id: ModuleId,\n thunk: () => any,\n esm: boolean = false\n): Exports | EsmNamespaceObject {\n let raw\n try {\n raw = thunk()\n } catch (err) {\n // TODO(alexkirsz) This can happen when a client-side module tries to load\n // an external module we don't provide a shim for (e.g. querystring, url).\n // For now, we fail semi-silently, but in the future this should be a\n // compilation error.\n throw new Error(`Failed to load external module ${id}: ${err}`)\n }\n\n if (!esm || raw.__esModule) {\n return raw\n }\n\n return interopEsm(raw, createNS(raw), true)\n}\n\nexternalRequire.resolve = (\n id: string,\n options?: {\n paths?: string[]\n }\n) => {\n return require.resolve(id, options)\n}\n"],"names":[],"mappings":"AAAA,oDAAoD,GAEpD,mDAAmD;AAEnD,6DAA6D;AAC7D,sDAAsD;AACtD,qGAAqG;AAErG,eAAe,eAAe,EAAuB;IACnD,IAAI;IACJ,IAAI;QACF,MAAM,MAAM,MAAM,CAAC;IACrB,EAAE,OAAO,KAAK;QACZ,0EAA0E;QAC1E,0EAA0E;QAC1E,qEAAqE;QACrE,qBAAqB;QACrB,MAAM,IAAI,MAAM,CAAC,+BAA+B,EAAE,GAAG,EAAE,EAAE,KAAK;IAChE;IAEA,IAAI,OAAO,IAAI,UAAU,IAAI,IAAI,OAAO,IAAI,aAAa,IAAI,OAAO,EAAE;QACpE,OAAO,WAAW,IAAI,OAAO,EAAE,SAAS,MAAM;IAChD;IAEA,OAAO;AACT;AAEA,SAAS,gBACP,EAAY,EACZ,KAAgB,EAChB,MAAe,KAAK;IAEpB,IAAI;IACJ,IAAI;QACF,MAAM;IACR,EAAE,OAAO,KAAK;QACZ,0EAA0E;QAC1E,0EAA0E;QAC1E,qEAAqE;QACrE,qBAAqB;QACrB,MAAM,IAAI,MAAM,CAAC,+BAA+B,EAAE,GAAG,EAAE,EAAE,KAAK;IAChE;IAEA,IAAI,CAAC,OAAO,IAAI,UAAU,EAAE;QAC1B,OAAO;IACT;IAEA,OAAO,WAAW,KAAK,SAAS,MAAM;AACxC;AAEA,gBAAgB,OAAO,GAAG,CACxB,IACA;IAIA,OAAO,QAAQ,OAAO,CAAC,IAAI;AAC7B","ignoreList":[0]}}, {"offset": {"line": 406, "column": 0}, "map": {"version":3,"sources":["turbopack:///[turbopack]/shared-node/node-externals-utils.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\n\ndeclare var RUNTIME_PUBLIC_PATH: string\ndeclare var RELATIVE_ROOT_PATH: string\ndeclare var ASSET_PREFIX: string\n\nconst path = require('path')\n\nconst relativePathToRuntimeRoot = path.relative(RUNTIME_PUBLIC_PATH, '.')\n// Compute the relative path to the `distDir`.\nconst relativePathToDistRoot = path.join(\n relativePathToRuntimeRoot,\n RELATIVE_ROOT_PATH\n)\nconst RUNTIME_ROOT = path.resolve(__filename, relativePathToRuntimeRoot)\n// Compute the absolute path to the root, by stripping distDir from the absolute path to this file.\nconst ABSOLUTE_ROOT = path.resolve(__filename, relativePathToDistRoot)\n\n/**\n * Returns an absolute path to the given module path.\n * Module path should be relative, either path to a file or a directory.\n *\n * This fn allows to calculate an absolute path for some global static values, such as\n * `__dirname` or `import.meta.url` that Turbopack will not embeds in compile time.\n * See ImportMetaBinding::code_generation for the usage.\n */\nfunction resolveAbsolutePath(modulePath?: string): string {\n if (modulePath) {\n return path.join(ABSOLUTE_ROOT, modulePath)\n }\n return ABSOLUTE_ROOT\n}\n"],"names":[],"mappings":"AAAA,oDAAoD,GAMpD,MAAM,OAAO,QAAQ;AAErB,MAAM,4BAA4B,KAAK,QAAQ,CAAC,qBAAqB;AACrE,8CAA8C;AAC9C,MAAM,yBAAyB,KAAK,IAAI,CACtC,2BACA;AAEF,MAAM,eAAe,KAAK,OAAO,CAAC,YAAY;AAC9C,mGAAmG;AACnG,MAAM,gBAAgB,KAAK,OAAO,CAAC,YAAY;AAE/C;;;;;;;CAOC,GACD,SAAS,oBAAoB,UAAmB;IAC9C,IAAI,YAAY;QACd,OAAO,KAAK,IAAI,CAAC,eAAe;IAClC;IACA,OAAO;AACT","ignoreList":[0]}}, {"offset": {"line": 426, "column": 0}, "map": {"version":3,"sources":["turbopack:///[turbopack]/shared-node/node-wasm-utils.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\n\n/// \n\nfunction readWebAssemblyAsResponse(path: string) {\n const { createReadStream } = require('fs') as typeof import('fs')\n const { Readable } = require('stream') as typeof import('stream')\n\n const stream = createReadStream(path)\n\n // @ts-ignore unfortunately there's a slight type mismatch with the stream.\n return new Response(Readable.toWeb(stream), {\n headers: {\n 'content-type': 'application/wasm',\n },\n })\n}\n\nasync function compileWebAssemblyFromPath(\n path: string\n): Promise {\n const response = readWebAssemblyAsResponse(path)\n\n return await WebAssembly.compileStreaming(response)\n}\n\nasync function instantiateWebAssemblyFromPath(\n path: string,\n importsObj: WebAssembly.Imports\n): Promise {\n const response = readWebAssemblyAsResponse(path)\n\n const { instance } = await WebAssembly.instantiateStreaming(\n response,\n importsObj\n )\n\n return instance.exports\n}\n"],"names":[],"mappings":"AAAA,oDAAoD,GAEpD,mDAAmD;AAEnD,SAAS,0BAA0B,IAAY;IAC7C,MAAM,EAAE,gBAAgB,EAAE,GAAG,QAAQ;IACrC,MAAM,EAAE,QAAQ,EAAE,GAAG,QAAQ;IAE7B,MAAM,SAAS,iBAAiB;IAEhC,2EAA2E;IAC3E,OAAO,IAAI,SAAS,SAAS,KAAK,CAAC,SAAS;QAC1C,SAAS;YACP,gBAAgB;QAClB;IACF;AACF;AAEA,eAAe,2BACb,IAAY;IAEZ,MAAM,WAAW,0BAA0B;IAE3C,OAAO,MAAM,YAAY,gBAAgB,CAAC;AAC5C;AAEA,eAAe,+BACb,IAAY,EACZ,UAA+B;IAE/B,MAAM,WAAW,0BAA0B;IAE3C,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,YAAY,oBAAoB,CACzD,UACA;IAGF,OAAO,SAAS,OAAO;AACzB","ignoreList":[0]}}, - {"offset": {"line": 447, "column": 0}, "map": {"version":3,"sources":["turbopack:///[turbopack]/nodejs/runtime.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\n\n/// \n/// \n/// \n/// \n\nenum SourceType {\n /**\n * The module was instantiated because it was included in an evaluated chunk's\n * runtime.\n */\n Runtime = 0,\n /**\n * The module was instantiated because a parent module imported it.\n */\n Parent = 1,\n}\n\ntype SourceInfo =\n | {\n type: SourceType.Runtime\n chunkPath: ChunkPath\n }\n | {\n type: SourceType.Parent\n parentId: ModuleId\n }\n\nprocess.env.TURBOPACK = '1'\n\nfunction stringifySourceInfo(source: SourceInfo): string {\n switch (source.type) {\n case SourceType.Runtime:\n return `runtime for chunk ${source.chunkPath}`\n case SourceType.Parent:\n return `parent module ${source.parentId}`\n default:\n invariant(source, (source) => `Unknown source type: ${source?.type}`)\n }\n}\n\ntype ExternalRequire = (\n id: ModuleId,\n thunk: () => any,\n esm?: boolean\n) => Exports | EsmNamespaceObject\ntype ExternalImport = (id: ModuleId) => Promise\n\ninterface TurbopackNodeBuildContext extends TurbopackBaseContext {\n R: ResolvePathFromModule\n x: ExternalRequire\n y: ExternalImport\n}\n\ntype ModuleFactory = (\n this: Module['exports'],\n context: TurbopackNodeBuildContext\n) => unknown\n\nconst url = require('url') as typeof import('url')\nconst fs = require('fs/promises') as typeof import('fs/promises')\n\nconst moduleFactories: ModuleFactories = Object.create(null)\nconst moduleCache: ModuleCache = Object.create(null)\n\n/**\n * Returns an absolute path to the given module's id.\n */\nfunction createResolvePathFromModule(\n resolver: (moduleId: string) => Exports\n): (moduleId: string) => string {\n return function resolvePathFromModule(moduleId: string): string {\n const exported = resolver(moduleId)\n const exportedPath = exported?.default ?? exported\n if (typeof exportedPath !== 'string') {\n return exported as any\n }\n\n const strippedAssetPrefix = exportedPath.slice(ASSET_PREFIX.length)\n const resolved = path.resolve(RUNTIME_ROOT, strippedAssetPrefix)\n\n return url.pathToFileURL(resolved).href\n }\n}\n\nfunction loadChunk(chunkData: ChunkData, source?: SourceInfo): void {\n if (typeof chunkData === 'string') {\n loadChunkPath(chunkData, source)\n } else {\n loadChunkPath(chunkData.path, source)\n }\n}\n\nconst loadedChunks = new Set()\nconst unsupportedLoadChunk = Promise.resolve(undefined)\nconst loadedChunk: Promise = Promise.resolve(undefined)\nconst chunkCache = new Map>()\n\nfunction clearChunkCache() {\n chunkCache.clear()\n}\n\nfunction loadChunkPath(chunkPath: ChunkPath, source?: SourceInfo): void {\n if (!isJs(chunkPath)) {\n // We only support loading JS chunks in Node.js.\n // This branch can be hit when trying to load a CSS chunk.\n return\n }\n\n if (loadedChunks.has(chunkPath)) {\n return\n }\n\n try {\n const resolved = path.resolve(RUNTIME_ROOT, chunkPath)\n const chunkModules: CompressedModuleFactories = require(resolved)\n\n for (const [moduleId, moduleFactory] of Object.entries(chunkModules)) {\n if (!moduleFactories[moduleId]) {\n if (Array.isArray(moduleFactory)) {\n const [moduleFactoryFn, otherIds] = moduleFactory\n moduleFactories[moduleId] = moduleFactoryFn\n for (const otherModuleId of otherIds) {\n moduleFactories[otherModuleId] = moduleFactoryFn\n }\n } else {\n moduleFactories[moduleId] = moduleFactory\n }\n }\n }\n loadedChunks.add(chunkPath)\n } catch (e) {\n let errorMessage = `Failed to load chunk ${chunkPath}`\n\n if (source) {\n errorMessage += ` from ${stringifySourceInfo(source)}`\n }\n\n throw new Error(errorMessage, {\n cause: e,\n })\n }\n}\n\nfunction loadChunkUncached(chunkPath: ChunkPath) {\n // resolve to an absolute path to simplify `require` handling\n const resolved = path.resolve(RUNTIME_ROOT, chunkPath)\n\n const chunkModules: CompressedModuleFactories = require(resolved)\n for (const [moduleId, moduleFactory] of Object.entries(chunkModules)) {\n if (!moduleFactories[moduleId]) {\n if (Array.isArray(moduleFactory)) {\n const [moduleFactoryFn, otherIds] = moduleFactory\n moduleFactories[moduleId] = moduleFactoryFn\n for (const otherModuleId of otherIds) {\n moduleFactories[otherModuleId] = moduleFactoryFn\n }\n } else {\n moduleFactories[moduleId] = moduleFactory\n }\n }\n }\n}\n\nfunction loadChunkAsync(\n source: SourceInfo,\n chunkData: ChunkData\n): Promise {\n const chunkPath = typeof chunkData === 'string' ? chunkData : chunkData.path\n if (!isJs(chunkPath)) {\n // We only support loading JS chunks in Node.js.\n // This branch can be hit when trying to load a CSS chunk.\n return unsupportedLoadChunk\n }\n\n let entry = chunkCache.get(chunkPath)\n if (entry === undefined) {\n try {\n // Load the chunk synchronously\n loadChunkUncached(chunkPath)\n entry = loadedChunk\n } catch (e) {\n let errorMessage = `Failed to load chunk ${chunkPath}`\n if (source) {\n errorMessage += ` from ${stringifySourceInfo(source)}`\n }\n\n // Cache the failure promise, future requests will also get this same rejection\n entry = Promise.reject(\n new Error(errorMessage, {\n cause: e,\n })\n )\n }\n chunkCache.set(chunkPath, entry)\n }\n // TODO: Return an instrumented Promise that React can use instead of relying on referential equality.\n return entry\n}\n\nfunction loadChunkAsyncByUrl(source: SourceInfo, chunkUrl: string) {\n const path = url.fileURLToPath(new URL(chunkUrl, RUNTIME_ROOT)) as ChunkPath\n return loadChunkAsync(source, path)\n}\n\nfunction loadWebAssembly(\n chunkPath: ChunkPath,\n _edgeModule: () => WebAssembly.Module,\n imports: WebAssembly.Imports\n) {\n const resolved = path.resolve(RUNTIME_ROOT, chunkPath)\n\n return instantiateWebAssemblyFromPath(resolved, imports)\n}\n\nfunction loadWebAssemblyModule(\n chunkPath: ChunkPath,\n _edgeModule: () => WebAssembly.Module\n) {\n const resolved = path.resolve(RUNTIME_ROOT, chunkPath)\n\n return compileWebAssemblyFromPath(resolved)\n}\n\nfunction getWorkerBlobURL(_chunks: ChunkPath[]): string {\n throw new Error('Worker blobs are not implemented yet for Node.js')\n}\n\nfunction instantiateModule(id: ModuleId, source: SourceInfo): Module {\n const moduleFactory = moduleFactories[id]\n if (typeof moduleFactory !== 'function') {\n // This can happen if modules incorrectly handle HMR disposes/updates,\n // e.g. when they keep a `setTimeout` around which still executes old code\n // and contains e.g. a `require(\"something\")` call.\n let instantiationReason\n switch (source.type) {\n case SourceType.Runtime:\n instantiationReason = `as a runtime entry of chunk ${source.chunkPath}`\n break\n case SourceType.Parent:\n instantiationReason = `because it was required from module ${source.parentId}`\n break\n default:\n invariant(source, (source) => `Unknown source type: ${source?.type}`)\n }\n throw new Error(\n `Module ${id} was instantiated ${instantiationReason}, but the module factory is not available. It might have been deleted in an HMR update.`\n )\n }\n\n const module: Module = {\n exports: {},\n error: undefined,\n loaded: false,\n id,\n namespaceObject: undefined,\n }\n moduleCache[id] = module\n\n // NOTE(alexkirsz) This can fail when the module encounters a runtime error.\n try {\n const r = commonJsRequire.bind(null, module)\n moduleFactory.call(module.exports, {\n a: asyncModule.bind(null, module),\n e: module.exports,\n r,\n t: runtimeRequire,\n x: externalRequire,\n y: externalImport,\n f: moduleContext,\n i: esmImport.bind(null, module),\n s: esmExport.bind(null, module, module.exports, moduleCache),\n j: dynamicExport.bind(null, module, module.exports, moduleCache),\n v: exportValue.bind(null, module, moduleCache),\n n: exportNamespace.bind(null, module, moduleCache),\n m: module,\n c: moduleCache,\n M: moduleFactories,\n l: loadChunkAsync.bind(null, { type: SourceType.Parent, parentId: id }),\n L: loadChunkAsyncByUrl.bind(null, {\n type: SourceType.Parent,\n parentId: id,\n }),\n C: clearChunkCache,\n w: loadWebAssembly,\n u: loadWebAssemblyModule,\n P: resolveAbsolutePath,\n U: relativeURL,\n R: createResolvePathFromModule(r),\n b: getWorkerBlobURL,\n z: requireStub,\n })\n } catch (error) {\n module.error = error as any\n throw error\n }\n\n module.loaded = true\n if (module.namespaceObject && module.exports !== module.namespaceObject) {\n // in case of a circular dependency: cjs1 -> esm2 -> cjs1\n interopEsm(module.exports, module.namespaceObject)\n }\n\n return module\n}\n\n/**\n * Retrieves a module from the cache, or instantiate it if it is not cached.\n */\n// @ts-ignore\nfunction getOrInstantiateModuleFromParent(\n id: ModuleId,\n sourceModule: Module\n): Module {\n const module = moduleCache[id]\n\n if (module) {\n return module\n }\n\n return instantiateModule(id, {\n type: SourceType.Parent,\n parentId: sourceModule.id,\n })\n}\n\n/**\n * Instantiates a runtime module.\n */\nfunction instantiateRuntimeModule(\n moduleId: ModuleId,\n chunkPath: ChunkPath\n): Module {\n return instantiateModule(moduleId, { type: SourceType.Runtime, chunkPath })\n}\n\n/**\n * Retrieves a module from the cache, or instantiate it as a runtime module if it is not cached.\n */\n// @ts-ignore TypeScript doesn't separate this module space from the browser runtime\nfunction getOrInstantiateRuntimeModule(\n moduleId: ModuleId,\n chunkPath: ChunkPath\n): Module {\n const module = moduleCache[moduleId]\n if (module) {\n if (module.error) {\n throw module.error\n }\n return module\n }\n\n return instantiateRuntimeModule(moduleId, chunkPath)\n}\n\nconst regexJsUrl = /\\.js(?:\\?[^#]*)?(?:#.*)?$/\n/**\n * Checks if a given path/URL ends with .js, optionally followed by ?query or #fragment.\n */\nfunction isJs(chunkUrlOrPath: ChunkUrl | ChunkPath): boolean {\n return regexJsUrl.test(chunkUrlOrPath)\n}\n\nmodule.exports = {\n getOrInstantiateRuntimeModule,\n loadChunk,\n}\n"],"names":[],"mappings":"AAAA,oDAAoD,GAEpD,mDAAmD;AACnD,+DAA+D;AAC/D,+DAA+D;AAC/D,0DAA0D;AAE1D,IAAA,AAAK,oCAAA;IACH;;;GAGC;IAED;;GAEC;WARE;EAAA;AAsBL,QAAQ,GAAG,CAAC,SAAS,GAAG;AAExB,SAAS,oBAAoB,MAAkB;IAC7C,OAAQ,OAAO,IAAI;QACjB;YACE,OAAO,CAAC,kBAAkB,EAAE,OAAO,SAAS,EAAE;QAChD;YACE,OAAO,CAAC,cAAc,EAAE,OAAO,QAAQ,EAAE;QAC3C;YACE,UAAU,QAAQ,CAAC,SAAW,CAAC,qBAAqB,EAAE,QAAQ,MAAM;IACxE;AACF;AAoBA,MAAM,MAAM,QAAQ;AACpB,MAAM,KAAK,QAAQ;AAEnB,MAAM,kBAAmC,OAAO,MAAM,CAAC;AACvD,MAAM,cAAmC,OAAO,MAAM,CAAC;AAEvD;;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,SAAQ;QACV,IAAI,QAAO,KAAK,EAAE;YAChB,MAAM,QAAO,KAAK;QACpB;QACA,OAAO;IACT;IAEA,OAAO,yBAAyB,UAAU;AAC5C;AAEA,MAAM,aAAa;AACnB;;CAEC,GACD,SAAS,KAAK,cAAoC;IAChD,OAAO,WAAW,IAAI,CAAC;AACzB;AAEA,OAAO,OAAO,GAAG;IACf;IACA;AACF","ignoreList":[0]}}] + {"offset": {"line": 447, "column": 0}, "map": {"version":3,"sources":["turbopack:///[turbopack]/nodejs/runtime.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\n\n/// \n/// \n/// \n/// \n\nenum SourceType {\n /**\n * The module was instantiated because it was included in an evaluated chunk's\n * runtime.\n */\n Runtime = 0,\n /**\n * The module was instantiated because a parent module imported it.\n */\n Parent = 1,\n}\n\ntype SourceInfo =\n | {\n type: SourceType.Runtime\n chunkPath: ChunkPath\n }\n | {\n type: SourceType.Parent\n parentId: ModuleId\n }\n\nprocess.env.TURBOPACK = '1'\n\nfunction stringifySourceInfo(source: SourceInfo): string {\n switch (source.type) {\n case SourceType.Runtime:\n return `runtime for chunk ${source.chunkPath}`\n case SourceType.Parent:\n return `parent module ${source.parentId}`\n default:\n invariant(source, (source) => `Unknown source type: ${source?.type}`)\n }\n}\n\ntype ExternalRequire = (\n id: ModuleId,\n thunk: () => any,\n esm?: boolean\n) => Exports | EsmNamespaceObject\ntype ExternalImport = (id: ModuleId) => Promise\n\ninterface TurbopackNodeBuildContext extends TurbopackBaseContext {\n R: ResolvePathFromModule\n x: ExternalRequire\n y: ExternalImport\n}\n\ntype ModuleFactory = (\n this: Module['exports'],\n context: TurbopackNodeBuildContext\n) => unknown\n\nconst url = require('url') as typeof import('url')\nconst fs = require('fs/promises') as typeof import('fs/promises')\n\nconst moduleFactories: ModuleFactories = Object.create(null)\nconst moduleCache: ModuleCache = Object.create(null)\n\n/**\n * Returns an absolute path to the given module's id.\n */\nfunction createResolvePathFromModule(\n resolver: (moduleId: string) => Exports\n): (moduleId: string) => string {\n return function resolvePathFromModule(moduleId: string): string {\n const exported = resolver(moduleId)\n const exportedPath = exported?.default ?? exported\n if (typeof exportedPath !== 'string') {\n return exported as any\n }\n\n const strippedAssetPrefix = exportedPath.slice(ASSET_PREFIX.length)\n const resolved = path.resolve(RUNTIME_ROOT, strippedAssetPrefix)\n\n return url.pathToFileURL(resolved).href\n }\n}\n\nfunction loadChunk(chunkData: ChunkData, source?: SourceInfo): void {\n if (typeof chunkData === 'string') {\n loadChunkPath(chunkData, source)\n } else {\n loadChunkPath(chunkData.path, source)\n }\n}\n\nconst loadedChunks = new Set()\nconst unsupportedLoadChunk = Promise.resolve(undefined)\nconst loadedChunk: Promise = Promise.resolve(undefined)\nconst chunkCache = new Map>()\n\nfunction clearChunkCache() {\n chunkCache.clear()\n}\n\nfunction loadChunkPath(chunkPath: ChunkPath, source?: SourceInfo): void {\n if (!isJs(chunkPath)) {\n // We only support loading JS chunks in Node.js.\n // This branch can be hit when trying to load a CSS chunk.\n return\n }\n\n if (loadedChunks.has(chunkPath)) {\n return\n }\n\n try {\n const resolved = path.resolve(RUNTIME_ROOT, chunkPath)\n const chunkModules: CompressedModuleFactories = require(resolved)\n\n for (const [moduleId, moduleFactory] of Object.entries(chunkModules)) {\n if (!moduleFactories[moduleId]) {\n if (Array.isArray(moduleFactory)) {\n const [moduleFactoryFn, otherIds] = moduleFactory\n moduleFactories[moduleId] = moduleFactoryFn\n for (const otherModuleId of otherIds) {\n moduleFactories[otherModuleId] = moduleFactoryFn\n }\n } else {\n moduleFactories[moduleId] = moduleFactory\n }\n }\n }\n loadedChunks.add(chunkPath)\n } catch (e) {\n let errorMessage = `Failed to load chunk ${chunkPath}`\n\n if (source) {\n errorMessage += ` from ${stringifySourceInfo(source)}`\n }\n\n throw new Error(errorMessage, {\n cause: e,\n })\n }\n}\n\nfunction loadChunkUncached(chunkPath: ChunkPath) {\n // resolve to an absolute path to simplify `require` handling\n const resolved = path.resolve(RUNTIME_ROOT, chunkPath)\n\n // TODO: consider switching to `import()` to enable concurrent chunk loading and async file io\n // However this is incompatible with hot reloading (since `import` doesn't use the require cache)\n const chunkModules: CompressedModuleFactories = require(resolved)\n for (const [moduleId, moduleFactory] of Object.entries(chunkModules)) {\n if (!moduleFactories[moduleId]) {\n if (Array.isArray(moduleFactory)) {\n const [moduleFactoryFn, otherIds] = moduleFactory\n moduleFactories[moduleId] = moduleFactoryFn\n for (const otherModuleId of otherIds) {\n moduleFactories[otherModuleId] = moduleFactoryFn\n }\n } else {\n moduleFactories[moduleId] = moduleFactory\n }\n }\n }\n}\n\nfunction loadChunkAsync(\n source: SourceInfo,\n chunkData: ChunkData\n): Promise {\n const chunkPath = typeof chunkData === 'string' ? chunkData : chunkData.path\n if (!isJs(chunkPath)) {\n // We only support loading JS chunks in Node.js.\n // This branch can be hit when trying to load a CSS chunk.\n return unsupportedLoadChunk\n }\n\n let entry = chunkCache.get(chunkPath)\n if (entry === undefined) {\n try {\n // Load the chunk synchronously\n loadChunkUncached(chunkPath)\n entry = loadedChunk\n } catch (e) {\n let errorMessage = `Failed to load chunk ${chunkPath}`\n if (source) {\n errorMessage += ` from ${stringifySourceInfo(source)}`\n }\n\n // Cache the failure promise, future requests will also get this same rejection\n entry = Promise.reject(\n new Error(errorMessage, {\n cause: e,\n })\n )\n }\n chunkCache.set(chunkPath, entry)\n }\n // TODO: Return an instrumented Promise that React can use instead of relying on referential equality.\n return entry\n}\n\nfunction loadChunkAsyncByUrl(source: SourceInfo, chunkUrl: string) {\n const path = url.fileURLToPath(new URL(chunkUrl, RUNTIME_ROOT)) as ChunkPath\n return loadChunkAsync(source, path)\n}\n\nfunction loadWebAssembly(\n chunkPath: ChunkPath,\n _edgeModule: () => WebAssembly.Module,\n imports: WebAssembly.Imports\n) {\n const resolved = path.resolve(RUNTIME_ROOT, chunkPath)\n\n return instantiateWebAssemblyFromPath(resolved, imports)\n}\n\nfunction loadWebAssemblyModule(\n chunkPath: ChunkPath,\n _edgeModule: () => WebAssembly.Module\n) {\n const resolved = path.resolve(RUNTIME_ROOT, chunkPath)\n\n return compileWebAssemblyFromPath(resolved)\n}\n\nfunction getWorkerBlobURL(_chunks: ChunkPath[]): string {\n throw new Error('Worker blobs are not implemented yet for Node.js')\n}\n\nfunction instantiateModule(id: ModuleId, source: SourceInfo): Module {\n const moduleFactory = moduleFactories[id]\n if (typeof moduleFactory !== 'function') {\n // This can happen if modules incorrectly handle HMR disposes/updates,\n // e.g. when they keep a `setTimeout` around which still executes old code\n // and contains e.g. a `require(\"something\")` call.\n let instantiationReason\n switch (source.type) {\n case SourceType.Runtime:\n instantiationReason = `as a runtime entry of chunk ${source.chunkPath}`\n break\n case SourceType.Parent:\n instantiationReason = `because it was required from module ${source.parentId}`\n break\n default:\n invariant(source, (source) => `Unknown source type: ${source?.type}`)\n }\n throw new Error(\n `Module ${id} was instantiated ${instantiationReason}, but the module factory is not available. It might have been deleted in an HMR update.`\n )\n }\n\n const module: Module = {\n exports: {},\n error: undefined,\n loaded: false,\n id,\n namespaceObject: undefined,\n }\n moduleCache[id] = module\n\n // NOTE(alexkirsz) This can fail when the module encounters a runtime error.\n try {\n const r = commonJsRequire.bind(null, module)\n moduleFactory.call(module.exports, {\n a: asyncModule.bind(null, module),\n e: module.exports,\n r,\n t: runtimeRequire,\n x: externalRequire,\n y: externalImport,\n f: moduleContext,\n i: esmImport.bind(null, module),\n s: esmExport.bind(null, module, module.exports, moduleCache),\n j: dynamicExport.bind(null, module, module.exports, moduleCache),\n v: exportValue.bind(null, module, moduleCache),\n n: exportNamespace.bind(null, module, moduleCache),\n m: module,\n c: moduleCache,\n M: moduleFactories,\n l: loadChunkAsync.bind(null, { type: SourceType.Parent, parentId: id }),\n L: loadChunkAsyncByUrl.bind(null, {\n type: SourceType.Parent,\n parentId: id,\n }),\n C: clearChunkCache,\n w: loadWebAssembly,\n u: loadWebAssemblyModule,\n P: resolveAbsolutePath,\n U: relativeURL,\n R: createResolvePathFromModule(r),\n b: getWorkerBlobURL,\n z: requireStub,\n })\n } catch (error) {\n module.error = error as any\n throw error\n }\n\n module.loaded = true\n if (module.namespaceObject && module.exports !== module.namespaceObject) {\n // in case of a circular dependency: cjs1 -> esm2 -> cjs1\n interopEsm(module.exports, module.namespaceObject)\n }\n\n return module\n}\n\n/**\n * Retrieves a module from the cache, or instantiate it if it is not cached.\n */\n// @ts-ignore\nfunction getOrInstantiateModuleFromParent(\n id: ModuleId,\n sourceModule: Module\n): Module {\n const module = moduleCache[id]\n\n if (module) {\n return module\n }\n\n return instantiateModule(id, {\n type: SourceType.Parent,\n parentId: sourceModule.id,\n })\n}\n\n/**\n * Instantiates a runtime module.\n */\nfunction instantiateRuntimeModule(\n moduleId: ModuleId,\n chunkPath: ChunkPath\n): Module {\n return instantiateModule(moduleId, { type: SourceType.Runtime, chunkPath })\n}\n\n/**\n * Retrieves a module from the cache, or instantiate it as a runtime module if it is not cached.\n */\n// @ts-ignore TypeScript doesn't separate this module space from the browser runtime\nfunction getOrInstantiateRuntimeModule(\n moduleId: ModuleId,\n chunkPath: ChunkPath\n): Module {\n const module = moduleCache[moduleId]\n if (module) {\n if (module.error) {\n throw module.error\n }\n return module\n }\n\n return instantiateRuntimeModule(moduleId, chunkPath)\n}\n\nconst regexJsUrl = /\\.js(?:\\?[^#]*)?(?:#.*)?$/\n/**\n * Checks if a given path/URL ends with .js, optionally followed by ?query or #fragment.\n */\nfunction isJs(chunkUrlOrPath: ChunkUrl | ChunkPath): boolean {\n return regexJsUrl.test(chunkUrlOrPath)\n}\n\nmodule.exports = {\n getOrInstantiateRuntimeModule,\n loadChunk,\n}\n"],"names":[],"mappings":"AAAA,oDAAoD,GAEpD,mDAAmD;AACnD,+DAA+D;AAC/D,+DAA+D;AAC/D,0DAA0D;AAE1D,IAAA,AAAK,oCAAA;IACH;;;GAGC;IAED;;GAEC;WARE;EAAA;AAsBL,QAAQ,GAAG,CAAC,SAAS,GAAG;AAExB,SAAS,oBAAoB,MAAkB;IAC7C,OAAQ,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