From f1331c56ebfa3d84c4d8a0529cc35d4b14278dfe Mon Sep 17 00:00:00 2001 From: hrmny Date: Mon, 3 Jul 2023 22:39:49 +0200 Subject: [PATCH 01/16] top-level-await support --- crates/turbopack-core/src/resolve/mod.rs | 2 +- .../js/src/build/runtime.ts | 18 +- .../js/src/dev/runtime/base/runtime-base.ts | 20 +- .../runtime/nodejs/runtime-backend-nodejs.ts | 7 + .../js/src/shared/runtime-types.d.ts | 33 ++- .../js/src/shared/runtime-utils.ts | 219 +++++++++++++++++- .../src/analyzer/top_level_await.rs | 23 +- crates/turbopack-ecmascript/src/chunk/item.rs | 27 +++ .../src/chunk/placeable.rs | 5 +- crates/turbopack-ecmascript/src/lib.rs | 28 ++- .../src/references/async_module.rs | 149 ++++++++++++ .../src/references/esm/base.rs | 35 ++- .../src/references/mod.rs | 105 ++++++--- .../src/tree_shake/chunk_item.rs | 8 +- .../basic/top-level-await/input/Actions.js | 28 +++ .../basic/top-level-await/input/README.md | 2 + .../basic/top-level-await/input/UserAPI.js | 7 + .../top-level-await/input/db-connection.js | 18 ++ .../basic/top-level-await/input/index.js | 6 + ...ic_top-level-await_input_UserAPI_030d34.js | 48 ++++ ...op-level-await_input_UserAPI_030d34.js.map | 8 + ...ic_top-level-await_input_UserAPI_6657ac.js | 11 + ...ic_top-level-await_input_UserAPI_853a42.js | 11 + ...ic_top-level-await_input_UserAPI_d6e51f.js | 16 ++ ...op-level-await_input_UserAPI_d6e51f.js.map | 4 + ...asic_top-level-await_input_index_5771e1.js | 11 + ...asic_top-level-await_input_index_b53fce.js | 47 ++++ ..._top-level-await_input_index_b53fce.js.map | 8 + ...asic_top-level-await_input_index_d8ac4f.js | 6 + ..._top-level-await_input_index_d8ac4f.js.map | 4 + ...de_protocol_external_input_index_b53fce.js | 2 +- 31 files changed, 821 insertions(+), 95 deletions(-) create mode 100644 crates/turbopack-ecmascript/src/references/async_module.rs create mode 100644 crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/Actions.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/README.md create mode 100644 crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/UserAPI.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/db-connection.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/index.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_030d34.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_030d34.js.map create mode 100644 crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_6657ac.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_853a42.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_d6e51f.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_d6e51f.js.map create mode 100644 crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_5771e1.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_b53fce.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_b53fce.js.map create mode 100644 crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_d8ac4f.js create mode 100644 crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_d8ac4f.js.map diff --git a/crates/turbopack-core/src/resolve/mod.rs b/crates/turbopack-core/src/resolve/mod.rs index 3472ba6db4ca2..d4c7a3c4986dd 100644 --- a/crates/turbopack-core/src/resolve/mod.rs +++ b/crates/turbopack-core/src/resolve/mod.rs @@ -1438,7 +1438,7 @@ pub async fn handle_resolve_error( }) } -/// ModulePart represnts a part of a module. +/// ModulePart represents a part of a module. /// /// Currently this is used only for ESMs. #[turbo_tasks::value] diff --git a/crates/turbopack-ecmascript-runtime/js/src/build/runtime.ts b/crates/turbopack-ecmascript-runtime/js/src/build/runtime.ts index 978df9c65221c..feefe129b20f7 100644 --- a/crates/turbopack-ecmascript-runtime/js/src/build/runtime.ts +++ b/crates/turbopack-ecmascript-runtime/js/src/build/runtime.ts @@ -30,21 +30,8 @@ interface RequireContextEntry { type ExternalRequire = (id: ModuleId) => Exports | EsmNamespaceObject; -interface TurbopackNodeBuildContext { - e: Module["exports"]; - r: CommonJsRequire; +interface TurbopackNodeBuildContext extends TurbopackBaseContext { x: ExternalRequire; - f: RequireContextFactory; - i: EsmImport; - s: EsmExport; - j: typeof dynamicExport; - v: ExportValue; - n: typeof exportNamespace; - m: Module; - c: ModuleCache; - l: LoadChunk; - g: typeof globalThis; - __dirname: string; } type ModuleFactory = ( @@ -176,13 +163,14 @@ function instantiateModule(id: ModuleId, source: SourceInfo): Module { // NOTE(alexkirsz) This can fail when the module encounters a runtime error. try { moduleFactory.call(module.exports, { + a: asyncModule.bind(null, module), e: module.exports, r: commonJsRequire.bind(null, module), x: externalRequire, f: requireContext.bind(null, module), i: esmImport.bind(null, module), s: esm.bind(null, module.exports), - j: dynamicExport.bind(null, module), + j: dynamicExport.bind(null, module, module.exports), v: exportValue.bind(null, module), n: exportNamespace.bind(null, module), m: module, diff --git a/crates/turbopack-ecmascript-runtime/js/src/dev/runtime/base/runtime-base.ts b/crates/turbopack-ecmascript-runtime/js/src/dev/runtime/base/runtime-base.ts index cc86e9c0afde6..69fb3f5ace44c 100644 --- a/crates/turbopack-ecmascript-runtime/js/src/dev/runtime/base/runtime-base.ts +++ b/crates/turbopack-ecmascript-runtime/js/src/dev/runtime/base/runtime-base.ts @@ -33,21 +33,8 @@ type RefreshContext = { type RefreshHelpers = RefreshRuntimeGlobals["$RefreshHelpers$"]; -interface TurbopackDevBaseContext { - e: Module["exports"]; - r: CommonJsRequire; - f: RequireContextFactory; - i: EsmImport; - s: EsmExport; - j: typeof dynamicExport; - v: ExportValue; - n: typeof exportNamespace; - m: Module; - c: ModuleCache; - l: LoadChunk; - g: typeof globalThis; +interface TurbopackDevBaseContext extends TurbopackBaseContext { k: RefreshContext; - __dirname: string; } interface TurbopackDevContext extends TurbopackDevBaseContext {} @@ -333,12 +320,13 @@ function instantiateModule(id: ModuleId, source: SourceInfo): Module { moduleFactory.call( module.exports, augmentContext({ + a: asyncModule.bind(null, module), e: module.exports, r: commonJsRequire.bind(null, module), f: requireContext.bind(null, module), i: esmImport.bind(null, module), - s: esmExport.bind(null, module), - j: dynamicExport.bind(null, module), + s: esmExport.bind(null, module, module.exports), + j: dynamicExport.bind(null, module, module.exports), v: exportValue.bind(null, module), n: exportNamespace.bind(null, module), m: module, diff --git a/crates/turbopack-ecmascript-runtime/js/src/dev/runtime/nodejs/runtime-backend-nodejs.ts b/crates/turbopack-ecmascript-runtime/js/src/dev/runtime/nodejs/runtime-backend-nodejs.ts index 2a08b17381367..0449e30421d1c 100644 --- a/crates/turbopack-ecmascript-runtime/js/src/dev/runtime/nodejs/runtime-backend-nodejs.ts +++ b/crates/turbopack-ecmascript-runtime/js/src/dev/runtime/nodejs/runtime-backend-nodejs.ts @@ -13,9 +13,11 @@ interface RequireContextEntry { } type ExternalRequire = (id: ModuleId) => Exports | EsmNamespaceObject; +type ExternalImport = (id: ModuleId) => Promise; interface TurbopackDevContext { x: ExternalRequire; + y: ExternalImport; } function commonJsRequireContext( @@ -27,6 +29,10 @@ function commonJsRequireContext( : commonJsRequire(sourceModule, entry.id()); } +function externalImport(id: ModuleId) { + return import(id) +} + function externalRequire( id: ModuleId, esm: boolean = false @@ -62,6 +68,7 @@ externalRequire.resolve = ( function augmentContext(context: TurbopackDevBaseContext): TurbopackDevContext { const nodejsContext = context as TurbopackDevContext; nodejsContext.x = externalRequire; + nodejsContext.y = externalImport; return nodejsContext; } diff --git a/crates/turbopack-ecmascript-runtime/js/src/shared/runtime-types.d.ts b/crates/turbopack-ecmascript-runtime/js/src/shared/runtime-types.d.ts index f9ed380b10767..07763b07d4814 100644 --- a/crates/turbopack-ecmascript-runtime/js/src/shared/runtime-types.d.ts +++ b/crates/turbopack-ecmascript-runtime/js/src/shared/runtime-types.d.ts @@ -20,16 +20,43 @@ type ChunkData = }; type CommonJsRequire = (moduleId: ModuleId) => Exports; -type CommonJsExport = (exports: Record) => void; - type EsmImport = ( moduleId: ModuleId, allowExportDefault: boolean -) => EsmNamespaceObject; +) => EsmNamespaceObject | Promise; type EsmExport = (exportGetters: Record any>) => void; type ExportValue = (value: any) => void; +type ExportNamespace = (namespace: any) => void; +type DynamicExport = (object: Record) => void; type LoadChunk = (chunkPath: ChunkPath) => Promise | undefined; type ModuleCache = Record; type ModuleFactories = Record; + +type AsyncModule = ( + body: ( + handleAsyncDependencies: ( + deps: Dep[] + ) => Exports[] | Promise<() => Exports[]>, + asyncResult: (err?: any) => void + ) => void, + hasAwait: boolean +) => void; + +interface TurbopackBaseContext { + a: AsyncModule; + e: Module["exports"]; + r: CommonJsRequire; + f: RequireContextFactory; + i: EsmImport; + s: EsmExport; + j: DynamicExport; + v: ExportValue; + n: ExportNamespace; + m: Module; + c: ModuleCache; + l: LoadChunk; + g: typeof globalThis; + __dirname: string; +} diff --git a/crates/turbopack-ecmascript-runtime/js/src/shared/runtime-utils.ts b/crates/turbopack-ecmascript-runtime/js/src/shared/runtime-utils.ts index c02c5982553bb..da75a61f5aac4 100644 --- a/crates/turbopack-ecmascript-runtime/js/src/shared/runtime-utils.ts +++ b/crates/turbopack-ecmascript-runtime/js/src/shared/runtime-utils.ts @@ -14,18 +14,19 @@ interface Exports { [key: string]: any; } + type EsmNamespaceObject = Record; const REEXPORTED_OBJECTS = Symbol("reexported objects"); interface BaseModule { - exports: Exports; + exports: Exports | AsyncModulePromise; error: Error | undefined; loaded: boolean; id: ModuleId; children: ModuleId[]; parents: ModuleId[]; - namespaceObject?: EsmNamespaceObject; + namespaceObject?: EsmNamespaceObject | AsyncModulePromise; [REEXPORTED_OBJECTS]?: any[]; } @@ -39,7 +40,9 @@ interface RequireContextEntry { interface RequireContext { (moduleId: ModuleId): Exports | EsmNamespaceObject; + keys(): ModuleId[]; + resolve(moduleId: ModuleId): ModuleId; } @@ -79,18 +82,26 @@ function esm(exports: Exports, getters: Record any>) { /** * Makes the module an ESM with exports */ -function esmExport(module: Module, getters: Record any>) { - esm((module.namespaceObject = module.exports), getters); +function esmExport( + module: Module, + exports: Exports, + getters: Record any> +) { + esm((module.namespaceObject = exports), getters); } /** * Dynamically exports properties from an object */ -function dynamicExport(module: Module, object: Record) { +function dynamicExport( + module: Module, + exports: Exports, + object: Record +) { let reexportedObjects = module[REEXPORTED_OBJECTS]; if (!reexportedObjects) { reexportedObjects = module[REEXPORTED_OBJECTS] = []; - module.exports = module.namespaceObject = new Proxy(module.exports, { + module.exports = module.namespaceObject = new Proxy(exports, { get(target, prop) { if ( hasOwnProperty.call(target, prop) || @@ -142,6 +153,8 @@ const getProto: (obj: any) => any = Object.getPrototypeOf const LEAF_PROTOTYPES = [null, getProto({}), getProto([]), getProto(getProto)]; /** + * @param raw + * @param ns * @param allowExportDefault * * `false`: will have the raw module as default export * * `true`: will have the default property as default export @@ -168,11 +181,37 @@ function interopEsm( esm(ns, getters); } -function esmImport(sourceModule: Module, id: ModuleId): EsmNamespaceObject { +function esmImport( + sourceModule: Module, + id: ModuleId +): EsmNamespaceObject | (Promise & AsyncModuleExt) { const module = getOrInstantiateModuleFromParent(id, sourceModule); if (module.error) throw module.error; if (module.namespaceObject) return module.namespaceObject; const raw = module.exports; + + if (isPromise(raw)) { + const promise = raw.then((e) => { + const ns = {}; + interopEsm(e, ns, e.__esModule); + return ns; + }); + + module.namespaceObject = Object.assign(promise, { + get [turbopackExports]() { + return raw[turbopackExports]; + }, + get [turbopackQueues]() { + return raw[turbopackQueues]; + }, + get [turbopackError]() { + return raw[turbopackError]; + }, + } satisfies AsyncModuleExt); + + return module.namespaceObject; + } + const ns = (module.namespaceObject = {}); interopEsm(raw, ns, raw.__esModule); return ns; @@ -227,3 +266,169 @@ function requireContext( function getChunkPath(chunkData: ChunkData): ChunkPath { return typeof chunkData === "string" ? chunkData : chunkData.path; } + +function isPromise(maybePromise: any): maybePromise is Promise { + return ( + maybePromise != null && + typeof maybePromise === "object" && + "then" in maybePromise && + typeof maybePromise.then === "function" + ); +} + +function createPromise() { + let resolve: (value: T | PromiseLike) => void; + let reject: (reason?: any) => void; + + const promise = new Promise((res, rej) => { + reject = rej; + resolve = res; + }); + + return { + promise, + resolve: resolve!, + reject: reject!, + }; +} + +// everything below is adapted from webpack +// https://github.com/webpack/webpack/blob/6be4065ade1e252c1d8dcba4af0f43e32af1bdc1/lib/runtime/AsyncModuleRuntimeModule.js#L13 + +const turbopackQueues = Symbol("turbopack queues"); +const turbopackExports = Symbol("turbopack exports"); +const turbopackError = Symbol("turbopack error"); + +type AsyncQueueFn = (() => void) & { queueCount: number }; +type AsyncQueue = AsyncQueueFn[] & { resolved: boolean }; + +function resolveQueue(queue?: AsyncQueue) { + if (queue && !queue.resolved) { + queue.resolved = true; + queue.forEach((fn) => fn.queueCount--); + queue.forEach((fn) => (fn.queueCount-- ? fn.queueCount++ : fn())); + } +} + +type Dep = Exports | AsyncModulePromise | Promise; + +type AsyncModuleExt = { + [turbopackQueues]: (fn: (queue: AsyncQueue) => void) => void; + [turbopackExports]: Exports; + [turbopackError]?: any; +}; + +type AsyncModulePromise = Promise & AsyncModuleExt; + +function wrapDeps(deps: Dep[]): AsyncModuleExt[] { + return deps.map((dep) => { + if (dep !== null && typeof dep === "object") { + if (turbopackQueues in dep) return dep; + if (isPromise(dep)) { + const queue: AsyncQueue = Object.assign([], { resolved: false }); + + const obj: AsyncModuleExt = { + [turbopackExports]: {}, + [turbopackQueues]: (fn: (queue: AsyncQueue) => void) => fn(queue), + }; + + dep.then( + (res) => { + obj[turbopackExports] = res; + resolveQueue(queue); + }, + (err) => { + obj[turbopackError] = err; + resolveQueue(queue); + } + ); + + return obj; + } + } + + const ret: AsyncModuleExt = { + [turbopackExports]: dep, + [turbopackQueues]: () => {}, + }; + + return ret; + }); +} + +function asyncModule( + module: Module, + body: ( + handleAsyncDependencies: ( + deps: Dep[] + ) => Exports[] | Promise<() => Exports[]>, + asyncResult: (err?: any) => void + ) => void, + hasAwait: boolean +) { + const queue: AsyncQueue | undefined = hasAwait + ? Object.assign([], { resolved: true }) + : undefined; + + const depQueues: Set = new Set(); + const exports = module.exports; + + const { resolve, reject, promise: rawPromise } = createPromise(); + + const promise: AsyncModulePromise = Object.assign(rawPromise, { + [turbopackExports]: exports, + [turbopackQueues]: (fn) => { + queue && fn(queue); + depQueues.forEach(fn); + promise["catch"](() => {}); + }, + } satisfies AsyncModuleExt); + + module.exports = promise; + + function handleAsyncDependencies(deps: Dep[]) { + const currentDeps = wrapDeps(deps); + + const getResult = () => + currentDeps.map((d) => { + if (d[turbopackError]) throw d[turbopackError]; + return d[turbopackExports]; + }); + + const { promise, resolve } = createPromise<() => Exports[]>(); + + const fn: AsyncQueueFn = Object.assign(() => resolve(getResult), { + queueCount: 0, + }); + + function fnQueue(q: AsyncQueue) { + if (q !== queue && !depQueues.has(q)) { + depQueues.add(q); + if (q && !q.resolved) { + fn.queueCount++; + q.push(fn); + } + } + } + + currentDeps.map((dep) => dep[turbopackQueues](fnQueue)); + + return fn.queueCount ? promise : getResult(); + } + + function asyncResult(err?: any) { + if (err) { + reject((promise[turbopackError] = err)); + } else { + resolve(exports); + } + + resolveQueue(queue); + } + + body(handleAsyncDependencies, asyncResult); + + if (queue) { + queue.resolved = false; + } +} diff --git a/crates/turbopack-ecmascript/src/analyzer/top_level_await.rs b/crates/turbopack-ecmascript/src/analyzer/top_level_await.rs index 507980c3ea554..61d44e29c0473 100644 --- a/crates/turbopack-ecmascript/src/analyzer/top_level_await.rs +++ b/crates/turbopack-ecmascript/src/analyzer/top_level_await.rs @@ -1,19 +1,24 @@ -use swc_core::ecma::{ - ast::*, - visit::{noop_visit_type, Visit, VisitWith}, +use swc_core::{ + common::Span, + ecma::{ + ast::*, + visit::{noop_visit_type, Visit, VisitWith}, + }, }; -pub(crate) fn has_top_level_await(m: &Program) -> bool { +/// Checks if the program contains a top level await, if it does it will returns +/// the span of the first await. +pub(crate) fn has_top_level_await(m: &Program) -> Option { let mut visitor = TopLevelAwaitVisitor::default(); m.visit_with(&mut visitor); - visitor.has_top_level_await + visitor.top_level_await_span } #[derive(Default)] struct TopLevelAwaitVisitor { - has_top_level_await: bool, + top_level_await_span: Option, } macro_rules! noop { @@ -23,8 +28,10 @@ macro_rules! noop { } impl Visit for TopLevelAwaitVisitor { - fn visit_await_expr(&mut self, _: &AwaitExpr) { - self.has_top_level_await = true; + fn visit_await_expr(&mut self, n: &AwaitExpr) { + if self.top_level_await_span.is_none() { + self.top_level_await_span = Some(n.span); + } } // prevent non top level items from visiting their children diff --git a/crates/turbopack-ecmascript/src/chunk/item.rs b/crates/turbopack-ecmascript/src/chunk/item.rs index 5e457a5845df1..a6ade5f7f6378 100644 --- a/crates/turbopack-ecmascript/src/chunk/item.rs +++ b/crates/turbopack-ecmascript/src/chunk/item.rs @@ -18,6 +18,7 @@ use turbopack_core::{ use super::{EcmascriptChunkPlaceable, EcmascriptChunkingContext}; use crate::{ manifest::{chunk_asset::ManifestChunkAsset, loader_item::ManifestLoaderItem}, + references::async_module::{AsyncModuleOptions, OptionAsyncModuleOptions}, utils::FormatIter, EcmascriptModuleContent, ParseResultSourceMap, }; @@ -37,6 +38,7 @@ impl EcmascriptChunkItemContent { pub async fn new( content: Vc, context: Vc>, + async_module_options: Vc, ) -> Result> { let refresh = *context.has_react_refresh().await?; let externals = *context.environment().node_externals().await?; @@ -46,9 +48,12 @@ impl EcmascriptChunkItemContent { inner_code: content.inner_code.clone(), source_map: content.source_map, options: if content.is_esm { + let async_module = async_module_options.await?.clone_value(); + EcmascriptChunkItemOptions { refresh, externals, + async_module, ..Default::default() } } else { @@ -84,8 +89,12 @@ impl EcmascriptChunkItemContent { // HACK "__dirname", ]; + if this.options.async_module.is_some() { + args.push("a: __turbopack_async_module__"); + } if this.options.externals { args.push("x: __turbopack_external_require__"); + args.push("y: __turbopack_external_import__"); } if this.options.refresh { args.push("k: __turbopack_refresh__"); @@ -104,8 +113,23 @@ impl EcmascriptChunkItemContent { write!(code, "(({{ {} }}) => (() => {{\n\n", args,)?; } + if this.options.async_module.is_some() { + code += "__turbopack_async_module__(async (__turbopack_handle_async_dependencies__, \ + __turbopack_async_result__) => { try {"; + } + let source_map = this.source_map.map(Vc::upcast); code.push_source(&this.inner_code, source_map); + + if let Some(opts) = &this.options.async_module { + write!( + code, + "__turbopack_async_result__();\n}} catch(e) {{ __turbopack_async_result__(e); }} \ + }}, {});", + opts.has_top_level_await + )?; + } + if this.options.this { code += "\n}.call(this) })"; } else { @@ -129,6 +153,9 @@ pub struct EcmascriptChunkItemOptions { /// Whether this chunk item's module factory should include a /// `__turbopack_external_require__` argument. pub externals: bool, + /// Whether this chunk item's module is async (either has a top level await + /// or is importing async modules). + pub async_module: Option, pub this: bool, pub placeholder_for_future_extensions: (), } diff --git a/crates/turbopack-ecmascript/src/chunk/placeable.rs b/crates/turbopack-ecmascript/src/chunk/placeable.rs index 6c3c95d3b414a..31a563ed3ca61 100644 --- a/crates/turbopack-ecmascript/src/chunk/placeable.rs +++ b/crates/turbopack-ecmascript/src/chunk/placeable.rs @@ -2,7 +2,7 @@ use turbo_tasks::Vc; use turbopack_core::{asset::Asset, chunk::ChunkableModule, module::Module}; use super::{item::EcmascriptChunkItem, EcmascriptChunkingContext}; -use crate::references::esm::EsmExports; +use crate::references::{async_module::OptionAsyncModuleOptions, esm::EsmExports}; #[turbo_tasks::value_trait] pub trait EcmascriptChunkPlaceable: ChunkableModule + Module + Asset { @@ -11,6 +11,9 @@ pub trait EcmascriptChunkPlaceable: ChunkableModule + Module + Asset { context: Vc>, ) -> Vc>; fn get_exports(self: Vc) -> Vc; + fn get_async_module_options(&self) -> Vc { + Vc::cell(None) + } } #[turbo_tasks::value(transparent)] diff --git a/crates/turbopack-ecmascript/src/lib.rs b/crates/turbopack-ecmascript/src/lib.rs index fcac1d70590aa..1e851a9f1f0ac 100644 --- a/crates/turbopack-ecmascript/src/lib.rs +++ b/crates/turbopack-ecmascript/src/lib.rs @@ -73,7 +73,10 @@ use self::{ tree_shake::asset::EcmascriptModulePartAsset, }; use crate::{ - chunk::EcmascriptChunkPlaceable, references::analyze_ecmascript_module, + chunk::EcmascriptChunkPlaceable, references::{ + analyze_ecmascript_module, + async_module::{OptionAsyncModuleOptions}, + }, transform::remove_shebang, }; @@ -121,7 +124,7 @@ struct MemoizedSuccessfulAnalysis { operation: RawVc, references: ReadRef, exports: ReadRef, - has_top_level_await: bool, + async_module_options: ReadRef, } pub struct EcmascriptModuleAssetBuilder { @@ -307,13 +310,13 @@ impl EcmascriptModuleAsset { // We need to store the ReadRefs since we want to keep a snapshot. references: result_value.references.await?, exports: result_value.exports.await?, - has_top_level_await: result_value.has_top_level_await, + async_module_options: result_value.async_module_options.await?, })); } else if let Some(MemoizedSuccessfulAnalysis { operation, references, exports, - has_top_level_await, + async_module_options, }) = &*this.last_successful_analysis.get() { // It's important to connect to the last operation here to keep it active, so @@ -323,7 +326,7 @@ impl EcmascriptModuleAsset { references: ReadRef::cell(references.clone()), exports: ReadRef::cell(exports.clone()), code_generation: result_value.code_generation, - has_top_level_await: *has_top_level_await, + async_module_options: ReadRef::cell(async_module_options.clone()), successful: false, } .cell()); @@ -442,6 +445,13 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleAsset { async fn get_exports(self: Vc) -> Result> { Ok(self.failsafe_analyze().await?.exports) } + + #[turbo_tasks::function] + async fn get_async_module_options( + self_vc: EcmascriptModuleAssetVc, + ) -> Result { + Ok(self_vc.failsafe_analyze().await?.async_module_options) + } } #[turbo_tasks::value_impl] @@ -511,7 +521,13 @@ impl EcmascriptChunkItem for ModuleChunkItem { ) -> Result> { let this = self.await?; let content = this.module.module_content(this.context, availability_info); - Ok(EcmascriptChunkItemContent::new(content, this.context)) + let async_module_options = this.module.get_async_module_options(); + + Ok(EcmascriptChunkItemContent::new( + content, + this.context, + async_module_options, + )) } } diff --git a/crates/turbopack-ecmascript/src/references/async_module.rs b/crates/turbopack-ecmascript/src/references/async_module.rs new file mode 100644 index 0000000000000..d4943df238ccb --- /dev/null +++ b/crates/turbopack-ecmascript/src/references/async_module.rs @@ -0,0 +1,149 @@ +use anyhow::Result; +use indexmap::IndexSet; +use serde::{Deserialize, Serialize}; +use swc_core::{ + common::DUMMY_SP, + ecma::ast::{ArrayLit, ArrayPat, Expr, Ident, Pat, Program}, + quote, +}; +use turbo_tasks::{primitives::BoolVc, trace::TraceRawVcs, TryJoinIterExt}; + +use crate::{ + chunk::EcmascriptChunkingContextVc, + code_gen::{CodeGenerateable, CodeGeneration, CodeGenerationVc}, + create_visitor, + references::esm::{base::insert_hoisted_stmt, EsmAssetReferenceVc}, + CodeGenerateableVc, +}; + +#[derive(PartialEq, Eq, Default, Debug, Clone, Serialize, Deserialize, TraceRawVcs)] +pub struct AsyncModuleOptions { + pub has_top_level_await: bool, +} + +#[turbo_tasks::value(transparent)] +pub struct OptionAsyncModuleOptions(Option); + +#[turbo_tasks::value_impl] +impl OptionAsyncModuleOptionsVc { + #[turbo_tasks::function] + pub(super) async fn is_async(self) -> Result { + Ok(BoolVc::cell(self.await?.is_some())) + } +} + +#[turbo_tasks::value(shared)] +pub struct AsyncModule { + pub(super) references: IndexSet, + pub(super) has_top_level_await: bool, +} + +#[turbo_tasks::value(transparent)] +pub struct OptionAsyncModule(Option); + +#[turbo_tasks::value_impl] +impl AsyncModuleVc { + #[turbo_tasks::function] + pub(super) async fn is_async(self) -> Result { + let this = self.await?; + + if this.has_top_level_await { + return Ok(BoolVc::cell(this.has_top_level_await)); + } + + let references_async = this + .references + .iter() + .map(|r| async { anyhow::Ok(*r.is_async().await?) }) + .try_join() + .await?; + + Ok(BoolVc::cell(references_async.contains(&true))) + } + + #[turbo_tasks::function] + pub(crate) async fn module_options(self) -> Result { + if !*self.is_async().await? { + return Ok(OptionAsyncModuleOptionsVc::cell(None)); + } + + Ok(OptionAsyncModuleOptionsVc::cell(Some(AsyncModuleOptions { + has_top_level_await: self.await?.has_top_level_await, + }))) + } +} + +#[turbo_tasks::value_impl] +impl CodeGenerateable for AsyncModule { + #[turbo_tasks::function] + async fn code_generation( + self_vc: AsyncModuleVc, + _context: EcmascriptChunkingContextVc, + ) -> Result { + let this = self_vc.await?; + let mut visitors = Vec::new(); + + if *self_vc.is_async().await? { + let reference_idents: Vec> = this + .references + .iter() + .map(|r| async { + let referenced_asset = r.get_referenced_asset().await?; + let ident = referenced_asset.get_ident().await?; + anyhow::Ok(ident) + }) + .try_join() + .await?; + + let reference_idents = reference_idents + .into_iter() + .flatten() + .collect::>(); + + if !reference_idents.is_empty() { + visitors.push(create_visitor!(visit_mut_program(program: &mut Program) { + add_async_dependency_handler(program, &reference_idents); + })); + } + } + + Ok(CodeGeneration { visitors }.into()) + } +} + +fn add_async_dependency_handler(program: &mut Program, idents: &IndexSet) { + let idents = idents + .iter() + .map(|ident| Ident::new(ident.clone().into(), DUMMY_SP)) + .collect::>(); + + let stmt = quote!( + "var __turbopack_async_dependencies__ = __turbopack_handle_async_dependencies__($deps);" + as Stmt, + deps: Expr = Expr::Array(ArrayLit { + span: DUMMY_SP, + elems: idents + .iter() + .map(|ident| { Some(Expr::Ident(ident.clone()).into()) }) + .collect(), + }), + ); + + insert_hoisted_stmt(program, stmt); + + let stmt = quote!( + "($deps = __turbopack_async_dependencies__.then ? (await \ + __turbopack_async_dependencies__)() : __turbopack_async_dependencies__);" as Stmt, + deps: Pat = Pat::Array(ArrayPat { + span: DUMMY_SP, + elems: idents + .into_iter() + .map(|ident| { Some(ident.into()) }) + .collect(), + optional: false, + type_ann: None, + }), + ); + + insert_hoisted_stmt(program, stmt); +} diff --git a/crates/turbopack-ecmascript/src/references/esm/base.rs b/crates/turbopack-ecmascript/src/references/esm/base.rs index 7ee9645cd9e89..7f4991bf55c92 100644 --- a/crates/turbopack-ecmascript/src/references/esm/base.rs +++ b/crates/turbopack-ecmascript/src/references/esm/base.rs @@ -118,16 +118,6 @@ impl EsmAssetReference { #[turbo_tasks::value_impl] impl EsmAssetReference { - #[turbo_tasks::function] - pub(crate) async fn get_referenced_asset(self: Vc) -> Result> { - let this = self.await?; - - Ok(ReferencedAsset::from_resolve_result( - self.resolve_reference(), - this.request, - )) - } - #[turbo_tasks::function] pub fn new( origin: Vc>, @@ -142,6 +132,31 @@ impl EsmAssetReference { export_name, }) } + + #[turbo_tasks::function] + pub(crate) async fn get_referenced_asset(self: Vc) -> Result> { + let this = self.await?; + + Ok(ReferencedAssetVc::from_resolve_result( + self.resolve_reference(), + this.request, + )) + } + + #[turbo_tasks::function] + pub(crate) async fn is_async(self: Vc) -> Result> { + let asset = self.get_referenced_asset().await?; + + let placeable = match &*asset { + ReferencedAsset::Some(placeable) => placeable, + // TODO(WEB-1259): we need to detect if external modules are esm + ReferencedAsset::OriginalReferenceTypeExternal(_) | ReferencedAsset::None => { + return Ok(BoolVc::cell(false)); + } + }; + + Ok(placeable.get_async_module_options().is_async()) + } } #[turbo_tasks::value_impl] diff --git a/crates/turbopack-ecmascript/src/references/mod.rs b/crates/turbopack-ecmascript/src/references/mod.rs index 990a29b444813..c4a8dde521304 100644 --- a/crates/turbopack-ecmascript/src/references/mod.rs +++ b/crates/turbopack-ecmascript/src/references/mod.rs @@ -1,4 +1,5 @@ pub mod amd; +pub mod async_module; pub mod cjs; pub mod constant_condition; pub mod constant_value; @@ -49,7 +50,7 @@ use turbo_tasks_fs::{FileJsonContent, FileSystemPath}; use turbopack_core::{ compile_time_info::{CompileTimeInfo, FreeVarReference}, error::PrettyPrintError, - issue::{IssueExt, IssueSource, OptionIssueSource}, + issue::{analyze::AnalyzeIssue, IssueExt, IssueSource, OptionIssueSource}, module::Module, reference::{AssetReference, AssetReferences, SourceMapReference}, reference_type::{CommonJsReferenceSubType, ReferenceType}, @@ -114,6 +115,7 @@ use crate::{ }, magic_identifier, references::{ + async_module::{AsyncModule, OptionAsyncModuleOptionsVc}, cjs::{CjsRequireAssetReference, CjsRequireCacheAccess, CjsRequireResolveAssetReference}, esm::{module_id::EsmModuleIdAssetReference, EsmBinding}, require_context::{RequireContextAssetReference, RequireContextMap}, @@ -130,7 +132,7 @@ pub struct AnalyzeEcmascriptModuleResult { pub references: Vc, pub code_generation: Vc, pub exports: Vc, - pub has_top_level_await: bool, + pub async_module_options: Vc, /// `true` when the analysis was successful. pub successful: bool, } @@ -167,7 +169,7 @@ pub(crate) struct AnalyzeEcmascriptModuleResultBuilder { references: IndexSet>>, code_gens: Vec, exports: EcmascriptExports, - has_top_level_await: bool, + async_module_options: Vc, successful: bool, } @@ -177,7 +179,7 @@ impl AnalyzeEcmascriptModuleResultBuilder { references: IndexSet::new(), code_gens: Vec::new(), exports: EcmascriptExports::None, - has_top_level_await: false, + async_module_options: Vc::cell(None), successful: false, } } @@ -216,9 +218,9 @@ impl AnalyzeEcmascriptModuleResultBuilder { self.exports = exports; } - /// Sets whether the analysed module has a top level await. - pub fn set_top_level_await(&mut self, top_level_await: bool) { - self.has_top_level_await = top_level_await; + /// Sets the analysis result ES export. + pub fn set_async_module_options(&mut self, options: OptionAsyncModuleOptionsVc) { + self.async_module_options = options; } /// Sets whether the analysis was successful. @@ -248,7 +250,7 @@ impl AnalyzeEcmascriptModuleResultBuilder { references: Vc::cell(references), code_generation: Vc::cell(self.code_gens), exports: self.exports.into(), - has_top_level_await: self.has_top_level_await, + async_module_options: self.async_module_options, successful: self.successful, }, )) @@ -447,11 +449,6 @@ pub(crate) async fn analyze_ecmascript_module( }), ); - let has_top_level_await = - set_handler_and_globals(&handler, globals, || has_top_level_await(program)); - - analysis.set_top_level_await(has_top_level_await); - let mut var_graph = set_handler_and_globals(&handler, globals, || create_graph(program, eval_context)); @@ -565,6 +562,10 @@ pub(crate) async fn analyze_ecmascript_module( } } + let top_level_await_span = + set_handler_and_globals(&handler, globals, || has_top_level_await(program)); + let has_top_level_await = top_level_await_span.is_some(); + let exports = if !esm_exports.is_empty() || !esm_star_exports.is_empty() { if matches!(specified_type, SpecifiedModuleType::CommonJs) { SpecifiedModuleTypeIssue { @@ -575,15 +576,31 @@ pub(crate) async fn analyze_ecmascript_module( .emit(); } + let async_module = AsyncModule { + references: import_references.iter().copied().collect(), + has_top_level_await, + } + .cell(); + analysis.set_async_module_options(async_module.module_options()); + let esm_exports: Vc = EsmExports { exports: esm_exports, star_exports: esm_star_exports, } .cell(); + analysis.add_code_gen(esm_exports); + analysis.add_code_gen(async_module); EcmascriptExports::EsmExports(esm_exports) } else if matches!(specified_type, SpecifiedModuleType::EcmaScript) { + let async_module = AsyncModule { + references: import_references.iter().copied().collect(), + has_top_level_await, + } + .cell(); + analysis.set_async_module_options(async_module.module_options()); + match detect_dynamic_export(program) { DetectedDynamicExportType::CommonJs => { SpecifiedModuleTypeIssue { @@ -592,6 +609,9 @@ pub(crate) async fn analyze_ecmascript_module( } .cell() .emit(); + + analysis.add_code_gen(async_module); + EcmascriptExports::EsmExports( EsmExports { exports: Default::default(), @@ -603,30 +623,63 @@ pub(crate) async fn analyze_ecmascript_module( DetectedDynamicExportType::Namespace => EcmascriptExports::DynamicNamespace, DetectedDynamicExportType::Value => EcmascriptExports::Value, DetectedDynamicExportType::UsingModuleDeclarations - | DetectedDynamicExportType::None => EcmascriptExports::EsmExports( - EsmExports { - exports: Default::default(), - star_exports: Default::default(), - } - .cell(), - ), + | DetectedDynamicExportType::None => { + analysis.add_code_gen(async_module); + + EcmascriptExports::EsmExports( + EsmExports { + exports: Default::default(), + star_exports: Default::default(), + } + .cell(), + ) + } } } else { match detect_dynamic_export(program) { DetectedDynamicExportType::CommonJs => EcmascriptExports::CommonJs, DetectedDynamicExportType::Namespace => EcmascriptExports::DynamicNamespace, DetectedDynamicExportType::Value => EcmascriptExports::Value, - DetectedDynamicExportType::UsingModuleDeclarations => EcmascriptExports::EsmExports( - EsmExports { - exports: Default::default(), - star_exports: Default::default(), + DetectedDynamicExportType::UsingModuleDeclarations => { + let async_module = AsyncModule { + references: import_references.iter().copied().collect(), + has_top_level_await, } - .cell(), - ), + .cell(); + analysis.add_code_gen(async_module); + analysis.set_async_module_options(async_module.module_options()); + + EcmascriptExports::EsmExports( + EsmExports { + exports: Default::default(), + star_exports: Default::default(), + } + .cell(), + ) + } DetectedDynamicExportType::None => EcmascriptExports::None, } }; + if let Some(span) = top_level_await_span { + if !matches!(exports, EcmascriptExports::EsmExports(_)) { + AnalyzeIssue { + code: None, + category: StringVc::cell("analyze".to_string()), + message: StringVc::cell( + "top level await is only supported in ESM modules.".to_string(), + ), + source_ident: source.ident(), + severity: IssueSeverity::Error.into(), + source: Some(issue_source(source, span)), + title: StringVc::cell("unexpected top level await".to_string()), + } + .cell() + .as_issue() + .emit(); + } + } + analysis.set_exports(exports); let effects = take(&mut var_graph.effects); diff --git a/crates/turbopack-ecmascript/src/tree_shake/chunk_item.rs b/crates/turbopack-ecmascript/src/tree_shake/chunk_item.rs index e9f9606be71a8..03cd8a7a0885e 100644 --- a/crates/turbopack-ecmascript/src/tree_shake/chunk_item.rs +++ b/crates/turbopack-ecmascript/src/tree_shake/chunk_item.rs @@ -54,7 +54,13 @@ impl EcmascriptChunkItem for EcmascriptModulePartChunkItem { availability_info, ); - Ok(EcmascriptChunkItemContent::new(content, this.context)) + let async_module_options = module.full_module.get_async_module_options(); + + Ok(EcmascriptChunkItemContent::new( + content, + this.context, + async_module_options, + )) } #[turbo_tasks::function] diff --git a/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/Actions.js b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/Actions.js new file mode 100644 index 0000000000000..0f2170c5a2d33 --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/Actions.js @@ -0,0 +1,28 @@ +// import() doesn't care about whether a module is an async module or not +const UserApi = import("./UserAPI.js"); + +export const CreateUserAction = async (name) => { + console.log("Creating user", name); + // These are normal awaits, because they are in an async function + const { createUser } = await UserApi; + await createUser(name); +}; + +// You can place import() where you like +// Placing it at top-level will start loading and evaluating on +// module evaluation. +// see CreateUserAction above +// Here: Connecting to the DB starts when the application starts +// Placing it inside of an (async) function will start loading +// and evaluating when the function is called for the first time +// which basically makes it lazy-loaded. +// see AlternativeCreateUserAction below +// Here: Connecting to the DB starts when AlternativeCreateUserAction +// is called +export const AlternativeCreateUserAction = async (name) => { + const { createUser } = await import("./UserAPI.js"); + await createUser(name); +}; + +// Note: Using await import() at top-level doesn't make much sense +// except in rare cases. It will import modules sequentially. diff --git a/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/README.md b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/README.md new file mode 100644 index 0000000000000..723f730dc5110 --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/README.md @@ -0,0 +1,2 @@ +Adapted from webpack +https://github.com/webpack/webpack/blob/6be4065ade1e252c1d8dcba4af0f43e32af1bdc1/examples/top-level-await/README.md diff --git a/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/UserAPI.js b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/UserAPI.js new file mode 100644 index 0000000000000..810fe24f9aa7f --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/UserAPI.js @@ -0,0 +1,7 @@ +import { dbCall } from "./db-connection.js"; + +export const createUser = async (name) => { + const command = `CREATE USER ${name}`; + // This is a normal await, because it's in an async function + await dbCall({ command }); +}; diff --git a/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/db-connection.js b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/db-connection.js new file mode 100644 index 0000000000000..412eee71b72cf --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/db-connection.js @@ -0,0 +1,18 @@ +const connectToDB = async (url) => { + console.log("connecting to db", url); + await new Promise((r) => setTimeout(r, 1000)); +}; + +// This is a top-level-await +await connectToDB("my-sql://example.com"); + +export const dbCall = async (data) => { + console.log("dbCall", data); + // This is a normal await, because it's in an async function + await new Promise((r) => setTimeout(r, 100)); + return "fake data"; +}; + +export const close = () => { + console.log("closes the DB connection"); +}; diff --git a/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/index.js b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/index.js new file mode 100644 index 0000000000000..db6ef5c78f9a9 --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/index.js @@ -0,0 +1,6 @@ +import { CreateUserAction } from "./Actions.js"; + +(async () => { + await CreateUserAction("John"); + console.log("created user John"); +})(); diff --git a/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_030d34.js b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_030d34.js new file mode 100644 index 0000000000000..0695bab534948 --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_030d34.js @@ -0,0 +1,48 @@ +(globalThis.TURBOPACK = globalThis.TURBOPACK || []).push(["output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_030d34.js", { + +"[project]/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/db-connection.js (ecmascript)": (({ r: __turbopack_require__, f: __turbopack_require_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, l: __turbopack_load__, j: __turbopack_dynamic__, g: global, __dirname, a: __turbopack_async_module__, k: __turbopack_refresh__ }) => (() => { + +__turbopack_async_module__(async (__turbopack_handle_async_dependencies__, __turbopack_async_result__) => { try {__turbopack_esm__({ + "close": ()=>close, + "dbCall": ()=>dbCall +}); +const connectToDB = async (url)=>{ + console.log("connecting to db", url); + await new Promise((r)=>setTimeout(r, 1000)); +}; +await connectToDB("my-sql://example.com"); +const dbCall = async (data)=>{ + console.log("dbCall", data); + await new Promise((r)=>setTimeout(r, 100)); + return "fake data"; +}; +const close = ()=>{ + console.log("closes the DB connection"); +}; +__turbopack_async_result__(); +} catch(e) { __turbopack_async_result__(e); } }, true); +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/UserAPI.js (ecmascript)": (({ r: __turbopack_require__, f: __turbopack_require_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, l: __turbopack_load__, j: __turbopack_dynamic__, g: global, __dirname, a: __turbopack_async_module__, k: __turbopack_refresh__ }) => (() => { + +__turbopack_async_module__(async (__turbopack_handle_async_dependencies__, __turbopack_async_result__) => { try {__turbopack_esm__({ + "createUser": ()=>createUser +}); +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2f$top$2d$level$2d$await$2f$input$2f$db$2d$connection$2e$js__$28$ecmascript$29$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/db-connection.js (ecmascript)"); +var __turbopack_async_dependencies__ = __turbopack_handle_async_dependencies__([ + __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2f$top$2d$level$2d$await$2f$input$2f$db$2d$connection$2e$js__$28$ecmascript$29$__ +]); +[__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2f$top$2d$level$2d$await$2f$input$2f$db$2d$connection$2e$js__$28$ecmascript$29$__] = __turbopack_async_dependencies__.then ? (await __turbopack_async_dependencies__)() : __turbopack_async_dependencies__; +"__TURBOPACK__ecmascript__hoisting__location__"; +; +const createUser = async (name)=>{ + const command = `CREATE USER ${name}`; + await __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2f$top$2d$level$2d$await$2f$input$2f$db$2d$connection$2e$js__$28$ecmascript$29$__["dbCall"]({ + command + }); +}; +__turbopack_async_result__(); +} catch(e) { __turbopack_async_result__(e); } }, false); +})()), +}]); + +//# sourceMappingURL=crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_030d34.js.map \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_030d34.js.map b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_030d34.js.map new file mode 100644 index 0000000000000..fada634db8b2e --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_030d34.js.map @@ -0,0 +1,8 @@ +{ + "version": 3, + "sections": [ + {"offset": {"line": 4, "column": 113}, "map": {"version":3,"sources":["/turbopack/[project]/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/db-connection.js"],"sourcesContent":["const connectToDB = async (url) => {\n console.log(\"connecting to db\", url);\n await new Promise((r) => setTimeout(r, 1000));\n};\n\n// This is a top-level-await\nawait connectToDB(\"my-sql://example.com\");\n\nexport const dbCall = async (data) => {\n console.log(\"dbCall\", data);\n // This is a normal await, because it's in an async function\n await new Promise((r) => setTimeout(r, 100));\n return \"fake data\";\n};\n\nexport const close = () => {\n console.log(\"closes the DB connection\");\n};\n"],"names":[],"mappings":";;;;AAAA,MAAM,cAAc,OAAO;IACzB,QAAQ,GAAG,CAAC,oBAAoB;IAChC,MAAM,IAAI,QAAQ,CAAC,IAAM,WAAW,GAAG;AACzC;AAGA,MAAM,YAAY;AAEX,MAAM,SAAS,OAAO;IAC3B,QAAQ,GAAG,CAAC,UAAU;IAEtB,MAAM,IAAI,QAAQ,CAAC,IAAM,WAAW,GAAG;IACvC,OAAO;AACT;AAEO,MAAM,QAAQ;IACnB,QAAQ,GAAG,CAAC;AACd"}}, + {"offset": {"line": 21, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 26, "column": 113}, "map": {"version":3,"sources":["/turbopack/[project]/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/UserAPI.js"],"sourcesContent":["import { dbCall } from \"./db-connection.js\";\n\nexport const createUser = async (name) => {\n const command = `CREATE USER ${name}`;\n // This is a normal await, because it's in an async function\n await dbCall({ command });\n};\n"],"names":[],"mappings":";;;;;;;;;;AAEO,MAAM,aAAa,OAAO;IAC/B,MAAM,UAAU,CAAC,YAAY,EAAE,KAAK,CAAC;IAErC,MAAM,uMAAO;QAAE;IAAQ;AACzB"}}, + {"offset": {"line": 42, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}] +} \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_6657ac.js b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_6657ac.js new file mode 100644 index 0000000000000..8c05e55adcc78 --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_6657ac.js @@ -0,0 +1,11 @@ +(globalThis.TURBOPACK = globalThis.TURBOPACK || []).push([ + "output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_6657ac.js", + {}, +]); +(globalThis.TURBOPACK_CHUNK_LISTS = globalThis.TURBOPACK_CHUNK_LISTS || []).push({ + "path": "output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_6657ac.js", + "chunks": [ + "output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_d6e51f.js" + ], + "source": "dynamic" +}); \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_853a42.js b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_853a42.js new file mode 100644 index 0000000000000..bed5a724b7d38 --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_853a42.js @@ -0,0 +1,11 @@ +(globalThis.TURBOPACK = globalThis.TURBOPACK || []).push([ + "output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_853a42.js", + {}, +]); +(globalThis.TURBOPACK_CHUNK_LISTS = globalThis.TURBOPACK_CHUNK_LISTS || []).push({ + "path": "output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_853a42.js", + "chunks": [ + "output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_030d34.js" + ], + "source": "dynamic" +}); \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_d6e51f.js b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_d6e51f.js new file mode 100644 index 0000000000000..2b49a61144a47 --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_d6e51f.js @@ -0,0 +1,16 @@ +(globalThis.TURBOPACK = globalThis.TURBOPACK || []).push(["output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_d6e51f.js", { + +"[project]/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/UserAPI.js (ecmascript, manifest chunk)": (({ r: __turbopack_require__, f: __turbopack_require_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, l: __turbopack_load__, j: __turbopack_dynamic__, g: global, __dirname }) => (() => { + +__turbopack_export_value__([ + { + "path": "output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_030d34.js", + "included": [ + "[project]/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/UserAPI.js (ecmascript)" + ] + }, + "output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_853a42.js" +]); + +})()), +}]); \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_d6e51f.js.map b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_d6e51f.js.map new file mode 100644 index 0000000000000..a12b83d3337ca --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_d6e51f.js.map @@ -0,0 +1,4 @@ +{ + "version": 3, + "sections": [] +} \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_5771e1.js b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_5771e1.js new file mode 100644 index 0000000000000..976c8cdd3f9cf --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_5771e1.js @@ -0,0 +1,11 @@ +(globalThis.TURBOPACK = globalThis.TURBOPACK || []).push([ + "output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_5771e1.js", + {}, +]); +(globalThis.TURBOPACK_CHUNK_LISTS = globalThis.TURBOPACK_CHUNK_LISTS || []).push({ + "path": "output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_5771e1.js", + "chunks": [ + "output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_b53fce.js" + ], + "source": "entry" +}); \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_b53fce.js b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_b53fce.js new file mode 100644 index 0000000000000..cb2812fd9ae05 --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_b53fce.js @@ -0,0 +1,47 @@ +(globalThis.TURBOPACK = globalThis.TURBOPACK || []).push(["output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_b53fce.js", { + +"[project]/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/UserAPI.js (ecmascript, manifest chunk, loader)": (({ r: __turbopack_require__, f: __turbopack_require_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, l: __turbopack_load__, j: __turbopack_dynamic__, g: global, __dirname }) => (() => { + +__turbopack_export_value__((__turbopack_import__) => { + return Promise.all([{"path":"output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_d6e51f.js","included":["[project]/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/UserAPI.js (ecmascript, manifest chunk)"]},"output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_UserAPI_6657ac.js"].map((chunk) => __turbopack_load__(chunk))).then(() => { + return __turbopack_require__("[project]/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/UserAPI.js (ecmascript, manifest chunk)"); + }).then((chunks) => { + return Promise.all(chunks.map((chunk) => __turbopack_load__(chunk))); + }).then(() => { + return __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/UserAPI.js (ecmascript)"); + }); +}); + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/Actions.js (ecmascript)": (({ r: __turbopack_require__, f: __turbopack_require_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, l: __turbopack_load__, j: __turbopack_dynamic__, g: global, __dirname, k: __turbopack_refresh__ }) => (() => { + +__turbopack_esm__({ + "AlternativeCreateUserAction": ()=>AlternativeCreateUserAction, + "CreateUserAction": ()=>CreateUserAction +}); +const UserApi = __turbopack_require__("[project]/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/UserAPI.js (ecmascript, manifest chunk, loader)")(__turbopack_import__); +const CreateUserAction = async (name)=>{ + console.log("Creating user", name); + const { createUser } = await UserApi; + await createUser(name); +}; +const AlternativeCreateUserAction = async (name)=>{ + const { createUser } = await __turbopack_require__("[project]/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/UserAPI.js (ecmascript, manifest chunk, loader)")(__turbopack_import__); + await createUser(name); +}; + +})()), +"[project]/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/index.js (ecmascript)": (({ r: __turbopack_require__, f: __turbopack_require_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, l: __turbopack_load__, j: __turbopack_dynamic__, g: global, __dirname, k: __turbopack_refresh__ }) => (() => { + +var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2f$top$2d$level$2d$await$2f$input$2f$Actions$2e$js__$28$ecmascript$29$__ = __turbopack_import__("[project]/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/Actions.js (ecmascript)"); +"__TURBOPACK__ecmascript__hoisting__location__"; +; +(async ()=>{ + await __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2f$top$2d$level$2d$await$2f$input$2f$Actions$2e$js__$28$ecmascript$29$__["CreateUserAction"]("John"); + console.log("created user John"); +})(); + +})()), +}]); + +//# sourceMappingURL=crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_b53fce.js.map \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_b53fce.js.map b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_b53fce.js.map new file mode 100644 index 0000000000000..071ae668d4723 --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_b53fce.js.map @@ -0,0 +1,8 @@ +{ + "version": 3, + "sections": [ + {"offset": {"line": 17, "column": 0}, "map": {"version":3,"sources":["/turbopack/[project]/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/Actions.js"],"sourcesContent":["// import() doesn't care about whether a module is an async module or not\nconst UserApi = import(\"./UserAPI.js\");\n\nexport const CreateUserAction = async (name) => {\n console.log(\"Creating user\", name);\n // These are normal awaits, because they are in an async function\n const { createUser } = await UserApi;\n await createUser(name);\n};\n\n// You can place import() where you like\n// Placing it at top-level will start loading and evaluating on\n// module evaluation.\n// see CreateUserAction above\n// Here: Connecting to the DB starts when the application starts\n// Placing it inside of an (async) function will start loading\n// and evaluating when the function is called for the first time\n// which basically makes it lazy-loaded.\n// see AlternativeCreateUserAction below\n// Here: Connecting to the DB starts when AlternativeCreateUserAction\n// is called\nexport const AlternativeCreateUserAction = async (name) => {\n const { createUser } = await import(\"./UserAPI.js\");\n await createUser(name);\n};\n\n// Note: Using await import() at top-level doesn't make much sense\n// except in rare cases. It will import modules sequentially.\n"],"names":[],"mappings":";;;;AACA,MAAM,UAAU;AAET,MAAM,mBAAmB,OAAO;IACrC,QAAQ,GAAG,CAAC,iBAAiB;IAE7B,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM;IAC7B,MAAM,WAAW;AACnB;AAaO,MAAM,8BAA8B,OAAO;IAChD,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM;IAC7B,MAAM,WAAW;AACnB"}}, + {"offset": {"line": 31, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}, + {"offset": {"line": 35, "column": 0}, "map": {"version":3,"sources":["/turbopack/[project]/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/index.js"],"sourcesContent":["import { CreateUserAction } from \"./Actions.js\";\n\n(async () => {\n await CreateUserAction(\"John\");\n console.log(\"created user John\");\n})();\n"],"names":[],"mappings":";;;AAEC,CAAA;IACC,MAAM,wMAAiB;IACvB,QAAQ,GAAG,CAAC;AACd,CAAA"}}, + {"offset": {"line": 42, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}] +} \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_d8ac4f.js b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_d8ac4f.js new file mode 100644 index 0000000000000..7906e87cf8af4 --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_d8ac4f.js @@ -0,0 +1,6 @@ +(globalThis.TURBOPACK = globalThis.TURBOPACK || []).push([ + "output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_d8ac4f.js", + {}, + {"otherChunks":[{"path":"output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_b53fce.js","included":["[project]/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/index.js (ecmascript)"]}],"runtimeModuleIds":["[project]/crates/turbopack-tests/tests/snapshot/basic/top-level-await/input/index.js (ecmascript)"]} +]); +// Dummy runtime \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_d8ac4f.js.map b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_d8ac4f.js.map new file mode 100644 index 0000000000000..a12b83d3337ca --- /dev/null +++ b/crates/turbopack-tests/tests/snapshot/basic/top-level-await/output/crates_turbopack-tests_tests_snapshot_basic_top-level-await_input_index_d8ac4f.js.map @@ -0,0 +1,4 @@ +{ + "version": 3, + "sections": [] +} \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/node/node_protocol_external/output/79fb1_turbopack-tests_tests_snapshot_node_node_protocol_external_input_index_b53fce.js b/crates/turbopack-tests/tests/snapshot/node/node_protocol_external/output/79fb1_turbopack-tests_tests_snapshot_node_node_protocol_external_input_index_b53fce.js index 000224a78745d..4994c0316cad4 100644 --- a/crates/turbopack-tests/tests/snapshot/node/node_protocol_external/output/79fb1_turbopack-tests_tests_snapshot_node_node_protocol_external_input_index_b53fce.js +++ b/crates/turbopack-tests/tests/snapshot/node/node_protocol_external/output/79fb1_turbopack-tests_tests_snapshot_node_node_protocol_external_input_index_b53fce.js @@ -1,6 +1,6 @@ (globalThis.TURBOPACK = globalThis.TURBOPACK || []).push(["output/79fb1_turbopack-tests_tests_snapshot_node_node_protocol_external_input_index_b53fce.js", { -"[project]/crates/turbopack-tests/tests/snapshot/node/node_protocol_external/input/index.js (ecmascript)": (({ r: __turbopack_require__, f: __turbopack_require_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, l: __turbopack_load__, j: __turbopack_dynamic__, g: global, __dirname, x: __turbopack_external_require__, k: __turbopack_refresh__ }) => (() => { +"[project]/crates/turbopack-tests/tests/snapshot/node/node_protocol_external/input/index.js (ecmascript)": (({ r: __turbopack_require__, f: __turbopack_require_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, l: __turbopack_load__, j: __turbopack_dynamic__, g: global, __dirname, x: __turbopack_external_require__, y: __turbopack_external_import__, k: __turbopack_refresh__ }) => (() => { var __TURBOPACK__external__node$3a$fs__ = __turbopack_external_require__("node:fs", true); "__TURBOPACK__ecmascript__hoisting__location__"; From 764eeefe42741065e30f8cbdc810b329ed6d182e Mon Sep 17 00:00:00 2001 From: hrmny Date: Tue, 4 Jul 2023 19:50:23 +0200 Subject: [PATCH 02/16] only await async dependencies --- .../src/references/async_module.rs | 60 +++++++++++-------- 1 file changed, 35 insertions(+), 25 deletions(-) diff --git a/crates/turbopack-ecmascript/src/references/async_module.rs b/crates/turbopack-ecmascript/src/references/async_module.rs index d4943df238ccb..764ccc7bc34c7 100644 --- a/crates/turbopack-ecmascript/src/references/async_module.rs +++ b/crates/turbopack-ecmascript/src/references/async_module.rs @@ -41,8 +41,38 @@ pub struct AsyncModule { #[turbo_tasks::value(transparent)] pub struct OptionAsyncModule(Option); +#[turbo_tasks::value(transparent)] +pub struct AsyncModuleIdents(IndexSet); + #[turbo_tasks::value_impl] impl AsyncModuleVc { + #[turbo_tasks::function] + pub(super) async fn get_async_idents(self) -> Result { + let this = self.await?; + + let reference_idents: Vec> = this + .references + .iter() + .map(|r| async { + let referenced_asset = r.get_referenced_asset().await?; + let ident = if *r.is_async().await? { + referenced_asset.get_ident().await? + } else { + None + }; + anyhow::Ok(ident) + }) + .try_join() + .await?; + + let reference_idents = reference_idents + .into_iter() + .flatten() + .collect::>(); + + Ok(AsyncModuleIdentsVc::cell(reference_idents)) + } + #[turbo_tasks::function] pub(super) async fn is_async(self) -> Result { let this = self.await?; @@ -51,14 +81,9 @@ impl AsyncModuleVc { return Ok(BoolVc::cell(this.has_top_level_await)); } - let references_async = this - .references - .iter() - .map(|r| async { anyhow::Ok(*r.is_async().await?) }) - .try_join() - .await?; + let async_idents = self.get_async_idents().await?; - Ok(BoolVc::cell(references_async.contains(&true))) + Ok(BoolVc::cell(!async_idents.is_empty())) } #[turbo_tasks::function] @@ -80,29 +105,14 @@ impl CodeGenerateable for AsyncModule { self_vc: AsyncModuleVc, _context: EcmascriptChunkingContextVc, ) -> Result { - let this = self_vc.await?; let mut visitors = Vec::new(); if *self_vc.is_async().await? { - let reference_idents: Vec> = this - .references - .iter() - .map(|r| async { - let referenced_asset = r.get_referenced_asset().await?; - let ident = referenced_asset.get_ident().await?; - anyhow::Ok(ident) - }) - .try_join() - .await?; - - let reference_idents = reference_idents - .into_iter() - .flatten() - .collect::>(); + let async_idents = self_vc.get_async_idents().await?; - if !reference_idents.is_empty() { + if !async_idents.is_empty() { visitors.push(create_visitor!(visit_mut_program(program: &mut Program) { - add_async_dependency_handler(program, &reference_idents); + add_async_dependency_handler(program, &async_idents); })); } } From 9264862004d3b911b14eb3c428bec64cd232af17 Mon Sep 17 00:00:00 2001 From: hrmny Date: Tue, 4 Jul 2023 19:54:34 +0200 Subject: [PATCH 03/16] always add code gen in esm modules --- .../src/references/mod.rs | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/crates/turbopack-ecmascript/src/references/mod.rs b/crates/turbopack-ecmascript/src/references/mod.rs index c4a8dde521304..2b1c8680ed5a6 100644 --- a/crates/turbopack-ecmascript/src/references/mod.rs +++ b/crates/turbopack-ecmascript/src/references/mod.rs @@ -600,6 +600,7 @@ pub(crate) async fn analyze_ecmascript_module( } .cell(); analysis.set_async_module_options(async_module.module_options()); + analysis.add_code_gen(async_module); match detect_dynamic_export(program) { DetectedDynamicExportType::CommonJs => { @@ -610,8 +611,6 @@ pub(crate) async fn analyze_ecmascript_module( .cell() .emit(); - analysis.add_code_gen(async_module); - EcmascriptExports::EsmExports( EsmExports { exports: Default::default(), @@ -623,17 +622,13 @@ pub(crate) async fn analyze_ecmascript_module( DetectedDynamicExportType::Namespace => EcmascriptExports::DynamicNamespace, DetectedDynamicExportType::Value => EcmascriptExports::Value, DetectedDynamicExportType::UsingModuleDeclarations - | DetectedDynamicExportType::None => { - analysis.add_code_gen(async_module); - - EcmascriptExports::EsmExports( - EsmExports { - exports: Default::default(), - star_exports: Default::default(), - } - .cell(), - ) - } + | DetectedDynamicExportType::None => EcmascriptExports::EsmExports( + EsmExports { + exports: Default::default(), + star_exports: Default::default(), + } + .cell(), + ), } } else { match detect_dynamic_export(program) { From a8e21613aca77fd6b98fbcb317e57a862eadad2a Mon Sep 17 00:00:00 2001 From: hrmny Date: Wed, 5 Jul 2023 20:06:08 +0200 Subject: [PATCH 04/16] make sure we only add the async module symbols if the dependency exports an async module promise --- .../js/src/shared/runtime-utils.ts | 80 +++++++++++++------ 1 file changed, 55 insertions(+), 25 deletions(-) diff --git a/crates/turbopack-ecmascript-runtime/js/src/shared/runtime-utils.ts b/crates/turbopack-ecmascript-runtime/js/src/shared/runtime-utils.ts index da75a61f5aac4..10e6fa1cbefca 100644 --- a/crates/turbopack-ecmascript-runtime/js/src/shared/runtime-utils.ts +++ b/crates/turbopack-ecmascript-runtime/js/src/shared/runtime-utils.ts @@ -20,13 +20,16 @@ type EsmNamespaceObject = Record; const REEXPORTED_OBJECTS = Symbol("reexported objects"); interface BaseModule { - exports: Exports | AsyncModulePromise; + exports: Exports | Promise | AsyncModulePromise; error: Error | undefined; loaded: boolean; id: ModuleId; children: ModuleId[]; parents: ModuleId[]; - namespaceObject?: EsmNamespaceObject | AsyncModulePromise; + namespaceObject?: + | EsmNamespaceObject + | Promise + | AsyncModulePromise; [REEXPORTED_OBJECTS]?: any[]; } @@ -101,7 +104,8 @@ function dynamicExport( let reexportedObjects = module[REEXPORTED_OBJECTS]; if (!reexportedObjects) { reexportedObjects = module[REEXPORTED_OBJECTS] = []; - module.exports = module.namespaceObject = new Proxy(exports, { + + const namespaceObject = new Proxy(exports, { get(target, prop) { if ( hasOwnProperty.call(target, prop) || @@ -126,6 +130,18 @@ function dynamicExport( return keys; }, }); + + // `exports` passed to this function will always be an object, + // `module.exports` might have been turned into a promise + // if this is inside an async module. + if (isPromise(module.exports)) { + module.exports = module.namespaceObject = maybeWrapAsyncModulePromise( + module.exports, + () => namespaceObject + ); + } else { + module.exports = module.namespaceObject = namespaceObject; + } } reexportedObjects.push(object); } @@ -179,42 +195,27 @@ function interopEsm( getters["default"] = () => raw; } esm(ns, getters); + return ns; } function esmImport( sourceModule: Module, id: ModuleId -): EsmNamespaceObject | (Promise & AsyncModuleExt) { +): Exclude { const module = getOrInstantiateModuleFromParent(id, sourceModule); if (module.error) throw module.error; if (module.namespaceObject) return module.namespaceObject; const raw = module.exports; if (isPromise(raw)) { - const promise = raw.then((e) => { - const ns = {}; - interopEsm(e, ns, e.__esModule); - return ns; - }); - - module.namespaceObject = Object.assign(promise, { - get [turbopackExports]() { - return raw[turbopackExports]; - }, - get [turbopackQueues]() { - return raw[turbopackQueues]; - }, - get [turbopackError]() { - return raw[turbopackError]; - }, - } satisfies AsyncModuleExt); + module.namespaceObject = maybeWrapAsyncModulePromise(raw, (e) => + interopEsm(e, {}, e.__esModule) + ); return module.namespaceObject; } - const ns = (module.namespaceObject = {}); - interopEsm(raw, ns, raw.__esModule); - return ns; + return (module.namespaceObject = interopEsm(raw, {}, raw.__esModule)); } function commonJsRequire(sourceModule: Module, id: ModuleId): Exports { @@ -276,6 +277,35 @@ function isPromise(maybePromise: any): maybePromise is Promise { ); } +function isAsyncModuleExt(obj: T): obj is AsyncModuleExt & T { + return turbopackQueues in obj; +} + +function maybeWrapAsyncModulePromise( + promise: Promise, + then: (val: T) => U | PromiseLike +): typeof promise extends AsyncModulePromise + ? AsyncModulePromise + : Promise { + const newPromise = promise.then(then); + + if (isAsyncModuleExt(promise)) { + Object.assign(newPromise, { + get [turbopackExports]() { + return promise[turbopackExports]; + }, + get [turbopackQueues]() { + return promise[turbopackQueues]; + }, + get [turbopackError]() { + return promise[turbopackError]; + }, + } satisfies AsyncModuleExt); + } + + return newPromise as any; +} + function createPromise() { let resolve: (value: T | PromiseLike) => void; let reject: (reason?: any) => void; @@ -323,7 +353,7 @@ type AsyncModulePromise = Promise & AsyncModuleExt; function wrapDeps(deps: Dep[]): AsyncModuleExt[] { return deps.map((dep) => { if (dep !== null && typeof dep === "object") { - if (turbopackQueues in dep) return dep; + if (isAsyncModuleExt(dep)) return dep; if (isPromise(dep)) { const queue: AsyncQueue = Object.assign([], { resolved: false }); From 794f2aa1bf0927f254023f8165e3cc5406596b2a Mon Sep 17 00:00:00 2001 From: hrmny Date: Wed, 5 Jul 2023 20:21:12 +0200 Subject: [PATCH 05/16] merge external require of the build runtime and dev node runtime --- .../js/src/build/runtime.ts | 49 ++---------------- .../runtime/nodejs/runtime-backend-nodejs.ts | 48 +----------------- .../js/src/shared-node/require.ts | 50 +++++++++++++++++++ .../js/src/shared-node/tsconfig.json | 8 +++ .../src/build_runtime.rs | 18 ++----- .../src/dev_runtime.rs | 50 ++++++++----------- .../src/embed_js.rs | 7 +++ .../output/[turbopack]_runtime.js | 36 ++++++------- 8 files changed, 115 insertions(+), 151 deletions(-) create mode 100644 crates/turbopack-ecmascript-runtime/js/src/shared-node/require.ts create mode 100644 crates/turbopack-ecmascript-runtime/js/src/shared-node/tsconfig.json diff --git a/crates/turbopack-ecmascript-runtime/js/src/build/runtime.ts b/crates/turbopack-ecmascript-runtime/js/src/build/runtime.ts index feefe129b20f7..d3b2331d1ed7f 100644 --- a/crates/turbopack-ecmascript-runtime/js/src/build/runtime.ts +++ b/crates/turbopack-ecmascript-runtime/js/src/build/runtime.ts @@ -1,4 +1,5 @@ /// +/// declare var RUNTIME_PUBLIC_PATH: string; @@ -24,14 +25,12 @@ type SourceInfo = parentId: ModuleId; }; -interface RequireContextEntry { - external: boolean; -} - type ExternalRequire = (id: ModuleId) => Exports | EsmNamespaceObject; +type ExternalImport = (id: ModuleId) => Promise; interface TurbopackNodeBuildContext extends TurbopackBaseContext { x: ExternalRequire; + y: ExternalImport; } type ModuleFactory = ( @@ -46,47 +45,6 @@ const RUNTIME_ROOT = path.resolve(__filename, relativePathToRuntimeRoot); const moduleFactories: ModuleFactories = Object.create(null); const moduleCache: ModuleCache = Object.create(null); -function commonJsRequireContext( - entry: RequireContextEntry, - sourceModule: Module -): Exports { - return entry.external - ? externalRequire(entry.id(), false) - : commonJsRequire(sourceModule, entry.id()); -} - -function externalRequire( - id: ModuleId, - esm: boolean = false -): Exports | EsmNamespaceObject { - let raw; - try { - raw = require(id); - } catch (err) { - // TODO(alexkirsz) This can happen when a client-side module tries to load - // an external module we don't provide a shim for (e.g. querystring, url). - // For now, we fail semi-silently, but in the future this should be a - // compilation error. - throw new Error(`Failed to load external module ${id}: ${err}`); - } - if (!esm || raw.__esModule) { - return raw; - } - const ns = {}; - interopEsm(raw, ns, true); - return ns; -} -externalRequire.resolve = ( - id: string, - options?: - | { - paths?: string[] | undefined; - } - | undefined -) => { - return require.resolve(id, options); -}; - function loadChunk(chunkPath: ChunkPath) { if (!chunkPath.endsWith(".js")) { // We only support loading JS chunks in Node.js. @@ -167,6 +125,7 @@ function instantiateModule(id: ModuleId, source: SourceInfo): Module { e: module.exports, r: commonJsRequire.bind(null, module), x: externalRequire, + y: externalImport, f: requireContext.bind(null, module), i: esmImport.bind(null, module), s: esm.bind(null, module.exports), diff --git a/crates/turbopack-ecmascript-runtime/js/src/dev/runtime/nodejs/runtime-backend-nodejs.ts b/crates/turbopack-ecmascript-runtime/js/src/dev/runtime/nodejs/runtime-backend-nodejs.ts index 0449e30421d1c..6a6abca245e9c 100644 --- a/crates/turbopack-ecmascript-runtime/js/src/dev/runtime/nodejs/runtime-backend-nodejs.ts +++ b/crates/turbopack-ecmascript-runtime/js/src/dev/runtime/nodejs/runtime-backend-nodejs.ts @@ -6,6 +6,7 @@ */ /// +/// interface RequireContextEntry { // Only the Node.js backend has this flag. @@ -15,56 +16,11 @@ interface RequireContextEntry { type ExternalRequire = (id: ModuleId) => Exports | EsmNamespaceObject; type ExternalImport = (id: ModuleId) => Promise; -interface TurbopackDevContext { +interface TurbopackDevContext extends TurbopackDevBaseContext { x: ExternalRequire; y: ExternalImport; } -function commonJsRequireContext( - entry: RequireContextEntry, - sourceModule: Module -): Exports { - return entry.external - ? externalRequire(entry.id(), false) - : commonJsRequire(sourceModule, entry.id()); -} - -function externalImport(id: ModuleId) { - return import(id) -} - -function externalRequire( - id: ModuleId, - esm: boolean = false -): Exports | EsmNamespaceObject { - let raw; - try { - raw = require(id); - } catch (err) { - // TODO(alexkirsz) This can happen when a client-side module tries to load - // an external module we don't provide a shim for (e.g. querystring, url). - // For now, we fail semi-silently, but in the future this should be a - // compilation error. - throw new Error(`Failed to load external module ${id}: ${err}`); - } - if (!esm) { - return raw; - } - const ns = {}; - interopEsm(raw, ns, raw.__esModule); - return ns; -} -externalRequire.resolve = ( - id: string, - options?: - | { - paths?: string[] | undefined; - } - | undefined -) => { - return require.resolve(id, options); -}; - function augmentContext(context: TurbopackDevBaseContext): TurbopackDevContext { const nodejsContext = context as TurbopackDevContext; nodejsContext.x = externalRequire; diff --git a/crates/turbopack-ecmascript-runtime/js/src/shared-node/require.ts b/crates/turbopack-ecmascript-runtime/js/src/shared-node/require.ts new file mode 100644 index 0000000000000..64e51367b3885 --- /dev/null +++ b/crates/turbopack-ecmascript-runtime/js/src/shared-node/require.ts @@ -0,0 +1,50 @@ +/// + +interface RequireContextEntry { + external: boolean; +} + +function commonJsRequireContext( + entry: RequireContextEntry, + sourceModule: Module +): Exports { + return entry.external + ? externalRequire(entry.id(), false) + : commonJsRequire(sourceModule, entry.id()); +} + +function externalImport(id: ModuleId) { + return import(id); +} + +function externalRequire( + id: ModuleId, + esm: boolean = false +): Exports | EsmNamespaceObject { + let raw; + try { + raw = require(id); + } catch (err) { + // TODO(alexkirsz) This can happen when a client-side module tries to load + // an external module we don't provide a shim for (e.g. querystring, url). + // For now, we fail semi-silently, but in the future this should be a + // compilation error. + throw new Error(`Failed to load external module ${id}: ${err}`); + } + + if (!esm || raw.__esModule) { + return raw; + } + + return interopEsm(raw, {}, true); +} +externalRequire.resolve = ( + id: string, + options?: + | { + paths?: string[] | undefined; + } + | undefined +) => { + return require.resolve(id, options); +}; diff --git a/crates/turbopack-ecmascript-runtime/js/src/shared-node/tsconfig.json b/crates/turbopack-ecmascript-runtime/js/src/shared-node/tsconfig.json new file mode 100644 index 0000000000000..f8b2080f48e96 --- /dev/null +++ b/crates/turbopack-ecmascript-runtime/js/src/shared-node/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../tsconfig.base.json", + "compilerOptions": { + // environment + "lib": ["ESNext"] + }, + "include": ["*.ts"] +} diff --git a/crates/turbopack-ecmascript-runtime/src/build_runtime.rs b/crates/turbopack-ecmascript-runtime/src/build_runtime.rs index 0fb899ff793e6..da24c42344500 100644 --- a/crates/turbopack-ecmascript-runtime/src/build_runtime.rs +++ b/crates/turbopack-ecmascript-runtime/src/build_runtime.rs @@ -4,29 +4,21 @@ use turbopack_core::{ code_builder::{Code, CodeBuilder}, environment::Environment, }; -use turbopack_ecmascript::StaticEcmascriptCode; -use crate::{asset_context::get_runtime_asset_context, embed_file_path}; +use crate::{asset_context::get_runtime_asset_context, embed_js::embed_static_code}; /// Returns the code for the Node.js production ECMAScript runtime. #[turbo_tasks::function] pub async fn get_build_runtime_code(environment: Vc) -> Result> { let asset_context = get_runtime_asset_context(environment); - let shared_runtime_utils_code = StaticEcmascriptCode::new( - asset_context, - embed_file_path("shared/runtime-utils.ts".to_string()), - ) - .code(); - - let runtime_code = StaticEcmascriptCode::new( - asset_context, - embed_file_path("build/runtime.ts".to_string()), - ) - .code(); + let shared_runtime_utils_code = embed_static_code(asset_context, "shared/runtime-utils.ts"); + let shared_node_utils_code = embed_static_code(asset_context, "shared-node/require.ts"); + let runtime_code = embed_static_code(asset_context, "build/runtime.ts"); let mut code = CodeBuilder::default(); code.push_code(&*shared_runtime_utils_code.await?); + code.push_code(&*shared_node_utils_code.await?); code.push_code(&*runtime_code.await?); Ok(Code::cell(code.build())) diff --git a/crates/turbopack-ecmascript-runtime/src/dev_runtime.rs b/crates/turbopack-ecmascript-runtime/src/dev_runtime.rs index 7dfda8d741caf..80fcf8bcdfa8a 100644 --- a/crates/turbopack-ecmascript-runtime/src/dev_runtime.rs +++ b/crates/turbopack-ecmascript-runtime/src/dev_runtime.rs @@ -8,9 +8,9 @@ use turbopack_core::{ context::AssetContext, environment::{ChunkLoading, Environment}, }; -use turbopack_ecmascript::{utils::StringifyJs, StaticEcmascriptCode}; +use turbopack_ecmascript::utils::StringifyJs; -use crate::{asset_context::get_runtime_asset_context, embed_file_path}; +use crate::{asset_context::get_runtime_asset_context, embed_js::embed_static_code}; /// Returns the code for the development ECMAScript runtime. #[turbo_tasks::function] @@ -20,38 +20,23 @@ pub async fn get_dev_runtime_code( ) -> Result> { let asset_context = get_runtime_asset_context(environment); - let shared_runtime_utils_code = StaticEcmascriptCode::new( - asset_context, - embed_file_path("shared/runtime-utils.ts".to_string()), - ) - .code(); + let shared_runtime_utils_code = embed_static_code(asset_context, "shared/runtime-utils.ts"); + let runtime_base_code = embed_static_code(asset_context, "dev/runtime/base/runtime-base.ts"); - let runtime_base_code = StaticEcmascriptCode::new( - asset_context, - embed_file_path("dev/runtime/base/runtime-base.ts".to_string()), - ) - .code(); + let chunk_loading = &*asset_context + .compile_time_info() + .environment() + .chunk_loading() + .await?; - let runtime_backend_code = StaticEcmascriptCode::new( + let runtime_backend_code = embed_static_code( asset_context, - match &*asset_context - .compile_time_info() - .environment() - .chunk_loading() - .await? - { - ChunkLoading::None => { - embed_file_path("dev/runtime/none/runtime-backend-none.ts".to_string()) - } - ChunkLoading::NodeJs => { - embed_file_path("dev/runtime/nodejs/runtime-backend-nodejs.ts".to_string()) - } - ChunkLoading::Dom => { - embed_file_path("dev/runtime/dom/runtime-backend-dom.ts".to_string()) - } + match chunk_loading { + ChunkLoading::None => "dev/runtime/none/runtime-backend-none.ts", + ChunkLoading::NodeJs => "dev/runtime/nodejs/runtime-backend-nodejs.ts", + ChunkLoading::Dom => "dev/runtime/dom/runtime-backend-dom.ts", }, - ) - .code(); + ); let mut code: CodeBuilder = CodeBuilder::default(); @@ -74,6 +59,11 @@ pub async fn get_dev_runtime_code( code.push_code(&*shared_runtime_utils_code.await?); code.push_code(&*runtime_base_code.await?); + + if matches!(chunk_loading, ChunkLoading::NodeJs) { + code.push_code(&*embed_static_code(asset_context, "shared-node/require.ts").await?); + } + code.push_code(&*runtime_backend_code.await?); // Registering chunks depends on the BACKEND variable, which is set by the diff --git a/crates/turbopack-ecmascript-runtime/src/embed_js.rs b/crates/turbopack-ecmascript-runtime/src/embed_js.rs index 383a63b5472a5..baa95d47ed7b3 100644 --- a/crates/turbopack-ecmascript-runtime/src/embed_js.rs +++ b/crates/turbopack-ecmascript-runtime/src/embed_js.rs @@ -1,5 +1,7 @@ use turbo_tasks::Vc; use turbo_tasks_fs::{embed_directory, FileContent, FileSystem, FileSystemPath}; +use turbopack_core::{code_builder::Code, context::AssetContext}; +use turbopack_ecmascript::StaticEcmascriptCode; #[turbo_tasks::function] pub fn embed_fs() -> Vc> { @@ -15,3 +17,8 @@ pub fn embed_file(path: String) -> Vc { pub fn embed_file_path(path: String) -> Vc { embed_fs().root().join(path) } + +#[turbo_tasks::function] +pub fn embed_static_code(asset_context: Vc, path: &str) -> Vc { + StaticEcmascriptCode::new(asset_context, embed_file_path(path)).code() +} diff --git a/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js b/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js index 9fb0cde1f22e3..b70a35ec5a2fd 100644 --- a/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js +++ b/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js @@ -121,38 +121,39 @@ function getChunkPath(chunkData) { return typeof chunkData === "string" ? chunkData : chunkData.path; } ; -var SourceType; -(function(SourceType) { - SourceType[SourceType["Runtime"] = 0] = "Runtime"; - SourceType[SourceType["Parent"] = 1] = "Parent"; -})(SourceType || (SourceType = {})); -; -; -const path = require("path"); -const relativePathToRuntimeRoot = path.relative(RUNTIME_PUBLIC_PATH, "."); -const RUNTIME_ROOT = path.resolve(__filename, relativePathToRuntimeRoot); -const moduleFactories = Object.create(null); -const moduleCache = Object.create(null); function commonJsRequireContext(entry, sourceModule) { return entry.external ? externalRequire(entry.id(), false) : commonJsRequire(sourceModule, entry.id()); } -function externalRequire(id, esm1 = false) { +function externalImport(id) { + return import(id); +} +function externalRequire(id, esm = false) { let raw; try { raw = require(id); } catch (err) { throw new Error(`Failed to load external module ${id}: ${err}`); } - if (!esm1 || raw.__esModule) { + if (!esm || raw.__esModule) { return raw; } - const ns = {}; - interopEsm(raw, ns, true); - return ns; + return interopEsm(raw, {}, true); } externalRequire.resolve = (id, options)=>{ return require.resolve(id, options); }; +; +var SourceType; +(function(SourceType) { + SourceType[SourceType["Runtime"] = 0] = "Runtime"; + SourceType[SourceType["Parent"] = 1] = "Parent"; +})(SourceType || (SourceType = {})); +; +const path = require("path"); +const relativePathToRuntimeRoot = path.relative(RUNTIME_PUBLIC_PATH, "."); +const RUNTIME_ROOT = path.resolve(__filename, relativePathToRuntimeRoot); +const moduleFactories = Object.create(null); +const moduleCache = Object.create(null); function loadChunk(chunkPath) { if (!chunkPath.endsWith(".js")) { return; @@ -217,6 +218,7 @@ function instantiateModule(id, source) { e: module1.exports, r: commonJsRequire.bind(null, module1), x: externalRequire, + y: externalImport, f: requireContext.bind(null, module1), i: esmImport.bind(null, module1), s: esm.bind(null, module1.exports), From d91516a78d81d6897e8804290e17eb3138248e8f Mon Sep 17 00:00:00 2001 From: hrmny Date: Thu, 6 Jul 2023 00:26:51 +0200 Subject: [PATCH 06/16] fix bugs in runtime --- .../js/src/shared/runtime-utils.ts | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/crates/turbopack-ecmascript-runtime/js/src/shared/runtime-utils.ts b/crates/turbopack-ecmascript-runtime/js/src/shared/runtime-utils.ts index 10e6fa1cbefca..be6bd1c3ba630 100644 --- a/crates/turbopack-ecmascript-runtime/js/src/shared/runtime-utils.ts +++ b/crates/turbopack-ecmascript-runtime/js/src/shared/runtime-utils.ts @@ -90,7 +90,8 @@ function esmExport( exports: Exports, getters: Record any> ) { - esm((module.namespaceObject = exports), getters); + module.namespaceObject = module.exports; + esm(exports, getters); } /** @@ -131,12 +132,11 @@ function dynamicExport( }, }); - // `exports` passed to this function will always be an object, - // `module.exports` might have been turned into a promise - // if this is inside an async module. - if (isPromise(module.exports)) { + // If this is inside an async module `module.namespaceObject` is a promise, + // so we need to replace it with a new promise. + if (isPromise(module.namespaceObject)) { module.exports = module.namespaceObject = maybeWrapAsyncModulePromise( - module.exports, + module.namespaceObject, () => namespaceObject ); } else { @@ -204,18 +204,17 @@ function esmImport( ): Exclude { const module = getOrInstantiateModuleFromParent(id, sourceModule); if (module.error) throw module.error; - if (module.namespaceObject) return module.namespaceObject; - const raw = module.exports; - - if (isPromise(raw)) { - module.namespaceObject = maybeWrapAsyncModulePromise(raw, (e) => - interopEsm(e, {}, e.__esModule) - ); - return module.namespaceObject; - } + // any async module has to have `module.namespaceObject` defined + if (module.namespaceObject) return module.namespaceObject; - return (module.namespaceObject = interopEsm(raw, {}, raw.__esModule)); + // can't be an async module at this point + const raw = module.exports; + return (module.namespaceObject = interopEsm( + raw, + {}, + (raw as any).__esModule + )); } function commonJsRequire(sourceModule: Module, id: ModuleId): Exports { @@ -414,7 +413,7 @@ function asyncModule( }, } satisfies AsyncModuleExt); - module.exports = promise; + module.exports = module.namespaceObject = promise; function handleAsyncDependencies(deps: Dep[]) { const currentDeps = wrapDeps(deps); From efd908ba992a8adefa55175d2e9341a0aee80c59 Mon Sep 17 00:00:00 2001 From: hrmny Date: Thu, 6 Jul 2023 00:27:01 +0200 Subject: [PATCH 07/16] add basic tla execution test --- .../basic/top-level-await/input/Actions.js | 28 +++++++++++++++++++ .../basic/top-level-await/input/README.md | 2 ++ .../basic/top-level-await/input/UserAPI.js | 7 +++++ .../top-level-await/input/db-connection.js | 18 ++++++++++++ .../basic/top-level-await/input/index.js | 11 ++++++++ 5 files changed, 66 insertions(+) create mode 100644 crates/turbopack-tests/tests/execution/turbopack/basic/top-level-await/input/Actions.js create mode 100644 crates/turbopack-tests/tests/execution/turbopack/basic/top-level-await/input/README.md create mode 100644 crates/turbopack-tests/tests/execution/turbopack/basic/top-level-await/input/UserAPI.js create mode 100644 crates/turbopack-tests/tests/execution/turbopack/basic/top-level-await/input/db-connection.js create mode 100644 crates/turbopack-tests/tests/execution/turbopack/basic/top-level-await/input/index.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/basic/top-level-await/input/Actions.js b/crates/turbopack-tests/tests/execution/turbopack/basic/top-level-await/input/Actions.js new file mode 100644 index 0000000000000..0628b7be26331 --- /dev/null +++ b/crates/turbopack-tests/tests/execution/turbopack/basic/top-level-await/input/Actions.js @@ -0,0 +1,28 @@ +// import() doesn't care about whether a module is an async module or not +const UserApi = import("./UserAPI.js"); + +export const CreateUserAction = async (name) => { + console.log("Creating user", name); + // These are normal awaits, because they are in an async function + const { createUser } = await UserApi; + return await createUser(name); +}; + +// You can place import() where you like +// Placing it at top-level will start loading and evaluating on +// module evaluation. +// see CreateUserAction above +// Here: Connecting to the DB starts when the application starts +// Placing it inside of an (async) function will start loading +// and evaluating when the function is called for the first time +// which basically makes it lazy-loaded. +// see AlternativeCreateUserAction below +// Here: Connecting to the DB starts when AlternativeCreateUserAction +// is called +export const AlternativeCreateUserAction = async (name) => { + const { createUser } = await import("./UserAPI.js"); + return await createUser(name); +}; + +// Note: Using await import() at top-level doesn't make much sense +// except in rare cases. It will import modules sequentially. diff --git a/crates/turbopack-tests/tests/execution/turbopack/basic/top-level-await/input/README.md b/crates/turbopack-tests/tests/execution/turbopack/basic/top-level-await/input/README.md new file mode 100644 index 0000000000000..723f730dc5110 --- /dev/null +++ b/crates/turbopack-tests/tests/execution/turbopack/basic/top-level-await/input/README.md @@ -0,0 +1,2 @@ +Adapted from webpack +https://github.com/webpack/webpack/blob/6be4065ade1e252c1d8dcba4af0f43e32af1bdc1/examples/top-level-await/README.md diff --git a/crates/turbopack-tests/tests/execution/turbopack/basic/top-level-await/input/UserAPI.js b/crates/turbopack-tests/tests/execution/turbopack/basic/top-level-await/input/UserAPI.js new file mode 100644 index 0000000000000..8fd6a1ff927f0 --- /dev/null +++ b/crates/turbopack-tests/tests/execution/turbopack/basic/top-level-await/input/UserAPI.js @@ -0,0 +1,7 @@ +import { dbCall } from "./db-connection.js"; + +export const createUser = async (name) => { + const command = `CREATE USER ${name}`; + // This is a normal await, because it's in an async function + return await dbCall({ command }); +}; diff --git a/crates/turbopack-tests/tests/execution/turbopack/basic/top-level-await/input/db-connection.js b/crates/turbopack-tests/tests/execution/turbopack/basic/top-level-await/input/db-connection.js new file mode 100644 index 0000000000000..412eee71b72cf --- /dev/null +++ b/crates/turbopack-tests/tests/execution/turbopack/basic/top-level-await/input/db-connection.js @@ -0,0 +1,18 @@ +const connectToDB = async (url) => { + console.log("connecting to db", url); + await new Promise((r) => setTimeout(r, 1000)); +}; + +// This is a top-level-await +await connectToDB("my-sql://example.com"); + +export const dbCall = async (data) => { + console.log("dbCall", data); + // This is a normal await, because it's in an async function + await new Promise((r) => setTimeout(r, 100)); + return "fake data"; +}; + +export const close = () => { + console.log("closes the DB connection"); +}; diff --git a/crates/turbopack-tests/tests/execution/turbopack/basic/top-level-await/input/index.js b/crates/turbopack-tests/tests/execution/turbopack/basic/top-level-await/input/index.js new file mode 100644 index 0000000000000..c0fd41050c19f --- /dev/null +++ b/crates/turbopack-tests/tests/execution/turbopack/basic/top-level-await/input/index.js @@ -0,0 +1,11 @@ +import { CreateUserAction, AlternativeCreateUserAction } from "./Actions.js"; + +it("should handle top level await", async () => { + const res = await CreateUserAction("John"); + expect(res).toBe("fake data"); +}); + +it("should handle top level await (alternative)", async () => { + const res = await AlternativeCreateUserAction("John"); + expect(res).toBe("fake data"); +}); From 48724b5d34944a9d10cca8a1ef3786fe096d8585 Mon Sep 17 00:00:00 2001 From: hrmny Date: Sat, 8 Jul 2023 03:43:20 +0200 Subject: [PATCH 08/16] shitty fix for import cycles --- Cargo.lock | 1 + crates/turbo-tasks-build/src/lib.rs | 1 - crates/turbo-tasks-bytes/src/stream.rs | 10 ++ .../js/src/shared/runtime-utils.ts | 4 + crates/turbopack-ecmascript/Cargo.toml | 1 + .../src/chunk/placeable.rs | 4 +- crates/turbopack-ecmascript/src/lib.rs | 16 +- .../src/references/async_module.rs | 152 +++++++++++++++--- .../src/references/esm/base.rs | 19 +-- .../src/references/mod.rs | 18 +-- .../src/tree_shake/chunk_item.rs | 2 +- crates/turbopack-tests/build.rs | 3 +- crates/turbopack-tests/tests/execution.rs | 16 +- .../top-level-await/input/db-connection.js | 2 +- 14 files changed, 192 insertions(+), 57 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5b7b87eb474dd..6977544d82b47 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9325,6 +9325,7 @@ dependencies = [ "anyhow", "async-trait", "criterion", + "futures", "indexmap", "indoc", "lazy_static", diff --git a/crates/turbo-tasks-build/src/lib.rs b/crates/turbo-tasks-build/src/lib.rs index dd83adf84ffe8..7a11b7b386342 100644 --- a/crates/turbo-tasks-build/src/lib.rs +++ b/crates/turbo-tasks-build/src/lib.rs @@ -165,7 +165,6 @@ pub fn rerun_if_glob(globs: &str, root: &str) { let cwd = env::current_dir().unwrap(); let globs = cwd.join(globs.replace('/', PATH_SEP.to_string().as_str())); let root = cwd.join(root.replace('/', PATH_SEP.to_string().as_str())); - println!("cargo:rerun-if-changed={}", root.display()); let mut seen = HashSet::from([root]); for entry in glob(globs.to_str().unwrap()).unwrap() { let path = entry.unwrap(); diff --git a/crates/turbo-tasks-bytes/src/stream.rs b/crates/turbo-tasks-bytes/src/stream.rs index 602d3b0470abb..c51518702e3ac 100644 --- a/crates/turbo-tasks-bytes/src/stream.rs +++ b/crates/turbo-tasks-bytes/src/stream.rs @@ -99,6 +99,16 @@ pub enum SingleValue { Single(T), } +impl fmt::Debug for SingleValue { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + SingleValue::None => f.debug_struct("SingleValue::None").finish(), + SingleValue::Multiple => f.debug_struct("SingleValue::Multiple").finish(), + SingleValue::Single(v) => f.debug_tuple("SingleValue::Single").field(v).finish(), + } + } +} + impl + Send + Unpin + 'static> From for Stream { fn from(source: S) -> Self { Self::new_open(vec![], Box::new(source)) diff --git a/crates/turbopack-ecmascript-runtime/js/src/shared/runtime-utils.ts b/crates/turbopack-ecmascript-runtime/js/src/shared/runtime-utils.ts index be6bd1c3ba630..b5d03185c7973 100644 --- a/crates/turbopack-ecmascript-runtime/js/src/shared/runtime-utils.ts +++ b/crates/turbopack-ecmascript-runtime/js/src/shared/runtime-utils.ts @@ -191,9 +191,13 @@ function interopEsm( getters[key] = createGetter(raw, key); } } + + // this is not really correct + // we should set the `default` getter if the imported module is a `.cjs file` if (!(allowExportDefault && "default" in getters)) { getters["default"] = () => raw; } + esm(ns, getters); return ns; } diff --git a/crates/turbopack-ecmascript/Cargo.toml b/crates/turbopack-ecmascript/Cargo.toml index 534545f43efa8..57d77a30dd09e 100644 --- a/crates/turbopack-ecmascript/Cargo.toml +++ b/crates/turbopack-ecmascript/Cargo.toml @@ -12,6 +12,7 @@ bench = false [dependencies] anyhow = { workspace = true } async-trait = { workspace = true } +futures = { workspace = true } indexmap = { workspace = true } indoc = { workspace = true } lazy_static = { workspace = true } diff --git a/crates/turbopack-ecmascript/src/chunk/placeable.rs b/crates/turbopack-ecmascript/src/chunk/placeable.rs index 31a563ed3ca61..cf285bc984eb0 100644 --- a/crates/turbopack-ecmascript/src/chunk/placeable.rs +++ b/crates/turbopack-ecmascript/src/chunk/placeable.rs @@ -2,7 +2,7 @@ use turbo_tasks::Vc; use turbopack_core::{asset::Asset, chunk::ChunkableModule, module::Module}; use super::{item::EcmascriptChunkItem, EcmascriptChunkingContext}; -use crate::references::{async_module::OptionAsyncModuleOptions, esm::EsmExports}; +use crate::references::{async_module::OptionAsyncModule, esm::EsmExports}; #[turbo_tasks::value_trait] pub trait EcmascriptChunkPlaceable: ChunkableModule + Module + Asset { @@ -11,7 +11,7 @@ pub trait EcmascriptChunkPlaceable: ChunkableModule + Module + Asset { context: Vc>, ) -> Vc>; fn get_exports(self: Vc) -> Vc; - fn get_async_module_options(&self) -> Vc { + fn get_async_module_options(&self) -> Vc { Vc::cell(None) } } diff --git a/crates/turbopack-ecmascript/src/lib.rs b/crates/turbopack-ecmascript/src/lib.rs index 1e851a9f1f0ac..9fc567c21fade 100644 --- a/crates/turbopack-ecmascript/src/lib.rs +++ b/crates/turbopack-ecmascript/src/lib.rs @@ -124,7 +124,7 @@ struct MemoizedSuccessfulAnalysis { operation: RawVc, references: ReadRef, exports: ReadRef, - async_module_options: ReadRef, + async_module_options: ReadRef, } pub struct EcmascriptModuleAssetBuilder { @@ -310,13 +310,13 @@ impl EcmascriptModuleAsset { // We need to store the ReadRefs since we want to keep a snapshot. references: result_value.references.await?, exports: result_value.exports.await?, - async_module_options: result_value.async_module_options.await?, + async_module: result_value.async_module.await?, })); } else if let Some(MemoizedSuccessfulAnalysis { operation, references, exports, - async_module_options, + async_module, }) = &*this.last_successful_analysis.get() { // It's important to connect to the last operation here to keep it active, so @@ -326,7 +326,7 @@ impl EcmascriptModuleAsset { references: ReadRef::cell(references.clone()), exports: ReadRef::cell(exports.clone()), code_generation: result_value.code_generation, - async_module_options: ReadRef::cell(async_module_options.clone()), + async_module: ReadRef::cell(async_module.clone()), successful: false, } .cell()); @@ -447,10 +447,8 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleAsset { } #[turbo_tasks::function] - async fn get_async_module_options( - self_vc: EcmascriptModuleAssetVc, - ) -> Result { - Ok(self_vc.failsafe_analyze().await?.async_module_options) + async fn get_async_module(self_vc: EcmascriptModuleAssetVc) -> Result { + Ok(self_vc.failsafe_analyze().await?.async_module) } } @@ -521,7 +519,7 @@ impl EcmascriptChunkItem for ModuleChunkItem { ) -> Result> { let this = self.await?; let content = this.module.module_content(this.context, availability_info); - let async_module_options = this.module.get_async_module_options(); + let async_module_options = this.module.get_async_module().module_options(); Ok(EcmascriptChunkItemContent::new( content, diff --git a/crates/turbopack-ecmascript/src/references/async_module.rs b/crates/turbopack-ecmascript/src/references/async_module.rs index 764ccc7bc34c7..d5807609d5677 100644 --- a/crates/turbopack-ecmascript/src/references/async_module.rs +++ b/crates/turbopack-ecmascript/src/references/async_module.rs @@ -1,4 +1,7 @@ +use std::future::IntoFuture; + use anyhow::Result; +use futures::{stream::FuturesOrdered, TryStreamExt}; use indexmap::IndexSet; use serde::{Deserialize, Serialize}; use swc_core::{ @@ -6,13 +9,16 @@ use swc_core::{ ecma::ast::{ArrayLit, ArrayPat, Expr, Ident, Pat, Program}, quote, }; -use turbo_tasks::{primitives::BoolVc, trace::TraceRawVcs, TryJoinIterExt}; +use turbo_tasks::{primitives::BoolVc, trace::TraceRawVcs, TryFlatJoinIterExt}; use crate::{ - chunk::EcmascriptChunkingContextVc, + chunk::{EcmascriptChunkPlaceable, EcmascriptChunkingContextVc}, code_gen::{CodeGenerateable, CodeGeneration, CodeGenerationVc}, create_visitor, - references::esm::{base::insert_hoisted_stmt, EsmAssetReferenceVc}, + references::esm::{ + base::{insert_hoisted_stmt, ReferencedAsset}, + EsmAssetReferenceVc, + }, CodeGenerateableVc, }; @@ -27,7 +33,12 @@ pub struct OptionAsyncModuleOptions(Option); #[turbo_tasks::value_impl] impl OptionAsyncModuleOptionsVc { #[turbo_tasks::function] - pub(super) async fn is_async(self) -> Result { + pub(crate) fn none() -> Self { + Self::cell(None) + } + + #[turbo_tasks::function] + pub(crate) async fn is_async(self) -> Result { Ok(BoolVc::cell(self.await?.is_some())) } } @@ -38,52 +49,157 @@ pub struct AsyncModule { pub(super) has_top_level_await: bool, } +#[turbo_tasks::value(transparent)] +pub struct AsyncModules(IndexSet); + #[turbo_tasks::value(transparent)] pub struct OptionAsyncModule(Option); +#[turbo_tasks::value_impl] +impl OptionAsyncModuleVc { + #[turbo_tasks::function] + pub(crate) fn none() -> Self { + Self::cell(None) + } + + #[turbo_tasks::function] + pub(crate) async fn is_async(self) -> Result { + Ok(BoolVc::cell(self.module_options().await?.is_some())) + } + + #[turbo_tasks::function] + pub(crate) async fn module_options(self) -> Result { + if let Some(async_module) = &*self.await? { + return Ok(async_module.module_options()); + } + + Ok(OptionAsyncModuleOptionsVc::none()) + } +} + #[turbo_tasks::value(transparent)] pub struct AsyncModuleIdents(IndexSet); #[turbo_tasks::value_impl] impl AsyncModuleVc { + /// Collects all [AsyncModuleVc]s from the references and returns them + /// after resolving. + #[turbo_tasks::function] + pub(crate) async fn collect_direct_async_module_children(self) -> Result { + let this = self.await?; + + let async_modules = this + .references + .iter() + .map(|r| async { + let referenced_asset = r.get_referenced_asset().await?; + let ReferencedAsset::Some(placeable) = &*referenced_asset else { + return anyhow::Ok(None); + }; + + let Some(async_module) = &*placeable.get_async_module().await? else { + return anyhow::Ok(None); + }; + + let resolved = async_module.resolve().await?; + if resolved == self { + return anyhow::Ok(None); + }; + + anyhow::Ok(Some(resolved)) + }) + .try_flat_join() + .await?; + + Ok(AsyncModulesVc::cell(IndexSet::from_iter(async_modules))) + } + + /// Collects all [AsyncModuleVc]s referenced including the current + /// [AsyncModuleVc]. + #[turbo_tasks::function] + pub(crate) async fn collect_all_async_modules(self) -> Result { + let mut futures = FuturesOrdered::new(); + futures.push_back(self.collect_direct_async_module_children().into_future()); + + let mut async_modules = IndexSet::from([self]); + while let Some(modules) = futures.try_next().await? { + for async_module in modules.iter().copied() { + if async_modules.insert(async_module) { + futures.push_back( + async_module + .collect_direct_async_module_children() + .into_future(), + ); + } + } + } + + Ok(AsyncModulesVc::cell(async_modules)) + } + #[turbo_tasks::function] - pub(super) async fn get_async_idents(self) -> Result { + pub(crate) async fn get_async_idents(self) -> Result { let this = self.await?; - let reference_idents: Vec> = this + let reference_idents = this .references .iter() .map(|r| async { let referenced_asset = r.get_referenced_asset().await?; - let ident = if *r.is_async().await? { + let ident = if *r.is_async(true).await? { referenced_asset.get_ident().await? } else { None }; anyhow::Ok(ident) }) - .try_join() + .try_flat_join() .await?; - let reference_idents = reference_idents - .into_iter() - .flatten() - .collect::>(); - - Ok(AsyncModuleIdentsVc::cell(reference_idents)) + Ok(AsyncModuleIdentsVc::cell(IndexSet::from_iter( + reference_idents, + ))) } #[turbo_tasks::function] - pub(super) async fn is_async(self) -> Result { + pub(crate) async fn is_self_async(self) -> Result { let this = self.await?; if this.has_top_level_await { - return Ok(BoolVc::cell(this.has_top_level_await)); + return Ok(BoolVc::cell(true)); } - let async_idents = self.get_async_idents().await?; + let references = this + .references + .iter() + .map(|r| async { anyhow::Ok((*r.is_async(false).await?).then_some(())) }) + .try_flat_join() + .await?; + + Ok(BoolVc::cell(!references.is_empty())) + } + + #[turbo_tasks::function] + pub(crate) async fn is_async(self) -> Result { + if *self.is_self_async().await? { + return Ok(BoolVc::cell(true)); + } + + let async_modules = self + .collect_all_async_modules() + .await? + .iter() + .map(|a| async { + anyhow::Ok(if *a.is_self_async().await? { + Some(*a) + } else { + None + }) + }) + .try_flat_join() + .await?; - Ok(BoolVc::cell(!async_idents.is_empty())) + Ok(BoolVc::cell(!async_modules.is_empty())) } #[turbo_tasks::function] diff --git a/crates/turbopack-ecmascript/src/references/esm/base.rs b/crates/turbopack-ecmascript/src/references/esm/base.rs index 7f4991bf55c92..dd778d0f039bd 100644 --- a/crates/turbopack-ecmascript/src/references/esm/base.rs +++ b/crates/turbopack-ecmascript/src/references/esm/base.rs @@ -144,18 +144,19 @@ impl EsmAssetReference { } #[turbo_tasks::function] - pub(crate) async fn is_async(self: Vc) -> Result> { + pub(crate) async fn is_async(self: Vc, recursive: bool) -> Result> { let asset = self.get_referenced_asset().await?; - let placeable = match &*asset { - ReferencedAsset::Some(placeable) => placeable, - // TODO(WEB-1259): we need to detect if external modules are esm - ReferencedAsset::OriginalReferenceTypeExternal(_) | ReferencedAsset::None => { - return Ok(BoolVc::cell(false)); + match &*asset { + ReferencedAsset::Some(placeable) if recursive => { + Ok(placeable.get_async_module().is_async()) } - }; - - Ok(placeable.get_async_module_options().is_async()) + ReferencedAsset::OriginalReferenceTypeExternal(_) => { + // TODO(WEB-1259): we need to detect if external modules are esm + Ok(BoolVc::cell(false)) + } + ReferencedAsset::Some(_) | ReferencedAsset::None => Ok(BoolVc::cell(false)), + } } } diff --git a/crates/turbopack-ecmascript/src/references/mod.rs b/crates/turbopack-ecmascript/src/references/mod.rs index 2b1c8680ed5a6..7b78b7ee04a0f 100644 --- a/crates/turbopack-ecmascript/src/references/mod.rs +++ b/crates/turbopack-ecmascript/src/references/mod.rs @@ -115,7 +115,7 @@ use crate::{ }, magic_identifier, references::{ - async_module::{AsyncModule, OptionAsyncModuleOptionsVc}, + async_module::{AsyncModule, OptionAsyncModule}, cjs::{CjsRequireAssetReference, CjsRequireCacheAccess, CjsRequireResolveAssetReference}, esm::{module_id::EsmModuleIdAssetReference, EsmBinding}, require_context::{RequireContextAssetReference, RequireContextMap}, @@ -132,7 +132,7 @@ pub struct AnalyzeEcmascriptModuleResult { pub references: Vc, pub code_generation: Vc, pub exports: Vc, - pub async_module_options: Vc, + pub async_module_options: Vc, /// `true` when the analysis was successful. pub successful: bool, } @@ -169,7 +169,7 @@ pub(crate) struct AnalyzeEcmascriptModuleResultBuilder { references: IndexSet>>, code_gens: Vec, exports: EcmascriptExports, - async_module_options: Vc, + async_module_options: Vc, successful: bool, } @@ -219,8 +219,8 @@ impl AnalyzeEcmascriptModuleResultBuilder { } /// Sets the analysis result ES export. - pub fn set_async_module_options(&mut self, options: OptionAsyncModuleOptionsVc) { - self.async_module_options = options; + pub fn set_async_module(&mut self, async_module: AsyncModuleVc) { + self.async_module = OptionAsyncModuleVc::cell(Some(async_module)); } /// Sets whether the analysis was successful. @@ -250,7 +250,7 @@ impl AnalyzeEcmascriptModuleResultBuilder { references: Vc::cell(references), code_generation: Vc::cell(self.code_gens), exports: self.exports.into(), - async_module_options: self.async_module_options, + async_module: self.async_module, successful: self.successful, }, )) @@ -581,7 +581,7 @@ pub(crate) async fn analyze_ecmascript_module( has_top_level_await, } .cell(); - analysis.set_async_module_options(async_module.module_options()); + analysis.set_async_module(async_module); let esm_exports: Vc = EsmExports { exports: esm_exports, @@ -599,7 +599,7 @@ pub(crate) async fn analyze_ecmascript_module( has_top_level_await, } .cell(); - analysis.set_async_module_options(async_module.module_options()); + analysis.set_async_module(async_module); analysis.add_code_gen(async_module); match detect_dynamic_export(program) { @@ -641,8 +641,8 @@ pub(crate) async fn analyze_ecmascript_module( has_top_level_await, } .cell(); + analysis.set_async_module(async_module); analysis.add_code_gen(async_module); - analysis.set_async_module_options(async_module.module_options()); EcmascriptExports::EsmExports( EsmExports { diff --git a/crates/turbopack-ecmascript/src/tree_shake/chunk_item.rs b/crates/turbopack-ecmascript/src/tree_shake/chunk_item.rs index 03cd8a7a0885e..015927e535073 100644 --- a/crates/turbopack-ecmascript/src/tree_shake/chunk_item.rs +++ b/crates/turbopack-ecmascript/src/tree_shake/chunk_item.rs @@ -54,7 +54,7 @@ impl EcmascriptChunkItem for EcmascriptModulePartChunkItem { availability_info, ); - let async_module_options = module.full_module.get_async_module_options(); + let async_module_options = module.full_module.get_async_module().module_options(); Ok(EcmascriptChunkItemContent::new( content, diff --git a/crates/turbopack-tests/build.rs b/crates/turbopack-tests/build.rs index a370dda2966fc..8b2f6227bd0d3 100644 --- a/crates/turbopack-tests/build.rs +++ b/crates/turbopack-tests/build.rs @@ -5,5 +5,6 @@ fn main() { // The test/snapshot crate need to be rebuilt if any snapshots are added. // Unfortunately, we can't have the build.rs file operate differently on // each file, so the entire turbopack crate needs to be rebuilt. - rerun_if_glob("tests/{execution,snapshot}/*/*", "tests/"); + rerun_if_glob("tests/execution/*/*/*/input", "tests/"); + rerun_if_glob("tests/snapshot/*/*/input", "tests/"); } diff --git a/crates/turbopack-tests/tests/execution.rs b/crates/turbopack-tests/tests/execution.rs index 9fb37ccfc7ab6..5a00febe08b9d 100644 --- a/crates/turbopack-tests/tests/execution.rs +++ b/crates/turbopack-tests/tests/execution.rs @@ -35,7 +35,7 @@ use turbopack_core::{ source::Source, }; use turbopack_dev::DevChunkingContext; -use turbopack_node::evaluate::evaluate; +use turbopack_node::{debug::should_debug, evaluate::evaluate}; use turbopack_test_utils::jest::JestRunResult; use crate::util::REPO_ROOT; @@ -263,16 +263,20 @@ async fn run_test(resource: String) -> Result> { ])), vec![], Completion::immutable(), - false, + should_debug("execution_test"), ) .await?; - let SingleValue::Single(bytes) = res + let single = res .try_into_single() .await - .context("test node result did not emit anything")? - else { - panic!("Evaluation stream must yield SingleValue."); + .context("test node result did not emit anything")?; + + let SingleValue::Single(bytes) = single else { + panic!( + "Evaluation stream must yield SingleValue, but got: {:?}", + single + ); }; Ok(RunTestResult { diff --git a/crates/turbopack-tests/tests/execution/turbopack/basic/top-level-await/input/db-connection.js b/crates/turbopack-tests/tests/execution/turbopack/basic/top-level-await/input/db-connection.js index 412eee71b72cf..8b5e6229f462c 100644 --- a/crates/turbopack-tests/tests/execution/turbopack/basic/top-level-await/input/db-connection.js +++ b/crates/turbopack-tests/tests/execution/turbopack/basic/top-level-await/input/db-connection.js @@ -1,6 +1,6 @@ const connectToDB = async (url) => { console.log("connecting to db", url); - await new Promise((r) => setTimeout(r, 1000)); + await new Promise((r) => setTimeout(r, 100)); }; // This is a top-level-await From 5dc3a008f1d625ec57dd02144ae3f898d355ea1c Mon Sep 17 00:00:00 2001 From: hrmny Date: Wed, 12 Jul 2023 20:43:09 +0200 Subject: [PATCH 09/16] SCC stuff --- Cargo.lock | 2 + crates/turbo-tasks-macros/src/lib.rs | 67 +++++- crates/turbo-tasks/src/primitives.rs | 45 +++- crates/turbopack-cli/Cargo.toml | 3 +- crates/turbopack-core/src/issue/mod.rs | 2 +- crates/turbopack-ecmascript/src/lib.rs | 18 +- .../src/references/async_module.rs | 221 ++++++++++-------- .../src/references/esm/base.rs | 40 +++- .../src/references/mod.rs | 28 ++- .../src/tree_shake/asset.rs | 14 +- .../src/tree_shake/chunk_item.rs | 5 +- crates/turbopack-test-utils/Cargo.toml | 13 +- crates/turbopack-test-utils/src/snapshot.rs | 30 ++- crates/turbopack-tests/.gitignore | 3 +- crates/turbopack-tests/Cargo.toml | 1 + crates/turbopack-tests/tests/execution.rs | 24 +- ... source code for parsing failed-3b6255.txt | 19 +- ...rmat (CommonJs) is not matching-5fdb68.txt | 18 +- ...rmat (EcmaScript Modules) is no-34c311.txt | 17 +- crates/turbopack-tests/tests/snapshot.rs | 9 +- .../unexpected export __star__-c9d8a6.txt | 17 +- .../unexpected export __star__-38cf67.txt | 17 +- ...ving EcmaScript Modules request-aff400.txt | 23 +- 23 files changed, 364 insertions(+), 272 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6977544d82b47..6fa77172850dc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9526,6 +9526,7 @@ dependencies = [ "turbo-tasks-build", "turbo-tasks-fs", "turbo-tasks-hash", + "turbopack-cli-utils", "turbopack-core", ] @@ -9549,6 +9550,7 @@ dependencies = [ "turbo-tasks-memory", "turbopack", "turbopack-build", + "turbopack-cli-utils", "turbopack-core", "turbopack-dev", "turbopack-ecmascript-plugins", diff --git a/crates/turbo-tasks-macros/src/lib.rs b/crates/turbo-tasks-macros/src/lib.rs index 1b51ffd1d323f..a2c9ccc702c63 100644 --- a/crates/turbo-tasks-macros/src/lib.rs +++ b/crates/turbo-tasks-macros/src/lib.rs @@ -44,19 +44,74 @@ pub fn derive_task_input(input: TokenStream) -> TokenStream { /// Creates a Vc struct for a `struct` or `enum` that represent /// that type placed into a cell in a Task. /// -/// That Vc object can be `.await?`ed to get a readonly reference -/// to the original value. +/// That Vc object can be `await`ed to get a readonly reference +/// to the value contained in the cell. /// -/// `into` argument (`#[turbo_tasks::value(into: xxx)]`) +/// ## Arguments +/// +/// Example: `#[turbo_tasks::value(into = "new", eq = "manual")]` +/// +/// ### `cell` +/// +/// Possible values: +/// +/// - "new": Always overrides the value in the cell. Invalidating all +/// dependent tasks. +/// - "shared" (default): Compares with the existing value in the cell, before +/// overriding it. Requires Value to implement [Eq]. +/// +/// ### `eq` +/// +/// Possible values: +/// +/// - "manual": Prevents deriving [Eq] so you can do it manually. +/// +/// ### `into` /// /// When provided the Vc implement `From` to allow to convert /// a Value to a Vc by placing it into a cell in a Task. /// -/// `into: new`: Always overrides the value in the cell. Invalidating all -/// dependent tasks. +/// Possible values: /// -/// `into: shared`: Compares with the existing value in the cell, before +/// - "new": Always overrides the value in the cell. Invalidating all +/// dependent tasks. +/// - "shared": Compares with the existing value in the cell, before /// overriding it. Requires Value to implement [Eq]. +/// - "none" (default): Prevents implementing `From`. +/// +/// ### `serialization` +/// +/// Affects serialization via [serde::Serialize] and [serde::Deserialize]. +/// +/// Possible values: +/// +/// - "auto" (default): Derives the serialization traits and enabled +/// serialization. +/// - "auto_for_input": Same as "auto", but also adds the marker trait +/// [turbo_tasks::TypedForInput]. +/// - "custom": Prevents deriving the serialization traits, but still enables +/// serialization (you need to manually implement [serde::Serialize] and +/// [serde::Deserialize]). +/// - "custom_for_input":Same as "auto", but also adds the marker trait +/// [turbo_tasks::TypedForInput]. +/// - "none": Disables serialization and prevents deriving the traits. +/// +/// ### `shared` +/// +/// Sets both `cell = "shared"` and `into = "shared"` +/// +/// No value. +/// +/// Example: `#[turbo_tasks::value(shared)]` +/// +/// ### `transparent` +/// +/// If applied to a unit struct (e.g. `struct Wrapper(Value)`) the outer struct +/// is skipped for all operations (cell, into, reading). +/// +/// No value. +/// +/// Example: `#[turbo_tasks::value(transparent)]` /// /// TODO: add more documentation: presets, traits #[allow_internal_unstable(min_specialization, into_future, trivial_bounds)] diff --git a/crates/turbo-tasks/src/primitives.rs b/crates/turbo-tasks/src/primitives.rs index 4164a1ca0c6a3..94b12f78b8517 100644 --- a/crates/turbo-tasks/src/primitives.rs +++ b/crates/turbo-tasks/src/primitives.rs @@ -1,11 +1,12 @@ -use std::ops::Deref; +use std::{future::IntoFuture, ops::Deref}; use auto_hash_map::AutoSet; +use futures::TryFutureExt; // This specific macro identifier is detected by turbo-tasks-build. use turbo_tasks_macros::primitive as __turbo_tasks_internal_primitive; use crate::{ - RawVc, Vc, {self as turbo_tasks}, + RawVc, Vc, {self as turbo_tasks}, TryJoinIterExt, }; __turbo_tasks_internal_primitive!(()); @@ -74,6 +75,46 @@ __turbo_tasks_internal_primitive!(AutoSet); __turbo_tasks_internal_primitive!(serde_json::Value); __turbo_tasks_internal_primitive!(Vec); +__turbo_tasks_internal_primitive!(Vec); + +#[turbo_tasks::value(transparent)] +pub struct Bools(Vec>); + +#[turbo_tasks::value_impl] +impl Bools { + #[turbo_tasks::function] + pub fn empty() -> Vc { + Self::cell(Vec::new()) + } + + #[turbo_tasks::function] + async fn into_bools(self: Vc) -> Result>> { + let this = self.await?; + + let bools = this + .iter() + .map(|b| b.into_future().map_ok(|b| *b)) + .try_join() + .await?; + + Ok(Vc::cell(bools)) + } + + #[turbo_tasks::function] + pub async fn all(self: Vc) -> Result> { + let bools = self.into_bools().await?; + + Ok(Vc::cell(bools.iter().all(|b| *b))) + } + + #[turbo_tasks::function] + pub async fn any(self: Vc) -> Result> { + let bools = self.into_bools().await?; + + Ok(Vc::cell(bools.iter().any(|b| *b))) + } +} + #[turbo_tasks::value(transparent, eq = "manual")] #[derive(Debug, Clone)] pub struct Regex( diff --git a/crates/turbopack-cli/Cargo.toml b/crates/turbopack-cli/Cargo.toml index 1ac25fa4ed7d8..3203acf7b0ad5 100644 --- a/crates/turbopack-cli/Cargo.toml +++ b/crates/turbopack-cli/Cargo.toml @@ -15,7 +15,8 @@ bench = false bench = false [[bench]] -name = "mod" +name = "turbopack-cli" +path = "benches/mod.rs" harness = false [features] diff --git a/crates/turbopack-core/src/issue/mod.rs b/crates/turbopack-core/src/issue/mod.rs index e2d46c7845951..34c5e2c202361 100644 --- a/crates/turbopack-core/src/issue/mod.rs +++ b/crates/turbopack-core/src/issue/mod.rs @@ -328,8 +328,8 @@ pub struct Issues(Vec>>); /// A list of issues captured with [`Issue::peek_issues_with_path`] and /// [`Issue::take_issues_with_path`]. -#[derive(Debug)] #[turbo_tasks::value] +#[derive(Debug)] pub struct CapturedIssues { issues: AutoSet>>, #[cfg(feature = "issue_path")] diff --git a/crates/turbopack-ecmascript/src/lib.rs b/crates/turbopack-ecmascript/src/lib.rs index 9fc567c21fade..d729fbcc3bcd5 100644 --- a/crates/turbopack-ecmascript/src/lib.rs +++ b/crates/turbopack-ecmascript/src/lib.rs @@ -285,17 +285,8 @@ impl EcmascriptModuleAsset { } #[turbo_tasks::function] - pub async fn analyze(self: Vc) -> Result> { - let this = self.await?; - Ok(analyze_ecmascript_module( - this.source, - Vc::upcast(self), - Value::new(this.ty), - this.transforms, - Value::new(this.options), - this.compile_time_info, - None, - )) + pub fn analyze(self: Vc) -> Vc { + analyze_ecmascript_module(self, None) } #[turbo_tasks::function] @@ -519,7 +510,10 @@ impl EcmascriptChunkItem for ModuleChunkItem { ) -> Result> { let this = self.await?; let content = this.module.module_content(this.context, availability_info); - let async_module_options = this.module.get_async_module().module_options(); + let async_module_options = this + .module + .get_async_module() + .module_options(availability_info); Ok(EcmascriptChunkItemContent::new( content, diff --git a/crates/turbopack-ecmascript/src/references/async_module.rs b/crates/turbopack-ecmascript/src/references/async_module.rs index d5807609d5677..4ac2829e339c1 100644 --- a/crates/turbopack-ecmascript/src/references/async_module.rs +++ b/crates/turbopack-ecmascript/src/references/async_module.rs @@ -1,7 +1,4 @@ -use std::future::IntoFuture; - use anyhow::Result; -use futures::{stream::FuturesOrdered, TryStreamExt}; use indexmap::IndexSet; use serde::{Deserialize, Serialize}; use swc_core::{ @@ -9,17 +6,22 @@ use swc_core::{ ecma::ast::{ArrayLit, ArrayPat, Expr, Ident, Pat, Program}, quote, }; -use turbo_tasks::{primitives::BoolVc, trace::TraceRawVcs, TryFlatJoinIterExt}; +use turbo_tasks::{ + primitives::{BoolVc, BoolVcsVc}, + trace::TraceRawVcs, + TryFlatJoinIterExt, Value, +}; +use turbopack_core::chunk::availability_info::AvailabilityInfo; use crate::{ - chunk::{EcmascriptChunkPlaceable, EcmascriptChunkingContextVc}, - code_gen::{CodeGenerateable, CodeGeneration, CodeGenerationVc}, - create_visitor, - references::esm::{ - base::{insert_hoisted_stmt, ReferencedAsset}, - EsmAssetReferenceVc, + chunk::{ + esm_scope::{EsmScopeSccVc, EsmScopeVc}, + EcmascriptChunkPlaceable, EcmascriptChunkPlaceableVc, EcmascriptChunkingContextVc, }, - CodeGenerateableVc, + code_gen::{CodeGenerateableWithAvailabilityInfo, CodeGeneration, CodeGenerationVc}, + create_visitor, + references::esm::{base::insert_hoisted_stmt, EsmAssetReferenceVc}, + CodeGenerateableWithAvailabilityInfoVc, EcmascriptModuleAssetVc, }; #[derive(PartialEq, Eq, Default, Debug, Clone, Serialize, Deserialize, TraceRawVcs)] @@ -45,6 +47,7 @@ impl OptionAsyncModuleOptionsVc { #[turbo_tasks::value(shared)] pub struct AsyncModule { + pub(super) module: EcmascriptModuleAssetVc, pub(super) references: IndexSet, pub(super) has_top_level_await: bool, } @@ -63,82 +66,83 @@ impl OptionAsyncModuleVc { } #[turbo_tasks::function] - pub(crate) async fn is_async(self) -> Result { - Ok(BoolVc::cell(self.module_options().await?.is_some())) + pub(crate) async fn is_async( + self, + availability_info: Value, + ) -> Result { + Ok(BoolVc::cell( + self.module_options(availability_info).await?.is_some(), + )) } #[turbo_tasks::function] - pub(crate) async fn module_options(self) -> Result { + pub(crate) async fn module_options( + self, + availability_info: Value, + ) -> Result { if let Some(async_module) = &*self.await? { - return Ok(async_module.module_options()); + return Ok(async_module.module_options(availability_info)); } Ok(OptionAsyncModuleOptionsVc::none()) } } +#[turbo_tasks::value] +pub struct AsyncModuleScc { + scc: EsmScopeSccVc, + scope: EsmScopeVc, +} + #[turbo_tasks::value(transparent)] -pub struct AsyncModuleIdents(IndexSet); +pub struct OptionAsyncModuleScc(Option); -#[turbo_tasks::value_impl] -impl AsyncModuleVc { - /// Collects all [AsyncModuleVc]s from the references and returns them - /// after resolving. - #[turbo_tasks::function] - pub(crate) async fn collect_direct_async_module_children(self) -> Result { - let this = self.await?; +#[turbo_tasks::function] +async fn is_placeable_self_async(placeable: EcmascriptChunkPlaceableVc) -> Result { + let Some(async_module) = &*placeable.get_async_module().await? else { + return Ok(BoolVc::cell(false)); + }; - let async_modules = this - .references - .iter() - .map(|r| async { - let referenced_asset = r.get_referenced_asset().await?; - let ReferencedAsset::Some(placeable) = &*referenced_asset else { - return anyhow::Ok(None); - }; + Ok(async_module.is_self_async()) +} - let Some(async_module) = &*placeable.get_async_module().await? else { - return anyhow::Ok(None); - }; +#[turbo_tasks::value_impl] +impl AsyncModuleSccVc { + #[turbo_tasks::function] + fn new(scc: EsmScopeSccVc, scope: EsmScopeVc) -> Self { + Self::cell(AsyncModuleScc { scc, scope }) + } - let resolved = async_module.resolve().await?; - if resolved == self { - return anyhow::Ok(None); - }; + #[turbo_tasks::function] + pub(crate) async fn is_async(self) -> Result { + let this = self.await?; - anyhow::Ok(Some(resolved)) - }) - .try_flat_join() - .await?; + let mut bools = Vec::new(); - Ok(AsyncModulesVc::cell(IndexSet::from_iter(async_modules))) - } + for placeable in &*this.scc.await? { + bools.push(is_placeable_self_async(*placeable)); + } - /// Collects all [AsyncModuleVc]s referenced including the current - /// [AsyncModuleVc]. - #[turbo_tasks::function] - pub(crate) async fn collect_all_async_modules(self) -> Result { - let mut futures = FuturesOrdered::new(); - futures.push_back(self.collect_direct_async_module_children().into_future()); - - let mut async_modules = IndexSet::from([self]); - while let Some(modules) = futures.try_next().await? { - for async_module in modules.iter().copied() { - if async_modules.insert(async_module) { - futures.push_back( - async_module - .collect_direct_async_module_children() - .into_future(), - ); - } - } + for scc in &*this.scope.get_scc_children(this.scc).await? { + // Because we generated SCCs there can be no loops in the children, so calling + // recursively is fine. + bools.push(AsyncModuleSccVc::new(*scc, this.scope).is_async()); } - Ok(AsyncModulesVc::cell(async_modules)) + Ok(BoolVcsVc::cell(bools).any()) } +} + +#[turbo_tasks::value(transparent)] +pub struct AsyncModuleIdents(IndexSet); +#[turbo_tasks::value_impl] +impl AsyncModuleVc { #[turbo_tasks::function] - pub(crate) async fn get_async_idents(self) -> Result { + pub(crate) async fn get_async_idents( + self, + availability_info: Value, + ) -> Result { let this = self.await?; let reference_idents = this @@ -146,7 +150,7 @@ impl AsyncModuleVc { .iter() .map(|r| async { let referenced_asset = r.get_referenced_asset().await?; - let ident = if *r.is_async(true).await? { + let ident = if *r.is_async(availability_info).await? { referenced_asset.get_ident().await? } else { None @@ -161,6 +165,11 @@ impl AsyncModuleVc { ))) } + #[turbo_tasks::function] + pub(crate) async fn has_top_level_await(self) -> Result { + Ok(BoolVc::cell(self.await?.has_top_level_await)) + } + #[turbo_tasks::function] pub(crate) async fn is_self_async(self) -> Result { let this = self.await?; @@ -169,42 +178,57 @@ impl AsyncModuleVc { return Ok(BoolVc::cell(true)); } - let references = this - .references - .iter() - .map(|r| async { anyhow::Ok((*r.is_async(false).await?).then_some(())) }) - .try_flat_join() - .await?; + let bools = BoolVcsVc::cell( + this.references + .iter() + .map(|r| r.is_external_esm()) + .collect(), + ); - Ok(BoolVc::cell(!references.is_empty())) + Ok(bools.any()) } #[turbo_tasks::function] - pub(crate) async fn is_async(self) -> Result { - if *self.is_self_async().await? { - return Ok(BoolVc::cell(true)); - } + async fn get_scc( + self, + availability_info: Value, + ) -> Result { + let this = self.await?; - let async_modules = self - .collect_all_async_modules() + let scope = EsmScopeVc::new(availability_info); + let Some(scc) = &*scope + .get_scc(this.module.as_ecmascript_chunk_placeable()) .await? - .iter() - .map(|a| async { - anyhow::Ok(if *a.is_self_async().await? { - Some(*a) - } else { - None - }) - }) - .try_flat_join() - .await?; + else { + // I'm not sure if this should be possible. + return Ok(OptionAsyncModuleSccVc::cell(None)); + }; + + let scc = AsyncModuleSccVc::new(*scc, scope); - Ok(BoolVc::cell(!async_modules.is_empty())) + Ok(OptionAsyncModuleSccVc::cell(Some(scc))) + } + + #[turbo_tasks::function] + pub(crate) async fn is_async( + self, + availability_info: Value, + ) -> Result { + Ok( + if let Some(scc) = &*self.get_scc(availability_info).await? { + scc.is_async() + } else { + self.is_self_async() + }, + ) } #[turbo_tasks::function] - pub(crate) async fn module_options(self) -> Result { - if !*self.is_async().await? { + pub(crate) async fn module_options( + self, + availability_info: Value, + ) -> Result { + if !*self.is_async(availability_info).await? { return Ok(OptionAsyncModuleOptionsVc::cell(None)); } @@ -215,22 +239,21 @@ impl AsyncModuleVc { } #[turbo_tasks::value_impl] -impl CodeGenerateable for AsyncModule { +impl CodeGenerateableWithAvailabilityInfo for AsyncModule { #[turbo_tasks::function] async fn code_generation( self_vc: AsyncModuleVc, _context: EcmascriptChunkingContextVc, + availability_info: Value, ) -> Result { let mut visitors = Vec::new(); - if *self_vc.is_async().await? { - let async_idents = self_vc.get_async_idents().await?; + let async_idents = self_vc.get_async_idents(availability_info).await?; - if !async_idents.is_empty() { - visitors.push(create_visitor!(visit_mut_program(program: &mut Program) { - add_async_dependency_handler(program, &async_idents); - })); - } + if !async_idents.is_empty() { + visitors.push(create_visitor!(visit_mut_program(program: &mut Program) { + add_async_dependency_handler(program, &async_idents); + })); } Ok(CodeGeneration { visitors }.into()) diff --git a/crates/turbopack-ecmascript/src/references/esm/base.rs b/crates/turbopack-ecmascript/src/references/esm/base.rs index dd778d0f039bd..43c99f85a6484 100644 --- a/crates/turbopack-ecmascript/src/references/esm/base.rs +++ b/crates/turbopack-ecmascript/src/references/esm/base.rs @@ -8,7 +8,8 @@ use swc_core::{ use turbo_tasks::{Value, ValueToString, Vc}; use turbopack_core::{ chunk::{ - ChunkableModuleReference, ChunkingContext, ChunkingType, ChunkingTypeOption, ModuleId, + availability_info::AvailabilityInfo, ChunkableModuleReference, + ChunkingContext, ChunkingType, ChunkingTypeOption, ModuleId, }, issue::{IssueSeverity, OptionIssueSource}, module::Module, @@ -106,6 +107,10 @@ pub struct EsmAssetReference { pub export_name: Option>, } +/// A list of [EsmAssetReference]s +#[turbo_tasks::value(transparent)] +pub struct EsmAssetReferences(Vec>); + impl EsmAssetReference { fn get_origin(&self) -> Vc> { let mut origin = self.origin; @@ -144,19 +149,32 @@ impl EsmAssetReference { } #[turbo_tasks::function] - pub(crate) async fn is_async(self: Vc, recursive: bool) -> Result> { + pub(crate) async fn is_external_esm(self) -> Result> { let asset = self.get_referenced_asset().await?; - match &*asset { - ReferencedAsset::Some(placeable) if recursive => { - Ok(placeable.get_async_module().is_async()) - } - ReferencedAsset::OriginalReferenceTypeExternal(_) => { - // TODO(WEB-1259): we need to detect if external modules are esm - Ok(BoolVc::cell(false)) - } - ReferencedAsset::Some(_) | ReferencedAsset::None => Ok(BoolVc::cell(false)), + let ReferencedAsset::OriginalReferenceTypeExternal(_) = &*asset else { + return Ok(Vc::cell(false)); + }; + + // TODO(WEB-1259): we need to detect if external modules are esm + Ok(Vc::cell(false)) + } + + #[turbo_tasks::function] + pub(crate) async fn is_async( + self, + availability_info: Value, + ) -> Result> { + if *self.is_external_esm().await? { + return Ok(Vc::cell(true)); } + + let asset = self.get_referenced_asset().await?; + let ReferencedAsset::Some(placeable) = &*asset else { + return Ok(Vc::cell(false)); + }; + + Ok(placeable.get_async_module().is_async(availability_info)) } } diff --git a/crates/turbopack-ecmascript/src/references/mod.rs b/crates/turbopack-ecmascript/src/references/mod.rs index 7b78b7ee04a0f..8bfa67f76bbc2 100644 --- a/crates/turbopack-ecmascript/src/references/mod.rs +++ b/crates/turbopack-ecmascript/src/references/mod.rs @@ -124,7 +124,7 @@ use crate::{ resolve::try_to_severity, tree_shake::{part_of_module, split}, typescript::resolve::tsconfig, - EcmascriptInputTransforms, EcmascriptOptions, SpecifiedModuleType, + EcmascriptInputTransforms, EcmascriptModuleAsset, SpecifiedModuleType, }; #[turbo_tasks::value(shared)] @@ -317,14 +317,19 @@ where #[turbo_tasks::function] pub(crate) async fn analyze_ecmascript_module( - source: Vc>, - origin: Vc>, - ty: Value, - transforms: Vc, - options: Value, - compile_time_info: Vc, + module: Vc, part: Option>, ) -> Result> { + let raw_module = module.await?; + + let source = raw_module.source; + let ty = Value::new(raw_module.ty); + let transforms = raw_module.transforms; + let options = raw_module.options; + let compile_time_info = raw_module.compile_time_info; + + let origin = module.as_resolve_origin(); + let mut analysis = AnalyzeEcmascriptModuleResultBuilder::new(); let path = origin.origin_path(); @@ -577,6 +582,7 @@ pub(crate) async fn analyze_ecmascript_module( } let async_module = AsyncModule { + module, references: import_references.iter().copied().collect(), has_top_level_await, } @@ -590,17 +596,18 @@ pub(crate) async fn analyze_ecmascript_module( .cell(); analysis.add_code_gen(esm_exports); - analysis.add_code_gen(async_module); + analysis.add_code_gen_with_availability_info(async_module); EcmascriptExports::EsmExports(esm_exports) } else if matches!(specified_type, SpecifiedModuleType::EcmaScript) { let async_module = AsyncModule { + module, references: import_references.iter().copied().collect(), has_top_level_await, } .cell(); analysis.set_async_module(async_module); - analysis.add_code_gen(async_module); + analysis.add_code_gen_with_availability_info(async_module); match detect_dynamic_export(program) { DetectedDynamicExportType::CommonJs => { @@ -637,12 +644,13 @@ pub(crate) async fn analyze_ecmascript_module( DetectedDynamicExportType::Value => EcmascriptExports::Value, DetectedDynamicExportType::UsingModuleDeclarations => { let async_module = AsyncModule { + module, references: import_references.iter().copied().collect(), has_top_level_await, } .cell(); analysis.set_async_module(async_module); - analysis.add_code_gen(async_module); + analysis.add_code_gen_with_availability_info(async_module); EcmascriptExports::EsmExports( EsmExports { diff --git a/crates/turbopack-ecmascript/src/tree_shake/asset.rs b/crates/turbopack-ecmascript/src/tree_shake/asset.rs index f55605727c332..c35f75592c6ef 100644 --- a/crates/turbopack-ecmascript/src/tree_shake/asset.rs +++ b/crates/turbopack-ecmascript/src/tree_shake/asset.rs @@ -156,18 +156,8 @@ impl EcmascriptModulePartAsset { #[turbo_tasks::function] async fn analyze( - full_module: Vc, + module: Vc, part: Vc, ) -> Result> { - let module = full_module.await?; - - Ok(analyze_ecmascript_module( - module.source, - Vc::upcast(full_module), - Value::new(module.ty), - module.transforms, - Value::new(module.options), - module.compile_time_info, - Some(part), - )) + Ok(analyze_ecmascript_module(module, Some(part))) } diff --git a/crates/turbopack-ecmascript/src/tree_shake/chunk_item.rs b/crates/turbopack-ecmascript/src/tree_shake/chunk_item.rs index 015927e535073..b4b98a710e699 100644 --- a/crates/turbopack-ecmascript/src/tree_shake/chunk_item.rs +++ b/crates/turbopack-ecmascript/src/tree_shake/chunk_item.rs @@ -54,7 +54,10 @@ impl EcmascriptChunkItem for EcmascriptModulePartChunkItem { availability_info, ); - let async_module_options = module.full_module.get_async_module().module_options(); + let async_module_options = module + .full_module + .get_async_module() + .module_options(availability_info); Ok(EcmascriptChunkItemContent::new( content, diff --git a/crates/turbopack-test-utils/Cargo.toml b/crates/turbopack-test-utils/Cargo.toml index b87f9b43913d0..8dd75d5e01d08 100644 --- a/crates/turbopack-test-utils/Cargo.toml +++ b/crates/turbopack-test-utils/Cargo.toml @@ -10,14 +10,15 @@ autobenches = false bench = false [dependencies] -anyhow = "1.0.47" +anyhow = { workspace = true } once_cell = { workspace = true } serde = { workspace = true } similar = "2.2.0" -turbo-tasks = { path = "../turbo-tasks" } -turbo-tasks-fs = { path = "../turbo-tasks-fs" } -turbo-tasks-hash = { path = "../turbo-tasks-hash" } -turbopack-core = { path = "../turbopack-core" } +turbo-tasks = { workspace = true } +turbo-tasks-fs = { workspace = true } +turbo-tasks-hash = { workspace = true } +turbopack-core = { workspace = true } +turbopack-cli-utils = { workspace = true } [build-dependencies] -turbo-tasks-build = { path = "../turbo-tasks-build" } +turbo-tasks-build = { workspace = true } diff --git a/crates/turbopack-test-utils/src/snapshot.rs b/crates/turbopack-test-utils/src/snapshot.rs index 3875db9015560..60ae0db10579f 100644 --- a/crates/turbopack-test-utils/src/snapshot.rs +++ b/crates/turbopack-test-utils/src/snapshot.rs @@ -1,6 +1,7 @@ use std::{ collections::{HashMap, HashSet}, env, fs, + path::PathBuf, }; use anyhow::{anyhow, bail, Context, Result}; @@ -12,22 +13,26 @@ use turbo_tasks_fs::{ FileSystemPath, }; use turbo_tasks_hash::encode_hex; -use turbopack_core::{asset::AssetContent, issue::PlainIssue}; +use turbopack_cli_utils::issue::{format_issue, LogOptions}; +use turbopack_core::{ + asset::{AssetContent}, + issue::{IssueSeverity, PlainIssue}, +}; // Updates the existing snapshot outputs with the actual outputs of this run. // e.g. `UPDATE=1 cargo test -p turbopack-tests -- test_my_pattern` static UPDATE: Lazy = Lazy::new(|| env::var("UPDATE").unwrap_or_default() == "1"); -pub async fn snapshot_issues< - I: IntoIterator, ReadRef)>, ->( +pub async fn snapshot_issues>>( captured_issues: I, issues_path: Vc, workspace_root: &str, ) -> Result<()> { let expected_issues = expected(issues_path).await?; let mut seen = HashSet::new(); - for (plain_issue, debug_string) in captured_issues.into_iter() { + for plain_issue in captured_issues.into_iter() { + let plain_issue = plain_issue.await?; + let title = plain_issue .title .replace('/', "__") @@ -48,14 +53,27 @@ pub async fn snapshot_issues< continue; } + let formatted = format_issue( + &plain_issue, + None, + &LogOptions { + current_dir: PathBuf::new(), + project_dir: PathBuf::new(), + show_all: true, + log_detail: true, + log_level: IssueSeverity::Info, + }, + ); + // Annoyingly, the PlainIssue.source -> PlainIssueSource.asset -> // PlainSource.path -> FileSystemPath.fs -> DiskFileSystem.root changes // for everyone. - let content = debug_string + let content = formatted .as_str() .replace(workspace_root, "WORKSPACE_ROOT") // Normalize syspaths from Windows. These appear in stack traces. .replace("\\\\", "/"); + let asset = AssetContent::file(File::from(content).into()); diff(path, asset).await?; diff --git a/crates/turbopack-tests/.gitignore b/crates/turbopack-tests/.gitignore index 8e11f6eef270a..fd43f2fb12b85 100644 --- a/crates/turbopack-tests/.gitignore +++ b/crates/turbopack-tests/.gitignore @@ -1 +1,2 @@ -tests/execution/**/*/output +tests/execution/**/*/output/ +tests/snapshot/**/output/ diff --git a/crates/turbopack-tests/Cargo.toml b/crates/turbopack-tests/Cargo.toml index 6601992fba38a..c8117a8202861 100644 --- a/crates/turbopack-tests/Cargo.toml +++ b/crates/turbopack-tests/Cargo.toml @@ -27,6 +27,7 @@ turbo-tasks-env = { workspace = true } turbo-tasks-fs = { workspace = true } turbo-tasks-memory = { workspace = true } turbopack-build = { workspace = true, features = ["test"] } +turbopack-cli-utils = { workspace = true } turbopack-core = { workspace = true, features = ["issue_path"] } turbopack-dev = { workspace = true, features = ["test"] } turbopack-ecmascript-plugins = { workspace = true, features = [ diff --git a/crates/turbopack-tests/tests/execution.rs b/crates/turbopack-tests/tests/execution.rs index 5a00febe08b9d..7df11f950d30f 100644 --- a/crates/turbopack-tests/tests/execution.rs +++ b/crates/turbopack-tests/tests/execution.rs @@ -273,10 +273,17 @@ async fn run_test(resource: String) -> Result> { .context("test node result did not emit anything")?; let SingleValue::Single(bytes) = single else { - panic!( - "Evaluation stream must yield SingleValue, but got: {:?}", - single - ); + return Ok(RunTestResult { + js_result: JsResultVc::cell(JsResult { + uncaught_exceptions: vec![], + unhandled_rejections: vec![], + jest_result: JestRunResult { + test_results: vec![], + }, + }), + path, + } + .cell()); }; Ok(RunTestResult { @@ -298,14 +305,7 @@ async fn snapshot_issues(run_result: Vc) -> Result> { let plain_issues = captured_issues .iter_with_shortest_path() - .map(|(issue_vc, path)| async move { - Ok(( - issue_vc.into_plain(path).await?, - issue_vc.into_plain(path).dbg().await?, - )) - }) - .try_join() - .await?; + .map(|(issue_vc, path)| issue_vc.into_plain(path)); turbopack_test_utils::snapshot::snapshot_issues( plain_issues, diff --git a/crates/turbopack-tests/tests/execution/turbopack/basic/error/issues/Reading source code for parsing failed-3b6255.txt b/crates/turbopack-tests/tests/execution/turbopack/basic/error/issues/Reading source code for parsing failed-3b6255.txt index 90d28dfb1113f..1f6f066719fa6 100644 --- a/crates/turbopack-tests/tests/execution/turbopack/basic/error/issues/Reading source code for parsing failed-3b6255.txt +++ b/crates/turbopack-tests/tests/execution/turbopack/basic/error/issues/Reading source code for parsing failed-3b6255.txt @@ -1,14 +1,5 @@ -PlainIssue { - severity: Error, - context: "[project]/crates/turbopack-tests/tests/execution/turbopack/basic/error/input/broken.js", - category: "parse", - title: "Reading source code for parsing failed", - description: "An unexpected error happened while trying to read the source code to parse: failed to convert rope into string\n\nCaused by:\n- invalid utf-8 sequence of 1 bytes from index 1", - detail: "", - documentation_link: "", - source: None, - sub_issues: [], - processing_path: Some( - [], - ), -} \ No newline at end of file +error - [parse] [project]/crates/turbopack-tests/tests/execution/turbopack/basic/error/input/broken.js Reading source code for parsing failed + An unexpected error happened while trying to read the source code to parse: failed to convert rope into string + + Caused by: + - invalid utf-8 sequence of 1 bytes from index 1 \ No newline at end of file diff --git a/crates/turbopack-tests/tests/execution/turbopack/basic/node-default-import/issues/Specified module format (CommonJs) is not matching-5fdb68.txt b/crates/turbopack-tests/tests/execution/turbopack/basic/node-default-import/issues/Specified module format (CommonJs) is not matching-5fdb68.txt index 8ce56b3259d33..27a58929de2c3 100644 --- a/crates/turbopack-tests/tests/execution/turbopack/basic/node-default-import/issues/Specified module format (CommonJs) is not matching-5fdb68.txt +++ b/crates/turbopack-tests/tests/execution/turbopack/basic/node-default-import/issues/Specified module format (CommonJs) is not matching-5fdb68.txt @@ -1,14 +1,4 @@ -PlainIssue { - severity: Error, - context: "[project]/crates/turbopack-tests/tests/execution/turbopack/basic/node-default-import/input/node_modules/esm-package/invalid-exports.cjs", - category: "module type", - title: "Specified module format (CommonJs) is not matching the module format of the source code (EcmaScript Modules)", - description: "The CommonJs module format was specified in the package.json that is affecting this source file or by using an special extension, but Ecmascript import/export syntax is used in the source code.\nThe module was automatically converted to an EcmaScript module, but that is in conflict with the specified module format. Either change the \"type\" field in the package.json or replace EcmaScript import/export syntax with CommonJs syntas in the source file.\nIn some cases EcmaScript import/export syntax is added by an transform and isn't actually part of the source code. In these cases revisit transformation options to inject the correct syntax.", - detail: "", - documentation_link: "", - source: None, - sub_issues: [], - processing_path: Some( - [], - ), -} \ No newline at end of file +error - [module type] [project]/crates/turbopack-tests/tests/execution/turbopack/basic/node-default-import/input/node_modules/esm-package/invalid-exports.cjs Specified module format (CommonJs) is not matching the module format of the source code (EcmaScript Modules) + The CommonJs module format was specified in the package.json that is affecting this source file or by using an special extension, but Ecmascript import/export syntax is used in the source code. + The module was automatically converted to an EcmaScript module, but that is in conflict with the specified module format. Either change the "type" field in the package.json or replace EcmaScript import/export syntax with CommonJs syntas in the source file. + In some cases EcmaScript import/export syntax is added by an transform and isn't actually part of the source code. In these cases revisit transformation options to inject the correct syntax. \ No newline at end of file diff --git a/crates/turbopack-tests/tests/execution/turbopack/basic/node-default-import/issues/Specified module format (EcmaScript Modules) is no-34c311.txt b/crates/turbopack-tests/tests/execution/turbopack/basic/node-default-import/issues/Specified module format (EcmaScript Modules) is no-34c311.txt index 4c5829599758c..8b90743b769f3 100644 --- a/crates/turbopack-tests/tests/execution/turbopack/basic/node-default-import/issues/Specified module format (EcmaScript Modules) is no-34c311.txt +++ b/crates/turbopack-tests/tests/execution/turbopack/basic/node-default-import/issues/Specified module format (EcmaScript Modules) is no-34c311.txt @@ -1,14 +1,3 @@ -PlainIssue { - severity: Warning, - context: "[project]/crates/turbopack-tests/tests/execution/turbopack/basic/node-default-import/input/node_modules/esm-package/invalid-exports.js", - category: "module type", - title: "Specified module format (EcmaScript Modules) is not matching the module format of the source code (CommonJs)", - description: "The EcmaScript module format was specified in the package.json that is affecting this source file or by using an special extension, but it looks like that CommonJs syntax is used in the source code.\nExports made by CommonJs syntax will lead to a runtime error, since the module is in EcmaScript mode. Either change the \"type\" field in the package.json or replace CommonJs syntax with EcmaScript import/export syntax in the source file.", - detail: "", - documentation_link: "", - source: None, - sub_issues: [], - processing_path: Some( - [], - ), -} \ No newline at end of file +warning - [module type] [project]/crates/turbopack-tests/tests/execution/turbopack/basic/node-default-import/input/node_modules/esm-package/invalid-exports.js Specified module format (EcmaScript Modules) is not matching the module format of the source code (CommonJs) + The EcmaScript module format was specified in the package.json that is affecting this source file or by using an special extension, but it looks like that CommonJs syntax is used in the source code. + Exports made by CommonJs syntax will lead to a runtime error, since the module is in EcmaScript mode. Either change the "type" field in the package.json or replace CommonJs syntax with EcmaScript import/export syntax in the source file. \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot.rs b/crates/turbopack-tests/tests/snapshot.rs index 29a14698e6d65..50e98dbe0a3b0 100644 --- a/crates/turbopack-tests/tests/snapshot.rs +++ b/crates/turbopack-tests/tests/snapshot.rs @@ -148,14 +148,7 @@ async fn run(resource: PathBuf) -> Result<()> { let plain_issues = captured_issues .iter_with_shortest_path() - .map(|(issue_vc, path)| async move { - Ok(( - issue_vc.into_plain(path).await?, - issue_vc.into_plain(path).dbg().await?, - )) - }) - .try_join() - .await?; + .map(|(issue_vc, path)| issue_vc.into_plain(path)); snapshot_issues(plain_issues, out.join("issues".to_string()), &REPO_ROOT) .await diff --git a/crates/turbopack-tests/tests/snapshot/export-alls/cjs-2/issues/unexpected export __star__-c9d8a6.txt b/crates/turbopack-tests/tests/snapshot/export-alls/cjs-2/issues/unexpected export __star__-c9d8a6.txt index 4d82202bd482f..3d0a94236dd02 100644 --- a/crates/turbopack-tests/tests/snapshot/export-alls/cjs-2/issues/unexpected export __star__-c9d8a6.txt +++ b/crates/turbopack-tests/tests/snapshot/export-alls/cjs-2/issues/unexpected export __star__-c9d8a6.txt @@ -1,14 +1,3 @@ -PlainIssue { - severity: Warning, - context: "[project]/crates/turbopack-tests/tests/snapshot/export-alls/cjs-2/input/commonjs.js", - category: "analyze", - title: "unexpected export *", - description: "export * used with module [project]/crates/turbopack-tests/tests/snapshot/export-alls/cjs-2/input/commonjs.js (ecmascript) which is a CommonJS module with exports only available at runtime\nList all export names manually (`export { a, b, c } from \"...\") or rewrite the module to ESM, to avoid the additional runtime code.`", - detail: "", - documentation_link: "", - source: None, - sub_issues: [], - processing_path: Some( - [], - ), -} \ No newline at end of file +warning - [analyze] [project]/crates/turbopack-tests/tests/snapshot/export-alls/cjs-2/input/commonjs.js unexpected export * + export * used with module [project]/crates/turbopack-tests/tests/snapshot/export-alls/cjs-2/input/commonjs.js (ecmascript) which is a CommonJS module with exports only available at runtime + List all export names manually (`export { a, b, c } from "...") or rewrite the module to ESM, to avoid the additional runtime code.` \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/export-alls/cjs-script/issues/unexpected export __star__-38cf67.txt b/crates/turbopack-tests/tests/snapshot/export-alls/cjs-script/issues/unexpected export __star__-38cf67.txt index 2e59a9c516941..e764296aac81f 100644 --- a/crates/turbopack-tests/tests/snapshot/export-alls/cjs-script/issues/unexpected export __star__-38cf67.txt +++ b/crates/turbopack-tests/tests/snapshot/export-alls/cjs-script/issues/unexpected export __star__-38cf67.txt @@ -1,14 +1,3 @@ -PlainIssue { - severity: Warning, - context: "[project]/crates/turbopack-tests/tests/snapshot/export-alls/cjs-script/input/exported.cjs", - category: "analyze", - title: "unexpected export *", - description: "export * used with module [project]/crates/turbopack-tests/tests/snapshot/export-alls/cjs-script/input/exported.cjs (ecmascript) which is a CommonJS module with exports only available at runtime\nList all export names manually (`export { a, b, c } from \"...\") or rewrite the module to ESM, to avoid the additional runtime code.`", - detail: "", - documentation_link: "", - source: None, - sub_issues: [], - processing_path: Some( - [], - ), -} \ No newline at end of file +warning - [analyze] [project]/crates/turbopack-tests/tests/snapshot/export-alls/cjs-script/input/exported.cjs unexpected export * + export * used with module [project]/crates/turbopack-tests/tests/snapshot/export-alls/cjs-script/input/exported.cjs (ecmascript) which is a CommonJS module with exports only available at runtime + List all export names manually (`export { a, b, c } from "...") or rewrite the module to ESM, to avoid the additional runtime code.` \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/imports/resolve_error_esm/issues/Error resolving EcmaScript Modules request-aff400.txt b/crates/turbopack-tests/tests/snapshot/imports/resolve_error_esm/issues/Error resolving EcmaScript Modules request-aff400.txt index 4258654d1eba2..5cdc76d213c7f 100644 --- a/crates/turbopack-tests/tests/snapshot/imports/resolve_error_esm/issues/Error resolving EcmaScript Modules request-aff400.txt +++ b/crates/turbopack-tests/tests/snapshot/imports/resolve_error_esm/issues/Error resolving EcmaScript Modules request-aff400.txt @@ -1,14 +1,9 @@ -PlainIssue { - severity: Error, - context: "[project]/crates/turbopack-tests/tests/snapshot/imports/resolve_error_esm/input/index.js", - category: "resolve", - title: "Error resolving EcmaScript Modules request", - description: "unable to resolve module \"does-not-exist\" with subpath \"/path\"", - detail: "It was not possible to find the requested file.\nParsed request as written in source code: module \"does-not-exist\" with subpath \"/path\"\nPath where resolving has started: [project]/crates/turbopack-tests/tests/snapshot/imports/resolve_error_esm/input/index.js\nType of request: EcmaScript Modules request\nImport map: No import map entry\n", - documentation_link: "", - source: None, - sub_issues: [], - processing_path: Some( - [], - ), -} \ No newline at end of file +error - [resolve] [project]/crates/turbopack-tests/tests/snapshot/imports/resolve_error_esm/input/index.js Error resolving EcmaScript Modules request + unable to resolve module "does-not-exist" with subpath "/path" + + | It was not possible to find the requested file. + | Parsed request as written in source code: module "does-not-exist" with subpath "/path" + | Path where resolving has started: [project]/crates/turbopack-tests/tests/snapshot/imports/resolve_error_esm/input/index.js + | Type of request: EcmaScript Modules request + | Import map: No import map entry + | \ No newline at end of file From 566971099bc107be6e99b058f42f7288a715b3e9 Mon Sep 17 00:00:00 2001 From: hrmny Date: Wed, 12 Jul 2023 20:58:04 +0200 Subject: [PATCH 10/16] snapshots --- .../output/[turbopack]_runtime.js | 148 ++++++++++++++++- .../output/[turbopack]_runtime.js.map | 5 +- ..._default_dev_runtime_input_index_e60ecd.js | 150 ++++++++++++++++-- ...ault_dev_runtime_input_index_e60ecd.js.map | 8 +- 4 files changed, 288 insertions(+), 23 deletions(-) diff --git a/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js b/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js index b70a35ec5a2fd..2875e9d9f3948 100644 --- a/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js +++ b/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js @@ -24,14 +24,15 @@ function esm(exports, getters) { }); } } -function esmExport(module, getters) { - esm(module.namespaceObject = module.exports, getters); +function esmExport(module, exports, getters) { + module.namespaceObject = module.exports; + esm(exports, getters); } -function dynamicExport(module, object) { +function dynamicExport(module, exports, object) { let reexportedObjects = module[REEXPORTED_OBJECTS]; if (!reexportedObjects) { reexportedObjects = module[REEXPORTED_OBJECTS] = []; - module.exports = module.namespaceObject = new Proxy(module.exports, { + const namespaceObject = new Proxy(exports, { get (target, prop) { if (hasOwnProperty.call(target, prop) || prop === "default" || prop === "__esModule") { return Reflect.get(target, prop); @@ -52,6 +53,11 @@ function dynamicExport(module, object) { return keys; } }); + if (isPromise(module.namespaceObject)) { + module.exports = module.namespaceObject = maybeWrapAsyncModulePromise(module.namespaceObject, ()=>namespaceObject); + } else { + module.exports = module.namespaceObject = namespaceObject; + } } reexportedObjects.push(object); } @@ -82,15 +88,14 @@ function interopEsm(raw, ns, allowExportDefault) { getters["default"] = ()=>raw; } esm(ns, getters); + return ns; } function esmImport(sourceModule, id) { const module = getOrInstantiateModuleFromParent(id, sourceModule); if (module.error) throw module.error; if (module.namespaceObject) return module.namespaceObject; const raw = module.exports; - const ns = module.namespaceObject = {}; - interopEsm(raw, ns, raw.__esModule); - return ns; + return module.namespaceObject = interopEsm(raw, {}, raw.__esModule); } function commonJsRequire(sourceModule, id) { const module = getOrInstantiateModuleFromParent(id, sourceModule); @@ -120,6 +125,132 @@ function requireContext(sourceModule, map) { function getChunkPath(chunkData) { return typeof chunkData === "string" ? chunkData : chunkData.path; } +function isPromise(maybePromise) { + return maybePromise != null && typeof maybePromise === "object" && "then" in maybePromise && typeof maybePromise.then === "function"; +} +function isAsyncModuleExt(obj) { + return turbopackQueues in obj; +} +function maybeWrapAsyncModulePromise(promise, then) { + const newPromise = promise.then(then); + if (isAsyncModuleExt(promise)) { + Object.assign(newPromise, { + get [turbopackExports] () { + return promise[turbopackExports]; + }, + get [turbopackQueues] () { + return promise[turbopackQueues]; + }, + get [turbopackError] () { + return promise[turbopackError]; + } + }); + } + return newPromise; +} +function createPromise() { + let resolve; + let reject; + const promise = new Promise((res, rej)=>{ + reject = rej; + resolve = res; + }); + return { + promise, + resolve: resolve, + reject: reject + }; +} +const turbopackQueues = Symbol("turbopack queues"); +const turbopackExports = Symbol("turbopack exports"); +const turbopackError = Symbol("turbopack error"); +function resolveQueue(queue) { + if (queue && !queue.resolved) { + queue.resolved = true; + queue.forEach((fn)=>fn.queueCount--); + queue.forEach((fn)=>fn.queueCount-- ? fn.queueCount++ : fn()); + } +} +function wrapDeps(deps) { + return deps.map((dep)=>{ + if (dep !== null && typeof dep === "object") { + if (isAsyncModuleExt(dep)) return dep; + if (isPromise(dep)) { + const queue = Object.assign([], { + resolved: false + }); + const obj = { + [turbopackExports]: {}, + [turbopackQueues]: (fn)=>fn(queue) + }; + dep.then((res)=>{ + obj[turbopackExports] = res; + resolveQueue(queue); + }, (err)=>{ + obj[turbopackError] = err; + resolveQueue(queue); + }); + return obj; + } + } + const ret = { + [turbopackExports]: dep, + [turbopackQueues]: ()=>{} + }; + return ret; + }); +} +function asyncModule(module, body, hasAwait) { + const queue = hasAwait ? Object.assign([], { + resolved: true + }) : undefined; + const depQueues = new Set(); + const exports = module.exports; + const { resolve, reject, promise: rawPromise } = createPromise(); + const promise = Object.assign(rawPromise, { + [turbopackExports]: exports, + [turbopackQueues]: (fn)=>{ + queue && fn(queue); + depQueues.forEach(fn); + promise["catch"](()=>{}); + } + }); + module.exports = module.namespaceObject = promise; + function handleAsyncDependencies(deps) { + const currentDeps = wrapDeps(deps); + const getResult = ()=>currentDeps.map((d)=>{ + if (d[turbopackError]) throw d[turbopackError]; + return d[turbopackExports]; + }); + const { promise, resolve } = createPromise(); + const fn = Object.assign(()=>resolve(getResult), { + queueCount: 0 + }); + function fnQueue(q) { + if (q !== queue && !depQueues.has(q)) { + depQueues.add(q); + if (q && !q.resolved) { + fn.queueCount++; + q.push(fn); + } + } + } + currentDeps.map((dep)=>dep[turbopackQueues](fnQueue)); + return fn.queueCount ? promise : getResult(); + } + function asyncResult(err) { + if (err) { + reject(promise[turbopackError] = err); + } else { + resolve(exports); + } + resolveQueue(queue); + } + body(handleAsyncDependencies, asyncResult); + if (queue) { + queue.resolved = false; + } +} ; function commonJsRequireContext(entry, sourceModule) { return entry.external ? externalRequire(entry.id(), false) : commonJsRequire(sourceModule, entry.id()); @@ -215,6 +346,7 @@ function instantiateModule(id, source) { moduleCache[id] = module1; try { moduleFactory.call(module1.exports, { + a: asyncModule.bind(null, module1), e: module1.exports, r: commonJsRequire.bind(null, module1), x: externalRequire, @@ -222,7 +354,7 @@ function instantiateModule(id, source) { f: requireContext.bind(null, module1), i: esmImport.bind(null, module1), s: esm.bind(null, module1.exports), - j: dynamicExport.bind(null, module1), + j: dynamicExport.bind(null, module1, module1.exports), v: exportValue.bind(null, module1), n: exportNamespace.bind(null, module1), m: module1, diff --git a/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js.map b/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js.map index be0c478d3d6f5..fe210c43f4e38 100644 --- a/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js.map +++ b/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js.map @@ -1,6 +1,7 @@ { "version": 3, "sections": [ - {"offset": {"line": 1, "column": 0}, "map": {"version":3,"sources":["/turbopack/[turbopack]/shared/runtime-utils.ts"],"sourcesContent":["/**\n * This file contains runtime types and functions that are shared between all\n * TurboPack ECMAScript runtimes.\n *\n * It will be prepended to the runtime code of each runtime.\n */\n\n/* eslint-disable @next/next/no-assign-module-variable */\n\n/// \n\ninterface Exports {\n __esModule?: boolean;\n\n [key: string]: any;\n}\ntype EsmNamespaceObject = Record;\n\nconst REEXPORTED_OBJECTS = Symbol(\"reexported objects\");\n\ninterface BaseModule {\n exports: Exports;\n error: Error | undefined;\n loaded: boolean;\n id: ModuleId;\n children: ModuleId[];\n parents: ModuleId[];\n namespaceObject?: EsmNamespaceObject;\n [REEXPORTED_OBJECTS]?: any[];\n}\n\ninterface Module extends BaseModule {}\n\ntype RequireContextMap = Record;\n\ninterface RequireContextEntry {\n id: () => ModuleId;\n}\n\ninterface RequireContext {\n (moduleId: ModuleId): Exports | EsmNamespaceObject;\n keys(): ModuleId[];\n resolve(moduleId: ModuleId): ModuleId;\n}\n\ntype GetOrInstantiateModuleFromParent = (\n moduleId: ModuleId,\n parentModule: Module\n) => Module;\n\ntype CommonJsRequireContext = (\n entry: RequireContextEntry,\n parentModule: Module\n) => Exports;\n\nconst hasOwnProperty = Object.prototype.hasOwnProperty;\nconst toStringTag = typeof Symbol !== \"undefined\" && Symbol.toStringTag;\n\nfunction defineProp(\n obj: any,\n name: PropertyKey,\n options: PropertyDescriptor & ThisType\n) {\n if (!hasOwnProperty.call(obj, name))\n Object.defineProperty(obj, name, options);\n}\n\n/**\n * Adds the getters to the exports object.\n */\nfunction esm(exports: Exports, getters: Record any>) {\n defineProp(exports, \"__esModule\", { value: true });\n if (toStringTag) defineProp(exports, toStringTag, { value: \"Module\" });\n for (const key in getters) {\n defineProp(exports, key, { get: getters[key], enumerable: true });\n }\n}\n\n/**\n * Makes the module an ESM with exports\n */\nfunction esmExport(module: Module, getters: Record any>) {\n esm((module.namespaceObject = module.exports), getters);\n}\n\n/**\n * Dynamically exports properties from an object\n */\nfunction dynamicExport(module: Module, object: Record) {\n let reexportedObjects = module[REEXPORTED_OBJECTS];\n if (!reexportedObjects) {\n reexportedObjects = module[REEXPORTED_OBJECTS] = [];\n module.exports = module.namespaceObject = new Proxy(module.exports, {\n get(target, prop) {\n if (\n hasOwnProperty.call(target, prop) ||\n prop === \"default\" ||\n prop === \"__esModule\"\n ) {\n return Reflect.get(target, prop);\n }\n for (const obj of reexportedObjects!) {\n const value = Reflect.get(obj, prop);\n if (value !== undefined) return value;\n }\n return undefined;\n },\n ownKeys(target) {\n const keys = Reflect.ownKeys(target);\n for (const obj of reexportedObjects!) {\n for (const key of Reflect.ownKeys(obj)) {\n if (key !== \"default\" && !keys.includes(key)) keys.push(key);\n }\n }\n return keys;\n },\n });\n }\n reexportedObjects.push(object);\n}\n\nfunction exportValue(module: Module, value: any) {\n module.exports = value;\n}\n\nfunction exportNamespace(module: Module, namespace: any) {\n module.exports = module.namespaceObject = namespace;\n}\n\nfunction createGetter(obj: Record, key: string) {\n return () => obj[key];\n}\n\n/**\n * @returns prototype of the object\n */\nconst getProto: (obj: any) => any = Object.getPrototypeOf\n ? (obj) => Object.getPrototypeOf(obj)\n : (obj) => obj.__proto__;\n\n/** Prototypes that are not expanded for exports */\nconst LEAF_PROTOTYPES = [null, getProto({}), getProto([]), getProto(getProto)];\n\n/**\n * @param allowExportDefault\n * * `false`: will have the raw module as default export\n * * `true`: will have the default property as default export\n */\nfunction interopEsm(\n raw: Exports,\n ns: EsmNamespaceObject,\n allowExportDefault?: boolean\n) {\n const getters: { [s: string]: () => any } = Object.create(null);\n for (\n let current = raw;\n (typeof current === \"object\" || typeof current === \"function\") &&\n !LEAF_PROTOTYPES.includes(current);\n current = getProto(current)\n ) {\n for (const key of Object.getOwnPropertyNames(current)) {\n getters[key] = createGetter(raw, key);\n }\n }\n if (!(allowExportDefault && \"default\" in getters)) {\n getters[\"default\"] = () => raw;\n }\n esm(ns, getters);\n}\n\nfunction esmImport(sourceModule: Module, id: ModuleId): EsmNamespaceObject {\n const module = getOrInstantiateModuleFromParent(id, sourceModule);\n if (module.error) throw module.error;\n if (module.namespaceObject) return module.namespaceObject;\n const raw = module.exports;\n const ns = (module.namespaceObject = {});\n interopEsm(raw, ns, raw.__esModule);\n return ns;\n}\n\nfunction commonJsRequire(sourceModule: Module, id: ModuleId): Exports {\n const module = getOrInstantiateModuleFromParent(id, sourceModule);\n if (module.error) throw module.error;\n return module.exports;\n}\n\ntype RequireContextFactory = (map: RequireContextMap) => RequireContext;\n\nfunction requireContext(\n sourceModule: Module,\n map: RequireContextMap\n): RequireContext {\n function requireContext(id: ModuleId): Exports {\n const entry = map[id];\n\n if (!entry) {\n throw new Error(\n `module ${id} is required from a require.context, but is not in the context`\n );\n }\n\n return commonJsRequireContext(entry, sourceModule);\n }\n\n requireContext.keys = (): ModuleId[] => {\n return Object.keys(map);\n };\n\n requireContext.resolve = (id: ModuleId): ModuleId => {\n const entry = map[id];\n\n if (!entry) {\n throw new Error(\n `module ${id} is resolved from a require.context, but is not in the context`\n );\n }\n\n return entry.id();\n };\n\n return requireContext;\n}\n\n/**\n * Returns the path of a chunk defined by its data.\n */\nfunction getChunkPath(chunkData: ChunkData): ChunkPath {\n return typeof chunkData === \"string\" ? chunkData : chunkData.path;\n}\n"],"names":[],"mappings":";AAkBA,MAAM,qBAAqB,OAAO;;;;;AAqClC,MAAM,iBAAiB,OAAO,SAAS,CAAC,cAAc;AACtD,MAAM,cAAc,OAAO,WAAW,eAAe,OAAO,WAAW;AAEvE,SAAS,WACP,GAAQ,EACR,IAAiB,EACjB,OAA2C;IAE3C,IAAI,CAAC,eAAe,IAAI,CAAC,KAAK,OAC5B,OAAO,cAAc,CAAC,KAAK,MAAM;AACrC;AAKA,SAAS,IAAI,OAAgB,EAAE,OAAkC;IAC/D,WAAW,SAAS,cAAc;QAAE,OAAO;IAAK;IAChD,IAAI,aAAa,WAAW,SAAS,aAAa;QAAE,OAAO;IAAS;IACpE,IAAK,MAAM,OAAO,QAAS;QACzB,WAAW,SAAS,KAAK;YAAE,KAAK,OAAO,CAAC,IAAI;YAAE,YAAY;QAAK;IACjE;AACF;AAKA,SAAS,UAAU,MAAc,EAAE,OAAkC;IACnE,IAAK,OAAO,eAAe,GAAG,OAAO,OAAO,EAAG;AACjD;AAKA,SAAS,cAAc,MAAc,EAAE,MAA2B;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E,GAAG,8DAA8D,CAAC;QAEhF;QAEA,OAAO,MAAM,EAAE;IACjB;IAEA,OAAO;AACT;AAKA,SAAS,aAAa,SAAoB;IACxC,OAAO,OAAO,cAAc,WAAW,YAAY,UAAU,IAAI;AACnE"}}, - {"offset": {"line": 122, "column": 0}, "map": {"version":3,"sources":["/turbopack/[turbopack]/build/runtime.ts"],"sourcesContent":["/// \n\ndeclare var RUNTIME_PUBLIC_PATH: string;\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\ninterface RequireContextEntry {\n external: boolean;\n}\n\ntype ExternalRequire = (id: ModuleId) => Exports | EsmNamespaceObject;\n\ninterface TurbopackNodeBuildContext {\n e: Module[\"exports\"];\n r: CommonJsRequire;\n x: ExternalRequire;\n f: RequireContextFactory;\n i: EsmImport;\n s: EsmExport;\n j: typeof dynamicExport;\n v: ExportValue;\n n: typeof exportNamespace;\n m: Module;\n c: ModuleCache;\n l: LoadChunk;\n g: typeof globalThis;\n __dirname: string;\n}\n\ntype ModuleFactory = (\n this: Module[\"exports\"],\n context: TurbopackNodeBuildContext\n) => undefined;\n\nconst path = require(\"path\");\nconst relativePathToRuntimeRoot = path.relative(RUNTIME_PUBLIC_PATH, \".\");\nconst RUNTIME_ROOT = path.resolve(__filename, relativePathToRuntimeRoot);\n\nconst moduleFactories: ModuleFactories = Object.create(null);\nconst moduleCache: ModuleCache = Object.create(null);\n\nfunction commonJsRequireContext(\n entry: RequireContextEntry,\n sourceModule: Module\n): Exports {\n return entry.external\n ? externalRequire(entry.id(), false)\n : commonJsRequire(sourceModule, entry.id());\n}\n\nfunction externalRequire(\n id: ModuleId,\n esm: boolean = false\n): Exports | EsmNamespaceObject {\n let raw;\n try {\n raw = require(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 if (!esm || raw.__esModule) {\n return raw;\n }\n const ns = {};\n interopEsm(raw, ns, true);\n return ns;\n}\nexternalRequire.resolve = (\n id: string,\n options?:\n | {\n paths?: string[] | undefined;\n }\n | undefined\n) => {\n return require.resolve(id, options);\n};\n\nfunction loadChunk(chunkPath: ChunkPath) {\n if (!chunkPath.endsWith(\".js\")) {\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 const resolved = require.resolve(path.resolve(RUNTIME_ROOT, chunkPath));\n delete require.cache[resolved];\n const chunkModules: ModuleFactories = require(resolved);\n\n for (const [moduleId, moduleFactory] of Object.entries(chunkModules)) {\n if (!moduleFactories[moduleId]) {\n moduleFactories[moduleId] = moduleFactory;\n }\n }\n}\n\nfunction loadChunkAsync(source: SourceInfo, chunkPath: string): Promise {\n return new Promise((resolve, reject) => {\n try {\n loadChunk(chunkPath);\n } catch (err) {\n reject(err);\n return;\n }\n resolve();\n });\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 }\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 let parents: ModuleId[];\n switch (source.type) {\n case SourceType.Runtime:\n parents = [];\n break;\n case SourceType.Parent:\n // No need to add this module as a child of the parent module here, this\n // has already been taken care of in `getOrInstantiateModuleFromParent`.\n parents = [source.parentId];\n break;\n }\n\n const module: Module = {\n exports: {},\n error: undefined,\n loaded: false,\n id,\n parents,\n children: [],\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 moduleFactory.call(module.exports, {\n e: module.exports,\n r: commonJsRequire.bind(null, module),\n x: externalRequire,\n f: requireContext.bind(null, module),\n i: esmImport.bind(null, module),\n s: esm.bind(null, module.exports),\n j: dynamicExport.bind(null, module),\n v: exportValue.bind(null, module),\n n: exportNamespace.bind(null, module),\n m: module,\n c: moduleCache,\n l: loadChunkAsync.bind(null, { type: SourceType.Parent, parentId: id }),\n g: globalThis,\n __dirname: module.id.replace(/(^|\\/)[\\/]+$/, \"\"),\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 */\nfunction getOrInstantiateModuleFromParent(\n id: ModuleId,\n sourceModule: Module\n): Module {\n const module = moduleCache[id];\n\n if (sourceModule.children.indexOf(id) === -1) {\n sourceModule.children.push(id);\n }\n\n if (module) {\n if (module.parents.indexOf(sourceModule.id) === -1) {\n module.parents.push(sourceModule.id);\n }\n\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 */\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\nmodule.exports = {\n getOrInstantiateRuntimeModule,\n loadChunk,\n};\n"],"names":[],"mappings":";IAIA;UAAK,UAAU;IAAV,WAAA,WAKH,aAAU,KAAV;IALG,WAAA,WASH,YAAS,KAAT;GATG,eAAA;;;AAkDL,MAAM,OAAO,QAAQ;AACrB,MAAM,4BAA4B,KAAK,QAAQ,CAAC,qBAAqB;AACrE,MAAM,eAAe,KAAK,OAAO,CAAC,YAAY;AAE9C,MAAM,kBAAmC,OAAO,MAAM,CAAC;AACvD,MAAM,cAA2B,OAAO,MAAM,CAAC;AAE/C,SAAS,uBACP,KAA0B,EAC1B,YAAoB;IAEpB,OAAO,MAAM,QAAQ,GACjB,gBAAgB,MAAM,EAAE,IAAI,SAC5B,gBAAgB,cAAc,MAAM,EAAE;AAC5C;AAEA,SAAS,gBACP,EAAY,EACZ,OAAe,KAAK;IAEpB,IAAI;IACJ,IAAI;QACF,MAAM,QAAQ;IAChB,EAAE,OAAO,KAAK;QAKZ,MAAM,IAAI,MAAM,CAAC,+BAA+B,EAAE,GAAG,EAAE,EAAE,IAAI,CAAC;IAChE;IACA,IAAI,CAAC,QAAO,IAAI,UAAU,EAAE;QAC1B,OAAO;IACT;IACA,MAAM,KAAK,CAAC;IACZ,WAAW,KAAK,IAAI;IACpB,OAAO;AACT;AACA,gBAAgB,OAAO,GAAG,CACxB,IACA;IAMA,OAAO,QAAQ,OAAO,CAAC,IAAI;AAC7B;AAEA,SAAS,UAAU,SAAoB;IACrC,IAAI,CAAC,UAAU,QAAQ,CAAC,QAAQ;QAG9B;IACF;IAEA,MAAM,WAAW,QAAQ,OAAO,CAAC,KAAK,OAAO,CAAC,cAAc;IAC5D,OAAO,QAAQ,KAAK,CAAC,SAAS;IAC9B,MAAM,eAAgC,QAAQ;IAE9C,KAAK,MAAM,CAAC,UAAU,cA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,OAAO;IACT;IAEA,OAAO,yBAAyB,UAAU;AAC5C;AAEA,OAAO,OAAO,GAAG;IACf;IACA;AACF"}}] + {"offset": {"line": 1, "column": 0}, "map": {"version":3,"sources":["/turbopack/[turbopack]/shared/runtime-utils.ts"],"sourcesContent":["/**\n * This file contains runtime types and functions that are shared between all\n * TurboPack ECMAScript runtimes.\n *\n * It will be prepended to the runtime code of each runtime.\n */\n\n/* eslint-disable @next/next/no-assign-module-variable */\n\n/// \n\ninterface Exports {\n __esModule?: boolean;\n\n [key: string]: any;\n}\n\ntype EsmNamespaceObject = Record;\n\nconst REEXPORTED_OBJECTS = Symbol(\"reexported objects\");\n\ninterface BaseModule {\n exports: Exports | Promise | AsyncModulePromise;\n error: Error | undefined;\n loaded: boolean;\n id: ModuleId;\n children: ModuleId[];\n parents: ModuleId[];\n namespaceObject?:\n | EsmNamespaceObject\n | Promise\n | AsyncModulePromise;\n [REEXPORTED_OBJECTS]?: any[];\n}\n\ninterface Module extends BaseModule {}\n\ntype RequireContextMap = Record;\n\ninterface RequireContextEntry {\n id: () => ModuleId;\n}\n\ninterface RequireContext {\n (moduleId: ModuleId): Exports | EsmNamespaceObject;\n\n keys(): ModuleId[];\n\n resolve(moduleId: ModuleId): ModuleId;\n}\n\ntype GetOrInstantiateModuleFromParent = (\n moduleId: ModuleId,\n parentModule: Module\n) => Module;\n\ntype CommonJsRequireContext = (\n entry: RequireContextEntry,\n parentModule: Module\n) => Exports;\n\nconst hasOwnProperty = Object.prototype.hasOwnProperty;\nconst toStringTag = typeof Symbol !== \"undefined\" && Symbol.toStringTag;\n\nfunction defineProp(\n obj: any,\n name: PropertyKey,\n options: PropertyDescriptor & ThisType\n) {\n if (!hasOwnProperty.call(obj, name))\n Object.defineProperty(obj, name, options);\n}\n\n/**\n * Adds the getters to the exports object.\n */\nfunction esm(exports: Exports, getters: Record any>) {\n defineProp(exports, \"__esModule\", { value: true });\n if (toStringTag) defineProp(exports, toStringTag, { value: \"Module\" });\n for (const key in getters) {\n defineProp(exports, key, { get: getters[key], enumerable: true });\n }\n}\n\n/**\n * Makes the module an ESM with exports\n */\nfunction esmExport(\n module: Module,\n exports: Exports,\n getters: Record any>\n) {\n module.namespaceObject = module.exports;\n esm(exports, getters);\n}\n\n/**\n * Dynamically exports properties from an object\n */\nfunction dynamicExport(\n module: Module,\n exports: Exports,\n object: Record\n) {\n let reexportedObjects = module[REEXPORTED_OBJECTS];\n if (!reexportedObjects) {\n reexportedObjects = module[REEXPORTED_OBJECTS] = [];\n\n const namespaceObject = new Proxy(exports, {\n get(target, prop) {\n if (\n hasOwnProperty.call(target, prop) ||\n prop === \"default\" ||\n prop === \"__esModule\"\n ) {\n return Reflect.get(target, prop);\n }\n for (const obj of reexportedObjects!) {\n const value = Reflect.get(obj, prop);\n if (value !== undefined) return value;\n }\n return undefined;\n },\n ownKeys(target) {\n const keys = Reflect.ownKeys(target);\n for (const obj of reexportedObjects!) {\n for (const key of Reflect.ownKeys(obj)) {\n if (key !== \"default\" && !keys.includes(key)) keys.push(key);\n }\n }\n return keys;\n },\n });\n\n // If this is inside an async module `module.namespaceObject` is a promise,\n // so we need to replace it with a new promise.\n if (isPromise(module.namespaceObject)) {\n module.exports = module.namespaceObject = maybeWrapAsyncModulePromise(\n module.namespaceObject,\n () => namespaceObject\n );\n } else {\n module.exports = module.namespaceObject = namespaceObject;\n }\n }\n reexportedObjects.push(object);\n}\n\nfunction exportValue(module: Module, value: any) {\n module.exports = value;\n}\n\nfunction exportNamespace(module: Module, namespace: any) {\n module.exports = module.namespaceObject = namespace;\n}\n\nfunction createGetter(obj: Record, key: string) {\n return () => obj[key];\n}\n\n/**\n * @returns prototype of the object\n */\nconst getProto: (obj: any) => any = Object.getPrototypeOf\n ? (obj) => Object.getPrototypeOf(obj)\n : (obj) => obj.__proto__;\n\n/** Prototypes that are not expanded for exports */\nconst LEAF_PROTOTYPES = [null, getProto({}), getProto([]), getProto(getProto)];\n\n/**\n * @param raw\n * @param ns\n * @param allowExportDefault\n * * `false`: will have the raw module as default export\n * * `true`: will have the default property as default export\n */\nfunction interopEsm(\n raw: Exports,\n ns: EsmNamespaceObject,\n allowExportDefault?: boolean\n) {\n const getters: { [s: string]: () => any } = Object.create(null);\n for (\n let current = raw;\n (typeof current === \"object\" || typeof current === \"function\") &&\n !LEAF_PROTOTYPES.includes(current);\n current = getProto(current)\n ) {\n for (const key of Object.getOwnPropertyNames(current)) {\n getters[key] = createGetter(raw, key);\n }\n }\n\n // this is not really correct\n // we should set the `default` getter if the imported module is a `.cjs file`\n if (!(allowExportDefault && \"default\" in getters)) {\n getters[\"default\"] = () => raw;\n }\n\n esm(ns, getters);\n return ns;\n}\n\nfunction esmImport(\n sourceModule: Module,\n id: ModuleId\n): Exclude {\n const module = getOrInstantiateModuleFromParent(id, sourceModule);\n if (module.error) throw module.error;\n\n // any async module has to have `module.namespaceObject` defined\n if (module.namespaceObject) return module.namespaceObject;\n\n // can't be an async module at this point\n const raw = module.exports;\n return (module.namespaceObject = interopEsm(\n raw,\n {},\n (raw as any).__esModule\n ));\n}\n\nfunction commonJsRequire(sourceModule: Module, id: ModuleId): Exports {\n const module = getOrInstantiateModuleFromParent(id, sourceModule);\n if (module.error) throw module.error;\n return module.exports;\n}\n\ntype RequireContextFactory = (map: RequireContextMap) => RequireContext;\n\nfunction requireContext(\n sourceModule: Module,\n map: RequireContextMap\n): RequireContext {\n function requireContext(id: ModuleId): Exports {\n const entry = map[id];\n\n if (!entry) {\n throw new Error(\n `module ${id} is required from a require.context, but is not in the context`\n );\n }\n\n return commonJsRequireContext(entry, sourceModule);\n }\n\n requireContext.keys = (): ModuleId[] => {\n return Object.keys(map);\n };\n\n requireContext.resolve = (id: ModuleId): ModuleId => {\n const entry = map[id];\n\n if (!entry) {\n throw new Error(\n `module ${id} is resolved from a require.context, but is not in the context`\n );\n }\n\n return entry.id();\n };\n\n return requireContext;\n}\n\n/**\n * Returns the path of a chunk defined by its data.\n */\nfunction getChunkPath(chunkData: ChunkData): ChunkPath {\n return typeof chunkData === \"string\" ? chunkData : chunkData.path;\n}\n\nfunction isPromise(maybePromise: any): maybePromise is Promise {\n return (\n maybePromise != null &&\n typeof maybePromise === \"object\" &&\n \"then\" in maybePromise &&\n typeof maybePromise.then === \"function\"\n );\n}\n\nfunction isAsyncModuleExt(obj: T): obj is AsyncModuleExt & T {\n return turbopackQueues in obj;\n}\n\nfunction maybeWrapAsyncModulePromise(\n promise: Promise,\n then: (val: T) => U | PromiseLike\n): typeof promise extends AsyncModulePromise\n ? AsyncModulePromise\n : Promise {\n const newPromise = promise.then(then);\n\n if (isAsyncModuleExt(promise)) {\n Object.assign(newPromise, {\n get [turbopackExports]() {\n return promise[turbopackExports];\n },\n get [turbopackQueues]() {\n return promise[turbopackQueues];\n },\n get [turbopackError]() {\n return promise[turbopackError];\n },\n } satisfies AsyncModuleExt);\n }\n\n return newPromise as any;\n}\n\nfunction createPromise() {\n let resolve: (value: T | PromiseLike) => void;\n let reject: (reason?: any) => void;\n\n const promise = new Promise((res, rej) => {\n reject = rej;\n resolve = res;\n });\n\n return {\n promise,\n resolve: resolve!,\n reject: reject!,\n };\n}\n\n// everything below is adapted from webpack\n// https://github.com/webpack/webpack/blob/6be4065ade1e252c1d8dcba4af0f43e32af1bdc1/lib/runtime/AsyncModuleRuntimeModule.js#L13\n\nconst turbopackQueues = Symbol(\"turbopack queues\");\nconst turbopackExports = Symbol(\"turbopack exports\");\nconst turbopackError = Symbol(\"turbopack error\");\n\ntype AsyncQueueFn = (() => void) & { queueCount: number };\ntype AsyncQueue = AsyncQueueFn[] & { resolved: boolean };\n\nfunction resolveQueue(queue?: AsyncQueue) {\n if (queue && !queue.resolved) {\n queue.resolved = true;\n queue.forEach((fn) => fn.queueCount--);\n queue.forEach((fn) => (fn.queueCount-- ? fn.queueCount++ : fn()));\n }\n}\n\ntype Dep = Exports | AsyncModulePromise | Promise;\n\ntype AsyncModuleExt = {\n [turbopackQueues]: (fn: (queue: AsyncQueue) => void) => void;\n [turbopackExports]: Exports;\n [turbopackError]?: any;\n};\n\ntype AsyncModulePromise = Promise & AsyncModuleExt;\n\nfunction wrapDeps(deps: Dep[]): AsyncModuleExt[] {\n return deps.map((dep) => {\n if (dep !== null && typeof dep === \"object\") {\n if (isAsyncModuleExt(dep)) return dep;\n if (isPromise(dep)) {\n const queue: AsyncQueue = Object.assign([], { resolved: false });\n\n const obj: AsyncModuleExt = {\n [turbopackExports]: {},\n [turbopackQueues]: (fn: (queue: AsyncQueue) => void) => fn(queue),\n };\n\n dep.then(\n (res) => {\n obj[turbopackExports] = res;\n resolveQueue(queue);\n },\n (err) => {\n obj[turbopackError] = err;\n resolveQueue(queue);\n }\n );\n\n return obj;\n }\n }\n\n const ret: AsyncModuleExt = {\n [turbopackExports]: dep,\n [turbopackQueues]: () => {},\n };\n\n return ret;\n });\n}\n\nfunction asyncModule(\n module: Module,\n body: (\n handleAsyncDependencies: (\n deps: Dep[]\n ) => Exports[] | Promise<() => Exports[]>,\n asyncResult: (err?: any) => void\n ) => void,\n hasAwait: boolean\n) {\n const queue: AsyncQueue | undefined = hasAwait\n ? Object.assign([], { resolved: true })\n : undefined;\n\n const depQueues: Set = new Set();\n const exports = module.exports;\n\n const { resolve, reject, promise: rawPromise } = createPromise();\n\n const promise: AsyncModulePromise = Object.assign(rawPromise, {\n [turbopackExports]: exports,\n [turbopackQueues]: (fn) => {\n queue && fn(queue);\n depQueues.forEach(fn);\n promise[\"catch\"](() => {});\n },\n } satisfies AsyncModuleExt);\n\n module.exports = module.namespaceObject = promise;\n\n function handleAsyncDependencies(deps: Dep[]) {\n const currentDeps = wrapDeps(deps);\n\n const getResult = () =>\n currentDeps.map((d) => {\n if (d[turbopackError]) throw d[turbopackError];\n return d[turbopackExports];\n });\n\n const { promise, resolve } = createPromise<() => Exports[]>();\n\n const fn: AsyncQueueFn = Object.assign(() => resolve(getResult), {\n queueCount: 0,\n });\n\n function fnQueue(q: AsyncQueue) {\n if (q !== queue && !depQueues.has(q)) {\n depQueues.add(q);\n if (q && !q.resolved) {\n fn.queueCount++;\n q.push(fn);\n }\n }\n }\n\n currentDeps.map((dep) => dep[turbopackQueues](fnQueue));\n\n return fn.queueCount ? promise : getResult();\n }\n\n function asyncResult(err?: any) {\n if (err) {\n reject((promise[turbopackError] = err));\n } else {\n resolve(exports);\n }\n\n resolveQueue(queue);\n }\n\n body(handleAsyncDependencies, asyncResult);\n\n if (queue) {\n queue.resolved = false;\n }\n}\n"],"names":[],"mappings":";AAmBA,MAAM,qBAAqB,OAAO;;;;;AA0ClC,MAAM,iBAAiB,OAAO,SAAS,CAAC,cAAc;AACtD,MAAM,cAAc,OAAO,WAAW,eAAe,OAAO,WAAW;AAEvE,SAAS,WACP,GAAQ,EACR,IAAiB,EACjB,OAA2C;IAE3C,IAAI,CAAC,eAAe,IAAI,CAAC,KAAK,OAC5B,OAAO,cAAc,CAAC,KAAK,MAAM;AACrC;AAKA,SAAS,IAAI,OAAgB,EAAE,OAAkC;IAC/D,WAAW,SAAS,cAAc;QAAE,OAAO;IAAK;IAChD,IAAI,aAAa,WAAW,SAAS,aAAa;QAAE,OAAO;IAAS;IACpE,IAAK,MAAM,OAAO,QAAS;QACzB,WAAW,SAAS,KAAK;YAAE,KAAK,OAAO,CAAC,IAAI;YAAE,YAAY;QAAK;IACjE;AACF;AAKA,SAAS,UACP,MAAc,EACd,OAAgB,EAChB,OAAkC;IAElC,OAAO,eAAe,GAAG,OAAO,OAAO;IACvC,IAAI,SAAS;AACf;AAKA,SAAS,cACP,MAAc,EACd,OAAgB,EAChB,MAA2B;IAE3B,IAAI,oBAAoB,MAAM,CAAC,mBAAmB;IAClD,IAAI,CAAC,mBAAmB;QACtB,oBAAoB,MAAM,CAAC,mBAAmB,GAAG,EAAE;QAEnD,MAAM,kBAAkB,IAAI,MAAM,SAAS;YACzC,KAAI,MAAM,EAAE,IAAI;gBACd,IACE,eAAe,IAAI,CAAC,QAAQ,SAC5B,SAAS,aACT,SAAS,cACT;oBACA,OAAO,QAAQ,GAAG,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d;QAEA,SAAS,QAAQ,CAAa;YAC5B,IAAI,MAAM,SAAS,CAAC,UAAU,GAAG,CAAC,IAAI;gBACpC,UAAU,GAAG,CAAC;gBACd,IAAI,KAAK,CAAC,EAAE,QAAQ,EAAE;oBACpB,GAAG,UAAU;oBACb,EAAE,IAAI,CAAC;gBACT;YACF;QACF;QAEA,YAAY,GAAG,CAAC,CAAC,MAAQ,GAAG,CAAC,gBAAgB,CAAC;QAE9C,OAAO,GAAG,UAAU,GAAG,UAAU;IACnC;IAEA,SAAS,YAAY,GAAS;QAC5B,IAAI,KAAK;YACP,OAAQ,OAAO,CAAC,eAAe,GAAG;QACpC,OAAO;YACL,QAAQ;QACV;QAEA,aAAa;IACf;IAEA,KAAK,yBAAyB;IAE9B,IAAI,OAAO;QACT,MAAM,QAAQ,GAAG;IACnB;AACF"}}, + {"offset": {"line": 253, "column": 0}, "map": {"version":3,"sources":["/turbopack/[turbopack]/shared-node/require.ts"],"sourcesContent":["/// \n\ninterface RequireContextEntry {\n external: boolean;\n}\n\nfunction commonJsRequireContext(\n entry: RequireContextEntry,\n sourceModule: Module\n): Exports {\n return entry.external\n ? externalRequire(entry.id(), false)\n : commonJsRequire(sourceModule, entry.id());\n}\n\nfunction externalImport(id: ModuleId) {\n return import(id);\n}\n\nfunction externalRequire(\n id: ModuleId,\n esm: boolean = false\n): Exports | EsmNamespaceObject {\n let raw;\n try {\n raw = require(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 (!esm || raw.__esModule) {\n return raw;\n }\n\n return interopEsm(raw, {}, true);\n}\nexternalRequire.resolve = (\n id: string,\n options?:\n | {\n paths?: string[] | undefined;\n }\n | undefined\n) => {\n return require.resolve(id, options);\n};\n"],"names":[],"mappings":";AAMA,SAAS,uBACP,KAA0B,EAC1B,YAAoB;IAEpB,OAAO,MAAM,QAAQ,GACjB,gBAAgB,MAAM,EAAE,IAAI,SAC5B,gBAAgB,cAAc,MAAM,EAAE;AAC5C;AAEA,SAAS,eAAe,EAAY;IAClC,OAAO,MAAM,CAAC;AAChB;AAEA,SAAS,gBACP,EAAY,EACZ,MAAe,KAAK;IAEpB,IAAI;IACJ,IAAI;QACF,MAAM,QAAQ;IAChB,EAAE,OAAO,KAAK;QAKZ,MAAM,IAAI,MAAM,CAAC,+BAA+B,EAAE,GAAG,EAAE,EAAE,IAAI,CAAC;IAChE;IAEA,IAAI,CAAC,OAAO,IAAI,UAAU,EAAE;QAC1B,OAAO;IACT;IAEA,OAAO,WAAW,KAAK,CAAC,GAAG;AAC7B;AACA,gBAAgB,OAAO,GAAG,CACxB,IACA;IAMA,OAAO,QAAQ,OAAO,CAAC,IAAI;AAC7B"}}, + {"offset": {"line": 275, "column": 0}, "map": {"version":3,"sources":["/turbopack/[turbopack]/build/runtime.ts"],"sourcesContent":["/// \n/// \n\ndeclare var RUNTIME_PUBLIC_PATH: string;\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\ntype ExternalRequire = (id: ModuleId) => Exports | EsmNamespaceObject;\ntype ExternalImport = (id: ModuleId) => Promise;\n\ninterface TurbopackNodeBuildContext extends TurbopackBaseContext {\n x: ExternalRequire;\n y: ExternalImport;\n}\n\ntype ModuleFactory = (\n this: Module[\"exports\"],\n context: TurbopackNodeBuildContext\n) => undefined;\n\nconst path = require(\"path\");\nconst relativePathToRuntimeRoot = path.relative(RUNTIME_PUBLIC_PATH, \".\");\nconst RUNTIME_ROOT = path.resolve(__filename, relativePathToRuntimeRoot);\n\nconst moduleFactories: ModuleFactories = Object.create(null);\nconst moduleCache: ModuleCache = Object.create(null);\n\nfunction loadChunk(chunkPath: ChunkPath) {\n if (!chunkPath.endsWith(\".js\")) {\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 const resolved = require.resolve(path.resolve(RUNTIME_ROOT, chunkPath));\n delete require.cache[resolved];\n const chunkModules: ModuleFactories = require(resolved);\n\n for (const [moduleId, moduleFactory] of Object.entries(chunkModules)) {\n if (!moduleFactories[moduleId]) {\n moduleFactories[moduleId] = moduleFactory;\n }\n }\n}\n\nfunction loadChunkAsync(source: SourceInfo, chunkPath: string): Promise {\n return new Promise((resolve, reject) => {\n try {\n loadChunk(chunkPath);\n } catch (err) {\n reject(err);\n return;\n }\n resolve();\n });\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 }\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 let parents: ModuleId[];\n switch (source.type) {\n case SourceType.Runtime:\n parents = [];\n break;\n case SourceType.Parent:\n // No need to add this module as a child of the parent module here, this\n // has already been taken care of in `getOrInstantiateModuleFromParent`.\n parents = [source.parentId];\n break;\n }\n\n const module: Module = {\n exports: {},\n error: undefined,\n loaded: false,\n id,\n parents,\n children: [],\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 moduleFactory.call(module.exports, {\n a: asyncModule.bind(null, module),\n e: module.exports,\n r: commonJsRequire.bind(null, module),\n x: externalRequire,\n y: externalImport,\n f: requireContext.bind(null, module),\n i: esmImport.bind(null, module),\n s: esm.bind(null, module.exports),\n j: dynamicExport.bind(null, module, module.exports),\n v: exportValue.bind(null, module),\n n: exportNamespace.bind(null, module),\n m: module,\n c: moduleCache,\n l: loadChunkAsync.bind(null, { type: SourceType.Parent, parentId: id }),\n g: globalThis,\n __dirname: module.id.replace(/(^|\\/)[\\/]+$/, \"\"),\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 */\nfunction getOrInstantiateModuleFromParent(\n id: ModuleId,\n sourceModule: Module\n): Module {\n const module = moduleCache[id];\n\n if (sourceModule.children.indexOf(id) === -1) {\n sourceModule.children.push(id);\n }\n\n if (module) {\n if (module.parents.indexOf(sourceModule.id) === -1) {\n module.parents.push(sourceModule.id);\n }\n\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 */\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\nmodule.exports = {\n getOrInstantiateRuntimeModule,\n loadChunk,\n};\n"],"names":[],"mappings":";IAKA;UAAK,UAAU;IAAV,WAAA,WAKH,aAAU,KAAV;IALG,WAAA,WASH,YAAS,KAAT;GAT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EA,IAAI,SAAQ;QACV,IAAI,QAAO,OAAO,CAAC,OAAO,CAAC,aAAa,EAAE,MAAM,CAAC,GAAG;YAClD,QAAO,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE;QACrC;QAEA,OAAO;IACT;IAEA,OAAO,kBAAkB,IAAI;QAC3B,MAAM,WAAW,MAAM;QACvB,UAAU,aAAa,EAAE;IAC3B;AACF;AAKA,SAAS,yBACP,QAAkB,EAClB,SAAoB;IAEpB,OAAO,kBAAkB,UAAU;QAAE,MAAM,WAAW,OAAO;QAAE;IAAU;AAC3E;AAKA,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,OAAO,OAAO,GAAG;IACf;IACA;AACF"}}] } \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/79fb1_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_e60ecd.js b/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/79fb1_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_e60ecd.js index 541fccdbc6b09..0ba4dcfc02c06 100644 --- a/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/79fb1_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_e60ecd.js +++ b/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/79fb1_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_e60ecd.js @@ -34,14 +34,15 @@ function esm(exports, getters) { }); } } -function esmExport(module, getters) { - esm(module.namespaceObject = module.exports, getters); +function esmExport(module, exports, getters) { + module.namespaceObject = module.exports; + esm(exports, getters); } -function dynamicExport(module, object) { +function dynamicExport(module, exports, object) { let reexportedObjects = module[REEXPORTED_OBJECTS]; if (!reexportedObjects) { reexportedObjects = module[REEXPORTED_OBJECTS] = []; - module.exports = module.namespaceObject = new Proxy(module.exports, { + const namespaceObject = new Proxy(exports, { get (target, prop) { if (hasOwnProperty.call(target, prop) || prop === "default" || prop === "__esModule") { return Reflect.get(target, prop); @@ -62,6 +63,11 @@ function dynamicExport(module, object) { return keys; } }); + if (isPromise(module.namespaceObject)) { + module.exports = module.namespaceObject = maybeWrapAsyncModulePromise(module.namespaceObject, ()=>namespaceObject); + } else { + module.exports = module.namespaceObject = namespaceObject; + } } reexportedObjects.push(object); } @@ -92,15 +98,14 @@ function interopEsm(raw, ns, allowExportDefault) { getters["default"] = ()=>raw; } esm(ns, getters); + return ns; } function esmImport(sourceModule, id) { const module = getOrInstantiateModuleFromParent(id, sourceModule); if (module.error) throw module.error; if (module.namespaceObject) return module.namespaceObject; const raw = module.exports; - const ns = module.namespaceObject = {}; - interopEsm(raw, ns, raw.__esModule); - return ns; + return module.namespaceObject = interopEsm(raw, {}, raw.__esModule); } function commonJsRequire(sourceModule, id) { const module = getOrInstantiateModuleFromParent(id, sourceModule); @@ -130,6 +135,132 @@ function requireContext(sourceModule, map) { function getChunkPath(chunkData) { return typeof chunkData === "string" ? chunkData : chunkData.path; } +function isPromise(maybePromise) { + return maybePromise != null && typeof maybePromise === "object" && "then" in maybePromise && typeof maybePromise.then === "function"; +} +function isAsyncModuleExt(obj) { + return turbopackQueues in obj; +} +function maybeWrapAsyncModulePromise(promise, then) { + const newPromise = promise.then(then); + if (isAsyncModuleExt(promise)) { + Object.assign(newPromise, { + get [turbopackExports] () { + return promise[turbopackExports]; + }, + get [turbopackQueues] () { + return promise[turbopackQueues]; + }, + get [turbopackError] () { + return promise[turbopackError]; + } + }); + } + return newPromise; +} +function createPromise() { + let resolve; + let reject; + const promise = new Promise((res, rej)=>{ + reject = rej; + resolve = res; + }); + return { + promise, + resolve: resolve, + reject: reject + }; +} +const turbopackQueues = Symbol("turbopack queues"); +const turbopackExports = Symbol("turbopack exports"); +const turbopackError = Symbol("turbopack error"); +function resolveQueue(queue) { + if (queue && !queue.resolved) { + queue.resolved = true; + queue.forEach((fn)=>fn.queueCount--); + queue.forEach((fn)=>fn.queueCount-- ? fn.queueCount++ : fn()); + } +} +function wrapDeps(deps) { + return deps.map((dep)=>{ + if (dep !== null && typeof dep === "object") { + if (isAsyncModuleExt(dep)) return dep; + if (isPromise(dep)) { + const queue = Object.assign([], { + resolved: false + }); + const obj = { + [turbopackExports]: {}, + [turbopackQueues]: (fn)=>fn(queue) + }; + dep.then((res)=>{ + obj[turbopackExports] = res; + resolveQueue(queue); + }, (err)=>{ + obj[turbopackError] = err; + resolveQueue(queue); + }); + return obj; + } + } + const ret = { + [turbopackExports]: dep, + [turbopackQueues]: ()=>{} + }; + return ret; + }); +} +function asyncModule(module, body, hasAwait) { + const queue = hasAwait ? Object.assign([], { + resolved: true + }) : undefined; + const depQueues = new Set(); + const exports = module.exports; + const { resolve, reject, promise: rawPromise } = createPromise(); + const promise = Object.assign(rawPromise, { + [turbopackExports]: exports, + [turbopackQueues]: (fn)=>{ + queue && fn(queue); + depQueues.forEach(fn); + promise["catch"](()=>{}); + } + }); + module.exports = module.namespaceObject = promise; + function handleAsyncDependencies(deps) { + const currentDeps = wrapDeps(deps); + const getResult = ()=>currentDeps.map((d)=>{ + if (d[turbopackError]) throw d[turbopackError]; + return d[turbopackExports]; + }); + const { promise, resolve } = createPromise(); + const fn = Object.assign(()=>resolve(getResult), { + queueCount: 0 + }); + function fnQueue(q) { + if (q !== queue && !depQueues.has(q)) { + depQueues.add(q); + if (q && !q.resolved) { + fn.queueCount++; + q.push(fn); + } + } + } + currentDeps.map((dep)=>dep[turbopackQueues](fnQueue)); + return fn.queueCount ? promise : getResult(); + } + function asyncResult(err) { + if (err) { + reject(promise[turbopackError] = err); + } else { + resolve(exports); + } + resolveQueue(queue); + } + body(handleAsyncDependencies, asyncResult); + if (queue) { + queue.resolved = false; + } +} ; ; ; @@ -275,12 +406,13 @@ function instantiateModule(id, source) { try { runModuleExecutionHooks(module, (refresh)=>{ moduleFactory.call(module.exports, augmentContext({ + a: asyncModule.bind(null, module), e: module.exports, r: commonJsRequire.bind(null, module), f: requireContext.bind(null, module), i: esmImport.bind(null, module), - s: esmExport.bind(null, module), - j: dynamicExport.bind(null, module), + s: esmExport.bind(null, module, module.exports), + j: dynamicExport.bind(null, module, module.exports), v: exportValue.bind(null, module), n: exportNamespace.bind(null, module), m: module, diff --git a/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/79fb1_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_e60ecd.js.map b/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/79fb1_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_e60ecd.js.map index 4490d45c0d37d..edccc038dcc28 100644 --- a/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/79fb1_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_e60ecd.js.map +++ b/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/79fb1_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_e60ecd.js.map @@ -1,8 +1,8 @@ { "version": 3, "sections": [ - {"offset": {"line": 11, "column": 0}, "map": {"version":3,"sources":["/turbopack/[turbopack]/shared/runtime-utils.ts"],"sourcesContent":["/**\n * This file contains runtime types and functions that are shared between all\n * TurboPack ECMAScript runtimes.\n *\n * It will be prepended to the runtime code of each runtime.\n */\n\n/* eslint-disable @next/next/no-assign-module-variable */\n\n/// \n\ninterface Exports {\n __esModule?: boolean;\n\n [key: string]: any;\n}\ntype EsmNamespaceObject = Record;\n\nconst REEXPORTED_OBJECTS = Symbol(\"reexported objects\");\n\ninterface BaseModule {\n exports: Exports;\n error: Error | undefined;\n loaded: boolean;\n id: ModuleId;\n children: ModuleId[];\n parents: ModuleId[];\n namespaceObject?: EsmNamespaceObject;\n [REEXPORTED_OBJECTS]?: any[];\n}\n\ninterface Module extends BaseModule {}\n\ntype RequireContextMap = Record;\n\ninterface RequireContextEntry {\n id: () => ModuleId;\n}\n\ninterface RequireContext {\n (moduleId: ModuleId): Exports | EsmNamespaceObject;\n keys(): ModuleId[];\n resolve(moduleId: ModuleId): ModuleId;\n}\n\ntype GetOrInstantiateModuleFromParent = (\n moduleId: ModuleId,\n parentModule: Module\n) => Module;\n\ntype CommonJsRequireContext = (\n entry: RequireContextEntry,\n parentModule: Module\n) => Exports;\n\nconst hasOwnProperty = Object.prototype.hasOwnProperty;\nconst toStringTag = typeof Symbol !== \"undefined\" && Symbol.toStringTag;\n\nfunction defineProp(\n obj: any,\n name: PropertyKey,\n options: PropertyDescriptor & ThisType\n) {\n if (!hasOwnProperty.call(obj, name))\n Object.defineProperty(obj, name, options);\n}\n\n/**\n * Adds the getters to the exports object.\n */\nfunction esm(exports: Exports, getters: Record any>) {\n defineProp(exports, \"__esModule\", { value: true });\n if (toStringTag) defineProp(exports, toStringTag, { value: \"Module\" });\n for (const key in getters) {\n defineProp(exports, key, { get: getters[key], enumerable: true });\n }\n}\n\n/**\n * Makes the module an ESM with exports\n */\nfunction esmExport(module: Module, getters: Record any>) {\n esm((module.namespaceObject = module.exports), getters);\n}\n\n/**\n * Dynamically exports properties from an object\n */\nfunction dynamicExport(module: Module, object: Record) {\n let reexportedObjects = module[REEXPORTED_OBJECTS];\n if (!reexportedObjects) {\n reexportedObjects = module[REEXPORTED_OBJECTS] = [];\n module.exports = module.namespaceObject = new Proxy(module.exports, {\n get(target, prop) {\n if (\n hasOwnProperty.call(target, prop) ||\n prop === \"default\" ||\n prop === \"__esModule\"\n ) {\n return Reflect.get(target, prop);\n }\n for (const obj of reexportedObjects!) {\n const value = Reflect.get(obj, prop);\n if (value !== undefined) return value;\n }\n return undefined;\n },\n ownKeys(target) {\n const keys = Reflect.ownKeys(target);\n for (const obj of reexportedObjects!) {\n for (const key of Reflect.ownKeys(obj)) {\n if (key !== \"default\" && !keys.includes(key)) keys.push(key);\n }\n }\n return keys;\n },\n });\n }\n reexportedObjects.push(object);\n}\n\nfunction exportValue(module: Module, value: any) {\n module.exports = value;\n}\n\nfunction exportNamespace(module: Module, namespace: any) {\n module.exports = module.namespaceObject = namespace;\n}\n\nfunction createGetter(obj: Record, key: string) {\n return () => obj[key];\n}\n\n/**\n * @returns prototype of the object\n */\nconst getProto: (obj: any) => any = Object.getPrototypeOf\n ? (obj) => Object.getPrototypeOf(obj)\n : (obj) => obj.__proto__;\n\n/** Prototypes that are not expanded for exports */\nconst LEAF_PROTOTYPES = [null, getProto({}), getProto([]), getProto(getProto)];\n\n/**\n * @param allowExportDefault\n * * `false`: will have the raw module as default export\n * * `true`: will have the default property as default export\n */\nfunction interopEsm(\n raw: Exports,\n ns: EsmNamespaceObject,\n allowExportDefault?: boolean\n) {\n const getters: { [s: string]: () => any } = Object.create(null);\n for (\n let current = raw;\n (typeof current === \"object\" || typeof current === \"function\") &&\n !LEAF_PROTOTYPES.includes(current);\n current = getProto(current)\n ) {\n for (const key of Object.getOwnPropertyNames(current)) {\n getters[key] = createGetter(raw, key);\n }\n }\n if (!(allowExportDefault && \"default\" in getters)) {\n getters[\"default\"] = () => raw;\n }\n esm(ns, getters);\n}\n\nfunction esmImport(sourceModule: Module, id: ModuleId): EsmNamespaceObject {\n const module = getOrInstantiateModuleFromParent(id, sourceModule);\n if (module.error) throw module.error;\n if (module.namespaceObject) return module.namespaceObject;\n const raw = module.exports;\n const ns = (module.namespaceObject = {});\n interopEsm(raw, ns, raw.__esModule);\n return ns;\n}\n\nfunction commonJsRequire(sourceModule: Module, id: ModuleId): Exports {\n const module = getOrInstantiateModuleFromParent(id, sourceModule);\n if (module.error) throw module.error;\n return module.exports;\n}\n\ntype RequireContextFactory = (map: RequireContextMap) => RequireContext;\n\nfunction requireContext(\n sourceModule: Module,\n map: RequireContextMap\n): RequireContext {\n function requireContext(id: ModuleId): Exports {\n const entry = map[id];\n\n if (!entry) {\n throw new Error(\n `module ${id} is required from a require.context, but is not in the context`\n );\n }\n\n return commonJsRequireContext(entry, sourceModule);\n }\n\n requireContext.keys = (): ModuleId[] => {\n return Object.keys(map);\n };\n\n requireContext.resolve = (id: ModuleId): ModuleId => {\n const entry = map[id];\n\n if (!entry) {\n throw new Error(\n `module ${id} is resolved from a require.context, but is not in the context`\n );\n }\n\n return entry.id();\n };\n\n return requireContext;\n}\n\n/**\n * Returns the path of a chunk defined by its data.\n */\nfunction getChunkPath(chunkData: ChunkData): ChunkPath {\n return typeof chunkData === \"string\" ? chunkData : chunkData.path;\n}\n"],"names":[],"mappings":";AAkBA,MAAM,qBAAqB,OAAO;;;;;AAqClC,MAAM,iBAAiB,OAAO,SAAS,CAAC,cAAc;AACtD,MAAM,cAAc,OAAO,WAAW,eAAe,OAAO,WAAW;AAEvE,SAAS,WACP,GAAQ,EACR,IAAiB,EACjB,OAA2C;IAE3C,IAAI,CAAC,eAAe,IAAI,CAAC,KAAK,OAC5B,OAAO,cAAc,CAAC,KAAK,MAAM;AACrC;AAKA,SAAS,IAAI,OAAgB,EAAE,OAAkC;IAC/D,WAAW,SAAS,cAAc;QAAE,OAAO;IAAK;IAChD,IAAI,aAAa,WAAW,SAAS,aAAa;QAAE,OAAO;IAAS;IACpE,IAAK,MAAM,OAAO,QAAS;QACzB,WAAW,SAAS,KAAK;YAAE,KAAK,OAAO,CAAC,IAAI;YAAE,YAAY;QAAK;IACjE;AACF;AAKA,SAAS,UAAU,MAAc,EAAE,OAAkC;IACnE,IAAK,OAAO,eAAe,GAAG,OAAO,OAAO,EAAG;AACjD;AAKA,SAAS,cAAc,MAAc,EAAE,MAA2B;IAChE,IAAI,oBAAoB,MAAM,CAAC,mBAAmB;IAClD,IAAI,CAAC,mBAAmB;QACtB,oBAAoB,MAAM,CAAC,mBAAmB,GAAG,EAAE;QACnD,OAAO,OAAO,GAAG,OAAO,eAAe,GAAG,IAAI,MAAM,OAAO,OAAO,EAAE;YAClE,KAAI,MAAM,EAAE,IAAI;gBACd,IACE,eAAe,IAA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"],"sourcesContent":["/**\n * This file contains runtime types and functions that are shared between all\n * Turbopack *development* ECMAScript runtimes.\n *\n * It will be appended to the runtime code of each runtime right after the\n * shared runtime utils.\n */\n\n/* eslint-disable @next/next/no-assign-module-variable */\n\n/// \n/// \n/// \n/// \n\n// This file must not use `import` and `export` statements. Otherwise, it\n// becomes impossible to augment interfaces declared in ``d files\n// (e.g. `Module`). Hence, the need for `import()` here.\ntype RefreshRuntimeGlobals =\n import(\"@next/react-refresh-utils/dist/runtime\").RefreshRuntimeGlobals;\n\ndeclare var CHUNK_BASE_PATH: string;\ndeclare var $RefreshHelpers$: RefreshRuntimeGlobals[\"$RefreshHelpers$\"];\ndeclare var $RefreshReg$: RefreshRuntimeGlobals[\"$RefreshReg$\"];\ndeclare var $RefreshSig$: RefreshRuntimeGlobals[\"$RefreshSig$\"];\ndeclare var $RefreshInterceptModuleExecution$:\n | RefreshRuntimeGlobals[\"$RefreshInterceptModuleExecution$\"];\n\ntype RefreshContext = {\n register: RefreshRuntimeGlobals[\"$RefreshReg$\"];\n signature: RefreshRuntimeGlobals[\"$RefreshSig$\"];\n};\n\ntype RefreshHelpers = RefreshRuntimeGlobals[\"$RefreshHelpers$\"];\n\ninterface TurbopackDevBaseContext {\n e: Module[\"exports\"];\n r: CommonJsRequire;\n f: RequireContextFactory;\n i: EsmImport;\n s: EsmExport;\n j: typeof dynamicExport;\n v: ExportValue;\n n: typeof exportNamespace;\n m: Module;\n c: ModuleCache;\n l: LoadChunk;\n g: typeof globalThis;\n k: RefreshContext;\n __dirname: string;\n}\n\ninterface TurbopackDevContext extends TurbopackDevBaseContext {}\n\n// string encoding of a module factory (used in hmr updates)\ntype ModuleFactoryString = string;\n\ntype ModuleFactory = (\n this: Module[\"exports\"],\n context: TurbopackDevContext\n) => undefined;\n\ntype DevRuntimeParams = {\n otherChunks: ChunkData[];\n runtimeModuleIds: ModuleId[];\n};\n\ntype ChunkRegistration = [\n chunkPath: ChunkPath,\n chunkModules: ModuleFactories,\n params: DevRuntimeParams | undefined\n];\ntype ChunkList = {\n path: ChunkPath;\n chunks: ChunkData[];\n source: \"entry\" | \"dynamic\";\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 * The module was instantiated because it was included in a chunk's hot module\n * update.\n */\n Update = 2,\n}\n\ntype SourceInfo =\n | {\n type: SourceType.Runtime;\n chunkPath: ChunkPath;\n }\n | {\n type: SourceType.Parent;\n parentId: ModuleId;\n }\n | {\n type: SourceType.Update;\n parents?: ModuleId[];\n };\n\ninterface RuntimeBackend {\n registerChunk: (chunkPath: ChunkPath, params?: DevRuntimeParams) => void;\n loadChunk: (chunkPath: ChunkPath, source: SourceInfo) => Promise;\n reloadChunk?: (chunkPath: ChunkPath) => Promise;\n unloadChunk?: (chunkPath: ChunkPath) => void;\n\n restart: () => void;\n}\n\nconst moduleFactories: ModuleFactories = Object.create(null);\nconst moduleCache: ModuleCache = Object.create(null);\n/**\n * Maps module IDs to persisted data between executions of their hot module\n * implementation (`hot.data`).\n */\nconst moduleHotData: Map = new Map();\n/**\n * Maps module instances to their hot module state.\n */\nconst moduleHotState: Map = new Map();\n/**\n * Modules that call `module.hot.invalidate()` (while being updated).\n */\nconst queuedInvalidatedModules: Set = new Set();\n/**\n * Module IDs that are instantiated as part of the runtime of a chunk.\n */\nconst runtimeModules: Set = new Set();\n/**\n * Map from module ID to the chunks that contain this module.\n *\n * In HMR, we need to keep track of which modules are contained in which so\n * chunks. This is so we don't eagerly dispose of a module when it is removed\n * from chunk A, but still exists in chunk B.\n */\nconst moduleChunksMap: Map> = new Map();\n/**\n * Map from a chunk path to all modules it contains.\n */\nconst chunkModulesMap: Map> = new Map();\n/**\n * Chunk lists that contain a runtime. When these chunk lists receive an update\n * that can't be reconciled with the current state of the page, we need to\n * reload the runtime entirely.\n */\nconst runtimeChunkLists: Set = new Set();\n/**\n * Map from a chunk list to the chunk paths it contains.\n */\nconst chunkListChunksMap: Map> = new Map();\n/**\n * Map from a chunk path to the chunk lists it belongs to.\n */\nconst chunkChunkListsMap: Map> = new Map();\n\nconst availableModules: Map | true> = new Map();\n\nconst availableModuleChunks: Map | true> = new Map();\n\nasync function loadChunk(\n source: SourceInfo,\n chunkData: ChunkData\n): Promise {\n if (typeof chunkData === \"string\") {\n return loadChunkPath(source, chunkData);\n }\n\n const includedList = chunkData.included || [];\n const modulesPromises = includedList.map((included) => {\n if (moduleFactories[included]) return true;\n return availableModules.get(included);\n });\n if (modulesPromises.length > 0 && modulesPromises.every((p) => p)) {\n // When all included items are already loaded or loading, we can skip loading ourselves\n return Promise.all(modulesPromises);\n }\n\n const includedModuleChunksList = chunkData.moduleChunks || [];\n const moduleChunksPromises = includedModuleChunksList\n .map((included) => {\n // TODO(alexkirsz) Do we need this check?\n // if (moduleFactories[included]) return true;\n return availableModuleChunks.get(included);\n })\n .filter((p) => p);\n\n let promise;\n if (moduleChunksPromises.length > 0) {\n // Some module chunks are already loaded or loading.\n\n if (moduleChunksPromises.length == includedModuleChunksList.length) {\n // When all included module chunks are already loaded or loading, we can skip loading ourselves\n return Promise.all(moduleChunksPromises);\n }\n\n const moduleChunksToLoad: Set = new Set();\n for (const moduleChunk of includedModuleChunksList) {\n if (!availableModuleChunks.has(moduleChunk)) {\n moduleChunksToLoad.add(moduleChunk);\n }\n }\n\n for (const moduleChunkToLoad of moduleChunksToLoad) {\n const promise = loadChunkPath(source, moduleChunkToLoad);\n\n availableModuleChunks.set(moduleChunkToLoad, promise);\n\n moduleChunksPromises.push(promise);\n }\n\n promise = Promise.all(moduleChunksPromises);\n } else {\n promise = loadChunkPath(source, chunkData.path);\n\n // Mark all included module chunks as loading if they are not already loaded or loading.\n for (const includedModuleChunk of includedModuleChunksList) {\n if (!availableModuleChunks.has(includedModuleChunk)) {\n availableModuleChunks.set(includedModuleChunk, promise);\n }\n }\n }\n\n for (const included of includedList) {\n if (!availableModules.has(included)) {\n // It might be better to race old and new promises, but it's rare that the new promise will be faster than a request started earlier.\n // In production it's even more rare, because the chunk optimization tries to deduplicate modules anyway.\n availableModules.set(included, promise);\n }\n }\n\n return promise;\n}\n\nasync function loadChunkPath(\n source: SourceInfo,\n chunkPath: ChunkPath\n): Promise {\n try {\n await BACKEND.loadChunk(chunkPath, source);\n } catch (error) {\n let loadReason;\n switch (source.type) {\n case SourceType.Runtime:\n loadReason = `as a runtime dependency of chunk ${source.chunkPath}`;\n break;\n case SourceType.Parent:\n loadReason = `from module ${source.parentId}`;\n break;\n case SourceType.Update:\n loadReason = \"from an HMR update\";\n break;\n }\n throw new Error(\n `Failed to load chunk ${chunkPath} ${loadReason}${\n error ? `: ${error}` : \"\"\n }`,\n error\n ? {\n cause: error,\n }\n : undefined\n );\n }\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 case SourceType.Update:\n instantiationReason = \"because of an HMR update\";\n break;\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 hotData = moduleHotData.get(id)!;\n const { hot, hotState } = createModuleHot(id, hotData);\n\n let parents: ModuleId[];\n switch (source.type) {\n case SourceType.Runtime:\n runtimeModules.add(id);\n parents = [];\n break;\n case SourceType.Parent:\n // No need to add this module as a child of the parent module here, this\n // has already been taken care of in `getOrInstantiateModuleFromParent`.\n parents = [source.parentId];\n break;\n case SourceType.Update:\n parents = source.parents || [];\n break;\n }\n const module: Module = {\n exports: {},\n error: undefined,\n loaded: false,\n id,\n parents,\n children: [],\n namespaceObject: undefined,\n hot,\n };\n\n moduleCache[id] = module;\n moduleHotState.set(module, hotState);\n\n // NOTE(alexkirsz) This can fail when the module encounters a runtime error.\n try {\n runModuleExecutionHooks(module, (refresh) => {\n moduleFactory.call(\n module.exports,\n augmentContext({\n e: module.exports,\n r: commonJsRequire.bind(null, module),\n f: requireContext.bind(null, module),\n i: esmImport.bind(null, module),\n s: esmExport.bind(null, module),\n j: dynamicExport.bind(null, module),\n v: exportValue.bind(null, module),\n n: exportNamespace.bind(null, module),\n m: module,\n c: moduleCache,\n l: loadChunk.bind(null, { type: SourceType.Parent, parentId: id }),\n g: globalThis,\n k: refresh,\n __dirname: module.id.replace(/(^|\\/)\\/+$/, \"\"),\n })\n );\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 * NOTE(alexkirsz) Webpack has a \"module execution\" interception hook that\n * Next.js' React Refresh runtime hooks into to add module context to the\n * refresh registry.\n */\nfunction runModuleExecutionHooks(\n module: Module,\n executeModule: (ctx: RefreshContext) => void\n) {\n const cleanupReactRefreshIntercept =\n typeof globalThis.$RefreshInterceptModuleExecution$ === \"function\"\n ? globalThis.$RefreshInterceptModuleExecution$(module.id)\n : () => {};\n\n try {\n executeModule({\n register: globalThis.$RefreshReg$,\n signature: globalThis.$RefreshSig$,\n });\n\n if (\"$RefreshHelpers$\" in globalThis) {\n // This pattern can also be used to register the exports of\n // a module with the React Refresh runtime.\n registerExportsAndSetupBoundaryForReactRefresh(\n module,\n globalThis.$RefreshHelpers$\n );\n }\n } catch (e) {\n throw e;\n } finally {\n // Always cleanup the intercept, even if module execution failed.\n cleanupReactRefreshIntercept();\n }\n}\n\n/**\n * Retrieves a module from the cache, or instantiate it if it is not cached.\n */\nconst getOrInstantiateModuleFromParent: GetOrInstantiateModuleFromParent = (\n id,\n sourceModule\n) => {\n if (!sourceModule.hot.active) {\n console.warn(\n `Unexpected import of module ${id} from module ${sourceModule.id}, which was deleted by an HMR update`\n );\n }\n\n const module = moduleCache[id];\n\n if (sourceModule.children.indexOf(id) === -1) {\n sourceModule.children.push(id);\n }\n\n if (module) {\n if (module.parents.indexOf(sourceModule.id) === -1) {\n module.parents.push(sourceModule.id);\n }\n\n return module;\n }\n\n return instantiateModule(id, {\n type: SourceType.Parent,\n parentId: sourceModule.id,\n });\n};\n\n/**\n * This is adapted from https://github.com/vercel/next.js/blob/3466862d9dc9c8bb3131712134d38757b918d1c0/packages/react-refresh-utils/internal/ReactRefreshModule.runtime.ts\n */\nfunction registerExportsAndSetupBoundaryForReactRefresh(\n module: Module,\n helpers: RefreshHelpers\n) {\n const currentExports = module.exports;\n const prevExports = module.hot.data.prevExports ?? null;\n\n helpers.registerExportsForReactRefresh(currentExports, module.id);\n\n // A module can be accepted automatically based on its exports, e.g. when\n // it is a Refresh Boundary.\n if (helpers.isReactRefreshBoundary(currentExports)) {\n // Save the previous exports on update, so we can compare the boundary\n // signatures.\n module.hot.dispose((data) => {\n data.prevExports = currentExports;\n });\n // Unconditionally accept an update to this module, we'll check if it's\n // still a Refresh Boundary later.\n module.hot.accept();\n\n // This field is set when the previous version of this module was a\n // Refresh Boundary, letting us know we need to check for invalidation or\n // enqueue an update.\n if (prevExports !== null) {\n // A boundary can become ineligible if its exports are incompatible\n // with the previous exports.\n //\n // For example, if you add/remove/change exports, we'll want to\n // re-execute the importing modules, and force those components to\n // re-render. Similarly, if you convert a class component to a\n // function, we want to invalidate the boundary.\n if (\n helpers.shouldInvalidateReactRefreshBoundary(\n prevExports,\n currentExports\n )\n ) {\n module.hot.invalidate();\n } else {\n helpers.scheduleUpdate();\n }\n }\n } else {\n // Since we just executed the code for the module, it's possible that the\n // new exports made it ineligible for being a boundary.\n // We only care about the case when we were _previously_ a boundary,\n // because we already accepted this update (accidental side effect).\n const isNoLongerABoundary = prevExports !== null;\n if (isNoLongerABoundary) {\n module.hot.invalidate();\n }\n }\n}\n\nfunction formatDependencyChain(dependencyChain: ModuleId[]): string {\n return `Dependency chain: ${dependencyChain.join(\" -> \")}`;\n}\n\nfunction computeOutdatedModules(\n added: Map,\n modified: Map\n): {\n outdatedModules: Set;\n newModuleFactories: Map;\n} {\n const newModuleFactories = new Map();\n\n for (const [moduleId, entry] of added) {\n if (entry != null) {\n newModuleFactories.set(moduleId, _eval(entry));\n }\n }\n\n const outdatedModules = computedInvalidatedModules(modified.keys());\n\n for (const [moduleId, entry] of modified) {\n newModuleFactories.set(moduleId, _eval(entry));\n }\n\n return { outdatedModules, newModuleFactories };\n}\n\nfunction computedInvalidatedModules(\n invalidated: Iterable\n): Set {\n const outdatedModules = new Set();\n\n for (const moduleId of invalidated) {\n const effect = getAffectedModuleEffects(moduleId);\n\n switch (effect.type) {\n case \"unaccepted\":\n throw new Error(\n `cannot apply update: unaccepted module. ${formatDependencyChain(\n effect.dependencyChain\n )}.`\n );\n case \"self-declined\":\n throw new Error(\n `cannot apply update: self-declined module. ${formatDependencyChain(\n effect.dependencyChain\n )}.`\n );\n case \"accepted\":\n for (const outdatedModuleId of effect.outdatedModules) {\n outdatedModules.add(outdatedModuleId);\n }\n break;\n // TODO(alexkirsz) Dependencies: handle dependencies effects.\n }\n }\n\n return outdatedModules;\n}\n\nfunction computeOutdatedSelfAcceptedModules(\n outdatedModules: Iterable\n): { moduleId: ModuleId; errorHandler: true | Function }[] {\n const outdatedSelfAcceptedModules = [];\n for (const moduleId of outdatedModules) {\n const module = moduleCache[moduleId];\n const hotState = moduleHotState.get(module)!;\n if (module && hotState.selfAccepted && !hotState.selfInvalidated) {\n outdatedSelfAcceptedModules.push({\n moduleId,\n errorHandler: hotState.selfAccepted,\n });\n }\n }\n return outdatedSelfAcceptedModules;\n}\n\n/**\n * Adds, deletes, and moves modules between chunks. This must happen before the\n * dispose phase as it needs to know which modules were removed from all chunks,\n * which we can only compute *after* taking care of added and moved modules.\n */\nfunction updateChunksPhase(\n chunksAddedModules: Map>,\n chunksDeletedModules: Map>\n): { disposedModules: Set } {\n for (const [chunkPath, addedModuleIds] of chunksAddedModules) {\n for (const moduleId of addedModuleIds) {\n addModuleToChunk(moduleId, chunkPath);\n }\n }\n\n const disposedModules: Set = new Set();\n for (const [chunkPath, addedModuleIds] of chunksDeletedModules) {\n for (const moduleId of addedModuleIds) {\n if (removeModuleFromChunk(moduleId, chunkPath)) {\n disposedModules.add(moduleId);\n }\n }\n }\n\n return { disposedModules };\n}\n\nfunction disposePhase(\n outdatedModules: Iterable,\n disposedModules: Iterable\n): { outdatedModuleParents: Map> } {\n for (const moduleId of outdatedModules) {\n disposeModule(moduleId, \"replace\");\n }\n\n for (const moduleId of disposedModules) {\n disposeModule(moduleId, \"clear\");\n }\n\n // Removing modules from the module cache is a separate step.\n // We also want to keep track of previous parents of the outdated modules.\n const outdatedModuleParents = new Map();\n for (const moduleId of outdatedModules) {\n const oldModule = moduleCache[moduleId];\n outdatedModuleParents.set(moduleId, oldModule?.parents);\n delete moduleCache[moduleId];\n }\n\n // TODO(alexkirsz) Dependencies: remove outdated dependency from module\n // children.\n\n return { outdatedModuleParents };\n}\n\n/**\n * Disposes of an instance of a module.\n *\n * Returns the persistent hot data that should be kept for the next module\n * instance.\n *\n * NOTE: mode = \"replace\" will not remove modules from the moduleCache.\n * This must be done in a separate step afterwards.\n * This is important because all modules need to be disposed to update the\n * parent/child relationships before they are actually removed from the moduleCache.\n * If this was done in this method, the following disposeModule calls won't find\n * the module from the module id in the cache.\n */\nfunction disposeModule(moduleId: ModuleId, mode: \"clear\" | \"replace\") {\n const module = moduleCache[moduleId];\n if (!module) {\n return;\n }\n\n const hotState = moduleHotState.get(module)!;\n const data = {};\n\n // Run the `hot.dispose` handler, if any, passing in the persistent\n // `hot.data` object.\n for (const disposeHandler of hotState.disposeHandlers) {\n disposeHandler(data);\n }\n\n // This used to warn in `getOrInstantiateModuleFromParent` when a disposed\n // module is still importing other modules.\n module.hot.active = false;\n\n moduleHotState.delete(module);\n\n // TODO(alexkirsz) Dependencies: delete the module from outdated deps.\n\n // Remove the disposed module from its children's parent list.\n // It will be added back once the module re-instantiates and imports its\n // children again.\n for (const childId of module.children) {\n const child = moduleCache[childId];\n if (!child) {\n continue;\n }\n\n const idx = child.parents.indexOf(module.id);\n if (idx >= 0) {\n child.parents.splice(idx, 1);\n }\n }\n\n switch (mode) {\n case \"clear\":\n delete moduleCache[module.id];\n moduleHotData.delete(module.id);\n break;\n case \"replace\":\n moduleHotData.set(module.id, data);\n break;\n default:\n invariant(mode, (mode) => `invalid mode: ${mode}`);\n }\n}\n\nfunction applyPhase(\n outdatedSelfAcceptedModules: {\n moduleId: ModuleId;\n errorHandler: true | Function;\n }[],\n newModuleFactories: Map,\n outdatedModuleParents: Map>,\n reportError: (err: any) => void\n) {\n // Update module factories.\n for (const [moduleId, factory] of newModuleFactories.entries()) {\n moduleFactories[moduleId] = factory;\n }\n\n // TODO(alexkirsz) Run new runtime entries here.\n\n // TODO(alexkirsz) Dependencies: call accept handlers for outdated deps.\n\n // Re-instantiate all outdated self-accepted modules.\n for (const { moduleId, errorHandler } of outdatedSelfAcceptedModules) {\n try {\n instantiateModule(moduleId, {\n type: SourceType.Update,\n parents: outdatedModuleParents.get(moduleId),\n });\n } catch (err) {\n if (typeof errorHandler === \"function\") {\n try {\n errorHandler(err, { moduleId, module: moduleCache[moduleId] });\n } catch (err2) {\n reportError(err2);\n reportError(err);\n }\n } else {\n reportError(err);\n }\n }\n }\n}\n\n/**\n * Utility function to ensure all variants of an enum are handled.\n */\nfunction invariant(never: never, computeMessage: (arg: any) => string): never {\n throw new Error(`Invariant: ${computeMessage(never)}`);\n}\n\nfunction applyUpdate(chunkListPath: ChunkPath, update: PartialUpdate) {\n switch (update.type) {\n case \"ChunkListUpdate\":\n applyChunkListUpdate(chunkListPath, update);\n break;\n default:\n invariant(update, (update) => `Unknown update type: ${update.type}`);\n }\n}\n\nfunction applyChunkListUpdate(\n chunkListPath: ChunkPath,\n update: ChunkListUpdate\n) {\n if (update.merged != null) {\n for (const merged of update.merged) {\n switch (merged.type) {\n case \"EcmascriptMergedUpdate\":\n applyEcmascriptMergedUpdate(chunkListPath, merged);\n break;\n default:\n invariant(merged, (merged) => `Unknown merged type: ${merged.type}`);\n }\n }\n }\n\n if (update.chunks != null) {\n for (const [chunkPath, chunkUpdate] of Object.entries(update.chunks)) {\n switch (chunkUpdate.type) {\n case \"added\":\n BACKEND.loadChunk(chunkPath, { type: SourceType.Update });\n break;\n case \"total\":\n BACKEND.reloadChunk?.(chunkPath);\n break;\n case \"deleted\":\n BACKEND.unloadChunk?.(chunkPath);\n break;\n case \"partial\":\n invariant(\n chunkUpdate.instruction,\n (instruction) =>\n `Unknown partial instruction: ${JSON.stringify(instruction)}.`\n );\n default:\n invariant(\n chunkUpdate,\n (chunkUpdate) => `Unknown chunk update type: ${chunkUpdate.type}`\n );\n }\n }\n }\n}\n\nfunction applyEcmascriptMergedUpdate(\n chunkPath: ChunkPath,\n update: EcmascriptMergedUpdate\n) {\n const { entries = {}, chunks = {} } = update;\n const { added, modified, chunksAdded, chunksDeleted } = computeChangedModules(\n entries,\n chunks\n );\n const { outdatedModules, newModuleFactories } = computeOutdatedModules(\n added,\n modified\n );\n const { disposedModules } = updateChunksPhase(chunksAdded, chunksDeleted);\n\n applyInternal(outdatedModules, disposedModules, newModuleFactories);\n}\n\nfunction applyInvalidatedModules(outdatedModules: Set) {\n if (queuedInvalidatedModules.size > 0) {\n computedInvalidatedModules(queuedInvalidatedModules).forEach((moduleId) => {\n outdatedModules.add(moduleId);\n });\n\n queuedInvalidatedModules.clear();\n }\n\n return outdatedModules;\n}\n\nfunction applyInternal(\n outdatedModules: Set,\n disposedModules: Iterable,\n newModuleFactories: Map\n) {\n outdatedModules = applyInvalidatedModules(outdatedModules);\n\n const outdatedSelfAcceptedModules =\n computeOutdatedSelfAcceptedModules(outdatedModules);\n\n const { outdatedModuleParents } = disposePhase(\n outdatedModules,\n disposedModules\n );\n\n // we want to continue on error and only throw the error after we tried applying all updates\n let error: any;\n function reportError(err: any) {\n if (!error) error = err;\n }\n\n applyPhase(\n outdatedSelfAcceptedModules,\n newModuleFactories,\n outdatedModuleParents,\n reportError\n );\n\n if (error) {\n throw error;\n }\n\n if (queuedInvalidatedModules.size > 0) {\n applyInternal(new Set(), [], new Map());\n }\n}\n\nfunction computeChangedModules(\n entries: Record,\n updates: Record\n): {\n added: Map;\n modified: Map;\n deleted: Set;\n chunksAdded: Map>;\n chunksDeleted: Map>;\n} {\n const chunksAdded = new Map();\n const chunksDeleted = new Map();\n const added: Map = new Map();\n const modified = new Map();\n const deleted: Set = new Set();\n\n for (const [chunkPath, mergedChunkUpdate] of Object.entries(updates)) {\n switch (mergedChunkUpdate.type) {\n case \"added\": {\n const updateAdded = new Set(mergedChunkUpdate.modules);\n for (const moduleId of updateAdded) {\n added.set(moduleId, entries[moduleId]);\n }\n chunksAdded.set(chunkPath, updateAdded);\n break;\n }\n case \"deleted\": {\n // We could also use `mergedChunkUpdate.modules` here.\n const updateDeleted = new Set(chunkModulesMap.get(chunkPath));\n for (const moduleId of updateDeleted) {\n deleted.add(moduleId);\n }\n chunksDeleted.set(chunkPath, updateDeleted);\n break;\n }\n case \"partial\": {\n const updateAdded = new Set(mergedChunkUpdate.added);\n const updateDeleted = new Set(mergedChunkUpdate.deleted);\n for (const moduleId of updateAdded) {\n added.set(moduleId, entries[moduleId]);\n }\n for (const moduleId of updateDeleted) {\n deleted.add(moduleId);\n }\n chunksAdded.set(chunkPath, updateAdded);\n chunksDeleted.set(chunkPath, updateDeleted);\n break;\n }\n default:\n invariant(\n mergedChunkUpdate,\n (mergedChunkUpdate) =>\n `Unknown merged chunk update type: ${mergedChunkUpdate.type}`\n );\n }\n }\n\n // If a module was added from one chunk and deleted from another in the same update,\n // consider it to be modified, as it means the module was moved from one chunk to another\n // AND has new code in a single update.\n for (const moduleId of added.keys()) {\n if (deleted.has(moduleId)) {\n added.delete(moduleId);\n deleted.delete(moduleId);\n }\n }\n\n for (const [moduleId, entry] of Object.entries(entries)) {\n // Modules that haven't been added to any chunk but have new code are considered\n // to be modified.\n // This needs to be under the previous loop, as we need it to get rid of modules\n // that were added and deleted in the same update.\n if (!added.has(moduleId)) {\n modified.set(moduleId, entry);\n }\n }\n\n return { added, deleted, modified, chunksAdded, chunksDeleted };\n}\n\ntype ModuleEffect =\n | {\n type: \"unaccepted\";\n dependencyChain: ModuleId[];\n }\n | {\n type: \"self-declined\";\n dependencyChain: ModuleId[];\n moduleId: ModuleId;\n }\n | {\n type: \"accepted\";\n moduleId: ModuleId;\n outdatedModules: Set;\n };\n\nfunction getAffectedModuleEffects(moduleId: ModuleId): ModuleEffect {\n const outdatedModules: Set = new Set();\n\n type QueueItem = { moduleId?: ModuleId; dependencyChain: ModuleId[] };\n\n const queue: QueueItem[] = [\n {\n moduleId,\n dependencyChain: [],\n },\n ];\n\n let nextItem;\n while ((nextItem = queue.shift())) {\n const { moduleId, dependencyChain } = nextItem;\n\n if (moduleId != null) {\n outdatedModules.add(moduleId);\n }\n\n // We've arrived at the runtime of the chunk, which means that nothing\n // else above can accept this update.\n if (moduleId === undefined) {\n return {\n type: \"unaccepted\",\n dependencyChain,\n };\n }\n\n const module = moduleCache[moduleId];\n const hotState = moduleHotState.get(module)!;\n\n if (\n // The module is not in the cache. Since this is a \"modified\" update,\n // it means that the module was never instantiated before.\n !module || // The module accepted itself without invalidating globalThis.\n // TODO is that right?\n (hotState.selfAccepted && !hotState.selfInvalidated)\n ) {\n continue;\n }\n\n if (hotState.selfDeclined) {\n return {\n type: \"self-declined\",\n dependencyChain,\n moduleId,\n };\n }\n\n if (runtimeModules.has(moduleId)) {\n queue.push({\n moduleId: undefined,\n dependencyChain: [...dependencyChain, moduleId],\n });\n continue;\n }\n\n for (const parentId of module.parents) {\n const parent = moduleCache[parentId];\n\n if (!parent) {\n // TODO(alexkirsz) Is this even possible?\n continue;\n }\n\n // TODO(alexkirsz) Dependencies: check accepted and declined\n // dependencies here.\n\n queue.push({\n moduleId: parentId,\n dependencyChain: [...dependencyChain, moduleId],\n });\n }\n }\n\n return {\n type: \"accepted\",\n moduleId,\n outdatedModules,\n };\n}\n\nfunction handleApply(chunkListPath: ChunkPath, update: ServerMessage) {\n switch (update.type) {\n case \"partial\": {\n // This indicates that the update is can be applied to the current state of the application.\n applyUpdate(chunkListPath, update.instruction);\n break;\n }\n case \"restart\": {\n // This indicates that there is no way to apply the update to the\n // current state of the application, and that the application must be\n // restarted.\n BACKEND.restart();\n break;\n }\n case \"notFound\": {\n // This indicates that the chunk list no longer exists: either the dynamic import which created it was removed,\n // or the page itself was deleted.\n // If it is a dynamic import, we simply discard all modules that the chunk has exclusive access to.\n // If it is a runtime chunk list, we restart the application.\n if (runtimeChunkLists.has(chunkListPath)) {\n BACKEND.restart();\n } else {\n disposeChunkList(chunkListPath);\n }\n break;\n }\n default:\n throw new Error(`Unknown update type: ${update.type}`);\n }\n}\n\nfunction createModuleHot(\n moduleId: ModuleId,\n hotData: HotData\n): { hot: Hot; hotState: HotState } {\n const hotState: HotState = {\n selfAccepted: false,\n selfDeclined: false,\n selfInvalidated: false,\n disposeHandlers: [],\n };\n\n const hot: Hot = {\n // TODO(alexkirsz) This is not defined in the HMR API. It was used to\n // decide whether to warn whenever an HMR-disposed module required other\n // modules. We might want to remove it.\n active: true,\n\n data: hotData ?? {},\n\n // TODO(alexkirsz) Support full (dep, callback, errorHandler) form.\n accept: (\n modules?: string | string[] | AcceptErrorHandler,\n _callback?: AcceptCallback,\n _errorHandler?: AcceptErrorHandler\n ) => {\n if (modules === undefined) {\n hotState.selfAccepted = true;\n } else if (typeof modules === \"function\") {\n hotState.selfAccepted = modules;\n } else {\n throw new Error(\"unsupported `accept` signature\");\n }\n },\n\n decline: (dep) => {\n if (dep === undefined) {\n hotState.selfDeclined = true;\n } else {\n throw new Error(\"unsupported `decline` signature\");\n }\n },\n\n dispose: (callback) => {\n hotState.disposeHandlers.push(callback);\n },\n\n addDisposeHandler: (callback) => {\n hotState.disposeHandlers.push(callback);\n },\n\n removeDisposeHandler: (callback) => {\n const idx = hotState.disposeHandlers.indexOf(callback);\n if (idx >= 0) {\n hotState.disposeHandlers.splice(idx, 1);\n }\n },\n\n invalidate: () => {\n hotState.selfInvalidated = true;\n queuedInvalidatedModules.add(moduleId);\n },\n\n // NOTE(alexkirsz) This is part of the management API, which we don't\n // implement, but the Next.js React Refresh runtime uses this to decide\n // whether to schedule an update.\n status: () => \"idle\",\n\n // NOTE(alexkirsz) Since we always return \"idle\" for now, these are no-ops.\n addStatusHandler: (_handler) => {},\n removeStatusHandler: (_handler) => {},\n };\n\n return { hot, hotState };\n}\n\n/**\n * Adds a module to a chunk.\n */\nfunction addModuleToChunk(moduleId: ModuleId, chunkPath: ChunkPath) {\n let moduleChunks = moduleChunksMap.get(moduleId);\n if (!moduleChunks) {\n moduleChunks = new Set([chunkPath]);\n moduleChunksMap.set(moduleId, moduleChunks);\n } else {\n moduleChunks.add(chunkPath);\n }\n\n let chunkModules = chunkModulesMap.get(chunkPath);\n if (!chunkModules) {\n chunkModules = new Set([moduleId]);\n chunkModulesMap.set(chunkPath, chunkModules);\n } else {\n chunkModules.add(moduleId);\n }\n}\n\n/**\n * Returns the first chunk that included a module.\n * This is used by the Node.js backend, hence why it's marked as unused in this\n * file.\n */\nfunction getFirstModuleChunk(moduleId: ModuleId) {\n const moduleChunkPaths = moduleChunksMap.get(moduleId);\n if (moduleChunkPaths == null) {\n return null;\n }\n\n return moduleChunkPaths.values().next().value;\n}\n\n/**\n * Removes a module from a chunk.\n * Returns `true` if there are no remaining chunks including this module.\n */\nfunction removeModuleFromChunk(\n moduleId: ModuleId,\n chunkPath: ChunkPath\n): boolean {\n const moduleChunks = moduleChunksMap.get(moduleId)!;\n moduleChunks.delete(chunkPath);\n\n const chunkModules = chunkModulesMap.get(chunkPath)!;\n chunkModules.delete(moduleId);\n\n const noRemainingModules = chunkModules.size === 0;\n if (noRemainingModules) {\n chunkModulesMap.delete(chunkPath);\n }\n\n const noRemainingChunks = moduleChunks.size === 0;\n if (noRemainingChunks) {\n moduleChunksMap.delete(moduleId);\n }\n\n return noRemainingChunks;\n}\n\n/**\n * Disposes of a chunk list and its corresponding exclusive chunks.\n */\nfunction disposeChunkList(chunkListPath: ChunkPath): boolean {\n const chunkPaths = chunkListChunksMap.get(chunkListPath);\n if (chunkPaths == null) {\n return false;\n }\n chunkListChunksMap.delete(chunkListPath);\n\n for (const chunkPath of chunkPaths) {\n const chunkChunkLists = chunkChunkListsMap.get(chunkPath)!;\n chunkChunkLists.delete(chunkListPath);\n\n if (chunkChunkLists.size === 0) {\n chunkChunkListsMap.delete(chunkPath);\n disposeChunk(chunkPath);\n }\n }\n\n // We must also dispose of the chunk list's chunk itself to ensure it may\n // be reloaded properly in the future.\n BACKEND.unloadChunk?.(chunkListPath);\n\n return true;\n}\n\n/**\n * Disposes of a chunk and its corresponding exclusive modules.\n *\n * @returns Whether the chunk was disposed of.\n */\nfunction disposeChunk(chunkPath: ChunkPath): boolean {\n // This should happen whether the chunk has any modules in it or not.\n // For instance, CSS chunks have no modules in them, but they still need to be unloaded.\n BACKEND.unloadChunk?.(chunkPath);\n\n const chunkModules = chunkModulesMap.get(chunkPath);\n if (chunkModules == null) {\n return false;\n }\n chunkModules.delete(chunkPath);\n\n for (const moduleId of chunkModules) {\n const moduleChunks = moduleChunksMap.get(moduleId)!;\n moduleChunks.delete(chunkPath);\n\n const noRemainingChunks = moduleChunks.size === 0;\n if (noRemainingChunks) {\n moduleChunksMap.delete(moduleId);\n disposeModule(moduleId, \"clear\");\n availableModules.delete(moduleId);\n }\n }\n\n return true;\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 * Gets or instantiates a runtime module.\n */\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 instantiateModule(moduleId, { type: SourceType.Runtime, chunkPath });\n}\n\n/**\n * Returns the URL relative to the origin where a chunk can be fetched from.\n */\nfunction getChunkRelativeUrl(chunkPath: ChunkPath): string {\n return `${CHUNK_BASE_PATH}${chunkPath}`;\n}\n\n/**\n * Subscribes to chunk list updates from the update server and applies them.\n */\nfunction registerChunkList(\n chunkUpdateProvider: ChunkUpdateProvider,\n chunkList: ChunkList\n) {\n chunkUpdateProvider.push([\n chunkList.path,\n handleApply.bind(null, chunkList.path),\n ]);\n\n // Adding chunks to chunk lists and vice versa.\n const chunks = new Set(chunkList.chunks.map(getChunkPath));\n chunkListChunksMap.set(chunkList.path, chunks);\n for (const chunkPath of chunks) {\n let chunkChunkLists = chunkChunkListsMap.get(chunkPath);\n if (!chunkChunkLists) {\n chunkChunkLists = new Set([chunkList.path]);\n chunkChunkListsMap.set(chunkPath, chunkChunkLists);\n } else {\n chunkChunkLists.add(chunkList.path);\n }\n }\n\n if (chunkList.source === \"entry\") {\n markChunkListAsRuntime(chunkList.path);\n }\n}\n\n/**\n * Marks a chunk list as a runtime chunk list. There can be more than one\n * runtime chunk list. For instance, integration tests can have multiple chunk\n * groups loaded at runtime, each with its own chunk list.\n */\nfunction markChunkListAsRuntime(chunkListPath: ChunkPath) {\n runtimeChunkLists.add(chunkListPath);\n}\n\nfunction registerChunk([\n chunkPath,\n chunkModules,\n runtimeParams,\n]: ChunkRegistration) {\n for (const [moduleId, moduleFactory] of Object.entries(chunkModules)) {\n if (!moduleFactories[moduleId]) {\n moduleFactories[moduleId] = moduleFactory;\n }\n addModuleToChunk(moduleId, chunkPath);\n }\n\n return BACKEND.registerChunk(chunkPath, runtimeParams);\n}\n\nglobalThis.TURBOPACK_CHUNK_UPDATE_LISTENERS ??= [];\n\nconst chunkListsToRegister = globalThis.TURBOPACK_CHUNK_LISTS;\nif (Array.isArray(chunkListsToRegister)) {\n for (const chunkList of chunkListsToRegister) {\n registerChunkList(globalThis.TURBOPACK_CHUNK_UPDATE_LISTENERS, chunkList);\n }\n}\n\nglobalThis.TURBOPACK_CHUNK_LISTS = {\n push: (chunkList) => {\n registerChunkList(globalThis.TURBOPACK_CHUNK_UPDATE_LISTENERS!, chunkList);\n },\n} satisfies ChunkListProvider;\n"],"names":[],"mappings":";;;;;;;IA8EA;UAAK,UAAU;IAAV,WAAA,WAKH,aAAU,KAAV;IALG,WAAA,WASH,YAAS,KAAT;IATG,WAAA,WAcH,YAAS,KAAT;GAdG,eAAA;;AAwCL,MAAM,kBAAmC,OAAO,MAAM,CAAC;AACvD,MAAM,cAA2B,OAAO,MAAM,CAAC;AAK/C,MAAM,gBAAwC,IAAI;AAIlD,MAAM,iBAAwC,IAAI;AAIlD,MAAM,2BAA0C,IAAI;AAIpD,MAAM,iBAAgC,IAAI;AAQ1C,MAAM,kBAAiD,IAAI;AAI3D,MAAM,kBAAiD,IAAI;AAM3D,MAAM,oBAAoC,IAAI;AAI9C,MAAM,qBAAqD,IAAI;AAI/D,MAAM,qBAAqD,IAAI;AAE/D,MAAM,mBAAuD,IAAI;AAEjE,MAAM,wBAA6D,IAAI;AAEvE,eAAe,UACb,MAAkB,EAClB,SAAoB;IAEpB,IAAI,OAAO,cAAc,UAAU;QACjC,OAAO,cAAc,QAAQ;IAC/B;IAEA,MAAM,eAAe,UAAU,QAAQ,IAAI,EAAE;IAC7C,MAAM,kBAAkB,aAAa,GAAG,CAAC,CAAC;QACxC,IAAI,eAAe,CAAC,SAAS,EAAE,OAAO;QACtC,OAAO,iBAAiB,GAAG,CAAC;IAC9B;IACA,IAAI,gBAAgB,MAAM,GAAG,KAAK,gBAAgB,KAAK,CAAC,CAAC,IAAM,IAAI;QAEjE,OAAO,QAAQ,GAAG,CAAC;IACrB;IAEA,MAAM,2BAA2B,UAAU,YAAY,IAAI,EAAE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I,IAAI,UAAU,MAAM,CAAC,GAAG,CAAC;IAC5C,mBAAmB,GAAG,CAAC,UAAU,IAAI,EAAE;IACvC,KAAK,MAAM,aAAa,OAAQ;QAC9B,IAAI,kBAAkB,mBAAmB,GAAG,CAAC;QAC7C,IAAI,CAAC,iBAAiB;YACpB,kBAAkB,IAAI,IAAI;gBAAC,UAAU,IAAI;aAAC;YAC1C,mBAAmB,GAAG,CAAC,WAAW;QACpC,OAAO;YACL,gBAAgB,GAAG,CAAC,UAAU,IAAI;QACpC;IACF;IAEA,IAAI,UAAU,MAAM,KAAK,SAAS;QAChC,uBAAuB,UAAU,IAAI;IACvC;AACF;AAOA,SAAS,uBAAuB,aAAwB;IACtD,kBAAkB,GAAG,CAAC;AACxB;AAEA,SAAS,cAAc,CACrB,WACA,cACA,cACkB;IAClB,KAAK,MAAM,CAAC,UAAU,cAAc,IAAI,OAAO,OAAO,CAAC,cAAe;QACpE,IAAI,CAAC,eAAe,CAAC,SAAS,EAAE;YAC9B,eAAe,CAAC,SAAS,GAAG;QAC9B;QACA,iBAAiB,UAAU;IAC7B;IAEA,OAAO,QAAQ,aAAa,CAAC,WAAW;AAC1C;AAEA,WAAW,gCAAgC,KAAK,EAAE;AAElD,MAAM,uBAAuB,WAAW,qBAAqB;AAC7D,IAAI,MAAM,OAAO,CAAC,uBAAuB;IACvC,KAAK,MAAM,aAAa,qBAAsB;QAC5C,kBAAkB,WAAW,gCAAgC,EAAE;IACjE;AACF;AAEA,WAAW,qBAAqB,GAAG;IACjC,MAAM,CAAC;QACL,kBAAkB,WAAW,gCAAgC,EAAG;IAClE;AACF"}}, - {"offset": {"line": 936, "column": 0}, "map": {"version":3,"sources":["/turbopack/[turbopack]/dev/runtime/dom/runtime-backend-dom.ts"],"sourcesContent":["/**\n * This file contains the runtime code specific to the Turbopack development\n * ECMAScript DOM runtime.\n *\n * It will be appended to the base development runtime code.\n */\n\n/// \n\ntype ChunkResolver = {\n resolved: boolean;\n resolve: () => void;\n reject: (error?: Error) => void;\n promise: Promise;\n};\n\nlet BACKEND: RuntimeBackend;\n\nfunction augmentContext(context: TurbopackDevBaseContext): TurbopackDevContext {\n return context;\n}\n\nfunction commonJsRequireContext(\n entry: RequireContextEntry,\n sourceModule: Module\n): Exports {\n return commonJsRequire(sourceModule, entry.id());\n}\n\n(() => {\n BACKEND = {\n async registerChunk(chunkPath, params) {\n const resolver = getOrCreateResolver(chunkPath);\n resolver.resolve();\n\n if (params == null) {\n return;\n }\n\n for (const otherChunkData of params.otherChunks) {\n const otherChunkPath = getChunkPath(otherChunkData);\n // Chunk might have started loading, so we want to avoid triggering another load.\n getOrCreateResolver(otherChunkPath);\n }\n\n // This waits for chunks to be loaded, but also marks included items as available.\n await Promise.all(\n params.otherChunks.map((otherChunkData) =>\n loadChunk({ type: SourceType.Runtime, chunkPath }, otherChunkData)\n )\n );\n\n if (params.runtimeModuleIds.length > 0) {\n for (const moduleId of params.runtimeModuleIds) {\n getOrInstantiateRuntimeModule(moduleId, chunkPath);\n }\n }\n },\n\n loadChunk(chunkPath, source) {\n return doLoadChunk(chunkPath, source);\n },\n\n unloadChunk(chunkPath) {\n deleteResolver(chunkPath);\n\n const chunkUrl = getChunkRelativeUrl(chunkPath);\n\n if (chunkPath.endsWith(\".css\")) {\n const links = document.querySelectorAll(`link[href=\"${chunkUrl}\"]`);\n for (const link of Array.from(links)) {\n link.remove();\n }\n } else if (chunkPath.endsWith(\".js\")) {\n // Unloading a JS chunk would have no effect, as it lives in the JS\n // runtime once evaluated.\n // However, we still want to remove the script tag from the DOM to keep\n // the HTML somewhat consistent from the user's perspective.\n const scripts = document.querySelectorAll(`script[src=\"${chunkUrl}\"]`);\n for (const script of Array.from(scripts)) {\n script.remove();\n }\n } else {\n throw new Error(`can't infer type of chunk from path ${chunkPath}`);\n }\n },\n\n reloadChunk(chunkPath) {\n return new Promise((resolve, reject) => {\n if (!chunkPath.endsWith(\".css\")) {\n reject(new Error(\"The DOM backend can only reload CSS chunks\"));\n return;\n }\n\n const encodedChunkPath = chunkPath\n .split(\"/\")\n .map((p) => encodeURIComponent(p))\n .join(\"/\");\n\n const chunkUrl = `/${getChunkRelativeUrl(encodedChunkPath)}`;\n\n const previousLink = document.querySelector(\n `link[rel=stylesheet][href^=\"${chunkUrl}\"]`\n );\n\n if (previousLink == null) {\n reject(new Error(`No link element found for chunk ${chunkPath}`));\n return;\n }\n\n const link = document.createElement(\"link\");\n link.rel = \"stylesheet\";\n link.href = chunkUrl;\n link.onerror = () => {\n reject();\n };\n link.onload = () => {\n // First load the new CSS, then remove the old one. This prevents visible\n // flickering that would happen in-between removing the previous CSS and\n // loading the new one.\n previousLink.remove();\n\n // CSS chunks do not register themselves, and as such must be marked as\n // loaded instantly.\n resolve();\n };\n\n // Make sure to insert the new CSS right after the previous one, so that\n // its precedence is higher.\n previousLink.parentElement!.insertBefore(\n link,\n previousLink.nextSibling\n );\n });\n },\n\n restart: () => self.location.reload(),\n };\n\n /**\n * Maps chunk paths to the corresponding resolver.\n */\n const chunkResolvers: Map = new Map();\n\n function getOrCreateResolver(chunkPath: ChunkPath): ChunkResolver {\n let resolver = chunkResolvers.get(chunkPath);\n if (!resolver) {\n let resolve: () => void;\n let reject: (error?: Error) => void;\n const promise = new Promise((innerResolve, innerReject) => {\n resolve = innerResolve;\n reject = innerReject;\n });\n resolver = {\n resolved: false,\n promise,\n resolve: () => {\n resolver!.resolved = true;\n resolve();\n },\n reject: reject!,\n };\n chunkResolvers.set(chunkPath, resolver);\n }\n return resolver;\n }\n\n function deleteResolver(chunkPath: ChunkPath) {\n chunkResolvers.delete(chunkPath);\n }\n\n /**\n * Loads the given chunk, and returns a promise that resolves once the chunk\n * has been loaded.\n */\n async function doLoadChunk(chunkPath: ChunkPath, source: SourceInfo) {\n const resolver = getOrCreateResolver(chunkPath);\n if (resolver.resolved) {\n return resolver.promise;\n }\n\n if (source.type === SourceType.Runtime) {\n // We don't need to load chunks references from runtime code, as they're already\n // present in the DOM.\n\n if (chunkPath.endsWith(\".css\")) {\n // CSS chunks do not register themselves, and as such must be marked as\n // loaded instantly.\n resolver.resolve();\n }\n\n // We need to wait for JS chunks to register themselves within `registerChunk`\n // before we can start instantiating runtime modules, hence the absence of\n // `resolver.resolve()` in this branch.\n\n return resolver.promise;\n }\n\n const chunkUrl = `/${getChunkRelativeUrl(chunkPath)}`;\n\n if (chunkPath.endsWith(\".css\")) {\n const link = document.createElement(\"link\");\n link.rel = \"stylesheet\";\n link.href = chunkUrl;\n link.onerror = () => {\n resolver.reject();\n };\n link.onload = () => {\n // CSS chunks do not register themselves, and as such must be marked as\n // loaded instantly.\n resolver.resolve();\n };\n document.body.appendChild(link);\n } else if (chunkPath.endsWith(\".js\")) {\n const script = document.createElement(\"script\");\n script.src = chunkUrl;\n // We'll only mark the chunk as loaded once the script has been executed,\n // which happens in `registerChunk`. Hence the absence of `resolve()` in\n // this branch.\n script.onerror = () => {\n resolver.reject();\n };\n document.body.appendChild(script);\n } else {\n throw new Error(`can't infer type of chunk from path ${chunkPath}`);\n }\n\n return resolver.promise;\n }\n})();\n\nfunction _eval({ code, url, map }: EcmascriptModuleEntry): ModuleFactory {\n code += `\\n\\n//# sourceURL=${location.origin}/${url}`;\n if (map) code += `\\n//# sourceMappingURL=${map}`;\n return eval(code);\n}\n"],"names":[],"mappings":"AAgBA,IAAI;AAEJ,SAAS,eAAe,QAAgC;IACtD,OAAO;AACT;AAEA,SAAS,uBACP,MAA0B,EAC1B,aAAoB;IAEpB,OAAO,gBAAgB,eAAc,OAAM,EAAE;AAC/C;AAEC,CAAA;IACC,UAAU;QACR,MAAM,eAAc,UAAS,EAAE,OAAM;YACnC,MAAM,YAAW,qBAAoB;YACrC,UAAS,OAAO;YAEhB,IAAI,WAAU,MAAM;gBAClB;YACF;YAEA,KAAK,MAAM,mBAAkB,QAAO,WAAW,CAAE;gBAC/C,MAAM,kBAAiB,aAAa;gBAEpC,qBAAoB;YACtB;YAGA,MAAM,QAAQ,GAAG,CACf,QAAO,WAAW,CAAC,GA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,GAAG;gBACb,UAAS,MAAM;YACjB;YACA,MAAK,MAAM,GAAG;gBAGZ,UAAS,OAAO;YAClB;YACA,SAAS,IAAI,CAAC,WAAW,CAAC;QAC5B,OAAO,IAAI,WAAU,QAAQ,CAAC,QAAQ;YACpC,MAAM,UAAS,SAAS,aAAa,CAAC;YACtC,QAAO,GAAG,GAAG;YAIb,QAAO,OAAO,GAAG;gBACf,UAAS,MAAM;YACjB;YACA,SAAS,IAAI,CAAC,WAAW,CAAC;QAC5B,OAAO;YACL,MAAM,IAAI,MAAM,CAAC,oCAAoC,EAAE,WAAU,CAAC;QACpE;QAEA,OAAO,UAAS,OAAO;IACzB;AACF,CAAA;AAEA,SAAS,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAyB;IACtD,QAAQ,CAAC,kBAAkB,EAAE,SAAS,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC;IACrD,IAAI,KAAK,QAAQ,CAAC,uBAAuB,EAAE,IAAI,CAAC;IAChD,OAAO,KAAK;AACd"}}, - {"offset": {"line": 1080, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}] + {"offset": {"line": 11, "column": 0}, "map": {"version":3,"sources":["/turbopack/[turbopack]/shared/runtime-utils.ts"],"sourcesContent":["/**\n * This file contains runtime types and functions that are shared between all\n * TurboPack ECMAScript runtimes.\n *\n * It will be prepended to the runtime code of each runtime.\n */\n\n/* eslint-disable @next/next/no-assign-module-variable */\n\n/// \n\ninterface Exports {\n __esModule?: boolean;\n\n [key: string]: any;\n}\n\ntype EsmNamespaceObject = Record;\n\nconst REEXPORTED_OBJECTS = Symbol(\"reexported objects\");\n\ninterface BaseModule {\n exports: Exports | Promise | AsyncModulePromise;\n error: Error | undefined;\n loaded: boolean;\n id: ModuleId;\n children: ModuleId[];\n parents: ModuleId[];\n namespaceObject?:\n | EsmNamespaceObject\n | Promise\n | AsyncModulePromise;\n [REEXPORTED_OBJECTS]?: any[];\n}\n\ninterface Module extends BaseModule {}\n\ntype RequireContextMap = Record;\n\ninterface RequireContextEntry {\n id: () => ModuleId;\n}\n\ninterface RequireContext {\n (moduleId: ModuleId): Exports | EsmNamespaceObject;\n\n keys(): ModuleId[];\n\n resolve(moduleId: ModuleId): ModuleId;\n}\n\ntype GetOrInstantiateModuleFromParent = (\n moduleId: ModuleId,\n parentModule: Module\n) => Module;\n\ntype CommonJsRequireContext = (\n entry: RequireContextEntry,\n parentModule: Module\n) => Exports;\n\nconst hasOwnProperty = Object.prototype.hasOwnProperty;\nconst toStringTag = typeof Symbol !== \"undefined\" && Symbol.toStringTag;\n\nfunction defineProp(\n obj: any,\n name: PropertyKey,\n options: PropertyDescriptor & ThisType\n) {\n if (!hasOwnProperty.call(obj, name))\n Object.defineProperty(obj, name, options);\n}\n\n/**\n * Adds the getters to the exports object.\n */\nfunction esm(exports: Exports, getters: Record any>) {\n defineProp(exports, \"__esModule\", { value: true });\n if (toStringTag) defineProp(exports, toStringTag, { value: \"Module\" });\n for (const key in getters) {\n defineProp(exports, key, { get: getters[key], enumerable: true });\n }\n}\n\n/**\n * Makes the module an ESM with exports\n */\nfunction esmExport(\n module: Module,\n exports: Exports,\n getters: Record any>\n) {\n module.namespaceObject = module.exports;\n esm(exports, getters);\n}\n\n/**\n * Dynamically exports properties from an object\n */\nfunction dynamicExport(\n module: Module,\n exports: Exports,\n object: Record\n) {\n let reexportedObjects = module[REEXPORTED_OBJECTS];\n if (!reexportedObjects) {\n reexportedObjects = module[REEXPORTED_OBJECTS] = [];\n\n const namespaceObject = new Proxy(exports, {\n get(target, prop) {\n if (\n hasOwnProperty.call(target, prop) ||\n prop === \"default\" ||\n prop === \"__esModule\"\n ) {\n return Reflect.get(target, prop);\n }\n for (const obj of reexportedObjects!) {\n const value = Reflect.get(obj, prop);\n if (value !== undefined) return value;\n }\n return undefined;\n },\n ownKeys(target) {\n const keys = Reflect.ownKeys(target);\n for (const obj of reexportedObjects!) {\n for (const key of Reflect.ownKeys(obj)) {\n if (key !== \"default\" && !keys.includes(key)) keys.push(key);\n }\n }\n return keys;\n },\n });\n\n // If this is inside an async module `module.namespaceObject` is a promise,\n // so we need to replace it with a new promise.\n if (isPromise(module.namespaceObject)) {\n module.exports = module.namespaceObject = maybeWrapAsyncModulePromise(\n module.namespaceObject,\n () => namespaceObject\n );\n } else {\n module.exports = module.namespaceObject = namespaceObject;\n }\n }\n reexportedObjects.push(object);\n}\n\nfunction exportValue(module: Module, value: any) {\n module.exports = value;\n}\n\nfunction exportNamespace(module: Module, namespace: any) {\n module.exports = module.namespaceObject = namespace;\n}\n\nfunction createGetter(obj: Record, key: string) {\n return () => obj[key];\n}\n\n/**\n * @returns prototype of the object\n */\nconst getProto: (obj: any) => any = Object.getPrototypeOf\n ? (obj) => Object.getPrototypeOf(obj)\n : (obj) => obj.__proto__;\n\n/** Prototypes that are not expanded for exports */\nconst LEAF_PROTOTYPES = [null, getProto({}), getProto([]), getProto(getProto)];\n\n/**\n * @param raw\n * @param ns\n * @param allowExportDefault\n * * `false`: will have the raw module as default export\n * * `true`: will have the default property as default export\n */\nfunction interopEsm(\n raw: Exports,\n ns: EsmNamespaceObject,\n allowExportDefault?: boolean\n) {\n const getters: { [s: string]: () => any } = Object.create(null);\n for (\n let current = raw;\n (typeof current === \"object\" || typeof current === \"function\") &&\n !LEAF_PROTOTYPES.includes(current);\n current = getProto(current)\n ) {\n for (const key of Object.getOwnPropertyNames(current)) {\n getters[key] = createGetter(raw, key);\n }\n }\n\n // this is not really correct\n // we should set the `default` getter if the imported module is a `.cjs file`\n if (!(allowExportDefault && \"default\" in getters)) {\n getters[\"default\"] = () => raw;\n }\n\n esm(ns, getters);\n return ns;\n}\n\nfunction esmImport(\n sourceModule: Module,\n id: ModuleId\n): Exclude {\n const module = getOrInstantiateModuleFromParent(id, sourceModule);\n if (module.error) throw module.error;\n\n // any async module has to have `module.namespaceObject` defined\n if (module.namespaceObject) return module.namespaceObject;\n\n // can't be an async module at this point\n const raw = module.exports;\n return (module.namespaceObject = interopEsm(\n raw,\n {},\n (raw as any).__esModule\n ));\n}\n\nfunction commonJsRequire(sourceModule: Module, id: ModuleId): Exports {\n const module = getOrInstantiateModuleFromParent(id, sourceModule);\n if (module.error) throw module.error;\n return module.exports;\n}\n\ntype RequireContextFactory = (map: RequireContextMap) => RequireContext;\n\nfunction requireContext(\n sourceModule: Module,\n map: RequireContextMap\n): RequireContext {\n function requireContext(id: ModuleId): Exports {\n const entry = map[id];\n\n if (!entry) {\n throw new Error(\n `module ${id} is required from a require.context, but is not in the context`\n );\n }\n\n return commonJsRequireContext(entry, sourceModule);\n }\n\n requireContext.keys = (): ModuleId[] => {\n return Object.keys(map);\n };\n\n requireContext.resolve = (id: ModuleId): ModuleId => {\n const entry = map[id];\n\n if (!entry) {\n throw new Error(\n `module ${id} is resolved from a require.context, but is not in the context`\n );\n }\n\n return entry.id();\n };\n\n return requireContext;\n}\n\n/**\n * Returns the path of a chunk defined by its data.\n */\nfunction getChunkPath(chunkData: ChunkData): ChunkPath {\n return typeof chunkData === \"string\" ? chunkData : chunkData.path;\n}\n\nfunction isPromise(maybePromise: any): maybePromise is Promise {\n return (\n maybePromise != null &&\n typeof maybePromise === \"object\" &&\n \"then\" in maybePromise &&\n typeof maybePromise.then === \"function\"\n );\n}\n\nfunction isAsyncModuleExt(obj: T): obj is AsyncModuleExt & T {\n return turbopackQueues in obj;\n}\n\nfunction maybeWrapAsyncModulePromise(\n promise: Promise,\n then: (val: T) => U | PromiseLike\n): typeof promise extends AsyncModulePromise\n ? AsyncModulePromise\n : Promise {\n const newPromise = promise.then(then);\n\n if (isAsyncModuleExt(promise)) {\n Object.assign(newPromise, {\n get [turbopackExports]() {\n return promise[turbopackExports];\n },\n get [turbopackQueues]() {\n return promise[turbopackQueues];\n },\n get [turbopackError]() {\n return promise[turbopackError];\n },\n } satisfies AsyncModuleExt);\n }\n\n return newPromise as any;\n}\n\nfunction createPromise() {\n let resolve: (value: T | PromiseLike) => void;\n let reject: (reason?: any) => void;\n\n const promise = new Promise((res, rej) => {\n reject = rej;\n resolve = res;\n });\n\n return {\n promise,\n resolve: resolve!,\n reject: reject!,\n };\n}\n\n// everything below is adapted from webpack\n// https://github.com/webpack/webpack/blob/6be4065ade1e252c1d8dcba4af0f43e32af1bdc1/lib/runtime/AsyncModuleRuntimeModule.js#L13\n\nconst turbopackQueues = Symbol(\"turbopack queues\");\nconst turbopackExports = Symbol(\"turbopack exports\");\nconst turbopackError = Symbol(\"turbopack error\");\n\ntype AsyncQueueFn = (() => void) & { queueCount: number };\ntype AsyncQueue = AsyncQueueFn[] & { resolved: boolean };\n\nfunction resolveQueue(queue?: AsyncQueue) {\n if (queue && !queue.resolved) {\n queue.resolved = true;\n queue.forEach((fn) => fn.queueCount--);\n queue.forEach((fn) => (fn.queueCount-- ? fn.queueCount++ : fn()));\n }\n}\n\ntype Dep = Exports | AsyncModulePromise | Promise;\n\ntype AsyncModuleExt = {\n [turbopackQueues]: (fn: (queue: AsyncQueue) => void) => void;\n [turbopackExports]: Exports;\n [turbopackError]?: any;\n};\n\ntype AsyncModulePromise = Promise & AsyncModuleExt;\n\nfunction wrapDeps(deps: Dep[]): AsyncModuleExt[] {\n return deps.map((dep) => {\n if (dep !== null && typeof dep === \"object\") {\n if (isAsyncModuleExt(dep)) return dep;\n if (isPromise(dep)) {\n const queue: AsyncQueue = Object.assign([], { resolved: false });\n\n const obj: AsyncModuleExt = {\n [turbopackExports]: {},\n [turbopackQueues]: (fn: (queue: AsyncQueue) => void) => fn(queue),\n };\n\n dep.then(\n (res) => {\n obj[turbopackExports] = res;\n resolveQueue(queue);\n },\n (err) => {\n obj[turbopackError] = err;\n resolveQueue(queue);\n }\n );\n\n return obj;\n }\n }\n\n const ret: AsyncModuleExt = {\n [turbopackExports]: dep,\n [turbopackQueues]: () => {},\n };\n\n return ret;\n });\n}\n\nfunction asyncModule(\n module: Module,\n body: (\n handleAsyncDependencies: (\n deps: Dep[]\n ) => Exports[] | Promise<() => Exports[]>,\n asyncResult: (err?: any) => void\n ) => void,\n hasAwait: boolean\n) {\n const queue: AsyncQueue | undefined = hasAwait\n ? Object.assign([], { resolved: true })\n : undefined;\n\n const depQueues: Set = new Set();\n const exports = module.exports;\n\n const { resolve, reject, promise: rawPromise } = createPromise();\n\n const promise: AsyncModulePromise = Object.assign(rawPromise, {\n [turbopackExports]: exports,\n [turbopackQueues]: (fn) => {\n queue && fn(queue);\n depQueues.forEach(fn);\n promise[\"catch\"](() => {});\n },\n } satisfies AsyncModuleExt);\n\n module.exports = module.namespaceObject = promise;\n\n function handleAsyncDependencies(deps: Dep[]) {\n const currentDeps = wrapDeps(deps);\n\n const getResult = () =>\n currentDeps.map((d) => {\n if (d[turbopackError]) throw d[turbopackError];\n return d[turbopackExports];\n });\n\n const { promise, resolve } = createPromise<() => Exports[]>();\n\n const fn: AsyncQueueFn = Object.assign(() => resolve(getResult), {\n queueCount: 0,\n });\n\n function fnQueue(q: AsyncQueue) {\n if (q !== queue && !depQueues.has(q)) {\n depQueues.add(q);\n if (q && !q.resolved) {\n fn.queueCount++;\n q.push(fn);\n }\n }\n }\n\n currentDeps.map((dep) => dep[turbopackQueues](fnQueue));\n\n return fn.queueCount ? promise : getResult();\n }\n\n function asyncResult(err?: any) {\n if (err) {\n reject((promise[turbopackError] = err));\n } else {\n resolve(exports);\n }\n\n resolveQueue(queue);\n }\n\n body(handleAsyncDependencies, asyncResult);\n\n if (queue) {\n queue.resolved = false;\n }\n}\n"],"names":[],"mappings":";AAmBA,MAAM,qBAAqB,OAAO;;;;;AA0ClC,MAAM,iBAAiB,OAAO,SAAS,CAAC,cAAc;AACtD,MAAM,cAAc,OAAO,WAAW,eAAe,OAAO,WAAW;AAEvE,SAAS,WACP,GAAQ,EACR,IAAiB,EACjB,OAA2C;IAE3C,IAAI,CAAC,eAAe,IAAI,CAAC,KAAK,OAC5B,OAAO,cAAc,CAAC,KAAK,MAAM;AACrC;AAKA,SAAS,IAAI,OAAgB,EAAE,OAAkC;IAC/D,WAAW,SAAS,cAAc;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* This file contains runtime types and functions that are shared between all\n * Turbopack *development* ECMAScript runtimes.\n *\n * It will be appended to the runtime code of each runtime right after the\n * shared runtime utils.\n */\n\n/* eslint-disable @next/next/no-assign-module-variable */\n\n/// \n/// \n/// \n/// \n\n// This file must not use `import` and `export` statements. Otherwise, it\n// becomes impossible to augment interfaces declared in ``d files\n// (e.g. `Module`). Hence, the need for `import()` here.\ntype RefreshRuntimeGlobals =\n import(\"@next/react-refresh-utils/dist/runtime\").RefreshRuntimeGlobals;\n\ndeclare var CHUNK_BASE_PATH: string;\ndeclare var $RefreshHelpers$: RefreshRuntimeGlobals[\"$RefreshHelpers$\"];\ndeclare var $RefreshReg$: RefreshRuntimeGlobals[\"$RefreshReg$\"];\ndeclare var $RefreshSig$: RefreshRuntimeGlobals[\"$RefreshSig$\"];\ndeclare var $RefreshInterceptModuleExecution$:\n | RefreshRuntimeGlobals[\"$RefreshInterceptModuleExecution$\"];\n\ntype RefreshContext = {\n register: RefreshRuntimeGlobals[\"$RefreshReg$\"];\n signature: RefreshRuntimeGlobals[\"$RefreshSig$\"];\n};\n\ntype RefreshHelpers = RefreshRuntimeGlobals[\"$RefreshHelpers$\"];\n\ninterface TurbopackDevBaseContext extends TurbopackBaseContext {\n k: RefreshContext;\n}\n\ninterface TurbopackDevContext extends TurbopackDevBaseContext {}\n\n// string encoding of a module factory (used in hmr updates)\ntype ModuleFactoryString = string;\n\ntype ModuleFactory = (\n this: Module[\"exports\"],\n context: TurbopackDevContext\n) => undefined;\n\ntype DevRuntimeParams = {\n otherChunks: ChunkData[];\n runtimeModuleIds: ModuleId[];\n};\n\ntype ChunkRegistration = [\n chunkPath: ChunkPath,\n chunkModules: ModuleFactories,\n params: DevRuntimeParams | undefined\n];\ntype ChunkList = {\n path: ChunkPath;\n chunks: ChunkData[];\n source: \"entry\" | \"dynamic\";\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 * The module was instantiated because it was included in a chunk's hot module\n * update.\n */\n Update = 2,\n}\n\ntype SourceInfo =\n | {\n type: SourceType.Runtime;\n chunkPath: ChunkPath;\n }\n | {\n type: SourceType.Parent;\n parentId: ModuleId;\n }\n | {\n type: SourceType.Update;\n parents?: ModuleId[];\n };\n\ninterface RuntimeBackend {\n registerChunk: (chunkPath: ChunkPath, params?: DevRuntimeParams) => void;\n loadChunk: (chunkPath: ChunkPath, source: SourceInfo) => Promise;\n reloadChunk?: (chunkPath: ChunkPath) => Promise;\n unloadChunk?: (chunkPath: ChunkPath) => void;\n\n restart: () => void;\n}\n\nconst moduleFactories: ModuleFactories = Object.create(null);\nconst moduleCache: ModuleCache = Object.create(null);\n/**\n * Maps module IDs to persisted data between executions of their hot module\n * implementation (`hot.data`).\n */\nconst moduleHotData: Map = new Map();\n/**\n * Maps module instances to their hot module state.\n */\nconst moduleHotState: Map = new Map();\n/**\n * Modules that call `module.hot.invalidate()` (while being updated).\n */\nconst queuedInvalidatedModules: Set = new Set();\n/**\n * Module IDs that are instantiated as part of the runtime of a chunk.\n */\nconst runtimeModules: Set = new Set();\n/**\n * Map from module ID to the chunks that contain this module.\n *\n * In HMR, we need to keep track of which modules are contained in which so\n * chunks. This is so we don't eagerly dispose of a module when it is removed\n * from chunk A, but still exists in chunk B.\n */\nconst moduleChunksMap: Map> = new Map();\n/**\n * Map from a chunk path to all modules it contains.\n */\nconst chunkModulesMap: Map> = new Map();\n/**\n * Chunk lists that contain a runtime. When these chunk lists receive an update\n * that can't be reconciled with the current state of the page, we need to\n * reload the runtime entirely.\n */\nconst runtimeChunkLists: Set = new Set();\n/**\n * Map from a chunk list to the chunk paths it contains.\n */\nconst chunkListChunksMap: Map> = new Map();\n/**\n * Map from a chunk path to the chunk lists it belongs to.\n */\nconst chunkChunkListsMap: Map> = new Map();\n\nconst availableModules: Map | true> = new Map();\n\nconst availableModuleChunks: Map | true> = new Map();\n\nasync function loadChunk(\n source: SourceInfo,\n chunkData: ChunkData\n): Promise {\n if (typeof chunkData === \"string\") {\n return loadChunkPath(source, chunkData);\n }\n\n const includedList = chunkData.included || [];\n const modulesPromises = includedList.map((included) => {\n if (moduleFactories[included]) return true;\n return availableModules.get(included);\n });\n if (modulesPromises.length > 0 && modulesPromises.every((p) => p)) {\n // When all included items are already loaded or loading, we can skip loading ourselves\n return Promise.all(modulesPromises);\n }\n\n const includedModuleChunksList = chunkData.moduleChunks || [];\n const moduleChunksPromises = includedModuleChunksList\n .map((included) => {\n // TODO(alexkirsz) Do we need this check?\n // if (moduleFactories[included]) return true;\n return availableModuleChunks.get(included);\n })\n .filter((p) => p);\n\n let promise;\n if (moduleChunksPromises.length > 0) {\n // Some module chunks are already loaded or loading.\n\n if (moduleChunksPromises.length == includedModuleChunksList.length) {\n // When all included module chunks are already loaded or loading, we can skip loading ourselves\n return Promise.all(moduleChunksPromises);\n }\n\n const moduleChunksToLoad: Set = new Set();\n for (const moduleChunk of includedModuleChunksList) {\n if (!availableModuleChunks.has(moduleChunk)) {\n moduleChunksToLoad.add(moduleChunk);\n }\n }\n\n for (const moduleChunkToLoad of moduleChunksToLoad) {\n const promise = loadChunkPath(source, moduleChunkToLoad);\n\n availableModuleChunks.set(moduleChunkToLoad, promise);\n\n moduleChunksPromises.push(promise);\n }\n\n promise = Promise.all(moduleChunksPromises);\n } else {\n promise = loadChunkPath(source, chunkData.path);\n\n // Mark all included module chunks as loading if they are not already loaded or loading.\n for (const includedModuleChunk of includedModuleChunksList) {\n if (!availableModuleChunks.has(includedModuleChunk)) {\n availableModuleChunks.set(includedModuleChunk, promise);\n }\n }\n }\n\n for (const included of includedList) {\n if (!availableModules.has(included)) {\n // It might be better to race old and new promises, but it's rare that the new promise will be faster than a request started earlier.\n // In production it's even more rare, because the chunk optimization tries to deduplicate modules anyway.\n availableModules.set(included, promise);\n }\n }\n\n return promise;\n}\n\nasync function loadChunkPath(\n source: SourceInfo,\n chunkPath: ChunkPath\n): Promise {\n try {\n await BACKEND.loadChunk(chunkPath, source);\n } catch (error) {\n let loadReason;\n switch (source.type) {\n case SourceType.Runtime:\n loadReason = `as a runtime dependency of chunk ${source.chunkPath}`;\n break;\n case SourceType.Parent:\n loadReason = `from module ${source.parentId}`;\n break;\n case SourceType.Update:\n loadReason = \"from an HMR update\";\n break;\n }\n throw new Error(\n `Failed to load chunk ${chunkPath} ${loadReason}${\n error ? `: ${error}` : \"\"\n }`,\n error\n ? {\n cause: error,\n }\n : undefined\n );\n }\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 case SourceType.Update:\n instantiationReason = \"because of an HMR update\";\n break;\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 hotData = moduleHotData.get(id)!;\n const { hot, hotState } = createModuleHot(id, hotData);\n\n let parents: ModuleId[];\n switch (source.type) {\n case SourceType.Runtime:\n runtimeModules.add(id);\n parents = [];\n break;\n case SourceType.Parent:\n // No need to add this module as a child of the parent module here, this\n // has already been taken care of in `getOrInstantiateModuleFromParent`.\n parents = [source.parentId];\n break;\n case SourceType.Update:\n parents = source.parents || [];\n break;\n }\n const module: Module = {\n exports: {},\n error: undefined,\n loaded: false,\n id,\n parents,\n children: [],\n namespaceObject: undefined,\n hot,\n };\n\n moduleCache[id] = module;\n moduleHotState.set(module, hotState);\n\n // NOTE(alexkirsz) This can fail when the module encounters a runtime error.\n try {\n runModuleExecutionHooks(module, (refresh) => {\n moduleFactory.call(\n module.exports,\n augmentContext({\n a: asyncModule.bind(null, module),\n e: module.exports,\n r: commonJsRequire.bind(null, module),\n f: requireContext.bind(null, module),\n i: esmImport.bind(null, module),\n s: esmExport.bind(null, module, module.exports),\n j: dynamicExport.bind(null, module, module.exports),\n v: exportValue.bind(null, module),\n n: exportNamespace.bind(null, module),\n m: module,\n c: moduleCache,\n l: loadChunk.bind(null, { type: SourceType.Parent, parentId: id }),\n g: globalThis,\n k: refresh,\n __dirname: module.id.replace(/(^|\\/)\\/+$/, \"\"),\n })\n );\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 * NOTE(alexkirsz) Webpack has a \"module execution\" interception hook that\n * Next.js' React Refresh runtime hooks into to add module context to the\n * refresh registry.\n */\nfunction runModuleExecutionHooks(\n module: Module,\n executeModule: (ctx: RefreshContext) => void\n) {\n const cleanupReactRefreshIntercept =\n typeof globalThis.$RefreshInterceptModuleExecution$ === \"function\"\n ? globalThis.$RefreshInterceptModuleExecution$(module.id)\n : () => {};\n\n try {\n executeModule({\n register: globalThis.$RefreshReg$,\n signature: globalThis.$RefreshSig$,\n });\n\n if (\"$RefreshHelpers$\" in globalThis) {\n // This pattern can also be used to register the exports of\n // a module with the React Refresh runtime.\n registerExportsAndSetupBoundaryForReactRefresh(\n module,\n globalThis.$RefreshHelpers$\n );\n }\n } catch (e) {\n throw e;\n } finally {\n // Always cleanup the intercept, even if module execution failed.\n cleanupReactRefreshIntercept();\n }\n}\n\n/**\n * Retrieves a module from the cache, or instantiate it if it is not cached.\n */\nconst getOrInstantiateModuleFromParent: GetOrInstantiateModuleFromParent = (\n id,\n sourceModule\n) => {\n if (!sourceModule.hot.active) {\n console.warn(\n `Unexpected import of module ${id} from module ${sourceModule.id}, which was deleted by an HMR update`\n );\n }\n\n const module = moduleCache[id];\n\n if (sourceModule.children.indexOf(id) === -1) {\n sourceModule.children.push(id);\n }\n\n if (module) {\n if (module.parents.indexOf(sourceModule.id) === -1) {\n module.parents.push(sourceModule.id);\n }\n\n return module;\n }\n\n return instantiateModule(id, {\n type: SourceType.Parent,\n parentId: sourceModule.id,\n });\n};\n\n/**\n * This is adapted from https://github.com/vercel/next.js/blob/3466862d9dc9c8bb3131712134d38757b918d1c0/packages/react-refresh-utils/internal/ReactRefreshModule.runtime.ts\n */\nfunction registerExportsAndSetupBoundaryForReactRefresh(\n module: Module,\n helpers: RefreshHelpers\n) {\n const currentExports = module.exports;\n const prevExports = module.hot.data.prevExports ?? null;\n\n helpers.registerExportsForReactRefresh(currentExports, module.id);\n\n // A module can be accepted automatically based on its exports, e.g. when\n // it is a Refresh Boundary.\n if (helpers.isReactRefreshBoundary(currentExports)) {\n // Save the previous exports on update, so we can compare the boundary\n // signatures.\n module.hot.dispose((data) => {\n data.prevExports = currentExports;\n });\n // Unconditionally accept an update to this module, we'll check if it's\n // still a Refresh Boundary later.\n module.hot.accept();\n\n // This field is set when the previous version of this module was a\n // Refresh Boundary, letting us know we need to check for invalidation or\n // enqueue an update.\n if (prevExports !== null) {\n // A boundary can become ineligible if its exports are incompatible\n // with the previous exports.\n //\n // For example, if you add/remove/change exports, we'll want to\n // re-execute the importing modules, and force those components to\n // re-render. Similarly, if you convert a class component to a\n // function, we want to invalidate the boundary.\n if (\n helpers.shouldInvalidateReactRefreshBoundary(\n prevExports,\n currentExports\n )\n ) {\n module.hot.invalidate();\n } else {\n helpers.scheduleUpdate();\n }\n }\n } else {\n // Since we just executed the code for the module, it's possible that the\n // new exports made it ineligible for being a boundary.\n // We only care about the case when we were _previously_ a boundary,\n // because we already accepted this update (accidental side effect).\n const isNoLongerABoundary = prevExports !== null;\n if (isNoLongerABoundary) {\n module.hot.invalidate();\n }\n }\n}\n\nfunction formatDependencyChain(dependencyChain: ModuleId[]): string {\n return `Dependency chain: ${dependencyChain.join(\" -> \")}`;\n}\n\nfunction computeOutdatedModules(\n added: Map,\n modified: Map\n): {\n outdatedModules: Set;\n newModuleFactories: Map;\n} {\n const newModuleFactories = new Map();\n\n for (const [moduleId, entry] of added) {\n if (entry != null) {\n newModuleFactories.set(moduleId, _eval(entry));\n }\n }\n\n const outdatedModules = computedInvalidatedModules(modified.keys());\n\n for (const [moduleId, entry] of modified) {\n newModuleFactories.set(moduleId, _eval(entry));\n }\n\n return { outdatedModules, newModuleFactories };\n}\n\nfunction computedInvalidatedModules(\n invalidated: Iterable\n): Set {\n const outdatedModules = new Set();\n\n for (const moduleId of invalidated) {\n const effect = getAffectedModuleEffects(moduleId);\n\n switch (effect.type) {\n case \"unaccepted\":\n throw new Error(\n `cannot apply update: unaccepted module. ${formatDependencyChain(\n effect.dependencyChain\n )}.`\n );\n case \"self-declined\":\n throw new Error(\n `cannot apply update: self-declined module. ${formatDependencyChain(\n effect.dependencyChain\n )}.`\n );\n case \"accepted\":\n for (const outdatedModuleId of effect.outdatedModules) {\n outdatedModules.add(outdatedModuleId);\n }\n break;\n // TODO(alexkirsz) Dependencies: handle dependencies effects.\n }\n }\n\n return outdatedModules;\n}\n\nfunction computeOutdatedSelfAcceptedModules(\n outdatedModules: Iterable\n): { moduleId: ModuleId; errorHandler: true | Function }[] {\n const outdatedSelfAcceptedModules = [];\n for (const moduleId of outdatedModules) {\n const module = moduleCache[moduleId];\n const hotState = moduleHotState.get(module)!;\n if (module && hotState.selfAccepted && !hotState.selfInvalidated) {\n outdatedSelfAcceptedModules.push({\n moduleId,\n errorHandler: hotState.selfAccepted,\n });\n }\n }\n return outdatedSelfAcceptedModules;\n}\n\n/**\n * Adds, deletes, and moves modules between chunks. This must happen before the\n * dispose phase as it needs to know which modules were removed from all chunks,\n * which we can only compute *after* taking care of added and moved modules.\n */\nfunction updateChunksPhase(\n chunksAddedModules: Map>,\n chunksDeletedModules: Map>\n): { disposedModules: Set } {\n for (const [chunkPath, addedModuleIds] of chunksAddedModules) {\n for (const moduleId of addedModuleIds) {\n addModuleToChunk(moduleId, chunkPath);\n }\n }\n\n const disposedModules: Set = new Set();\n for (const [chunkPath, addedModuleIds] of chunksDeletedModules) {\n for (const moduleId of addedModuleIds) {\n if (removeModuleFromChunk(moduleId, chunkPath)) {\n disposedModules.add(moduleId);\n }\n }\n }\n\n return { disposedModules };\n}\n\nfunction disposePhase(\n outdatedModules: Iterable,\n disposedModules: Iterable\n): { outdatedModuleParents: Map> } {\n for (const moduleId of outdatedModules) {\n disposeModule(moduleId, \"replace\");\n }\n\n for (const moduleId of disposedModules) {\n disposeModule(moduleId, \"clear\");\n }\n\n // Removing modules from the module cache is a separate step.\n // We also want to keep track of previous parents of the outdated modules.\n const outdatedModuleParents = new Map();\n for (const moduleId of outdatedModules) {\n const oldModule = moduleCache[moduleId];\n outdatedModuleParents.set(moduleId, oldModule?.parents);\n delete moduleCache[moduleId];\n }\n\n // TODO(alexkirsz) Dependencies: remove outdated dependency from module\n // children.\n\n return { outdatedModuleParents };\n}\n\n/**\n * Disposes of an instance of a module.\n *\n * Returns the persistent hot data that should be kept for the next module\n * instance.\n *\n * NOTE: mode = \"replace\" will not remove modules from the moduleCache.\n * This must be done in a separate step afterwards.\n * This is important because all modules need to be disposed to update the\n * parent/child relationships before they are actually removed from the moduleCache.\n * If this was done in this method, the following disposeModule calls won't find\n * the module from the module id in the cache.\n */\nfunction disposeModule(moduleId: ModuleId, mode: \"clear\" | \"replace\") {\n const module = moduleCache[moduleId];\n if (!module) {\n return;\n }\n\n const hotState = moduleHotState.get(module)!;\n const data = {};\n\n // Run the `hot.dispose` handler, if any, passing in the persistent\n // `hot.data` object.\n for (const disposeHandler of hotState.disposeHandlers) {\n disposeHandler(data);\n }\n\n // This used to warn in `getOrInstantiateModuleFromParent` when a disposed\n // module is still importing other modules.\n module.hot.active = false;\n\n moduleHotState.delete(module);\n\n // TODO(alexkirsz) Dependencies: delete the module from outdated deps.\n\n // Remove the disposed module from its children's parent list.\n // It will be added back once the module re-instantiates and imports its\n // children again.\n for (const childId of module.children) {\n const child = moduleCache[childId];\n if (!child) {\n continue;\n }\n\n const idx = child.parents.indexOf(module.id);\n if (idx >= 0) {\n child.parents.splice(idx, 1);\n }\n }\n\n switch (mode) {\n case \"clear\":\n delete moduleCache[module.id];\n moduleHotData.delete(module.id);\n break;\n case \"replace\":\n moduleHotData.set(module.id, data);\n break;\n default:\n invariant(mode, (mode) => `invalid mode: ${mode}`);\n }\n}\n\nfunction applyPhase(\n outdatedSelfAcceptedModules: {\n moduleId: ModuleId;\n errorHandler: true | Function;\n }[],\n newModuleFactories: Map,\n outdatedModuleParents: Map>,\n reportError: (err: any) => void\n) {\n // Update module factories.\n for (const [moduleId, factory] of newModuleFactories.entries()) {\n moduleFactories[moduleId] = factory;\n }\n\n // TODO(alexkirsz) Run new runtime entries here.\n\n // TODO(alexkirsz) Dependencies: call accept handlers for outdated deps.\n\n // Re-instantiate all outdated self-accepted modules.\n for (const { moduleId, errorHandler } of outdatedSelfAcceptedModules) {\n try {\n instantiateModule(moduleId, {\n type: SourceType.Update,\n parents: outdatedModuleParents.get(moduleId),\n });\n } catch (err) {\n if (typeof errorHandler === \"function\") {\n try {\n errorHandler(err, { moduleId, module: moduleCache[moduleId] });\n } catch (err2) {\n reportError(err2);\n reportError(err);\n }\n } else {\n reportError(err);\n }\n }\n }\n}\n\n/**\n * Utility function to ensure all variants of an enum are handled.\n */\nfunction invariant(never: never, computeMessage: (arg: any) => string): never {\n throw new Error(`Invariant: ${computeMessage(never)}`);\n}\n\nfunction applyUpdate(chunkListPath: ChunkPath, update: PartialUpdate) {\n switch (update.type) {\n case \"ChunkListUpdate\":\n applyChunkListUpdate(chunkListPath, update);\n break;\n default:\n invariant(update, (update) => `Unknown update type: ${update.type}`);\n }\n}\n\nfunction applyChunkListUpdate(\n chunkListPath: ChunkPath,\n update: ChunkListUpdate\n) {\n if (update.merged != null) {\n for (const merged of update.merged) {\n switch (merged.type) {\n case \"EcmascriptMergedUpdate\":\n applyEcmascriptMergedUpdate(chunkListPath, merged);\n break;\n default:\n invariant(merged, (merged) => `Unknown merged type: ${merged.type}`);\n }\n }\n }\n\n if (update.chunks != null) {\n for (const [chunkPath, chunkUpdate] of Object.entries(update.chunks)) {\n switch (chunkUpdate.type) {\n case \"added\":\n BACKEND.loadChunk(chunkPath, { type: SourceType.Update });\n break;\n case \"total\":\n BACKEND.reloadChunk?.(chunkPath);\n break;\n case \"deleted\":\n BACKEND.unloadChunk?.(chunkPath);\n break;\n case \"partial\":\n invariant(\n chunkUpdate.instruction,\n (instruction) =>\n `Unknown partial instruction: ${JSON.stringify(instruction)}.`\n );\n default:\n invariant(\n chunkUpdate,\n (chunkUpdate) => `Unknown chunk update type: ${chunkUpdate.type}`\n );\n }\n }\n }\n}\n\nfunction applyEcmascriptMergedUpdate(\n chunkPath: ChunkPath,\n update: EcmascriptMergedUpdate\n) {\n const { entries = {}, chunks = {} } = update;\n const { added, modified, chunksAdded, chunksDeleted } = computeChangedModules(\n entries,\n chunks\n );\n const { outdatedModules, newModuleFactories } = computeOutdatedModules(\n added,\n modified\n );\n const { disposedModules } = updateChunksPhase(chunksAdded, chunksDeleted);\n\n applyInternal(outdatedModules, disposedModules, newModuleFactories);\n}\n\nfunction applyInvalidatedModules(outdatedModules: Set) {\n if (queuedInvalidatedModules.size > 0) {\n computedInvalidatedModules(queuedInvalidatedModules).forEach((moduleId) => {\n outdatedModules.add(moduleId);\n });\n\n queuedInvalidatedModules.clear();\n }\n\n return outdatedModules;\n}\n\nfunction applyInternal(\n outdatedModules: Set,\n disposedModules: Iterable,\n newModuleFactories: Map\n) {\n outdatedModules = applyInvalidatedModules(outdatedModules);\n\n const outdatedSelfAcceptedModules =\n computeOutdatedSelfAcceptedModules(outdatedModules);\n\n const { outdatedModuleParents } = disposePhase(\n outdatedModules,\n disposedModules\n );\n\n // we want to continue on error and only throw the error after we tried applying all updates\n let error: any;\n function reportError(err: any) {\n if (!error) error = err;\n }\n\n applyPhase(\n outdatedSelfAcceptedModules,\n newModuleFactories,\n outdatedModuleParents,\n reportError\n );\n\n if (error) {\n throw error;\n }\n\n if (queuedInvalidatedModules.size > 0) {\n applyInternal(new Set(), [], new Map());\n }\n}\n\nfunction computeChangedModules(\n entries: Record,\n updates: Record\n): {\n added: Map;\n modified: Map;\n deleted: Set;\n chunksAdded: Map>;\n chunksDeleted: Map>;\n} {\n const chunksAdded = new Map();\n const chunksDeleted = new Map();\n const added: Map = new Map();\n const modified = new Map();\n const deleted: Set = new Set();\n\n for (const [chunkPath, mergedChunkUpdate] of Object.entries(updates)) {\n switch (mergedChunkUpdate.type) {\n case \"added\": {\n const updateAdded = new Set(mergedChunkUpdate.modules);\n for (const moduleId of updateAdded) {\n added.set(moduleId, entries[moduleId]);\n }\n chunksAdded.set(chunkPath, updateAdded);\n break;\n }\n case \"deleted\": {\n // We could also use `mergedChunkUpdate.modules` here.\n const updateDeleted = new Set(chunkModulesMap.get(chunkPath));\n for (const moduleId of updateDeleted) {\n deleted.add(moduleId);\n }\n chunksDeleted.set(chunkPath, updateDeleted);\n break;\n }\n case \"partial\": {\n const updateAdded = new Set(mergedChunkUpdate.added);\n const updateDeleted = new Set(mergedChunkUpdate.deleted);\n for (const moduleId of updateAdded) {\n added.set(moduleId, entries[moduleId]);\n }\n for (const moduleId of updateDeleted) {\n deleted.add(moduleId);\n }\n chunksAdded.set(chunkPath, updateAdded);\n chunksDeleted.set(chunkPath, updateDeleted);\n break;\n }\n default:\n invariant(\n mergedChunkUpdate,\n (mergedChunkUpdate) =>\n `Unknown merged chunk update type: ${mergedChunkUpdate.type}`\n );\n }\n }\n\n // If a module was added from one chunk and deleted from another in the same update,\n // consider it to be modified, as it means the module was moved from one chunk to another\n // AND has new code in a single update.\n for (const moduleId of added.keys()) {\n if (deleted.has(moduleId)) {\n added.delete(moduleId);\n deleted.delete(moduleId);\n }\n }\n\n for (const [moduleId, entry] of Object.entries(entries)) {\n // Modules that haven't been added to any chunk but have new code are considered\n // to be modified.\n // This needs to be under the previous loop, as we need it to get rid of modules\n // that were added and deleted in the same update.\n if (!added.has(moduleId)) {\n modified.set(moduleId, entry);\n }\n }\n\n return { added, deleted, modified, chunksAdded, chunksDeleted };\n}\n\ntype ModuleEffect =\n | {\n type: \"unaccepted\";\n dependencyChain: ModuleId[];\n }\n | {\n type: \"self-declined\";\n dependencyChain: ModuleId[];\n moduleId: ModuleId;\n }\n | {\n type: \"accepted\";\n moduleId: ModuleId;\n outdatedModules: Set;\n };\n\nfunction getAffectedModuleEffects(moduleId: ModuleId): ModuleEffect {\n const outdatedModules: Set = new Set();\n\n type QueueItem = { moduleId?: ModuleId; dependencyChain: ModuleId[] };\n\n const queue: QueueItem[] = [\n {\n moduleId,\n dependencyChain: [],\n },\n ];\n\n let nextItem;\n while ((nextItem = queue.shift())) {\n const { moduleId, dependencyChain } = nextItem;\n\n if (moduleId != null) {\n outdatedModules.add(moduleId);\n }\n\n // We've arrived at the runtime of the chunk, which means that nothing\n // else above can accept this update.\n if (moduleId === undefined) {\n return {\n type: \"unaccepted\",\n dependencyChain,\n };\n }\n\n const module = moduleCache[moduleId];\n const hotState = moduleHotState.get(module)!;\n\n if (\n // The module is not in the cache. Since this is a \"modified\" update,\n // it means that the module was never instantiated before.\n !module || // The module accepted itself without invalidating globalThis.\n // TODO is that right?\n (hotState.selfAccepted && !hotState.selfInvalidated)\n ) {\n continue;\n }\n\n if (hotState.selfDeclined) {\n return {\n type: \"self-declined\",\n dependencyChain,\n moduleId,\n };\n }\n\n if (runtimeModules.has(moduleId)) {\n queue.push({\n moduleId: undefined,\n dependencyChain: [...dependencyChain, moduleId],\n });\n continue;\n }\n\n for (const parentId of module.parents) {\n const parent = moduleCache[parentId];\n\n if (!parent) {\n // TODO(alexkirsz) Is this even possible?\n continue;\n }\n\n // TODO(alexkirsz) Dependencies: check accepted and declined\n // dependencies here.\n\n queue.push({\n moduleId: parentId,\n dependencyChain: [...dependencyChain, moduleId],\n });\n }\n }\n\n return {\n type: \"accepted\",\n moduleId,\n outdatedModules,\n };\n}\n\nfunction handleApply(chunkListPath: ChunkPath, update: ServerMessage) {\n switch (update.type) {\n case \"partial\": {\n // This indicates that the update is can be applied to the current state of the application.\n applyUpdate(chunkListPath, update.instruction);\n break;\n }\n case \"restart\": {\n // This indicates that there is no way to apply the update to the\n // current state of the application, and that the application must be\n // restarted.\n BACKEND.restart();\n break;\n }\n case \"notFound\": {\n // This indicates that the chunk list no longer exists: either the dynamic import which created it was removed,\n // or the page itself was deleted.\n // If it is a dynamic import, we simply discard all modules that the chunk has exclusive access to.\n // If it is a runtime chunk list, we restart the application.\n if (runtimeChunkLists.has(chunkListPath)) {\n BACKEND.restart();\n } else {\n disposeChunkList(chunkListPath);\n }\n break;\n }\n default:\n throw new Error(`Unknown update type: ${update.type}`);\n }\n}\n\nfunction createModuleHot(\n moduleId: ModuleId,\n hotData: HotData\n): { hot: Hot; hotState: HotState } {\n const hotState: HotState = {\n selfAccepted: false,\n selfDeclined: false,\n selfInvalidated: false,\n disposeHandlers: [],\n };\n\n const hot: Hot = {\n // TODO(alexkirsz) This is not defined in the HMR API. It was used to\n // decide whether to warn whenever an HMR-disposed module required other\n // modules. We might want to remove it.\n active: true,\n\n data: hotData ?? {},\n\n // TODO(alexkirsz) Support full (dep, callback, errorHandler) form.\n accept: (\n modules?: string | string[] | AcceptErrorHandler,\n _callback?: AcceptCallback,\n _errorHandler?: AcceptErrorHandler\n ) => {\n if (modules === undefined) {\n hotState.selfAccepted = true;\n } else if (typeof modules === \"function\") {\n hotState.selfAccepted = modules;\n } else {\n throw new Error(\"unsupported `accept` signature\");\n }\n },\n\n decline: (dep) => {\n if (dep === undefined) {\n hotState.selfDeclined = true;\n } else {\n throw new Error(\"unsupported `decline` signature\");\n }\n },\n\n dispose: (callback) => {\n hotState.disposeHandlers.push(callback);\n },\n\n addDisposeHandler: (callback) => {\n hotState.disposeHandlers.push(callback);\n },\n\n removeDisposeHandler: (callback) => {\n const idx = hotState.disposeHandlers.indexOf(callback);\n if (idx >= 0) {\n hotState.disposeHandlers.splice(idx, 1);\n }\n },\n\n invalidate: () => {\n hotState.selfInvalidated = true;\n queuedInvalidatedModules.add(moduleId);\n },\n\n // NOTE(alexkirsz) This is part of the management API, which we don't\n // implement, but the Next.js React Refresh runtime uses this to decide\n // whether to schedule an update.\n status: () => \"idle\",\n\n // NOTE(alexkirsz) Since we always return \"idle\" for now, these are no-ops.\n addStatusHandler: (_handler) => {},\n removeStatusHandler: (_handler) => {},\n };\n\n return { hot, hotState };\n}\n\n/**\n * Adds a module to a chunk.\n */\nfunction addModuleToChunk(moduleId: ModuleId, chunkPath: ChunkPath) {\n let moduleChunks = moduleChunksMap.get(moduleId);\n if (!moduleChunks) {\n moduleChunks = new Set([chunkPath]);\n moduleChunksMap.set(moduleId, moduleChunks);\n } else {\n moduleChunks.add(chunkPath);\n }\n\n let chunkModules = chunkModulesMap.get(chunkPath);\n if (!chunkModules) {\n chunkModules = new Set([moduleId]);\n chunkModulesMap.set(chunkPath, chunkModules);\n } else {\n chunkModules.add(moduleId);\n }\n}\n\n/**\n * Returns the first chunk that included a module.\n * This is used by the Node.js backend, hence why it's marked as unused in this\n * file.\n */\nfunction getFirstModuleChunk(moduleId: ModuleId) {\n const moduleChunkPaths = moduleChunksMap.get(moduleId);\n if (moduleChunkPaths == null) {\n return null;\n }\n\n return moduleChunkPaths.values().next().value;\n}\n\n/**\n * Removes a module from a chunk.\n * Returns `true` if there are no remaining chunks including this module.\n */\nfunction removeModuleFromChunk(\n moduleId: ModuleId,\n chunkPath: ChunkPath\n): boolean {\n const moduleChunks = moduleChunksMap.get(moduleId)!;\n moduleChunks.delete(chunkPath);\n\n const chunkModules = chunkModulesMap.get(chunkPath)!;\n chunkModules.delete(moduleId);\n\n const noRemainingModules = chunkModules.size === 0;\n if (noRemainingModules) {\n chunkModulesMap.delete(chunkPath);\n }\n\n const noRemainingChunks = moduleChunks.size === 0;\n if (noRemainingChunks) {\n moduleChunksMap.delete(moduleId);\n }\n\n return noRemainingChunks;\n}\n\n/**\n * Disposes of a chunk list and its corresponding exclusive chunks.\n */\nfunction disposeChunkList(chunkListPath: ChunkPath): boolean {\n const chunkPaths = chunkListChunksMap.get(chunkListPath);\n if (chunkPaths == null) {\n return false;\n }\n chunkListChunksMap.delete(chunkListPath);\n\n for (const chunkPath of chunkPaths) {\n const chunkChunkLists = chunkChunkListsMap.get(chunkPath)!;\n chunkChunkLists.delete(chunkListPath);\n\n if (chunkChunkLists.size === 0) {\n chunkChunkListsMap.delete(chunkPath);\n disposeChunk(chunkPath);\n }\n }\n\n // We must also dispose of the chunk list's chunk itself to ensure it may\n // be reloaded properly in the future.\n BACKEND.unloadChunk?.(chunkListPath);\n\n return true;\n}\n\n/**\n * Disposes of a chunk and its corresponding exclusive modules.\n *\n * @returns Whether the chunk was disposed of.\n */\nfunction disposeChunk(chunkPath: ChunkPath): boolean {\n // This should happen whether the chunk has any modules in it or not.\n // For instance, CSS chunks have no modules in them, but they still need to be unloaded.\n BACKEND.unloadChunk?.(chunkPath);\n\n const chunkModules = chunkModulesMap.get(chunkPath);\n if (chunkModules == null) {\n return false;\n }\n chunkModules.delete(chunkPath);\n\n for (const moduleId of chunkModules) {\n const moduleChunks = moduleChunksMap.get(moduleId)!;\n moduleChunks.delete(chunkPath);\n\n const noRemainingChunks = moduleChunks.size === 0;\n if (noRemainingChunks) {\n moduleChunksMap.delete(moduleId);\n disposeModule(moduleId, \"clear\");\n availableModules.delete(moduleId);\n }\n }\n\n return true;\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 * Gets or instantiates a runtime module.\n */\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 instantiateModule(moduleId, { type: SourceType.Runtime, chunkPath });\n}\n\n/**\n * Returns the URL relative to the origin where a chunk can be fetched from.\n */\nfunction getChunkRelativeUrl(chunkPath: ChunkPath): string {\n return `${CHUNK_BASE_PATH}${chunkPath}`;\n}\n\n/**\n * Subscribes to chunk list updates from the update server and applies them.\n */\nfunction registerChunkList(\n chunkUpdateProvider: ChunkUpdateProvider,\n chunkList: ChunkList\n) {\n chunkUpdateProvider.push([\n chunkList.path,\n handleApply.bind(null, chunkList.path),\n ]);\n\n // Adding chunks to chunk lists and vice versa.\n const chunks = new Set(chunkList.chunks.map(getChunkPath));\n chunkListChunksMap.set(chunkList.path, chunks);\n for (const chunkPath of chunks) {\n let chunkChunkLists = chunkChunkListsMap.get(chunkPath);\n if (!chunkChunkLists) {\n chunkChunkLists = new Set([chunkList.path]);\n chunkChunkListsMap.set(chunkPath, chunkChunkLists);\n } else {\n chunkChunkLists.add(chunkList.path);\n }\n }\n\n if (chunkList.source === \"entry\") {\n markChunkListAsRuntime(chunkList.path);\n }\n}\n\n/**\n * Marks a chunk list as a runtime chunk list. There can be more than one\n * runtime chunk list. For instance, integration tests can have multiple chunk\n * groups loaded at runtime, each with its own chunk list.\n */\nfunction markChunkListAsRuntime(chunkListPath: ChunkPath) {\n runtimeChunkLists.add(chunkListPath);\n}\n\nfunction registerChunk([\n chunkPath,\n chunkModules,\n runtimeParams,\n]: ChunkRegistration) {\n for (const [moduleId, moduleFactory] of Object.entries(chunkModules)) {\n if (!moduleFactories[moduleId]) {\n moduleFactories[moduleId] = moduleFactory;\n }\n addModuleToChunk(moduleId, chunkPath);\n }\n\n return BACKEND.registerChunk(chunkPath, runtimeParams);\n}\n\nglobalThis.TURBOPACK_CHUNK_UPDATE_LISTENERS ??= [];\n\nconst chunkListsToRegister = globalThis.TURBOPACK_CHUNK_LISTS;\nif (Array.isArray(chunkListsToRegister)) {\n for (const chunkList of chunkListsToRegister) {\n registerChunkList(globalThis.TURBOPACK_CHUNK_UPDATE_LISTENERS, chunkList);\n }\n}\n\n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IAAI,EAAE;IACvC,KAAK,MAAM,aAAa,OAAQ;QAC9B,IAAI,kBAAkB,mBAAmB,GAAG,CAAC;QAC7C,IAAI,CAAC,iBAAiB;YACpB,kBAAkB,IAAI,IAAI;gBAAC,UAAU,IAAI;aAAC;YAC1C,mBAAmB,GAAG,CAAC,WAAW;QACpC,OAAO;YACL,gBAAgB,GAAG,CAAC,UAAU,IAAI;QACpC;IACF;IAEA,IAAI,UAAU,MAAM,KAAK,SAAS;QAChC,uBAAuB,UAAU,IAAI;IACvC;AACF;AAOA,SAAS,uBAAuB,aAAwB;IACtD,kBAAkB,GAAG,CAAC;AACxB;AAEA,SAAS,cAAc,CACrB,WACA,cACA,cACkB;IAClB,KAAK,MAAM,CAAC,UAAU,cAAc,IAAI,OAAO,OAAO,CAAC,cAAe;QACpE,IAAI,CAAC,eAAe,CAAC,SAAS,EAAE;YAC9B,eAAe,CAAC,SAAS,GAAG;QAC9B;QACA,iBAAiB,UAAU;IAC7B;IAEA,OAAO,QAAQ,aAAa,CAAC,WAAW;AAC1C;AAEA,WAAW,gCAAgC,KAAK,EAAE;AAElD,MAAM,uBAAuB,WAAW,qBAAqB;AAC7D,IAAI,MAAM,OAAO,CAAC,uBAAuB;IACvC,KAAK,MAAM,aAAa,qBAAsB;QAC5C,kBAAkB,WAAW,gCAAgC,EAAE;IACjE;AACF;AAEA,WAAW,qBAAqB,GAAG;IACjC,MAAM,CAAC;QACL,kBAAkB,WAAW,gCAAgC,EAAG;IAClE;AACF"}}, + {"offset": {"line": 1068, "column": 0}, "map": {"version":3,"sources":["/turbopack/[turbopack]/dev/runtime/dom/runtime-backend-dom.ts"],"sourcesContent":["/**\n * This file contains the runtime code specific to the Turbopack development\n * ECMAScript DOM runtime.\n *\n * It will be appended to the base development runtime code.\n */\n\n/// \n\ntype ChunkResolver = {\n resolved: boolean;\n resolve: () => void;\n reject: (error?: Error) => void;\n promise: Promise;\n};\n\nlet BACKEND: RuntimeBackend;\n\nfunction augmentContext(context: TurbopackDevBaseContext): TurbopackDevContext {\n return context;\n}\n\nfunction commonJsRequireContext(\n entry: RequireContextEntry,\n sourceModule: Module\n): Exports {\n return commonJsRequire(sourceModule, entry.id());\n}\n\n(() => {\n BACKEND = {\n async registerChunk(chunkPath, params) {\n const resolver = getOrCreateResolver(chunkPath);\n resolver.resolve();\n\n if (params == null) {\n return;\n }\n\n for (const otherChunkData of params.otherChunks) {\n const otherChunkPath = getChunkPath(otherChunkData);\n // Chunk might have started loading, so we want to avoid triggering another load.\n getOrCreateResolver(otherChunkPath);\n }\n\n // This waits for chunks to be loaded, but also marks included items as available.\n await Promise.all(\n params.otherChunks.map((otherChunkData) =>\n loadChunk({ type: SourceType.Runtime, chunkPath }, otherChunkData)\n )\n );\n\n if (params.runtimeModuleIds.length > 0) {\n for (const moduleId of params.runtimeModuleIds) {\n getOrInstantiateRuntimeModule(moduleId, chunkPath);\n }\n }\n },\n\n loadChunk(chunkPath, source) {\n return doLoadChunk(chunkPath, source);\n },\n\n unloadChunk(chunkPath) {\n deleteResolver(chunkPath);\n\n const chunkUrl = getChunkRelativeUrl(chunkPath);\n\n if (chunkPath.endsWith(\".css\")) {\n const links = document.querySelectorAll(`link[href=\"${chunkUrl}\"]`);\n for (const link of Array.from(links)) {\n link.remove();\n }\n } else if (chunkPath.endsWith(\".js\")) {\n // Unloading a JS chunk would have no effect, as it lives in the JS\n // runtime once evaluated.\n // However, we still want to remove the script tag from the DOM to keep\n // the HTML somewhat consistent from the user's perspective.\n const scripts = document.querySelectorAll(`script[src=\"${chunkUrl}\"]`);\n for (const script of Array.from(scripts)) {\n script.remove();\n }\n } else {\n throw new Error(`can't infer type of chunk from path ${chunkPath}`);\n }\n },\n\n reloadChunk(chunkPath) {\n return new Promise((resolve, reject) => {\n if (!chunkPath.endsWith(\".css\")) {\n reject(new Error(\"The DOM backend can only reload CSS chunks\"));\n return;\n }\n\n const encodedChunkPath = chunkPath\n .split(\"/\")\n .map((p) => encodeURIComponent(p))\n .join(\"/\");\n\n const chunkUrl = `/${getChunkRelativeUrl(encodedChunkPath)}`;\n\n const previousLink = document.querySelector(\n `link[rel=stylesheet][href^=\"${chunkUrl}\"]`\n );\n\n if (previousLink == null) {\n reject(new Error(`No link element found for chunk ${chunkPath}`));\n return;\n }\n\n const link = document.createElement(\"link\");\n link.rel = \"stylesheet\";\n link.href = chunkUrl;\n link.onerror = () => {\n reject();\n };\n link.onload = () => {\n // First load the new CSS, then remove the old one. This prevents visible\n // flickering that would happen in-between removing the previous CSS and\n // loading the new one.\n previousLink.remove();\n\n // CSS chunks do not register themselves, and as such must be marked as\n // loaded instantly.\n resolve();\n };\n\n // Make sure to insert the new CSS right after the previous one, so that\n // its precedence is higher.\n previousLink.parentElement!.insertBefore(\n link,\n previousLink.nextSibling\n );\n });\n },\n\n restart: () => self.location.reload(),\n };\n\n /**\n * Maps chunk paths to the corresponding resolver.\n */\n const chunkResolvers: Map = new Map();\n\n function getOrCreateResolver(chunkPath: ChunkPath): ChunkResolver {\n let resolver = chunkResolvers.get(chunkPath);\n if (!resolver) {\n let resolve: () => void;\n let reject: (error?: Error) => void;\n const promise = new Promise((innerResolve, innerReject) => {\n resolve = innerResolve;\n reject = innerReject;\n });\n resolver = {\n resolved: false,\n promise,\n resolve: () => {\n resolver!.resolved = true;\n resolve();\n },\n reject: reject!,\n };\n chunkResolvers.set(chunkPath, resolver);\n }\n return resolver;\n }\n\n function deleteResolver(chunkPath: ChunkPath) {\n chunkResolvers.delete(chunkPath);\n }\n\n /**\n * Loads the given chunk, and returns a promise that resolves once the chunk\n * has been loaded.\n */\n async function doLoadChunk(chunkPath: ChunkPath, source: SourceInfo) {\n const resolver = getOrCreateResolver(chunkPath);\n if (resolver.resolved) {\n return resolver.promise;\n }\n\n if (source.type === SourceType.Runtime) {\n // We don't need to load chunks references from runtime code, as they're already\n // present in the DOM.\n\n if (chunkPath.endsWith(\".css\")) {\n // CSS chunks do not register themselves, and as such must be marked as\n // loaded instantly.\n resolver.resolve();\n }\n\n // We need to wait for JS chunks to register themselves within `registerChunk`\n // before we can start instantiating runtime modules, hence the absence of\n // `resolver.resolve()` in this branch.\n\n return resolver.promise;\n }\n\n const chunkUrl = `/${getChunkRelativeUrl(chunkPath)}`;\n\n if (chunkPath.endsWith(\".css\")) {\n const link = document.createElement(\"link\");\n link.rel = \"stylesheet\";\n link.href = chunkUrl;\n link.onerror = () => {\n resolver.reject();\n };\n link.onload = () => {\n // CSS chunks do not register themselves, and as such must be marked as\n // loaded instantly.\n resolver.resolve();\n };\n document.body.appendChild(link);\n } else if (chunkPath.endsWith(\".js\")) {\n const script = document.createElement(\"script\");\n script.src = chunkUrl;\n // We'll only mark the chunk as loaded once the script has been executed,\n // which happens in `registerChunk`. Hence the absence of `resolve()` in\n // this branch.\n script.onerror = () => {\n resolver.reject();\n };\n document.body.appendChild(script);\n } else {\n throw new Error(`can't infer type of chunk from path ${chunkPath}`);\n }\n\n return resolver.promise;\n }\n})();\n\nfunction _eval({ code, url, map }: EcmascriptModuleEntry): ModuleFactory {\n code += `\\n\\n//# sourceURL=${location.origin}/${url}`;\n if (map) code += `\\n//# sourceMappingURL=${map}`;\n return eval(code);\n}\n"],"names":[],"mappings":"AAgBA,IAAI;AAEJ,SAAS,eAAe,QAAgC;IACtD,OAAO;AACT;AAEA,SAAS,uBACP,MAA0B,EAC1B,aAAoB;IAEpB,OAAO,gBAAgB,eAAc,OAAM,EAAE;AAC/C;AAEC,CAAA;IACC,UAAU;QACR,MAAM,eAAc,UAAS,EAAE,OAAM;YACnC,MAAM,YAAW,qBAAoB;YACrC,UAAS,OAAO;YAEhB,IAAI,WAAU,MAAM;gBAClB;YACF;YAEA,KAAK,MAAM,mBAAkB,QAAO,WAAW,CAAE;gBAC/C,MAAM,kBAAiB,aAAa;gBAEpC,qBAAoB;YACtB;YAGA,MAAM,QAAQ,GAAG,CACf,QAAO,WAAW,CAAC,GAAG,CAAC,CAAC,kBACtB,UAAU;oBAAE,MAAM,WAAW,OAAO;oBAAE,WAAA;gBA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AO;YAClB;YACA,SAAS,IAAI,CAAC,WAAW,CAAC;QAC5B,OAAO,IAAI,WAAU,QAAQ,CAAC,QAAQ;YACpC,MAAM,UAAS,SAAS,aAAa,CAAC;YACtC,QAAO,GAAG,GAAG;YAIb,QAAO,OAAO,GAAG;gBACf,UAAS,MAAM;YACjB;YACA,SAAS,IAAI,CAAC,WAAW,CAAC;QAC5B,OAAO;YACL,MAAM,IAAI,MAAM,CAAC,oCAAoC,EAAE,WAAU,CAAC;QACpE;QAEA,OAAO,UAAS,OAAO;IACzB;AACF,CAAA;AAEA,SAAS,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAyB;IACtD,QAAQ,CAAC,kBAAkB,EAAE,SAAS,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC;IACrD,IAAI,KAAK,QAAQ,CAAC,uBAAuB,EAAE,IAAI,CAAC;IAChD,OAAO,KAAK;AACd"}}, + {"offset": {"line": 1212, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}] } \ No newline at end of file From a73b9d1637d0dd62cfe769274a23b6ec625aac0f Mon Sep 17 00:00:00 2001 From: hrmny Date: Tue, 18 Jul 2023 15:42:49 +0200 Subject: [PATCH 11/16] rebase fixes --- Cargo.lock | 1 + crates/turbo-tasks/src/primitives.rs | 5 +- .../turbopack-build/src/chunking_context.rs | 4 +- .../src/build_runtime.rs | 6 +- .../src/dev_runtime.rs | 12 +- .../src/embed_js.rs | 2 +- .../src/chunk/placeable.rs | 2 +- crates/turbopack-ecmascript/src/lib.rs | 12 +- .../src/references/async_module.rs | 130 +++++++++--------- .../src/references/esm/base.rs | 6 +- .../src/references/mod.rs | 20 +-- .../src/tree_shake/chunk_item.rs | 5 +- crates/turbopack-test-utils/Cargo.toml | 1 + crates/turbopack-test-utils/src/snapshot.rs | 12 +- crates/turbopack-tests/tests/execution.rs | 11 +- ...rror resolving commonjs request-ee63e3.txt | 48 +++---- ... source code for parsing failed-3b6255.txt | 2 +- ...rmat (CommonJs) is not matching-5fdb68.txt | 2 +- ...rmat (EcmaScript Modules) is no-34c311.txt | 2 +- crates/turbopack-tests/tests/snapshot.rs | 8 +- .../unexpected export __star__-c9d8a6.txt | 2 +- .../unexpected export __star__-38cf67.txt | 2 +- ...neration for chunk item errored-5567c6.txt | 32 +++-- ...rror resolving commonjs request-b97684.txt | 44 +++--- ...ving EcmaScript Modules request-aff400.txt | 2 +- 25 files changed, 181 insertions(+), 192 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6fa77172850dc..5e8de8d3b3f73 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9520,6 +9520,7 @@ version = "0.1.0" dependencies = [ "anyhow", "once_cell", + "regex", "serde", "similar", "turbo-tasks", diff --git a/crates/turbo-tasks/src/primitives.rs b/crates/turbo-tasks/src/primitives.rs index 94b12f78b8517..209f4bae6d00b 100644 --- a/crates/turbo-tasks/src/primitives.rs +++ b/crates/turbo-tasks/src/primitives.rs @@ -1,12 +1,13 @@ use std::{future::IntoFuture, ops::Deref}; +use anyhow::Result; use auto_hash_map::AutoSet; use futures::TryFutureExt; // This specific macro identifier is detected by turbo-tasks-build. use turbo_tasks_macros::primitive as __turbo_tasks_internal_primitive; use crate::{ - RawVc, Vc, {self as turbo_tasks}, TryJoinIterExt, + RawVc, TryJoinIterExt, Vc, {self as turbo_tasks}, }; __turbo_tasks_internal_primitive!(()); @@ -84,7 +85,7 @@ pub struct Bools(Vec>); impl Bools { #[turbo_tasks::function] pub fn empty() -> Vc { - Self::cell(Vec::new()) + Vc::cell(Vec::new()) } #[turbo_tasks::function] diff --git a/crates/turbopack-build/src/chunking_context.rs b/crates/turbopack-build/src/chunking_context.rs index 7e3c6fb8bbe2e..ca18e1e1fd5b0 100644 --- a/crates/turbopack-build/src/chunking_context.rs +++ b/crates/turbopack-build/src/chunking_context.rs @@ -360,8 +360,8 @@ where let chunks = ecmascript_chunks .iter() .copied() - .map(|chunk| Vc::upcast(chunk)) - .chain(css_chunks.iter().copied().map(|chunk| Vc::upcast(chunk))) + .map(Vc::upcast) + .chain(css_chunks.iter().copied().map(Vc::upcast)) .chain(other_chunks) .collect(); diff --git a/crates/turbopack-ecmascript-runtime/src/build_runtime.rs b/crates/turbopack-ecmascript-runtime/src/build_runtime.rs index da24c42344500..1eb9e06e43905 100644 --- a/crates/turbopack-ecmascript-runtime/src/build_runtime.rs +++ b/crates/turbopack-ecmascript-runtime/src/build_runtime.rs @@ -12,9 +12,9 @@ use crate::{asset_context::get_runtime_asset_context, embed_js::embed_static_cod pub async fn get_build_runtime_code(environment: Vc) -> Result> { let asset_context = get_runtime_asset_context(environment); - let shared_runtime_utils_code = embed_static_code(asset_context, "shared/runtime-utils.ts"); - let shared_node_utils_code = embed_static_code(asset_context, "shared-node/require.ts"); - let runtime_code = embed_static_code(asset_context, "build/runtime.ts"); + let shared_runtime_utils_code = embed_static_code(asset_context, "shared/runtime-utils.ts".to_string()); + let shared_node_utils_code = embed_static_code(asset_context, "shared-node/require.ts".to_string()); + let runtime_code = embed_static_code(asset_context, "build/runtime.ts".to_string()); let mut code = CodeBuilder::default(); code.push_code(&*shared_runtime_utils_code.await?); diff --git a/crates/turbopack-ecmascript-runtime/src/dev_runtime.rs b/crates/turbopack-ecmascript-runtime/src/dev_runtime.rs index 80fcf8bcdfa8a..9ab9831409de0 100644 --- a/crates/turbopack-ecmascript-runtime/src/dev_runtime.rs +++ b/crates/turbopack-ecmascript-runtime/src/dev_runtime.rs @@ -20,8 +20,8 @@ pub async fn get_dev_runtime_code( ) -> Result> { let asset_context = get_runtime_asset_context(environment); - let shared_runtime_utils_code = embed_static_code(asset_context, "shared/runtime-utils.ts"); - let runtime_base_code = embed_static_code(asset_context, "dev/runtime/base/runtime-base.ts"); + let shared_runtime_utils_code = embed_static_code(asset_context, "shared/runtime-utils.ts".to_string()); + let runtime_base_code = embed_static_code(asset_context, "dev/runtime/base/runtime-base.ts".to_string()); let chunk_loading = &*asset_context .compile_time_info() @@ -32,9 +32,9 @@ pub async fn get_dev_runtime_code( let runtime_backend_code = embed_static_code( asset_context, match chunk_loading { - ChunkLoading::None => "dev/runtime/none/runtime-backend-none.ts", - ChunkLoading::NodeJs => "dev/runtime/nodejs/runtime-backend-nodejs.ts", - ChunkLoading::Dom => "dev/runtime/dom/runtime-backend-dom.ts", + ChunkLoading::None => "dev/runtime/none/runtime-backend-none.ts".to_string(), + ChunkLoading::NodeJs => "dev/runtime/nodejs/runtime-backend-nodejs.ts".to_string(), + ChunkLoading::Dom => "dev/runtime/dom/runtime-backend-dom.ts".to_string(), }, ); @@ -61,7 +61,7 @@ pub async fn get_dev_runtime_code( code.push_code(&*runtime_base_code.await?); if matches!(chunk_loading, ChunkLoading::NodeJs) { - code.push_code(&*embed_static_code(asset_context, "shared-node/require.ts").await?); + code.push_code(&*embed_static_code(asset_context, "shared-node/require.ts".to_string()).await?); } code.push_code(&*runtime_backend_code.await?); diff --git a/crates/turbopack-ecmascript-runtime/src/embed_js.rs b/crates/turbopack-ecmascript-runtime/src/embed_js.rs index baa95d47ed7b3..bd503baa98ba0 100644 --- a/crates/turbopack-ecmascript-runtime/src/embed_js.rs +++ b/crates/turbopack-ecmascript-runtime/src/embed_js.rs @@ -19,6 +19,6 @@ pub fn embed_file_path(path: String) -> Vc { } #[turbo_tasks::function] -pub fn embed_static_code(asset_context: Vc, path: &str) -> Vc { +pub fn embed_static_code(asset_context: Vc>, path: String) -> Vc { StaticEcmascriptCode::new(asset_context, embed_file_path(path)).code() } diff --git a/crates/turbopack-ecmascript/src/chunk/placeable.rs b/crates/turbopack-ecmascript/src/chunk/placeable.rs index cf285bc984eb0..55cad139c19b3 100644 --- a/crates/turbopack-ecmascript/src/chunk/placeable.rs +++ b/crates/turbopack-ecmascript/src/chunk/placeable.rs @@ -11,7 +11,7 @@ pub trait EcmascriptChunkPlaceable: ChunkableModule + Module + Asset { context: Vc>, ) -> Vc>; fn get_exports(self: Vc) -> Vc; - fn get_async_module_options(&self) -> Vc { + fn get_async_module(self: Vc) -> Vc { Vc::cell(None) } } diff --git a/crates/turbopack-ecmascript/src/lib.rs b/crates/turbopack-ecmascript/src/lib.rs index d729fbcc3bcd5..302b46c0fb852 100644 --- a/crates/turbopack-ecmascript/src/lib.rs +++ b/crates/turbopack-ecmascript/src/lib.rs @@ -73,10 +73,8 @@ use self::{ tree_shake::asset::EcmascriptModulePartAsset, }; use crate::{ - chunk::EcmascriptChunkPlaceable, references::{ - analyze_ecmascript_module, - async_module::{OptionAsyncModuleOptions}, - }, + chunk::EcmascriptChunkPlaceable, + references::{analyze_ecmascript_module, async_module::OptionAsyncModule}, transform::remove_shebang, }; @@ -124,7 +122,7 @@ struct MemoizedSuccessfulAnalysis { operation: RawVc, references: ReadRef, exports: ReadRef, - async_module_options: ReadRef, + async_module: ReadRef, } pub struct EcmascriptModuleAssetBuilder { @@ -438,8 +436,8 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleAsset { } #[turbo_tasks::function] - async fn get_async_module(self_vc: EcmascriptModuleAssetVc) -> Result { - Ok(self_vc.failsafe_analyze().await?.async_module) + async fn get_async_module(self: Vc) -> Result> { + Ok(self.failsafe_analyze().await?.async_module) } } diff --git a/crates/turbopack-ecmascript/src/references/async_module.rs b/crates/turbopack-ecmascript/src/references/async_module.rs index 4ac2829e339c1..5bfe7d75ca0c5 100644 --- a/crates/turbopack-ecmascript/src/references/async_module.rs +++ b/crates/turbopack-ecmascript/src/references/async_module.rs @@ -6,22 +6,18 @@ use swc_core::{ ecma::ast::{ArrayLit, ArrayPat, Expr, Ident, Pat, Program}, quote, }; -use turbo_tasks::{ - primitives::{BoolVc, BoolVcsVc}, - trace::TraceRawVcs, - TryFlatJoinIterExt, Value, -}; +use turbo_tasks::{primitives::Bools, trace::TraceRawVcs, TryFlatJoinIterExt, Value, Vc}; use turbopack_core::chunk::availability_info::AvailabilityInfo; use crate::{ chunk::{ - esm_scope::{EsmScopeSccVc, EsmScopeVc}, - EcmascriptChunkPlaceable, EcmascriptChunkPlaceableVc, EcmascriptChunkingContextVc, + esm_scope::{EsmScope, EsmScopeScc}, + EcmascriptChunkPlaceable, EcmascriptChunkingContext, }, - code_gen::{CodeGenerateableWithAvailabilityInfo, CodeGeneration, CodeGenerationVc}, + code_gen::{CodeGenerateableWithAvailabilityInfo, CodeGeneration}, create_visitor, - references::esm::{base::insert_hoisted_stmt, EsmAssetReferenceVc}, - CodeGenerateableWithAvailabilityInfoVc, EcmascriptModuleAssetVc, + references::esm::{base::insert_hoisted_stmt, EsmAssetReference}, + EcmascriptModuleAsset, }; #[derive(PartialEq, Eq, Default, Debug, Clone, Serialize, Deserialize, TraceRawVcs)] @@ -33,88 +29,90 @@ pub struct AsyncModuleOptions { pub struct OptionAsyncModuleOptions(Option); #[turbo_tasks::value_impl] -impl OptionAsyncModuleOptionsVc { +impl OptionAsyncModuleOptions { #[turbo_tasks::function] - pub(crate) fn none() -> Self { - Self::cell(None) + pub(crate) fn none() -> Vc { + Vc::cell(None) } #[turbo_tasks::function] - pub(crate) async fn is_async(self) -> Result { - Ok(BoolVc::cell(self.await?.is_some())) + pub(crate) async fn is_async(self: Vc) -> Result> { + Ok(Vc::cell(self.await?.is_some())) } } #[turbo_tasks::value(shared)] pub struct AsyncModule { - pub(super) module: EcmascriptModuleAssetVc, - pub(super) references: IndexSet, + pub(super) module: Vc, + pub(super) references: IndexSet>, pub(super) has_top_level_await: bool, } #[turbo_tasks::value(transparent)] -pub struct AsyncModules(IndexSet); +pub struct AsyncModules(IndexSet>); #[turbo_tasks::value(transparent)] -pub struct OptionAsyncModule(Option); +pub struct OptionAsyncModule(Option>); #[turbo_tasks::value_impl] -impl OptionAsyncModuleVc { +impl OptionAsyncModule { #[turbo_tasks::function] - pub(crate) fn none() -> Self { - Self::cell(None) + pub(crate) fn none() -> Vc { + Vc::cell(None) } #[turbo_tasks::function] pub(crate) async fn is_async( - self, + self: Vc, availability_info: Value, - ) -> Result { - Ok(BoolVc::cell( + ) -> Result> { + Ok(Vc::cell( self.module_options(availability_info).await?.is_some(), )) } #[turbo_tasks::function] pub(crate) async fn module_options( - self, + self: Vc, availability_info: Value, - ) -> Result { + ) -> Result> { if let Some(async_module) = &*self.await? { return Ok(async_module.module_options(availability_info)); } - Ok(OptionAsyncModuleOptionsVc::none()) + Ok(OptionAsyncModuleOptions::none()) } } #[turbo_tasks::value] pub struct AsyncModuleScc { - scc: EsmScopeSccVc, - scope: EsmScopeVc, + scc: Vc, + scope: Vc, } #[turbo_tasks::value(transparent)] -pub struct OptionAsyncModuleScc(Option); +pub struct OptionAsyncModuleScc(Option>); #[turbo_tasks::function] -async fn is_placeable_self_async(placeable: EcmascriptChunkPlaceableVc) -> Result { +async fn is_placeable_self_async( + placeable: Vc>, +) -> Result> { let Some(async_module) = &*placeable.get_async_module().await? else { - return Ok(BoolVc::cell(false)); + return Ok(Vc::cell(false)); }; Ok(async_module.is_self_async()) } #[turbo_tasks::value_impl] -impl AsyncModuleSccVc { +impl AsyncModuleScc { #[turbo_tasks::function] - fn new(scc: EsmScopeSccVc, scope: EsmScopeVc) -> Self { - Self::cell(AsyncModuleScc { scc, scope }) + fn new(scc: Vc, scope: Vc) -> Vc { + AsyncModuleScc { scc, scope }.cell() } #[turbo_tasks::function] - pub(crate) async fn is_async(self) -> Result { + pub(crate) async fn is_async(self: Vc) -> Result> { let this = self.await?; let mut bools = Vec::new(); @@ -126,10 +124,10 @@ impl AsyncModuleSccVc { for scc in &*this.scope.get_scc_children(this.scc).await? { // Because we generated SCCs there can be no loops in the children, so calling // recursively is fine. - bools.push(AsyncModuleSccVc::new(*scc, this.scope).is_async()); + bools.push(AsyncModuleScc::new(*scc, this.scope).is_async()); } - Ok(BoolVcsVc::cell(bools).any()) + Ok(Vc::::cell(bools).any()) } } @@ -137,12 +135,12 @@ impl AsyncModuleSccVc { pub struct AsyncModuleIdents(IndexSet); #[turbo_tasks::value_impl] -impl AsyncModuleVc { +impl AsyncModule { #[turbo_tasks::function] pub(crate) async fn get_async_idents( - self, + self: Vc, availability_info: Value, - ) -> Result { + ) -> Result> { let this = self.await?; let reference_idents = this @@ -160,25 +158,23 @@ impl AsyncModuleVc { .try_flat_join() .await?; - Ok(AsyncModuleIdentsVc::cell(IndexSet::from_iter( - reference_idents, - ))) + Ok(Vc::cell(IndexSet::from_iter(reference_idents))) } #[turbo_tasks::function] - pub(crate) async fn has_top_level_await(self) -> Result { - Ok(BoolVc::cell(self.await?.has_top_level_await)) + pub(crate) async fn has_top_level_await(self: Vc) -> Result> { + Ok(Vc::cell(self.await?.has_top_level_await)) } #[turbo_tasks::function] - pub(crate) async fn is_self_async(self) -> Result { + pub(crate) async fn is_self_async(self: Vc) -> Result> { let this = self.await?; if this.has_top_level_await { - return Ok(BoolVc::cell(true)); + return Ok(Vc::cell(true)); } - let bools = BoolVcsVc::cell( + let bools = Vc::::cell( this.references .iter() .map(|r| r.is_external_esm()) @@ -190,30 +186,30 @@ impl AsyncModuleVc { #[turbo_tasks::function] async fn get_scc( - self, + self: Vc, availability_info: Value, - ) -> Result { + ) -> Result> { let this = self.await?; - let scope = EsmScopeVc::new(availability_info); + let scope = EsmScope::new(availability_info); let Some(scc) = &*scope - .get_scc(this.module.as_ecmascript_chunk_placeable()) + .get_scc(Vc::upcast(this.module)) .await? else { // I'm not sure if this should be possible. - return Ok(OptionAsyncModuleSccVc::cell(None)); + return Ok(Vc::cell(None)); }; - let scc = AsyncModuleSccVc::new(*scc, scope); + let scc = AsyncModuleScc::new(*scc, scope); - Ok(OptionAsyncModuleSccVc::cell(Some(scc))) + Ok(Vc::cell(Some(scc))) } #[turbo_tasks::function] pub(crate) async fn is_async( - self, + self: Vc, availability_info: Value, - ) -> Result { + ) -> Result> { Ok( if let Some(scc) = &*self.get_scc(availability_info).await? { scc.is_async() @@ -225,14 +221,14 @@ impl AsyncModuleVc { #[turbo_tasks::function] pub(crate) async fn module_options( - self, + self: Vc, availability_info: Value, - ) -> Result { + ) -> Result> { if !*self.is_async(availability_info).await? { - return Ok(OptionAsyncModuleOptionsVc::cell(None)); + return Ok(Vc::cell(None)); } - Ok(OptionAsyncModuleOptionsVc::cell(Some(AsyncModuleOptions { + Ok(Vc::cell(Some(AsyncModuleOptions { has_top_level_await: self.await?.has_top_level_await, }))) } @@ -242,13 +238,13 @@ impl AsyncModuleVc { impl CodeGenerateableWithAvailabilityInfo for AsyncModule { #[turbo_tasks::function] async fn code_generation( - self_vc: AsyncModuleVc, - _context: EcmascriptChunkingContextVc, + self: Vc, + _context: Vc>, availability_info: Value, - ) -> Result { + ) -> Result> { let mut visitors = Vec::new(); - let async_idents = self_vc.get_async_idents(availability_info).await?; + let async_idents = self.get_async_idents(availability_info).await?; if !async_idents.is_empty() { visitors.push(create_visitor!(visit_mut_program(program: &mut Program) { diff --git a/crates/turbopack-ecmascript/src/references/esm/base.rs b/crates/turbopack-ecmascript/src/references/esm/base.rs index 43c99f85a6484..bea3399206cf6 100644 --- a/crates/turbopack-ecmascript/src/references/esm/base.rs +++ b/crates/turbopack-ecmascript/src/references/esm/base.rs @@ -142,14 +142,14 @@ impl EsmAssetReference { pub(crate) async fn get_referenced_asset(self: Vc) -> Result> { let this = self.await?; - Ok(ReferencedAssetVc::from_resolve_result( + Ok(ReferencedAsset::from_resolve_result( self.resolve_reference(), this.request, )) } #[turbo_tasks::function] - pub(crate) async fn is_external_esm(self) -> Result> { + pub(crate) async fn is_external_esm(self: Vc) -> Result> { let asset = self.get_referenced_asset().await?; let ReferencedAsset::OriginalReferenceTypeExternal(_) = &*asset else { @@ -162,7 +162,7 @@ impl EsmAssetReference { #[turbo_tasks::function] pub(crate) async fn is_async( - self, + self: Vc, availability_info: Value, ) -> Result> { if *self.is_external_esm().await? { diff --git a/crates/turbopack-ecmascript/src/references/mod.rs b/crates/turbopack-ecmascript/src/references/mod.rs index 8bfa67f76bbc2..878a0b6f676cc 100644 --- a/crates/turbopack-ecmascript/src/references/mod.rs +++ b/crates/turbopack-ecmascript/src/references/mod.rs @@ -64,6 +64,7 @@ use turbopack_core::{ }, source::{asset_to_source, Source}, }; +use turbopack_core::issue::IssueSeverity; use turbopack_swc_utils::emitter::IssueEmitter; use unreachable::Unreachable; @@ -132,7 +133,7 @@ pub struct AnalyzeEcmascriptModuleResult { pub references: Vc, pub code_generation: Vc, pub exports: Vc, - pub async_module_options: Vc, + pub async_module: Vc, /// `true` when the analysis was successful. pub successful: bool, } @@ -169,7 +170,7 @@ pub(crate) struct AnalyzeEcmascriptModuleResultBuilder { references: IndexSet>>, code_gens: Vec, exports: EcmascriptExports, - async_module_options: Vc, + async_module: Vc, successful: bool, } @@ -179,7 +180,7 @@ impl AnalyzeEcmascriptModuleResultBuilder { references: IndexSet::new(), code_gens: Vec::new(), exports: EcmascriptExports::None, - async_module_options: Vc::cell(None), + async_module: Vc::cell(None), successful: false, } } @@ -219,8 +220,8 @@ impl AnalyzeEcmascriptModuleResultBuilder { } /// Sets the analysis result ES export. - pub fn set_async_module(&mut self, async_module: AsyncModuleVc) { - self.async_module = OptionAsyncModuleVc::cell(Some(async_module)); + pub fn set_async_module(&mut self, async_module: Vc) { + self.async_module = Vc::cell(Some(async_module)); } /// Sets whether the analysis was successful. @@ -328,7 +329,7 @@ pub(crate) async fn analyze_ecmascript_module( let options = raw_module.options; let compile_time_info = raw_module.compile_time_info; - let origin = module.as_resolve_origin(); + let origin = Vc::upcast::>(module); let mut analysis = AnalyzeEcmascriptModuleResultBuilder::new(); let path = origin.origin_path(); @@ -668,17 +669,16 @@ pub(crate) async fn analyze_ecmascript_module( if !matches!(exports, EcmascriptExports::EsmExports(_)) { AnalyzeIssue { code: None, - category: StringVc::cell("analyze".to_string()), - message: StringVc::cell( + category: Vc::cell("analyze".to_string()), + message: Vc::cell( "top level await is only supported in ESM modules.".to_string(), ), source_ident: source.ident(), severity: IssueSeverity::Error.into(), source: Some(issue_source(source, span)), - title: StringVc::cell("unexpected top level await".to_string()), + title: Vc::cell("unexpected top level await".to_string()), } .cell() - .as_issue() .emit(); } } diff --git a/crates/turbopack-ecmascript/src/tree_shake/chunk_item.rs b/crates/turbopack-ecmascript/src/tree_shake/chunk_item.rs index b4b98a710e699..cae9654576659 100644 --- a/crates/turbopack-ecmascript/src/tree_shake/chunk_item.rs +++ b/crates/turbopack-ecmascript/src/tree_shake/chunk_item.rs @@ -9,7 +9,10 @@ use turbopack_core::{ use super::{asset::EcmascriptModulePartAsset, part_of_module, split_module}; use crate::{ - chunk::{EcmascriptChunkItem, EcmascriptChunkItemContent, EcmascriptChunkingContext}, + chunk::{ + placeable::EcmascriptChunkPlaceable, EcmascriptChunkItem, EcmascriptChunkItemContent, + EcmascriptChunkingContext, + }, EcmascriptModuleContent, }; diff --git a/crates/turbopack-test-utils/Cargo.toml b/crates/turbopack-test-utils/Cargo.toml index 8dd75d5e01d08..21ceac46f645e 100644 --- a/crates/turbopack-test-utils/Cargo.toml +++ b/crates/turbopack-test-utils/Cargo.toml @@ -12,6 +12,7 @@ bench = false [dependencies] anyhow = { workspace = true } once_cell = { workspace = true } +regex = { workspace = true, features = ["pattern"] } serde = { workspace = true } similar = "2.2.0" turbo-tasks = { workspace = true } diff --git a/crates/turbopack-test-utils/src/snapshot.rs b/crates/turbopack-test-utils/src/snapshot.rs index 60ae0db10579f..b495ede2eddf1 100644 --- a/crates/turbopack-test-utils/src/snapshot.rs +++ b/crates/turbopack-test-utils/src/snapshot.rs @@ -7,15 +7,16 @@ use std::{ use anyhow::{anyhow, bail, Context, Result}; use once_cell::sync::Lazy; use similar::TextDiff; -use turbo_tasks::{debug::ValueDebugString, ReadRef, TryJoinIterExt, ValueToString, Vc}; +use turbo_tasks::{ReadRef, TryJoinIterExt, ValueToString, Vc}; use turbo_tasks_fs::{ DirectoryContent, DirectoryEntry, DiskFileSystem, File, FileContent, FileSystemEntryType, FileSystemPath, }; +use regex::Regex; use turbo_tasks_hash::encode_hex; use turbopack_cli_utils::issue::{format_issue, LogOptions}; use turbopack_core::{ - asset::{AssetContent}, + asset::AssetContent, issue::{IssueSeverity, PlainIssue}, }; @@ -23,7 +24,9 @@ use turbopack_core::{ // e.g. `UPDATE=1 cargo test -p turbopack-tests -- test_my_pattern` static UPDATE: Lazy = Lazy::new(|| env::var("UPDATE").unwrap_or_default() == "1"); -pub async fn snapshot_issues>>( +static ANSI_REGEX: Lazy = Lazy::new(|| Regex::new(r"\x1b\[\d+m").unwrap()); + +pub async fn snapshot_issues>>( captured_issues: I, issues_path: Vc, workspace_root: &str, @@ -31,8 +34,6 @@ pub async fn snapshot_issues>>( let expected_issues = expected(issues_path).await?; let mut seen = HashSet::new(); for plain_issue in captured_issues.into_iter() { - let plain_issue = plain_issue.await?; - let title = plain_issue .title .replace('/', "__") @@ -71,6 +72,7 @@ pub async fn snapshot_issues>>( let content = formatted .as_str() .replace(workspace_root, "WORKSPACE_ROOT") + .replace(&*ANSI_REGEX, "") // Normalize syspaths from Windows. These appear in stack traces. .replace("\\\\", "/"); diff --git a/crates/turbopack-tests/tests/execution.rs b/crates/turbopack-tests/tests/execution.rs index 7df11f950d30f..b4d4077ef76ab 100644 --- a/crates/turbopack-tests/tests/execution.rs +++ b/crates/turbopack-tests/tests/execution.rs @@ -10,7 +10,7 @@ use std::{ }; use anyhow::{Context, Result}; -use turbo_tasks::{debug::ValueDebug, unit, Completion, TryJoinIterExt, TurboTasks, Value, Vc}; +use turbo_tasks::{unit, Completion, TryJoinIterExt, TurboTasks, Value, Vc}; use turbo_tasks_bytes::stream::SingleValue; use turbo_tasks_env::CommandLineProcessEnv; use turbo_tasks_fs::{ @@ -274,13 +274,14 @@ async fn run_test(resource: String) -> Result> { let SingleValue::Single(bytes) = single else { return Ok(RunTestResult { - js_result: JsResultVc::cell(JsResult { + js_result: JsResult { uncaught_exceptions: vec![], unhandled_rejections: vec![], jest_result: JestRunResult { test_results: vec![], }, - }), + } + .cell(), path, } .cell()); @@ -305,7 +306,9 @@ async fn snapshot_issues(run_result: Vc) -> Result> { let plain_issues = captured_issues .iter_with_shortest_path() - .map(|(issue_vc, path)| issue_vc.into_plain(path)); + .map(|(issue_vc, path)| async move { issue_vc.into_plain(path).await }) + .try_join() + .await?; turbopack_test_utils::snapshot::snapshot_issues( plain_issues, diff --git a/crates/turbopack-tests/tests/execution/turbopack/basic/comptime/issues/Error resolving commonjs request-ee63e3.txt b/crates/turbopack-tests/tests/execution/turbopack/basic/comptime/issues/Error resolving commonjs request-ee63e3.txt index aa7d4526b8dc7..ce51578bb4a5e 100644 --- a/crates/turbopack-tests/tests/execution/turbopack/basic/comptime/issues/Error resolving commonjs request-ee63e3.txt +++ b/crates/turbopack-tests/tests/execution/turbopack/basic/comptime/issues/Error resolving commonjs request-ee63e3.txt @@ -1,28 +1,20 @@ -PlainIssue { - severity: Error, - context: "[project]/crates/turbopack-tests/tests/execution/turbopack/basic/comptime/input/index.js", - category: "resolve", - title: "Error resolving commonjs request", - description: "unable to resolve relative \"./not-existing-file\"", - detail: "It was not possible to find the requested file.\nParsed request as written in source code: relative \"./not-existing-file\"\nPath where resolving has started: [project]/crates/turbopack-tests/tests/execution/turbopack/basic/comptime/input/index.js\nType of request: commonjs request\nImport map: No import map entry\n", - documentation_link: "", - source: Some( - PlainIssueSource { - asset: PlainSource { - ident: "[project]/crates/turbopack-tests/tests/execution/turbopack/basic/comptime/input/index.js", - }, - start: SourcePos { - line: 3, - column: 5, - }, - end: SourcePos { - line: 3, - column: 35, - }, - }, - ), - sub_issues: [], - processing_path: Some( - [], - ), -} \ No newline at end of file +error - [resolve] [project]/crates/turbopack-tests/tests/execution/turbopack/basic/comptime/input/index.js /crates/turbopack-tests/tests/execution/turbopack/basic/comptime/input/index.js:4:5 Error resolving commonjs request + 1 | it("importing a not existing file should throw", () => { + 2 | // This is a check to make sure that the following tests would fail if they require("fail") + 3 | expect(() => { + + v----------------------------v + 4 + require("./not-existing-file"); + + ^----------------------------^ + 5 | }).toThrow(); + 6 | }); + 7 | + 8 | function maybeReturn(x) { + + unable to resolve relative "./not-existing-file" + + | It was not possible to find the requested file. + | Parsed request as written in source code: relative "./not-existing-file" + | Path where resolving has started: [project]/crates/turbopack-tests/tests/execution/turbopack/basic/comptime/input/index.js + | Type of request: commonjs request + | Import map: No import map entry + | \ No newline at end of file diff --git a/crates/turbopack-tests/tests/execution/turbopack/basic/error/issues/Reading source code for parsing failed-3b6255.txt b/crates/turbopack-tests/tests/execution/turbopack/basic/error/issues/Reading source code for parsing failed-3b6255.txt index 1f6f066719fa6..bf599e10d8e6e 100644 --- a/crates/turbopack-tests/tests/execution/turbopack/basic/error/issues/Reading source code for parsing failed-3b6255.txt +++ b/crates/turbopack-tests/tests/execution/turbopack/basic/error/issues/Reading source code for parsing failed-3b6255.txt @@ -1,4 +1,4 @@ -error - [parse] [project]/crates/turbopack-tests/tests/execution/turbopack/basic/error/input/broken.js Reading source code for parsing failed +error - [parse] [project]/crates/turbopack-tests/tests/execution/turbopack/basic/error/input/broken.js Reading source code for parsing failed An unexpected error happened while trying to read the source code to parse: failed to convert rope into string Caused by: diff --git a/crates/turbopack-tests/tests/execution/turbopack/basic/node-default-import/issues/Specified module format (CommonJs) is not matching-5fdb68.txt b/crates/turbopack-tests/tests/execution/turbopack/basic/node-default-import/issues/Specified module format (CommonJs) is not matching-5fdb68.txt index 27a58929de2c3..0d8e9548d3358 100644 --- a/crates/turbopack-tests/tests/execution/turbopack/basic/node-default-import/issues/Specified module format (CommonJs) is not matching-5fdb68.txt +++ b/crates/turbopack-tests/tests/execution/turbopack/basic/node-default-import/issues/Specified module format (CommonJs) is not matching-5fdb68.txt @@ -1,4 +1,4 @@ -error - [module type] [project]/crates/turbopack-tests/tests/execution/turbopack/basic/node-default-import/input/node_modules/esm-package/invalid-exports.cjs Specified module format (CommonJs) is not matching the module format of the source code (EcmaScript Modules) +error - [module type] [project]/crates/turbopack-tests/tests/execution/turbopack/basic/node-default-import/input/node_modules/esm-package/invalid-exports.cjs Specified module format (CommonJs) is not matching the module format of the source code (EcmaScript Modules) The CommonJs module format was specified in the package.json that is affecting this source file or by using an special extension, but Ecmascript import/export syntax is used in the source code. The module was automatically converted to an EcmaScript module, but that is in conflict with the specified module format. Either change the "type" field in the package.json or replace EcmaScript import/export syntax with CommonJs syntas in the source file. In some cases EcmaScript import/export syntax is added by an transform and isn't actually part of the source code. In these cases revisit transformation options to inject the correct syntax. \ No newline at end of file diff --git a/crates/turbopack-tests/tests/execution/turbopack/basic/node-default-import/issues/Specified module format (EcmaScript Modules) is no-34c311.txt b/crates/turbopack-tests/tests/execution/turbopack/basic/node-default-import/issues/Specified module format (EcmaScript Modules) is no-34c311.txt index 8b90743b769f3..8ab52b5ba3073 100644 --- a/crates/turbopack-tests/tests/execution/turbopack/basic/node-default-import/issues/Specified module format (EcmaScript Modules) is no-34c311.txt +++ b/crates/turbopack-tests/tests/execution/turbopack/basic/node-default-import/issues/Specified module format (EcmaScript Modules) is no-34c311.txt @@ -1,3 +1,3 @@ -warning - [module type] [project]/crates/turbopack-tests/tests/execution/turbopack/basic/node-default-import/input/node_modules/esm-package/invalid-exports.js Specified module format (EcmaScript Modules) is not matching the module format of the source code (CommonJs) +warning - [module type] [project]/crates/turbopack-tests/tests/execution/turbopack/basic/node-default-import/input/node_modules/esm-package/invalid-exports.js Specified module format (EcmaScript Modules) is not matching the module format of the source code (CommonJs) The EcmaScript module format was specified in the package.json that is affecting this source file or by using an special extension, but it looks like that CommonJs syntax is used in the source code. Exports made by CommonJs syntax will lead to a runtime error, since the module is in EcmaScript mode. Either change the "type" field in the package.json or replace CommonJs syntax with EcmaScript import/export syntax in the source file. \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot.rs b/crates/turbopack-tests/tests/snapshot.rs index 50e98dbe0a3b0..f34b993c8fb01 100644 --- a/crates/turbopack-tests/tests/snapshot.rs +++ b/crates/turbopack-tests/tests/snapshot.rs @@ -11,9 +11,7 @@ use std::{ use anyhow::{bail, Context, Result}; use dunce::canonicalize; use serde::Deserialize; -use turbo_tasks::{ - debug::ValueDebug, unit, ReadRef, TryJoinIterExt, TurboTasks, Value, ValueToString, Vc, -}; +use turbo_tasks::{unit, ReadRef, TryJoinIterExt, TurboTasks, Value, ValueToString, Vc}; use turbo_tasks_env::DotenvProcessEnv; use turbo_tasks_fs::{ json::parse_json_with_source_context, util::sys_to_unix, DiskFileSystem, FileSystem, @@ -148,7 +146,9 @@ async fn run(resource: PathBuf) -> Result<()> { let plain_issues = captured_issues .iter_with_shortest_path() - .map(|(issue_vc, path)| issue_vc.into_plain(path)); + .map(|(issue_vc, path)| async move { issue_vc.into_plain(path).await }) + .try_join() + .await?; snapshot_issues(plain_issues, out.join("issues".to_string()), &REPO_ROOT) .await diff --git a/crates/turbopack-tests/tests/snapshot/export-alls/cjs-2/issues/unexpected export __star__-c9d8a6.txt b/crates/turbopack-tests/tests/snapshot/export-alls/cjs-2/issues/unexpected export __star__-c9d8a6.txt index 3d0a94236dd02..351a91de29c3e 100644 --- a/crates/turbopack-tests/tests/snapshot/export-alls/cjs-2/issues/unexpected export __star__-c9d8a6.txt +++ b/crates/turbopack-tests/tests/snapshot/export-alls/cjs-2/issues/unexpected export __star__-c9d8a6.txt @@ -1,3 +1,3 @@ -warning - [analyze] [project]/crates/turbopack-tests/tests/snapshot/export-alls/cjs-2/input/commonjs.js unexpected export * +warning - [analyze] [project]/crates/turbopack-tests/tests/snapshot/export-alls/cjs-2/input/commonjs.js unexpected export * export * used with module [project]/crates/turbopack-tests/tests/snapshot/export-alls/cjs-2/input/commonjs.js (ecmascript) which is a CommonJS module with exports only available at runtime List all export names manually (`export { a, b, c } from "...") or rewrite the module to ESM, to avoid the additional runtime code.` \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/export-alls/cjs-script/issues/unexpected export __star__-38cf67.txt b/crates/turbopack-tests/tests/snapshot/export-alls/cjs-script/issues/unexpected export __star__-38cf67.txt index e764296aac81f..31e8dda48183a 100644 --- a/crates/turbopack-tests/tests/snapshot/export-alls/cjs-script/issues/unexpected export __star__-38cf67.txt +++ b/crates/turbopack-tests/tests/snapshot/export-alls/cjs-script/issues/unexpected export __star__-38cf67.txt @@ -1,3 +1,3 @@ -warning - [analyze] [project]/crates/turbopack-tests/tests/snapshot/export-alls/cjs-script/input/exported.cjs unexpected export * +warning - [analyze] [project]/crates/turbopack-tests/tests/snapshot/export-alls/cjs-script/input/exported.cjs unexpected export * export * used with module [project]/crates/turbopack-tests/tests/snapshot/export-alls/cjs-script/input/exported.cjs (ecmascript) which is a CommonJS module with exports only available at runtime List all export names manually (`export { a, b, c } from "...") or rewrite the module to ESM, to avoid the additional runtime code.` \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/imports/json/issues/Code generation for chunk item errored-5567c6.txt b/crates/turbopack-tests/tests/snapshot/imports/json/issues/Code generation for chunk item errored-5567c6.txt index f2c3813dddcbe..3abc098754023 100644 --- a/crates/turbopack-tests/tests/snapshot/imports/json/issues/Code generation for chunk item errored-5567c6.txt +++ b/crates/turbopack-tests/tests/snapshot/imports/json/issues/Code generation for chunk item errored-5567c6.txt @@ -1,14 +1,18 @@ -PlainIssue { - severity: Error, - context: "[project]/crates/turbopack-tests/tests/snapshot/imports/json/input/invalid.json", - category: "code generation", - title: "Code generation for chunk item errored", - description: "An error occurred while generating the chunk item [project]/crates/turbopack-tests/tests/snapshot/imports/json/input/invalid.json (json)\n\nCaused by:\n- Unable to make a module from invalid JSON: expected `,` or `}` at line 3 column 26\n\nDebug info:\n- An error occurred while generating the chunk item [project]/crates/turbopack-tests/tests/snapshot/imports/json/input/invalid.json (json)\n- Execution of ::content failed\n- Unable to make a module from invalid JSON: expected `,` or `}` at line 3 column 26\n at nested.?\n 1 | {\n 2 | \"nested\": {\n | v\n 3 + \"this-is\": \"invalid\" // lint-staged will remove trailing commas, so here's a comment\n | ^\n 4 | }\n 5 | }", - detail: "", - documentation_link: "", - source: None, - sub_issues: [], - processing_path: Some( - [], - ), -} \ No newline at end of file +error - [code generation] [project]/crates/turbopack-tests/tests/snapshot/imports/json/input/invalid.json Code generation for chunk item errored + An error occurred while generating the chunk item [project]/crates/turbopack-tests/tests/snapshot/imports/json/input/invalid.json (json) + + Caused by: + - Unable to make a module from invalid JSON: expected `,` or `}` at line 3 column 26 + + Debug info: + - An error occurred while generating the chunk item [project]/crates/turbopack-tests/tests/snapshot/imports/json/input/invalid.json (json) + - Execution of ::content failed + - Unable to make a module from invalid JSON: expected `,` or `}` at line 3 column 26 + at nested.? + 1 | { + 2 | "nested": { + | v + 3 + "this-is": "invalid" // lint-staged will remove trailing commas, so here's a comment + | ^ + 4 | } + 5 | } \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/imports/resolve_error_cjs/issues/Error resolving commonjs request-b97684.txt b/crates/turbopack-tests/tests/snapshot/imports/resolve_error_cjs/issues/Error resolving commonjs request-b97684.txt index 968f52b5d3a18..3c8e795ebaed1 100644 --- a/crates/turbopack-tests/tests/snapshot/imports/resolve_error_cjs/issues/Error resolving commonjs request-b97684.txt +++ b/crates/turbopack-tests/tests/snapshot/imports/resolve_error_cjs/issues/Error resolving commonjs request-b97684.txt @@ -1,28 +1,16 @@ -PlainIssue { - severity: Error, - context: "[project]/crates/turbopack-tests/tests/snapshot/imports/resolve_error_cjs/input/index.js", - category: "resolve", - title: "Error resolving commonjs request", - description: "unable to resolve module \"does-not-exist\" with subpath \"/path\"", - detail: "It was not possible to find the requested file.\nParsed request as written in source code: module \"does-not-exist\" with subpath \"/path\"\nPath where resolving has started: [project]/crates/turbopack-tests/tests/snapshot/imports/resolve_error_cjs/input/index.js\nType of request: commonjs request\nImport map: No import map entry\n", - documentation_link: "", - source: Some( - PlainIssueSource { - asset: PlainSource { - ident: "[project]/crates/turbopack-tests/tests/snapshot/imports/resolve_error_cjs/input/index.js", - }, - start: SourcePos { - line: 0, - column: 13, - }, - end: SourcePos { - line: 0, - column: 43, - }, - }, - ), - sub_issues: [], - processing_path: Some( - [], - ), -} \ No newline at end of file +error - [resolve] [project]/crates/turbopack-tests/tests/snapshot/imports/resolve_error_cjs/input/index.js /crates/turbopack-tests/tests/snapshot/imports/resolve_error_cjs/input/index.js:1:13 Error resolving commonjs request + + v----------------------------v + 1 + const dne = require("does-not-exist/path"); + + ^----------------------------^ + 2 | + 3 | console.log(dne); + 4 | + + unable to resolve module "does-not-exist" with subpath "/path" + + | It was not possible to find the requested file. + | Parsed request as written in source code: module "does-not-exist" with subpath "/path" + | Path where resolving has started: [project]/crates/turbopack-tests/tests/snapshot/imports/resolve_error_cjs/input/index.js + | Type of request: commonjs request + | Import map: No import map entry + | \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/imports/resolve_error_esm/issues/Error resolving EcmaScript Modules request-aff400.txt b/crates/turbopack-tests/tests/snapshot/imports/resolve_error_esm/issues/Error resolving EcmaScript Modules request-aff400.txt index 5cdc76d213c7f..1e1abc39b0f62 100644 --- a/crates/turbopack-tests/tests/snapshot/imports/resolve_error_esm/issues/Error resolving EcmaScript Modules request-aff400.txt +++ b/crates/turbopack-tests/tests/snapshot/imports/resolve_error_esm/issues/Error resolving EcmaScript Modules request-aff400.txt @@ -1,4 +1,4 @@ -error - [resolve] [project]/crates/turbopack-tests/tests/snapshot/imports/resolve_error_esm/input/index.js Error resolving EcmaScript Modules request +error - [resolve] [project]/crates/turbopack-tests/tests/snapshot/imports/resolve_error_esm/input/index.js Error resolving EcmaScript Modules request unable to resolve module "does-not-exist" with subpath "/path" | It was not possible to find the requested file. From 6b2ca21adc39436f3cde7cba63fd390c5d973f5f Mon Sep 17 00:00:00 2001 From: hrmny Date: Tue, 18 Jul 2023 16:23:36 +0200 Subject: [PATCH 12/16] review fixes --- crates/turbo-tasks-build/src/lib.rs | 1 + .../js/src/shared/runtime-utils.ts | 4 ++-- .../src/build_runtime.rs | 6 ++++-- .../turbopack-ecmascript-runtime/src/dev_runtime.rs | 12 +++++++++--- .../src/references/async_module.rs | 5 +---- .../turbopack-ecmascript/src/references/esm/base.rs | 4 ++-- crates/turbopack-ecmascript/src/references/mod.rs | 7 ++----- crates/turbopack-test-utils/src/snapshot.rs | 2 +- crates/turbopack-tests/build.rs | 4 ++-- 9 files changed, 24 insertions(+), 21 deletions(-) diff --git a/crates/turbo-tasks-build/src/lib.rs b/crates/turbo-tasks-build/src/lib.rs index 7a11b7b386342..dd83adf84ffe8 100644 --- a/crates/turbo-tasks-build/src/lib.rs +++ b/crates/turbo-tasks-build/src/lib.rs @@ -165,6 +165,7 @@ pub fn rerun_if_glob(globs: &str, root: &str) { let cwd = env::current_dir().unwrap(); let globs = cwd.join(globs.replace('/', PATH_SEP.to_string().as_str())); let root = cwd.join(root.replace('/', PATH_SEP.to_string().as_str())); + println!("cargo:rerun-if-changed={}", root.display()); let mut seen = HashSet::from([root]); for entry in glob(globs.to_str().unwrap()).unwrap() { let path = entry.unwrap(); diff --git a/crates/turbopack-ecmascript-runtime/js/src/shared/runtime-utils.ts b/crates/turbopack-ecmascript-runtime/js/src/shared/runtime-utils.ts index b5d03185c7973..19443ffe9c844 100644 --- a/crates/turbopack-ecmascript-runtime/js/src/shared/runtime-utils.ts +++ b/crates/turbopack-ecmascript-runtime/js/src/shared/runtime-utils.ts @@ -209,10 +209,10 @@ function esmImport( const module = getOrInstantiateModuleFromParent(id, sourceModule); if (module.error) throw module.error; - // any async module has to have `module.namespaceObject` defined + // Any ES module has to have `module.namespaceObject` defined. if (module.namespaceObject) return module.namespaceObject; - // can't be an async module at this point + // only ESM can be an async module, so we don't need to worry about exports being a promise. const raw = module.exports; return (module.namespaceObject = interopEsm( raw, diff --git a/crates/turbopack-ecmascript-runtime/src/build_runtime.rs b/crates/turbopack-ecmascript-runtime/src/build_runtime.rs index 1eb9e06e43905..44318de4c7aa8 100644 --- a/crates/turbopack-ecmascript-runtime/src/build_runtime.rs +++ b/crates/turbopack-ecmascript-runtime/src/build_runtime.rs @@ -12,8 +12,10 @@ use crate::{asset_context::get_runtime_asset_context, embed_js::embed_static_cod pub async fn get_build_runtime_code(environment: Vc) -> Result> { let asset_context = get_runtime_asset_context(environment); - let shared_runtime_utils_code = embed_static_code(asset_context, "shared/runtime-utils.ts".to_string()); - let shared_node_utils_code = embed_static_code(asset_context, "shared-node/require.ts".to_string()); + let shared_runtime_utils_code = + embed_static_code(asset_context, "shared/runtime-utils.ts".to_string()); + let shared_node_utils_code = + embed_static_code(asset_context, "shared-node/require.ts".to_string()); let runtime_code = embed_static_code(asset_context, "build/runtime.ts".to_string()); let mut code = CodeBuilder::default(); diff --git a/crates/turbopack-ecmascript-runtime/src/dev_runtime.rs b/crates/turbopack-ecmascript-runtime/src/dev_runtime.rs index 9ab9831409de0..800fd7b573ec8 100644 --- a/crates/turbopack-ecmascript-runtime/src/dev_runtime.rs +++ b/crates/turbopack-ecmascript-runtime/src/dev_runtime.rs @@ -20,8 +20,12 @@ pub async fn get_dev_runtime_code( ) -> Result> { let asset_context = get_runtime_asset_context(environment); - let shared_runtime_utils_code = embed_static_code(asset_context, "shared/runtime-utils.ts".to_string()); - let runtime_base_code = embed_static_code(asset_context, "dev/runtime/base/runtime-base.ts".to_string()); + let shared_runtime_utils_code = + embed_static_code(asset_context, "shared/runtime-utils.ts".to_string()); + let runtime_base_code = embed_static_code( + asset_context, + "dev/runtime/base/runtime-base.ts".to_string(), + ); let chunk_loading = &*asset_context .compile_time_info() @@ -61,7 +65,9 @@ pub async fn get_dev_runtime_code( code.push_code(&*runtime_base_code.await?); if matches!(chunk_loading, ChunkLoading::NodeJs) { - code.push_code(&*embed_static_code(asset_context, "shared-node/require.ts".to_string()).await?); + code.push_code( + &*embed_static_code(asset_context, "shared-node/require.ts".to_string()).await?, + ); } code.push_code(&*runtime_backend_code.await?); diff --git a/crates/turbopack-ecmascript/src/references/async_module.rs b/crates/turbopack-ecmascript/src/references/async_module.rs index 5bfe7d75ca0c5..7874a4a57835c 100644 --- a/crates/turbopack-ecmascript/src/references/async_module.rs +++ b/crates/turbopack-ecmascript/src/references/async_module.rs @@ -192,10 +192,7 @@ impl AsyncModule { let this = self.await?; let scope = EsmScope::new(availability_info); - let Some(scc) = &*scope - .get_scc(Vc::upcast(this.module)) - .await? - else { + let Some(scc) = &*scope.get_scc(Vc::upcast(this.module)).await? else { // I'm not sure if this should be possible. return Ok(Vc::cell(None)); }; diff --git a/crates/turbopack-ecmascript/src/references/esm/base.rs b/crates/turbopack-ecmascript/src/references/esm/base.rs index bea3399206cf6..ccf30d91595ce 100644 --- a/crates/turbopack-ecmascript/src/references/esm/base.rs +++ b/crates/turbopack-ecmascript/src/references/esm/base.rs @@ -8,8 +8,8 @@ use swc_core::{ use turbo_tasks::{Value, ValueToString, Vc}; use turbopack_core::{ chunk::{ - availability_info::AvailabilityInfo, ChunkableModuleReference, - ChunkingContext, ChunkingType, ChunkingTypeOption, ModuleId, + availability_info::AvailabilityInfo, ChunkableModuleReference, ChunkingContext, + ChunkingType, ChunkingTypeOption, ModuleId, }, issue::{IssueSeverity, OptionIssueSource}, module::Module, diff --git a/crates/turbopack-ecmascript/src/references/mod.rs b/crates/turbopack-ecmascript/src/references/mod.rs index 878a0b6f676cc..c1ca498760272 100644 --- a/crates/turbopack-ecmascript/src/references/mod.rs +++ b/crates/turbopack-ecmascript/src/references/mod.rs @@ -50,7 +50,7 @@ use turbo_tasks_fs::{FileJsonContent, FileSystemPath}; use turbopack_core::{ compile_time_info::{CompileTimeInfo, FreeVarReference}, error::PrettyPrintError, - issue::{analyze::AnalyzeIssue, IssueExt, IssueSource, OptionIssueSource}, + issue::{analyze::AnalyzeIssue, IssueExt, IssueSeverity, IssueSource, OptionIssueSource}, module::Module, reference::{AssetReference, AssetReferences, SourceMapReference}, reference_type::{CommonJsReferenceSubType, ReferenceType}, @@ -64,7 +64,6 @@ use turbopack_core::{ }, source::{asset_to_source, Source}, }; -use turbopack_core::issue::IssueSeverity; use turbopack_swc_utils::emitter::IssueEmitter; use unreachable::Unreachable; @@ -670,9 +669,7 @@ pub(crate) async fn analyze_ecmascript_module( AnalyzeIssue { code: None, category: Vc::cell("analyze".to_string()), - message: Vc::cell( - "top level await is only supported in ESM modules.".to_string(), - ), + message: Vc::cell("top level await is only supported in ESM modules.".to_string()), source_ident: source.ident(), severity: IssueSeverity::Error.into(), source: Some(issue_source(source, span)), diff --git a/crates/turbopack-test-utils/src/snapshot.rs b/crates/turbopack-test-utils/src/snapshot.rs index b495ede2eddf1..cf830d1e5fe02 100644 --- a/crates/turbopack-test-utils/src/snapshot.rs +++ b/crates/turbopack-test-utils/src/snapshot.rs @@ -6,13 +6,13 @@ use std::{ use anyhow::{anyhow, bail, Context, Result}; use once_cell::sync::Lazy; +use regex::Regex; use similar::TextDiff; use turbo_tasks::{ReadRef, TryJoinIterExt, ValueToString, Vc}; use turbo_tasks_fs::{ DirectoryContent, DirectoryEntry, DiskFileSystem, File, FileContent, FileSystemEntryType, FileSystemPath, }; -use regex::Regex; use turbo_tasks_hash::encode_hex; use turbopack_cli_utils::issue::{format_issue, LogOptions}; use turbopack_core::{ diff --git a/crates/turbopack-tests/build.rs b/crates/turbopack-tests/build.rs index 8b2f6227bd0d3..2fe041a8dc58b 100644 --- a/crates/turbopack-tests/build.rs +++ b/crates/turbopack-tests/build.rs @@ -5,6 +5,6 @@ fn main() { // The test/snapshot crate need to be rebuilt if any snapshots are added. // Unfortunately, we can't have the build.rs file operate differently on // each file, so the entire turbopack crate needs to be rebuilt. - rerun_if_glob("tests/execution/*/*/*/input", "tests/"); - rerun_if_glob("tests/snapshot/*/*/input", "tests/"); + rerun_if_glob("tests/execution/*/*/*/input", "tests/execution"); + rerun_if_glob("tests/snapshot/*/*/input", "tests/snapshot"); } From a4a0e216f13143df4099c5303929522400a3318c Mon Sep 17 00:00:00 2001 From: hrmny Date: Tue, 18 Jul 2023 17:18:24 +0200 Subject: [PATCH 13/16] simplify `dynamicExport` --- .../js/src/build/runtime.ts | 2 +- .../js/src/dev/runtime/base/runtime-base.ts | 2 +- .../js/src/shared/runtime-utils.ts | 53 ++++--------------- .../async-modules/export-all/input/exports.js | 4 ++ .../async-modules/export-all/input/index.js | 9 ++++ .../async-modules/export-all/input/single.js | 1 + .../async-modules/export-all/input/tla.js | 3 ++ .../top-level-await/input/Actions.js | 0 .../top-level-await/input/README.md | 0 .../top-level-await/input/UserAPI.js | 0 .../top-level-await/input/db-connection.js | 0 .../top-level-await/input/index.js | 0 .../output/[turbopack]_runtime.js | 36 +++---------- .../output/[turbopack]_runtime.js.map | 6 +-- ..._default_dev_runtime_input_index_e60ecd.js | 36 +++---------- ...ault_dev_runtime_input_index_e60ecd.js.map | 8 +-- 16 files changed, 50 insertions(+), 110 deletions(-) create mode 100644 crates/turbopack-tests/tests/execution/turbopack/async-modules/export-all/input/exports.js create mode 100644 crates/turbopack-tests/tests/execution/turbopack/async-modules/export-all/input/index.js create mode 100644 crates/turbopack-tests/tests/execution/turbopack/async-modules/export-all/input/single.js create mode 100644 crates/turbopack-tests/tests/execution/turbopack/async-modules/export-all/input/tla.js rename crates/turbopack-tests/tests/execution/turbopack/{basic => async-modules}/top-level-await/input/Actions.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{basic => async-modules}/top-level-await/input/README.md (100%) rename crates/turbopack-tests/tests/execution/turbopack/{basic => async-modules}/top-level-await/input/UserAPI.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{basic => async-modules}/top-level-await/input/db-connection.js (100%) rename crates/turbopack-tests/tests/execution/turbopack/{basic => async-modules}/top-level-await/input/index.js (100%) diff --git a/crates/turbopack-ecmascript-runtime/js/src/build/runtime.ts b/crates/turbopack-ecmascript-runtime/js/src/build/runtime.ts index d3b2331d1ed7f..53c2105f9070f 100644 --- a/crates/turbopack-ecmascript-runtime/js/src/build/runtime.ts +++ b/crates/turbopack-ecmascript-runtime/js/src/build/runtime.ts @@ -129,7 +129,7 @@ function instantiateModule(id: ModuleId, source: SourceInfo): Module { f: requireContext.bind(null, module), i: esmImport.bind(null, module), s: esm.bind(null, module.exports), - j: dynamicExport.bind(null, module, module.exports), + j: dynamicExport.bind(null, module.exports), v: exportValue.bind(null, module), n: exportNamespace.bind(null, module), m: module, diff --git a/crates/turbopack-ecmascript-runtime/js/src/dev/runtime/base/runtime-base.ts b/crates/turbopack-ecmascript-runtime/js/src/dev/runtime/base/runtime-base.ts index 69fb3f5ace44c..69e83438c9712 100644 --- a/crates/turbopack-ecmascript-runtime/js/src/dev/runtime/base/runtime-base.ts +++ b/crates/turbopack-ecmascript-runtime/js/src/dev/runtime/base/runtime-base.ts @@ -326,7 +326,7 @@ function instantiateModule(id: ModuleId, source: SourceInfo): Module { f: requireContext.bind(null, module), i: esmImport.bind(null, module), s: esmExport.bind(null, module, module.exports), - j: dynamicExport.bind(null, module, module.exports), + j: dynamicExport.bind(null, module.exports), v: exportValue.bind(null, module), n: exportNamespace.bind(null, module), m: module, diff --git a/crates/turbopack-ecmascript-runtime/js/src/shared/runtime-utils.ts b/crates/turbopack-ecmascript-runtime/js/src/shared/runtime-utils.ts index 19443ffe9c844..94e7306bb0bff 100644 --- a/crates/turbopack-ecmascript-runtime/js/src/shared/runtime-utils.ts +++ b/crates/turbopack-ecmascript-runtime/js/src/shared/runtime-utils.ts @@ -98,52 +98,19 @@ function esmExport( * Dynamically exports properties from an object */ function dynamicExport( - module: Module, exports: Exports, object: Record ) { - let reexportedObjects = module[REEXPORTED_OBJECTS]; - if (!reexportedObjects) { - reexportedObjects = module[REEXPORTED_OBJECTS] = []; - - const namespaceObject = new Proxy(exports, { - get(target, prop) { - if ( - hasOwnProperty.call(target, prop) || - prop === "default" || - prop === "__esModule" - ) { - return Reflect.get(target, prop); - } - for (const obj of reexportedObjects!) { - const value = Reflect.get(obj, prop); - if (value !== undefined) return value; - } - return undefined; - }, - ownKeys(target) { - const keys = Reflect.ownKeys(target); - for (const obj of reexportedObjects!) { - for (const key of Reflect.ownKeys(obj)) { - if (key !== "default" && !keys.includes(key)) keys.push(key); - } - } - return keys; - }, - }); + const keys = Reflect.ownKeys(exports); - // If this is inside an async module `module.namespaceObject` is a promise, - // so we need to replace it with a new promise. - if (isPromise(module.namespaceObject)) { - module.exports = module.namespaceObject = maybeWrapAsyncModulePromise( - module.namespaceObject, - () => namespaceObject - ); - } else { - module.exports = module.namespaceObject = namespaceObject; + for (const key of Reflect.ownKeys(object)) { + if (key !== "default" && !keys.includes(key)) { + defineProp(exports, key, { + get: createGetter(object, key), + enumerable: true, + }); } } - reexportedObjects.push(object); } function exportValue(module: Module, value: any) { @@ -154,7 +121,7 @@ function exportNamespace(module: Module, namespace: any) { module.exports = module.namespaceObject = namespace; } -function createGetter(obj: Record, key: string) { +function createGetter(obj: Record, key: string | symbol) { return () => obj[key]; } @@ -209,10 +176,10 @@ function esmImport( const module = getOrInstantiateModuleFromParent(id, sourceModule); if (module.error) throw module.error; - // Any ES module has to have `module.namespaceObject` defined. + // any ES module has to have `module.namespaceObject` defined. if (module.namespaceObject) return module.namespaceObject; - // only ESM can be an async module, so we don't need to worry about exports being a promise. + // only ESM can be an async module, so we don't need to worry about exports being a promise here. const raw = module.exports; return (module.namespaceObject = interopEsm( raw, diff --git a/crates/turbopack-tests/tests/execution/turbopack/async-modules/export-all/input/exports.js b/crates/turbopack-tests/tests/execution/turbopack/async-modules/export-all/input/exports.js new file mode 100644 index 0000000000000..474eabac82741 --- /dev/null +++ b/crates/turbopack-tests/tests/execution/turbopack/async-modules/export-all/input/exports.js @@ -0,0 +1,4 @@ +module.exports = {}; + +module.exports.a = "export-a"; +module.exports.b = "export-b"; diff --git a/crates/turbopack-tests/tests/execution/turbopack/async-modules/export-all/input/index.js b/crates/turbopack-tests/tests/execution/turbopack/async-modules/export-all/input/index.js new file mode 100644 index 0000000000000..b0ee892b62049 --- /dev/null +++ b/crates/turbopack-tests/tests/execution/turbopack/async-modules/export-all/input/index.js @@ -0,0 +1,9 @@ +import { a, b, single } from "./tla"; + +it("should handle export all from cjs modules in modules with top level await", async () => { + expect(a).toBe("export-a"); + expect(b).toBe("export-b"); + expect(single).toMatchObject({ + single: 1, + }); +}); diff --git a/crates/turbopack-tests/tests/execution/turbopack/async-modules/export-all/input/single.js b/crates/turbopack-tests/tests/execution/turbopack/async-modules/export-all/input/single.js new file mode 100644 index 0000000000000..11cebbf56bd53 --- /dev/null +++ b/crates/turbopack-tests/tests/execution/turbopack/async-modules/export-all/input/single.js @@ -0,0 +1 @@ +export const single = 1; diff --git a/crates/turbopack-tests/tests/execution/turbopack/async-modules/export-all/input/tla.js b/crates/turbopack-tests/tests/execution/turbopack/async-modules/export-all/input/tla.js new file mode 100644 index 0000000000000..4a607dded2a05 --- /dev/null +++ b/crates/turbopack-tests/tests/execution/turbopack/async-modules/export-all/input/tla.js @@ -0,0 +1,3 @@ +export const single = await import("./single"); + +export * from "./exports"; diff --git a/crates/turbopack-tests/tests/execution/turbopack/basic/top-level-await/input/Actions.js b/crates/turbopack-tests/tests/execution/turbopack/async-modules/top-level-await/input/Actions.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/basic/top-level-await/input/Actions.js rename to crates/turbopack-tests/tests/execution/turbopack/async-modules/top-level-await/input/Actions.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/basic/top-level-await/input/README.md b/crates/turbopack-tests/tests/execution/turbopack/async-modules/top-level-await/input/README.md similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/basic/top-level-await/input/README.md rename to crates/turbopack-tests/tests/execution/turbopack/async-modules/top-level-await/input/README.md diff --git a/crates/turbopack-tests/tests/execution/turbopack/basic/top-level-await/input/UserAPI.js b/crates/turbopack-tests/tests/execution/turbopack/async-modules/top-level-await/input/UserAPI.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/basic/top-level-await/input/UserAPI.js rename to crates/turbopack-tests/tests/execution/turbopack/async-modules/top-level-await/input/UserAPI.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/basic/top-level-await/input/db-connection.js b/crates/turbopack-tests/tests/execution/turbopack/async-modules/top-level-await/input/db-connection.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/basic/top-level-await/input/db-connection.js rename to crates/turbopack-tests/tests/execution/turbopack/async-modules/top-level-await/input/db-connection.js diff --git a/crates/turbopack-tests/tests/execution/turbopack/basic/top-level-await/input/index.js b/crates/turbopack-tests/tests/execution/turbopack/async-modules/top-level-await/input/index.js similarity index 100% rename from crates/turbopack-tests/tests/execution/turbopack/basic/top-level-await/input/index.js rename to crates/turbopack-tests/tests/execution/turbopack/async-modules/top-level-await/input/index.js diff --git a/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js b/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js index 2875e9d9f3948..06c35987297fa 100644 --- a/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js +++ b/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js @@ -29,37 +29,15 @@ function esmExport(module, exports, getters) { esm(exports, getters); } function dynamicExport(module, exports, object) { - let reexportedObjects = module[REEXPORTED_OBJECTS]; - if (!reexportedObjects) { - reexportedObjects = module[REEXPORTED_OBJECTS] = []; - const namespaceObject = new Proxy(exports, { - get (target, prop) { - if (hasOwnProperty.call(target, prop) || prop === "default" || prop === "__esModule") { - return Reflect.get(target, prop); - } - for (const obj of reexportedObjects){ - const value = Reflect.get(obj, prop); - if (value !== undefined) return value; - } - return undefined; - }, - ownKeys (target) { - const keys = Reflect.ownKeys(target); - for (const obj of reexportedObjects){ - for (const key of Reflect.ownKeys(obj)){ - if (key !== "default" && !keys.includes(key)) keys.push(key); - } - } - return keys; - } - }); - if (isPromise(module.namespaceObject)) { - module.exports = module.namespaceObject = maybeWrapAsyncModulePromise(module.namespaceObject, ()=>namespaceObject); - } else { - module.exports = module.namespaceObject = namespaceObject; + const keys = Reflect.ownKeys(exports); + for (const key of Reflect.ownKeys(object)){ + if (key !== "default" && !keys.includes(key)) { + defineProp(exports, key, { + get: createGetter(object, key), + enumerable: true + }); } } - reexportedObjects.push(object); } function exportValue(module, value) { module.exports = value; diff --git a/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js.map b/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js.map index fe210c43f4e38..10b7f4d4425f4 100644 --- a/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js.map +++ b/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js.map @@ -1,7 +1,7 @@ { "version": 3, "sections": [ - {"offset": {"line": 1, "column": 0}, "map": {"version":3,"sources":["/turbopack/[turbopack]/shared/runtime-utils.ts"],"sourcesContent":["/**\n * This file contains runtime types and functions that are shared between all\n * TurboPack ECMAScript runtimes.\n *\n * It will be prepended to the runtime code of each runtime.\n */\n\n/* eslint-disable @next/next/no-assign-module-variable */\n\n/// \n\ninterface Exports {\n __esModule?: boolean;\n\n [key: string]: any;\n}\n\ntype EsmNamespaceObject = Record;\n\nconst REEXPORTED_OBJECTS = Symbol(\"reexported objects\");\n\ninterface BaseModule {\n exports: Exports | Promise | AsyncModulePromise;\n error: Error | undefined;\n loaded: boolean;\n id: ModuleId;\n children: ModuleId[];\n parents: ModuleId[];\n namespaceObject?:\n | EsmNamespaceObject\n | Promise\n | AsyncModulePromise;\n [REEXPORTED_OBJECTS]?: any[];\n}\n\ninterface Module extends BaseModule {}\n\ntype RequireContextMap = Record;\n\ninterface RequireContextEntry {\n id: () => ModuleId;\n}\n\ninterface RequireContext {\n (moduleId: ModuleId): Exports | EsmNamespaceObject;\n\n keys(): ModuleId[];\n\n resolve(moduleId: ModuleId): ModuleId;\n}\n\ntype GetOrInstantiateModuleFromParent = (\n moduleId: ModuleId,\n parentModule: Module\n) => Module;\n\ntype CommonJsRequireContext = (\n entry: RequireContextEntry,\n parentModule: Module\n) => Exports;\n\nconst hasOwnProperty = Object.prototype.hasOwnProperty;\nconst toStringTag = typeof Symbol !== \"undefined\" && Symbol.toStringTag;\n\nfunction defineProp(\n obj: any,\n name: PropertyKey,\n options: PropertyDescriptor & ThisType\n) {\n if (!hasOwnProperty.call(obj, name))\n Object.defineProperty(obj, name, options);\n}\n\n/**\n * Adds the getters to the exports object.\n */\nfunction esm(exports: Exports, getters: Record any>) {\n defineProp(exports, \"__esModule\", { value: true });\n if (toStringTag) defineProp(exports, toStringTag, { value: \"Module\" });\n for (const key in getters) {\n defineProp(exports, key, { get: getters[key], enumerable: true });\n }\n}\n\n/**\n * Makes the module an ESM with exports\n */\nfunction esmExport(\n module: Module,\n exports: Exports,\n getters: Record any>\n) {\n module.namespaceObject = module.exports;\n esm(exports, getters);\n}\n\n/**\n * Dynamically exports properties from an object\n */\nfunction dynamicExport(\n module: Module,\n exports: Exports,\n object: Record\n) {\n let reexportedObjects = module[REEXPORTED_OBJECTS];\n if (!reexportedObjects) {\n reexportedObjects = module[REEXPORTED_OBJECTS] = [];\n\n const namespaceObject = new Proxy(exports, {\n get(target, prop) {\n if (\n hasOwnProperty.call(target, prop) ||\n prop === \"default\" ||\n prop === \"__esModule\"\n ) {\n return Reflect.get(target, prop);\n }\n for (const obj of reexportedObjects!) {\n const value = Reflect.get(obj, prop);\n if (value !== undefined) return value;\n }\n return undefined;\n },\n ownKeys(target) {\n const keys = Reflect.ownKeys(target);\n for (const obj of reexportedObjects!) {\n for (const key of Reflect.ownKeys(obj)) {\n if (key !== \"default\" && !keys.includes(key)) keys.push(key);\n }\n }\n return keys;\n },\n });\n\n // If this is inside an async module `module.namespaceObject` is a promise,\n // so we need to replace it with a new promise.\n if (isPromise(module.namespaceObject)) {\n module.exports = module.namespaceObject = maybeWrapAsyncModulePromise(\n module.namespaceObject,\n () => namespaceObject\n );\n } else {\n module.exports = module.namespaceObject = namespaceObject;\n }\n }\n reexportedObjects.push(object);\n}\n\nfunction exportValue(module: Module, value: any) {\n module.exports = value;\n}\n\nfunction exportNamespace(module: Module, namespace: any) {\n module.exports = module.namespaceObject = namespace;\n}\n\nfunction createGetter(obj: Record, key: string) {\n return () => obj[key];\n}\n\n/**\n * @returns prototype of the object\n */\nconst getProto: (obj: any) => any = Object.getPrototypeOf\n ? (obj) => Object.getPrototypeOf(obj)\n : (obj) => obj.__proto__;\n\n/** Prototypes that are not expanded for exports */\nconst LEAF_PROTOTYPES = [null, getProto({}), getProto([]), getProto(getProto)];\n\n/**\n * @param raw\n * @param ns\n * @param allowExportDefault\n * * `false`: will have the raw module as default export\n * * `true`: will have the default property as default export\n */\nfunction interopEsm(\n raw: Exports,\n ns: EsmNamespaceObject,\n allowExportDefault?: boolean\n) {\n const getters: { [s: string]: () => any } = Object.create(null);\n for (\n let current = raw;\n (typeof current === \"object\" || typeof current === \"function\") &&\n !LEAF_PROTOTYPES.includes(current);\n current = getProto(current)\n ) {\n for (const key of Object.getOwnPropertyNames(current)) {\n getters[key] = createGetter(raw, key);\n }\n }\n\n // this is not really correct\n // we should set the `default` getter if the imported module is a `.cjs file`\n if (!(allowExportDefault && \"default\" in getters)) {\n getters[\"default\"] = () => raw;\n }\n\n esm(ns, getters);\n return ns;\n}\n\nfunction esmImport(\n sourceModule: Module,\n id: ModuleId\n): Exclude {\n const module = getOrInstantiateModuleFromParent(id, sourceModule);\n if (module.error) throw module.error;\n\n // any async module has to have `module.namespaceObject` defined\n if (module.namespaceObject) return module.namespaceObject;\n\n // can't be an async module at this point\n const raw = module.exports;\n return (module.namespaceObject = interopEsm(\n raw,\n {},\n (raw as any).__esModule\n ));\n}\n\nfunction commonJsRequire(sourceModule: Module, id: ModuleId): Exports {\n const module = getOrInstantiateModuleFromParent(id, sourceModule);\n if (module.error) throw module.error;\n return module.exports;\n}\n\ntype RequireContextFactory = (map: RequireContextMap) => RequireContext;\n\nfunction requireContext(\n sourceModule: Module,\n map: RequireContextMap\n): RequireContext {\n function requireContext(id: ModuleId): Exports {\n const entry = map[id];\n\n if (!entry) {\n throw new Error(\n `module ${id} is required from a require.context, but is not in the context`\n );\n }\n\n return commonJsRequireContext(entry, sourceModule);\n }\n\n requireContext.keys = (): ModuleId[] => {\n return Object.keys(map);\n };\n\n requireContext.resolve = (id: ModuleId): ModuleId => {\n const entry = map[id];\n\n if (!entry) {\n throw new Error(\n `module ${id} is resolved from a require.context, but is not in the context`\n );\n }\n\n return entry.id();\n };\n\n return requireContext;\n}\n\n/**\n * Returns the path of a chunk defined by its data.\n */\nfunction getChunkPath(chunkData: ChunkData): ChunkPath {\n return typeof chunkData === \"string\" ? chunkData : chunkData.path;\n}\n\nfunction isPromise(maybePromise: any): maybePromise is Promise {\n return (\n maybePromise != null &&\n typeof maybePromise === \"object\" &&\n \"then\" in maybePromise &&\n typeof maybePromise.then === \"function\"\n );\n}\n\nfunction isAsyncModuleExt(obj: T): obj is AsyncModuleExt & T {\n return turbopackQueues in obj;\n}\n\nfunction maybeWrapAsyncModulePromise(\n promise: Promise,\n then: (val: T) => U | PromiseLike\n): typeof promise extends AsyncModulePromise\n ? AsyncModulePromise\n : Promise {\n const newPromise = promise.then(then);\n\n if (isAsyncModuleExt(promise)) {\n Object.assign(newPromise, {\n get [turbopackExports]() {\n return promise[turbopackExports];\n },\n get [turbopackQueues]() {\n return promise[turbopackQueues];\n },\n get [turbopackError]() {\n return promise[turbopackError];\n },\n } satisfies AsyncModuleExt);\n }\n\n return newPromise as any;\n}\n\nfunction createPromise() {\n let resolve: (value: T | PromiseLike) => void;\n let reject: (reason?: any) => void;\n\n const promise = new Promise((res, rej) => {\n reject = rej;\n resolve = res;\n });\n\n return {\n promise,\n resolve: resolve!,\n reject: reject!,\n };\n}\n\n// everything below is adapted from webpack\n// https://github.com/webpack/webpack/blob/6be4065ade1e252c1d8dcba4af0f43e32af1bdc1/lib/runtime/AsyncModuleRuntimeModule.js#L13\n\nconst turbopackQueues = Symbol(\"turbopack queues\");\nconst turbopackExports = Symbol(\"turbopack exports\");\nconst turbopackError = Symbol(\"turbopack error\");\n\ntype AsyncQueueFn = (() => void) & { queueCount: number };\ntype AsyncQueue = AsyncQueueFn[] & { resolved: boolean };\n\nfunction resolveQueue(queue?: AsyncQueue) {\n if (queue && !queue.resolved) {\n queue.resolved = true;\n queue.forEach((fn) => fn.queueCount--);\n queue.forEach((fn) => (fn.queueCount-- ? fn.queueCount++ : fn()));\n }\n}\n\ntype Dep = Exports | AsyncModulePromise | Promise;\n\ntype AsyncModuleExt = {\n [turbopackQueues]: (fn: (queue: AsyncQueue) => void) => void;\n [turbopackExports]: Exports;\n [turbopackError]?: any;\n};\n\ntype AsyncModulePromise = Promise & AsyncModuleExt;\n\nfunction wrapDeps(deps: Dep[]): AsyncModuleExt[] {\n return deps.map((dep) => {\n if (dep !== null && typeof dep === \"object\") {\n if (isAsyncModuleExt(dep)) return dep;\n if (isPromise(dep)) {\n const queue: AsyncQueue = Object.assign([], { resolved: false });\n\n const obj: AsyncModuleExt = {\n [turbopackExports]: {},\n [turbopackQueues]: (fn: (queue: AsyncQueue) => void) => fn(queue),\n };\n\n dep.then(\n (res) => {\n obj[turbopackExports] = res;\n resolveQueue(queue);\n },\n (err) => {\n obj[turbopackError] = err;\n resolveQueue(queue);\n }\n );\n\n return obj;\n }\n }\n\n const ret: AsyncModuleExt = {\n [turbopackExports]: dep,\n [turbopackQueues]: () => {},\n };\n\n return ret;\n });\n}\n\nfunction asyncModule(\n module: Module,\n body: (\n handleAsyncDependencies: (\n deps: Dep[]\n ) => Exports[] | Promise<() => Exports[]>,\n asyncResult: (err?: any) => void\n ) => void,\n hasAwait: boolean\n) {\n const queue: AsyncQueue | undefined = hasAwait\n ? Object.assign([], { resolved: true })\n : undefined;\n\n const depQueues: Set = new Set();\n const exports = module.exports;\n\n const { resolve, reject, promise: rawPromise } = createPromise();\n\n const promise: AsyncModulePromise = Object.assign(rawPromise, {\n [turbopackExports]: exports,\n [turbopackQueues]: (fn) => {\n queue && fn(queue);\n depQueues.forEach(fn);\n promise[\"catch\"](() => {});\n },\n } satisfies AsyncModuleExt);\n\n module.exports = module.namespaceObject = promise;\n\n function handleAsyncDependencies(deps: Dep[]) {\n const currentDeps = wrapDeps(deps);\n\n const getResult = () =>\n currentDeps.map((d) => {\n if (d[turbopackError]) throw d[turbopackError];\n return d[turbopackExports];\n });\n\n const { promise, resolve } = createPromise<() => Exports[]>();\n\n const fn: AsyncQueueFn = Object.assign(() => resolve(getResult), {\n queueCount: 0,\n });\n\n function fnQueue(q: AsyncQueue) {\n if (q !== queue && !depQueues.has(q)) {\n depQueues.add(q);\n if (q && !q.resolved) {\n fn.queueCount++;\n q.push(fn);\n }\n }\n }\n\n currentDeps.map((dep) => dep[turbopackQueues](fnQueue));\n\n return fn.queueCount ? promise : getResult();\n }\n\n function asyncResult(err?: any) {\n if (err) {\n reject((promise[turbopackError] = err));\n } else {\n resolve(exports);\n }\n\n resolveQueue(queue);\n }\n\n body(handleAsyncDependencies, asyncResult);\n\n if (queue) {\n queue.resolved = false;\n }\n}\n"],"names":[],"mappings":";AAmBA,MAAM,qBAAqB,OAAO;;;;;AA0ClC,MAAM,iBAAiB,OAAO,SAAS,CAAC,cAAc;AACtD,MAAM,cAAc,OAAO,WAAW,eAAe,OAAO,WAAW;AAEvE,SAAS,WACP,GAAQ,EACR,IAAiB,EACjB,OAA2C;IAE3C,IAAI,CAAC,eAAe,IAAI,CAAC,KAAK,OAC5B,OAAO,cAAc,CAAC,KAAK,MAAM;AACrC;AAKA,SAAS,IAAI,OAAgB,EAAE,OAAkC;IAC/D,WAAW,SAAS,cAAc;QAAE,OAAO;IAAK;IAChD,IAAI,aAAa,WAAW,SAAS,aAAa;QAAE,OAAO;IAAS;IACpE,IAAK,MAAM,OAAO,QAAS;QACzB,WAAW,SAAS,KAAK;YAAE,KAAK,OAAO,CAAC,IAAI;YAAE,YAAY;QAAK;IACjE;AACF;AAKA,SAAS,UACP,MAAc,EACd,OAAgB,EAChB,OAAkC;IAElC,OAAO,eAAe,GAAG,OAAO,OAAO;IACvC,IAAI,SAAS;AACf;AAKA,SAAS,cACP,MAAc,EACd,OAAgB,EAChB,MAA2B;IAE3B,IAAI,oBAAoB,MAAM,CAAC,mBAAmB;IAClD,IAAI,CAAC,mBAAmB;QACtB,oBAAoB,MAAM,CAAC,mBAAmB,GAAG,EAAE;QAEnD,MAAM,kBAAkB,IAAI,MAAM,SAAS;YACzC,KAAI,MAAM,EAAE,IAAI;gBACd,IACE,eAAe,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QAE7B,MAAM,KAAmB,OAAO,MAAM,CAAC,IAAM,QAAQ,YAAY;YAC/D,YAAY;QACd;QAEA,SAAS,QAAQ,CAAa;YAC5B,IAAI,MAAM,SAAS,CAAC,UAAU,GAAG,CAAC,IAAI;gBACpC,UAAU,GAAG,CAAC;gBACd,IAAI,KAAK,CAAC,EAAE,QAAQ,EAAE;oBACpB,GAAG,UAAU;oBACb,EAAE,IAAI,CAAC;gBACT;YACF;QACF;QAEA,YAAY,GAAG,CAAC,CAAC,MAAQ,GAAG,CAAC,gBAAgB,CAAC;QAE9C,OAAO,GAAG,UAAU,GAAG,UAAU;IACnC;IAEA,SAAS,YAAY,GAAS;QAC5B,IAAI,KAAK;YACP,OAAQ,OAAO,CAAC,eAAe,GAAG;QACpC,OAAO;YACL,QAAQ;QACV;QAEA,aAAa;IACf;IAEA,KAAK,yBAAyB;IAE9B,IAAI,OAAO;QACT,MAAM,QAAQ,GAAG;IACnB;AACF"}}, - {"offset": {"line": 253, "column": 0}, "map": {"version":3,"sources":["/turbopack/[turbopack]/shared-node/require.ts"],"sourcesContent":["/// \n\ninterface RequireContextEntry {\n external: boolean;\n}\n\nfunction commonJsRequireContext(\n entry: RequireContextEntry,\n sourceModule: Module\n): Exports {\n return entry.external\n ? externalRequire(entry.id(), false)\n : commonJsRequire(sourceModule, entry.id());\n}\n\nfunction externalImport(id: ModuleId) {\n return import(id);\n}\n\nfunction externalRequire(\n id: ModuleId,\n esm: boolean = false\n): Exports | EsmNamespaceObject {\n let raw;\n try {\n raw = require(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 (!esm || raw.__esModule) {\n return raw;\n }\n\n return interopEsm(raw, {}, true);\n}\nexternalRequire.resolve = (\n id: string,\n options?:\n | {\n paths?: string[] | undefined;\n }\n | undefined\n) => {\n return require.resolve(id, options);\n};\n"],"names":[],"mappings":";AAMA,SAAS,uBACP,KAA0B,EAC1B,YAAoB;IAEpB,OAAO,MAAM,QAAQ,GACjB,gBAAgB,MAAM,EAAE,IAAI,SAC5B,gBAAgB,cAAc,MAAM,EAAE;AAC5C;AAEA,SAAS,eAAe,EAAY;IAClC,OAAO,MAAM,CAAC;AAChB;AAEA,SAAS,gBACP,EAAY,EACZ,MAAe,KAAK;IAEpB,IAAI;IACJ,IAAI;QACF,MAAM,QAAQ;IAChB,EAAE,OAAO,KAAK;QAKZ,MAAM,IAAI,MAAM,CAAC,+BAA+B,EAAE,GAAG,EAAE,EAAE,IAAI,CAAC;IAChE;IAEA,IAAI,CAAC,OAAO,IAAI,UAAU,EAAE;QAC1B,OAAO;IACT;IAEA,OAAO,WAAW,KAAK,CAAC,GAAG;AAC7B;AACA,gBAAgB,OAAO,GAAG,CACxB,IACA;IAMA,OAAO,QAAQ,OAAO,CAAC,IAAI;AAC7B"}}, - {"offset": {"line": 275, "column": 0}, "map": {"version":3,"sources":["/turbopack/[turbopack]/build/runtime.ts"],"sourcesContent":["/// \n/// \n\ndeclare var RUNTIME_PUBLIC_PATH: string;\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\ntype ExternalRequire = (id: ModuleId) => Exports | EsmNamespaceObject;\ntype ExternalImport = (id: ModuleId) => Promise;\n\ninterface TurbopackNodeBuildContext extends TurbopackBaseContext {\n x: ExternalRequire;\n y: ExternalImport;\n}\n\ntype ModuleFactory = (\n this: Module[\"exports\"],\n context: TurbopackNodeBuildContext\n) => undefined;\n\nconst path = require(\"path\");\nconst relativePathToRuntimeRoot = path.relative(RUNTIME_PUBLIC_PATH, \".\");\nconst RUNTIME_ROOT = path.resolve(__filename, relativePathToRuntimeRoot);\n\nconst moduleFactories: ModuleFactories = Object.create(null);\nconst moduleCache: ModuleCache = Object.create(null);\n\nfunction loadChunk(chunkPath: ChunkPath) {\n if (!chunkPath.endsWith(\".js\")) {\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 const resolved = require.resolve(path.resolve(RUNTIME_ROOT, chunkPath));\n delete require.cache[resolved];\n const chunkModules: ModuleFactories = require(resolved);\n\n for (const [moduleId, moduleFactory] of Object.entries(chunkModules)) {\n if (!moduleFactories[moduleId]) {\n moduleFactories[moduleId] = moduleFactory;\n }\n }\n}\n\nfunction loadChunkAsync(source: SourceInfo, chunkPath: string): Promise {\n return new Promise((resolve, reject) => {\n try {\n loadChunk(chunkPath);\n } catch (err) {\n reject(err);\n return;\n }\n resolve();\n });\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 }\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 let parents: ModuleId[];\n switch (source.type) {\n case SourceType.Runtime:\n parents = [];\n break;\n case SourceType.Parent:\n // No need to add this module as a child of the parent module here, this\n // has already been taken care of in `getOrInstantiateModuleFromParent`.\n parents = [source.parentId];\n break;\n }\n\n const module: Module = {\n exports: {},\n error: undefined,\n loaded: false,\n id,\n parents,\n children: [],\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 moduleFactory.call(module.exports, {\n a: asyncModule.bind(null, module),\n e: module.exports,\n r: commonJsRequire.bind(null, module),\n x: externalRequire,\n y: externalImport,\n f: requireContext.bind(null, module),\n i: esmImport.bind(null, module),\n s: esm.bind(null, module.exports),\n j: dynamicExport.bind(null, module, module.exports),\n v: exportValue.bind(null, module),\n n: exportNamespace.bind(null, module),\n m: module,\n c: moduleCache,\n l: loadChunkAsync.bind(null, { type: SourceType.Parent, parentId: id }),\n g: globalThis,\n __dirname: module.id.replace(/(^|\\/)[\\/]+$/, \"\"),\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 */\nfunction getOrInstantiateModuleFromParent(\n id: ModuleId,\n sourceModule: Module\n): Module {\n const module = moduleCache[id];\n\n if (sourceModule.children.indexOf(id) === -1) {\n sourceModule.children.push(id);\n }\n\n if (module) {\n if (module.parents.indexOf(sourceModule.id) === -1) {\n module.parents.push(sourceModule.id);\n }\n\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 */\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\nmodule.exports = {\n getOrInstantiateRuntimeModule,\n loadChunk,\n};\n"],"names":[],"mappings":";IAKA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CAAC,QAAQ,CAAC,GAAG;QAC5C,aAAa,QAAQ,CAAC,IAAI,CAAC;IAC7B;IAEA,IAAI,SAAQ;QACV,IAAI,QAAO,OAAO,CAAC,OAAO,CAAC,aAAa,EAAE,MAAM,CAAC,GAAG;YAClD,QAAO,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE;QACrC;QAEA,OAAO;IACT;IAEA,OAAO,kBAAkB,IAAI;QAC3B,MAAM,WAAW,MAAM;QACvB,UAAU,aAAa,EAAE;IAC3B;AACF;AAKA,SAAS,yBACP,QAAkB,EAClB,SAAoB;IAEpB,OAAO,kBAAkB,UAAU;QAAE,MAAM,WAAW,OAAO;QAAE;IAAU;AAC3E;AAKA,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,OAAO,OAAO,GAAG;IACf;IACA;AACF"}}] + {"offset": {"line": 1, "column": 0}, "map": {"version":3,"sources":["/turbopack/[turbopack]/shared/runtime-utils.ts"],"sourcesContent":["/**\n * This file contains runtime types and functions that are shared between all\n * TurboPack ECMAScript runtimes.\n *\n * It will be prepended to the runtime code of each runtime.\n */\n\n/* eslint-disable @next/next/no-assign-module-variable */\n\n/// \n\ninterface Exports {\n __esModule?: boolean;\n\n [key: string]: any;\n}\n\ntype EsmNamespaceObject = Record;\n\nconst REEXPORTED_OBJECTS = Symbol(\"reexported objects\");\n\ninterface BaseModule {\n exports: Exports | Promise | AsyncModulePromise;\n error: Error | undefined;\n loaded: boolean;\n id: ModuleId;\n children: ModuleId[];\n parents: ModuleId[];\n namespaceObject?:\n | EsmNamespaceObject\n | Promise\n | AsyncModulePromise;\n [REEXPORTED_OBJECTS]?: any[];\n}\n\ninterface Module extends BaseModule {}\n\ntype RequireContextMap = Record;\n\ninterface RequireContextEntry {\n id: () => ModuleId;\n}\n\ninterface RequireContext {\n (moduleId: ModuleId): Exports | EsmNamespaceObject;\n\n keys(): ModuleId[];\n\n resolve(moduleId: ModuleId): ModuleId;\n}\n\ntype GetOrInstantiateModuleFromParent = (\n moduleId: ModuleId,\n parentModule: Module\n) => Module;\n\ntype CommonJsRequireContext = (\n entry: RequireContextEntry,\n parentModule: Module\n) => Exports;\n\nconst hasOwnProperty = Object.prototype.hasOwnProperty;\nconst toStringTag = typeof Symbol !== \"undefined\" && Symbol.toStringTag;\n\nfunction defineProp(\n obj: any,\n name: PropertyKey,\n options: PropertyDescriptor & ThisType\n) {\n if (!hasOwnProperty.call(obj, name))\n Object.defineProperty(obj, name, options);\n}\n\n/**\n * Adds the getters to the exports object.\n */\nfunction esm(exports: Exports, getters: Record any>) {\n defineProp(exports, \"__esModule\", { value: true });\n if (toStringTag) defineProp(exports, toStringTag, { value: \"Module\" });\n for (const key in getters) {\n defineProp(exports, key, { get: getters[key], enumerable: true });\n }\n}\n\n/**\n * Makes the module an ESM with exports\n */\nfunction esmExport(\n module: Module,\n exports: Exports,\n getters: Record any>\n) {\n module.namespaceObject = module.exports;\n esm(exports, getters);\n}\n\n/**\n * Dynamically exports properties from an object\n */\nfunction dynamicExport(\n module: Module,\n exports: Exports,\n object: Record\n) {\n const keys = Reflect.ownKeys(exports);\n\n for (const key of Reflect.ownKeys(object)) {\n if (key !== \"default\" && !keys.includes(key)) {\n defineProp(exports, key, {\n get: createGetter(object, key),\n enumerable: true,\n });\n }\n }\n}\n\nfunction exportValue(module: Module, value: any) {\n module.exports = value;\n}\n\nfunction exportNamespace(module: Module, namespace: any) {\n module.exports = module.namespaceObject = namespace;\n}\n\nfunction createGetter(obj: Record, key: string | symbol) {\n return () => obj[key];\n}\n\n/**\n * @returns prototype of the object\n */\nconst getProto: (obj: any) => any = Object.getPrototypeOf\n ? (obj) => Object.getPrototypeOf(obj)\n : (obj) => obj.__proto__;\n\n/** Prototypes that are not expanded for exports */\nconst LEAF_PROTOTYPES = [null, getProto({}), getProto([]), getProto(getProto)];\n\n/**\n * @param raw\n * @param ns\n * @param allowExportDefault\n * * `false`: will have the raw module as default export\n * * `true`: will have the default property as default export\n */\nfunction interopEsm(\n raw: Exports,\n ns: EsmNamespaceObject,\n allowExportDefault?: boolean\n) {\n const getters: { [s: string]: () => any } = Object.create(null);\n for (\n let current = raw;\n (typeof current === \"object\" || typeof current === \"function\") &&\n !LEAF_PROTOTYPES.includes(current);\n current = getProto(current)\n ) {\n for (const key of Object.getOwnPropertyNames(current)) {\n getters[key] = createGetter(raw, key);\n }\n }\n\n // this is not really correct\n // we should set the `default` getter if the imported module is a `.cjs file`\n if (!(allowExportDefault && \"default\" in getters)) {\n getters[\"default\"] = () => raw;\n }\n\n esm(ns, getters);\n return ns;\n}\n\nfunction esmImport(\n sourceModule: Module,\n id: ModuleId\n): Exclude {\n const module = getOrInstantiateModuleFromParent(id, sourceModule);\n if (module.error) throw module.error;\n\n // Any ES module has to have `module.namespaceObject` defined.\n if (module.namespaceObject) return module.namespaceObject;\n\n // only ESM can be an async module, so we don't need to worry about exports being a promise.\n const raw = module.exports;\n return (module.namespaceObject = interopEsm(\n raw,\n {},\n (raw as any).__esModule\n ));\n}\n\nfunction commonJsRequire(sourceModule: Module, id: ModuleId): Exports {\n const module = getOrInstantiateModuleFromParent(id, sourceModule);\n if (module.error) throw module.error;\n return module.exports;\n}\n\ntype RequireContextFactory = (map: RequireContextMap) => RequireContext;\n\nfunction requireContext(\n sourceModule: Module,\n map: RequireContextMap\n): RequireContext {\n function requireContext(id: ModuleId): Exports {\n const entry = map[id];\n\n if (!entry) {\n throw new Error(\n `module ${id} is required from a require.context, but is not in the context`\n );\n }\n\n return commonJsRequireContext(entry, sourceModule);\n }\n\n requireContext.keys = (): ModuleId[] => {\n return Object.keys(map);\n };\n\n requireContext.resolve = (id: ModuleId): ModuleId => {\n const entry = map[id];\n\n if (!entry) {\n throw new Error(\n `module ${id} is resolved from a require.context, but is not in the context`\n );\n }\n\n return entry.id();\n };\n\n return requireContext;\n}\n\n/**\n * Returns the path of a chunk defined by its data.\n */\nfunction getChunkPath(chunkData: ChunkData): ChunkPath {\n return typeof chunkData === \"string\" ? chunkData : chunkData.path;\n}\n\nfunction isPromise(maybePromise: any): maybePromise is Promise {\n return (\n maybePromise != null &&\n typeof maybePromise === \"object\" &&\n \"then\" in maybePromise &&\n typeof maybePromise.then === \"function\"\n );\n}\n\nfunction isAsyncModuleExt(obj: T): obj is AsyncModuleExt & T {\n return turbopackQueues in obj;\n}\n\nfunction maybeWrapAsyncModulePromise(\n promise: Promise,\n then: (val: T) => U | PromiseLike\n): typeof promise extends AsyncModulePromise\n ? AsyncModulePromise\n : Promise {\n const newPromise = promise.then(then);\n\n if (isAsyncModuleExt(promise)) {\n Object.assign(newPromise, {\n get [turbopackExports]() {\n return promise[turbopackExports];\n },\n get [turbopackQueues]() {\n return promise[turbopackQueues];\n },\n get [turbopackError]() {\n return promise[turbopackError];\n },\n } satisfies AsyncModuleExt);\n }\n\n return newPromise as any;\n}\n\nfunction createPromise() {\n let resolve: (value: T | PromiseLike) => void;\n let reject: (reason?: any) => void;\n\n const promise = new Promise((res, rej) => {\n reject = rej;\n resolve = res;\n });\n\n return {\n promise,\n resolve: resolve!,\n reject: reject!,\n };\n}\n\n// everything below is adapted from webpack\n// https://github.com/webpack/webpack/blob/6be4065ade1e252c1d8dcba4af0f43e32af1bdc1/lib/runtime/AsyncModuleRuntimeModule.js#L13\n\nconst turbopackQueues = Symbol(\"turbopack queues\");\nconst turbopackExports = Symbol(\"turbopack exports\");\nconst turbopackError = Symbol(\"turbopack error\");\n\ntype AsyncQueueFn = (() => void) & { queueCount: number };\ntype AsyncQueue = AsyncQueueFn[] & { resolved: boolean };\n\nfunction resolveQueue(queue?: AsyncQueue) {\n if (queue && !queue.resolved) {\n queue.resolved = true;\n queue.forEach((fn) => fn.queueCount--);\n queue.forEach((fn) => (fn.queueCount-- ? fn.queueCount++ : fn()));\n }\n}\n\ntype Dep = Exports | AsyncModulePromise | Promise;\n\ntype AsyncModuleExt = {\n [turbopackQueues]: (fn: (queue: AsyncQueue) => void) => void;\n [turbopackExports]: Exports;\n [turbopackError]?: any;\n};\n\ntype AsyncModulePromise = Promise & AsyncModuleExt;\n\nfunction wrapDeps(deps: Dep[]): AsyncModuleExt[] {\n return deps.map((dep) => {\n if (dep !== null && typeof dep === \"object\") {\n if (isAsyncModuleExt(dep)) return dep;\n if (isPromise(dep)) {\n const queue: AsyncQueue = Object.assign([], { resolved: false });\n\n const obj: AsyncModuleExt = {\n [turbopackExports]: {},\n [turbopackQueues]: (fn: (queue: AsyncQueue) => void) => fn(queue),\n };\n\n dep.then(\n (res) => {\n obj[turbopackExports] = res;\n resolveQueue(queue);\n },\n (err) => {\n obj[turbopackError] = err;\n resolveQueue(queue);\n }\n );\n\n return obj;\n }\n }\n\n const ret: AsyncModuleExt = {\n [turbopackExports]: dep,\n [turbopackQueues]: () => {},\n };\n\n return ret;\n });\n}\n\nfunction asyncModule(\n module: Module,\n body: (\n handleAsyncDependencies: (\n deps: Dep[]\n ) => Exports[] | Promise<() => Exports[]>,\n asyncResult: (err?: any) => void\n ) => void,\n hasAwait: boolean\n) {\n const queue: AsyncQueue | undefined = hasAwait\n ? Object.assign([], { resolved: true })\n : undefined;\n\n const depQueues: Set = new Set();\n const exports = module.exports;\n\n const { resolve, reject, promise: rawPromise } = createPromise();\n\n const promise: AsyncModulePromise = Object.assign(rawPromise, {\n [turbopackExports]: exports,\n [turbopackQueues]: (fn) => {\n queue && fn(queue);\n depQueues.forEach(fn);\n promise[\"catch\"](() => {});\n },\n } satisfies AsyncModuleExt);\n\n module.exports = module.namespaceObject = promise;\n\n function handleAsyncDependencies(deps: Dep[]) {\n const currentDeps = wrapDeps(deps);\n\n const getResult = () =>\n currentDeps.map((d) => {\n if (d[turbopackError]) throw d[turbopackError];\n return d[turbopackExports];\n });\n\n const { promise, resolve } = createPromise<() => Exports[]>();\n\n const fn: AsyncQueueFn = Object.assign(() => resolve(getResult), {\n queueCount: 0,\n });\n\n function fnQueue(q: AsyncQueue) {\n if (q !== queue && !depQueues.has(q)) {\n depQueues.add(q);\n if (q && !q.resolved) {\n fn.queueCount++;\n q.push(fn);\n }\n }\n }\n\n currentDeps.map((dep) => dep[turbopackQueues](fnQueue));\n\n return fn.queueCount ? promise : getResult();\n }\n\n function asyncResult(err?: any) {\n if (err) {\n reject((promise[turbopackError] = err));\n } else {\n resolve(exports);\n }\n\n resolveQueue(queue);\n }\n\n body(handleAsyncDependencies, asyncResult);\n\n if (queue) {\n queue.resolved = false;\n }\n}\n"],"names":[],"mappings":";AAmBA,MAAM,qBAAqB,OAAO;;;;;AA0ClC,MAAM,iBAAiB,OAAO,SAAS,CAAC,cAAc;AACtD,MAAM,cAAc,OAAO,WAAW,eAAe,OAAO,WAAW;AAEvE,SAAS,WACP,GAAQ,EACR,IAAiB,EACjB,OAA2C;IAE3C,IAAI,CAAC,eAAe,IAAI,CAAC,KAAK,OAC5B,OAAO,cAAc,CAAC,KAAK,MAAM;AACrC;AAKA,SAAS,IAAI,OAAgB,EAAE,OAAkC;IAC/D,WAAW,SAAS,cAAc;QAAE,OAAO;IAAK;IAChD,IAAI,aAAa,WAAW,SAAS,aAAa;QAAE,OAAO;IAAS;IACpE,IAAK,MAAM,OAAO,QAAS;QACzB,WAAW,SAAS,KAAK;YAAE,KAAK,OAAO,CAAC,IAAI;YAAE,YAAY;QAAK;IACjE;AACF;AAKA,SAAS,UACP,MAAc,EACd,OAAgB,EAChB,OAAkC;IAElC,OAAO,eAAe,GAAG,OAAO,OAAO;IACvC,IAAI,SAAS;AACf;AAKA,SAAS,cACP,MAAc,EACd,OAAgB,EAChB,MAA2B;IAE3B,MAAM,OAAO,QAAQ,OAAO,CAAC;IAE7B,KAAK,MAAM,OAAO,QAAQ,OAAO,CAAC,QAAS;QACzC,IAAI,QAAQ,aAAa,CAAC,KAAK,QAAQ,CAAC,MAAM;YAC5C,WAAW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 0}, "map": {"version":3,"sources":["/turbopack/[turbopack]/shared-node/require.ts"],"sourcesContent":["/// \n\ninterface RequireContextEntry {\n external: boolean;\n}\n\nfunction commonJsRequireContext(\n entry: RequireContextEntry,\n sourceModule: Module\n): Exports {\n return entry.external\n ? externalRequire(entry.id(), false)\n : commonJsRequire(sourceModule, entry.id());\n}\n\nfunction externalImport(id: ModuleId) {\n return import(id);\n}\n\nfunction externalRequire(\n id: ModuleId,\n esm: boolean = false\n): Exports | EsmNamespaceObject {\n let raw;\n try {\n raw = require(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 (!esm || raw.__esModule) {\n return raw;\n }\n\n return interopEsm(raw, {}, true);\n}\nexternalRequire.resolve = (\n id: string,\n options?:\n | {\n paths?: string[] | undefined;\n }\n | undefined\n) => {\n return require.resolve(id, options);\n};\n"],"names":[],"mappings":";AAMA,SAAS,uBACP,KAA0B,EAC1B,YAAoB;IAEpB,OAAO,MAAM,QAAQ,GACjB,gBAAgB,MAAM,EAAE,IAAI,SAC5B,gBAAgB,cAAc,MAAM,EAAE;AAC5C;AAEA,SAAS,eAAe,EAAY;IAClC,OAAO,MAAM,CAAC;AAChB;AAEA,SAAS,gBACP,EAAY,EACZ,MAAe,KAAK;IAEpB,IAAI;IACJ,IAAI;QACF,MAAM,QAAQ;IAChB,EAAE,OAAO,KAAK;QAKZ,MAAM,IAAI,MAAM,CAAC,+BAA+B,EAAE,GAAG,EAAE,EAAE,IAAI,CAAC;IAChE;IAEA,IAAI,CAAC,OAAO,IAAI,UAAU,EAAE;QAC1B,OAAO;IACT;IAEA,OAAO,WAAW,KAAK,CAAC,GAAG;AAC7B;AACA,gBAAgB,OAAO,GAAG,CACxB,IACA;IAMA,OAAO,QAAQ,OAAO,CAAC,IAAI;AAC7B"}}, + {"offset": {"line": 253, "column": 0}, "map": {"version":3,"sources":["/turbopack/[turbopack]/build/runtime.ts"],"sourcesContent":["/// \n/// \n\ndeclare var RUNTIME_PUBLIC_PATH: string;\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\ntype ExternalRequire = (id: ModuleId) => Exports | EsmNamespaceObject;\ntype ExternalImport = (id: ModuleId) => Promise;\n\ninterface TurbopackNodeBuildContext extends TurbopackBaseContext {\n x: ExternalRequire;\n y: ExternalImport;\n}\n\ntype ModuleFactory = (\n this: Module[\"exports\"],\n context: TurbopackNodeBuildContext\n) => undefined;\n\nconst path = require(\"path\");\nconst relativePathToRuntimeRoot = path.relative(RUNTIME_PUBLIC_PATH, \".\");\nconst RUNTIME_ROOT = path.resolve(__filename, relativePathToRuntimeRoot);\n\nconst moduleFactories: ModuleFactories = Object.create(null);\nconst moduleCache: ModuleCache = Object.create(null);\n\nfunction loadChunk(chunkPath: ChunkPath) {\n if (!chunkPath.endsWith(\".js\")) {\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 const resolved = require.resolve(path.resolve(RUNTIME_ROOT, chunkPath));\n delete require.cache[resolved];\n const chunkModules: ModuleFactories = require(resolved);\n\n for (const [moduleId, moduleFactory] of Object.entries(chunkModules)) {\n if (!moduleFactories[moduleId]) {\n moduleFactories[moduleId] = moduleFactory;\n }\n }\n}\n\nfunction loadChunkAsync(source: SourceInfo, chunkPath: string): Promise {\n return new Promise((resolve, reject) => {\n try {\n loadChunk(chunkPath);\n } catch (err) {\n reject(err);\n return;\n }\n resolve();\n });\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 }\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 let parents: ModuleId[];\n switch (source.type) {\n case SourceType.Runtime:\n parents = [];\n break;\n case SourceType.Parent:\n // No need to add this module as a child of the parent module here, this\n // has already been taken care of in `getOrInstantiateModuleFromParent`.\n parents = [source.parentId];\n break;\n }\n\n const module: Module = {\n exports: {},\n error: undefined,\n loaded: false,\n id,\n parents,\n children: [],\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 moduleFactory.call(module.exports, {\n a: asyncModule.bind(null, module),\n e: module.exports,\n r: commonJsRequire.bind(null, module),\n x: externalRequire,\n y: externalImport,\n f: requireContext.bind(null, module),\n i: esmImport.bind(null, module),\n s: esm.bind(null, module.exports),\n j: dynamicExport.bind(null, module, module.exports),\n v: exportValue.bind(null, module),\n n: exportNamespace.bind(null, module),\n m: module,\n c: moduleCache,\n l: loadChunkAsync.bind(null, { type: SourceType.Parent, parentId: id }),\n g: globalThis,\n __dirname: module.id.replace(/(^|\\/)[\\/]+$/, \"\"),\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 */\nfunction getOrInstantiateModuleFromParent(\n id: ModuleId,\n sourceModule: Module\n): Module {\n const module = moduleCache[id];\n\n if (sourceModule.children.indexOf(id) === -1) {\n sourceModule.children.push(id);\n }\n\n if (module) {\n if (module.parents.indexOf(sourceModule.id) === -1) {\n module.parents.push(sourceModule.id);\n }\n\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 */\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\nmodule.exports = {\n getOrInstantiateRuntimeModule,\n loadChunk,\n};\n"],"names":[],"mappings":";IAKA;UAAK,UAAU;IAAV,WAAA,WAKH,aAAU,KAAV;IALG,WAAA,WASH,YAAS,KAAT;GATG,eAAA;;AAmCL,MAAM,OAAO,QAAQ;AACrB,MAAM,4BAA4B,KAAK,QAAQ,CAAC,qBAAqB;AACrE,MAAM,eAAe,KAAK,OAAO,CAAC,YAAY;AAE9C,MAAM,kBAAmC,OAAO,MAAM,CAAC;AACvD,MAAM,cAA2B,OAAO,MAAM,CAAC;AAE/C,SAAS,UAAU,SAAoB;IACrC,IAAI,CAAC,UAAU,QAAQ,CAAC,QAAQ;QAG9B;IACF;IAEA,MAAM,WAAW,QAAQ,OAAO,CAAC,KAAK,OAAO,CAAC,cAAc;IAC5D,OAAO,QAAQ,KAAK,CAAC,SAAS;IAC9B,MAAM,eAAgC,QAAQ;IAE9C,KAAK,MAAM,CAAC,UAAU,cAAc,IAAI,OAAO,OAAO,CAAC,cAAe;QACpE,IAAI,CAAC,eAAe,CAAC,SAAS,EAAE;YAC9B,eAAe,CAA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AAyB,UAAU;AAC5C;AAEA,OAAO,OAAO,GAAG;IACf;IACA;AACF"}}] } \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/79fb1_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_e60ecd.js b/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/79fb1_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_e60ecd.js index 0ba4dcfc02c06..c171fe61ca8ad 100644 --- a/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/79fb1_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_e60ecd.js +++ b/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/79fb1_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_e60ecd.js @@ -39,37 +39,15 @@ function esmExport(module, exports, getters) { esm(exports, getters); } function dynamicExport(module, exports, object) { - let reexportedObjects = module[REEXPORTED_OBJECTS]; - if (!reexportedObjects) { - reexportedObjects = module[REEXPORTED_OBJECTS] = []; - const namespaceObject = new Proxy(exports, { - get (target, prop) { - if (hasOwnProperty.call(target, prop) || prop === "default" || prop === "__esModule") { - return Reflect.get(target, prop); - } - for (const obj of reexportedObjects){ - const value = Reflect.get(obj, prop); - if (value !== undefined) return value; - } - return undefined; - }, - ownKeys (target) { - const keys = Reflect.ownKeys(target); - for (const obj of reexportedObjects){ - for (const key of Reflect.ownKeys(obj)){ - if (key !== "default" && !keys.includes(key)) keys.push(key); - } - } - return keys; - } - }); - if (isPromise(module.namespaceObject)) { - module.exports = module.namespaceObject = maybeWrapAsyncModulePromise(module.namespaceObject, ()=>namespaceObject); - } else { - module.exports = module.namespaceObject = namespaceObject; + const keys = Reflect.ownKeys(exports); + for (const key of Reflect.ownKeys(object)){ + if (key !== "default" && !keys.includes(key)) { + defineProp(exports, key, { + get: createGetter(object, key), + enumerable: true + }); } } - reexportedObjects.push(object); } function exportValue(module, value) { module.exports = value; diff --git a/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/79fb1_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_e60ecd.js.map b/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/79fb1_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_e60ecd.js.map index edccc038dcc28..39f1004022ba0 100644 --- a/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/79fb1_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_e60ecd.js.map +++ b/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/79fb1_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_e60ecd.js.map @@ -1,8 +1,8 @@ { "version": 3, "sections": [ - {"offset": {"line": 11, "column": 0}, "map": {"version":3,"sources":["/turbopack/[turbopack]/shared/runtime-utils.ts"],"sourcesContent":["/**\n * This file contains runtime types and functions that are shared between all\n * TurboPack ECMAScript runtimes.\n *\n * It will be prepended to the runtime code of each runtime.\n */\n\n/* eslint-disable @next/next/no-assign-module-variable */\n\n/// \n\ninterface Exports {\n __esModule?: boolean;\n\n [key: string]: any;\n}\n\ntype EsmNamespaceObject = Record;\n\nconst REEXPORTED_OBJECTS = Symbol(\"reexported objects\");\n\ninterface BaseModule {\n exports: Exports | Promise | AsyncModulePromise;\n error: Error | undefined;\n loaded: boolean;\n id: ModuleId;\n children: ModuleId[];\n parents: ModuleId[];\n namespaceObject?:\n | EsmNamespaceObject\n | Promise\n | AsyncModulePromise;\n [REEXPORTED_OBJECTS]?: any[];\n}\n\ninterface Module extends BaseModule {}\n\ntype RequireContextMap = Record;\n\ninterface RequireContextEntry {\n id: () => ModuleId;\n}\n\ninterface RequireContext {\n (moduleId: ModuleId): Exports | EsmNamespaceObject;\n\n keys(): ModuleId[];\n\n resolve(moduleId: ModuleId): ModuleId;\n}\n\ntype GetOrInstantiateModuleFromParent = (\n moduleId: ModuleId,\n parentModule: Module\n) => Module;\n\ntype CommonJsRequireContext = (\n entry: RequireContextEntry,\n parentModule: Module\n) => Exports;\n\nconst hasOwnProperty = Object.prototype.hasOwnProperty;\nconst toStringTag = typeof Symbol !== \"undefined\" && Symbol.toStringTag;\n\nfunction defineProp(\n obj: any,\n name: PropertyKey,\n options: PropertyDescriptor & ThisType\n) {\n if (!hasOwnProperty.call(obj, name))\n Object.defineProperty(obj, name, options);\n}\n\n/**\n * Adds the getters to the exports object.\n */\nfunction esm(exports: Exports, getters: Record any>) {\n defineProp(exports, \"__esModule\", { value: true });\n if (toStringTag) defineProp(exports, toStringTag, { value: \"Module\" });\n for (const key in getters) {\n defineProp(exports, key, { get: getters[key], enumerable: true });\n }\n}\n\n/**\n * Makes the module an ESM with exports\n */\nfunction esmExport(\n module: Module,\n exports: Exports,\n getters: Record any>\n) {\n module.namespaceObject = module.exports;\n esm(exports, getters);\n}\n\n/**\n * Dynamically exports properties from an object\n */\nfunction dynamicExport(\n module: Module,\n exports: Exports,\n object: Record\n) {\n let reexportedObjects = module[REEXPORTED_OBJECTS];\n if (!reexportedObjects) {\n reexportedObjects = module[REEXPORTED_OBJECTS] = [];\n\n const namespaceObject = new Proxy(exports, {\n get(target, prop) {\n if (\n hasOwnProperty.call(target, prop) ||\n prop === \"default\" ||\n prop === \"__esModule\"\n ) {\n return Reflect.get(target, prop);\n }\n for (const obj of reexportedObjects!) {\n const value = Reflect.get(obj, prop);\n if (value !== undefined) return value;\n }\n return undefined;\n },\n ownKeys(target) {\n const keys = Reflect.ownKeys(target);\n for (const obj of reexportedObjects!) {\n for (const key of Reflect.ownKeys(obj)) {\n if (key !== \"default\" && !keys.includes(key)) keys.push(key);\n }\n }\n return keys;\n },\n });\n\n // If this is inside an async module `module.namespaceObject` is a promise,\n // so we need to replace it with a new promise.\n if (isPromise(module.namespaceObject)) {\n module.exports = module.namespaceObject = maybeWrapAsyncModulePromise(\n module.namespaceObject,\n () => namespaceObject\n );\n } else {\n module.exports = module.namespaceObject = namespaceObject;\n }\n }\n reexportedObjects.push(object);\n}\n\nfunction exportValue(module: Module, value: any) {\n module.exports = value;\n}\n\nfunction exportNamespace(module: Module, namespace: any) {\n module.exports = module.namespaceObject = namespace;\n}\n\nfunction createGetter(obj: Record, key: string) {\n return () => obj[key];\n}\n\n/**\n * @returns prototype of the object\n */\nconst getProto: (obj: any) => any = Object.getPrototypeOf\n ? (obj) => Object.getPrototypeOf(obj)\n : (obj) => obj.__proto__;\n\n/** Prototypes that are not expanded for exports */\nconst LEAF_PROTOTYPES = [null, getProto({}), getProto([]), getProto(getProto)];\n\n/**\n * @param raw\n * @param ns\n * @param allowExportDefault\n * * `false`: will have the raw module as default export\n * * `true`: will have the default property as default export\n */\nfunction interopEsm(\n raw: Exports,\n ns: EsmNamespaceObject,\n allowExportDefault?: boolean\n) {\n const getters: { [s: string]: () => any } = Object.create(null);\n for (\n let current = raw;\n (typeof current === \"object\" || typeof current === \"function\") &&\n !LEAF_PROTOTYPES.includes(current);\n current = getProto(current)\n ) {\n for (const key of Object.getOwnPropertyNames(current)) {\n getters[key] = createGetter(raw, key);\n }\n }\n\n // this is not really correct\n // we should set the `default` getter if the imported module is a `.cjs file`\n if (!(allowExportDefault && \"default\" in getters)) {\n getters[\"default\"] = () => raw;\n }\n\n esm(ns, getters);\n return ns;\n}\n\nfunction esmImport(\n sourceModule: Module,\n id: ModuleId\n): Exclude {\n const module = getOrInstantiateModuleFromParent(id, sourceModule);\n if (module.error) throw module.error;\n\n // any async module has to have `module.namespaceObject` defined\n if (module.namespaceObject) return module.namespaceObject;\n\n // can't be an async module at this point\n const raw = module.exports;\n return (module.namespaceObject = interopEsm(\n raw,\n {},\n (raw as any).__esModule\n ));\n}\n\nfunction commonJsRequire(sourceModule: Module, id: ModuleId): Exports {\n const module = getOrInstantiateModuleFromParent(id, sourceModule);\n if (module.error) throw module.error;\n return module.exports;\n}\n\ntype RequireContextFactory = (map: RequireContextMap) => RequireContext;\n\nfunction requireContext(\n sourceModule: Module,\n map: RequireContextMap\n): RequireContext {\n function requireContext(id: ModuleId): Exports {\n const entry = map[id];\n\n if (!entry) {\n throw new Error(\n `module ${id} is required from a require.context, but is not in the context`\n );\n }\n\n return commonJsRequireContext(entry, sourceModule);\n }\n\n requireContext.keys = (): ModuleId[] => {\n return Object.keys(map);\n };\n\n requireContext.resolve = (id: ModuleId): ModuleId => {\n const entry = map[id];\n\n if (!entry) {\n throw new Error(\n `module ${id} is resolved from a require.context, but is not in the context`\n );\n }\n\n return entry.id();\n };\n\n return requireContext;\n}\n\n/**\n * Returns the path of a chunk defined by its data.\n */\nfunction getChunkPath(chunkData: ChunkData): ChunkPath {\n return typeof chunkData === \"string\" ? chunkData : chunkData.path;\n}\n\nfunction isPromise(maybePromise: any): maybePromise is Promise {\n return (\n maybePromise != null &&\n typeof maybePromise === \"object\" &&\n \"then\" in maybePromise &&\n typeof maybePromise.then === \"function\"\n );\n}\n\nfunction isAsyncModuleExt(obj: T): obj is AsyncModuleExt & T {\n return turbopackQueues in obj;\n}\n\nfunction maybeWrapAsyncModulePromise(\n promise: Promise,\n then: (val: T) => U | PromiseLike\n): typeof promise extends AsyncModulePromise\n ? AsyncModulePromise\n : Promise {\n const newPromise = promise.then(then);\n\n if (isAsyncModuleExt(promise)) {\n Object.assign(newPromise, {\n get [turbopackExports]() {\n return promise[turbopackExports];\n },\n get [turbopackQueues]() {\n return promise[turbopackQueues];\n },\n get [turbopackError]() {\n return promise[turbopackError];\n },\n } satisfies AsyncModuleExt);\n }\n\n return newPromise as any;\n}\n\nfunction createPromise() {\n let resolve: (value: T | PromiseLike) => void;\n let reject: (reason?: any) => void;\n\n const promise = new Promise((res, rej) => {\n reject = rej;\n resolve = res;\n });\n\n return {\n promise,\n resolve: resolve!,\n reject: reject!,\n };\n}\n\n// everything below is adapted from webpack\n// https://github.com/webpack/webpack/blob/6be4065ade1e252c1d8dcba4af0f43e32af1bdc1/lib/runtime/AsyncModuleRuntimeModule.js#L13\n\nconst turbopackQueues = Symbol(\"turbopack queues\");\nconst turbopackExports = Symbol(\"turbopack exports\");\nconst turbopackError = Symbol(\"turbopack error\");\n\ntype AsyncQueueFn = (() => void) & { queueCount: number };\ntype AsyncQueue = AsyncQueueFn[] & { resolved: boolean };\n\nfunction resolveQueue(queue?: AsyncQueue) {\n if (queue && !queue.resolved) {\n queue.resolved = true;\n queue.forEach((fn) => fn.queueCount--);\n queue.forEach((fn) => (fn.queueCount-- ? fn.queueCount++ : fn()));\n }\n}\n\ntype Dep = Exports | AsyncModulePromise | Promise;\n\ntype AsyncModuleExt = {\n [turbopackQueues]: (fn: (queue: AsyncQueue) => void) => void;\n [turbopackExports]: Exports;\n [turbopackError]?: any;\n};\n\ntype AsyncModulePromise = Promise & AsyncModuleExt;\n\nfunction wrapDeps(deps: Dep[]): AsyncModuleExt[] {\n return deps.map((dep) => {\n if (dep !== null && typeof dep === \"object\") {\n if (isAsyncModuleExt(dep)) return dep;\n if (isPromise(dep)) {\n const queue: AsyncQueue = Object.assign([], { resolved: false });\n\n const obj: AsyncModuleExt = {\n [turbopackExports]: {},\n [turbopackQueues]: (fn: (queue: AsyncQueue) => void) => fn(queue),\n };\n\n dep.then(\n (res) => {\n obj[turbopackExports] = res;\n resolveQueue(queue);\n },\n (err) => {\n obj[turbopackError] = err;\n resolveQueue(queue);\n }\n );\n\n return obj;\n }\n }\n\n const ret: AsyncModuleExt = {\n [turbopackExports]: dep,\n [turbopackQueues]: () => {},\n };\n\n return ret;\n });\n}\n\nfunction asyncModule(\n module: Module,\n body: (\n handleAsyncDependencies: (\n deps: Dep[]\n ) => Exports[] | Promise<() => Exports[]>,\n asyncResult: (err?: any) => void\n ) => void,\n hasAwait: boolean\n) {\n const queue: AsyncQueue | undefined = hasAwait\n ? Object.assign([], { resolved: true })\n : undefined;\n\n const depQueues: Set = new Set();\n const exports = module.exports;\n\n const { resolve, reject, promise: rawPromise } = createPromise();\n\n const promise: AsyncModulePromise = Object.assign(rawPromise, {\n [turbopackExports]: exports,\n [turbopackQueues]: (fn) => {\n queue && fn(queue);\n depQueues.forEach(fn);\n promise[\"catch\"](() => {});\n },\n } satisfies AsyncModuleExt);\n\n module.exports = module.namespaceObject = promise;\n\n function handleAsyncDependencies(deps: Dep[]) {\n const currentDeps = wrapDeps(deps);\n\n const getResult = () =>\n currentDeps.map((d) => {\n if (d[turbopackError]) throw d[turbopackError];\n return d[turbopackExports];\n });\n\n const { promise, resolve } = createPromise<() => Exports[]>();\n\n const fn: AsyncQueueFn = Object.assign(() => resolve(getResult), {\n queueCount: 0,\n });\n\n function fnQueue(q: AsyncQueue) {\n if (q !== queue && !depQueues.has(q)) {\n depQueues.add(q);\n if (q && !q.resolved) {\n fn.queueCount++;\n q.push(fn);\n }\n }\n }\n\n currentDeps.map((dep) => dep[turbopackQueues](fnQueue));\n\n return fn.queueCount ? promise : getResult();\n }\n\n function asyncResult(err?: any) {\n if (err) {\n reject((promise[turbopackError] = err));\n } else {\n resolve(exports);\n }\n\n resolveQueue(queue);\n }\n\n body(handleAsyncDependencies, asyncResult);\n\n if (queue) {\n queue.resolved = false;\n }\n}\n"],"names":[],"mappings":";AAmBA,MAAM,qBAAqB,OAAO;;;;;AA0ClC,MAAM,iBAAiB,OAAO,SAAS,CAAC,cAAc;AACtD,MAAM,cAAc,OAAO,WAAW,eAAe,OAAO,WAAW;AAEvE,SAAS,WACP,GAAQ,EACR,IAAiB,EACjB,OAA2C;IAE3C,IAAI,CAAC,eAAe,IAAI,CAAC,KAAK,OAC5B,OAAO,cAAc,CAAC,KAAK,MAAM;AACrC;AAKA,SAAS,IAAI,OAAgB,EAAE,OAAkC;IAC/D,WAAW,SAAS,cAAc;QAAE,OAAO;IAAK;IAChD,IAAI,aAAa,WAAW,SAAS,aAAa;QAAE,OAAO;IAAS;IACpE,IAAK,MAAM,OAAO,QAAS;QACzB,WAAW,SAAS,KAAK;YAAE,KAAK,OAAO,CAAC,IAAI;YAAE,YAAY;QAAK;IACjE;AACF;AAKA,SAAS,UACP,MAAc,EACd,OAAgB,EAChB,OAAkC;IAElC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C1B;IACF;IAEA,OAAO,OAAO,GAAG,OAAO,eAAe,GAAG;IAE1C,SAAS,wBAAwB,IAAW;QAC1C,MAAM,cAAc,SAAS;QAE7B,MAAM,YAAY,IAChB,YAAY,GAAG,CAAC,CAAC;gBACf,IAAI,CAAC,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC,eAAe;gBAC9C,OAAO,CAAC,CAAC,iBAAiB;YAC5B;QAEF,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG;QAE7B,MAAM,KAAmB,OAAO,MAAM,CAAC,IAAM,QAAQ,YAAY;YAC/D,YAAY;QACd;QAEA,SAAS,QAAQ,CAAa;YAC5B,IAAI,MAAM,SAAS,CAAC,UAAU,GAAG,CAAC,IAAI;gBACpC,UAAU,GAAG,CAAC;gBACd,IAAI,KAAK,CAAC,EAAE,QAAQ,EAAE;oBACpB,GAAG,UAAU;oBACb,EAAE,IAAI,CAAC;gBACT;YACF;QACF;QAEA,YAAY,GAAG,CAAC,CAAC,MAAQ,GAAG,CAAC,gBAAgB,CAAC;QAE9C,OAAO,GAAG,UAAU,GAAG,UAAU;IACnC;IAEA,SAAS,YAAY,GAAS;QAC5B,IAAI,KAAK;YACP,OAAQ,OAAO,CAAC,eAAe,GAAG;QACpC,OAAO;YACL,QAAQ;QACV;QAEA,aAAa;IACf;IAEA,KAAK,yBAAyB;IAE9B,IAAI,OAAO;QACT,MAAM,QAAQ,GAAG;IACnB;AACF"}}, - {"offset": {"line": 263, "column": 0}, "map": {"version":3,"sources":["/turbopack/[turbopack]/dev/runtime/base/runtime-base.ts"],"sourcesContent":["/**\n * This file contains runtime types and functions that are shared between all\n * Turbopack *development* ECMAScript runtimes.\n *\n * It will be appended to the runtime code of each runtime right after the\n * shared runtime utils.\n */\n\n/* eslint-disable @next/next/no-assign-module-variable */\n\n/// \n/// \n/// \n/// \n\n// This file must not use `import` and `export` statements. Otherwise, it\n// becomes impossible to augment interfaces declared in ``d files\n// (e.g. `Module`). Hence, the need for `import()` here.\ntype RefreshRuntimeGlobals =\n import(\"@next/react-refresh-utils/dist/runtime\").RefreshRuntimeGlobals;\n\ndeclare var CHUNK_BASE_PATH: string;\ndeclare var $RefreshHelpers$: RefreshRuntimeGlobals[\"$RefreshHelpers$\"];\ndeclare var $RefreshReg$: RefreshRuntimeGlobals[\"$RefreshReg$\"];\ndeclare var $RefreshSig$: RefreshRuntimeGlobals[\"$RefreshSig$\"];\ndeclare var $RefreshInterceptModuleExecution$:\n | RefreshRuntimeGlobals[\"$RefreshInterceptModuleExecution$\"];\n\ntype RefreshContext = {\n register: RefreshRuntimeGlobals[\"$RefreshReg$\"];\n signature: RefreshRuntimeGlobals[\"$RefreshSig$\"];\n};\n\ntype RefreshHelpers = RefreshRuntimeGlobals[\"$RefreshHelpers$\"];\n\ninterface TurbopackDevBaseContext extends TurbopackBaseContext {\n k: RefreshContext;\n}\n\ninterface TurbopackDevContext extends TurbopackDevBaseContext {}\n\n// string encoding of a module factory (used in hmr updates)\ntype ModuleFactoryString = string;\n\ntype ModuleFactory = (\n this: Module[\"exports\"],\n context: TurbopackDevContext\n) => undefined;\n\ntype DevRuntimeParams = {\n otherChunks: ChunkData[];\n runtimeModuleIds: ModuleId[];\n};\n\ntype ChunkRegistration = [\n chunkPath: ChunkPath,\n chunkModules: ModuleFactories,\n params: DevRuntimeParams | undefined\n];\ntype ChunkList = {\n path: ChunkPath;\n chunks: ChunkData[];\n source: \"entry\" | \"dynamic\";\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 * The module was instantiated because it was included in a chunk's hot module\n * update.\n */\n Update = 2,\n}\n\ntype SourceInfo =\n | {\n type: SourceType.Runtime;\n chunkPath: ChunkPath;\n }\n | {\n type: SourceType.Parent;\n parentId: ModuleId;\n }\n | {\n type: SourceType.Update;\n parents?: ModuleId[];\n };\n\ninterface RuntimeBackend {\n registerChunk: (chunkPath: ChunkPath, params?: DevRuntimeParams) => void;\n loadChunk: (chunkPath: ChunkPath, source: SourceInfo) => Promise;\n reloadChunk?: (chunkPath: ChunkPath) => Promise;\n unloadChunk?: (chunkPath: ChunkPath) => void;\n\n restart: () => void;\n}\n\nconst moduleFactories: ModuleFactories = Object.create(null);\nconst moduleCache: ModuleCache = Object.create(null);\n/**\n * Maps module IDs to persisted data between executions of their hot module\n * implementation (`hot.data`).\n */\nconst moduleHotData: Map = new Map();\n/**\n * Maps module instances to their hot module state.\n */\nconst moduleHotState: Map = new Map();\n/**\n * Modules that call `module.hot.invalidate()` (while being updated).\n */\nconst queuedInvalidatedModules: Set = new Set();\n/**\n * Module IDs that are instantiated as part of the runtime of a chunk.\n */\nconst runtimeModules: Set = new Set();\n/**\n * Map from module ID to the chunks that contain this module.\n *\n * In HMR, we need to keep track of which modules are contained in which so\n * chunks. This is so we don't eagerly dispose of a module when it is removed\n * from chunk A, but still exists in chunk B.\n */\nconst moduleChunksMap: Map> = new Map();\n/**\n * Map from a chunk path to all modules it contains.\n */\nconst chunkModulesMap: Map> = new Map();\n/**\n * Chunk lists that contain a runtime. When these chunk lists receive an update\n * that can't be reconciled with the current state of the page, we need to\n * reload the runtime entirely.\n */\nconst runtimeChunkLists: Set = new Set();\n/**\n * Map from a chunk list to the chunk paths it contains.\n */\nconst chunkListChunksMap: Map> = new Map();\n/**\n * Map from a chunk path to the chunk lists it belongs to.\n */\nconst chunkChunkListsMap: Map> = new Map();\n\nconst availableModules: Map | true> = new Map();\n\nconst availableModuleChunks: Map | true> = new Map();\n\nasync function loadChunk(\n source: SourceInfo,\n chunkData: ChunkData\n): Promise {\n if (typeof chunkData === \"string\") {\n return loadChunkPath(source, chunkData);\n }\n\n const includedList = chunkData.included || [];\n const modulesPromises = includedList.map((included) => {\n if (moduleFactories[included]) return true;\n return availableModules.get(included);\n });\n if (modulesPromises.length > 0 && modulesPromises.every((p) => p)) {\n // When all included items are already loaded or loading, we can skip loading ourselves\n return Promise.all(modulesPromises);\n }\n\n const includedModuleChunksList = chunkData.moduleChunks || [];\n const moduleChunksPromises = includedModuleChunksList\n .map((included) => {\n // TODO(alexkirsz) Do we need this check?\n // if (moduleFactories[included]) return true;\n return availableModuleChunks.get(included);\n })\n .filter((p) => p);\n\n let promise;\n if (moduleChunksPromises.length > 0) {\n // Some module chunks are already loaded or loading.\n\n if (moduleChunksPromises.length == includedModuleChunksList.length) {\n // When all included module chunks are already loaded or loading, we can skip loading ourselves\n return Promise.all(moduleChunksPromises);\n }\n\n const moduleChunksToLoad: Set = new Set();\n for (const moduleChunk of includedModuleChunksList) {\n if (!availableModuleChunks.has(moduleChunk)) {\n moduleChunksToLoad.add(moduleChunk);\n }\n }\n\n for (const moduleChunkToLoad of moduleChunksToLoad) {\n const promise = loadChunkPath(source, moduleChunkToLoad);\n\n availableModuleChunks.set(moduleChunkToLoad, promise);\n\n moduleChunksPromises.push(promise);\n }\n\n promise = Promise.all(moduleChunksPromises);\n } else {\n promise = loadChunkPath(source, chunkData.path);\n\n // Mark all included module chunks as loading if they are not already loaded or loading.\n for (const includedModuleChunk of includedModuleChunksList) {\n if (!availableModuleChunks.has(includedModuleChunk)) {\n availableModuleChunks.set(includedModuleChunk, promise);\n }\n }\n }\n\n for (const included of includedList) {\n if (!availableModules.has(included)) {\n // It might be better to race old and new promises, but it's rare that the new promise will be faster than a request started earlier.\n // In production it's even more rare, because the chunk optimization tries to deduplicate modules anyway.\n availableModules.set(included, promise);\n }\n }\n\n return promise;\n}\n\nasync function loadChunkPath(\n source: SourceInfo,\n chunkPath: ChunkPath\n): Promise {\n try {\n await BACKEND.loadChunk(chunkPath, source);\n } catch (error) {\n let loadReason;\n switch (source.type) {\n case SourceType.Runtime:\n loadReason = `as a runtime dependency of chunk ${source.chunkPath}`;\n break;\n case SourceType.Parent:\n loadReason = `from module ${source.parentId}`;\n break;\n case SourceType.Update:\n loadReason = \"from an HMR update\";\n break;\n }\n throw new Error(\n `Failed to load chunk ${chunkPath} ${loadReason}${\n error ? `: ${error}` : \"\"\n }`,\n error\n ? {\n cause: error,\n }\n : undefined\n );\n }\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 case SourceType.Update:\n instantiationReason = \"because of an HMR update\";\n break;\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 hotData = moduleHotData.get(id)!;\n const { hot, hotState } = createModuleHot(id, hotData);\n\n let parents: ModuleId[];\n switch (source.type) {\n case SourceType.Runtime:\n runtimeModules.add(id);\n parents = [];\n break;\n case SourceType.Parent:\n // No need to add this module as a child of the parent module here, this\n // has already been taken care of in `getOrInstantiateModuleFromParent`.\n parents = [source.parentId];\n break;\n case SourceType.Update:\n parents = source.parents || [];\n break;\n }\n const module: Module = {\n exports: {},\n error: undefined,\n loaded: false,\n id,\n parents,\n children: [],\n namespaceObject: undefined,\n hot,\n };\n\n moduleCache[id] = module;\n moduleHotState.set(module, hotState);\n\n // NOTE(alexkirsz) This can fail when the module encounters a runtime error.\n try {\n runModuleExecutionHooks(module, (refresh) => {\n moduleFactory.call(\n module.exports,\n augmentContext({\n a: asyncModule.bind(null, module),\n e: module.exports,\n r: commonJsRequire.bind(null, module),\n f: requireContext.bind(null, module),\n i: esmImport.bind(null, module),\n s: esmExport.bind(null, module, module.exports),\n j: dynamicExport.bind(null, module, module.exports),\n v: exportValue.bind(null, module),\n n: exportNamespace.bind(null, module),\n m: module,\n c: moduleCache,\n l: loadChunk.bind(null, { type: SourceType.Parent, parentId: id }),\n g: globalThis,\n k: refresh,\n __dirname: module.id.replace(/(^|\\/)\\/+$/, \"\"),\n })\n );\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 * NOTE(alexkirsz) Webpack has a \"module execution\" interception hook that\n * Next.js' React Refresh runtime hooks into to add module context to the\n * refresh registry.\n */\nfunction runModuleExecutionHooks(\n module: Module,\n executeModule: (ctx: RefreshContext) => void\n) {\n const cleanupReactRefreshIntercept =\n typeof globalThis.$RefreshInterceptModuleExecution$ === \"function\"\n ? globalThis.$RefreshInterceptModuleExecution$(module.id)\n : () => {};\n\n try {\n executeModule({\n register: globalThis.$RefreshReg$,\n signature: globalThis.$RefreshSig$,\n });\n\n if (\"$RefreshHelpers$\" in globalThis) {\n // This pattern can also be used to register the exports of\n // a module with the React Refresh runtime.\n registerExportsAndSetupBoundaryForReactRefresh(\n module,\n globalThis.$RefreshHelpers$\n );\n }\n } catch (e) {\n throw e;\n } finally {\n // Always cleanup the intercept, even if module execution failed.\n cleanupReactRefreshIntercept();\n }\n}\n\n/**\n * Retrieves a module from the cache, or instantiate it if it is not cached.\n */\nconst getOrInstantiateModuleFromParent: GetOrInstantiateModuleFromParent = (\n id,\n sourceModule\n) => {\n if (!sourceModule.hot.active) {\n console.warn(\n `Unexpected import of module ${id} from module ${sourceModule.id}, which was deleted by an HMR update`\n );\n }\n\n const module = moduleCache[id];\n\n if (sourceModule.children.indexOf(id) === -1) {\n sourceModule.children.push(id);\n }\n\n if (module) {\n if (module.parents.indexOf(sourceModule.id) === -1) {\n module.parents.push(sourceModule.id);\n }\n\n return module;\n }\n\n return instantiateModule(id, {\n type: SourceType.Parent,\n parentId: sourceModule.id,\n });\n};\n\n/**\n * This is adapted from https://github.com/vercel/next.js/blob/3466862d9dc9c8bb3131712134d38757b918d1c0/packages/react-refresh-utils/internal/ReactRefreshModule.runtime.ts\n */\nfunction registerExportsAndSetupBoundaryForReactRefresh(\n module: Module,\n helpers: RefreshHelpers\n) {\n const currentExports = module.exports;\n const prevExports = module.hot.data.prevExports ?? null;\n\n helpers.registerExportsForReactRefresh(currentExports, module.id);\n\n // A module can be accepted automatically based on its exports, e.g. when\n // it is a Refresh Boundary.\n if (helpers.isReactRefreshBoundary(currentExports)) {\n // Save the previous exports on update, so we can compare the boundary\n // signatures.\n module.hot.dispose((data) => {\n data.prevExports = currentExports;\n });\n // Unconditionally accept an update to this module, we'll check if it's\n // still a Refresh Boundary later.\n module.hot.accept();\n\n // This field is set when the previous version of this module was a\n // Refresh Boundary, letting us know we need to check for invalidation or\n // enqueue an update.\n if (prevExports !== null) {\n // A boundary can become ineligible if its exports are incompatible\n // with the previous exports.\n //\n // For example, if you add/remove/change exports, we'll want to\n // re-execute the importing modules, and force those components to\n // re-render. Similarly, if you convert a class component to a\n // function, we want to invalidate the boundary.\n if (\n helpers.shouldInvalidateReactRefreshBoundary(\n prevExports,\n currentExports\n )\n ) {\n module.hot.invalidate();\n } else {\n helpers.scheduleUpdate();\n }\n }\n } else {\n // Since we just executed the code for the module, it's possible that the\n // new exports made it ineligible for being a boundary.\n // We only care about the case when we were _previously_ a boundary,\n // because we already accepted this update (accidental side effect).\n const isNoLongerABoundary = prevExports !== null;\n if (isNoLongerABoundary) {\n module.hot.invalidate();\n }\n }\n}\n\nfunction formatDependencyChain(dependencyChain: ModuleId[]): string {\n return `Dependency chain: ${dependencyChain.join(\" -> \")}`;\n}\n\nfunction computeOutdatedModules(\n added: Map,\n modified: Map\n): {\n outdatedModules: Set;\n newModuleFactories: Map;\n} {\n const newModuleFactories = new Map();\n\n for (const [moduleId, entry] of added) {\n if (entry != null) {\n newModuleFactories.set(moduleId, _eval(entry));\n }\n }\n\n const outdatedModules = computedInvalidatedModules(modified.keys());\n\n for (const [moduleId, entry] of modified) {\n newModuleFactories.set(moduleId, _eval(entry));\n }\n\n return { outdatedModules, newModuleFactories };\n}\n\nfunction computedInvalidatedModules(\n invalidated: Iterable\n): Set {\n const outdatedModules = new Set();\n\n for (const moduleId of invalidated) {\n const effect = getAffectedModuleEffects(moduleId);\n\n switch (effect.type) {\n case \"unaccepted\":\n throw new Error(\n `cannot apply update: unaccepted module. ${formatDependencyChain(\n effect.dependencyChain\n )}.`\n );\n case \"self-declined\":\n throw new Error(\n `cannot apply update: self-declined module. ${formatDependencyChain(\n effect.dependencyChain\n )}.`\n );\n case \"accepted\":\n for (const outdatedModuleId of effect.outdatedModules) {\n outdatedModules.add(outdatedModuleId);\n }\n break;\n // TODO(alexkirsz) Dependencies: handle dependencies effects.\n }\n }\n\n return outdatedModules;\n}\n\nfunction computeOutdatedSelfAcceptedModules(\n outdatedModules: Iterable\n): { moduleId: ModuleId; errorHandler: true | Function }[] {\n const outdatedSelfAcceptedModules = [];\n for (const moduleId of outdatedModules) {\n const module = moduleCache[moduleId];\n const hotState = moduleHotState.get(module)!;\n if (module && hotState.selfAccepted && !hotState.selfInvalidated) {\n outdatedSelfAcceptedModules.push({\n moduleId,\n errorHandler: hotState.selfAccepted,\n });\n }\n }\n return outdatedSelfAcceptedModules;\n}\n\n/**\n * Adds, deletes, and moves modules between chunks. This must happen before the\n * dispose phase as it needs to know which modules were removed from all chunks,\n * which we can only compute *after* taking care of added and moved modules.\n */\nfunction updateChunksPhase(\n chunksAddedModules: Map>,\n chunksDeletedModules: Map>\n): { disposedModules: Set } {\n for (const [chunkPath, addedModuleIds] of chunksAddedModules) {\n for (const moduleId of addedModuleIds) {\n addModuleToChunk(moduleId, chunkPath);\n }\n }\n\n const disposedModules: Set = new Set();\n for (const [chunkPath, addedModuleIds] of chunksDeletedModules) {\n for (const moduleId of addedModuleIds) {\n if (removeModuleFromChunk(moduleId, chunkPath)) {\n disposedModules.add(moduleId);\n }\n }\n }\n\n return { disposedModules };\n}\n\nfunction disposePhase(\n outdatedModules: Iterable,\n disposedModules: Iterable\n): { outdatedModuleParents: Map> } {\n for (const moduleId of outdatedModules) {\n disposeModule(moduleId, \"replace\");\n }\n\n for (const moduleId of disposedModules) {\n disposeModule(moduleId, \"clear\");\n }\n\n // Removing modules from the module cache is a separate step.\n // We also want to keep track of previous parents of the outdated modules.\n const outdatedModuleParents = new Map();\n for (const moduleId of outdatedModules) {\n const oldModule = moduleCache[moduleId];\n outdatedModuleParents.set(moduleId, oldModule?.parents);\n delete moduleCache[moduleId];\n }\n\n // TODO(alexkirsz) Dependencies: remove outdated dependency from module\n // children.\n\n return { outdatedModuleParents };\n}\n\n/**\n * Disposes of an instance of a module.\n *\n * Returns the persistent hot data that should be kept for the next module\n * instance.\n *\n * NOTE: mode = \"replace\" will not remove modules from the moduleCache.\n * This must be done in a separate step afterwards.\n * This is important because all modules need to be disposed to update the\n * parent/child relationships before they are actually removed from the moduleCache.\n * If this was done in this method, the following disposeModule calls won't find\n * the module from the module id in the cache.\n */\nfunction disposeModule(moduleId: ModuleId, mode: \"clear\" | \"replace\") {\n const module = moduleCache[moduleId];\n if (!module) {\n return;\n }\n\n const hotState = moduleHotState.get(module)!;\n const data = {};\n\n // Run the `hot.dispose` handler, if any, passing in the persistent\n // `hot.data` object.\n for (const disposeHandler of hotState.disposeHandlers) {\n disposeHandler(data);\n }\n\n // This used to warn in `getOrInstantiateModuleFromParent` when a disposed\n // module is still importing other modules.\n module.hot.active = false;\n\n moduleHotState.delete(module);\n\n // TODO(alexkirsz) Dependencies: delete the module from outdated deps.\n\n // Remove the disposed module from its children's parent list.\n // It will be added back once the module re-instantiates and imports its\n // children again.\n for (const childId of module.children) {\n const child = moduleCache[childId];\n if (!child) {\n continue;\n }\n\n const idx = child.parents.indexOf(module.id);\n if (idx >= 0) {\n child.parents.splice(idx, 1);\n }\n }\n\n switch (mode) {\n case \"clear\":\n delete moduleCache[module.id];\n moduleHotData.delete(module.id);\n break;\n case \"replace\":\n moduleHotData.set(module.id, data);\n break;\n default:\n invariant(mode, (mode) => `invalid mode: ${mode}`);\n }\n}\n\nfunction applyPhase(\n outdatedSelfAcceptedModules: {\n moduleId: ModuleId;\n errorHandler: true | Function;\n }[],\n newModuleFactories: Map,\n outdatedModuleParents: Map>,\n reportError: (err: any) => void\n) {\n // Update module factories.\n for (const [moduleId, factory] of newModuleFactories.entries()) {\n moduleFactories[moduleId] = factory;\n }\n\n // TODO(alexkirsz) Run new runtime entries here.\n\n // TODO(alexkirsz) Dependencies: call accept handlers for outdated deps.\n\n // Re-instantiate all outdated self-accepted modules.\n for (const { moduleId, errorHandler } of outdatedSelfAcceptedModules) {\n try {\n instantiateModule(moduleId, {\n type: SourceType.Update,\n parents: outdatedModuleParents.get(moduleId),\n });\n } catch (err) {\n if (typeof errorHandler === \"function\") {\n try {\n errorHandler(err, { moduleId, module: moduleCache[moduleId] });\n } catch (err2) {\n reportError(err2);\n reportError(err);\n }\n } else {\n reportError(err);\n }\n }\n }\n}\n\n/**\n * Utility function to ensure all variants of an enum are handled.\n */\nfunction invariant(never: never, computeMessage: (arg: any) => string): never {\n throw new Error(`Invariant: ${computeMessage(never)}`);\n}\n\nfunction applyUpdate(chunkListPath: ChunkPath, update: PartialUpdate) {\n switch (update.type) {\n case \"ChunkListUpdate\":\n applyChunkListUpdate(chunkListPath, update);\n break;\n default:\n invariant(update, (update) => `Unknown update type: ${update.type}`);\n }\n}\n\nfunction applyChunkListUpdate(\n chunkListPath: ChunkPath,\n update: ChunkListUpdate\n) {\n if (update.merged != null) {\n for (const merged of update.merged) {\n switch (merged.type) {\n case \"EcmascriptMergedUpdate\":\n applyEcmascriptMergedUpdate(chunkListPath, merged);\n break;\n default:\n invariant(merged, (merged) => `Unknown merged type: ${merged.type}`);\n }\n }\n }\n\n if (update.chunks != null) {\n for (const [chunkPath, chunkUpdate] of Object.entries(update.chunks)) {\n switch (chunkUpdate.type) {\n case \"added\":\n BACKEND.loadChunk(chunkPath, { type: SourceType.Update });\n break;\n case \"total\":\n BACKEND.reloadChunk?.(chunkPath);\n break;\n case \"deleted\":\n BACKEND.unloadChunk?.(chunkPath);\n break;\n case \"partial\":\n invariant(\n chunkUpdate.instruction,\n (instruction) =>\n `Unknown partial instruction: ${JSON.stringify(instruction)}.`\n );\n default:\n invariant(\n chunkUpdate,\n (chunkUpdate) => `Unknown chunk update type: ${chunkUpdate.type}`\n );\n }\n }\n }\n}\n\nfunction applyEcmascriptMergedUpdate(\n chunkPath: ChunkPath,\n update: EcmascriptMergedUpdate\n) {\n const { entries = {}, chunks = {} } = update;\n const { added, modified, chunksAdded, chunksDeleted } = computeChangedModules(\n entries,\n chunks\n );\n const { outdatedModules, newModuleFactories } = computeOutdatedModules(\n added,\n modified\n );\n const { disposedModules } = updateChunksPhase(chunksAdded, chunksDeleted);\n\n applyInternal(outdatedModules, disposedModules, newModuleFactories);\n}\n\nfunction applyInvalidatedModules(outdatedModules: Set) {\n if (queuedInvalidatedModules.size > 0) {\n computedInvalidatedModules(queuedInvalidatedModules).forEach((moduleId) => {\n outdatedModules.add(moduleId);\n });\n\n queuedInvalidatedModules.clear();\n }\n\n return outdatedModules;\n}\n\nfunction applyInternal(\n outdatedModules: Set,\n disposedModules: Iterable,\n newModuleFactories: Map\n) {\n outdatedModules = applyInvalidatedModules(outdatedModules);\n\n const outdatedSelfAcceptedModules =\n computeOutdatedSelfAcceptedModules(outdatedModules);\n\n const { outdatedModuleParents } = disposePhase(\n outdatedModules,\n disposedModules\n );\n\n // we want to continue on error and only throw the error after we tried applying all updates\n let error: any;\n function reportError(err: any) {\n if (!error) error = err;\n }\n\n applyPhase(\n outdatedSelfAcceptedModules,\n newModuleFactories,\n outdatedModuleParents,\n reportError\n );\n\n if (error) {\n throw error;\n }\n\n if (queuedInvalidatedModules.size > 0) {\n applyInternal(new Set(), [], new Map());\n }\n}\n\nfunction computeChangedModules(\n entries: Record,\n updates: Record\n): {\n added: Map;\n modified: Map;\n deleted: Set;\n chunksAdded: Map>;\n chunksDeleted: Map>;\n} {\n const chunksAdded = new Map();\n const chunksDeleted = new Map();\n const added: Map = new Map();\n const modified = new Map();\n const deleted: Set = new Set();\n\n for (const [chunkPath, mergedChunkUpdate] of Object.entries(updates)) {\n switch (mergedChunkUpdate.type) {\n case \"added\": {\n const updateAdded = new Set(mergedChunkUpdate.modules);\n for (const moduleId of updateAdded) {\n added.set(moduleId, entries[moduleId]);\n }\n chunksAdded.set(chunkPath, updateAdded);\n break;\n }\n case \"deleted\": {\n // We could also use `mergedChunkUpdate.modules` here.\n const updateDeleted = new Set(chunkModulesMap.get(chunkPath));\n for (const moduleId of updateDeleted) {\n deleted.add(moduleId);\n }\n chunksDeleted.set(chunkPath, updateDeleted);\n break;\n }\n case \"partial\": {\n const updateAdded = new Set(mergedChunkUpdate.added);\n const updateDeleted = new Set(mergedChunkUpdate.deleted);\n for (const moduleId of updateAdded) {\n added.set(moduleId, entries[moduleId]);\n }\n for (const moduleId of updateDeleted) {\n deleted.add(moduleId);\n }\n chunksAdded.set(chunkPath, updateAdded);\n chunksDeleted.set(chunkPath, updateDeleted);\n break;\n }\n default:\n invariant(\n mergedChunkUpdate,\n (mergedChunkUpdate) =>\n `Unknown merged chunk update type: ${mergedChunkUpdate.type}`\n );\n }\n }\n\n // If a module was added from one chunk and deleted from another in the same update,\n // consider it to be modified, as it means the module was moved from one chunk to another\n // AND has new code in a single update.\n for (const moduleId of added.keys()) {\n if (deleted.has(moduleId)) {\n added.delete(moduleId);\n deleted.delete(moduleId);\n }\n }\n\n for (const [moduleId, entry] of Object.entries(entries)) {\n // Modules that haven't been added to any chunk but have new code are considered\n // to be modified.\n // This needs to be under the previous loop, as we need it to get rid of modules\n // that were added and deleted in the same update.\n if (!added.has(moduleId)) {\n modified.set(moduleId, entry);\n }\n }\n\n return { added, deleted, modified, chunksAdded, chunksDeleted };\n}\n\ntype ModuleEffect =\n | {\n type: \"unaccepted\";\n dependencyChain: ModuleId[];\n }\n | {\n type: \"self-declined\";\n dependencyChain: ModuleId[];\n moduleId: ModuleId;\n }\n | {\n type: \"accepted\";\n moduleId: ModuleId;\n outdatedModules: Set;\n };\n\nfunction getAffectedModuleEffects(moduleId: ModuleId): ModuleEffect {\n const outdatedModules: Set = new Set();\n\n type QueueItem = { moduleId?: ModuleId; dependencyChain: ModuleId[] };\n\n const queue: QueueItem[] = [\n {\n moduleId,\n dependencyChain: [],\n },\n ];\n\n let nextItem;\n while ((nextItem = queue.shift())) {\n const { moduleId, dependencyChain } = nextItem;\n\n if (moduleId != null) {\n outdatedModules.add(moduleId);\n }\n\n // We've arrived at the runtime of the chunk, which means that nothing\n // else above can accept this update.\n if (moduleId === undefined) {\n return {\n type: \"unaccepted\",\n dependencyChain,\n };\n }\n\n const module = moduleCache[moduleId];\n const hotState = moduleHotState.get(module)!;\n\n if (\n // The module is not in the cache. Since this is a \"modified\" update,\n // it means that the module was never instantiated before.\n !module || // The module accepted itself without invalidating globalThis.\n // TODO is that right?\n (hotState.selfAccepted && !hotState.selfInvalidated)\n ) {\n continue;\n }\n\n if (hotState.selfDeclined) {\n return {\n type: \"self-declined\",\n dependencyChain,\n moduleId,\n };\n }\n\n if (runtimeModules.has(moduleId)) {\n queue.push({\n moduleId: undefined,\n dependencyChain: [...dependencyChain, moduleId],\n });\n continue;\n }\n\n for (const parentId of module.parents) {\n const parent = moduleCache[parentId];\n\n if (!parent) {\n // TODO(alexkirsz) Is this even possible?\n continue;\n }\n\n // TODO(alexkirsz) Dependencies: check accepted and declined\n // dependencies here.\n\n queue.push({\n moduleId: parentId,\n dependencyChain: [...dependencyChain, moduleId],\n });\n }\n }\n\n return {\n type: \"accepted\",\n moduleId,\n outdatedModules,\n };\n}\n\nfunction handleApply(chunkListPath: ChunkPath, update: ServerMessage) {\n switch (update.type) {\n case \"partial\": {\n // This indicates that the update is can be applied to the current state of the application.\n applyUpdate(chunkListPath, update.instruction);\n break;\n }\n case \"restart\": {\n // This indicates that there is no way to apply the update to the\n // current state of the application, and that the application must be\n // restarted.\n BACKEND.restart();\n break;\n }\n case \"notFound\": {\n // This indicates that the chunk list no longer exists: either the dynamic import which created it was removed,\n // or the page itself was deleted.\n // If it is a dynamic import, we simply discard all modules that the chunk has exclusive access to.\n // If it is a runtime chunk list, we restart the application.\n if (runtimeChunkLists.has(chunkListPath)) {\n BACKEND.restart();\n } else {\n disposeChunkList(chunkListPath);\n }\n break;\n }\n default:\n throw new Error(`Unknown update type: ${update.type}`);\n }\n}\n\nfunction createModuleHot(\n moduleId: ModuleId,\n hotData: HotData\n): { hot: Hot; hotState: HotState } {\n const hotState: HotState = {\n selfAccepted: false,\n selfDeclined: false,\n selfInvalidated: false,\n disposeHandlers: [],\n };\n\n const hot: Hot = {\n // TODO(alexkirsz) This is not defined in the HMR API. It was used to\n // decide whether to warn whenever an HMR-disposed module required other\n // modules. We might want to remove it.\n active: true,\n\n data: hotData ?? {},\n\n // TODO(alexkirsz) Support full (dep, callback, errorHandler) form.\n accept: (\n modules?: string | string[] | AcceptErrorHandler,\n _callback?: AcceptCallback,\n _errorHandler?: AcceptErrorHandler\n ) => {\n if (modules === undefined) {\n hotState.selfAccepted = true;\n } else if (typeof modules === \"function\") {\n hotState.selfAccepted = modules;\n } else {\n throw new Error(\"unsupported `accept` signature\");\n }\n },\n\n decline: (dep) => {\n if (dep === undefined) {\n hotState.selfDeclined = true;\n } else {\n throw new Error(\"unsupported `decline` signature\");\n }\n },\n\n dispose: (callback) => {\n hotState.disposeHandlers.push(callback);\n },\n\n addDisposeHandler: (callback) => {\n hotState.disposeHandlers.push(callback);\n },\n\n removeDisposeHandler: (callback) => {\n const idx = hotState.disposeHandlers.indexOf(callback);\n if (idx >= 0) {\n hotState.disposeHandlers.splice(idx, 1);\n }\n },\n\n invalidate: () => {\n hotState.selfInvalidated = true;\n queuedInvalidatedModules.add(moduleId);\n },\n\n // NOTE(alexkirsz) This is part of the management API, which we don't\n // implement, but the Next.js React Refresh runtime uses this to decide\n // whether to schedule an update.\n status: () => \"idle\",\n\n // NOTE(alexkirsz) Since we always return \"idle\" for now, these are no-ops.\n addStatusHandler: (_handler) => {},\n removeStatusHandler: (_handler) => {},\n };\n\n return { hot, hotState };\n}\n\n/**\n * Adds a module to a chunk.\n */\nfunction addModuleToChunk(moduleId: ModuleId, chunkPath: ChunkPath) {\n let moduleChunks = moduleChunksMap.get(moduleId);\n if (!moduleChunks) {\n moduleChunks = new Set([chunkPath]);\n moduleChunksMap.set(moduleId, moduleChunks);\n } else {\n moduleChunks.add(chunkPath);\n }\n\n let chunkModules = chunkModulesMap.get(chunkPath);\n if (!chunkModules) {\n chunkModules = new Set([moduleId]);\n chunkModulesMap.set(chunkPath, chunkModules);\n } else {\n chunkModules.add(moduleId);\n }\n}\n\n/**\n * Returns the first chunk that included a module.\n * This is used by the Node.js backend, hence why it's marked as unused in this\n * file.\n */\nfunction getFirstModuleChunk(moduleId: ModuleId) {\n const moduleChunkPaths = moduleChunksMap.get(moduleId);\n if (moduleChunkPaths == null) {\n return null;\n }\n\n return moduleChunkPaths.values().next().value;\n}\n\n/**\n * Removes a module from a chunk.\n * Returns `true` if there are no remaining chunks including this module.\n */\nfunction removeModuleFromChunk(\n moduleId: ModuleId,\n chunkPath: ChunkPath\n): boolean {\n const moduleChunks = moduleChunksMap.get(moduleId)!;\n moduleChunks.delete(chunkPath);\n\n const chunkModules = chunkModulesMap.get(chunkPath)!;\n chunkModules.delete(moduleId);\n\n const noRemainingModules = chunkModules.size === 0;\n if (noRemainingModules) {\n chunkModulesMap.delete(chunkPath);\n }\n\n const noRemainingChunks = moduleChunks.size === 0;\n if (noRemainingChunks) {\n moduleChunksMap.delete(moduleId);\n }\n\n return noRemainingChunks;\n}\n\n/**\n * Disposes of a chunk list and its corresponding exclusive chunks.\n */\nfunction disposeChunkList(chunkListPath: ChunkPath): boolean {\n const chunkPaths = chunkListChunksMap.get(chunkListPath);\n if (chunkPaths == null) {\n return false;\n }\n chunkListChunksMap.delete(chunkListPath);\n\n for (const chunkPath of chunkPaths) {\n const chunkChunkLists = chunkChunkListsMap.get(chunkPath)!;\n chunkChunkLists.delete(chunkListPath);\n\n if (chunkChunkLists.size === 0) {\n chunkChunkListsMap.delete(chunkPath);\n disposeChunk(chunkPath);\n }\n }\n\n // We must also dispose of the chunk list's chunk itself to ensure it may\n // be reloaded properly in the future.\n BACKEND.unloadChunk?.(chunkListPath);\n\n return true;\n}\n\n/**\n * Disposes of a chunk and its corresponding exclusive modules.\n *\n * @returns Whether the chunk was disposed of.\n */\nfunction disposeChunk(chunkPath: ChunkPath): boolean {\n // This should happen whether the chunk has any modules in it or not.\n // For instance, CSS chunks have no modules in them, but they still need to be unloaded.\n BACKEND.unloadChunk?.(chunkPath);\n\n const chunkModules = chunkModulesMap.get(chunkPath);\n if (chunkModules == null) {\n return false;\n }\n chunkModules.delete(chunkPath);\n\n for (const moduleId of chunkModules) {\n const moduleChunks = moduleChunksMap.get(moduleId)!;\n moduleChunks.delete(chunkPath);\n\n const noRemainingChunks = moduleChunks.size === 0;\n if (noRemainingChunks) {\n moduleChunksMap.delete(moduleId);\n disposeModule(moduleId, \"clear\");\n availableModules.delete(moduleId);\n }\n }\n\n return true;\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 * Gets or instantiates a runtime module.\n */\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 instantiateModule(moduleId, { type: SourceType.Runtime, chunkPath });\n}\n\n/**\n * Returns the URL relative to the origin where a chunk can be fetched from.\n */\nfunction getChunkRelativeUrl(chunkPath: ChunkPath): string {\n return `${CHUNK_BASE_PATH}${chunkPath}`;\n}\n\n/**\n * Subscribes to chunk list updates from the update server and applies them.\n */\nfunction registerChunkList(\n chunkUpdateProvider: ChunkUpdateProvider,\n chunkList: ChunkList\n) {\n chunkUpdateProvider.push([\n chunkList.path,\n handleApply.bind(null, chunkList.path),\n ]);\n\n // Adding chunks to chunk lists and vice versa.\n const chunks = new Set(chunkList.chunks.map(getChunkPath));\n chunkListChunksMap.set(chunkList.path, chunks);\n for (const chunkPath of chunks) {\n let chunkChunkLists = chunkChunkListsMap.get(chunkPath);\n if (!chunkChunkLists) {\n chunkChunkLists = new Set([chunkList.path]);\n chunkChunkListsMap.set(chunkPath, chunkChunkLists);\n } else {\n chunkChunkLists.add(chunkList.path);\n }\n }\n\n if (chunkList.source === \"entry\") {\n markChunkListAsRuntime(chunkList.path);\n }\n}\n\n/**\n * Marks a chunk list as a runtime chunk list. There can be more than one\n * runtime chunk list. For instance, integration tests can have multiple chunk\n * groups loaded at runtime, each with its own chunk list.\n */\nfunction markChunkListAsRuntime(chunkListPath: ChunkPath) {\n runtimeChunkLists.add(chunkListPath);\n}\n\nfunction registerChunk([\n chunkPath,\n chunkModules,\n runtimeParams,\n]: ChunkRegistration) {\n for (const [moduleId, moduleFactory] of Object.entries(chunkModules)) {\n if (!moduleFactories[moduleId]) {\n moduleFactories[moduleId] = moduleFactory;\n }\n addModuleToChunk(moduleId, chunkPath);\n }\n\n return BACKEND.registerChunk(chunkPath, runtimeParams);\n}\n\nglobalThis.TURBOPACK_CHUNK_UPDATE_LISTENERS ??= [];\n\nconst chunkListsToRegister = globalThis.TURBOPACK_CHUNK_LISTS;\nif (Array.isArray(chunkListsToRegister)) {\n for (const chunkList of chunkListsToRegister) {\n registerChunkList(globalThis.TURBOPACK_CHUNK_UPDATE_LISTENERS, chunkList);\n }\n}\n\nglobalThis.TURBOPACK_CHUNK_LISTS = {\n push: (chunkList) => {\n registerChunkList(globalThis.TURBOPACK_CHUNK_UPDATE_LISTENERS!, chunkList);\n },\n} satisfies ChunkListProvider;\n"],"names":[],"mappings":";;;;;;;IAiEA;UAAK,UAAU;IAAV,WAAA,WAKH,aAAU,KAAV;IALG,WAAA,WASH,YAAS,KAAT;IATG,WAAA,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AU,IAAI;QACpC;IACF;IAEA,IAAI,UAAU,MAAM,KAAK,SAAS;QAChC,uBAAuB,UAAU,IAAI;IACvC;AACF;AAOA,SAAS,uBAAuB,aAAwB;IACtD,kBAAkB,GAAG,CAAC;AACxB;AAEA,SAAS,cAAc,CACrB,WACA,cACA,cACkB;IAClB,KAAK,MAAM,CAAC,UAAU,cAAc,IAAI,OAAO,OAAO,CAAC,cAAe;QACpE,IAAI,CAAC,eAAe,CAAC,SAAS,EAAE;YAC9B,eAAe,CAAC,SAAS,GAAG;QAC9B;QACA,iBAAiB,UAAU;IAC7B;IAEA,OAAO,QAAQ,aAAa,CAAC,WAAW;AAC1C;AAEA,WAAW,gCAAgC,KAAK,EAAE;AAElD,MAAM,uBAAuB,WAAW,qBAAqB;AAC7D,IAAI,MAAM,OAAO,CAAC,uBAAuB;IACvC,KAAK,MAAM,aAAa,qBAAsB;QAC5C,kBAAkB,WAAW,gCAAgC,EAAE;IACjE;AACF;AAEA,WAAW,qBAAqB,GAAG;IACjC,MAAM,CAAC;QACL,kBAAkB,WAAW,gCAAgC,EAAG;IAClE;AACF"}}, - {"offset": {"line": 1068, "column": 0}, "map": {"version":3,"sources":["/turbopack/[turbopack]/dev/runtime/dom/runtime-backend-dom.ts"],"sourcesContent":["/**\n * This file contains the runtime code specific to the Turbopack development\n * ECMAScript DOM runtime.\n *\n * It will be appended to the base development runtime code.\n */\n\n/// \n\ntype ChunkResolver = {\n resolved: boolean;\n resolve: () => void;\n reject: (error?: Error) => void;\n promise: Promise;\n};\n\nlet BACKEND: RuntimeBackend;\n\nfunction augmentContext(context: TurbopackDevBaseContext): TurbopackDevContext {\n return context;\n}\n\nfunction commonJsRequireContext(\n entry: RequireContextEntry,\n sourceModule: Module\n): Exports {\n return commonJsRequire(sourceModule, entry.id());\n}\n\n(() => {\n BACKEND = {\n async registerChunk(chunkPath, params) {\n const resolver = getOrCreateResolver(chunkPath);\n resolver.resolve();\n\n if (params == null) {\n return;\n }\n\n for (const otherChunkData of params.otherChunks) {\n const otherChunkPath = getChunkPath(otherChunkData);\n // Chunk might have started loading, so we want to avoid triggering another load.\n getOrCreateResolver(otherChunkPath);\n }\n\n // This waits for chunks to be loaded, but also marks included items as available.\n await Promise.all(\n params.otherChunks.map((otherChunkData) =>\n loadChunk({ type: SourceType.Runtime, chunkPath }, otherChunkData)\n )\n );\n\n if (params.runtimeModuleIds.length > 0) {\n for (const moduleId of params.runtimeModuleIds) {\n getOrInstantiateRuntimeModule(moduleId, chunkPath);\n }\n }\n },\n\n loadChunk(chunkPath, source) {\n return doLoadChunk(chunkPath, source);\n },\n\n unloadChunk(chunkPath) {\n deleteResolver(chunkPath);\n\n const chunkUrl = getChunkRelativeUrl(chunkPath);\n\n if (chunkPath.endsWith(\".css\")) {\n const links = document.querySelectorAll(`link[href=\"${chunkUrl}\"]`);\n for (const link of Array.from(links)) {\n link.remove();\n }\n } else if (chunkPath.endsWith(\".js\")) {\n // Unloading a JS chunk would have no effect, as it lives in the JS\n // runtime once evaluated.\n // However, we still want to remove the script tag from the DOM to keep\n // the HTML somewhat consistent from the user's perspective.\n const scripts = document.querySelectorAll(`script[src=\"${chunkUrl}\"]`);\n for (const script of Array.from(scripts)) {\n script.remove();\n }\n } else {\n throw new Error(`can't infer type of chunk from path ${chunkPath}`);\n }\n },\n\n reloadChunk(chunkPath) {\n return new Promise((resolve, reject) => {\n if (!chunkPath.endsWith(\".css\")) {\n reject(new Error(\"The DOM backend can only reload CSS chunks\"));\n return;\n }\n\n const encodedChunkPath = chunkPath\n .split(\"/\")\n .map((p) => encodeURIComponent(p))\n .join(\"/\");\n\n const chunkUrl = `/${getChunkRelativeUrl(encodedChunkPath)}`;\n\n const previousLink = document.querySelector(\n `link[rel=stylesheet][href^=\"${chunkUrl}\"]`\n );\n\n if (previousLink == null) {\n reject(new Error(`No link element found for chunk ${chunkPath}`));\n return;\n }\n\n const link = document.createElement(\"link\");\n link.rel = \"stylesheet\";\n link.href = chunkUrl;\n link.onerror = () => {\n reject();\n };\n link.onload = () => {\n // First load the new CSS, then remove the old one. This prevents visible\n // flickering that would happen in-between removing the previous CSS and\n // loading the new one.\n previousLink.remove();\n\n // CSS chunks do not register themselves, and as such must be marked as\n // loaded instantly.\n resolve();\n };\n\n // Make sure to insert the new CSS right after the previous one, so that\n // its precedence is higher.\n previousLink.parentElement!.insertBefore(\n link,\n previousLink.nextSibling\n );\n });\n },\n\n restart: () => self.location.reload(),\n };\n\n /**\n * Maps chunk paths to the corresponding resolver.\n */\n const chunkResolvers: Map = new Map();\n\n function getOrCreateResolver(chunkPath: ChunkPath): ChunkResolver {\n let resolver = chunkResolvers.get(chunkPath);\n if (!resolver) {\n let resolve: () => void;\n let reject: (error?: Error) => void;\n const promise = new Promise((innerResolve, innerReject) => {\n resolve = innerResolve;\n reject = innerReject;\n });\n resolver = {\n resolved: false,\n promise,\n resolve: () => {\n resolver!.resolved = true;\n resolve();\n },\n reject: reject!,\n };\n chunkResolvers.set(chunkPath, resolver);\n }\n return resolver;\n }\n\n function deleteResolver(chunkPath: ChunkPath) {\n chunkResolvers.delete(chunkPath);\n }\n\n /**\n * Loads the given chunk, and returns a promise that resolves once the chunk\n * has been loaded.\n */\n async function doLoadChunk(chunkPath: ChunkPath, source: SourceInfo) {\n const resolver = getOrCreateResolver(chunkPath);\n if (resolver.resolved) {\n return resolver.promise;\n }\n\n if (source.type === SourceType.Runtime) {\n // We don't need to load chunks references from runtime code, as they're already\n // present in the DOM.\n\n if (chunkPath.endsWith(\".css\")) {\n // CSS chunks do not register themselves, and as such must be marked as\n // loaded instantly.\n resolver.resolve();\n }\n\n // We need to wait for JS chunks to register themselves within `registerChunk`\n // before we can start instantiating runtime modules, hence the absence of\n // `resolver.resolve()` in this branch.\n\n return resolver.promise;\n }\n\n const chunkUrl = `/${getChunkRelativeUrl(chunkPath)}`;\n\n if (chunkPath.endsWith(\".css\")) {\n const link = document.createElement(\"link\");\n link.rel = \"stylesheet\";\n link.href = chunkUrl;\n link.onerror = () => {\n resolver.reject();\n };\n link.onload = () => {\n // CSS chunks do not register themselves, and as such must be marked as\n // loaded instantly.\n resolver.resolve();\n };\n document.body.appendChild(link);\n } else if (chunkPath.endsWith(\".js\")) {\n const script = document.createElement(\"script\");\n script.src = chunkUrl;\n // We'll only mark the chunk as loaded once the script has been executed,\n // which happens in `registerChunk`. Hence the absence of `resolve()` in\n // this branch.\n script.onerror = () => {\n resolver.reject();\n };\n document.body.appendChild(script);\n } else {\n throw new Error(`can't infer type of chunk from path ${chunkPath}`);\n }\n\n return resolver.promise;\n }\n})();\n\nfunction _eval({ code, url, map }: EcmascriptModuleEntry): ModuleFactory {\n code += `\\n\\n//# sourceURL=${location.origin}/${url}`;\n if (map) code += `\\n//# sourceMappingURL=${map}`;\n return eval(code);\n}\n"],"names":[],"mappings":"AAgBA,IAAI;AAEJ,SAAS,eAAe,QAAgC;IACtD,OAAO;AACT;AAEA,SAAS,uBACP,MAA0B,EAC1B,aAAoB;IAEpB,OAAO,gBAAgB,eAAc,OAAM,EAAE;AAC/C;AAEC,CAAA;IACC,UAAU;QACR,MAAM,eAAc,UAAS,EAAE,OAAM;YACnC,MAAM,YAAW,qBAAoB;YACrC,UAAS,OAAO;YAEhB,IAAI,WAAU,MAAM;gBAClB;YACF;YAEA,KAAK,MAAM,mBAAkB,QAAO,WAAW,CAAE;gBAC/C,MAAM,kBAAiB,aAAa;gBAEpC,qBAAoB;YACtB;YAGA,MAAM,QAAQ,GAAG,CACf,QAAO,WAAW,CAAC,GAAG,CAAC,CAAC,kBACtB,UAAU;oBAAE,MAAM,WAAW,OAAO;oBAAE,WAAA;gBAAU,GAAG;YAIvD,IAAI,QAAO,gBAAgB,CAAC,MAAM,GAAG,GAAG;gBACtC,KAAK,MAAM,aAAY,QAAO,gBAAgB,CAAE;oBAC9C,8BAA8B,WAAU;gBAC1C;YACF;QACF;QAEA,WAAU,UAAS,EAAE,OAAM;YACzB,OAAO,aAAY,YAAW;QAChC;QAEA,aAAY,UAAS;YACnB,gBAAe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B,OAAO;YACL,MAAM,IAAI,MAAM,CAAC,oCAAoC,EAAE,WAAU,CAAC;QACpE;QAEA,OAAO,UAAS,OAAO;IACzB;AACF,CAAA;AAEA,SAAS,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAyB;IACtD,QAAQ,CAAC,kBAAkB,EAAE,SAAS,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC;IACrD,IAAI,KAAK,QAAQ,CAAC,uBAAuB,EAAE,IAAI,CAAC;IAChD,OAAO,KAAK;AACd"}}, - {"offset": {"line": 1212, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}] + {"offset": {"line": 11, "column": 0}, "map": {"version":3,"sources":["/turbopack/[turbopack]/shared/runtime-utils.ts"],"sourcesContent":["/**\n * This file contains runtime types and functions that are shared between all\n * TurboPack ECMAScript runtimes.\n *\n * It will be prepended to the runtime code of each runtime.\n */\n\n/* eslint-disable @next/next/no-assign-module-variable */\n\n/// \n\ninterface Exports {\n __esModule?: boolean;\n\n [key: string]: any;\n}\n\ntype EsmNamespaceObject = Record;\n\nconst REEXPORTED_OBJECTS = Symbol(\"reexported objects\");\n\ninterface BaseModule {\n exports: Exports | Promise | AsyncModulePromise;\n error: Error | undefined;\n loaded: boolean;\n id: ModuleId;\n children: ModuleId[];\n parents: ModuleId[];\n namespaceObject?:\n | EsmNamespaceObject\n | Promise\n | AsyncModulePromise;\n [REEXPORTED_OBJECTS]?: any[];\n}\n\ninterface Module extends BaseModule {}\n\ntype RequireContextMap = Record;\n\ninterface RequireContextEntry {\n id: () => ModuleId;\n}\n\ninterface RequireContext {\n (moduleId: ModuleId): Exports | EsmNamespaceObject;\n\n keys(): ModuleId[];\n\n resolve(moduleId: ModuleId): ModuleId;\n}\n\ntype GetOrInstantiateModuleFromParent = (\n moduleId: ModuleId,\n parentModule: Module\n) => Module;\n\ntype CommonJsRequireContext = (\n entry: RequireContextEntry,\n parentModule: Module\n) => Exports;\n\nconst hasOwnProperty = Object.prototype.hasOwnProperty;\nconst toStringTag = typeof Symbol !== \"undefined\" && Symbol.toStringTag;\n\nfunction defineProp(\n obj: any,\n name: PropertyKey,\n options: PropertyDescriptor & ThisType\n) {\n if (!hasOwnProperty.call(obj, name))\n Object.defineProperty(obj, name, options);\n}\n\n/**\n * Adds the getters to the exports object.\n */\nfunction esm(exports: Exports, getters: Record any>) {\n defineProp(exports, \"__esModule\", { value: true });\n if (toStringTag) defineProp(exports, toStringTag, { value: \"Module\" });\n for (const key in getters) {\n defineProp(exports, key, { get: getters[key], enumerable: true });\n }\n}\n\n/**\n * Makes the module an ESM with exports\n */\nfunction esmExport(\n module: Module,\n exports: Exports,\n getters: Record any>\n) {\n module.namespaceObject = module.exports;\n esm(exports, getters);\n}\n\n/**\n * Dynamically exports properties from an object\n */\nfunction dynamicExport(\n module: Module,\n exports: Exports,\n object: Record\n) {\n const keys = Reflect.ownKeys(exports);\n\n for (const key of Reflect.ownKeys(object)) {\n if (key !== \"default\" && !keys.includes(key)) {\n defineProp(exports, key, {\n get: createGetter(object, key),\n enumerable: true,\n });\n }\n }\n}\n\nfunction exportValue(module: Module, value: any) {\n module.exports = value;\n}\n\nfunction exportNamespace(module: Module, namespace: any) {\n module.exports = module.namespaceObject = namespace;\n}\n\nfunction createGetter(obj: Record, key: string | symbol) {\n return () => obj[key];\n}\n\n/**\n * @returns prototype of the object\n */\nconst getProto: (obj: any) => any = Object.getPrototypeOf\n ? (obj) => Object.getPrototypeOf(obj)\n : (obj) => obj.__proto__;\n\n/** Prototypes that are not expanded for exports */\nconst LEAF_PROTOTYPES = [null, getProto({}), getProto([]), getProto(getProto)];\n\n/**\n * @param raw\n * @param ns\n * @param allowExportDefault\n * * `false`: will have the raw module as default export\n * * `true`: will have the default property as default export\n */\nfunction interopEsm(\n raw: Exports,\n ns: EsmNamespaceObject,\n allowExportDefault?: boolean\n) {\n const getters: { [s: string]: () => any } = Object.create(null);\n for (\n let current = raw;\n (typeof current === \"object\" || typeof current === \"function\") &&\n !LEAF_PROTOTYPES.includes(current);\n current = getProto(current)\n ) {\n for (const key of Object.getOwnPropertyNames(current)) {\n getters[key] = createGetter(raw, key);\n }\n }\n\n // this is not really correct\n // we should set the `default` getter if the imported module is a `.cjs file`\n if (!(allowExportDefault && \"default\" in getters)) {\n getters[\"default\"] = () => raw;\n }\n\n esm(ns, getters);\n return ns;\n}\n\nfunction esmImport(\n sourceModule: Module,\n id: ModuleId\n): Exclude {\n const module = getOrInstantiateModuleFromParent(id, sourceModule);\n if (module.error) throw module.error;\n\n // Any ES module has to have `module.namespaceObject` defined.\n if (module.namespaceObject) return module.namespaceObject;\n\n // only ESM can be an async module, so we don't need to worry about exports being a promise.\n const raw = module.exports;\n return (module.namespaceObject = interopEsm(\n raw,\n {},\n (raw as any).__esModule\n ));\n}\n\nfunction commonJsRequire(sourceModule: Module, id: ModuleId): Exports {\n const module = getOrInstantiateModuleFromParent(id, sourceModule);\n if (module.error) throw module.error;\n return module.exports;\n}\n\ntype RequireContextFactory = (map: RequireContextMap) => RequireContext;\n\nfunction requireContext(\n sourceModule: Module,\n map: RequireContextMap\n): RequireContext {\n function requireContext(id: ModuleId): Exports {\n const entry = map[id];\n\n if (!entry) {\n throw new Error(\n `module ${id} is required from a require.context, but is not in the context`\n );\n }\n\n return commonJsRequireContext(entry, sourceModule);\n }\n\n requireContext.keys = (): ModuleId[] => {\n return Object.keys(map);\n };\n\n requireContext.resolve = (id: ModuleId): ModuleId => {\n const entry = map[id];\n\n if (!entry) {\n throw new Error(\n `module ${id} is resolved from a require.context, but is not in the context`\n );\n }\n\n return entry.id();\n };\n\n return requireContext;\n}\n\n/**\n * Returns the path of a chunk defined by its data.\n */\nfunction getChunkPath(chunkData: ChunkData): ChunkPath {\n return typeof chunkData === \"string\" ? chunkData : chunkData.path;\n}\n\nfunction isPromise(maybePromise: any): maybePromise is Promise {\n return (\n maybePromise != null &&\n typeof maybePromise === \"object\" &&\n \"then\" in maybePromise &&\n typeof maybePromise.then === \"function\"\n );\n}\n\nfunction isAsyncModuleExt(obj: T): obj is AsyncModuleExt & T {\n return turbopackQueues in obj;\n}\n\nfunction maybeWrapAsyncModulePromise(\n promise: Promise,\n then: (val: T) => U | PromiseLike\n): typeof promise extends AsyncModulePromise\n ? AsyncModulePromise\n : Promise {\n const newPromise = promise.then(then);\n\n if (isAsyncModuleExt(promise)) {\n Object.assign(newPromise, {\n get [turbopackExports]() {\n return promise[turbopackExports];\n },\n get [turbopackQueues]() {\n return promise[turbopackQueues];\n },\n get [turbopackError]() {\n return promise[turbopackError];\n },\n } satisfies AsyncModuleExt);\n }\n\n return newPromise as any;\n}\n\nfunction createPromise() {\n let resolve: (value: T | PromiseLike) => void;\n let reject: (reason?: any) => void;\n\n const promise = new Promise((res, rej) => {\n reject = rej;\n resolve = res;\n });\n\n return {\n promise,\n resolve: resolve!,\n reject: reject!,\n };\n}\n\n// everything below is adapted from webpack\n// https://github.com/webpack/webpack/blob/6be4065ade1e252c1d8dcba4af0f43e32af1bdc1/lib/runtime/AsyncModuleRuntimeModule.js#L13\n\nconst turbopackQueues = Symbol(\"turbopack queues\");\nconst turbopackExports = Symbol(\"turbopack exports\");\nconst turbopackError = Symbol(\"turbopack error\");\n\ntype AsyncQueueFn = (() => void) & { queueCount: number };\ntype AsyncQueue = AsyncQueueFn[] & { resolved: boolean };\n\nfunction resolveQueue(queue?: AsyncQueue) {\n if (queue && !queue.resolved) {\n queue.resolved = true;\n queue.forEach((fn) => fn.queueCount--);\n queue.forEach((fn) => (fn.queueCount-- ? fn.queueCount++ : fn()));\n }\n}\n\ntype Dep = Exports | AsyncModulePromise | Promise;\n\ntype AsyncModuleExt = {\n [turbopackQueues]: (fn: (queue: AsyncQueue) => void) => void;\n [turbopackExports]: Exports;\n [turbopackError]?: any;\n};\n\ntype AsyncModulePromise = Promise & AsyncModuleExt;\n\nfunction wrapDeps(deps: Dep[]): AsyncModuleExt[] {\n return deps.map((dep) => {\n if (dep !== null && typeof dep === \"object\") {\n if (isAsyncModuleExt(dep)) return dep;\n if (isPromise(dep)) {\n const queue: AsyncQueue = Object.assign([], { resolved: false });\n\n const obj: AsyncModuleExt = {\n [turbopackExports]: {},\n [turbopackQueues]: (fn: (queue: AsyncQueue) => void) => fn(queue),\n };\n\n dep.then(\n (res) => {\n obj[turbopackExports] = res;\n resolveQueue(queue);\n },\n (err) => {\n obj[turbopackError] = err;\n resolveQueue(queue);\n }\n );\n\n return obj;\n }\n }\n\n const ret: AsyncModuleExt = {\n [turbopackExports]: dep,\n [turbopackQueues]: () => {},\n };\n\n return ret;\n });\n}\n\nfunction asyncModule(\n module: Module,\n body: (\n handleAsyncDependencies: (\n deps: Dep[]\n ) => Exports[] | Promise<() => Exports[]>,\n asyncResult: (err?: any) => void\n ) => void,\n hasAwait: boolean\n) {\n const queue: AsyncQueue | undefined = hasAwait\n ? Object.assign([], { resolved: true })\n : undefined;\n\n const depQueues: Set = new Set();\n const exports = module.exports;\n\n const { resolve, reject, promise: rawPromise } = createPromise();\n\n const promise: AsyncModulePromise = Object.assign(rawPromise, {\n [turbopackExports]: exports,\n [turbopackQueues]: (fn) => {\n queue && fn(queue);\n depQueues.forEach(fn);\n promise[\"catch\"](() => {});\n },\n } satisfies AsyncModuleExt);\n\n module.exports = module.namespaceObject = promise;\n\n function handleAsyncDependencies(deps: Dep[]) {\n const currentDeps = wrapDeps(deps);\n\n const getResult = () =>\n currentDeps.map((d) => {\n if (d[turbopackError]) throw d[turbopackError];\n return d[turbopackExports];\n });\n\n const { promise, resolve } = createPromise<() => Exports[]>();\n\n const fn: AsyncQueueFn = Object.assign(() => resolve(getResult), {\n queueCount: 0,\n });\n\n function fnQueue(q: AsyncQueue) {\n if (q !== queue && !depQueues.has(q)) {\n depQueues.add(q);\n if (q && !q.resolved) {\n fn.queueCount++;\n q.push(fn);\n }\n }\n }\n\n currentDeps.map((dep) => dep[turbopackQueues](fnQueue));\n\n return fn.queueCount ? promise : getResult();\n }\n\n function asyncResult(err?: any) {\n if (err) {\n reject((promise[turbopackError] = err));\n } else {\n resolve(exports);\n }\n\n resolveQueue(queue);\n }\n\n body(handleAsyncDependencies, asyncResult);\n\n if (queue) {\n queue.resolved = false;\n }\n}\n"],"names":[],"mappings":";AAmBA,MAAM,qBAAqB,OAAO;;;;;AA0ClC,MAAM,iBAAiB,OAAO,SAAS,CAAC,cAAc;AACtD,MAAM,cAAc,OAAO,WAAW,eAAe,OAAO,WAAW;AAEvE,SAAS,WACP,GAAQ,EACR,IAAiB,EACjB,OAA2C;IAE3C,IAAI,CAAC,eAAe,IAAI,CAAC,KAAK,OAC5B,OAAO,cAAc,CAAC,KAAK,MAAM;AACrC;AAKA,SAAS,IAAI,OAAgB,EAAE,OAAkC;IAC/D,WAAW,SAAS,cAAc;QAAE,OAAO;IAAK;IAChD,IAAI,aAAa,WAAW,SAAS,aAAa;QAAE,OAAO;IAAS;IACpE,IAAK,MAAM,OAAO,QAAS;QACzB,WAAW,SAAS,KAAK;YAAE,KAAK,OAAO,CAAC,IAAI;YAAE,YAAY;QAAK;IACjE;AACF;AAKA,SAAS,UACP,MAAc,EACd,OAAgB,EAChB,OAAkC;IAElC,OAAO,eAAe,GAAG,OAAO,OAAO;IACvC,IAAI,SAAS;AACf;AAKA,SAAS,cACP,MAAc,EACd,OAAgB,EAChB,MAA2B;IAE3B,MAAM,OAAO,QAAQ,OAAO,CAAC;IAE7B,KAAK,MAAM,OAAO,QAAQ,OAAO,CAAC,QAAS;QACzC,IAAI,QAAQ,aAAa,CAAC,KAAK,QAAQ,CAAC,MAAM;YAC5C,WAAW,SAAS,KAAK;gBACvB,KAAK,aAAa,QAAQ;gBAC1B,YAAY;YACd;QACF;IACF;AACF;AAEA,SAAS,YAAY,MAAc,EAAE,KAAU;IAC7C,OAAO,OAAO,GAAG;AACnB;AAEA,SAAS,gBAAgB,MAAc,EAAE,SAAc;IACrD,OAAO,OAAO,GAAG,OAAO,eAAe,GAAG;AAC5C;AAEA,SAAS,aAAa,GAAiC,EAAE,GAAoB;IAC3E,OAAO,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OAAO,CAAC,QAAQ,CAAC,KAAO;QAC1B;IACF;IAEA,OAAO,OAAO,GAAG,OAAO,eAAe,GAAG;IAE1C,SAAS,wBAAwB,IAAW;QAC1C,MAAM,cAAc,SAAS;QAE7B,MAAM,YAAY,IAChB,YAAY,GAAG,CAAC,CAAC;gBACf,IAAI,CAAC,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC,eAAe;gBAC9C,OAAO,CAAC,CAAC,iBAAiB;YAC5B;QAEF,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG;QAE7B,MAAM,KAAmB,OAAO,MAAM,CAAC,IAAM,QAAQ,YAAY;YAC/D,YAAY;QACd;QAEA,SAAS,QAAQ,CAAa;YAC5B,IAAI,MAAM,SAAS,CAAC,UAAU,GAAG,CAAC,IAAI;gBACpC,UAAU,GAAG,CAAC;gBACd,IAAI,KAAK,CAAC,EAAE,QAAQ,EAAE;oBACpB,GAAG,UAAU;oBACb,EAAE,IAAI,CAAC;gBACT;YACF;QACF;QAEA,YAAY,GAAG,CAAC,CAAC,MAAQ,GAAG,CAAC,gBAAgB,CAAC;QAE9C,OAAO,GAAG,UAAU,GAAG,UAAU;IACnC;IAEA,SAAS,YAAY,GAAS;QAC5B,IAAI,KAAK;YACP,OAAQ,OAAO,CAAC,eAAe,GAAG;QACpC,OAAO;YACL,QAAQ;QACV;QAEA,aAAa;IACf;IAEA,KAAK,yBAAyB;IAE9B,IAAI,OAAO;QACT,MAAM,QAAQ,GAAG;IACnB;AACF"}}, + {"offset": {"line": 241, "column": 0}, "map": {"version":3,"sources":["/turbopack/[turbopack]/dev/runtime/base/runtime-base.ts"],"sourcesContent":["/**\n * This file contains runtime types and functions that are shared between all\n * Turbopack *development* ECMAScript runtimes.\n *\n * It will be appended to the runtime code of each runtime right after the\n * shared runtime utils.\n */\n\n/* eslint-disable @next/next/no-assign-module-variable */\n\n/// \n/// \n/// \n/// \n\n// This file must not use `import` and `export` statements. Otherwise, it\n// becomes impossible to augment interfaces declared in ``d files\n// (e.g. `Module`). Hence, the need for `import()` here.\ntype RefreshRuntimeGlobals =\n import(\"@next/react-refresh-utils/dist/runtime\").RefreshRuntimeGlobals;\n\ndeclare var CHUNK_BASE_PATH: string;\ndeclare var $RefreshHelpers$: RefreshRuntimeGlobals[\"$RefreshHelpers$\"];\ndeclare var $RefreshReg$: RefreshRuntimeGlobals[\"$RefreshReg$\"];\ndeclare var $RefreshSig$: RefreshRuntimeGlobals[\"$RefreshSig$\"];\ndeclare var $RefreshInterceptModuleExecution$:\n | RefreshRuntimeGlobals[\"$RefreshInterceptModuleExecution$\"];\n\ntype RefreshContext = {\n register: RefreshRuntimeGlobals[\"$RefreshReg$\"];\n signature: RefreshRuntimeGlobals[\"$RefreshSig$\"];\n};\n\ntype RefreshHelpers = RefreshRuntimeGlobals[\"$RefreshHelpers$\"];\n\ninterface TurbopackDevBaseContext extends TurbopackBaseContext {\n k: RefreshContext;\n}\n\ninterface TurbopackDevContext extends TurbopackDevBaseContext {}\n\n// string encoding of a module factory (used in hmr updates)\ntype ModuleFactoryString = string;\n\ntype ModuleFactory = (\n this: Module[\"exports\"],\n context: TurbopackDevContext\n) => undefined;\n\ntype DevRuntimeParams = {\n otherChunks: ChunkData[];\n runtimeModuleIds: ModuleId[];\n};\n\ntype ChunkRegistration = [\n chunkPath: ChunkPath,\n chunkModules: ModuleFactories,\n params: DevRuntimeParams | undefined\n];\ntype ChunkList = {\n path: ChunkPath;\n chunks: ChunkData[];\n source: \"entry\" | \"dynamic\";\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 * The module was instantiated because it was included in a chunk's hot module\n * update.\n */\n Update = 2,\n}\n\ntype SourceInfo =\n | {\n type: SourceType.Runtime;\n chunkPath: ChunkPath;\n }\n | {\n type: SourceType.Parent;\n parentId: ModuleId;\n }\n | {\n type: SourceType.Update;\n parents?: ModuleId[];\n };\n\ninterface RuntimeBackend {\n registerChunk: (chunkPath: ChunkPath, params?: DevRuntimeParams) => void;\n loadChunk: (chunkPath: ChunkPath, source: SourceInfo) => Promise;\n reloadChunk?: (chunkPath: ChunkPath) => Promise;\n unloadChunk?: (chunkPath: ChunkPath) => void;\n\n restart: () => void;\n}\n\nconst moduleFactories: ModuleFactories = Object.create(null);\nconst moduleCache: ModuleCache = Object.create(null);\n/**\n * Maps module IDs to persisted data between executions of their hot module\n * implementation (`hot.data`).\n */\nconst moduleHotData: Map = new Map();\n/**\n * Maps module instances to their hot module state.\n */\nconst moduleHotState: Map = new Map();\n/**\n * Modules that call `module.hot.invalidate()` (while being updated).\n */\nconst queuedInvalidatedModules: Set = new Set();\n/**\n * Module IDs that are instantiated as part of the runtime of a chunk.\n */\nconst runtimeModules: Set = new Set();\n/**\n * Map from module ID to the chunks that contain this module.\n *\n * In HMR, we need to keep track of which modules are contained in which so\n * chunks. This is so we don't eagerly dispose of a module when it is removed\n * from chunk A, but still exists in chunk B.\n */\nconst moduleChunksMap: Map> = new Map();\n/**\n * Map from a chunk path to all modules it contains.\n */\nconst chunkModulesMap: Map> = new Map();\n/**\n * Chunk lists that contain a runtime. When these chunk lists receive an update\n * that can't be reconciled with the current state of the page, we need to\n * reload the runtime entirely.\n */\nconst runtimeChunkLists: Set = new Set();\n/**\n * Map from a chunk list to the chunk paths it contains.\n */\nconst chunkListChunksMap: Map> = new Map();\n/**\n * Map from a chunk path to the chunk lists it belongs to.\n */\nconst chunkChunkListsMap: Map> = new Map();\n\nconst availableModules: Map | true> = new Map();\n\nconst availableModuleChunks: Map | true> = new Map();\n\nasync function loadChunk(\n source: SourceInfo,\n chunkData: ChunkData\n): Promise {\n if (typeof chunkData === \"string\") {\n return loadChunkPath(source, chunkData);\n }\n\n const includedList = chunkData.included || [];\n const modulesPromises = includedList.map((included) => {\n if (moduleFactories[included]) return true;\n return availableModules.get(included);\n });\n if (modulesPromises.length > 0 && modulesPromises.every((p) => p)) {\n // When all included items are already loaded or loading, we can skip loading ourselves\n return Promise.all(modulesPromises);\n }\n\n const includedModuleChunksList = chunkData.moduleChunks || [];\n const moduleChunksPromises = includedModuleChunksList\n .map((included) => {\n // TODO(alexkirsz) Do we need this check?\n // if (moduleFactories[included]) return true;\n return availableModuleChunks.get(included);\n })\n .filter((p) => p);\n\n let promise;\n if (moduleChunksPromises.length > 0) {\n // Some module chunks are already loaded or loading.\n\n if (moduleChunksPromises.length == includedModuleChunksList.length) {\n // When all included module chunks are already loaded or loading, we can skip loading ourselves\n return Promise.all(moduleChunksPromises);\n }\n\n const moduleChunksToLoad: Set = new Set();\n for (const moduleChunk of includedModuleChunksList) {\n if (!availableModuleChunks.has(moduleChunk)) {\n moduleChunksToLoad.add(moduleChunk);\n }\n }\n\n for (const moduleChunkToLoad of moduleChunksToLoad) {\n const promise = loadChunkPath(source, moduleChunkToLoad);\n\n availableModuleChunks.set(moduleChunkToLoad, promise);\n\n moduleChunksPromises.push(promise);\n }\n\n promise = Promise.all(moduleChunksPromises);\n } else {\n promise = loadChunkPath(source, chunkData.path);\n\n // Mark all included module chunks as loading if they are not already loaded or loading.\n for (const includedModuleChunk of includedModuleChunksList) {\n if (!availableModuleChunks.has(includedModuleChunk)) {\n availableModuleChunks.set(includedModuleChunk, promise);\n }\n }\n }\n\n for (const included of includedList) {\n if (!availableModules.has(included)) {\n // It might be better to race old and new promises, but it's rare that the new promise will be faster than a request started earlier.\n // In production it's even more rare, because the chunk optimization tries to deduplicate modules anyway.\n availableModules.set(included, promise);\n }\n }\n\n return promise;\n}\n\nasync function loadChunkPath(\n source: SourceInfo,\n chunkPath: ChunkPath\n): Promise {\n try {\n await BACKEND.loadChunk(chunkPath, source);\n } catch (error) {\n let loadReason;\n switch (source.type) {\n case SourceType.Runtime:\n loadReason = `as a runtime dependency of chunk ${source.chunkPath}`;\n break;\n case SourceType.Parent:\n loadReason = `from module ${source.parentId}`;\n break;\n case SourceType.Update:\n loadReason = \"from an HMR update\";\n break;\n }\n throw new Error(\n `Failed to load chunk ${chunkPath} ${loadReason}${\n error ? `: ${error}` : \"\"\n }`,\n error\n ? {\n cause: error,\n }\n : undefined\n );\n }\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 case SourceType.Update:\n instantiationReason = \"because of an HMR update\";\n break;\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 hotData = moduleHotData.get(id)!;\n const { hot, hotState } = createModuleHot(id, hotData);\n\n let parents: ModuleId[];\n switch (source.type) {\n case SourceType.Runtime:\n runtimeModules.add(id);\n parents = [];\n break;\n case SourceType.Parent:\n // No need to add this module as a child of the parent module here, this\n // has already been taken care of in `getOrInstantiateModuleFromParent`.\n parents = [source.parentId];\n break;\n case SourceType.Update:\n parents = source.parents || [];\n break;\n }\n const module: Module = {\n exports: {},\n error: undefined,\n loaded: false,\n id,\n parents,\n children: [],\n namespaceObject: undefined,\n hot,\n };\n\n moduleCache[id] = module;\n moduleHotState.set(module, hotState);\n\n // NOTE(alexkirsz) This can fail when the module encounters a runtime error.\n try {\n runModuleExecutionHooks(module, (refresh) => {\n moduleFactory.call(\n module.exports,\n augmentContext({\n a: asyncModule.bind(null, module),\n e: module.exports,\n r: commonJsRequire.bind(null, module),\n f: requireContext.bind(null, module),\n i: esmImport.bind(null, module),\n s: esmExport.bind(null, module, module.exports),\n j: dynamicExport.bind(null, module, module.exports),\n v: exportValue.bind(null, module),\n n: exportNamespace.bind(null, module),\n m: module,\n c: moduleCache,\n l: loadChunk.bind(null, { type: SourceType.Parent, parentId: id }),\n g: globalThis,\n k: refresh,\n __dirname: module.id.replace(/(^|\\/)\\/+$/, \"\"),\n })\n );\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 * NOTE(alexkirsz) Webpack has a \"module execution\" interception hook that\n * Next.js' React Refresh runtime hooks into to add module context to the\n * refresh registry.\n */\nfunction runModuleExecutionHooks(\n module: Module,\n executeModule: (ctx: RefreshContext) => void\n) {\n const cleanupReactRefreshIntercept =\n typeof globalThis.$RefreshInterceptModuleExecution$ === \"function\"\n ? globalThis.$RefreshInterceptModuleExecution$(module.id)\n : () => {};\n\n try {\n executeModule({\n register: globalThis.$RefreshReg$,\n signature: globalThis.$RefreshSig$,\n });\n\n if (\"$RefreshHelpers$\" in globalThis) {\n // This pattern can also be used to register the exports of\n // a module with the React Refresh runtime.\n registerExportsAndSetupBoundaryForReactRefresh(\n module,\n globalThis.$RefreshHelpers$\n );\n }\n } catch (e) {\n throw e;\n } finally {\n // Always cleanup the intercept, even if module execution failed.\n cleanupReactRefreshIntercept();\n }\n}\n\n/**\n * Retrieves a module from the cache, or instantiate it if it is not cached.\n */\nconst getOrInstantiateModuleFromParent: GetOrInstantiateModuleFromParent = (\n id,\n sourceModule\n) => {\n if (!sourceModule.hot.active) {\n console.warn(\n `Unexpected import of module ${id} from module ${sourceModule.id}, which was deleted by an HMR update`\n );\n }\n\n const module = moduleCache[id];\n\n if (sourceModule.children.indexOf(id) === -1) {\n sourceModule.children.push(id);\n }\n\n if (module) {\n if (module.parents.indexOf(sourceModule.id) === -1) {\n module.parents.push(sourceModule.id);\n }\n\n return module;\n }\n\n return instantiateModule(id, {\n type: SourceType.Parent,\n parentId: sourceModule.id,\n });\n};\n\n/**\n * This is adapted from https://github.com/vercel/next.js/blob/3466862d9dc9c8bb3131712134d38757b918d1c0/packages/react-refresh-utils/internal/ReactRefreshModule.runtime.ts\n */\nfunction registerExportsAndSetupBoundaryForReactRefresh(\n module: Module,\n helpers: RefreshHelpers\n) {\n const currentExports = module.exports;\n const prevExports = module.hot.data.prevExports ?? null;\n\n helpers.registerExportsForReactRefresh(currentExports, module.id);\n\n // A module can be accepted automatically based on its exports, e.g. when\n // it is a Refresh Boundary.\n if (helpers.isReactRefreshBoundary(currentExports)) {\n // Save the previous exports on update, so we can compare the boundary\n // signatures.\n module.hot.dispose((data) => {\n data.prevExports = currentExports;\n });\n // Unconditionally accept an update to this module, we'll check if it's\n // still a Refresh Boundary later.\n module.hot.accept();\n\n // This field is set when the previous version of this module was a\n // Refresh Boundary, letting us know we need to check for invalidation or\n // enqueue an update.\n if (prevExports !== null) {\n // A boundary can become ineligible if its exports are incompatible\n // with the previous exports.\n //\n // For example, if you add/remove/change exports, we'll want to\n // re-execute the importing modules, and force those components to\n // re-render. Similarly, if you convert a class component to a\n // function, we want to invalidate the boundary.\n if (\n helpers.shouldInvalidateReactRefreshBoundary(\n prevExports,\n currentExports\n )\n ) {\n module.hot.invalidate();\n } else {\n helpers.scheduleUpdate();\n }\n }\n } else {\n // Since we just executed the code for the module, it's possible that the\n // new exports made it ineligible for being a boundary.\n // We only care about the case when we were _previously_ a boundary,\n // because we already accepted this update (accidental side effect).\n const isNoLongerABoundary = prevExports !== null;\n if (isNoLongerABoundary) {\n module.hot.invalidate();\n }\n }\n}\n\nfunction formatDependencyChain(dependencyChain: ModuleId[]): string {\n return `Dependency chain: ${dependencyChain.join(\" -> \")}`;\n}\n\nfunction computeOutdatedModules(\n added: Map,\n modified: Map\n): {\n outdatedModules: Set;\n newModuleFactories: Map;\n} {\n const newModuleFactories = new Map();\n\n for (const [moduleId, entry] of added) {\n if (entry != null) {\n newModuleFactories.set(moduleId, _eval(entry));\n }\n }\n\n const outdatedModules = computedInvalidatedModules(modified.keys());\n\n for (const [moduleId, entry] of modified) {\n newModuleFactories.set(moduleId, _eval(entry));\n }\n\n return { outdatedModules, newModuleFactories };\n}\n\nfunction computedInvalidatedModules(\n invalidated: Iterable\n): Set {\n const outdatedModules = new Set();\n\n for (const moduleId of invalidated) {\n const effect = getAffectedModuleEffects(moduleId);\n\n switch (effect.type) {\n case \"unaccepted\":\n throw new Error(\n `cannot apply update: unaccepted module. ${formatDependencyChain(\n effect.dependencyChain\n )}.`\n );\n case \"self-declined\":\n throw new Error(\n `cannot apply update: self-declined module. ${formatDependencyChain(\n effect.dependencyChain\n )}.`\n );\n case \"accepted\":\n for (const outdatedModuleId of effect.outdatedModules) {\n outdatedModules.add(outdatedModuleId);\n }\n break;\n // TODO(alexkirsz) Dependencies: handle dependencies effects.\n }\n }\n\n return outdatedModules;\n}\n\nfunction computeOutdatedSelfAcceptedModules(\n outdatedModules: Iterable\n): { moduleId: ModuleId; errorHandler: true | Function }[] {\n const outdatedSelfAcceptedModules = [];\n for (const moduleId of outdatedModules) {\n const module = moduleCache[moduleId];\n const hotState = moduleHotState.get(module)!;\n if (module && hotState.selfAccepted && !hotState.selfInvalidated) {\n outdatedSelfAcceptedModules.push({\n moduleId,\n errorHandler: hotState.selfAccepted,\n });\n }\n }\n return outdatedSelfAcceptedModules;\n}\n\n/**\n * Adds, deletes, and moves modules between chunks. This must happen before the\n * dispose phase as it needs to know which modules were removed from all chunks,\n * which we can only compute *after* taking care of added and moved modules.\n */\nfunction updateChunksPhase(\n chunksAddedModules: Map>,\n chunksDeletedModules: Map>\n): { disposedModules: Set } {\n for (const [chunkPath, addedModuleIds] of chunksAddedModules) {\n for (const moduleId of addedModuleIds) {\n addModuleToChunk(moduleId, chunkPath);\n }\n }\n\n const disposedModules: Set = new Set();\n for (const [chunkPath, addedModuleIds] of chunksDeletedModules) {\n for (const moduleId of addedModuleIds) {\n if (removeModuleFromChunk(moduleId, chunkPath)) {\n disposedModules.add(moduleId);\n }\n }\n }\n\n return { disposedModules };\n}\n\nfunction disposePhase(\n outdatedModules: Iterable,\n disposedModules: Iterable\n): { outdatedModuleParents: Map> } {\n for (const moduleId of outdatedModules) {\n disposeModule(moduleId, \"replace\");\n }\n\n for (const moduleId of disposedModules) {\n disposeModule(moduleId, \"clear\");\n }\n\n // Removing modules from the module cache is a separate step.\n // We also want to keep track of previous parents of the outdated modules.\n const outdatedModuleParents = new Map();\n for (const moduleId of outdatedModules) {\n const oldModule = moduleCache[moduleId];\n outdatedModuleParents.set(moduleId, oldModule?.parents);\n delete moduleCache[moduleId];\n }\n\n // TODO(alexkirsz) Dependencies: remove outdated dependency from module\n // children.\n\n return { outdatedModuleParents };\n}\n\n/**\n * Disposes of an instance of a module.\n *\n * Returns the persistent hot data that should be kept for the next module\n * instance.\n *\n * NOTE: mode = \"replace\" will not remove modules from the moduleCache.\n * This must be done in a separate step afterwards.\n * This is important because all modules need to be disposed to update the\n * parent/child relationships before they are actually removed from the moduleCache.\n * If this was done in this method, the following disposeModule calls won't find\n * the module from the module id in the cache.\n */\nfunction disposeModule(moduleId: ModuleId, mode: \"clear\" | \"replace\") {\n const module = moduleCache[moduleId];\n if (!module) {\n return;\n }\n\n const hotState = moduleHotState.get(module)!;\n const data = {};\n\n // Run the `hot.dispose` handler, if any, passing in the persistent\n // `hot.data` object.\n for (const disposeHandler of hotState.disposeHandlers) {\n disposeHandler(data);\n }\n\n // This used to warn in `getOrInstantiateModuleFromParent` when a disposed\n // module is still importing other modules.\n module.hot.active = false;\n\n moduleHotState.delete(module);\n\n // TODO(alexkirsz) Dependencies: delete the module from outdated deps.\n\n // Remove the disposed module from its children's parent list.\n // It will be added back once the module re-instantiates and imports its\n // children again.\n for (const childId of module.children) {\n const child = moduleCache[childId];\n if (!child) {\n continue;\n }\n\n const idx = child.parents.indexOf(module.id);\n if (idx >= 0) {\n child.parents.splice(idx, 1);\n }\n }\n\n switch (mode) {\n case \"clear\":\n delete moduleCache[module.id];\n moduleHotData.delete(module.id);\n break;\n case \"replace\":\n moduleHotData.set(module.id, data);\n break;\n default:\n invariant(mode, (mode) => `invalid mode: ${mode}`);\n }\n}\n\nfunction applyPhase(\n outdatedSelfAcceptedModules: {\n moduleId: ModuleId;\n errorHandler: true | Function;\n }[],\n newModuleFactories: Map,\n outdatedModuleParents: Map>,\n reportError: (err: any) => void\n) {\n // Update module factories.\n for (const [moduleId, factory] of newModuleFactories.entries()) {\n moduleFactories[moduleId] = factory;\n }\n\n // TODO(alexkirsz) Run new runtime entries here.\n\n // TODO(alexkirsz) Dependencies: call accept handlers for outdated deps.\n\n // Re-instantiate all outdated self-accepted modules.\n for (const { moduleId, errorHandler } of outdatedSelfAcceptedModules) {\n try {\n instantiateModule(moduleId, {\n type: SourceType.Update,\n parents: outdatedModuleParents.get(moduleId),\n });\n } catch (err) {\n if (typeof errorHandler === \"function\") {\n try {\n errorHandler(err, { moduleId, module: moduleCache[moduleId] });\n } catch (err2) {\n reportError(err2);\n reportError(err);\n }\n } else {\n reportError(err);\n }\n }\n }\n}\n\n/**\n * Utility function to ensure all variants of an enum are handled.\n */\nfunction invariant(never: never, computeMessage: (arg: any) => string): never {\n throw new Error(`Invariant: ${computeMessage(never)}`);\n}\n\nfunction applyUpdate(chunkListPath: ChunkPath, update: PartialUpdate) {\n switch (update.type) {\n case \"ChunkListUpdate\":\n applyChunkListUpdate(chunkListPath, update);\n break;\n default:\n invariant(update, (update) => `Unknown update type: ${update.type}`);\n }\n}\n\nfunction applyChunkListUpdate(\n chunkListPath: ChunkPath,\n update: ChunkListUpdate\n) {\n if (update.merged != null) {\n for (const merged of update.merged) {\n switch (merged.type) {\n case \"EcmascriptMergedUpdate\":\n applyEcmascriptMergedUpdate(chunkListPath, merged);\n break;\n default:\n invariant(merged, (merged) => `Unknown merged type: ${merged.type}`);\n }\n }\n }\n\n if (update.chunks != null) {\n for (const [chunkPath, chunkUpdate] of Object.entries(update.chunks)) {\n switch (chunkUpdate.type) {\n case \"added\":\n BACKEND.loadChunk(chunkPath, { type: SourceType.Update });\n break;\n case \"total\":\n BACKEND.reloadChunk?.(chunkPath);\n break;\n case \"deleted\":\n BACKEND.unloadChunk?.(chunkPath);\n break;\n case \"partial\":\n invariant(\n chunkUpdate.instruction,\n (instruction) =>\n `Unknown partial instruction: ${JSON.stringify(instruction)}.`\n );\n default:\n invariant(\n chunkUpdate,\n (chunkUpdate) => `Unknown chunk update type: ${chunkUpdate.type}`\n );\n }\n }\n }\n}\n\nfunction applyEcmascriptMergedUpdate(\n chunkPath: ChunkPath,\n update: EcmascriptMergedUpdate\n) {\n const { entries = {}, chunks = {} } = update;\n const { added, modified, chunksAdded, chunksDeleted } = computeChangedModules(\n entries,\n chunks\n );\n const { outdatedModules, newModuleFactories } = computeOutdatedModules(\n added,\n modified\n );\n const { disposedModules } = updateChunksPhase(chunksAdded, chunksDeleted);\n\n applyInternal(outdatedModules, disposedModules, newModuleFactories);\n}\n\nfunction applyInvalidatedModules(outdatedModules: Set) {\n if (queuedInvalidatedModules.size > 0) {\n computedInvalidatedModules(queuedInvalidatedModules).forEach((moduleId) => {\n outdatedModules.add(moduleId);\n });\n\n queuedInvalidatedModules.clear();\n }\n\n return outdatedModules;\n}\n\nfunction applyInternal(\n outdatedModules: Set,\n disposedModules: Iterable,\n newModuleFactories: Map\n) {\n outdatedModules = applyInvalidatedModules(outdatedModules);\n\n const outdatedSelfAcceptedModules =\n computeOutdatedSelfAcceptedModules(outdatedModules);\n\n const { outdatedModuleParents } = disposePhase(\n outdatedModules,\n disposedModules\n );\n\n // we want to continue on error and only throw the error after we tried applying all updates\n let error: any;\n function reportError(err: any) {\n if (!error) error = err;\n }\n\n applyPhase(\n outdatedSelfAcceptedModules,\n newModuleFactories,\n outdatedModuleParents,\n reportError\n );\n\n if (error) {\n throw error;\n }\n\n if (queuedInvalidatedModules.size > 0) {\n applyInternal(new Set(), [], new Map());\n }\n}\n\nfunction computeChangedModules(\n entries: Record,\n updates: Record\n): {\n added: Map;\n modified: Map;\n deleted: Set;\n chunksAdded: Map>;\n chunksDeleted: Map>;\n} {\n const chunksAdded = new Map();\n const chunksDeleted = new Map();\n const added: Map = new Map();\n const modified = new Map();\n const deleted: Set = new Set();\n\n for (const [chunkPath, mergedChunkUpdate] of Object.entries(updates)) {\n switch (mergedChunkUpdate.type) {\n case \"added\": {\n const updateAdded = new Set(mergedChunkUpdate.modules);\n for (const moduleId of updateAdded) {\n added.set(moduleId, entries[moduleId]);\n }\n chunksAdded.set(chunkPath, updateAdded);\n break;\n }\n case \"deleted\": {\n // We could also use `mergedChunkUpdate.modules` here.\n const updateDeleted = new Set(chunkModulesMap.get(chunkPath));\n for (const moduleId of updateDeleted) {\n deleted.add(moduleId);\n }\n chunksDeleted.set(chunkPath, updateDeleted);\n break;\n }\n case \"partial\": {\n const updateAdded = new Set(mergedChunkUpdate.added);\n const updateDeleted = new Set(mergedChunkUpdate.deleted);\n for (const moduleId of updateAdded) {\n added.set(moduleId, entries[moduleId]);\n }\n for (const moduleId of updateDeleted) {\n deleted.add(moduleId);\n }\n chunksAdded.set(chunkPath, updateAdded);\n chunksDeleted.set(chunkPath, updateDeleted);\n break;\n }\n default:\n invariant(\n mergedChunkUpdate,\n (mergedChunkUpdate) =>\n `Unknown merged chunk update type: ${mergedChunkUpdate.type}`\n );\n }\n }\n\n // If a module was added from one chunk and deleted from another in the same update,\n // consider it to be modified, as it means the module was moved from one chunk to another\n // AND has new code in a single update.\n for (const moduleId of added.keys()) {\n if (deleted.has(moduleId)) {\n added.delete(moduleId);\n deleted.delete(moduleId);\n }\n }\n\n for (const [moduleId, entry] of Object.entries(entries)) {\n // Modules that haven't been added to any chunk but have new code are considered\n // to be modified.\n // This needs to be under the previous loop, as we need it to get rid of modules\n // that were added and deleted in the same update.\n if (!added.has(moduleId)) {\n modified.set(moduleId, entry);\n }\n }\n\n return { added, deleted, modified, chunksAdded, chunksDeleted };\n}\n\ntype ModuleEffect =\n | {\n type: \"unaccepted\";\n dependencyChain: ModuleId[];\n }\n | {\n type: \"self-declined\";\n dependencyChain: ModuleId[];\n moduleId: ModuleId;\n }\n | {\n type: \"accepted\";\n moduleId: ModuleId;\n outdatedModules: Set;\n };\n\nfunction getAffectedModuleEffects(moduleId: ModuleId): ModuleEffect {\n const outdatedModules: Set = new Set();\n\n type QueueItem = { moduleId?: ModuleId; dependencyChain: ModuleId[] };\n\n const queue: QueueItem[] = [\n {\n moduleId,\n dependencyChain: [],\n },\n ];\n\n let nextItem;\n while ((nextItem = queue.shift())) {\n const { moduleId, dependencyChain } = nextItem;\n\n if (moduleId != null) {\n outdatedModules.add(moduleId);\n }\n\n // We've arrived at the runtime of the chunk, which means that nothing\n // else above can accept this update.\n if (moduleId === undefined) {\n return {\n type: \"unaccepted\",\n dependencyChain,\n };\n }\n\n const module = moduleCache[moduleId];\n const hotState = moduleHotState.get(module)!;\n\n if (\n // The module is not in the cache. Since this is a \"modified\" update,\n // it means that the module was never instantiated before.\n !module || // The module accepted itself without invalidating globalThis.\n // TODO is that right?\n (hotState.selfAccepted && !hotState.selfInvalidated)\n ) {\n continue;\n }\n\n if (hotState.selfDeclined) {\n return {\n type: \"self-declined\",\n dependencyChain,\n moduleId,\n };\n }\n\n if (runtimeModules.has(moduleId)) {\n queue.push({\n moduleId: undefined,\n dependencyChain: [...dependencyChain, moduleId],\n });\n continue;\n }\n\n for (const parentId of module.parents) {\n const parent = moduleCache[parentId];\n\n if (!parent) {\n // TODO(alexkirsz) Is this even possible?\n continue;\n }\n\n // TODO(alexkirsz) Dependencies: check accepted and declined\n // dependencies here.\n\n queue.push({\n moduleId: parentId,\n dependencyChain: [...dependencyChain, moduleId],\n });\n }\n }\n\n return {\n type: \"accepted\",\n moduleId,\n outdatedModules,\n };\n}\n\nfunction handleApply(chunkListPath: ChunkPath, update: ServerMessage) {\n switch (update.type) {\n case \"partial\": {\n // This indicates that the update is can be applied to the current state of the application.\n applyUpdate(chunkListPath, update.instruction);\n break;\n }\n case \"restart\": {\n // This indicates that there is no way to apply the update to the\n // current state of the application, and that the application must be\n // restarted.\n BACKEND.restart();\n break;\n }\n case \"notFound\": {\n // This indicates that the chunk list no longer exists: either the dynamic import which created it was removed,\n // or the page itself was deleted.\n // If it is a dynamic import, we simply discard all modules that the chunk has exclusive access to.\n // If it is a runtime chunk list, we restart the application.\n if (runtimeChunkLists.has(chunkListPath)) {\n BACKEND.restart();\n } else {\n disposeChunkList(chunkListPath);\n }\n break;\n }\n default:\n throw new Error(`Unknown update type: ${update.type}`);\n }\n}\n\nfunction createModuleHot(\n moduleId: ModuleId,\n hotData: HotData\n): { hot: Hot; hotState: HotState } {\n const hotState: HotState = {\n selfAccepted: false,\n selfDeclined: false,\n selfInvalidated: false,\n disposeHandlers: [],\n };\n\n const hot: Hot = {\n // TODO(alexkirsz) This is not defined in the HMR API. It was used to\n // decide whether to warn whenever an HMR-disposed module required other\n // modules. We might want to remove it.\n active: true,\n\n data: hotData ?? {},\n\n // TODO(alexkirsz) Support full (dep, callback, errorHandler) form.\n accept: (\n modules?: string | string[] | AcceptErrorHandler,\n _callback?: AcceptCallback,\n _errorHandler?: AcceptErrorHandler\n ) => {\n if (modules === undefined) {\n hotState.selfAccepted = true;\n } else if (typeof modules === \"function\") {\n hotState.selfAccepted = modules;\n } else {\n throw new Error(\"unsupported `accept` signature\");\n }\n },\n\n decline: (dep) => {\n if (dep === undefined) {\n hotState.selfDeclined = true;\n } else {\n throw new Error(\"unsupported `decline` signature\");\n }\n },\n\n dispose: (callback) => {\n hotState.disposeHandlers.push(callback);\n },\n\n addDisposeHandler: (callback) => {\n hotState.disposeHandlers.push(callback);\n },\n\n removeDisposeHandler: (callback) => {\n const idx = hotState.disposeHandlers.indexOf(callback);\n if (idx >= 0) {\n hotState.disposeHandlers.splice(idx, 1);\n }\n },\n\n invalidate: () => {\n hotState.selfInvalidated = true;\n queuedInvalidatedModules.add(moduleId);\n },\n\n // NOTE(alexkirsz) This is part of the management API, which we don't\n // implement, but the Next.js React Refresh runtime uses this to decide\n // whether to schedule an update.\n status: () => \"idle\",\n\n // NOTE(alexkirsz) Since we always return \"idle\" for now, these are no-ops.\n addStatusHandler: (_handler) => {},\n removeStatusHandler: (_handler) => {},\n };\n\n return { hot, hotState };\n}\n\n/**\n * Adds a module to a chunk.\n */\nfunction addModuleToChunk(moduleId: ModuleId, chunkPath: ChunkPath) {\n let moduleChunks = moduleChunksMap.get(moduleId);\n if (!moduleChunks) {\n moduleChunks = new Set([chunkPath]);\n moduleChunksMap.set(moduleId, moduleChunks);\n } else {\n moduleChunks.add(chunkPath);\n }\n\n let chunkModules = chunkModulesMap.get(chunkPath);\n if (!chunkModules) {\n chunkModules = new Set([moduleId]);\n chunkModulesMap.set(chunkPath, chunkModules);\n } else {\n chunkModules.add(moduleId);\n }\n}\n\n/**\n * Returns the first chunk that included a module.\n * This is used by the Node.js backend, hence why it's marked as unused in this\n * file.\n */\nfunction getFirstModuleChunk(moduleId: ModuleId) {\n const moduleChunkPaths = moduleChunksMap.get(moduleId);\n if (moduleChunkPaths == null) {\n return null;\n }\n\n return moduleChunkPaths.values().next().value;\n}\n\n/**\n * Removes a module from a chunk.\n * Returns `true` if there are no remaining chunks including this module.\n */\nfunction removeModuleFromChunk(\n moduleId: ModuleId,\n chunkPath: ChunkPath\n): boolean {\n const moduleChunks = moduleChunksMap.get(moduleId)!;\n moduleChunks.delete(chunkPath);\n\n const chunkModules = chunkModulesMap.get(chunkPath)!;\n chunkModules.delete(moduleId);\n\n const noRemainingModules = chunkModules.size === 0;\n if (noRemainingModules) {\n chunkModulesMap.delete(chunkPath);\n }\n\n const noRemainingChunks = moduleChunks.size === 0;\n if (noRemainingChunks) {\n moduleChunksMap.delete(moduleId);\n }\n\n return noRemainingChunks;\n}\n\n/**\n * Disposes of a chunk list and its corresponding exclusive chunks.\n */\nfunction disposeChunkList(chunkListPath: ChunkPath): boolean {\n const chunkPaths = chunkListChunksMap.get(chunkListPath);\n if (chunkPaths == null) {\n return false;\n }\n chunkListChunksMap.delete(chunkListPath);\n\n for (const chunkPath of chunkPaths) {\n const chunkChunkLists = chunkChunkListsMap.get(chunkPath)!;\n chunkChunkLists.delete(chunkListPath);\n\n if (chunkChunkLists.size === 0) {\n chunkChunkListsMap.delete(chunkPath);\n disposeChunk(chunkPath);\n }\n }\n\n // We must also dispose of the chunk list's chunk itself to ensure it may\n // be reloaded properly in the future.\n BACKEND.unloadChunk?.(chunkListPath);\n\n return true;\n}\n\n/**\n * Disposes of a chunk and its corresponding exclusive modules.\n *\n * @returns Whether the chunk was disposed of.\n */\nfunction disposeChunk(chunkPath: ChunkPath): boolean {\n // This should happen whether the chunk has any modules in it or not.\n // For instance, CSS chunks have no modules in them, but they still need to be unloaded.\n BACKEND.unloadChunk?.(chunkPath);\n\n const chunkModules = chunkModulesMap.get(chunkPath);\n if (chunkModules == null) {\n return false;\n }\n chunkModules.delete(chunkPath);\n\n for (const moduleId of chunkModules) {\n const moduleChunks = moduleChunksMap.get(moduleId)!;\n moduleChunks.delete(chunkPath);\n\n const noRemainingChunks = moduleChunks.size === 0;\n if (noRemainingChunks) {\n moduleChunksMap.delete(moduleId);\n disposeModule(moduleId, \"clear\");\n availableModules.delete(moduleId);\n }\n }\n\n return true;\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 * Gets or instantiates a runtime module.\n */\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 instantiateModule(moduleId, { type: SourceType.Runtime, chunkPath });\n}\n\n/**\n * Returns the URL relative to the origin where a chunk can be fetched from.\n */\nfunction getChunkRelativeUrl(chunkPath: ChunkPath): string {\n return `${CHUNK_BASE_PATH}${chunkPath}`;\n}\n\n/**\n * Subscribes to chunk list updates from the update server and applies them.\n */\nfunction registerChunkList(\n chunkUpdateProvider: ChunkUpdateProvider,\n chunkList: ChunkList\n) {\n chunkUpdateProvider.push([\n chunkList.path,\n handleApply.bind(null, chunkList.path),\n ]);\n\n // Adding chunks to chunk lists and vice versa.\n const chunks = new Set(chunkList.chunks.map(getChunkPath));\n chunkListChunksMap.set(chunkList.path, chunks);\n for (const chunkPath of chunks) {\n let chunkChunkLists = chunkChunkListsMap.get(chunkPath);\n if (!chunkChunkLists) {\n chunkChunkLists = new Set([chunkList.path]);\n chunkChunkListsMap.set(chunkPath, chunkChunkLists);\n } else {\n chunkChunkLists.add(chunkList.path);\n }\n }\n\n if (chunkList.source === \"entry\") {\n markChunkListAsRuntime(chunkList.path);\n }\n}\n\n/**\n * Marks a chunk list as a runtime chunk list. There can be more than one\n * runtime chunk list. For instance, integration tests can have multiple chunk\n * groups loaded at runtime, each with its own chunk list.\n */\nfunction markChunkListAsRuntime(chunkListPath: ChunkPath) {\n runtimeChunkLists.add(chunkListPath);\n}\n\nfunction registerChunk([\n chunkPath,\n chunkModules,\n runtimeParams,\n]: ChunkRegistration) {\n for (const [moduleId, moduleFactory] of Object.entries(chunkModules)) {\n if (!moduleFactories[moduleId]) {\n moduleFactories[moduleId] = moduleFactory;\n }\n addModuleToChunk(moduleId, chunkPath);\n }\n\n return BACKEND.registerChunk(chunkPath, runtimeParams);\n}\n\nglobalThis.TURBOPACK_CHUNK_UPDATE_LISTENERS ??= [];\n\nconst chunkListsToRegister = globalThis.TURBOPACK_CHUNK_LISTS;\nif (Array.isArray(chunkListsToRegister)) {\n for (const chunkList of chunkListsToRegister) {\n registerChunkList(globalThis.TURBOPACK_CHUNK_UPDATE_LISTENERS, chunkList);\n }\n}\n\nglobalThis.TURBOPACK_CHUNK_LISTS = {\n push: (chunkList) => {\n registerChunkList(globalThis.TURBOPACK_CHUNK_UPDATE_LISTENERS!, chunkList);\n },\n} satisfies ChunkListProvider;\n"],"names":[],"mappings":";;;;;;;IAiEA;UAAK,UAAU;IAAV,WAAA,WAKH,aAAU,KAAV;IALG,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OAAO;YACL,gBAAgB,GAAG,CAAC,UAAU,IAAI;QACpC;IACF;IAEA,IAAI,UAAU,MAAM,KAAK,SAAS;QAChC,uBAAuB,UAAU,IAAI;IACvC;AACF;AAOA,SAAS,uBAAuB,aAAwB;IACtD,kBAAkB,GAAG,CAAC;AACxB;AAEA,SAAS,cAAc,CACrB,WACA,cACA,cACkB;IAClB,KAAK,MAAM,CAAC,UAAU,cAAc,IAAI,OAAO,OAAO,CAAC,cAAe;QACpE,IAAI,CAAC,eAAe,CAAC,SAAS,EAAE;YAC9B,eAAe,CAAC,SAAS,GAAG;QAC9B;QACA,iBAAiB,UAAU;IAC7B;IAEA,OAAO,QAAQ,aAAa,CAAC,WAAW;AAC1C;AAEA,WAAW,gCAAgC,KAAK,EAAE;AAElD,MAAM,uBAAuB,WAAW,qBAAqB;AAC7D,IAAI,MAAM,OAAO,CAAC,uBAAuB;IACvC,KAAK,MAAM,aAAa,qBAAsB;QAC5C,kBAAkB,WAAW,gCAAgC,EAAE;IACjE;AACF;AAEA,WAAW,qBAAqB,GAAG;IACjC,MAAM,CAAC;QACL,kBAAkB,WAAW,gCAAgC,EAAG;IAClE;AACF"}}, + {"offset": {"line": 1046, "column": 0}, "map": {"version":3,"sources":["/turbopack/[turbopack]/dev/runtime/dom/runtime-backend-dom.ts"],"sourcesContent":["/**\n * This file contains the runtime code specific to the Turbopack development\n * ECMAScript DOM runtime.\n *\n * It will be appended to the base development runtime code.\n */\n\n/// \n\ntype ChunkResolver = {\n resolved: boolean;\n resolve: () => void;\n reject: (error?: Error) => void;\n promise: Promise;\n};\n\nlet BACKEND: RuntimeBackend;\n\nfunction augmentContext(context: TurbopackDevBaseContext): TurbopackDevContext {\n return context;\n}\n\nfunction commonJsRequireContext(\n entry: RequireContextEntry,\n sourceModule: Module\n): Exports {\n return commonJsRequire(sourceModule, entry.id());\n}\n\n(() => {\n BACKEND = {\n async registerChunk(chunkPath, params) {\n const resolver = getOrCreateResolver(chunkPath);\n resolver.resolve();\n\n if (params == null) {\n return;\n }\n\n for (const otherChunkData of params.otherChunks) {\n const otherChunkPath = getChunkPath(otherChunkData);\n // Chunk might have started loading, so we want to avoid triggering another load.\n getOrCreateResolver(otherChunkPath);\n }\n\n // This waits for chunks to be loaded, but also marks included items as available.\n await Promise.all(\n params.otherChunks.map((otherChunkData) =>\n loadChunk({ type: SourceType.Runtime, chunkPath }, otherChunkData)\n )\n );\n\n if (params.runtimeModuleIds.length > 0) {\n for (const moduleId of params.runtimeModuleIds) {\n getOrInstantiateRuntimeModule(moduleId, chunkPath);\n }\n }\n },\n\n loadChunk(chunkPath, source) {\n return doLoadChunk(chunkPath, source);\n },\n\n unloadChunk(chunkPath) {\n deleteResolver(chunkPath);\n\n const chunkUrl = getChunkRelativeUrl(chunkPath);\n\n if (chunkPath.endsWith(\".css\")) {\n const links = document.querySelectorAll(`link[href=\"${chunkUrl}\"]`);\n for (const link of Array.from(links)) {\n link.remove();\n }\n } else if (chunkPath.endsWith(\".js\")) {\n // Unloading a JS chunk would have no effect, as it lives in the JS\n // runtime once evaluated.\n // However, we still want to remove the script tag from the DOM to keep\n // the HTML somewhat consistent from the user's perspective.\n const scripts = document.querySelectorAll(`script[src=\"${chunkUrl}\"]`);\n for (const script of Array.from(scripts)) {\n script.remove();\n }\n } else {\n throw new Error(`can't infer type of chunk from path ${chunkPath}`);\n }\n },\n\n reloadChunk(chunkPath) {\n return new Promise((resolve, reject) => {\n if (!chunkPath.endsWith(\".css\")) {\n reject(new Error(\"The DOM backend can only reload CSS chunks\"));\n return;\n }\n\n const encodedChunkPath = chunkPath\n .split(\"/\")\n .map((p) => encodeURIComponent(p))\n .join(\"/\");\n\n const chunkUrl = `/${getChunkRelativeUrl(encodedChunkPath)}`;\n\n const previousLink = document.querySelector(\n `link[rel=stylesheet][href^=\"${chunkUrl}\"]`\n );\n\n if (previousLink == null) {\n reject(new Error(`No link element found for chunk ${chunkPath}`));\n return;\n }\n\n const link = document.createElement(\"link\");\n link.rel = \"stylesheet\";\n link.href = chunkUrl;\n link.onerror = () => {\n reject();\n };\n link.onload = () => {\n // First load the new CSS, then remove the old one. This prevents visible\n // flickering that would happen in-between removing the previous CSS and\n // loading the new one.\n previousLink.remove();\n\n // CSS chunks do not register themselves, and as such must be marked as\n // loaded instantly.\n resolve();\n };\n\n // Make sure to insert the new CSS right after the previous one, so that\n // its precedence is higher.\n previousLink.parentElement!.insertBefore(\n link,\n previousLink.nextSibling\n );\n });\n },\n\n restart: () => self.location.reload(),\n };\n\n /**\n * Maps chunk paths to the corresponding resolver.\n */\n const chunkResolvers: Map = new Map();\n\n function getOrCreateResolver(chunkPath: ChunkPath): ChunkResolver {\n let resolver = chunkResolvers.get(chunkPath);\n if (!resolver) {\n let resolve: () => void;\n let reject: (error?: Error) => void;\n const promise = new Promise((innerResolve, innerReject) => {\n resolve = innerResolve;\n reject = innerReject;\n });\n resolver = {\n resolved: false,\n promise,\n resolve: () => {\n resolver!.resolved = true;\n resolve();\n },\n reject: reject!,\n };\n chunkResolvers.set(chunkPath, resolver);\n }\n return resolver;\n }\n\n function deleteResolver(chunkPath: ChunkPath) {\n chunkResolvers.delete(chunkPath);\n }\n\n /**\n * Loads the given chunk, and returns a promise that resolves once the chunk\n * has been loaded.\n */\n async function doLoadChunk(chunkPath: ChunkPath, source: SourceInfo) {\n const resolver = getOrCreateResolver(chunkPath);\n if (resolver.resolved) {\n return resolver.promise;\n }\n\n if (source.type === SourceType.Runtime) {\n // We don't need to load chunks references from runtime code, as they're already\n // present in the DOM.\n\n if (chunkPath.endsWith(\".css\")) {\n // CSS chunks do not register themselves, and as such must be marked as\n // loaded instantly.\n resolver.resolve();\n }\n\n // We need to wait for JS chunks to register themselves within `registerChunk`\n // before we can start instantiating runtime modules, hence the absence of\n // `resolver.resolve()` in this branch.\n\n return resolver.promise;\n }\n\n const chunkUrl = `/${getChunkRelativeUrl(chunkPath)}`;\n\n if (chunkPath.endsWith(\".css\")) {\n const link = document.createElement(\"link\");\n link.rel = \"stylesheet\";\n link.href = chunkUrl;\n link.onerror = () => {\n resolver.reject();\n };\n link.onload = () => {\n // CSS chunks do not register themselves, and as such must be marked as\n // loaded instantly.\n resolver.resolve();\n };\n document.body.appendChild(link);\n } else if (chunkPath.endsWith(\".js\")) {\n const script = document.createElement(\"script\");\n script.src = chunkUrl;\n // We'll only mark the chunk as loaded once the script has been executed,\n // which happens in `registerChunk`. Hence the absence of `resolve()` in\n // this branch.\n script.onerror = () => {\n resolver.reject();\n };\n document.body.appendChild(script);\n } else {\n throw new Error(`can't infer type of chunk from path ${chunkPath}`);\n }\n\n return resolver.promise;\n }\n})();\n\nfunction _eval({ code, url, map }: EcmascriptModuleEntry): ModuleFactory {\n code += `\\n\\n//# sourceURL=${location.origin}/${url}`;\n if (map) code += `\\n//# sourceMappingURL=${map}`;\n return eval(code);\n}\n"],"names":[],"mappings":"AAgBA,IAAI;AAEJ,SAAS,eAAe,QAAgC;IACtD,OAAO;AACT;AAEA,SAAS,uBACP,MAA0B,EAC1B,aAAoB;IAEpB,OAAO,gBAAgB,eAAc,OAAM,EAAE;AAC/C;AAEC,CAAA;IACC,UAAU;QACR,MAAM,eAAc,UAAS,EAAE,OAAM;YACnC,MAAM,YAAW,qBAAoB;YACrC,UAAS,OAAO;YAEhB,IAAI,WAAU,MAAM;gBAClB;YACF;YAEA,KAAK,MAAM,mBAAkB,QAAO,WAAW,CAAE;gBAC/C,MAAM,kBAAiB,aAAa;gBAEpC,qBAAoB;YACtB;YAGA,MAAM,QAAQ,GAAG,CACf,QAAO,WAAW,CAAC,GAAG,CAAC,CAAC,kBACtB,UAAU;oBAAE,MAAM,WAAW,OAAO;oBAAE,WAAA;gBAAU,GAAG;YAIvD,IAAI,QAAO,gBAAgB,CAAC,MAAM,GAAG,GAAG;gBACtC,KAAK,MAAM,aAAY,QAAO,gBAAgB,CAAE;oBAC9C,8BAA8B,WAAU;gBAC1C;YACF;QACF;QAEA,WAAU,UAAS,EAAE,OAAM;YACzB,OAAO,aAAY,YAAW;QA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AAS,IAAI,CAAC,WAAW,CAAC;QAC5B,OAAO;YACL,MAAM,IAAI,MAAM,CAAC,oCAAoC,EAAE,WAAU,CAAC;QACpE;QAEA,OAAO,UAAS,OAAO;IACzB;AACF,CAAA;AAEA,SAAS,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAyB;IACtD,QAAQ,CAAC,kBAAkB,EAAE,SAAS,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC;IACrD,IAAI,KAAK,QAAQ,CAAC,uBAAuB,EAAE,IAAI,CAAC;IAChD,OAAO,KAAK;AACd"}}, + {"offset": {"line": 1190, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}] } \ No newline at end of file From 5556ebd666e734beb10fdfb69154c1958c965a83 Mon Sep 17 00:00:00 2001 From: hrmny Date: Wed, 19 Jul 2023 17:06:21 +0200 Subject: [PATCH 14/16] unsimplify `dynamicExport` --- .../js/src/build/runtime.ts | 2 +- .../js/src/dev/runtime/base/runtime-base.ts | 2 +- .../js/src/shared-node/require.ts | 6 +- .../js/src/shared/runtime-utils.ts | 72 ++++++++++--------- crates/turbopack-test-utils/Cargo.toml | 2 +- .../unexpected export __star__-884def.txt | 3 + .../output/[turbopack]_runtime.js | 56 ++++++++------- .../output/[turbopack]_runtime.js.map | 6 +- ..._default_dev_runtime_input_index_e60ecd.js | 56 ++++++++------- ...ault_dev_runtime_input_index_e60ecd.js.map | 8 +-- 10 files changed, 113 insertions(+), 100 deletions(-) create mode 100644 crates/turbopack-tests/tests/execution/turbopack/async-modules/export-all/issues/unexpected export __star__-884def.txt diff --git a/crates/turbopack-ecmascript-runtime/js/src/build/runtime.ts b/crates/turbopack-ecmascript-runtime/js/src/build/runtime.ts index 53c2105f9070f..d3b2331d1ed7f 100644 --- a/crates/turbopack-ecmascript-runtime/js/src/build/runtime.ts +++ b/crates/turbopack-ecmascript-runtime/js/src/build/runtime.ts @@ -129,7 +129,7 @@ function instantiateModule(id: ModuleId, source: SourceInfo): Module { f: requireContext.bind(null, module), i: esmImport.bind(null, module), s: esm.bind(null, module.exports), - j: dynamicExport.bind(null, module.exports), + j: dynamicExport.bind(null, module, module.exports), v: exportValue.bind(null, module), n: exportNamespace.bind(null, module), m: module, diff --git a/crates/turbopack-ecmascript-runtime/js/src/dev/runtime/base/runtime-base.ts b/crates/turbopack-ecmascript-runtime/js/src/dev/runtime/base/runtime-base.ts index 69e83438c9712..69fb3f5ace44c 100644 --- a/crates/turbopack-ecmascript-runtime/js/src/dev/runtime/base/runtime-base.ts +++ b/crates/turbopack-ecmascript-runtime/js/src/dev/runtime/base/runtime-base.ts @@ -326,7 +326,7 @@ function instantiateModule(id: ModuleId, source: SourceInfo): Module { f: requireContext.bind(null, module), i: esmImport.bind(null, module), s: esmExport.bind(null, module, module.exports), - j: dynamicExport.bind(null, module.exports), + j: dynamicExport.bind(null, module, module.exports), v: exportValue.bind(null, module), n: exportNamespace.bind(null, module), m: module, diff --git a/crates/turbopack-ecmascript-runtime/js/src/shared-node/require.ts b/crates/turbopack-ecmascript-runtime/js/src/shared-node/require.ts index 64e51367b3885..eeea53a7945d4 100644 --- a/crates/turbopack-ecmascript-runtime/js/src/shared-node/require.ts +++ b/crates/turbopack-ecmascript-runtime/js/src/shared-node/require.ts @@ -40,11 +40,9 @@ function externalRequire( } externalRequire.resolve = ( id: string, - options?: - | { - paths?: string[] | undefined; + options?: { + paths?: string[]; } - | undefined ) => { return require.resolve(id, options); }; diff --git a/crates/turbopack-ecmascript-runtime/js/src/shared/runtime-utils.ts b/crates/turbopack-ecmascript-runtime/js/src/shared/runtime-utils.ts index 94e7306bb0bff..3e23c4c28227f 100644 --- a/crates/turbopack-ecmascript-runtime/js/src/shared/runtime-utils.ts +++ b/crates/turbopack-ecmascript-runtime/js/src/shared/runtime-utils.ts @@ -94,23 +94,50 @@ function esmExport( esm(exports, getters); } +function ensureDynamicExports(module: Module, exports: Exports) { + let reexportedObjects = module[REEXPORTED_OBJECTS]; + + if (!reexportedObjects) { + reexportedObjects = module[REEXPORTED_OBJECTS] = []; + module.exports = module.namespaceObject = new Proxy(exports, { + get(target, prop) { + if ( + hasOwnProperty.call(target, prop) || + prop === "default" || + prop === "__esModule" + ) { + return Reflect.get(target, prop); + } + for (const obj of reexportedObjects!) { + const value = Reflect.get(obj, prop); + if (value !== undefined) return value; + } + return undefined; + }, + ownKeys(target) { + const keys = Reflect.ownKeys(target); + for (const obj of reexportedObjects!) { + for (const key of Reflect.ownKeys(obj)) { + if (key !== "default" && !keys.includes(key)) keys.push(key); + } + } + return keys; + }, + }); + } +} + /** * Dynamically exports properties from an object */ function dynamicExport( + module: Module, exports: Exports, object: Record ) { - const keys = Reflect.ownKeys(exports); + ensureDynamicExports(module, exports); - for (const key of Reflect.ownKeys(object)) { - if (key !== "default" && !keys.includes(key)) { - defineProp(exports, key, { - get: createGetter(object, key), - enumerable: true, - }); - } - } + module[REEXPORTED_OBJECTS]!.push(object); } function exportValue(module: Module, value: any) { @@ -251,31 +278,6 @@ function isAsyncModuleExt(obj: T): obj is AsyncModuleExt & T { return turbopackQueues in obj; } -function maybeWrapAsyncModulePromise( - promise: Promise, - then: (val: T) => U | PromiseLike -): typeof promise extends AsyncModulePromise - ? AsyncModulePromise - : Promise { - const newPromise = promise.then(then); - - if (isAsyncModuleExt(promise)) { - Object.assign(newPromise, { - get [turbopackExports]() { - return promise[turbopackExports]; - }, - get [turbopackQueues]() { - return promise[turbopackQueues]; - }, - get [turbopackError]() { - return promise[turbopackError]; - }, - } satisfies AsyncModuleExt); - } - - return newPromise as any; -} - function createPromise() { let resolve: (value: T | PromiseLike) => void; let reject: (reason?: any) => void; @@ -371,6 +373,8 @@ function asyncModule( : undefined; const depQueues: Set = new Set(); + + ensureDynamicExports(module, module.exports); const exports = module.exports; const { resolve, reject, promise: rawPromise } = createPromise(); diff --git a/crates/turbopack-test-utils/Cargo.toml b/crates/turbopack-test-utils/Cargo.toml index 21ceac46f645e..3932e60935f13 100644 --- a/crates/turbopack-test-utils/Cargo.toml +++ b/crates/turbopack-test-utils/Cargo.toml @@ -18,8 +18,8 @@ similar = "2.2.0" turbo-tasks = { workspace = true } turbo-tasks-fs = { workspace = true } turbo-tasks-hash = { workspace = true } -turbopack-core = { workspace = true } turbopack-cli-utils = { workspace = true } +turbopack-core = { workspace = true } [build-dependencies] turbo-tasks-build = { workspace = true } diff --git a/crates/turbopack-tests/tests/execution/turbopack/async-modules/export-all/issues/unexpected export __star__-884def.txt b/crates/turbopack-tests/tests/execution/turbopack/async-modules/export-all/issues/unexpected export __star__-884def.txt new file mode 100644 index 0000000000000..9065f2102176f --- /dev/null +++ b/crates/turbopack-tests/tests/execution/turbopack/async-modules/export-all/issues/unexpected export __star__-884def.txt @@ -0,0 +1,3 @@ +warning - [analyze] [project]/crates/turbopack-tests/tests/execution/turbopack/async-modules/export-all/input/exports.js unexpected export * + export * used with module [project]/crates/turbopack-tests/tests/execution/turbopack/async-modules/export-all/input/exports.js (ecmascript) which is a CommonJS module with exports only available at runtime + List all export names manually (`export { a, b, c } from "...") or rewrite the module to ESM, to avoid the additional runtime code.` \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js b/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js index 06c35987297fa..403386275004d 100644 --- a/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js +++ b/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js @@ -28,17 +28,37 @@ function esmExport(module, exports, getters) { module.namespaceObject = module.exports; esm(exports, getters); } -function dynamicExport(module, exports, object) { - const keys = Reflect.ownKeys(exports); - for (const key of Reflect.ownKeys(object)){ - if (key !== "default" && !keys.includes(key)) { - defineProp(exports, key, { - get: createGetter(object, key), - enumerable: true - }); - } +function ensureDynamicExports(module, exports) { + let reexportedObjects = module[REEXPORTED_OBJECTS]; + if (!reexportedObjects) { + reexportedObjects = module[REEXPORTED_OBJECTS] = []; + module.exports = module.namespaceObject = new Proxy(exports, { + get (target, prop) { + if (hasOwnProperty.call(target, prop) || prop === "default" || prop === "__esModule") { + return Reflect.get(target, prop); + } + for (const obj of reexportedObjects){ + const value = Reflect.get(obj, prop); + if (value !== undefined) return value; + } + return undefined; + }, + ownKeys (target) { + const keys = Reflect.ownKeys(target); + for (const obj of reexportedObjects){ + for (const key of Reflect.ownKeys(obj)){ + if (key !== "default" && !keys.includes(key)) keys.push(key); + } + } + return keys; + } + }); } } +function dynamicExport(module, exports, object) { + ensureDynamicExports(module, exports); + module[REEXPORTED_OBJECTS].push(object); +} function exportValue(module, value) { module.exports = value; } @@ -109,23 +129,6 @@ function isPromise(maybePromise) { function isAsyncModuleExt(obj) { return turbopackQueues in obj; } -function maybeWrapAsyncModulePromise(promise, then) { - const newPromise = promise.then(then); - if (isAsyncModuleExt(promise)) { - Object.assign(newPromise, { - get [turbopackExports] () { - return promise[turbopackExports]; - }, - get [turbopackQueues] () { - return promise[turbopackQueues]; - }, - get [turbopackError] () { - return promise[turbopackError]; - } - }); - } - return newPromise; -} function createPromise() { let resolve; let reject; @@ -183,6 +186,7 @@ function asyncModule(module, body, hasAwait) { resolved: true }) : undefined; const depQueues = new Set(); + ensureDynamicExports(module, module.exports); const exports = module.exports; const { resolve, reject, promise: rawPromise } = createPromise(); const promise = Object.assign(rawPromise, { diff --git a/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js.map b/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js.map index 10b7f4d4425f4..0372513fa747a 100644 --- a/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js.map +++ b/crates/turbopack-tests/tests/snapshot/runtime/default_build_runtime/output/[turbopack]_runtime.js.map @@ -1,7 +1,7 @@ { "version": 3, "sections": [ - {"offset": {"line": 1, "column": 0}, "map": {"version":3,"sources":["/turbopack/[turbopack]/shared/runtime-utils.ts"],"sourcesContent":["/**\n * This file contains runtime types and functions that are shared between all\n * TurboPack ECMAScript runtimes.\n *\n * It will be prepended to the runtime code of each runtime.\n */\n\n/* eslint-disable @next/next/no-assign-module-variable */\n\n/// \n\ninterface Exports {\n __esModule?: boolean;\n\n [key: string]: any;\n}\n\ntype EsmNamespaceObject = Record;\n\nconst REEXPORTED_OBJECTS = Symbol(\"reexported objects\");\n\ninterface BaseModule {\n exports: Exports | Promise | AsyncModulePromise;\n error: Error | undefined;\n loaded: boolean;\n id: ModuleId;\n children: ModuleId[];\n parents: ModuleId[];\n namespaceObject?:\n | EsmNamespaceObject\n | Promise\n | AsyncModulePromise;\n [REEXPORTED_OBJECTS]?: any[];\n}\n\ninterface Module extends BaseModule {}\n\ntype RequireContextMap = Record;\n\ninterface RequireContextEntry {\n id: () => ModuleId;\n}\n\ninterface RequireContext {\n (moduleId: ModuleId): Exports | EsmNamespaceObject;\n\n keys(): ModuleId[];\n\n resolve(moduleId: ModuleId): ModuleId;\n}\n\ntype GetOrInstantiateModuleFromParent = (\n moduleId: ModuleId,\n parentModule: Module\n) => Module;\n\ntype CommonJsRequireContext = (\n entry: RequireContextEntry,\n parentModule: Module\n) => Exports;\n\nconst hasOwnProperty = Object.prototype.hasOwnProperty;\nconst toStringTag = typeof Symbol !== \"undefined\" && Symbol.toStringTag;\n\nfunction defineProp(\n obj: any,\n name: PropertyKey,\n options: PropertyDescriptor & ThisType\n) {\n if (!hasOwnProperty.call(obj, name))\n Object.defineProperty(obj, name, options);\n}\n\n/**\n * Adds the getters to the exports object.\n */\nfunction esm(exports: Exports, getters: Record any>) {\n defineProp(exports, \"__esModule\", { value: true });\n if (toStringTag) defineProp(exports, toStringTag, { value: \"Module\" });\n for (const key in getters) {\n defineProp(exports, key, { get: getters[key], enumerable: true });\n }\n}\n\n/**\n * Makes the module an ESM with exports\n */\nfunction esmExport(\n module: Module,\n exports: Exports,\n getters: Record any>\n) {\n module.namespaceObject = module.exports;\n esm(exports, getters);\n}\n\n/**\n * Dynamically exports properties from an object\n */\nfunction dynamicExport(\n module: Module,\n exports: Exports,\n object: Record\n) {\n const keys = Reflect.ownKeys(exports);\n\n for (const key of Reflect.ownKeys(object)) {\n if (key !== \"default\" && !keys.includes(key)) {\n defineProp(exports, key, {\n get: createGetter(object, key),\n enumerable: true,\n });\n }\n }\n}\n\nfunction exportValue(module: Module, value: any) {\n module.exports = value;\n}\n\nfunction exportNamespace(module: Module, namespace: any) {\n module.exports = module.namespaceObject = namespace;\n}\n\nfunction createGetter(obj: Record, key: string | symbol) {\n return () => obj[key];\n}\n\n/**\n * @returns prototype of the object\n */\nconst getProto: (obj: any) => any = Object.getPrototypeOf\n ? (obj) => Object.getPrototypeOf(obj)\n : (obj) => obj.__proto__;\n\n/** Prototypes that are not expanded for exports */\nconst LEAF_PROTOTYPES = [null, getProto({}), getProto([]), getProto(getProto)];\n\n/**\n * @param raw\n * @param ns\n * @param allowExportDefault\n * * `false`: will have the raw module as default export\n * * `true`: will have the default property as default export\n */\nfunction interopEsm(\n raw: Exports,\n ns: EsmNamespaceObject,\n allowExportDefault?: boolean\n) {\n const getters: { [s: string]: () => any } = Object.create(null);\n for (\n let current = raw;\n (typeof current === \"object\" || typeof current === \"function\") &&\n !LEAF_PROTOTYPES.includes(current);\n current = getProto(current)\n ) {\n for (const key of Object.getOwnPropertyNames(current)) {\n getters[key] = createGetter(raw, key);\n }\n }\n\n // this is not really correct\n // we should set the `default` getter if the imported module is a `.cjs file`\n if (!(allowExportDefault && \"default\" in getters)) {\n getters[\"default\"] = () => raw;\n }\n\n esm(ns, getters);\n return ns;\n}\n\nfunction esmImport(\n sourceModule: Module,\n id: ModuleId\n): Exclude {\n const module = getOrInstantiateModuleFromParent(id, sourceModule);\n if (module.error) throw module.error;\n\n // Any ES module has to have `module.namespaceObject` defined.\n if (module.namespaceObject) return module.namespaceObject;\n\n // only ESM can be an async module, so we don't need to worry about exports being a promise.\n const raw = module.exports;\n return (module.namespaceObject = interopEsm(\n raw,\n {},\n (raw as any).__esModule\n ));\n}\n\nfunction commonJsRequire(sourceModule: Module, id: ModuleId): Exports {\n const module = getOrInstantiateModuleFromParent(id, sourceModule);\n if (module.error) throw module.error;\n return module.exports;\n}\n\ntype RequireContextFactory = (map: RequireContextMap) => RequireContext;\n\nfunction requireContext(\n sourceModule: Module,\n map: RequireContextMap\n): RequireContext {\n function requireContext(id: ModuleId): Exports {\n const entry = map[id];\n\n if (!entry) {\n throw new Error(\n `module ${id} is required from a require.context, but is not in the context`\n );\n }\n\n return commonJsRequireContext(entry, sourceModule);\n }\n\n requireContext.keys = (): ModuleId[] => {\n return Object.keys(map);\n };\n\n requireContext.resolve = (id: ModuleId): ModuleId => {\n const entry = map[id];\n\n if (!entry) {\n throw new Error(\n `module ${id} is resolved from a require.context, but is not in the context`\n );\n }\n\n return entry.id();\n };\n\n return requireContext;\n}\n\n/**\n * Returns the path of a chunk defined by its data.\n */\nfunction getChunkPath(chunkData: ChunkData): ChunkPath {\n return typeof chunkData === \"string\" ? chunkData : chunkData.path;\n}\n\nfunction isPromise(maybePromise: any): maybePromise is Promise {\n return (\n maybePromise != null &&\n typeof maybePromise === \"object\" &&\n \"then\" in maybePromise &&\n typeof maybePromise.then === \"function\"\n );\n}\n\nfunction isAsyncModuleExt(obj: T): obj is AsyncModuleExt & T {\n return turbopackQueues in obj;\n}\n\nfunction maybeWrapAsyncModulePromise(\n promise: Promise,\n then: (val: T) => U | PromiseLike\n): typeof promise extends AsyncModulePromise\n ? AsyncModulePromise\n : Promise {\n const newPromise = promise.then(then);\n\n if (isAsyncModuleExt(promise)) {\n Object.assign(newPromise, {\n get [turbopackExports]() {\n return promise[turbopackExports];\n },\n get [turbopackQueues]() {\n return promise[turbopackQueues];\n },\n get [turbopackError]() {\n return promise[turbopackError];\n },\n } satisfies AsyncModuleExt);\n }\n\n return newPromise as any;\n}\n\nfunction createPromise() {\n let resolve: (value: T | PromiseLike) => void;\n let reject: (reason?: any) => void;\n\n const promise = new Promise((res, rej) => {\n reject = rej;\n resolve = res;\n });\n\n return {\n promise,\n resolve: resolve!,\n reject: reject!,\n };\n}\n\n// everything below is adapted from webpack\n// https://github.com/webpack/webpack/blob/6be4065ade1e252c1d8dcba4af0f43e32af1bdc1/lib/runtime/AsyncModuleRuntimeModule.js#L13\n\nconst turbopackQueues = Symbol(\"turbopack queues\");\nconst turbopackExports = Symbol(\"turbopack exports\");\nconst turbopackError = Symbol(\"turbopack error\");\n\ntype AsyncQueueFn = (() => void) & { queueCount: number };\ntype AsyncQueue = AsyncQueueFn[] & { resolved: boolean };\n\nfunction resolveQueue(queue?: AsyncQueue) {\n if (queue && !queue.resolved) {\n queue.resolved = true;\n queue.forEach((fn) => fn.queueCount--);\n queue.forEach((fn) => (fn.queueCount-- ? fn.queueCount++ : fn()));\n }\n}\n\ntype Dep = Exports | AsyncModulePromise | Promise;\n\ntype AsyncModuleExt = {\n [turbopackQueues]: (fn: (queue: AsyncQueue) => void) => void;\n [turbopackExports]: Exports;\n [turbopackError]?: any;\n};\n\ntype AsyncModulePromise = Promise & AsyncModuleExt;\n\nfunction wrapDeps(deps: Dep[]): AsyncModuleExt[] {\n return deps.map((dep) => {\n if (dep !== null && typeof dep === \"object\") {\n if (isAsyncModuleExt(dep)) return dep;\n if (isPromise(dep)) {\n const queue: AsyncQueue = Object.assign([], { resolved: false });\n\n const obj: AsyncModuleExt = {\n [turbopackExports]: {},\n [turbopackQueues]: (fn: (queue: AsyncQueue) => void) => fn(queue),\n };\n\n dep.then(\n (res) => {\n obj[turbopackExports] = res;\n resolveQueue(queue);\n },\n (err) => {\n obj[turbopackError] = err;\n resolveQueue(queue);\n }\n );\n\n return obj;\n }\n }\n\n const ret: AsyncModuleExt = {\n [turbopackExports]: dep,\n [turbopackQueues]: () => {},\n };\n\n return ret;\n });\n}\n\nfunction asyncModule(\n module: Module,\n body: (\n handleAsyncDependencies: (\n deps: Dep[]\n ) => Exports[] | Promise<() => Exports[]>,\n asyncResult: (err?: any) => void\n ) => void,\n hasAwait: boolean\n) {\n const queue: AsyncQueue | undefined = hasAwait\n ? Object.assign([], { resolved: true })\n : undefined;\n\n const depQueues: Set = new Set();\n const exports = module.exports;\n\n const { resolve, reject, promise: rawPromise } = createPromise();\n\n const promise: AsyncModulePromise = Object.assign(rawPromise, {\n [turbopackExports]: exports,\n [turbopackQueues]: (fn) => {\n queue && fn(queue);\n depQueues.forEach(fn);\n promise[\"catch\"](() => {});\n },\n } satisfies AsyncModuleExt);\n\n module.exports = module.namespaceObject = promise;\n\n function handleAsyncDependencies(deps: Dep[]) {\n const currentDeps = wrapDeps(deps);\n\n const getResult = () =>\n currentDeps.map((d) => {\n if (d[turbopackError]) throw d[turbopackError];\n return d[turbopackExports];\n });\n\n const { promise, resolve } = createPromise<() => Exports[]>();\n\n const fn: AsyncQueueFn = Object.assign(() => resolve(getResult), {\n queueCount: 0,\n });\n\n function fnQueue(q: AsyncQueue) {\n if (q !== queue && !depQueues.has(q)) {\n depQueues.add(q);\n if (q && !q.resolved) {\n fn.queueCount++;\n q.push(fn);\n }\n }\n }\n\n currentDeps.map((dep) => dep[turbopackQueues](fnQueue));\n\n return fn.queueCount ? promise : getResult();\n }\n\n function asyncResult(err?: any) {\n if (err) {\n reject((promise[turbopackError] = err));\n } else {\n resolve(exports);\n }\n\n resolveQueue(queue);\n }\n\n body(handleAsyncDependencies, asyncResult);\n\n if (queue) {\n queue.resolved = false;\n }\n}\n"],"names":[],"mappings":";AAmBA,MAAM,qBAAqB,OAAO;;;;;AA0ClC,MAAM,iBAAiB,OAAO,SAAS,CAAC,cAAc;AACtD,MAAM,cAAc,OAAO,WAAW,eAAe,OAAO,WAAW;AAEvE,SAAS,WACP,GAAQ,EACR,IAAiB,EACjB,OAA2C;IAE3C,IAAI,CAAC,eAAe,IAAI,CAAC,KAAK,OAC5B,OAAO,cAAc,CAAC,KAAK,MAAM;AACrC;AAKA,SAAS,IAAI,OAAgB,EAAE,OAAkC;IAC/D,WAAW,SAAS,cAAc;QAAE,OAA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,CAAC,UAAU,GAAG,CAAC,IAAI;gBACpC,UAAU,GAAG,CAAC;gBACd,IAAI,KAAK,CAAC,EAAE,QAAQ,EAAE;oBACpB,GAAG,UAAU;oBACb,EAAE,IAAI,CAAC;gBACT;YACF;QACF;QAEA,YAAY,GAAG,CAAC,CAAC,MAAQ,GAAG,CAAC,gBAAgB,CAAC;QAE9C,OAAO,GAAG,UAAU,GAAG,UAAU;IACnC;IAEA,SAAS,YAAY,GAAS;QAC5B,IAAI,KAAK;YACP,OAAQ,OAAO,CAAC,eAAe,GAAG;QACpC,OAAO;YACL,QAAQ;QACV;QAEA,aAAa;IACf;IAEA,KAAK,yBAAyB;IAE9B,IAAI,OAAO;QACT,MAAM,QAAQ,GAAG;IACnB;AACF"}}, - {"offset": {"line": 231, "column": 0}, "map": {"version":3,"sources":["/turbopack/[turbopack]/shared-node/require.ts"],"sourcesContent":["/// \n\ninterface RequireContextEntry {\n external: boolean;\n}\n\nfunction commonJsRequireContext(\n entry: RequireContextEntry,\n sourceModule: Module\n): Exports {\n return entry.external\n ? externalRequire(entry.id(), false)\n : commonJsRequire(sourceModule, entry.id());\n}\n\nfunction externalImport(id: ModuleId) {\n return import(id);\n}\n\nfunction externalRequire(\n id: ModuleId,\n esm: boolean = false\n): Exports | EsmNamespaceObject {\n let raw;\n try {\n raw = require(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 (!esm || raw.__esModule) {\n return raw;\n }\n\n return interopEsm(raw, {}, true);\n}\nexternalRequire.resolve = (\n id: string,\n options?:\n | {\n paths?: string[] | undefined;\n }\n | undefined\n) => {\n return require.resolve(id, options);\n};\n"],"names":[],"mappings":";AAMA,SAAS,uBACP,KAA0B,EAC1B,YAAoB;IAEpB,OAAO,MAAM,QAAQ,GACjB,gBAAgB,MAAM,EAAE,IAAI,SAC5B,gBAAgB,cAAc,MAAM,EAAE;AAC5C;AAEA,SAAS,eAAe,EAAY;IAClC,OAAO,MAAM,CAAC;AAChB;AAEA,SAAS,gBACP,EAAY,EACZ,MAAe,KAAK;IAEpB,IAAI;IACJ,IAAI;QACF,MAAM,QAAQ;IAChB,EAAE,OAAO,KAAK;QAKZ,MAAM,IAAI,MAAM,CAAC,+BAA+B,EAAE,GAAG,EAAE,EAAE,IAAI,CAAC;IAChE;IAEA,IAAI,CAAC,OAAO,IAAI,UAAU,EAAE;QAC1B,OAAO;IACT;IAEA,OAAO,WAAW,KAAK,CAAC,GAAG;AAC7B;AACA,gBAAgB,OAAO,GAAG,CACxB,IACA;IAMA,OAAO,QAAQ,OAAO,CAAC,IAAI;AAC7B"}}, - {"offset": {"line": 253, "column": 0}, "map": {"version":3,"sources":["/turbopack/[turbopack]/build/runtime.ts"],"sourcesContent":["/// \n/// \n\ndeclare var RUNTIME_PUBLIC_PATH: string;\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\ntype ExternalRequire = (id: ModuleId) => Exports | EsmNamespaceObject;\ntype ExternalImport = (id: ModuleId) => Promise;\n\ninterface TurbopackNodeBuildContext extends TurbopackBaseContext {\n x: ExternalRequire;\n y: ExternalImport;\n}\n\ntype ModuleFactory = (\n this: Module[\"exports\"],\n context: TurbopackNodeBuildContext\n) => undefined;\n\nconst path = require(\"path\");\nconst relativePathToRuntimeRoot = path.relative(RUNTIME_PUBLIC_PATH, \".\");\nconst RUNTIME_ROOT = path.resolve(__filename, relativePathToRuntimeRoot);\n\nconst moduleFactories: ModuleFactories = Object.create(null);\nconst moduleCache: ModuleCache = Object.create(null);\n\nfunction loadChunk(chunkPath: ChunkPath) {\n if (!chunkPath.endsWith(\".js\")) {\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 const resolved = require.resolve(path.resolve(RUNTIME_ROOT, chunkPath));\n delete require.cache[resolved];\n const chunkModules: ModuleFactories = require(resolved);\n\n for (const [moduleId, moduleFactory] of Object.entries(chunkModules)) {\n if (!moduleFactories[moduleId]) {\n moduleFactories[moduleId] = moduleFactory;\n }\n }\n}\n\nfunction loadChunkAsync(source: SourceInfo, chunkPath: string): Promise {\n return new Promise((resolve, reject) => {\n try {\n loadChunk(chunkPath);\n } catch (err) {\n reject(err);\n return;\n }\n resolve();\n });\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 }\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 let parents: ModuleId[];\n switch (source.type) {\n case SourceType.Runtime:\n parents = [];\n break;\n case SourceType.Parent:\n // No need to add this module as a child of the parent module here, this\n // has already been taken care of in `getOrInstantiateModuleFromParent`.\n parents = [source.parentId];\n break;\n }\n\n const module: Module = {\n exports: {},\n error: undefined,\n loaded: false,\n id,\n parents,\n children: [],\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 moduleFactory.call(module.exports, {\n a: asyncModule.bind(null, module),\n e: module.exports,\n r: commonJsRequire.bind(null, module),\n x: externalRequire,\n y: externalImport,\n f: requireContext.bind(null, module),\n i: esmImport.bind(null, module),\n s: esm.bind(null, module.exports),\n j: dynamicExport.bind(null, module, module.exports),\n v: exportValue.bind(null, module),\n n: exportNamespace.bind(null, module),\n m: module,\n c: moduleCache,\n l: loadChunkAsync.bind(null, { type: SourceType.Parent, parentId: id }),\n g: globalThis,\n __dirname: module.id.replace(/(^|\\/)[\\/]+$/, \"\"),\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 */\nfunction getOrInstantiateModuleFromParent(\n id: ModuleId,\n sourceModule: Module\n): Module {\n const module = moduleCache[id];\n\n if (sourceModule.children.indexOf(id) === -1) {\n sourceModule.children.push(id);\n }\n\n if (module) {\n if (module.parents.indexOf(sourceModule.id) === -1) {\n module.parents.push(sourceModule.id);\n }\n\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 */\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\nmodule.exports = {\n getOrInstantiateRuntimeModule,\n loadChunk,\n};\n"],"names":[],"mappings":";IAKA;UAAK,UAAU;IAAV,WAAA,WAKH,aAAU,KAAV;IALG,WAAA,WASH,YAAS,KAAT;GATG,eAAA;;AAmCL,MAAM,OAAO,QAAQ;AACrB,MAAM,4BA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CAAC,aAAa,EAAE,MAAM,CAAC,GAAG;YAClD,QAAO,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE;QACrC;QAEA,OAAO;IACT;IAEA,OAAO,kBAAkB,IAAI;QAC3B,MAAM,WAAW,MAAM;QACvB,UAAU,aAAa,EAAE;IAC3B;AACF;AAKA,SAAS,yBACP,QAAkB,EAClB,SAAoB;IAEpB,OAAO,kBAAkB,UAAU;QAAE,MAAM,WAAW,OAAO;QAAE;IAAU;AAC3E;AAKA,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,OAAO,OAAO,GAAG;IACf;IACA;AACF"}}] + {"offset": {"line": 1, "column": 0}, "map": {"version":3,"sources":["/turbopack/[turbopack]/shared/runtime-utils.ts"],"sourcesContent":["/**\n * This file contains runtime types and functions that are shared between all\n * TurboPack ECMAScript runtimes.\n *\n * It will be prepended to the runtime code of each runtime.\n */\n\n/* eslint-disable @next/next/no-assign-module-variable */\n\n/// \n\ninterface Exports {\n __esModule?: boolean;\n\n [key: string]: any;\n}\n\ntype EsmNamespaceObject = Record;\n\nconst REEXPORTED_OBJECTS = Symbol(\"reexported objects\");\n\ninterface BaseModule {\n exports: Exports | Promise | AsyncModulePromise;\n error: Error | undefined;\n loaded: boolean;\n id: ModuleId;\n children: ModuleId[];\n parents: ModuleId[];\n namespaceObject?:\n | EsmNamespaceObject\n | Promise\n | AsyncModulePromise;\n [REEXPORTED_OBJECTS]?: any[];\n}\n\ninterface Module extends BaseModule {}\n\ntype RequireContextMap = Record;\n\ninterface RequireContextEntry {\n id: () => ModuleId;\n}\n\ninterface RequireContext {\n (moduleId: ModuleId): Exports | EsmNamespaceObject;\n\n keys(): ModuleId[];\n\n resolve(moduleId: ModuleId): ModuleId;\n}\n\ntype GetOrInstantiateModuleFromParent = (\n moduleId: ModuleId,\n parentModule: Module\n) => Module;\n\ntype CommonJsRequireContext = (\n entry: RequireContextEntry,\n parentModule: Module\n) => Exports;\n\nconst hasOwnProperty = Object.prototype.hasOwnProperty;\nconst toStringTag = typeof Symbol !== \"undefined\" && Symbol.toStringTag;\n\nfunction defineProp(\n obj: any,\n name: PropertyKey,\n options: PropertyDescriptor & ThisType\n) {\n if (!hasOwnProperty.call(obj, name))\n Object.defineProperty(obj, name, options);\n}\n\n/**\n * Adds the getters to the exports object.\n */\nfunction esm(exports: Exports, getters: Record any>) {\n defineProp(exports, \"__esModule\", { value: true });\n if (toStringTag) defineProp(exports, toStringTag, { value: \"Module\" });\n for (const key in getters) {\n defineProp(exports, key, { get: getters[key], enumerable: true });\n }\n}\n\n/**\n * Makes the module an ESM with exports\n */\nfunction esmExport(\n module: Module,\n exports: Exports,\n getters: Record any>\n) {\n module.namespaceObject = module.exports;\n esm(exports, getters);\n}\n\nfunction ensureDynamicExports(module: Module, exports: Exports) {\n let reexportedObjects = module[REEXPORTED_OBJECTS];\n\n if (!reexportedObjects) {\n reexportedObjects = module[REEXPORTED_OBJECTS] = [];\n module.exports = module.namespaceObject = new Proxy(exports, {\n get(target, prop) {\n if (\n hasOwnProperty.call(target, prop) ||\n prop === \"default\" ||\n prop === \"__esModule\"\n ) {\n return Reflect.get(target, prop);\n }\n for (const obj of reexportedObjects!) {\n const value = Reflect.get(obj, prop);\n if (value !== undefined) return value;\n }\n return undefined;\n },\n ownKeys(target) {\n const keys = Reflect.ownKeys(target);\n for (const obj of reexportedObjects!) {\n for (const key of Reflect.ownKeys(obj)) {\n if (key !== \"default\" && !keys.includes(key)) keys.push(key);\n }\n }\n return keys;\n },\n });\n }\n}\n\n/**\n * Dynamically exports properties from an object\n */\nfunction dynamicExport(\n module: Module,\n exports: Exports,\n object: Record\n) {\n ensureDynamicExports(module, exports);\n\n module[REEXPORTED_OBJECTS]!.push(object);\n}\n\nfunction exportValue(module: Module, value: any) {\n module.exports = value;\n}\n\nfunction exportNamespace(module: Module, namespace: any) {\n module.exports = module.namespaceObject = namespace;\n}\n\nfunction createGetter(obj: Record, key: string | symbol) {\n return () => obj[key];\n}\n\n/**\n * @returns prototype of the object\n */\nconst getProto: (obj: any) => any = Object.getPrototypeOf\n ? (obj) => Object.getPrototypeOf(obj)\n : (obj) => obj.__proto__;\n\n/** Prototypes that are not expanded for exports */\nconst LEAF_PROTOTYPES = [null, getProto({}), getProto([]), getProto(getProto)];\n\n/**\n * @param raw\n * @param ns\n * @param allowExportDefault\n * * `false`: will have the raw module as default export\n * * `true`: will have the default property as default export\n */\nfunction interopEsm(\n raw: Exports,\n ns: EsmNamespaceObject,\n allowExportDefault?: boolean\n) {\n const getters: { [s: string]: () => any } = Object.create(null);\n for (\n let current = raw;\n (typeof current === \"object\" || typeof current === \"function\") &&\n !LEAF_PROTOTYPES.includes(current);\n current = getProto(current)\n ) {\n for (const key of Object.getOwnPropertyNames(current)) {\n getters[key] = createGetter(raw, key);\n }\n }\n\n // this is not really correct\n // we should set the `default` getter if the imported module is a `.cjs file`\n if (!(allowExportDefault && \"default\" in getters)) {\n getters[\"default\"] = () => raw;\n }\n\n esm(ns, getters);\n return ns;\n}\n\nfunction esmImport(\n sourceModule: Module,\n id: ModuleId\n): Exclude {\n const module = getOrInstantiateModuleFromParent(id, sourceModule);\n if (module.error) throw module.error;\n\n // any ES module has to have `module.namespaceObject` defined.\n if (module.namespaceObject) return module.namespaceObject;\n\n // only ESM can be an async module, so we don't need to worry about exports being a promise here.\n const raw = module.exports;\n return (module.namespaceObject = interopEsm(\n raw,\n {},\n (raw as any).__esModule\n ));\n}\n\nfunction commonJsRequire(sourceModule: Module, id: ModuleId): Exports {\n const module = getOrInstantiateModuleFromParent(id, sourceModule);\n if (module.error) throw module.error;\n return module.exports;\n}\n\ntype RequireContextFactory = (map: RequireContextMap) => RequireContext;\n\nfunction requireContext(\n sourceModule: Module,\n map: RequireContextMap\n): RequireContext {\n function requireContext(id: ModuleId): Exports {\n const entry = map[id];\n\n if (!entry) {\n throw new Error(\n `module ${id} is required from a require.context, but is not in the context`\n );\n }\n\n return commonJsRequireContext(entry, sourceModule);\n }\n\n requireContext.keys = (): ModuleId[] => {\n return Object.keys(map);\n };\n\n requireContext.resolve = (id: ModuleId): ModuleId => {\n const entry = map[id];\n\n if (!entry) {\n throw new Error(\n `module ${id} is resolved from a require.context, but is not in the context`\n );\n }\n\n return entry.id();\n };\n\n return requireContext;\n}\n\n/**\n * Returns the path of a chunk defined by its data.\n */\nfunction getChunkPath(chunkData: ChunkData): ChunkPath {\n return typeof chunkData === \"string\" ? chunkData : chunkData.path;\n}\n\nfunction isPromise(maybePromise: any): maybePromise is Promise {\n return (\n maybePromise != null &&\n typeof maybePromise === \"object\" &&\n \"then\" in maybePromise &&\n typeof maybePromise.then === \"function\"\n );\n}\n\nfunction isAsyncModuleExt(obj: T): obj is AsyncModuleExt & T {\n return turbopackQueues in obj;\n}\n\nfunction createPromise() {\n let resolve: (value: T | PromiseLike) => void;\n let reject: (reason?: any) => void;\n\n const promise = new Promise((res, rej) => {\n reject = rej;\n resolve = res;\n });\n\n return {\n promise,\n resolve: resolve!,\n reject: reject!,\n };\n}\n\n// everything below is adapted from webpack\n// https://github.com/webpack/webpack/blob/6be4065ade1e252c1d8dcba4af0f43e32af1bdc1/lib/runtime/AsyncModuleRuntimeModule.js#L13\n\nconst turbopackQueues = Symbol(\"turbopack queues\");\nconst turbopackExports = Symbol(\"turbopack exports\");\nconst turbopackError = Symbol(\"turbopack error\");\n\ntype AsyncQueueFn = (() => void) & { queueCount: number };\ntype AsyncQueue = AsyncQueueFn[] & { resolved: boolean };\n\nfunction resolveQueue(queue?: AsyncQueue) {\n if (queue && !queue.resolved) {\n queue.resolved = true;\n queue.forEach((fn) => fn.queueCount--);\n queue.forEach((fn) => (fn.queueCount-- ? fn.queueCount++ : fn()));\n }\n}\n\ntype Dep = Exports | AsyncModulePromise | Promise;\n\ntype AsyncModuleExt = {\n [turbopackQueues]: (fn: (queue: AsyncQueue) => void) => void;\n [turbopackExports]: Exports;\n [turbopackError]?: any;\n};\n\ntype AsyncModulePromise = Promise & AsyncModuleExt;\n\nfunction wrapDeps(deps: Dep[]): AsyncModuleExt[] {\n return deps.map((dep) => {\n if (dep !== null && typeof dep === \"object\") {\n if (isAsyncModuleExt(dep)) return dep;\n if (isPromise(dep)) {\n const queue: AsyncQueue = Object.assign([], { resolved: false });\n\n const obj: AsyncModuleExt = {\n [turbopackExports]: {},\n [turbopackQueues]: (fn: (queue: AsyncQueue) => void) => fn(queue),\n };\n\n dep.then(\n (res) => {\n obj[turbopackExports] = res;\n resolveQueue(queue);\n },\n (err) => {\n obj[turbopackError] = err;\n resolveQueue(queue);\n }\n );\n\n return obj;\n }\n }\n\n const ret: AsyncModuleExt = {\n [turbopackExports]: dep,\n [turbopackQueues]: () => {},\n };\n\n return ret;\n });\n}\n\nfunction asyncModule(\n module: Module,\n body: (\n handleAsyncDependencies: (\n deps: Dep[]\n ) => Exports[] | Promise<() => Exports[]>,\n asyncResult: (err?: any) => void\n ) => void,\n hasAwait: boolean\n) {\n const queue: AsyncQueue | undefined = hasAwait\n ? Object.assign([], { resolved: true })\n : undefined;\n\n const depQueues: Set = new Set();\n\n ensureDynamicExports(module, module.exports);\n const exports = module.exports;\n\n const { resolve, reject, promise: rawPromise } = createPromise();\n\n const promise: AsyncModulePromise = Object.assign(rawPromise, {\n [turbopackExports]: exports,\n [turbopackQueues]: (fn) => {\n queue && fn(queue);\n depQueues.forEach(fn);\n promise[\"catch\"](() => {});\n },\n } satisfies AsyncModuleExt);\n\n module.exports = module.namespaceObject = promise;\n\n function handleAsyncDependencies(deps: Dep[]) {\n const currentDeps = wrapDeps(deps);\n\n const getResult = () =>\n currentDeps.map((d) => {\n if (d[turbopackError]) throw d[turbopackError];\n return d[turbopackExports];\n });\n\n const { promise, resolve } = createPromise<() => Exports[]>();\n\n const fn: AsyncQueueFn = Object.assign(() => resolve(getResult), {\n queueCount: 0,\n });\n\n function fnQueue(q: AsyncQueue) {\n if (q !== queue && !depQueues.has(q)) {\n depQueues.add(q);\n if (q && !q.resolved) {\n fn.queueCount++;\n q.push(fn);\n }\n }\n }\n\n currentDeps.map((dep) => dep[turbopackQueues](fnQueue));\n\n return fn.queueCount ? promise : getResult();\n }\n\n function asyncResult(err?: any) {\n if (err) {\n reject((promise[turbopackError] = err));\n } else {\n resolve(exports);\n }\n\n resolveQueue(queue);\n }\n\n body(handleAsyncDependencies, asyncResult);\n\n if (queue) {\n queue.resolved = false;\n }\n}\n"],"names":[],"mappings":";AAmBA,MAAM,qBAAqB,OAAO;;;;;AA0ClC,MAAM,iBAAiB,OAAO,SAAS,CAAC,cAAc;AACtD,MAAM,cAAc,OAAO,WAAW,eAAe,OAAO,WAAW;AAEvE,SAAS,WACP,GAAQ,EACR,IAAiB,EACjB,OAA2C;IAE3C,IAAI,CAAC,eAAe,IAAI,CAAC,KAAK,OAC5B,OAAO,cAAc,CAAC,KAAK,MAAM;AACrC;AAKA,SAAS,IAAI,OAAgB,EAAE,OAAkC;IAC/D,WAAW,SAAS,cAAc;QAAE,OAAO;IAAK;IAChD,IAAI,aAAa,WAAW,SAAS,aAAa;QAAE,OAAO;IAAS;IACpE,IAAK,MAAM,OAAO,QAAS;QACzB,WAAW,SAAS,KAAK;YAAE,KAAK,OAAO,CAAC,IAAI;YAAE,YAAY;QAAK;IACjE;AACF;AAKA,SAAS,UACP,MAAc,EACd,OAAgB,EAChB,OAAkC;IAElC,OAAO,eAAe,GAAG,OAAO,OAAO;IACvC,IAAI,SAAS;AACf;AAEA,SAAS,qBAAqB,MAAc,EAAE,OAAgB;IAC5D,IAAI,oBAAoB,MAAM,CAAC,mBAAmB;IAElD,IAAI,CAAC,mBAAmB;QACtB,oBAAoB,MAAM,CAAC,mBAAmB,GAAG,EAAE;QACnD,OAAO,OAAO,GAAG,OAAO,eAAe,GAAG,IAAI,MAAM,SAAS;YAC3D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G,UAAU,GAAG,UAAU;IACnC;IAEA,SAAS,YAAY,GAAS;QAC5B,IAAI,KAAK;YACP,OAAQ,OAAO,CAAC,eAAe,GAAG;QACpC,OAAO;YACL,QAAQ;QACV;QAEA,aAAa;IACf;IAEA,KAAK,yBAAyB;IAE9B,IAAI,OAAO;QACT,MAAM,QAAQ,GAAG;IACnB;AACF"}}, + {"offset": {"line": 235, "column": 0}, "map": {"version":3,"sources":["/turbopack/[turbopack]/shared-node/require.ts"],"sourcesContent":["/// \n\ninterface RequireContextEntry {\n external: boolean;\n}\n\nfunction commonJsRequireContext(\n entry: RequireContextEntry,\n sourceModule: Module\n): Exports {\n return entry.external\n ? externalRequire(entry.id(), false)\n : commonJsRequire(sourceModule, entry.id());\n}\n\nfunction externalImport(id: ModuleId) {\n return import(id);\n}\n\nfunction externalRequire(\n id: ModuleId,\n esm: boolean = false\n): Exports | EsmNamespaceObject {\n let raw;\n try {\n raw = require(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 (!esm || raw.__esModule) {\n return raw;\n }\n\n return interopEsm(raw, {}, true);\n}\nexternalRequire.resolve = (\n id: string,\n options?: {\n paths?: string[];\n }\n) => {\n return require.resolve(id, options);\n};\n"],"names":[],"mappings":";AAMA,SAAS,uBACP,KAA0B,EAC1B,YAAoB;IAEpB,OAAO,MAAM,QAAQ,GACjB,gBAAgB,MAAM,EAAE,IAAI,SAC5B,gBAAgB,cAAc,MAAM,EAAE;AAC5C;AAEA,SAAS,eAAe,EAAY;IAClC,OAAO,MAAM,CAAC;AAChB;AAEA,SAAS,gBACP,EAAY,EACZ,MAAe,KAAK;IAEpB,IAAI;IACJ,IAAI;QACF,MAAM,QAAQ;IAChB,EAAE,OAAO,KAAK;QAKZ,MAAM,IAAI,MAAM,CAAC,+BAA+B,EAAE,GAAG,EAAE,EAAE,IAAI,CAAC;IAChE;IAEA,IAAI,CAAC,OAAO,IAAI,UAAU,EAAE;QAC1B,OAAO;IACT;IAEA,OAAO,WAAW,KAAK,CAAC,GAAG;AAC7B;AACA,gBAAgB,OAAO,GAAG,CACxB,IACA;IAIA,OAAO,QAAQ,OAAO,CAAC,IAAI;AAC7B"}}, + {"offset": {"line": 257, "column": 0}, "map": {"version":3,"sources":["/turbopack/[turbopack]/build/runtime.ts"],"sourcesContent":["/// \n/// \n\ndeclare var RUNTIME_PUBLIC_PATH: string;\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\ntype ExternalRequire = (id: ModuleId) => Exports | EsmNamespaceObject;\ntype ExternalImport = (id: ModuleId) => Promise;\n\ninterface TurbopackNodeBuildContext extends TurbopackBaseContext {\n x: ExternalRequire;\n y: ExternalImport;\n}\n\ntype ModuleFactory = (\n this: Module[\"exports\"],\n context: TurbopackNodeBuildContext\n) => undefined;\n\nconst path = require(\"path\");\nconst relativePathToRuntimeRoot = path.relative(RUNTIME_PUBLIC_PATH, \".\");\nconst RUNTIME_ROOT = path.resolve(__filename, relativePathToRuntimeRoot);\n\nconst moduleFactories: ModuleFactories = Object.create(null);\nconst moduleCache: ModuleCache = Object.create(null);\n\nfunction loadChunk(chunkPath: ChunkPath) {\n if (!chunkPath.endsWith(\".js\")) {\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 const resolved = require.resolve(path.resolve(RUNTIME_ROOT, chunkPath));\n delete require.cache[resolved];\n const chunkModules: ModuleFactories = require(resolved);\n\n for (const [moduleId, moduleFactory] of Object.entries(chunkModules)) {\n if (!moduleFactories[moduleId]) {\n moduleFactories[moduleId] = moduleFactory;\n }\n }\n}\n\nfunction loadChunkAsync(source: SourceInfo, chunkPath: string): Promise {\n return new Promise((resolve, reject) => {\n try {\n loadChunk(chunkPath);\n } catch (err) {\n reject(err);\n return;\n }\n resolve();\n });\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 }\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 let parents: ModuleId[];\n switch (source.type) {\n case SourceType.Runtime:\n parents = [];\n break;\n case SourceType.Parent:\n // No need to add this module as a child of the parent module here, this\n // has already been taken care of in `getOrInstantiateModuleFromParent`.\n parents = [source.parentId];\n break;\n }\n\n const module: Module = {\n exports: {},\n error: undefined,\n loaded: false,\n id,\n parents,\n children: [],\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 moduleFactory.call(module.exports, {\n a: asyncModule.bind(null, module),\n e: module.exports,\n r: commonJsRequire.bind(null, module),\n x: externalRequire,\n y: externalImport,\n f: requireContext.bind(null, module),\n i: esmImport.bind(null, module),\n s: esm.bind(null, module.exports),\n j: dynamicExport.bind(null, module, module.exports),\n v: exportValue.bind(null, module),\n n: exportNamespace.bind(null, module),\n m: module,\n c: moduleCache,\n l: loadChunkAsync.bind(null, { type: SourceType.Parent, parentId: id }),\n g: globalThis,\n __dirname: module.id.replace(/(^|\\/)[\\/]+$/, \"\"),\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 */\nfunction getOrInstantiateModuleFromParent(\n id: ModuleId,\n sourceModule: Module\n): Module {\n const module = moduleCache[id];\n\n if (sourceModule.children.indexOf(id) === -1) {\n sourceModule.children.push(id);\n }\n\n if (module) {\n if (module.parents.indexOf(sourceModule.id) === -1) {\n module.parents.push(sourceModule.id);\n }\n\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 */\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\nmodule.exports = {\n getOrInstantiateRuntimeModule,\n loadChunk,\n};\n"],"names":[],"mappings":";IAKA;UAAK,UAAU;IAAV,WAAA,WAKH,aAAU,KAAV;IALG,WAAA,WASH,YAAS,KAAT;GATG,eAAA;;AAmCL,MAAM,OAAO,QAAQ;AACrB,MAAM,4BAA4B,KAAK,QAAQ,CAAC,qBAAqB;AACrE,MAAM,eAAe,KAAK,OAAO,CAAC,YAAY;AAE9C,MAAM,kBAAmC,OAAO,MAAM,CAAC;AACvD,MAAM,cAA2B,OAAO,MAAM,CAAC;AAE/C,SAAS,UAAU,SAAoB;IACrC,IAAI,CAAC,UAAU,QAAQ,CAAC,QAAQ;QAG9B;IACF;IAEA,MAAM,WAAW,QAA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AAU;QAAE,MAAM,WAAW,OAAO;QAAE;IAAU;AAC3E;AAKA,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,OAAO,OAAO,GAAG;IACf;IACA;AACF"}}] } \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/79fb1_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_e60ecd.js b/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/79fb1_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_e60ecd.js index c171fe61ca8ad..4bd88c92cfc87 100644 --- a/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/79fb1_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_e60ecd.js +++ b/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/79fb1_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_e60ecd.js @@ -38,17 +38,37 @@ function esmExport(module, exports, getters) { module.namespaceObject = module.exports; esm(exports, getters); } -function dynamicExport(module, exports, object) { - const keys = Reflect.ownKeys(exports); - for (const key of Reflect.ownKeys(object)){ - if (key !== "default" && !keys.includes(key)) { - defineProp(exports, key, { - get: createGetter(object, key), - enumerable: true - }); - } +function ensureDynamicExports(module, exports) { + let reexportedObjects = module[REEXPORTED_OBJECTS]; + if (!reexportedObjects) { + reexportedObjects = module[REEXPORTED_OBJECTS] = []; + module.exports = module.namespaceObject = new Proxy(exports, { + get (target, prop) { + if (hasOwnProperty.call(target, prop) || prop === "default" || prop === "__esModule") { + return Reflect.get(target, prop); + } + for (const obj of reexportedObjects){ + const value = Reflect.get(obj, prop); + if (value !== undefined) return value; + } + return undefined; + }, + ownKeys (target) { + const keys = Reflect.ownKeys(target); + for (const obj of reexportedObjects){ + for (const key of Reflect.ownKeys(obj)){ + if (key !== "default" && !keys.includes(key)) keys.push(key); + } + } + return keys; + } + }); } } +function dynamicExport(module, exports, object) { + ensureDynamicExports(module, exports); + module[REEXPORTED_OBJECTS].push(object); +} function exportValue(module, value) { module.exports = value; } @@ -119,23 +139,6 @@ function isPromise(maybePromise) { function isAsyncModuleExt(obj) { return turbopackQueues in obj; } -function maybeWrapAsyncModulePromise(promise, then) { - const newPromise = promise.then(then); - if (isAsyncModuleExt(promise)) { - Object.assign(newPromise, { - get [turbopackExports] () { - return promise[turbopackExports]; - }, - get [turbopackQueues] () { - return promise[turbopackQueues]; - }, - get [turbopackError] () { - return promise[turbopackError]; - } - }); - } - return newPromise; -} function createPromise() { let resolve; let reject; @@ -193,6 +196,7 @@ function asyncModule(module, body, hasAwait) { resolved: true }) : undefined; const depQueues = new Set(); + ensureDynamicExports(module, module.exports); const exports = module.exports; const { resolve, reject, promise: rawPromise } = createPromise(); const promise = Object.assign(rawPromise, { diff --git a/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/79fb1_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_e60ecd.js.map b/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/79fb1_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_e60ecd.js.map index 39f1004022ba0..22dcd089bb758 100644 --- a/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/79fb1_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_e60ecd.js.map +++ b/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/79fb1_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_e60ecd.js.map @@ -1,8 +1,8 @@ { "version": 3, "sections": [ - {"offset": {"line": 11, "column": 0}, "map": {"version":3,"sources":["/turbopack/[turbopack]/shared/runtime-utils.ts"],"sourcesContent":["/**\n * This file contains runtime types and functions that are shared between all\n * TurboPack ECMAScript runtimes.\n *\n * It will be prepended to the runtime code of each runtime.\n */\n\n/* eslint-disable @next/next/no-assign-module-variable */\n\n/// \n\ninterface Exports {\n __esModule?: boolean;\n\n [key: string]: any;\n}\n\ntype EsmNamespaceObject = Record;\n\nconst REEXPORTED_OBJECTS = Symbol(\"reexported objects\");\n\ninterface BaseModule {\n exports: Exports | Promise | AsyncModulePromise;\n error: Error | undefined;\n loaded: boolean;\n id: ModuleId;\n children: ModuleId[];\n parents: ModuleId[];\n namespaceObject?:\n | EsmNamespaceObject\n | Promise\n | AsyncModulePromise;\n [REEXPORTED_OBJECTS]?: any[];\n}\n\ninterface Module extends BaseModule {}\n\ntype RequireContextMap = Record;\n\ninterface RequireContextEntry {\n id: () => ModuleId;\n}\n\ninterface RequireContext {\n (moduleId: ModuleId): Exports | EsmNamespaceObject;\n\n keys(): ModuleId[];\n\n resolve(moduleId: ModuleId): ModuleId;\n}\n\ntype GetOrInstantiateModuleFromParent = (\n moduleId: ModuleId,\n parentModule: Module\n) => Module;\n\ntype CommonJsRequireContext = (\n entry: RequireContextEntry,\n parentModule: Module\n) => Exports;\n\nconst hasOwnProperty = Object.prototype.hasOwnProperty;\nconst toStringTag = typeof Symbol !== \"undefined\" && Symbol.toStringTag;\n\nfunction defineProp(\n obj: any,\n name: PropertyKey,\n options: PropertyDescriptor & ThisType\n) {\n if (!hasOwnProperty.call(obj, name))\n Object.defineProperty(obj, name, options);\n}\n\n/**\n * Adds the getters to the exports object.\n */\nfunction esm(exports: Exports, getters: Record any>) {\n defineProp(exports, \"__esModule\", { value: true });\n if (toStringTag) defineProp(exports, toStringTag, { value: \"Module\" });\n for (const key in getters) {\n defineProp(exports, key, { get: getters[key], enumerable: true });\n }\n}\n\n/**\n * Makes the module an ESM with exports\n */\nfunction esmExport(\n module: Module,\n exports: Exports,\n getters: Record any>\n) {\n module.namespaceObject = module.exports;\n esm(exports, getters);\n}\n\n/**\n * Dynamically exports properties from an object\n */\nfunction dynamicExport(\n module: Module,\n exports: Exports,\n object: Record\n) {\n const keys = Reflect.ownKeys(exports);\n\n for (const key of Reflect.ownKeys(object)) {\n if (key !== \"default\" && !keys.includes(key)) {\n defineProp(exports, key, {\n get: createGetter(object, key),\n enumerable: true,\n });\n }\n }\n}\n\nfunction exportValue(module: Module, value: any) {\n module.exports = value;\n}\n\nfunction exportNamespace(module: Module, namespace: any) {\n module.exports = module.namespaceObject = namespace;\n}\n\nfunction createGetter(obj: Record, key: string | symbol) {\n return () => obj[key];\n}\n\n/**\n * @returns prototype of the object\n */\nconst getProto: (obj: any) => any = Object.getPrototypeOf\n ? (obj) => Object.getPrototypeOf(obj)\n : (obj) => obj.__proto__;\n\n/** Prototypes that are not expanded for exports */\nconst LEAF_PROTOTYPES = [null, getProto({}), getProto([]), getProto(getProto)];\n\n/**\n * @param raw\n * @param ns\n * @param allowExportDefault\n * * `false`: will have the raw module as default export\n * * `true`: will have the default property as default export\n */\nfunction interopEsm(\n raw: Exports,\n ns: EsmNamespaceObject,\n allowExportDefault?: boolean\n) {\n const getters: { [s: string]: () => any } = Object.create(null);\n for (\n let current = raw;\n (typeof current === \"object\" || typeof current === \"function\") &&\n !LEAF_PROTOTYPES.includes(current);\n current = getProto(current)\n ) {\n for (const key of Object.getOwnPropertyNames(current)) {\n getters[key] = createGetter(raw, key);\n }\n }\n\n // this is not really correct\n // we should set the `default` getter if the imported module is a `.cjs file`\n if (!(allowExportDefault && \"default\" in getters)) {\n getters[\"default\"] = () => raw;\n }\n\n esm(ns, getters);\n return ns;\n}\n\nfunction esmImport(\n sourceModule: Module,\n id: ModuleId\n): Exclude {\n const module = getOrInstantiateModuleFromParent(id, sourceModule);\n if (module.error) throw module.error;\n\n // Any ES module has to have `module.namespaceObject` defined.\n if (module.namespaceObject) return module.namespaceObject;\n\n // only ESM can be an async module, so we don't need to worry about exports being a promise.\n const raw = module.exports;\n return (module.namespaceObject = interopEsm(\n raw,\n {},\n (raw as any).__esModule\n ));\n}\n\nfunction commonJsRequire(sourceModule: Module, id: ModuleId): Exports {\n const module = getOrInstantiateModuleFromParent(id, sourceModule);\n if (module.error) throw module.error;\n return module.exports;\n}\n\ntype RequireContextFactory = (map: RequireContextMap) => RequireContext;\n\nfunction requireContext(\n sourceModule: Module,\n map: RequireContextMap\n): RequireContext {\n function requireContext(id: ModuleId): Exports {\n const entry = map[id];\n\n if (!entry) {\n throw new Error(\n `module ${id} is required from a require.context, but is not in the context`\n );\n }\n\n return commonJsRequireContext(entry, sourceModule);\n }\n\n requireContext.keys = (): ModuleId[] => {\n return Object.keys(map);\n };\n\n requireContext.resolve = (id: ModuleId): ModuleId => {\n const entry = map[id];\n\n if (!entry) {\n throw new Error(\n `module ${id} is resolved from a require.context, but is not in the context`\n );\n }\n\n return entry.id();\n };\n\n return requireContext;\n}\n\n/**\n * Returns the path of a chunk defined by its data.\n */\nfunction getChunkPath(chunkData: ChunkData): ChunkPath {\n return typeof chunkData === \"string\" ? chunkData : chunkData.path;\n}\n\nfunction isPromise(maybePromise: any): maybePromise is Promise {\n return (\n maybePromise != null &&\n typeof maybePromise === \"object\" &&\n \"then\" in maybePromise &&\n typeof maybePromise.then === \"function\"\n );\n}\n\nfunction isAsyncModuleExt(obj: T): obj is AsyncModuleExt & T {\n return turbopackQueues in obj;\n}\n\nfunction maybeWrapAsyncModulePromise(\n promise: Promise,\n then: (val: T) => U | PromiseLike\n): typeof promise extends AsyncModulePromise\n ? AsyncModulePromise\n : Promise {\n const newPromise = promise.then(then);\n\n if (isAsyncModuleExt(promise)) {\n Object.assign(newPromise, {\n get [turbopackExports]() {\n return promise[turbopackExports];\n },\n get [turbopackQueues]() {\n return promise[turbopackQueues];\n },\n get [turbopackError]() {\n return promise[turbopackError];\n },\n } satisfies AsyncModuleExt);\n }\n\n return newPromise as any;\n}\n\nfunction createPromise() {\n let resolve: (value: T | PromiseLike) => void;\n let reject: (reason?: any) => void;\n\n const promise = new Promise((res, rej) => {\n reject = rej;\n resolve = res;\n });\n\n return {\n promise,\n resolve: resolve!,\n reject: reject!,\n };\n}\n\n// everything below is adapted from webpack\n// https://github.com/webpack/webpack/blob/6be4065ade1e252c1d8dcba4af0f43e32af1bdc1/lib/runtime/AsyncModuleRuntimeModule.js#L13\n\nconst turbopackQueues = Symbol(\"turbopack queues\");\nconst turbopackExports = Symbol(\"turbopack exports\");\nconst turbopackError = Symbol(\"turbopack error\");\n\ntype AsyncQueueFn = (() => void) & { queueCount: number };\ntype AsyncQueue = AsyncQueueFn[] & { resolved: boolean };\n\nfunction resolveQueue(queue?: AsyncQueue) {\n if (queue && !queue.resolved) {\n queue.resolved = true;\n queue.forEach((fn) => fn.queueCount--);\n queue.forEach((fn) => (fn.queueCount-- ? fn.queueCount++ : fn()));\n }\n}\n\ntype Dep = Exports | AsyncModulePromise | Promise;\n\ntype AsyncModuleExt = {\n [turbopackQueues]: (fn: (queue: AsyncQueue) => void) => void;\n [turbopackExports]: Exports;\n [turbopackError]?: any;\n};\n\ntype AsyncModulePromise = Promise & AsyncModuleExt;\n\nfunction wrapDeps(deps: Dep[]): AsyncModuleExt[] {\n return deps.map((dep) => {\n if (dep !== null && typeof dep === \"object\") {\n if (isAsyncModuleExt(dep)) return dep;\n if (isPromise(dep)) {\n const queue: AsyncQueue = Object.assign([], { resolved: false });\n\n const obj: AsyncModuleExt = {\n [turbopackExports]: {},\n [turbopackQueues]: (fn: (queue: AsyncQueue) => void) => fn(queue),\n };\n\n dep.then(\n (res) => {\n obj[turbopackExports] = res;\n resolveQueue(queue);\n },\n (err) => {\n obj[turbopackError] = err;\n resolveQueue(queue);\n }\n );\n\n return obj;\n }\n }\n\n const ret: AsyncModuleExt = {\n [turbopackExports]: dep,\n [turbopackQueues]: () => {},\n };\n\n return ret;\n });\n}\n\nfunction asyncModule(\n module: Module,\n body: (\n handleAsyncDependencies: (\n deps: Dep[]\n ) => Exports[] | Promise<() => Exports[]>,\n asyncResult: (err?: any) => void\n ) => void,\n hasAwait: boolean\n) {\n const queue: AsyncQueue | undefined = hasAwait\n ? Object.assign([], { resolved: true })\n : undefined;\n\n const depQueues: Set = new Set();\n const exports = module.exports;\n\n const { resolve, reject, promise: rawPromise } = createPromise();\n\n const promise: AsyncModulePromise = Object.assign(rawPromise, {\n [turbopackExports]: exports,\n [turbopackQueues]: (fn) => {\n queue && fn(queue);\n depQueues.forEach(fn);\n promise[\"catch\"](() => {});\n },\n } satisfies AsyncModuleExt);\n\n module.exports = module.namespaceObject = promise;\n\n function handleAsyncDependencies(deps: Dep[]) {\n const currentDeps = wrapDeps(deps);\n\n const getResult = () =>\n currentDeps.map((d) => {\n if (d[turbopackError]) throw d[turbopackError];\n return d[turbopackExports];\n });\n\n const { promise, resolve } = createPromise<() => Exports[]>();\n\n const fn: AsyncQueueFn = Object.assign(() => resolve(getResult), {\n queueCount: 0,\n });\n\n function fnQueue(q: AsyncQueue) {\n if (q !== queue && !depQueues.has(q)) {\n depQueues.add(q);\n if (q && !q.resolved) {\n fn.queueCount++;\n q.push(fn);\n }\n }\n }\n\n currentDeps.map((dep) => dep[turbopackQueues](fnQueue));\n\n return fn.queueCount ? promise : getResult();\n }\n\n function asyncResult(err?: any) {\n if (err) {\n reject((promise[turbopackError] = err));\n } else {\n resolve(exports);\n }\n\n resolveQueue(queue);\n }\n\n body(handleAsyncDependencies, asyncResult);\n\n if (queue) {\n queue.resolved = false;\n }\n}\n"],"names":[],"mappings":";AAmBA,MAAM,qBAAqB,OAAO;;;;;AA0ClC,MAAM,iBAAiB,OAAO,SAAS,CAAC,cAAc;AACtD,MAAM,cAAc,OAAO,WAAW,eAAe,OAAO,WAAW;AAEvE,SAAS,WACP,GAAQ,EACR,IAAiB,EACjB,OAA2C;IAE3C,IAAI,CAAC,eAAe,IAAI,CAAC,KAAK,OAC5B,OAAO,cAAc,CAAC,KAAK,MAAM;AACrC;AAKA,SAAS,IAAI,OAAgB,EAAE,OAAkC;IAC/D,WAAW,SAAS,cAAc;QAAE,OAAO;IAAK;IAChD,IAAI,aAAa,WAAW,SAAS,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UAAU,GAAG,CAAC;gBACd,IAAI,KAAK,CAAC,EAAE,QAAQ,EAAE;oBACpB,GAAG,UAAU;oBACb,EAAE,IAAI,CAAC;gBACT;YACF;QACF;QAEA,YAAY,GAAG,CAAC,CAAC,MAAQ,GAAG,CAAC,gBAAgB,CAAC;QAE9C,OAAO,GAAG,UAAU,GAAG,UAAU;IACnC;IAEA,SAAS,YAAY,GAAS;QAC5B,IAAI,KAAK;YACP,OAAQ,OAAO,CAAC,eAAe,GAAG;QACpC,OAAO;YACL,QAAQ;QACV;QAEA,aAAa;IACf;IAEA,KAAK,yBAAyB;IAE9B,IAAI,OAAO;QACT,MAAM,QAAQ,GAAG;IACnB;AACF"}}, - {"offset": {"line": 241, "column": 0}, "map": {"version":3,"sources":["/turbopack/[turbopack]/dev/runtime/base/runtime-base.ts"],"sourcesContent":["/**\n * This file contains runtime types and functions that are shared between all\n * Turbopack *development* ECMAScript runtimes.\n *\n * It will be appended to the runtime code of each runtime right after the\n * shared runtime utils.\n */\n\n/* eslint-disable @next/next/no-assign-module-variable */\n\n/// \n/// \n/// \n/// \n\n// This file must not use `import` and `export` statements. Otherwise, it\n// becomes impossible to augment interfaces declared in ``d files\n// (e.g. `Module`). Hence, the need for `import()` here.\ntype RefreshRuntimeGlobals =\n import(\"@next/react-refresh-utils/dist/runtime\").RefreshRuntimeGlobals;\n\ndeclare var CHUNK_BASE_PATH: string;\ndeclare var $RefreshHelpers$: RefreshRuntimeGlobals[\"$RefreshHelpers$\"];\ndeclare var $RefreshReg$: RefreshRuntimeGlobals[\"$RefreshReg$\"];\ndeclare var $RefreshSig$: RefreshRuntimeGlobals[\"$RefreshSig$\"];\ndeclare var $RefreshInterceptModuleExecution$:\n | RefreshRuntimeGlobals[\"$RefreshInterceptModuleExecution$\"];\n\ntype RefreshContext = {\n register: RefreshRuntimeGlobals[\"$RefreshReg$\"];\n signature: RefreshRuntimeGlobals[\"$RefreshSig$\"];\n};\n\ntype RefreshHelpers = RefreshRuntimeGlobals[\"$RefreshHelpers$\"];\n\ninterface TurbopackDevBaseContext extends TurbopackBaseContext {\n k: RefreshContext;\n}\n\ninterface TurbopackDevContext extends TurbopackDevBaseContext {}\n\n// string encoding of a module factory (used in hmr updates)\ntype ModuleFactoryString = string;\n\ntype ModuleFactory = (\n this: Module[\"exports\"],\n context: TurbopackDevContext\n) => undefined;\n\ntype DevRuntimeParams = {\n otherChunks: ChunkData[];\n runtimeModuleIds: ModuleId[];\n};\n\ntype ChunkRegistration = [\n chunkPath: ChunkPath,\n chunkModules: ModuleFactories,\n params: DevRuntimeParams | undefined\n];\ntype ChunkList = {\n path: ChunkPath;\n chunks: ChunkData[];\n source: \"entry\" | \"dynamic\";\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 * The module was instantiated because it was included in a chunk's hot module\n * update.\n */\n Update = 2,\n}\n\ntype SourceInfo =\n | {\n type: SourceType.Runtime;\n chunkPath: ChunkPath;\n }\n | {\n type: SourceType.Parent;\n parentId: ModuleId;\n }\n | {\n type: SourceType.Update;\n parents?: ModuleId[];\n };\n\ninterface RuntimeBackend {\n registerChunk: (chunkPath: ChunkPath, params?: DevRuntimeParams) => void;\n loadChunk: (chunkPath: ChunkPath, source: SourceInfo) => Promise;\n reloadChunk?: (chunkPath: ChunkPath) => Promise;\n unloadChunk?: (chunkPath: ChunkPath) => void;\n\n restart: () => void;\n}\n\nconst moduleFactories: ModuleFactories = Object.create(null);\nconst moduleCache: ModuleCache = Object.create(null);\n/**\n * Maps module IDs to persisted data between executions of their hot module\n * implementation (`hot.data`).\n */\nconst moduleHotData: Map = new Map();\n/**\n * Maps module instances to their hot module state.\n */\nconst moduleHotState: Map = new Map();\n/**\n * Modules that call `module.hot.invalidate()` (while being updated).\n */\nconst queuedInvalidatedModules: Set = new Set();\n/**\n * Module IDs that are instantiated as part of the runtime of a chunk.\n */\nconst runtimeModules: Set = new Set();\n/**\n * Map from module ID to the chunks that contain this module.\n *\n * In HMR, we need to keep track of which modules are contained in which so\n * chunks. This is so we don't eagerly dispose of a module when it is removed\n * from chunk A, but still exists in chunk B.\n */\nconst moduleChunksMap: Map> = new Map();\n/**\n * Map from a chunk path to all modules it contains.\n */\nconst chunkModulesMap: Map> = new Map();\n/**\n * Chunk lists that contain a runtime. When these chunk lists receive an update\n * that can't be reconciled with the current state of the page, we need to\n * reload the runtime entirely.\n */\nconst runtimeChunkLists: Set = new Set();\n/**\n * Map from a chunk list to the chunk paths it contains.\n */\nconst chunkListChunksMap: Map> = new Map();\n/**\n * Map from a chunk path to the chunk lists it belongs to.\n */\nconst chunkChunkListsMap: Map> = new Map();\n\nconst availableModules: Map | true> = new Map();\n\nconst availableModuleChunks: Map | true> = new Map();\n\nasync function loadChunk(\n source: SourceInfo,\n chunkData: ChunkData\n): Promise {\n if (typeof chunkData === \"string\") {\n return loadChunkPath(source, chunkData);\n }\n\n const includedList = chunkData.included || [];\n const modulesPromises = includedList.map((included) => {\n if (moduleFactories[included]) return true;\n return availableModules.get(included);\n });\n if (modulesPromises.length > 0 && modulesPromises.every((p) => p)) {\n // When all included items are already loaded or loading, we can skip loading ourselves\n return Promise.all(modulesPromises);\n }\n\n const includedModuleChunksList = chunkData.moduleChunks || [];\n const moduleChunksPromises = includedModuleChunksList\n .map((included) => {\n // TODO(alexkirsz) Do we need this check?\n // if (moduleFactories[included]) return true;\n return availableModuleChunks.get(included);\n })\n .filter((p) => p);\n\n let promise;\n if (moduleChunksPromises.length > 0) {\n // Some module chunks are already loaded or loading.\n\n if (moduleChunksPromises.length == includedModuleChunksList.length) {\n // When all included module chunks are already loaded or loading, we can skip loading ourselves\n return Promise.all(moduleChunksPromises);\n }\n\n const moduleChunksToLoad: Set = new Set();\n for (const moduleChunk of includedModuleChunksList) {\n if (!availableModuleChunks.has(moduleChunk)) {\n moduleChunksToLoad.add(moduleChunk);\n }\n }\n\n for (const moduleChunkToLoad of moduleChunksToLoad) {\n const promise = loadChunkPath(source, moduleChunkToLoad);\n\n availableModuleChunks.set(moduleChunkToLoad, promise);\n\n moduleChunksPromises.push(promise);\n }\n\n promise = Promise.all(moduleChunksPromises);\n } else {\n promise = loadChunkPath(source, chunkData.path);\n\n // Mark all included module chunks as loading if they are not already loaded or loading.\n for (const includedModuleChunk of includedModuleChunksList) {\n if (!availableModuleChunks.has(includedModuleChunk)) {\n availableModuleChunks.set(includedModuleChunk, promise);\n }\n }\n }\n\n for (const included of includedList) {\n if (!availableModules.has(included)) {\n // It might be better to race old and new promises, but it's rare that the new promise will be faster than a request started earlier.\n // In production it's even more rare, because the chunk optimization tries to deduplicate modules anyway.\n availableModules.set(included, promise);\n }\n }\n\n return promise;\n}\n\nasync function loadChunkPath(\n source: SourceInfo,\n chunkPath: ChunkPath\n): Promise {\n try {\n await BACKEND.loadChunk(chunkPath, source);\n } catch (error) {\n let loadReason;\n switch (source.type) {\n case SourceType.Runtime:\n loadReason = `as a runtime dependency of chunk ${source.chunkPath}`;\n break;\n case SourceType.Parent:\n loadReason = `from module ${source.parentId}`;\n break;\n case SourceType.Update:\n loadReason = \"from an HMR update\";\n break;\n }\n throw new Error(\n `Failed to load chunk ${chunkPath} ${loadReason}${\n error ? `: ${error}` : \"\"\n }`,\n error\n ? {\n cause: error,\n }\n : undefined\n );\n }\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 case SourceType.Update:\n instantiationReason = \"because of an HMR update\";\n break;\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 hotData = moduleHotData.get(id)!;\n const { hot, hotState } = createModuleHot(id, hotData);\n\n let parents: ModuleId[];\n switch (source.type) {\n case SourceType.Runtime:\n runtimeModules.add(id);\n parents = [];\n break;\n case SourceType.Parent:\n // No need to add this module as a child of the parent module here, this\n // has already been taken care of in `getOrInstantiateModuleFromParent`.\n parents = [source.parentId];\n break;\n case SourceType.Update:\n parents = source.parents || [];\n break;\n }\n const module: Module = {\n exports: {},\n error: undefined,\n loaded: false,\n id,\n parents,\n children: [],\n namespaceObject: undefined,\n hot,\n };\n\n moduleCache[id] = module;\n moduleHotState.set(module, hotState);\n\n // NOTE(alexkirsz) This can fail when the module encounters a runtime error.\n try {\n runModuleExecutionHooks(module, (refresh) => {\n moduleFactory.call(\n module.exports,\n augmentContext({\n a: asyncModule.bind(null, module),\n e: module.exports,\n r: commonJsRequire.bind(null, module),\n f: requireContext.bind(null, module),\n i: esmImport.bind(null, module),\n s: esmExport.bind(null, module, module.exports),\n j: dynamicExport.bind(null, module, module.exports),\n v: exportValue.bind(null, module),\n n: exportNamespace.bind(null, module),\n m: module,\n c: moduleCache,\n l: loadChunk.bind(null, { type: SourceType.Parent, parentId: id }),\n g: globalThis,\n k: refresh,\n __dirname: module.id.replace(/(^|\\/)\\/+$/, \"\"),\n })\n );\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 * NOTE(alexkirsz) Webpack has a \"module execution\" interception hook that\n * Next.js' React Refresh runtime hooks into to add module context to the\n * refresh registry.\n */\nfunction runModuleExecutionHooks(\n module: Module,\n executeModule: (ctx: RefreshContext) => void\n) {\n const cleanupReactRefreshIntercept =\n typeof globalThis.$RefreshInterceptModuleExecution$ === \"function\"\n ? globalThis.$RefreshInterceptModuleExecution$(module.id)\n : () => {};\n\n try {\n executeModule({\n register: globalThis.$RefreshReg$,\n signature: globalThis.$RefreshSig$,\n });\n\n if (\"$RefreshHelpers$\" in globalThis) {\n // This pattern can also be used to register the exports of\n // a module with the React Refresh runtime.\n registerExportsAndSetupBoundaryForReactRefresh(\n module,\n globalThis.$RefreshHelpers$\n );\n }\n } catch (e) {\n throw e;\n } finally {\n // Always cleanup the intercept, even if module execution failed.\n cleanupReactRefreshIntercept();\n }\n}\n\n/**\n * Retrieves a module from the cache, or instantiate it if it is not cached.\n */\nconst getOrInstantiateModuleFromParent: GetOrInstantiateModuleFromParent = (\n id,\n sourceModule\n) => {\n if (!sourceModule.hot.active) {\n console.warn(\n `Unexpected import of module ${id} from module ${sourceModule.id}, which was deleted by an HMR update`\n );\n }\n\n const module = moduleCache[id];\n\n if (sourceModule.children.indexOf(id) === -1) {\n sourceModule.children.push(id);\n }\n\n if (module) {\n if (module.parents.indexOf(sourceModule.id) === -1) {\n module.parents.push(sourceModule.id);\n }\n\n return module;\n }\n\n return instantiateModule(id, {\n type: SourceType.Parent,\n parentId: sourceModule.id,\n });\n};\n\n/**\n * This is adapted from https://github.com/vercel/next.js/blob/3466862d9dc9c8bb3131712134d38757b918d1c0/packages/react-refresh-utils/internal/ReactRefreshModule.runtime.ts\n */\nfunction registerExportsAndSetupBoundaryForReactRefresh(\n module: Module,\n helpers: RefreshHelpers\n) {\n const currentExports = module.exports;\n const prevExports = module.hot.data.prevExports ?? null;\n\n helpers.registerExportsForReactRefresh(currentExports, module.id);\n\n // A module can be accepted automatically based on its exports, e.g. when\n // it is a Refresh Boundary.\n if (helpers.isReactRefreshBoundary(currentExports)) {\n // Save the previous exports on update, so we can compare the boundary\n // signatures.\n module.hot.dispose((data) => {\n data.prevExports = currentExports;\n });\n // Unconditionally accept an update to this module, we'll check if it's\n // still a Refresh Boundary later.\n module.hot.accept();\n\n // This field is set when the previous version of this module was a\n // Refresh Boundary, letting us know we need to check for invalidation or\n // enqueue an update.\n if (prevExports !== null) {\n // A boundary can become ineligible if its exports are incompatible\n // with the previous exports.\n //\n // For example, if you add/remove/change exports, we'll want to\n // re-execute the importing modules, and force those components to\n // re-render. Similarly, if you convert a class component to a\n // function, we want to invalidate the boundary.\n if (\n helpers.shouldInvalidateReactRefreshBoundary(\n prevExports,\n currentExports\n )\n ) {\n module.hot.invalidate();\n } else {\n helpers.scheduleUpdate();\n }\n }\n } else {\n // Since we just executed the code for the module, it's possible that the\n // new exports made it ineligible for being a boundary.\n // We only care about the case when we were _previously_ a boundary,\n // because we already accepted this update (accidental side effect).\n const isNoLongerABoundary = prevExports !== null;\n if (isNoLongerABoundary) {\n module.hot.invalidate();\n }\n }\n}\n\nfunction formatDependencyChain(dependencyChain: ModuleId[]): string {\n return `Dependency chain: ${dependencyChain.join(\" -> \")}`;\n}\n\nfunction computeOutdatedModules(\n added: Map,\n modified: Map\n): {\n outdatedModules: Set;\n newModuleFactories: Map;\n} {\n const newModuleFactories = new Map();\n\n for (const [moduleId, entry] of added) {\n if (entry != null) {\n newModuleFactories.set(moduleId, _eval(entry));\n }\n }\n\n const outdatedModules = computedInvalidatedModules(modified.keys());\n\n for (const [moduleId, entry] of modified) {\n newModuleFactories.set(moduleId, _eval(entry));\n }\n\n return { outdatedModules, newModuleFactories };\n}\n\nfunction computedInvalidatedModules(\n invalidated: Iterable\n): Set {\n const outdatedModules = new Set();\n\n for (const moduleId of invalidated) {\n const effect = getAffectedModuleEffects(moduleId);\n\n switch (effect.type) {\n case \"unaccepted\":\n throw new Error(\n `cannot apply update: unaccepted module. ${formatDependencyChain(\n effect.dependencyChain\n )}.`\n );\n case \"self-declined\":\n throw new Error(\n `cannot apply update: self-declined module. ${formatDependencyChain(\n effect.dependencyChain\n )}.`\n );\n case \"accepted\":\n for (const outdatedModuleId of effect.outdatedModules) {\n outdatedModules.add(outdatedModuleId);\n }\n break;\n // TODO(alexkirsz) Dependencies: handle dependencies effects.\n }\n }\n\n return outdatedModules;\n}\n\nfunction computeOutdatedSelfAcceptedModules(\n outdatedModules: Iterable\n): { moduleId: ModuleId; errorHandler: true | Function }[] {\n const outdatedSelfAcceptedModules = [];\n for (const moduleId of outdatedModules) {\n const module = moduleCache[moduleId];\n const hotState = moduleHotState.get(module)!;\n if (module && hotState.selfAccepted && !hotState.selfInvalidated) {\n outdatedSelfAcceptedModules.push({\n moduleId,\n errorHandler: hotState.selfAccepted,\n });\n }\n }\n return outdatedSelfAcceptedModules;\n}\n\n/**\n * Adds, deletes, and moves modules between chunks. This must happen before the\n * dispose phase as it needs to know which modules were removed from all chunks,\n * which we can only compute *after* taking care of added and moved modules.\n */\nfunction updateChunksPhase(\n chunksAddedModules: Map>,\n chunksDeletedModules: Map>\n): { disposedModules: Set } {\n for (const [chunkPath, addedModuleIds] of chunksAddedModules) {\n for (const moduleId of addedModuleIds) {\n addModuleToChunk(moduleId, chunkPath);\n }\n }\n\n const disposedModules: Set = new Set();\n for (const [chunkPath, addedModuleIds] of chunksDeletedModules) {\n for (const moduleId of addedModuleIds) {\n if (removeModuleFromChunk(moduleId, chunkPath)) {\n disposedModules.add(moduleId);\n }\n }\n }\n\n return { disposedModules };\n}\n\nfunction disposePhase(\n outdatedModules: Iterable,\n disposedModules: Iterable\n): { outdatedModuleParents: Map> } {\n for (const moduleId of outdatedModules) {\n disposeModule(moduleId, \"replace\");\n }\n\n for (const moduleId of disposedModules) {\n disposeModule(moduleId, \"clear\");\n }\n\n // Removing modules from the module cache is a separate step.\n // We also want to keep track of previous parents of the outdated modules.\n const outdatedModuleParents = new Map();\n for (const moduleId of outdatedModules) {\n const oldModule = moduleCache[moduleId];\n outdatedModuleParents.set(moduleId, oldModule?.parents);\n delete moduleCache[moduleId];\n }\n\n // TODO(alexkirsz) Dependencies: remove outdated dependency from module\n // children.\n\n return { outdatedModuleParents };\n}\n\n/**\n * Disposes of an instance of a module.\n *\n * Returns the persistent hot data that should be kept for the next module\n * instance.\n *\n * NOTE: mode = \"replace\" will not remove modules from the moduleCache.\n * This must be done in a separate step afterwards.\n * This is important because all modules need to be disposed to update the\n * parent/child relationships before they are actually removed from the moduleCache.\n * If this was done in this method, the following disposeModule calls won't find\n * the module from the module id in the cache.\n */\nfunction disposeModule(moduleId: ModuleId, mode: \"clear\" | \"replace\") {\n const module = moduleCache[moduleId];\n if (!module) {\n return;\n }\n\n const hotState = moduleHotState.get(module)!;\n const data = {};\n\n // Run the `hot.dispose` handler, if any, passing in the persistent\n // `hot.data` object.\n for (const disposeHandler of hotState.disposeHandlers) {\n disposeHandler(data);\n }\n\n // This used to warn in `getOrInstantiateModuleFromParent` when a disposed\n // module is still importing other modules.\n module.hot.active = false;\n\n moduleHotState.delete(module);\n\n // TODO(alexkirsz) Dependencies: delete the module from outdated deps.\n\n // Remove the disposed module from its children's parent list.\n // It will be added back once the module re-instantiates and imports its\n // children again.\n for (const childId of module.children) {\n const child = moduleCache[childId];\n if (!child) {\n continue;\n }\n\n const idx = child.parents.indexOf(module.id);\n if (idx >= 0) {\n child.parents.splice(idx, 1);\n }\n }\n\n switch (mode) {\n case \"clear\":\n delete moduleCache[module.id];\n moduleHotData.delete(module.id);\n break;\n case \"replace\":\n moduleHotData.set(module.id, data);\n break;\n default:\n invariant(mode, (mode) => `invalid mode: ${mode}`);\n }\n}\n\nfunction applyPhase(\n outdatedSelfAcceptedModules: {\n moduleId: ModuleId;\n errorHandler: true | Function;\n }[],\n newModuleFactories: Map,\n outdatedModuleParents: Map>,\n reportError: (err: any) => void\n) {\n // Update module factories.\n for (const [moduleId, factory] of newModuleFactories.entries()) {\n moduleFactories[moduleId] = factory;\n }\n\n // TODO(alexkirsz) Run new runtime entries here.\n\n // TODO(alexkirsz) Dependencies: call accept handlers for outdated deps.\n\n // Re-instantiate all outdated self-accepted modules.\n for (const { moduleId, errorHandler } of outdatedSelfAcceptedModules) {\n try {\n instantiateModule(moduleId, {\n type: SourceType.Update,\n parents: outdatedModuleParents.get(moduleId),\n });\n } catch (err) {\n if (typeof errorHandler === \"function\") {\n try {\n errorHandler(err, { moduleId, module: moduleCache[moduleId] });\n } catch (err2) {\n reportError(err2);\n reportError(err);\n }\n } else {\n reportError(err);\n }\n }\n }\n}\n\n/**\n * Utility function to ensure all variants of an enum are handled.\n */\nfunction invariant(never: never, computeMessage: (arg: any) => string): never {\n throw new Error(`Invariant: ${computeMessage(never)}`);\n}\n\nfunction applyUpdate(chunkListPath: ChunkPath, update: PartialUpdate) {\n switch (update.type) {\n case \"ChunkListUpdate\":\n applyChunkListUpdate(chunkListPath, update);\n break;\n default:\n invariant(update, (update) => `Unknown update type: ${update.type}`);\n }\n}\n\nfunction applyChunkListUpdate(\n chunkListPath: ChunkPath,\n update: ChunkListUpdate\n) {\n if (update.merged != null) {\n for (const merged of update.merged) {\n switch (merged.type) {\n case \"EcmascriptMergedUpdate\":\n applyEcmascriptMergedUpdate(chunkListPath, merged);\n break;\n default:\n invariant(merged, (merged) => `Unknown merged type: ${merged.type}`);\n }\n }\n }\n\n if (update.chunks != null) {\n for (const [chunkPath, chunkUpdate] of Object.entries(update.chunks)) {\n switch (chunkUpdate.type) {\n case \"added\":\n BACKEND.loadChunk(chunkPath, { type: SourceType.Update });\n break;\n case \"total\":\n BACKEND.reloadChunk?.(chunkPath);\n break;\n case \"deleted\":\n BACKEND.unloadChunk?.(chunkPath);\n break;\n case \"partial\":\n invariant(\n chunkUpdate.instruction,\n (instruction) =>\n `Unknown partial instruction: ${JSON.stringify(instruction)}.`\n );\n default:\n invariant(\n chunkUpdate,\n (chunkUpdate) => `Unknown chunk update type: ${chunkUpdate.type}`\n );\n }\n }\n }\n}\n\nfunction applyEcmascriptMergedUpdate(\n chunkPath: ChunkPath,\n update: EcmascriptMergedUpdate\n) {\n const { entries = {}, chunks = {} } = update;\n const { added, modified, chunksAdded, chunksDeleted } = computeChangedModules(\n entries,\n chunks\n );\n const { outdatedModules, newModuleFactories } = computeOutdatedModules(\n added,\n modified\n );\n const { disposedModules } = updateChunksPhase(chunksAdded, chunksDeleted);\n\n applyInternal(outdatedModules, disposedModules, newModuleFactories);\n}\n\nfunction applyInvalidatedModules(outdatedModules: Set) {\n if (queuedInvalidatedModules.size > 0) {\n computedInvalidatedModules(queuedInvalidatedModules).forEach((moduleId) => {\n outdatedModules.add(moduleId);\n });\n\n queuedInvalidatedModules.clear();\n }\n\n return outdatedModules;\n}\n\nfunction applyInternal(\n outdatedModules: Set,\n disposedModules: Iterable,\n newModuleFactories: Map\n) {\n outdatedModules = applyInvalidatedModules(outdatedModules);\n\n const outdatedSelfAcceptedModules =\n computeOutdatedSelfAcceptedModules(outdatedModules);\n\n const { outdatedModuleParents } = disposePhase(\n outdatedModules,\n disposedModules\n );\n\n // we want to continue on error and only throw the error after we tried applying all updates\n let error: any;\n function reportError(err: any) {\n if (!error) error = err;\n }\n\n applyPhase(\n outdatedSelfAcceptedModules,\n newModuleFactories,\n outdatedModuleParents,\n reportError\n );\n\n if (error) {\n throw error;\n }\n\n if (queuedInvalidatedModules.size > 0) {\n applyInternal(new Set(), [], new Map());\n }\n}\n\nfunction computeChangedModules(\n entries: Record,\n updates: Record\n): {\n added: Map;\n modified: Map;\n deleted: Set;\n chunksAdded: Map>;\n chunksDeleted: Map>;\n} {\n const chunksAdded = new Map();\n const chunksDeleted = new Map();\n const added: Map = new Map();\n const modified = new Map();\n const deleted: Set = new Set();\n\n for (const [chunkPath, mergedChunkUpdate] of Object.entries(updates)) {\n switch (mergedChunkUpdate.type) {\n case \"added\": {\n const updateAdded = new Set(mergedChunkUpdate.modules);\n for (const moduleId of updateAdded) {\n added.set(moduleId, entries[moduleId]);\n }\n chunksAdded.set(chunkPath, updateAdded);\n break;\n }\n case \"deleted\": {\n // We could also use `mergedChunkUpdate.modules` here.\n const updateDeleted = new Set(chunkModulesMap.get(chunkPath));\n for (const moduleId of updateDeleted) {\n deleted.add(moduleId);\n }\n chunksDeleted.set(chunkPath, updateDeleted);\n break;\n }\n case \"partial\": {\n const updateAdded = new Set(mergedChunkUpdate.added);\n const updateDeleted = new Set(mergedChunkUpdate.deleted);\n for (const moduleId of updateAdded) {\n added.set(moduleId, entries[moduleId]);\n }\n for (const moduleId of updateDeleted) {\n deleted.add(moduleId);\n }\n chunksAdded.set(chunkPath, updateAdded);\n chunksDeleted.set(chunkPath, updateDeleted);\n break;\n }\n default:\n invariant(\n mergedChunkUpdate,\n (mergedChunkUpdate) =>\n `Unknown merged chunk update type: ${mergedChunkUpdate.type}`\n );\n }\n }\n\n // If a module was added from one chunk and deleted from another in the same update,\n // consider it to be modified, as it means the module was moved from one chunk to another\n // AND has new code in a single update.\n for (const moduleId of added.keys()) {\n if (deleted.has(moduleId)) {\n added.delete(moduleId);\n deleted.delete(moduleId);\n }\n }\n\n for (const [moduleId, entry] of Object.entries(entries)) {\n // Modules that haven't been added to any chunk but have new code are considered\n // to be modified.\n // This needs to be under the previous loop, as we need it to get rid of modules\n // that were added and deleted in the same update.\n if (!added.has(moduleId)) {\n modified.set(moduleId, entry);\n }\n }\n\n return { added, deleted, modified, chunksAdded, chunksDeleted };\n}\n\ntype ModuleEffect =\n | {\n type: \"unaccepted\";\n dependencyChain: ModuleId[];\n }\n | {\n type: \"self-declined\";\n dependencyChain: ModuleId[];\n moduleId: ModuleId;\n }\n | {\n type: \"accepted\";\n moduleId: ModuleId;\n outdatedModules: Set;\n };\n\nfunction getAffectedModuleEffects(moduleId: ModuleId): ModuleEffect {\n const outdatedModules: Set = new Set();\n\n type QueueItem = { moduleId?: ModuleId; dependencyChain: ModuleId[] };\n\n const queue: QueueItem[] = [\n {\n moduleId,\n dependencyChain: [],\n },\n ];\n\n let nextItem;\n while ((nextItem = queue.shift())) {\n const { moduleId, dependencyChain } = nextItem;\n\n if (moduleId != null) {\n outdatedModules.add(moduleId);\n }\n\n // We've arrived at the runtime of the chunk, which means that nothing\n // else above can accept this update.\n if (moduleId === undefined) {\n return {\n type: \"unaccepted\",\n dependencyChain,\n };\n }\n\n const module = moduleCache[moduleId];\n const hotState = moduleHotState.get(module)!;\n\n if (\n // The module is not in the cache. Since this is a \"modified\" update,\n // it means that the module was never instantiated before.\n !module || // The module accepted itself without invalidating globalThis.\n // TODO is that right?\n (hotState.selfAccepted && !hotState.selfInvalidated)\n ) {\n continue;\n }\n\n if (hotState.selfDeclined) {\n return {\n type: \"self-declined\",\n dependencyChain,\n moduleId,\n };\n }\n\n if (runtimeModules.has(moduleId)) {\n queue.push({\n moduleId: undefined,\n dependencyChain: [...dependencyChain, moduleId],\n });\n continue;\n }\n\n for (const parentId of module.parents) {\n const parent = moduleCache[parentId];\n\n if (!parent) {\n // TODO(alexkirsz) Is this even possible?\n continue;\n }\n\n // TODO(alexkirsz) Dependencies: check accepted and declined\n // dependencies here.\n\n queue.push({\n moduleId: parentId,\n dependencyChain: [...dependencyChain, moduleId],\n });\n }\n }\n\n return {\n type: \"accepted\",\n moduleId,\n outdatedModules,\n };\n}\n\nfunction handleApply(chunkListPath: ChunkPath, update: ServerMessage) {\n switch (update.type) {\n case \"partial\": {\n // This indicates that the update is can be applied to the current state of the application.\n applyUpdate(chunkListPath, update.instruction);\n break;\n }\n case \"restart\": {\n // This indicates that there is no way to apply the update to the\n // current state of the application, and that the application must be\n // restarted.\n BACKEND.restart();\n break;\n }\n case \"notFound\": {\n // This indicates that the chunk list no longer exists: either the dynamic import which created it was removed,\n // or the page itself was deleted.\n // If it is a dynamic import, we simply discard all modules that the chunk has exclusive access to.\n // If it is a runtime chunk list, we restart the application.\n if (runtimeChunkLists.has(chunkListPath)) {\n BACKEND.restart();\n } else {\n disposeChunkList(chunkListPath);\n }\n break;\n }\n default:\n throw new Error(`Unknown update type: ${update.type}`);\n }\n}\n\nfunction createModuleHot(\n moduleId: ModuleId,\n hotData: HotData\n): { hot: Hot; hotState: HotState } {\n const hotState: HotState = {\n selfAccepted: false,\n selfDeclined: false,\n selfInvalidated: false,\n disposeHandlers: [],\n };\n\n const hot: Hot = {\n // TODO(alexkirsz) This is not defined in the HMR API. It was used to\n // decide whether to warn whenever an HMR-disposed module required other\n // modules. We might want to remove it.\n active: true,\n\n data: hotData ?? {},\n\n // TODO(alexkirsz) Support full (dep, callback, errorHandler) form.\n accept: (\n modules?: string | string[] | AcceptErrorHandler,\n _callback?: AcceptCallback,\n _errorHandler?: AcceptErrorHandler\n ) => {\n if (modules === undefined) {\n hotState.selfAccepted = true;\n } else if (typeof modules === \"function\") {\n hotState.selfAccepted = modules;\n } else {\n throw new Error(\"unsupported `accept` signature\");\n }\n },\n\n decline: (dep) => {\n if (dep === undefined) {\n hotState.selfDeclined = true;\n } else {\n throw new Error(\"unsupported `decline` signature\");\n }\n },\n\n dispose: (callback) => {\n hotState.disposeHandlers.push(callback);\n },\n\n addDisposeHandler: (callback) => {\n hotState.disposeHandlers.push(callback);\n },\n\n removeDisposeHandler: (callback) => {\n const idx = hotState.disposeHandlers.indexOf(callback);\n if (idx >= 0) {\n hotState.disposeHandlers.splice(idx, 1);\n }\n },\n\n invalidate: () => {\n hotState.selfInvalidated = true;\n queuedInvalidatedModules.add(moduleId);\n },\n\n // NOTE(alexkirsz) This is part of the management API, which we don't\n // implement, but the Next.js React Refresh runtime uses this to decide\n // whether to schedule an update.\n status: () => \"idle\",\n\n // NOTE(alexkirsz) Since we always return \"idle\" for now, these are no-ops.\n addStatusHandler: (_handler) => {},\n removeStatusHandler: (_handler) => {},\n };\n\n return { hot, hotState };\n}\n\n/**\n * Adds a module to a chunk.\n */\nfunction addModuleToChunk(moduleId: ModuleId, chunkPath: ChunkPath) {\n let moduleChunks = moduleChunksMap.get(moduleId);\n if (!moduleChunks) {\n moduleChunks = new Set([chunkPath]);\n moduleChunksMap.set(moduleId, moduleChunks);\n } else {\n moduleChunks.add(chunkPath);\n }\n\n let chunkModules = chunkModulesMap.get(chunkPath);\n if (!chunkModules) {\n chunkModules = new Set([moduleId]);\n chunkModulesMap.set(chunkPath, chunkModules);\n } else {\n chunkModules.add(moduleId);\n }\n}\n\n/**\n * Returns the first chunk that included a module.\n * This is used by the Node.js backend, hence why it's marked as unused in this\n * file.\n */\nfunction getFirstModuleChunk(moduleId: ModuleId) {\n const moduleChunkPaths = moduleChunksMap.get(moduleId);\n if (moduleChunkPaths == null) {\n return null;\n }\n\n return moduleChunkPaths.values().next().value;\n}\n\n/**\n * Removes a module from a chunk.\n * Returns `true` if there are no remaining chunks including this module.\n */\nfunction removeModuleFromChunk(\n moduleId: ModuleId,\n chunkPath: ChunkPath\n): boolean {\n const moduleChunks = moduleChunksMap.get(moduleId)!;\n moduleChunks.delete(chunkPath);\n\n const chunkModules = chunkModulesMap.get(chunkPath)!;\n chunkModules.delete(moduleId);\n\n const noRemainingModules = chunkModules.size === 0;\n if (noRemainingModules) {\n chunkModulesMap.delete(chunkPath);\n }\n\n const noRemainingChunks = moduleChunks.size === 0;\n if (noRemainingChunks) {\n moduleChunksMap.delete(moduleId);\n }\n\n return noRemainingChunks;\n}\n\n/**\n * Disposes of a chunk list and its corresponding exclusive chunks.\n */\nfunction disposeChunkList(chunkListPath: ChunkPath): boolean {\n const chunkPaths = chunkListChunksMap.get(chunkListPath);\n if (chunkPaths == null) {\n return false;\n }\n chunkListChunksMap.delete(chunkListPath);\n\n for (const chunkPath of chunkPaths) {\n const chunkChunkLists = chunkChunkListsMap.get(chunkPath)!;\n chunkChunkLists.delete(chunkListPath);\n\n if (chunkChunkLists.size === 0) {\n chunkChunkListsMap.delete(chunkPath);\n disposeChunk(chunkPath);\n }\n }\n\n // We must also dispose of the chunk list's chunk itself to ensure it may\n // be reloaded properly in the future.\n BACKEND.unloadChunk?.(chunkListPath);\n\n return true;\n}\n\n/**\n * Disposes of a chunk and its corresponding exclusive modules.\n *\n * @returns Whether the chunk was disposed of.\n */\nfunction disposeChunk(chunkPath: ChunkPath): boolean {\n // This should happen whether the chunk has any modules in it or not.\n // For instance, CSS chunks have no modules in them, but they still need to be unloaded.\n BACKEND.unloadChunk?.(chunkPath);\n\n const chunkModules = chunkModulesMap.get(chunkPath);\n if (chunkModules == null) {\n return false;\n }\n chunkModules.delete(chunkPath);\n\n for (const moduleId of chunkModules) {\n const moduleChunks = moduleChunksMap.get(moduleId)!;\n moduleChunks.delete(chunkPath);\n\n const noRemainingChunks = moduleChunks.size === 0;\n if (noRemainingChunks) {\n moduleChunksMap.delete(moduleId);\n disposeModule(moduleId, \"clear\");\n availableModules.delete(moduleId);\n }\n }\n\n return true;\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 * Gets or instantiates a runtime module.\n */\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 instantiateModule(moduleId, { type: SourceType.Runtime, chunkPath });\n}\n\n/**\n * Returns the URL relative to the origin where a chunk can be fetched from.\n */\nfunction getChunkRelativeUrl(chunkPath: ChunkPath): string {\n return `${CHUNK_BASE_PATH}${chunkPath}`;\n}\n\n/**\n * Subscribes to chunk list updates from the update server and applies them.\n */\nfunction registerChunkList(\n chunkUpdateProvider: ChunkUpdateProvider,\n chunkList: ChunkList\n) {\n chunkUpdateProvider.push([\n chunkList.path,\n handleApply.bind(null, chunkList.path),\n ]);\n\n // Adding chunks to chunk lists and vice versa.\n const chunks = new Set(chunkList.chunks.map(getChunkPath));\n chunkListChunksMap.set(chunkList.path, chunks);\n for (const chunkPath of chunks) {\n let chunkChunkLists = chunkChunkListsMap.get(chunkPath);\n if (!chunkChunkLists) {\n chunkChunkLists = new Set([chunkList.path]);\n chunkChunkListsMap.set(chunkPath, chunkChunkLists);\n } else {\n chunkChunkLists.add(chunkList.path);\n }\n }\n\n if (chunkList.source === \"entry\") {\n markChunkListAsRuntime(chunkList.path);\n }\n}\n\n/**\n * Marks a chunk list as a runtime chunk list. There can be more than one\n * runtime chunk list. For instance, integration tests can have multiple chunk\n * groups loaded at runtime, each with its own chunk list.\n */\nfunction markChunkListAsRuntime(chunkListPath: ChunkPath) {\n runtimeChunkLists.add(chunkListPath);\n}\n\nfunction registerChunk([\n chunkPath,\n chunkModules,\n runtimeParams,\n]: ChunkRegistration) {\n for (const [moduleId, moduleFactory] of Object.entries(chunkModules)) {\n if (!moduleFactories[moduleId]) {\n moduleFactories[moduleId] = moduleFactory;\n }\n addModuleToChunk(moduleId, chunkPath);\n }\n\n return BACKEND.registerChunk(chunkPath, runtimeParams);\n}\n\nglobalThis.TURBOPACK_CHUNK_UPDATE_LISTENERS ??= [];\n\nconst chunkListsToRegister = globalThis.TURBOPACK_CHUNK_LISTS;\nif (Array.isArray(chunkListsToRegister)) {\n for (const chunkList of chunkListsToRegister) {\n registerChunkList(globalThis.TURBOPACK_CHUNK_UPDATE_LISTENERS, chunkList);\n }\n}\n\nglobalThis.TURBOPACK_CHUNK_LISTS = {\n push: (chunkList) => {\n registerChunkList(globalThis.TURBOPACK_CHUNK_UPDATE_LISTENERS!, chunkList);\n },\n} satisfies ChunkListProvider;\n"],"names":[],"mappings":";;;;;;;IAiEA;UAAK,UAAU;IAAV,WAAA,WAKH,aAAU,KAAV;IALG,WAAA,WASH,YAAS,KAAT;IATG,WAAA,WAcH,YAAS,KAAT;GAdG,eAAA;;AAwCL,MAAM,kBAAmC,OAAO,MAAM,CAAC;AACvD,MAAM,cAA2B,OAAO,MAAM,CAAC;AAK/C,MAAM,gBAAwC,IAAI;AAIlD,MAAM,iBAAwC,IAAI;AAIlD,MAAM,2BAA0C,IAAI;AAIpD,MAAM,iBAAgC,IAAI;AAQ1C,MAAM,kBAAiD,IAAI;AAI3D,MAAM,kBAAiD,IAAI;AAM3D,MAAM,oBAAoC,IAAI;AAI9C,MAAM,qBAAqD,IAAI;AAI/D,MAAM,qBAAqD,IAAI;AAE/D,MAAM,mBAAuD,IAAI;AAEjE,MAAM,wBAA6D,IAAI;AAEvE,eAAe,UACb,MAAkB,EAClB,SAAoB;IAEpB,IAAI,OA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W,qBAAqB;AAC7D,IAAI,MAAM,OAAO,CAAC,uBAAuB;IACvC,KAAK,MAAM,aAAa,qBAAsB;QAC5C,kBAAkB,WAAW,gCAAgC,EAAE;IACjE;AACF;AAEA,WAAW,qBAAqB,GAAG;IACjC,MAAM,CAAC;QACL,kBAAkB,WAAW,gCAAgC,EAAG;IAClE;AACF"}}, - {"offset": {"line": 1046, "column": 0}, "map": {"version":3,"sources":["/turbopack/[turbopack]/dev/runtime/dom/runtime-backend-dom.ts"],"sourcesContent":["/**\n * This file contains the runtime code specific to the Turbopack development\n * ECMAScript DOM runtime.\n *\n * It will be appended to the base development runtime code.\n */\n\n/// \n\ntype ChunkResolver = {\n resolved: boolean;\n resolve: () => void;\n reject: (error?: Error) => void;\n promise: Promise;\n};\n\nlet BACKEND: RuntimeBackend;\n\nfunction augmentContext(context: TurbopackDevBaseContext): TurbopackDevContext {\n return context;\n}\n\nfunction commonJsRequireContext(\n entry: RequireContextEntry,\n sourceModule: Module\n): Exports {\n return commonJsRequire(sourceModule, entry.id());\n}\n\n(() => {\n BACKEND = {\n async registerChunk(chunkPath, params) {\n const resolver = getOrCreateResolver(chunkPath);\n resolver.resolve();\n\n if (params == null) {\n return;\n }\n\n for (const otherChunkData of params.otherChunks) {\n const otherChunkPath = getChunkPath(otherChunkData);\n // Chunk might have started loading, so we want to avoid triggering another load.\n getOrCreateResolver(otherChunkPath);\n }\n\n // This waits for chunks to be loaded, but also marks included items as available.\n await Promise.all(\n params.otherChunks.map((otherChunkData) =>\n loadChunk({ type: SourceType.Runtime, chunkPath }, otherChunkData)\n )\n );\n\n if (params.runtimeModuleIds.length > 0) {\n for (const moduleId of params.runtimeModuleIds) {\n getOrInstantiateRuntimeModule(moduleId, chunkPath);\n }\n }\n },\n\n loadChunk(chunkPath, source) {\n return doLoadChunk(chunkPath, source);\n },\n\n unloadChunk(chunkPath) {\n deleteResolver(chunkPath);\n\n const chunkUrl = getChunkRelativeUrl(chunkPath);\n\n if (chunkPath.endsWith(\".css\")) {\n const links = document.querySelectorAll(`link[href=\"${chunkUrl}\"]`);\n for (const link of Array.from(links)) {\n link.remove();\n }\n } else if (chunkPath.endsWith(\".js\")) {\n // Unloading a JS chunk would have no effect, as it lives in the JS\n // runtime once evaluated.\n // However, we still want to remove the script tag from the DOM to keep\n // the HTML somewhat consistent from the user's perspective.\n const scripts = document.querySelectorAll(`script[src=\"${chunkUrl}\"]`);\n for (const script of Array.from(scripts)) {\n script.remove();\n }\n } else {\n throw new Error(`can't infer type of chunk from path ${chunkPath}`);\n }\n },\n\n reloadChunk(chunkPath) {\n return new Promise((resolve, reject) => {\n if (!chunkPath.endsWith(\".css\")) {\n reject(new Error(\"The DOM backend can only reload CSS chunks\"));\n return;\n }\n\n const encodedChunkPath = chunkPath\n .split(\"/\")\n .map((p) => encodeURIComponent(p))\n .join(\"/\");\n\n const chunkUrl = `/${getChunkRelativeUrl(encodedChunkPath)}`;\n\n const previousLink = document.querySelector(\n `link[rel=stylesheet][href^=\"${chunkUrl}\"]`\n );\n\n if (previousLink == null) {\n reject(new Error(`No link element found for chunk ${chunkPath}`));\n return;\n }\n\n const link = document.createElement(\"link\");\n link.rel = \"stylesheet\";\n link.href = chunkUrl;\n link.onerror = () => {\n reject();\n };\n link.onload = () => {\n // First load the new CSS, then remove the old one. This prevents visible\n // flickering that would happen in-between removing the previous CSS and\n // loading the new one.\n previousLink.remove();\n\n // CSS chunks do not register themselves, and as such must be marked as\n // loaded instantly.\n resolve();\n };\n\n // Make sure to insert the new CSS right after the previous one, so that\n // its precedence is higher.\n previousLink.parentElement!.insertBefore(\n link,\n previousLink.nextSibling\n );\n });\n },\n\n restart: () => self.location.reload(),\n };\n\n /**\n * Maps chunk paths to the corresponding resolver.\n */\n const chunkResolvers: Map = new Map();\n\n function getOrCreateResolver(chunkPath: ChunkPath): ChunkResolver {\n let resolver = chunkResolvers.get(chunkPath);\n if (!resolver) {\n let resolve: () => void;\n let reject: (error?: Error) => void;\n const promise = new Promise((innerResolve, innerReject) => {\n resolve = innerResolve;\n reject = innerReject;\n });\n resolver = {\n resolved: false,\n promise,\n resolve: () => {\n resolver!.resolved = true;\n resolve();\n },\n reject: reject!,\n };\n chunkResolvers.set(chunkPath, resolver);\n }\n return resolver;\n }\n\n function deleteResolver(chunkPath: ChunkPath) {\n chunkResolvers.delete(chunkPath);\n }\n\n /**\n * Loads the given chunk, and returns a promise that resolves once the chunk\n * has been loaded.\n */\n async function doLoadChunk(chunkPath: ChunkPath, source: SourceInfo) {\n const resolver = getOrCreateResolver(chunkPath);\n if (resolver.resolved) {\n return resolver.promise;\n }\n\n if (source.type === SourceType.Runtime) {\n // We don't need to load chunks references from runtime code, as they're already\n // present in the DOM.\n\n if (chunkPath.endsWith(\".css\")) {\n // CSS chunks do not register themselves, and as such must be marked as\n // loaded instantly.\n resolver.resolve();\n }\n\n // We need to wait for JS chunks to register themselves within `registerChunk`\n // before we can start instantiating runtime modules, hence the absence of\n // `resolver.resolve()` in this branch.\n\n return resolver.promise;\n }\n\n const chunkUrl = `/${getChunkRelativeUrl(chunkPath)}`;\n\n if (chunkPath.endsWith(\".css\")) {\n const link = document.createElement(\"link\");\n link.rel = \"stylesheet\";\n link.href = chunkUrl;\n link.onerror = () => {\n resolver.reject();\n };\n link.onload = () => {\n // CSS chunks do not register themselves, and as such must be marked as\n // loaded instantly.\n resolver.resolve();\n };\n document.body.appendChild(link);\n } else if (chunkPath.endsWith(\".js\")) {\n const script = document.createElement(\"script\");\n script.src = chunkUrl;\n // We'll only mark the chunk as loaded once the script has been executed,\n // which happens in `registerChunk`. Hence the absence of `resolve()` in\n // this branch.\n script.onerror = () => {\n resolver.reject();\n };\n document.body.appendChild(script);\n } else {\n throw new Error(`can't infer type of chunk from path ${chunkPath}`);\n }\n\n return resolver.promise;\n }\n})();\n\nfunction _eval({ code, url, map }: EcmascriptModuleEntry): ModuleFactory {\n code += `\\n\\n//# sourceURL=${location.origin}/${url}`;\n if (map) code += `\\n//# sourceMappingURL=${map}`;\n return eval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Ae,aAAY,UAAoB,EAAE,OAAkB;QACjE,MAAM,YAAW,qBAAoB;QACrC,IAAI,UAAS,QAAQ,EAAE;YACrB,OAAO,UAAS,OAAO;QACzB;QAEA,IAAI,QAAO,IAAI,KAAK,WAAW,OAAO,EAAE;YAItC,IAAI,WAAU,QAAQ,CAAC,SAAS;gBAG9B,UAAS,OAAO;YAClB;YAMA,OAAO,UAAS,OAAO;QACzB;QAEA,MAAM,YAAW,CAAC,CAAC,EAAE,oBAAoB,YAAW,CAAC;QAErD,IAAI,WAAU,QAAQ,CAAC,SAAS;YAC9B,MAAM,QAAO,SAAS,aAAa,CAAC;YACpC,MAAK,GAAG,GAAG;YACX,MAAK,IAAI,GAAG;YACZ,MAAK,OAAO,GAAG;gBACb,UAAS,MAAM;YACjB;YACA,MAAK,MAAM,GAAG;gBAGZ,UAAS,OAAO;YAClB;YACA,SAAS,IAAI,CAAC,WAAW,CAAC;QAC5B,OAAO,IAAI,WAAU,QAAQ,CAAC,QAAQ;YACpC,MAAM,UAAS,SAAS,aAAa,CAAC;YACtC,QAAO,GAAG,GAAG;YAIb,QAAO,OAAO,GAAG;gBACf,UAAS,MAAM;YACjB;YACA,SAAS,IAAI,CAAC,WAAW,CAAC;QAC5B,OAAO;YACL,MAAM,IAAI,MAAM,CAAC,oCAAoC,EAAE,WAAU,CAAC;QACpE;QAEA,OAAO,UAAS,OAAO;IACzB;AACF,CAAA;AAEA,SAAS,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAyB;IACtD,QAAQ,CAAC,kBAAkB,EAAE,SAAS,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC;IACrD,IAAI,KAAK,QAAQ,CAAC,uBAAuB,EAAE,IAAI,CAAC;IAChD,OAAO,KAAK;AACd"}}, - {"offset": {"line": 1190, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}] + {"offset": {"line": 11, "column": 0}, "map": {"version":3,"sources":["/turbopack/[turbopack]/shared/runtime-utils.ts"],"sourcesContent":["/**\n * This file contains runtime types and functions that are shared between all\n * TurboPack ECMAScript runtimes.\n *\n * It will be prepended to the runtime code of each runtime.\n */\n\n/* eslint-disable @next/next/no-assign-module-variable */\n\n/// \n\ninterface Exports {\n __esModule?: boolean;\n\n [key: string]: any;\n}\n\ntype EsmNamespaceObject = Record;\n\nconst REEXPORTED_OBJECTS = Symbol(\"reexported objects\");\n\ninterface BaseModule {\n exports: Exports | Promise | AsyncModulePromise;\n error: Error | undefined;\n loaded: boolean;\n id: ModuleId;\n children: ModuleId[];\n parents: ModuleId[];\n namespaceObject?:\n | EsmNamespaceObject\n | Promise\n | AsyncModulePromise;\n [REEXPORTED_OBJECTS]?: any[];\n}\n\ninterface Module extends BaseModule {}\n\ntype RequireContextMap = Record;\n\ninterface RequireContextEntry {\n id: () => ModuleId;\n}\n\ninterface RequireContext {\n (moduleId: ModuleId): Exports | EsmNamespaceObject;\n\n keys(): ModuleId[];\n\n resolve(moduleId: ModuleId): ModuleId;\n}\n\ntype GetOrInstantiateModuleFromParent = (\n moduleId: ModuleId,\n parentModule: Module\n) => Module;\n\ntype CommonJsRequireContext = (\n entry: RequireContextEntry,\n parentModule: Module\n) => Exports;\n\nconst hasOwnProperty = Object.prototype.hasOwnProperty;\nconst toStringTag = typeof Symbol !== \"undefined\" && Symbol.toStringTag;\n\nfunction defineProp(\n obj: any,\n name: PropertyKey,\n options: PropertyDescriptor & ThisType\n) {\n if (!hasOwnProperty.call(obj, name))\n Object.defineProperty(obj, name, options);\n}\n\n/**\n * Adds the getters to the exports object.\n */\nfunction esm(exports: Exports, getters: Record any>) {\n defineProp(exports, \"__esModule\", { value: true });\n if (toStringTag) defineProp(exports, toStringTag, { value: \"Module\" });\n for (const key in getters) {\n defineProp(exports, key, { get: getters[key], enumerable: true });\n }\n}\n\n/**\n * Makes the module an ESM with exports\n */\nfunction esmExport(\n module: Module,\n exports: Exports,\n getters: Record any>\n) {\n module.namespaceObject = module.exports;\n esm(exports, getters);\n}\n\nfunction ensureDynamicExports(module: Module, exports: Exports) {\n let reexportedObjects = module[REEXPORTED_OBJECTS];\n\n if (!reexportedObjects) {\n reexportedObjects = module[REEXPORTED_OBJECTS] = [];\n module.exports = module.namespaceObject = new Proxy(exports, {\n get(target, prop) {\n if (\n hasOwnProperty.call(target, prop) ||\n prop === \"default\" ||\n prop === \"__esModule\"\n ) {\n return Reflect.get(target, prop);\n }\n for (const obj of reexportedObjects!) {\n const value = Reflect.get(obj, prop);\n if (value !== undefined) return value;\n }\n return undefined;\n },\n ownKeys(target) {\n const keys = Reflect.ownKeys(target);\n for (const obj of reexportedObjects!) {\n for (const key of Reflect.ownKeys(obj)) {\n if (key !== \"default\" && !keys.includes(key)) keys.push(key);\n }\n }\n return keys;\n },\n });\n }\n}\n\n/**\n * Dynamically exports properties from an object\n */\nfunction dynamicExport(\n module: Module,\n exports: Exports,\n object: Record\n) {\n ensureDynamicExports(module, exports);\n\n module[REEXPORTED_OBJECTS]!.push(object);\n}\n\nfunction exportValue(module: Module, value: any) {\n module.exports = value;\n}\n\nfunction exportNamespace(module: Module, namespace: any) {\n module.exports = module.namespaceObject = namespace;\n}\n\nfunction createGetter(obj: Record, key: string | symbol) {\n return () => obj[key];\n}\n\n/**\n * @returns prototype of the object\n */\nconst getProto: (obj: any) => any = Object.getPrototypeOf\n ? (obj) => Object.getPrototypeOf(obj)\n : (obj) => obj.__proto__;\n\n/** Prototypes that are not expanded for exports */\nconst LEAF_PROTOTYPES = [null, getProto({}), getProto([]), getProto(getProto)];\n\n/**\n * @param raw\n * @param ns\n * @param allowExportDefault\n * * `false`: will have the raw module as default export\n * * `true`: will have the default property as default export\n */\nfunction interopEsm(\n raw: Exports,\n ns: EsmNamespaceObject,\n allowExportDefault?: boolean\n) {\n const getters: { [s: string]: () => any } = Object.create(null);\n for (\n let current = raw;\n (typeof current === \"object\" || typeof current === \"function\") &&\n !LEAF_PROTOTYPES.includes(current);\n current = getProto(current)\n ) {\n for (const key of Object.getOwnPropertyNames(current)) {\n getters[key] = createGetter(raw, key);\n }\n }\n\n // this is not really correct\n // we should set the `default` getter if the imported module is a `.cjs file`\n if (!(allowExportDefault && \"default\" in getters)) {\n getters[\"default\"] = () => raw;\n }\n\n esm(ns, getters);\n return ns;\n}\n\nfunction esmImport(\n sourceModule: Module,\n id: ModuleId\n): Exclude {\n const module = getOrInstantiateModuleFromParent(id, sourceModule);\n if (module.error) throw module.error;\n\n // any ES module has to have `module.namespaceObject` defined.\n if (module.namespaceObject) return module.namespaceObject;\n\n // only ESM can be an async module, so we don't need to worry about exports being a promise here.\n const raw = module.exports;\n return (module.namespaceObject = interopEsm(\n raw,\n {},\n (raw as any).__esModule\n ));\n}\n\nfunction commonJsRequire(sourceModule: Module, id: ModuleId): Exports {\n const module = getOrInstantiateModuleFromParent(id, sourceModule);\n if (module.error) throw module.error;\n return module.exports;\n}\n\ntype RequireContextFactory = (map: RequireContextMap) => RequireContext;\n\nfunction requireContext(\n sourceModule: Module,\n map: RequireContextMap\n): RequireContext {\n function requireContext(id: ModuleId): Exports {\n const entry = map[id];\n\n if (!entry) {\n throw new Error(\n `module ${id} is required from a require.context, but is not in the context`\n );\n }\n\n return commonJsRequireContext(entry, sourceModule);\n }\n\n requireContext.keys = (): ModuleId[] => {\n return Object.keys(map);\n };\n\n requireContext.resolve = (id: ModuleId): ModuleId => {\n const entry = map[id];\n\n if (!entry) {\n throw new Error(\n `module ${id} is resolved from a require.context, but is not in the context`\n );\n }\n\n return entry.id();\n };\n\n return requireContext;\n}\n\n/**\n * Returns the path of a chunk defined by its data.\n */\nfunction getChunkPath(chunkData: ChunkData): ChunkPath {\n return typeof chunkData === \"string\" ? chunkData : chunkData.path;\n}\n\nfunction isPromise(maybePromise: any): maybePromise is Promise {\n return (\n maybePromise != null &&\n typeof maybePromise === \"object\" &&\n \"then\" in maybePromise &&\n typeof maybePromise.then === \"function\"\n );\n}\n\nfunction isAsyncModuleExt(obj: T): obj is AsyncModuleExt & T {\n return turbopackQueues in obj;\n}\n\nfunction createPromise() {\n let resolve: (value: T | PromiseLike) => void;\n let reject: (reason?: any) => void;\n\n const promise = new Promise((res, rej) => {\n reject = rej;\n resolve = res;\n });\n\n return {\n promise,\n resolve: resolve!,\n reject: reject!,\n };\n}\n\n// everything below is adapted from webpack\n// https://github.com/webpack/webpack/blob/6be4065ade1e252c1d8dcba4af0f43e32af1bdc1/lib/runtime/AsyncModuleRuntimeModule.js#L13\n\nconst turbopackQueues = Symbol(\"turbopack queues\");\nconst turbopackExports = Symbol(\"turbopack exports\");\nconst turbopackError = Symbol(\"turbopack error\");\n\ntype AsyncQueueFn = (() => void) & { queueCount: number };\ntype AsyncQueue = AsyncQueueFn[] & { resolved: boolean };\n\nfunction resolveQueue(queue?: AsyncQueue) {\n if (queue && !queue.resolved) {\n queue.resolved = true;\n queue.forEach((fn) => fn.queueCount--);\n queue.forEach((fn) => (fn.queueCount-- ? fn.queueCount++ : fn()));\n }\n}\n\ntype Dep = Exports | AsyncModulePromise | Promise;\n\ntype AsyncModuleExt = {\n [turbopackQueues]: (fn: (queue: AsyncQueue) => void) => void;\n [turbopackExports]: Exports;\n [turbopackError]?: any;\n};\n\ntype AsyncModulePromise = Promise & AsyncModuleExt;\n\nfunction wrapDeps(deps: Dep[]): AsyncModuleExt[] {\n return deps.map((dep) => {\n if (dep !== null && typeof dep === \"object\") {\n if (isAsyncModuleExt(dep)) return dep;\n if (isPromise(dep)) {\n const queue: AsyncQueue = Object.assign([], { resolved: false });\n\n const obj: AsyncModuleExt = {\n [turbopackExports]: {},\n [turbopackQueues]: (fn: (queue: AsyncQueue) => void) => fn(queue),\n };\n\n dep.then(\n (res) => {\n obj[turbopackExports] = res;\n resolveQueue(queue);\n },\n (err) => {\n obj[turbopackError] = err;\n resolveQueue(queue);\n }\n );\n\n return obj;\n }\n }\n\n const ret: AsyncModuleExt = {\n [turbopackExports]: dep,\n [turbopackQueues]: () => {},\n };\n\n return ret;\n });\n}\n\nfunction asyncModule(\n module: Module,\n body: (\n handleAsyncDependencies: (\n deps: Dep[]\n ) => Exports[] | Promise<() => Exports[]>,\n asyncResult: (err?: any) => void\n ) => void,\n hasAwait: boolean\n) {\n const queue: AsyncQueue | undefined = hasAwait\n ? Object.assign([], { resolved: true })\n : undefined;\n\n const depQueues: Set = new Set();\n\n ensureDynamicExports(module, module.exports);\n const exports = module.exports;\n\n const { resolve, reject, promise: rawPromise } = createPromise();\n\n const promise: AsyncModulePromise = Object.assign(rawPromise, {\n [turbopackExports]: exports,\n [turbopackQueues]: (fn) => {\n queue && fn(queue);\n depQueues.forEach(fn);\n promise[\"catch\"](() => {});\n },\n } satisfies AsyncModuleExt);\n\n module.exports = module.namespaceObject = promise;\n\n function handleAsyncDependencies(deps: Dep[]) {\n const currentDeps = wrapDeps(deps);\n\n const getResult = () =>\n currentDeps.map((d) => {\n if (d[turbopackError]) throw d[turbopackError];\n return d[turbopackExports];\n });\n\n const { promise, resolve } = createPromise<() => Exports[]>();\n\n const fn: AsyncQueueFn = Object.assign(() => resolve(getResult), {\n queueCount: 0,\n });\n\n function fnQueue(q: AsyncQueue) {\n if (q !== queue && !depQueues.has(q)) {\n depQueues.add(q);\n if (q && !q.resolved) {\n fn.queueCount++;\n q.push(fn);\n }\n }\n }\n\n currentDeps.map((dep) => dep[turbopackQueues](fnQueue));\n\n return fn.queueCount ? promise : getResult();\n }\n\n function asyncResult(err?: any) {\n if (err) {\n reject((promise[turbopackError] = err));\n } else {\n resolve(exports);\n }\n\n resolveQueue(queue);\n }\n\n body(handleAsyncDependencies, asyncResult);\n\n if (queue) {\n queue.resolved = false;\n }\n}\n"],"names":[],"mappings":";AAmBA,MAAM,qBAAqB,OAAO;;;;;AA0ClC,MAAM,iBAAiB,OAAO,SAAS,CAAC,cAAc;AACtD,MAAM,cAAc,OAAO,WAAW,eAAe,OAAO,WAAW;AAEvE,SAAS,WACP,GAAQ,EACR,IAAiB,EACjB,OAA2C;IAE3C,IAAI,CAAC,eAAe,IAAI,CAAC,KAAK,OAC5B,OAAO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AAS,wBAAwB,IAAW;QAC1C,MAAM,cAAc,SAAS;QAE7B,MAAM,YAAY,IAChB,YAAY,GAAG,CAAC,CAAC;gBACf,IAAI,CAAC,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC,eAAe;gBAC9C,OAAO,CAAC,CAAC,iBAAiB;YAC5B;QAEF,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG;QAE7B,MAAM,KAAmB,OAAO,MAAM,CAAC,IAAM,QAAQ,YAAY;YAC/D,YAAY;QACd;QAEA,SAAS,QAAQ,CAAa;YAC5B,IAAI,MAAM,SAAS,CAAC,UAAU,GAAG,CAAC,IAAI;gBACpC,UAAU,GAAG,CAAC;gBACd,IAAI,KAAK,CAAC,EAAE,QAAQ,EAAE;oBACpB,GAAG,UAAU;oBACb,EAAE,IAAI,CAAC;gBACT;YACF;QACF;QAEA,YAAY,GAAG,CAAC,CAAC,MAAQ,GAAG,CAAC,gBAAgB,CAAC;QAE9C,OAAO,GAAG,UAAU,GAAG,UAAU;IACnC;IAEA,SAAS,YAAY,GAAS;QAC5B,IAAI,KAAK;YACP,OAAQ,OAAO,CAAC,eAAe,GAAG;QACpC,OAAO;YACL,QAAQ;QACV;QAEA,aAAa;IACf;IAEA,KAAK,yBAAyB;IAE9B,IAAI,OAAO;QACT,MAAM,QAAQ,GAAG;IACnB;AACF"}}, + {"offset": {"line": 245, "column": 0}, "map": {"version":3,"sources":["/turbopack/[turbopack]/dev/runtime/base/runtime-base.ts"],"sourcesContent":["/**\n * This file contains runtime types and functions that are shared between all\n * Turbopack *development* ECMAScript runtimes.\n *\n * It will be appended to the runtime code of each runtime right after the\n * shared runtime utils.\n */\n\n/* eslint-disable @next/next/no-assign-module-variable */\n\n/// \n/// \n/// \n/// \n\n// This file must not use `import` and `export` statements. Otherwise, it\n// becomes impossible to augment interfaces declared in ``d files\n// (e.g. `Module`). Hence, the need for `import()` here.\ntype RefreshRuntimeGlobals =\n import(\"@next/react-refresh-utils/dist/runtime\").RefreshRuntimeGlobals;\n\ndeclare var CHUNK_BASE_PATH: string;\ndeclare var $RefreshHelpers$: RefreshRuntimeGlobals[\"$RefreshHelpers$\"];\ndeclare var $RefreshReg$: RefreshRuntimeGlobals[\"$RefreshReg$\"];\ndeclare var $RefreshSig$: RefreshRuntimeGlobals[\"$RefreshSig$\"];\ndeclare var $RefreshInterceptModuleExecution$:\n | RefreshRuntimeGlobals[\"$RefreshInterceptModuleExecution$\"];\n\ntype RefreshContext = {\n register: RefreshRuntimeGlobals[\"$RefreshReg$\"];\n signature: RefreshRuntimeGlobals[\"$RefreshSig$\"];\n};\n\ntype RefreshHelpers = RefreshRuntimeGlobals[\"$RefreshHelpers$\"];\n\ninterface TurbopackDevBaseContext extends TurbopackBaseContext {\n k: RefreshContext;\n}\n\ninterface TurbopackDevContext extends TurbopackDevBaseContext {}\n\n// string encoding of a module factory (used in hmr updates)\ntype ModuleFactoryString = string;\n\ntype ModuleFactory = (\n this: Module[\"exports\"],\n context: TurbopackDevContext\n) => undefined;\n\ntype DevRuntimeParams = {\n otherChunks: ChunkData[];\n runtimeModuleIds: ModuleId[];\n};\n\ntype ChunkRegistration = [\n chunkPath: ChunkPath,\n chunkModules: ModuleFactories,\n params: DevRuntimeParams | undefined\n];\ntype ChunkList = {\n path: ChunkPath;\n chunks: ChunkData[];\n source: \"entry\" | \"dynamic\";\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 * The module was instantiated because it was included in a chunk's hot module\n * update.\n */\n Update = 2,\n}\n\ntype SourceInfo =\n | {\n type: SourceType.Runtime;\n chunkPath: ChunkPath;\n }\n | {\n type: SourceType.Parent;\n parentId: ModuleId;\n }\n | {\n type: SourceType.Update;\n parents?: ModuleId[];\n };\n\ninterface RuntimeBackend {\n registerChunk: (chunkPath: ChunkPath, params?: DevRuntimeParams) => void;\n loadChunk: (chunkPath: ChunkPath, source: SourceInfo) => Promise;\n reloadChunk?: (chunkPath: ChunkPath) => Promise;\n unloadChunk?: (chunkPath: ChunkPath) => void;\n\n restart: () => void;\n}\n\nconst moduleFactories: ModuleFactories = Object.create(null);\nconst moduleCache: ModuleCache = Object.create(null);\n/**\n * Maps module IDs to persisted data between executions of their hot module\n * implementation (`hot.data`).\n */\nconst moduleHotData: Map = new Map();\n/**\n * Maps module instances to their hot module state.\n */\nconst moduleHotState: Map = new Map();\n/**\n * Modules that call `module.hot.invalidate()` (while being updated).\n */\nconst queuedInvalidatedModules: Set = new Set();\n/**\n * Module IDs that are instantiated as part of the runtime of a chunk.\n */\nconst runtimeModules: Set = new Set();\n/**\n * Map from module ID to the chunks that contain this module.\n *\n * In HMR, we need to keep track of which modules are contained in which so\n * chunks. This is so we don't eagerly dispose of a module when it is removed\n * from chunk A, but still exists in chunk B.\n */\nconst moduleChunksMap: Map> = new Map();\n/**\n * Map from a chunk path to all modules it contains.\n */\nconst chunkModulesMap: Map> = new Map();\n/**\n * Chunk lists that contain a runtime. When these chunk lists receive an update\n * that can't be reconciled with the current state of the page, we need to\n * reload the runtime entirely.\n */\nconst runtimeChunkLists: Set = new Set();\n/**\n * Map from a chunk list to the chunk paths it contains.\n */\nconst chunkListChunksMap: Map> = new Map();\n/**\n * Map from a chunk path to the chunk lists it belongs to.\n */\nconst chunkChunkListsMap: Map> = new Map();\n\nconst availableModules: Map | true> = new Map();\n\nconst availableModuleChunks: Map | true> = new Map();\n\nasync function loadChunk(\n source: SourceInfo,\n chunkData: ChunkData\n): Promise {\n if (typeof chunkData === \"string\") {\n return loadChunkPath(source, chunkData);\n }\n\n const includedList = chunkData.included || [];\n const modulesPromises = includedList.map((included) => {\n if (moduleFactories[included]) return true;\n return availableModules.get(included);\n });\n if (modulesPromises.length > 0 && modulesPromises.every((p) => p)) {\n // When all included items are already loaded or loading, we can skip loading ourselves\n return Promise.all(modulesPromises);\n }\n\n const includedModuleChunksList = chunkData.moduleChunks || [];\n const moduleChunksPromises = includedModuleChunksList\n .map((included) => {\n // TODO(alexkirsz) Do we need this check?\n // if (moduleFactories[included]) return true;\n return availableModuleChunks.get(included);\n })\n .filter((p) => p);\n\n let promise;\n if (moduleChunksPromises.length > 0) {\n // Some module chunks are already loaded or loading.\n\n if (moduleChunksPromises.length == includedModuleChunksList.length) {\n // When all included module chunks are already loaded or loading, we can skip loading ourselves\n return Promise.all(moduleChunksPromises);\n }\n\n const moduleChunksToLoad: Set = new Set();\n for (const moduleChunk of includedModuleChunksList) {\n if (!availableModuleChunks.has(moduleChunk)) {\n moduleChunksToLoad.add(moduleChunk);\n }\n }\n\n for (const moduleChunkToLoad of moduleChunksToLoad) {\n const promise = loadChunkPath(source, moduleChunkToLoad);\n\n availableModuleChunks.set(moduleChunkToLoad, promise);\n\n moduleChunksPromises.push(promise);\n }\n\n promise = Promise.all(moduleChunksPromises);\n } else {\n promise = loadChunkPath(source, chunkData.path);\n\n // Mark all included module chunks as loading if they are not already loaded or loading.\n for (const includedModuleChunk of includedModuleChunksList) {\n if (!availableModuleChunks.has(includedModuleChunk)) {\n availableModuleChunks.set(includedModuleChunk, promise);\n }\n }\n }\n\n for (const included of includedList) {\n if (!availableModules.has(included)) {\n // It might be better to race old and new promises, but it's rare that the new promise will be faster than a request started earlier.\n // In production it's even more rare, because the chunk optimization tries to deduplicate modules anyway.\n availableModules.set(included, promise);\n }\n }\n\n return promise;\n}\n\nasync function loadChunkPath(\n source: SourceInfo,\n chunkPath: ChunkPath\n): Promise {\n try {\n await BACKEND.loadChunk(chunkPath, source);\n } catch (error) {\n let loadReason;\n switch (source.type) {\n case SourceType.Runtime:\n loadReason = `as a runtime dependency of chunk ${source.chunkPath}`;\n break;\n case SourceType.Parent:\n loadReason = `from module ${source.parentId}`;\n break;\n case SourceType.Update:\n loadReason = \"from an HMR update\";\n break;\n }\n throw new Error(\n `Failed to load chunk ${chunkPath} ${loadReason}${\n error ? `: ${error}` : \"\"\n }`,\n error\n ? {\n cause: error,\n }\n : undefined\n );\n }\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 case SourceType.Update:\n instantiationReason = \"because of an HMR update\";\n break;\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 hotData = moduleHotData.get(id)!;\n const { hot, hotState } = createModuleHot(id, hotData);\n\n let parents: ModuleId[];\n switch (source.type) {\n case SourceType.Runtime:\n runtimeModules.add(id);\n parents = [];\n break;\n case SourceType.Parent:\n // No need to add this module as a child of the parent module here, this\n // has already been taken care of in `getOrInstantiateModuleFromParent`.\n parents = [source.parentId];\n break;\n case SourceType.Update:\n parents = source.parents || [];\n break;\n }\n const module: Module = {\n exports: {},\n error: undefined,\n loaded: false,\n id,\n parents,\n children: [],\n namespaceObject: undefined,\n hot,\n };\n\n moduleCache[id] = module;\n moduleHotState.set(module, hotState);\n\n // NOTE(alexkirsz) This can fail when the module encounters a runtime error.\n try {\n runModuleExecutionHooks(module, (refresh) => {\n moduleFactory.call(\n module.exports,\n augmentContext({\n a: asyncModule.bind(null, module),\n e: module.exports,\n r: commonJsRequire.bind(null, module),\n f: requireContext.bind(null, module),\n i: esmImport.bind(null, module),\n s: esmExport.bind(null, module, module.exports),\n j: dynamicExport.bind(null, module, module.exports),\n v: exportValue.bind(null, module),\n n: exportNamespace.bind(null, module),\n m: module,\n c: moduleCache,\n l: loadChunk.bind(null, { type: SourceType.Parent, parentId: id }),\n g: globalThis,\n k: refresh,\n __dirname: module.id.replace(/(^|\\/)\\/+$/, \"\"),\n })\n );\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 * NOTE(alexkirsz) Webpack has a \"module execution\" interception hook that\n * Next.js' React Refresh runtime hooks into to add module context to the\n * refresh registry.\n */\nfunction runModuleExecutionHooks(\n module: Module,\n executeModule: (ctx: RefreshContext) => void\n) {\n const cleanupReactRefreshIntercept =\n typeof globalThis.$RefreshInterceptModuleExecution$ === \"function\"\n ? globalThis.$RefreshInterceptModuleExecution$(module.id)\n : () => {};\n\n try {\n executeModule({\n register: globalThis.$RefreshReg$,\n signature: globalThis.$RefreshSig$,\n });\n\n if (\"$RefreshHelpers$\" in globalThis) {\n // This pattern can also be used to register the exports of\n // a module with the React Refresh runtime.\n registerExportsAndSetupBoundaryForReactRefresh(\n module,\n globalThis.$RefreshHelpers$\n );\n }\n } catch (e) {\n throw e;\n } finally {\n // Always cleanup the intercept, even if module execution failed.\n cleanupReactRefreshIntercept();\n }\n}\n\n/**\n * Retrieves a module from the cache, or instantiate it if it is not cached.\n */\nconst getOrInstantiateModuleFromParent: GetOrInstantiateModuleFromParent = (\n id,\n sourceModule\n) => {\n if (!sourceModule.hot.active) {\n console.warn(\n `Unexpected import of module ${id} from module ${sourceModule.id}, which was deleted by an HMR update`\n );\n }\n\n const module = moduleCache[id];\n\n if (sourceModule.children.indexOf(id) === -1) {\n sourceModule.children.push(id);\n }\n\n if (module) {\n if (module.parents.indexOf(sourceModule.id) === -1) {\n module.parents.push(sourceModule.id);\n }\n\n return module;\n }\n\n return instantiateModule(id, {\n type: SourceType.Parent,\n parentId: sourceModule.id,\n });\n};\n\n/**\n * This is adapted from https://github.com/vercel/next.js/blob/3466862d9dc9c8bb3131712134d38757b918d1c0/packages/react-refresh-utils/internal/ReactRefreshModule.runtime.ts\n */\nfunction registerExportsAndSetupBoundaryForReactRefresh(\n module: Module,\n helpers: RefreshHelpers\n) {\n const currentExports = module.exports;\n const prevExports = module.hot.data.prevExports ?? null;\n\n helpers.registerExportsForReactRefresh(currentExports, module.id);\n\n // A module can be accepted automatically based on its exports, e.g. when\n // it is a Refresh Boundary.\n if (helpers.isReactRefreshBoundary(currentExports)) {\n // Save the previous exports on update, so we can compare the boundary\n // signatures.\n module.hot.dispose((data) => {\n data.prevExports = currentExports;\n });\n // Unconditionally accept an update to this module, we'll check if it's\n // still a Refresh Boundary later.\n module.hot.accept();\n\n // This field is set when the previous version of this module was a\n // Refresh Boundary, letting us know we need to check for invalidation or\n // enqueue an update.\n if (prevExports !== null) {\n // A boundary can become ineligible if its exports are incompatible\n // with the previous exports.\n //\n // For example, if you add/remove/change exports, we'll want to\n // re-execute the importing modules, and force those components to\n // re-render. Similarly, if you convert a class component to a\n // function, we want to invalidate the boundary.\n if (\n helpers.shouldInvalidateReactRefreshBoundary(\n prevExports,\n currentExports\n )\n ) {\n module.hot.invalidate();\n } else {\n helpers.scheduleUpdate();\n }\n }\n } else {\n // Since we just executed the code for the module, it's possible that the\n // new exports made it ineligible for being a boundary.\n // We only care about the case when we were _previously_ a boundary,\n // because we already accepted this update (accidental side effect).\n const isNoLongerABoundary = prevExports !== null;\n if (isNoLongerABoundary) {\n module.hot.invalidate();\n }\n }\n}\n\nfunction formatDependencyChain(dependencyChain: ModuleId[]): string {\n return `Dependency chain: ${dependencyChain.join(\" -> \")}`;\n}\n\nfunction computeOutdatedModules(\n added: Map,\n modified: Map\n): {\n outdatedModules: Set;\n newModuleFactories: Map;\n} {\n const newModuleFactories = new Map();\n\n for (const [moduleId, entry] of added) {\n if (entry != null) {\n newModuleFactories.set(moduleId, _eval(entry));\n }\n }\n\n const outdatedModules = computedInvalidatedModules(modified.keys());\n\n for (const [moduleId, entry] of modified) {\n newModuleFactories.set(moduleId, _eval(entry));\n }\n\n return { outdatedModules, newModuleFactories };\n}\n\nfunction computedInvalidatedModules(\n invalidated: Iterable\n): Set {\n const outdatedModules = new Set();\n\n for (const moduleId of invalidated) {\n const effect = getAffectedModuleEffects(moduleId);\n\n switch (effect.type) {\n case \"unaccepted\":\n throw new Error(\n `cannot apply update: unaccepted module. ${formatDependencyChain(\n effect.dependencyChain\n )}.`\n );\n case \"self-declined\":\n throw new Error(\n `cannot apply update: self-declined module. ${formatDependencyChain(\n effect.dependencyChain\n )}.`\n );\n case \"accepted\":\n for (const outdatedModuleId of effect.outdatedModules) {\n outdatedModules.add(outdatedModuleId);\n }\n break;\n // TODO(alexkirsz) Dependencies: handle dependencies effects.\n }\n }\n\n return outdatedModules;\n}\n\nfunction computeOutdatedSelfAcceptedModules(\n outdatedModules: Iterable\n): { moduleId: ModuleId; errorHandler: true | Function }[] {\n const outdatedSelfAcceptedModules = [];\n for (const moduleId of outdatedModules) {\n const module = moduleCache[moduleId];\n const hotState = moduleHotState.get(module)!;\n if (module && hotState.selfAccepted && !hotState.selfInvalidated) {\n outdatedSelfAcceptedModules.push({\n moduleId,\n errorHandler: hotState.selfAccepted,\n });\n }\n }\n return outdatedSelfAcceptedModules;\n}\n\n/**\n * Adds, deletes, and moves modules between chunks. This must happen before the\n * dispose phase as it needs to know which modules were removed from all chunks,\n * which we can only compute *after* taking care of added and moved modules.\n */\nfunction updateChunksPhase(\n chunksAddedModules: Map>,\n chunksDeletedModules: Map>\n): { disposedModules: Set } {\n for (const [chunkPath, addedModuleIds] of chunksAddedModules) {\n for (const moduleId of addedModuleIds) {\n addModuleToChunk(moduleId, chunkPath);\n }\n }\n\n const disposedModules: Set = new Set();\n for (const [chunkPath, addedModuleIds] of chunksDeletedModules) {\n for (const moduleId of addedModuleIds) {\n if (removeModuleFromChunk(moduleId, chunkPath)) {\n disposedModules.add(moduleId);\n }\n }\n }\n\n return { disposedModules };\n}\n\nfunction disposePhase(\n outdatedModules: Iterable,\n disposedModules: Iterable\n): { outdatedModuleParents: Map> } {\n for (const moduleId of outdatedModules) {\n disposeModule(moduleId, \"replace\");\n }\n\n for (const moduleId of disposedModules) {\n disposeModule(moduleId, \"clear\");\n }\n\n // Removing modules from the module cache is a separate step.\n // We also want to keep track of previous parents of the outdated modules.\n const outdatedModuleParents = new Map();\n for (const moduleId of outdatedModules) {\n const oldModule = moduleCache[moduleId];\n outdatedModuleParents.set(moduleId, oldModule?.parents);\n delete moduleCache[moduleId];\n }\n\n // TODO(alexkirsz) Dependencies: remove outdated dependency from module\n // children.\n\n return { outdatedModuleParents };\n}\n\n/**\n * Disposes of an instance of a module.\n *\n * Returns the persistent hot data that should be kept for the next module\n * instance.\n *\n * NOTE: mode = \"replace\" will not remove modules from the moduleCache.\n * This must be done in a separate step afterwards.\n * This is important because all modules need to be disposed to update the\n * parent/child relationships before they are actually removed from the moduleCache.\n * If this was done in this method, the following disposeModule calls won't find\n * the module from the module id in the cache.\n */\nfunction disposeModule(moduleId: ModuleId, mode: \"clear\" | \"replace\") {\n const module = moduleCache[moduleId];\n if (!module) {\n return;\n }\n\n const hotState = moduleHotState.get(module)!;\n const data = {};\n\n // Run the `hot.dispose` handler, if any, passing in the persistent\n // `hot.data` object.\n for (const disposeHandler of hotState.disposeHandlers) {\n disposeHandler(data);\n }\n\n // This used to warn in `getOrInstantiateModuleFromParent` when a disposed\n // module is still importing other modules.\n module.hot.active = false;\n\n moduleHotState.delete(module);\n\n // TODO(alexkirsz) Dependencies: delete the module from outdated deps.\n\n // Remove the disposed module from its children's parent list.\n // It will be added back once the module re-instantiates and imports its\n // children again.\n for (const childId of module.children) {\n const child = moduleCache[childId];\n if (!child) {\n continue;\n }\n\n const idx = child.parents.indexOf(module.id);\n if (idx >= 0) {\n child.parents.splice(idx, 1);\n }\n }\n\n switch (mode) {\n case \"clear\":\n delete moduleCache[module.id];\n moduleHotData.delete(module.id);\n break;\n case \"replace\":\n moduleHotData.set(module.id, data);\n break;\n default:\n invariant(mode, (mode) => `invalid mode: ${mode}`);\n }\n}\n\nfunction applyPhase(\n outdatedSelfAcceptedModules: {\n moduleId: ModuleId;\n errorHandler: true | Function;\n }[],\n newModuleFactories: Map,\n outdatedModuleParents: Map>,\n reportError: (err: any) => void\n) {\n // Update module factories.\n for (const [moduleId, factory] of newModuleFactories.entries()) {\n moduleFactories[moduleId] = factory;\n }\n\n // TODO(alexkirsz) Run new runtime entries here.\n\n // TODO(alexkirsz) Dependencies: call accept handlers for outdated deps.\n\n // Re-instantiate all outdated self-accepted modules.\n for (const { moduleId, errorHandler } of outdatedSelfAcceptedModules) {\n try {\n instantiateModule(moduleId, {\n type: SourceType.Update,\n parents: outdatedModuleParents.get(moduleId),\n });\n } catch (err) {\n if (typeof errorHandler === \"function\") {\n try {\n errorHandler(err, { moduleId, module: moduleCache[moduleId] });\n } catch (err2) {\n reportError(err2);\n reportError(err);\n }\n } else {\n reportError(err);\n }\n }\n }\n}\n\n/**\n * Utility function to ensure all variants of an enum are handled.\n */\nfunction invariant(never: never, computeMessage: (arg: any) => string): never {\n throw new Error(`Invariant: ${computeMessage(never)}`);\n}\n\nfunction applyUpdate(chunkListPath: ChunkPath, update: PartialUpdate) {\n switch (update.type) {\n case \"ChunkListUpdate\":\n applyChunkListUpdate(chunkListPath, update);\n break;\n default:\n invariant(update, (update) => `Unknown update type: ${update.type}`);\n }\n}\n\nfunction applyChunkListUpdate(\n chunkListPath: ChunkPath,\n update: ChunkListUpdate\n) {\n if (update.merged != null) {\n for (const merged of update.merged) {\n switch (merged.type) {\n case \"EcmascriptMergedUpdate\":\n applyEcmascriptMergedUpdate(chunkListPath, merged);\n break;\n default:\n invariant(merged, (merged) => `Unknown merged type: ${merged.type}`);\n }\n }\n }\n\n if (update.chunks != null) {\n for (const [chunkPath, chunkUpdate] of Object.entries(update.chunks)) {\n switch (chunkUpdate.type) {\n case \"added\":\n BACKEND.loadChunk(chunkPath, { type: SourceType.Update });\n break;\n case \"total\":\n BACKEND.reloadChunk?.(chunkPath);\n break;\n case \"deleted\":\n BACKEND.unloadChunk?.(chunkPath);\n break;\n case \"partial\":\n invariant(\n chunkUpdate.instruction,\n (instruction) =>\n `Unknown partial instruction: ${JSON.stringify(instruction)}.`\n );\n default:\n invariant(\n chunkUpdate,\n (chunkUpdate) => `Unknown chunk update type: ${chunkUpdate.type}`\n );\n }\n }\n }\n}\n\nfunction applyEcmascriptMergedUpdate(\n chunkPath: ChunkPath,\n update: EcmascriptMergedUpdate\n) {\n const { entries = {}, chunks = {} } = update;\n const { added, modified, chunksAdded, chunksDeleted } = computeChangedModules(\n entries,\n chunks\n );\n const { outdatedModules, newModuleFactories } = computeOutdatedModules(\n added,\n modified\n );\n const { disposedModules } = updateChunksPhase(chunksAdded, chunksDeleted);\n\n applyInternal(outdatedModules, disposedModules, newModuleFactories);\n}\n\nfunction applyInvalidatedModules(outdatedModules: Set) {\n if (queuedInvalidatedModules.size > 0) {\n computedInvalidatedModules(queuedInvalidatedModules).forEach((moduleId) => {\n outdatedModules.add(moduleId);\n });\n\n queuedInvalidatedModules.clear();\n }\n\n return outdatedModules;\n}\n\nfunction applyInternal(\n outdatedModules: Set,\n disposedModules: Iterable,\n newModuleFactories: Map\n) {\n outdatedModules = applyInvalidatedModules(outdatedModules);\n\n const outdatedSelfAcceptedModules =\n computeOutdatedSelfAcceptedModules(outdatedModules);\n\n const { outdatedModuleParents } = disposePhase(\n outdatedModules,\n disposedModules\n );\n\n // we want to continue on error and only throw the error after we tried applying all updates\n let error: any;\n function reportError(err: any) {\n if (!error) error = err;\n }\n\n applyPhase(\n outdatedSelfAcceptedModules,\n newModuleFactories,\n outdatedModuleParents,\n reportError\n );\n\n if (error) {\n throw error;\n }\n\n if (queuedInvalidatedModules.size > 0) {\n applyInternal(new Set(), [], new Map());\n }\n}\n\nfunction computeChangedModules(\n entries: Record,\n updates: Record\n): {\n added: Map;\n modified: Map;\n deleted: Set;\n chunksAdded: Map>;\n chunksDeleted: Map>;\n} {\n const chunksAdded = new Map();\n const chunksDeleted = new Map();\n const added: Map = new Map();\n const modified = new Map();\n const deleted: Set = new Set();\n\n for (const [chunkPath, mergedChunkUpdate] of Object.entries(updates)) {\n switch (mergedChunkUpdate.type) {\n case \"added\": {\n const updateAdded = new Set(mergedChunkUpdate.modules);\n for (const moduleId of updateAdded) {\n added.set(moduleId, entries[moduleId]);\n }\n chunksAdded.set(chunkPath, updateAdded);\n break;\n }\n case \"deleted\": {\n // We could also use `mergedChunkUpdate.modules` here.\n const updateDeleted = new Set(chunkModulesMap.get(chunkPath));\n for (const moduleId of updateDeleted) {\n deleted.add(moduleId);\n }\n chunksDeleted.set(chunkPath, updateDeleted);\n break;\n }\n case \"partial\": {\n const updateAdded = new Set(mergedChunkUpdate.added);\n const updateDeleted = new Set(mergedChunkUpdate.deleted);\n for (const moduleId of updateAdded) {\n added.set(moduleId, entries[moduleId]);\n }\n for (const moduleId of updateDeleted) {\n deleted.add(moduleId);\n }\n chunksAdded.set(chunkPath, updateAdded);\n chunksDeleted.set(chunkPath, updateDeleted);\n break;\n }\n default:\n invariant(\n mergedChunkUpdate,\n (mergedChunkUpdate) =>\n `Unknown merged chunk update type: ${mergedChunkUpdate.type}`\n );\n }\n }\n\n // If a module was added from one chunk and deleted from another in the same update,\n // consider it to be modified, as it means the module was moved from one chunk to another\n // AND has new code in a single update.\n for (const moduleId of added.keys()) {\n if (deleted.has(moduleId)) {\n added.delete(moduleId);\n deleted.delete(moduleId);\n }\n }\n\n for (const [moduleId, entry] of Object.entries(entries)) {\n // Modules that haven't been added to any chunk but have new code are considered\n // to be modified.\n // This needs to be under the previous loop, as we need it to get rid of modules\n // that were added and deleted in the same update.\n if (!added.has(moduleId)) {\n modified.set(moduleId, entry);\n }\n }\n\n return { added, deleted, modified, chunksAdded, chunksDeleted };\n}\n\ntype ModuleEffect =\n | {\n type: \"unaccepted\";\n dependencyChain: ModuleId[];\n }\n | {\n type: \"self-declined\";\n dependencyChain: ModuleId[];\n moduleId: ModuleId;\n }\n | {\n type: \"accepted\";\n moduleId: ModuleId;\n outdatedModules: Set;\n };\n\nfunction getAffectedModuleEffects(moduleId: ModuleId): ModuleEffect {\n const outdatedModules: Set = new Set();\n\n type QueueItem = { moduleId?: ModuleId; dependencyChain: ModuleId[] };\n\n const queue: QueueItem[] = [\n {\n moduleId,\n dependencyChain: [],\n },\n ];\n\n let nextItem;\n while ((nextItem = queue.shift())) {\n const { moduleId, dependencyChain } = nextItem;\n\n if (moduleId != null) {\n outdatedModules.add(moduleId);\n }\n\n // We've arrived at the runtime of the chunk, which means that nothing\n // else above can accept this update.\n if (moduleId === undefined) {\n return {\n type: \"unaccepted\",\n dependencyChain,\n };\n }\n\n const module = moduleCache[moduleId];\n const hotState = moduleHotState.get(module)!;\n\n if (\n // The module is not in the cache. Since this is a \"modified\" update,\n // it means that the module was never instantiated before.\n !module || // The module accepted itself without invalidating globalThis.\n // TODO is that right?\n (hotState.selfAccepted && !hotState.selfInvalidated)\n ) {\n continue;\n }\n\n if (hotState.selfDeclined) {\n return {\n type: \"self-declined\",\n dependencyChain,\n moduleId,\n };\n }\n\n if (runtimeModules.has(moduleId)) {\n queue.push({\n moduleId: undefined,\n dependencyChain: [...dependencyChain, moduleId],\n });\n continue;\n }\n\n for (const parentId of module.parents) {\n const parent = moduleCache[parentId];\n\n if (!parent) {\n // TODO(alexkirsz) Is this even possible?\n continue;\n }\n\n // TODO(alexkirsz) Dependencies: check accepted and declined\n // dependencies here.\n\n queue.push({\n moduleId: parentId,\n dependencyChain: [...dependencyChain, moduleId],\n });\n }\n }\n\n return {\n type: \"accepted\",\n moduleId,\n outdatedModules,\n };\n}\n\nfunction handleApply(chunkListPath: ChunkPath, update: ServerMessage) {\n switch (update.type) {\n case \"partial\": {\n // This indicates that the update is can be applied to the current state of the application.\n applyUpdate(chunkListPath, update.instruction);\n break;\n }\n case \"restart\": {\n // This indicates that there is no way to apply the update to the\n // current state of the application, and that the application must be\n // restarted.\n BACKEND.restart();\n break;\n }\n case \"notFound\": {\n // This indicates that the chunk list no longer exists: either the dynamic import which created it was removed,\n // or the page itself was deleted.\n // If it is a dynamic import, we simply discard all modules that the chunk has exclusive access to.\n // If it is a runtime chunk list, we restart the application.\n if (runtimeChunkLists.has(chunkListPath)) {\n BACKEND.restart();\n } else {\n disposeChunkList(chunkListPath);\n }\n break;\n }\n default:\n throw new Error(`Unknown update type: ${update.type}`);\n }\n}\n\nfunction createModuleHot(\n moduleId: ModuleId,\n hotData: HotData\n): { hot: Hot; hotState: HotState } {\n const hotState: HotState = {\n selfAccepted: false,\n selfDeclined: false,\n selfInvalidated: false,\n disposeHandlers: [],\n };\n\n const hot: Hot = {\n // TODO(alexkirsz) This is not defined in the HMR API. It was used to\n // decide whether to warn whenever an HMR-disposed module required other\n // modules. We might want to remove it.\n active: true,\n\n data: hotData ?? {},\n\n // TODO(alexkirsz) Support full (dep, callback, errorHandler) form.\n accept: (\n modules?: string | string[] | AcceptErrorHandler,\n _callback?: AcceptCallback,\n _errorHandler?: AcceptErrorHandler\n ) => {\n if (modules === undefined) {\n hotState.selfAccepted = true;\n } else if (typeof modules === \"function\") {\n hotState.selfAccepted = modules;\n } else {\n throw new Error(\"unsupported `accept` signature\");\n }\n },\n\n decline: (dep) => {\n if (dep === undefined) {\n hotState.selfDeclined = true;\n } else {\n throw new Error(\"unsupported `decline` signature\");\n }\n },\n\n dispose: (callback) => {\n hotState.disposeHandlers.push(callback);\n },\n\n addDisposeHandler: (callback) => {\n hotState.disposeHandlers.push(callback);\n },\n\n removeDisposeHandler: (callback) => {\n const idx = hotState.disposeHandlers.indexOf(callback);\n if (idx >= 0) {\n hotState.disposeHandlers.splice(idx, 1);\n }\n },\n\n invalidate: () => {\n hotState.selfInvalidated = true;\n queuedInvalidatedModules.add(moduleId);\n },\n\n // NOTE(alexkirsz) This is part of the management API, which we don't\n // implement, but the Next.js React Refresh runtime uses this to decide\n // whether to schedule an update.\n status: () => \"idle\",\n\n // NOTE(alexkirsz) Since we always return \"idle\" for now, these are no-ops.\n addStatusHandler: (_handler) => {},\n removeStatusHandler: (_handler) => {},\n };\n\n return { hot, hotState };\n}\n\n/**\n * Adds a module to a chunk.\n */\nfunction addModuleToChunk(moduleId: ModuleId, chunkPath: ChunkPath) {\n let moduleChunks = moduleChunksMap.get(moduleId);\n if (!moduleChunks) {\n moduleChunks = new Set([chunkPath]);\n moduleChunksMap.set(moduleId, moduleChunks);\n } else {\n moduleChunks.add(chunkPath);\n }\n\n let chunkModules = chunkModulesMap.get(chunkPath);\n if (!chunkModules) {\n chunkModules = new Set([moduleId]);\n chunkModulesMap.set(chunkPath, chunkModules);\n } else {\n chunkModules.add(moduleId);\n }\n}\n\n/**\n * Returns the first chunk that included a module.\n * This is used by the Node.js backend, hence why it's marked as unused in this\n * file.\n */\nfunction getFirstModuleChunk(moduleId: ModuleId) {\n const moduleChunkPaths = moduleChunksMap.get(moduleId);\n if (moduleChunkPaths == null) {\n return null;\n }\n\n return moduleChunkPaths.values().next().value;\n}\n\n/**\n * Removes a module from a chunk.\n * Returns `true` if there are no remaining chunks including this module.\n */\nfunction removeModuleFromChunk(\n moduleId: ModuleId,\n chunkPath: ChunkPath\n): boolean {\n const moduleChunks = moduleChunksMap.get(moduleId)!;\n moduleChunks.delete(chunkPath);\n\n const chunkModules = chunkModulesMap.get(chunkPath)!;\n chunkModules.delete(moduleId);\n\n const noRemainingModules = chunkModules.size === 0;\n if (noRemainingModules) {\n chunkModulesMap.delete(chunkPath);\n }\n\n const noRemainingChunks = moduleChunks.size === 0;\n if (noRemainingChunks) {\n moduleChunksMap.delete(moduleId);\n }\n\n return noRemainingChunks;\n}\n\n/**\n * Disposes of a chunk list and its corresponding exclusive chunks.\n */\nfunction disposeChunkList(chunkListPath: ChunkPath): boolean {\n const chunkPaths = chunkListChunksMap.get(chunkListPath);\n if (chunkPaths == null) {\n return false;\n }\n chunkListChunksMap.delete(chunkListPath);\n\n for (const chunkPath of chunkPaths) {\n const chunkChunkLists = chunkChunkListsMap.get(chunkPath)!;\n chunkChunkLists.delete(chunkListPath);\n\n if (chunkChunkLists.size === 0) {\n chunkChunkListsMap.delete(chunkPath);\n disposeChunk(chunkPath);\n }\n }\n\n // We must also dispose of the chunk list's chunk itself to ensure it may\n // be reloaded properly in the future.\n BACKEND.unloadChunk?.(chunkListPath);\n\n return true;\n}\n\n/**\n * Disposes of a chunk and its corresponding exclusive modules.\n *\n * @returns Whether the chunk was disposed of.\n */\nfunction disposeChunk(chunkPath: ChunkPath): boolean {\n // This should happen whether the chunk has any modules in it or not.\n // For instance, CSS chunks have no modules in them, but they still need to be unloaded.\n BACKEND.unloadChunk?.(chunkPath);\n\n const chunkModules = chunkModulesMap.get(chunkPath);\n if (chunkModules == null) {\n return false;\n }\n chunkModules.delete(chunkPath);\n\n for (const moduleId of chunkModules) {\n const moduleChunks = moduleChunksMap.get(moduleId)!;\n moduleChunks.delete(chunkPath);\n\n const noRemainingChunks = moduleChunks.size === 0;\n if (noRemainingChunks) {\n moduleChunksMap.delete(moduleId);\n disposeModule(moduleId, \"clear\");\n availableModules.delete(moduleId);\n }\n }\n\n return true;\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 * Gets or instantiates a runtime module.\n */\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 instantiateModule(moduleId, { type: SourceType.Runtime, chunkPath });\n}\n\n/**\n * Returns the URL relative to the origin where a chunk can be fetched from.\n */\nfunction getChunkRelativeUrl(chunkPath: ChunkPath): string {\n return `${CHUNK_BASE_PATH}${chunkPath}`;\n}\n\n/**\n * Subscribes to chunk list updates from the update server and applies them.\n */\nfunction registerChunkList(\n chunkUpdateProvider: ChunkUpdateProvider,\n chunkList: ChunkList\n) {\n chunkUpdateProvider.push([\n chunkList.path,\n handleApply.bind(null, chunkList.path),\n ]);\n\n // Adding chunks to chunk lists and vice versa.\n const chunks = new Set(chunkList.chunks.map(getChunkPath));\n chunkListChunksMap.set(chunkList.path, chunks);\n for (const chunkPath of chunks) {\n let chunkChunkLists = chunkChunkListsMap.get(chunkPath);\n if (!chunkChunkLists) {\n chunkChunkLists = new Set([chunkList.path]);\n chunkChunkListsMap.set(chunkPath, chunkChunkLists);\n } else {\n chunkChunkLists.add(chunkList.path);\n }\n }\n\n if (chunkList.source === \"entry\") {\n markChunkListAsRuntime(chunkList.path);\n }\n}\n\n/**\n * Marks a chunk list as a runtime chunk list. There can be more than one\n * runtime chunk list. For instance, integration tests can have multiple chunk\n * groups loaded at runtime, each with its own chunk list.\n */\nfunction markChunkListAsRuntime(chunkListPath: ChunkPath) {\n runtimeChunkLists.add(chunkListPath);\n}\n\nfunction registerChunk([\n chunkPath,\n chunkModules,\n runtimeParams,\n]: ChunkRegistration) {\n for (const [moduleId, moduleFactory] of Object.entries(chunkModules)) {\n if (!moduleFactories[moduleId]) {\n moduleFactories[moduleId] = moduleFactory;\n }\n addModuleToChunk(moduleId, chunkPath);\n }\n\n return BACKEND.registerChunk(chunkPath, runtimeParams);\n}\n\nglobalThis.TURBOPACK_CHUNK_UPDATE_LISTENERS ??= [];\n\nconst chunkListsToRegister = globalThis.TURBOPACK_CHUNK_LISTS;\nif (Array.isArray(chunkListsToRegister)) {\n for (const chunkList of chunkListsToRegister) {\n registerChunkList(globalThis.TURBOPACK_CHUNK_UPDATE_LISTENERS, chunkList);\n }\n}\n\nglobalThis.TURBOPACK_CHUNK_LISTS = {\n push: (chunkList) => {\n registerChunkList(globalThis.TURBOPACK_CHUNK_UPDATE_LISTENERS!, chunkList);\n },\n} satisfies ChunkListProvider;\n"],"names":[],"mappings":";;;;;;;IAiEA;UAAK,UAAU;IAAV,WAAA,WAKH,aAAU,KAAV;IALG,WAAA,WASH,YAAS,KAAT;IATG,WAAA,WAcH,YAAS,KAAT;GAdG,eAAA;;AAwCL,MAAM,kBAAmC,OAAO,M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C,uBAAuB,UAAU,IAAI;IACvC;AACF;AAOA,SAAS,uBAAuB,aAAwB;IACtD,kBAAkB,GAAG,CAAC;AACxB;AAEA,SAAS,cAAc,CACrB,WACA,cACA,cACkB;IAClB,KAAK,MAAM,CAAC,UAAU,cAAc,IAAI,OAAO,OAAO,CAAC,cAAe;QACpE,IAAI,CAAC,eAAe,CAAC,SAAS,EAAE;YAC9B,eAAe,CAAC,SAAS,GAAG;QAC9B;QACA,iBAAiB,UAAU;IAC7B;IAEA,OAAO,QAAQ,aAAa,CAAC,WAAW;AAC1C;AAEA,WAAW,gCAAgC,KAAK,EAAE;AAElD,MAAM,uBAAuB,WAAW,qBAAqB;AAC7D,IAAI,MAAM,OAAO,CAAC,uBAAuB;IACvC,KAAK,MAAM,aAAa,qBAAsB;QAC5C,kBAAkB,WAAW,gCAAgC,EAAE;IACjE;AACF;AAEA,WAAW,qBAAqB,GAAG;IACjC,MAAM,CAAC;QACL,kBAAkB,WAAW,gCAAgC,EAAG;IAClE;AACF"}}, + {"offset": {"line": 1050, "column": 0}, "map": {"version":3,"sources":["/turbopack/[turbopack]/dev/runtime/dom/runtime-backend-dom.ts"],"sourcesContent":["/**\n * This file contains the runtime code specific to the Turbopack development\n * ECMAScript DOM runtime.\n *\n * It will be appended to the base development runtime code.\n */\n\n/// \n\ntype ChunkResolver = {\n resolved: boolean;\n resolve: () => void;\n reject: (error?: Error) => void;\n promise: Promise;\n};\n\nlet BACKEND: RuntimeBackend;\n\nfunction augmentContext(context: TurbopackDevBaseContext): TurbopackDevContext {\n return context;\n}\n\nfunction commonJsRequireContext(\n entry: RequireContextEntry,\n sourceModule: Module\n): Exports {\n return commonJsRequire(sourceModule, entry.id());\n}\n\n(() => {\n BACKEND = {\n async registerChunk(chunkPath, params) {\n const resolver = getOrCreateResolver(chunkPath);\n resolver.resolve();\n\n if (params == null) {\n return;\n }\n\n for (const otherChunkData of params.otherChunks) {\n const otherChunkPath = getChunkPath(otherChunkData);\n // Chunk might have started loading, so we want to avoid triggering another load.\n getOrCreateResolver(otherChunkPath);\n }\n\n // This waits for chunks to be loaded, but also marks included items as available.\n await Promise.all(\n params.otherChunks.map((otherChunkData) =>\n loadChunk({ type: SourceType.Runtime, chunkPath }, otherChunkData)\n )\n );\n\n if (params.runtimeModuleIds.length > 0) {\n for (const moduleId of params.runtimeModuleIds) {\n getOrInstantiateRuntimeModule(moduleId, chunkPath);\n }\n }\n },\n\n loadChunk(chunkPath, source) {\n return doLoadChunk(chunkPath, source);\n },\n\n unloadChunk(chunkPath) {\n deleteResolver(chunkPath);\n\n const chunkUrl = getChunkRelativeUrl(chunkPath);\n\n if (chunkPath.endsWith(\".css\")) {\n const links = document.querySelectorAll(`link[href=\"${chunkUrl}\"]`);\n for (const link of Array.from(links)) {\n link.remove();\n }\n } else if (chunkPath.endsWith(\".js\")) {\n // Unloading a JS chunk would have no effect, as it lives in the JS\n // runtime once evaluated.\n // However, we still want to remove the script tag from the DOM to keep\n // the HTML somewhat consistent from the user's perspective.\n const scripts = document.querySelectorAll(`script[src=\"${chunkUrl}\"]`);\n for (const script of Array.from(scripts)) {\n script.remove();\n }\n } else {\n throw new Error(`can't infer type of chunk from path ${chunkPath}`);\n }\n },\n\n reloadChunk(chunkPath) {\n return new Promise((resolve, reject) => {\n if (!chunkPath.endsWith(\".css\")) {\n reject(new Error(\"The DOM backend can only reload CSS chunks\"));\n return;\n }\n\n const encodedChunkPath = chunkPath\n .split(\"/\")\n .map((p) => encodeURIComponent(p))\n .join(\"/\");\n\n const chunkUrl = `/${getChunkRelativeUrl(encodedChunkPath)}`;\n\n const previousLink = document.querySelector(\n `link[rel=stylesheet][href^=\"${chunkUrl}\"]`\n );\n\n if (previousLink == null) {\n reject(new Error(`No link element found for chunk ${chunkPath}`));\n return;\n }\n\n const link = document.createElement(\"link\");\n link.rel = \"stylesheet\";\n link.href = chunkUrl;\n link.onerror = () => {\n reject();\n };\n link.onload = () => {\n // First load the new CSS, then remove the old one. This prevents visible\n // flickering that would happen in-between removing the previous CSS and\n // loading the new one.\n previousLink.remove();\n\n // CSS chunks do not register themselves, and as such must be marked as\n // loaded instantly.\n resolve();\n };\n\n // Make sure to insert the new CSS right after the previous one, so that\n // its precedence is higher.\n previousLink.parentElement!.insertBefore(\n link,\n previousLink.nextSibling\n );\n });\n },\n\n restart: () => self.location.reload(),\n };\n\n /**\n * Maps chunk paths to the corresponding resolver.\n */\n const chunkResolvers: Map = new Map();\n\n function getOrCreateResolver(chunkPath: ChunkPath): ChunkResolver {\n let resolver = chunkResolvers.get(chunkPath);\n if (!resolver) {\n let resolve: () => void;\n let reject: (error?: Error) => void;\n const promise = new Promise((innerResolve, innerReject) => {\n resolve = innerResolve;\n reject = innerReject;\n });\n resolver = {\n resolved: false,\n promise,\n resolve: () => {\n resolver!.resolved = true;\n resolve();\n },\n reject: reject!,\n };\n chunkResolvers.set(chunkPath, resolver);\n }\n return resolver;\n }\n\n function deleteResolver(chunkPath: ChunkPath) {\n chunkResolvers.delete(chunkPath);\n }\n\n /**\n * Loads the given chunk, and returns a promise that resolves once the chunk\n * has been loaded.\n */\n async function doLoadChunk(chunkPath: ChunkPath, source: SourceInfo) {\n const resolver = getOrCreateResolver(chunkPath);\n if (resolver.resolved) {\n return resolver.promise;\n }\n\n if (source.type === SourceType.Runtime) {\n // We don't need to load chunks references from runtime code, as they're already\n // present in the DOM.\n\n if (chunkPath.endsWith(\".css\")) {\n // CSS chunks do not register themselves, and as such must be marked as\n // loaded instantly.\n resolver.resolve();\n }\n\n // We need to wait for JS chunks to register themselves within `registerChunk`\n // before we can start instantiating runtime modules, hence the absence of\n // `resolver.resolve()` in this branch.\n\n return resolver.promise;\n }\n\n const chunkUrl = `/${getChunkRelativeUrl(chunkPath)}`;\n\n if (chunkPath.endsWith(\".css\")) {\n const link = document.createElement(\"link\");\n link.rel = \"stylesheet\";\n link.href = chunkUrl;\n link.onerror = () => {\n resolver.reject();\n };\n link.onload = () => {\n // CSS chunks do not register themselves, and as such must be marked as\n // loaded instantly.\n resolver.resolve();\n };\n document.body.appendChild(link);\n } else if (chunkPath.endsWith(\".js\")) {\n const script = document.createElement(\"script\");\n script.src = chunkUrl;\n // We'll only mark the chunk as loaded once the script has been executed,\n // which happens in `registerChunk`. Hence the absence of `resolve()` in\n // this branch.\n script.onerror = () => {\n resolver.reject();\n };\n document.body.appendChild(script);\n } else {\n throw new Error(`can't infer type of chunk from path ${chunkPath}`);\n }\n\n return resolver.promise;\n }\n})();\n\nfunction _eval({ code, url, map }: EcmascriptModuleEntry): ModuleFactory {\n code += `\\n\\n//# sourceURL=${location.origin}/${url}`;\n if (map) code += `\\n//# sourceMappingURL=${map}`;\n return eval(code);\n}\n"],"names":[],"mappings":"AAgBA,IAAI;AAEJ,SAAS,eAAe,QAAgC;IACtD,OAAO;AACT;AAEA,SAAS,uBACP,MAA0B,EAC1B,aAAoB;IAEpB,OAAO,gBAAgB,eAAc,OAAM,EAAE;AAC/C;AAEC,CAAA;IACC,UAAU;QACR,MAAM,eAAc,UAAS,EAAE,OAAM;YACnC,MAAM,YAAW,qBAAoB;YACrC,UAAS,OAAO;YAEhB,IAAI,WAAU,MAAM;gBAClB;YACF;YAEA,KAAK,MAAM,mBAAkB,QAAO,WAAW,CAAE;gBAC/C,MAAM,kBAAiB,aAAa;gBAEpC,qBAAoB;YACtB;YAGA,MAAM,QAAQ,GAAG,CACf,QAAO,WAAW,CAAC,GAAG,CAAC,CAAC,kBACtB,UAAU;oBAAE,MAAM,WAAW,OAAO;oBAAE,WAAA;gBAAU,GAAG;YAIvD,IAAI,QAAO,gBAAgB,CAAC,MAAM,GAAG,GAAG;gBACtC,KAAK,MAAM,aAAY,QAAO,gBAAgB,CAAE;oBAC9C,8BAA8B,WAAU;gBAC1C;YACF;QACF;QAEA,WAAU,UAAS,EAAE,OAAM;YACzB,OAAO,aAAY,YAAW;QAChC;QAEA,aAAY,UAAS;YACnB,gBAAe;YAEf,MAAM,YAAW,oBAAoB;YAErC,IAAI,WAAU,QAAQ,CAAC,S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AC;QACpE;QAEA,OAAO,UAAS,OAAO;IACzB;AACF,CAAA;AAEA,SAAS,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAyB;IACtD,QAAQ,CAAC,kBAAkB,EAAE,SAAS,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC;IACrD,IAAI,KAAK,QAAQ,CAAC,uBAAuB,EAAE,IAAI,CAAC;IAChD,OAAO,KAAK;AACd"}}, + {"offset": {"line": 1194, "column": 0}, "map": {"version":3,"sources":[],"names":[],"mappings":"A"}}] } \ No newline at end of file From 3b0be02a03f0af9e2ad9c23b2f320e61a76b73e4 Mon Sep 17 00:00:00 2001 From: hrmny Date: Thu, 20 Jul 2023 16:14:19 +0200 Subject: [PATCH 15/16] revert snapshot changes --- Cargo.lock | 3 -- crates/turbopack-cli/Cargo.toml | 3 +- crates/turbopack-test-utils/Cargo.toml | 14 +++--- crates/turbopack-test-utils/src/snapshot.rs | 34 +++---------- crates/turbopack-tests/Cargo.toml | 1 - crates/turbopack-tests/tests/execution.rs | 33 +++++-------- .../unexpected export __star__-884def.txt | 17 +++++-- ...rror resolving commonjs request-ee63e3.txt | 48 +++++++++++-------- ... source code for parsing failed-3b6255.txt | 19 ++++++-- ...rmat (CommonJs) is not matching-5fdb68.txt | 18 +++++-- ...rmat (EcmaScript Modules) is no-34c311.txt | 17 +++++-- crates/turbopack-tests/tests/snapshot.rs | 11 ++++- .../unexpected export __star__-c9d8a6.txt | 17 +++++-- .../unexpected export __star__-38cf67.txt | 17 +++++-- ...neration for chunk item errored-5567c6.txt | 32 ++++++------- ...rror resolving commonjs request-b97684.txt | 44 ++++++++++------- ...ving EcmaScript Modules request-aff400.txt | 23 +++++---- 17 files changed, 204 insertions(+), 147 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5e8de8d3b3f73..6977544d82b47 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9520,14 +9520,12 @@ version = "0.1.0" dependencies = [ "anyhow", "once_cell", - "regex", "serde", "similar", "turbo-tasks", "turbo-tasks-build", "turbo-tasks-fs", "turbo-tasks-hash", - "turbopack-cli-utils", "turbopack-core", ] @@ -9551,7 +9549,6 @@ dependencies = [ "turbo-tasks-memory", "turbopack", "turbopack-build", - "turbopack-cli-utils", "turbopack-core", "turbopack-dev", "turbopack-ecmascript-plugins", diff --git a/crates/turbopack-cli/Cargo.toml b/crates/turbopack-cli/Cargo.toml index 3203acf7b0ad5..1ac25fa4ed7d8 100644 --- a/crates/turbopack-cli/Cargo.toml +++ b/crates/turbopack-cli/Cargo.toml @@ -15,8 +15,7 @@ bench = false bench = false [[bench]] -name = "turbopack-cli" -path = "benches/mod.rs" +name = "mod" harness = false [features] diff --git a/crates/turbopack-test-utils/Cargo.toml b/crates/turbopack-test-utils/Cargo.toml index 3932e60935f13..b87f9b43913d0 100644 --- a/crates/turbopack-test-utils/Cargo.toml +++ b/crates/turbopack-test-utils/Cargo.toml @@ -10,16 +10,14 @@ autobenches = false bench = false [dependencies] -anyhow = { workspace = true } +anyhow = "1.0.47" once_cell = { workspace = true } -regex = { workspace = true, features = ["pattern"] } serde = { workspace = true } similar = "2.2.0" -turbo-tasks = { workspace = true } -turbo-tasks-fs = { workspace = true } -turbo-tasks-hash = { workspace = true } -turbopack-cli-utils = { workspace = true } -turbopack-core = { workspace = true } +turbo-tasks = { path = "../turbo-tasks" } +turbo-tasks-fs = { path = "../turbo-tasks-fs" } +turbo-tasks-hash = { path = "../turbo-tasks-hash" } +turbopack-core = { path = "../turbopack-core" } [build-dependencies] -turbo-tasks-build = { workspace = true } +turbo-tasks-build = { path = "../turbo-tasks-build" } diff --git a/crates/turbopack-test-utils/src/snapshot.rs b/crates/turbopack-test-utils/src/snapshot.rs index cf830d1e5fe02..3875db9015560 100644 --- a/crates/turbopack-test-utils/src/snapshot.rs +++ b/crates/turbopack-test-utils/src/snapshot.rs @@ -1,39 +1,33 @@ use std::{ collections::{HashMap, HashSet}, env, fs, - path::PathBuf, }; use anyhow::{anyhow, bail, Context, Result}; use once_cell::sync::Lazy; -use regex::Regex; use similar::TextDiff; -use turbo_tasks::{ReadRef, TryJoinIterExt, ValueToString, Vc}; +use turbo_tasks::{debug::ValueDebugString, ReadRef, TryJoinIterExt, ValueToString, Vc}; use turbo_tasks_fs::{ DirectoryContent, DirectoryEntry, DiskFileSystem, File, FileContent, FileSystemEntryType, FileSystemPath, }; use turbo_tasks_hash::encode_hex; -use turbopack_cli_utils::issue::{format_issue, LogOptions}; -use turbopack_core::{ - asset::AssetContent, - issue::{IssueSeverity, PlainIssue}, -}; +use turbopack_core::{asset::AssetContent, issue::PlainIssue}; // Updates the existing snapshot outputs with the actual outputs of this run. // e.g. `UPDATE=1 cargo test -p turbopack-tests -- test_my_pattern` static UPDATE: Lazy = Lazy::new(|| env::var("UPDATE").unwrap_or_default() == "1"); -static ANSI_REGEX: Lazy = Lazy::new(|| Regex::new(r"\x1b\[\d+m").unwrap()); - -pub async fn snapshot_issues>>( +pub async fn snapshot_issues< + I: IntoIterator, ReadRef)>, +>( captured_issues: I, issues_path: Vc, workspace_root: &str, ) -> Result<()> { let expected_issues = expected(issues_path).await?; let mut seen = HashSet::new(); - for plain_issue in captured_issues.into_iter() { + for (plain_issue, debug_string) in captured_issues.into_iter() { let title = plain_issue .title .replace('/', "__") @@ -54,28 +48,14 @@ pub async fn snapshot_issues>>( continue; } - let formatted = format_issue( - &plain_issue, - None, - &LogOptions { - current_dir: PathBuf::new(), - project_dir: PathBuf::new(), - show_all: true, - log_detail: true, - log_level: IssueSeverity::Info, - }, - ); - // Annoyingly, the PlainIssue.source -> PlainIssueSource.asset -> // PlainSource.path -> FileSystemPath.fs -> DiskFileSystem.root changes // for everyone. - let content = formatted + let content = debug_string .as_str() .replace(workspace_root, "WORKSPACE_ROOT") - .replace(&*ANSI_REGEX, "") // Normalize syspaths from Windows. These appear in stack traces. .replace("\\\\", "/"); - let asset = AssetContent::file(File::from(content).into()); diff(path, asset).await?; diff --git a/crates/turbopack-tests/Cargo.toml b/crates/turbopack-tests/Cargo.toml index c8117a8202861..6601992fba38a 100644 --- a/crates/turbopack-tests/Cargo.toml +++ b/crates/turbopack-tests/Cargo.toml @@ -27,7 +27,6 @@ turbo-tasks-env = { workspace = true } turbo-tasks-fs = { workspace = true } turbo-tasks-memory = { workspace = true } turbopack-build = { workspace = true, features = ["test"] } -turbopack-cli-utils = { workspace = true } turbopack-core = { workspace = true, features = ["issue_path"] } turbopack-dev = { workspace = true, features = ["test"] } turbopack-ecmascript-plugins = { workspace = true, features = [ diff --git a/crates/turbopack-tests/tests/execution.rs b/crates/turbopack-tests/tests/execution.rs index b4d4077ef76ab..9fb37ccfc7ab6 100644 --- a/crates/turbopack-tests/tests/execution.rs +++ b/crates/turbopack-tests/tests/execution.rs @@ -10,7 +10,7 @@ use std::{ }; use anyhow::{Context, Result}; -use turbo_tasks::{unit, Completion, TryJoinIterExt, TurboTasks, Value, Vc}; +use turbo_tasks::{debug::ValueDebug, unit, Completion, TryJoinIterExt, TurboTasks, Value, Vc}; use turbo_tasks_bytes::stream::SingleValue; use turbo_tasks_env::CommandLineProcessEnv; use turbo_tasks_fs::{ @@ -35,7 +35,7 @@ use turbopack_core::{ source::Source, }; use turbopack_dev::DevChunkingContext; -use turbopack_node::{debug::should_debug, evaluate::evaluate}; +use turbopack_node::evaluate::evaluate; use turbopack_test_utils::jest::JestRunResult; use crate::util::REPO_ROOT; @@ -263,28 +263,16 @@ async fn run_test(resource: String) -> Result> { ])), vec![], Completion::immutable(), - should_debug("execution_test"), + false, ) .await?; - let single = res + let SingleValue::Single(bytes) = res .try_into_single() .await - .context("test node result did not emit anything")?; - - let SingleValue::Single(bytes) = single else { - return Ok(RunTestResult { - js_result: JsResult { - uncaught_exceptions: vec![], - unhandled_rejections: vec![], - jest_result: JestRunResult { - test_results: vec![], - }, - } - .cell(), - path, - } - .cell()); + .context("test node result did not emit anything")? + else { + panic!("Evaluation stream must yield SingleValue."); }; Ok(RunTestResult { @@ -306,7 +294,12 @@ async fn snapshot_issues(run_result: Vc) -> Result> { let plain_issues = captured_issues .iter_with_shortest_path() - .map(|(issue_vc, path)| async move { issue_vc.into_plain(path).await }) + .map(|(issue_vc, path)| async move { + Ok(( + issue_vc.into_plain(path).await?, + issue_vc.into_plain(path).dbg().await?, + )) + }) .try_join() .await?; diff --git a/crates/turbopack-tests/tests/execution/turbopack/async-modules/export-all/issues/unexpected export __star__-884def.txt b/crates/turbopack-tests/tests/execution/turbopack/async-modules/export-all/issues/unexpected export __star__-884def.txt index 9065f2102176f..a63b6ce28ca3c 100644 --- a/crates/turbopack-tests/tests/execution/turbopack/async-modules/export-all/issues/unexpected export __star__-884def.txt +++ b/crates/turbopack-tests/tests/execution/turbopack/async-modules/export-all/issues/unexpected export __star__-884def.txt @@ -1,3 +1,14 @@ -warning - [analyze] [project]/crates/turbopack-tests/tests/execution/turbopack/async-modules/export-all/input/exports.js unexpected export * - export * used with module [project]/crates/turbopack-tests/tests/execution/turbopack/async-modules/export-all/input/exports.js (ecmascript) which is a CommonJS module with exports only available at runtime - List all export names manually (`export { a, b, c } from "...") or rewrite the module to ESM, to avoid the additional runtime code.` \ No newline at end of file +PlainIssue { + severity: Warning, + context: "[project]/crates/turbopack-tests/tests/execution/turbopack/async-modules/export-all/input/exports.js", + category: "analyze", + title: "unexpected export *", + description: "export * used with module [project]/crates/turbopack-tests/tests/execution/turbopack/async-modules/export-all/input/exports.js (ecmascript) which is a CommonJS module with exports only available at runtime\nList all export names manually (`export { a, b, c } from \"...\") or rewrite the module to ESM, to avoid the additional runtime code.`", + detail: "", + documentation_link: "", + source: None, + sub_issues: [], + processing_path: Some( + [], + ), +} \ No newline at end of file diff --git a/crates/turbopack-tests/tests/execution/turbopack/basic/comptime/issues/Error resolving commonjs request-ee63e3.txt b/crates/turbopack-tests/tests/execution/turbopack/basic/comptime/issues/Error resolving commonjs request-ee63e3.txt index ce51578bb4a5e..aa7d4526b8dc7 100644 --- a/crates/turbopack-tests/tests/execution/turbopack/basic/comptime/issues/Error resolving commonjs request-ee63e3.txt +++ b/crates/turbopack-tests/tests/execution/turbopack/basic/comptime/issues/Error resolving commonjs request-ee63e3.txt @@ -1,20 +1,28 @@ -error - [resolve] [project]/crates/turbopack-tests/tests/execution/turbopack/basic/comptime/input/index.js /crates/turbopack-tests/tests/execution/turbopack/basic/comptime/input/index.js:4:5 Error resolving commonjs request - 1 | it("importing a not existing file should throw", () => { - 2 | // This is a check to make sure that the following tests would fail if they require("fail") - 3 | expect(() => { - + v----------------------------v - 4 + require("./not-existing-file"); - + ^----------------------------^ - 5 | }).toThrow(); - 6 | }); - 7 | - 8 | function maybeReturn(x) { - - unable to resolve relative "./not-existing-file" - - | It was not possible to find the requested file. - | Parsed request as written in source code: relative "./not-existing-file" - | Path where resolving has started: [project]/crates/turbopack-tests/tests/execution/turbopack/basic/comptime/input/index.js - | Type of request: commonjs request - | Import map: No import map entry - | \ No newline at end of file +PlainIssue { + severity: Error, + context: "[project]/crates/turbopack-tests/tests/execution/turbopack/basic/comptime/input/index.js", + category: "resolve", + title: "Error resolving commonjs request", + description: "unable to resolve relative \"./not-existing-file\"", + detail: "It was not possible to find the requested file.\nParsed request as written in source code: relative \"./not-existing-file\"\nPath where resolving has started: [project]/crates/turbopack-tests/tests/execution/turbopack/basic/comptime/input/index.js\nType of request: commonjs request\nImport map: No import map entry\n", + documentation_link: "", + source: Some( + PlainIssueSource { + asset: PlainSource { + ident: "[project]/crates/turbopack-tests/tests/execution/turbopack/basic/comptime/input/index.js", + }, + start: SourcePos { + line: 3, + column: 5, + }, + end: SourcePos { + line: 3, + column: 35, + }, + }, + ), + sub_issues: [], + processing_path: Some( + [], + ), +} \ No newline at end of file diff --git a/crates/turbopack-tests/tests/execution/turbopack/basic/error/issues/Reading source code for parsing failed-3b6255.txt b/crates/turbopack-tests/tests/execution/turbopack/basic/error/issues/Reading source code for parsing failed-3b6255.txt index bf599e10d8e6e..90d28dfb1113f 100644 --- a/crates/turbopack-tests/tests/execution/turbopack/basic/error/issues/Reading source code for parsing failed-3b6255.txt +++ b/crates/turbopack-tests/tests/execution/turbopack/basic/error/issues/Reading source code for parsing failed-3b6255.txt @@ -1,5 +1,14 @@ -error - [parse] [project]/crates/turbopack-tests/tests/execution/turbopack/basic/error/input/broken.js Reading source code for parsing failed - An unexpected error happened while trying to read the source code to parse: failed to convert rope into string - - Caused by: - - invalid utf-8 sequence of 1 bytes from index 1 \ No newline at end of file +PlainIssue { + severity: Error, + context: "[project]/crates/turbopack-tests/tests/execution/turbopack/basic/error/input/broken.js", + category: "parse", + title: "Reading source code for parsing failed", + description: "An unexpected error happened while trying to read the source code to parse: failed to convert rope into string\n\nCaused by:\n- invalid utf-8 sequence of 1 bytes from index 1", + detail: "", + documentation_link: "", + source: None, + sub_issues: [], + processing_path: Some( + [], + ), +} \ No newline at end of file diff --git a/crates/turbopack-tests/tests/execution/turbopack/basic/node-default-import/issues/Specified module format (CommonJs) is not matching-5fdb68.txt b/crates/turbopack-tests/tests/execution/turbopack/basic/node-default-import/issues/Specified module format (CommonJs) is not matching-5fdb68.txt index 0d8e9548d3358..8ce56b3259d33 100644 --- a/crates/turbopack-tests/tests/execution/turbopack/basic/node-default-import/issues/Specified module format (CommonJs) is not matching-5fdb68.txt +++ b/crates/turbopack-tests/tests/execution/turbopack/basic/node-default-import/issues/Specified module format (CommonJs) is not matching-5fdb68.txt @@ -1,4 +1,14 @@ -error - [module type] [project]/crates/turbopack-tests/tests/execution/turbopack/basic/node-default-import/input/node_modules/esm-package/invalid-exports.cjs Specified module format (CommonJs) is not matching the module format of the source code (EcmaScript Modules) - The CommonJs module format was specified in the package.json that is affecting this source file or by using an special extension, but Ecmascript import/export syntax is used in the source code. - The module was automatically converted to an EcmaScript module, but that is in conflict with the specified module format. Either change the "type" field in the package.json or replace EcmaScript import/export syntax with CommonJs syntas in the source file. - In some cases EcmaScript import/export syntax is added by an transform and isn't actually part of the source code. In these cases revisit transformation options to inject the correct syntax. \ No newline at end of file +PlainIssue { + severity: Error, + context: "[project]/crates/turbopack-tests/tests/execution/turbopack/basic/node-default-import/input/node_modules/esm-package/invalid-exports.cjs", + category: "module type", + title: "Specified module format (CommonJs) is not matching the module format of the source code (EcmaScript Modules)", + description: "The CommonJs module format was specified in the package.json that is affecting this source file or by using an special extension, but Ecmascript import/export syntax is used in the source code.\nThe module was automatically converted to an EcmaScript module, but that is in conflict with the specified module format. Either change the \"type\" field in the package.json or replace EcmaScript import/export syntax with CommonJs syntas in the source file.\nIn some cases EcmaScript import/export syntax is added by an transform and isn't actually part of the source code. In these cases revisit transformation options to inject the correct syntax.", + detail: "", + documentation_link: "", + source: None, + sub_issues: [], + processing_path: Some( + [], + ), +} \ No newline at end of file diff --git a/crates/turbopack-tests/tests/execution/turbopack/basic/node-default-import/issues/Specified module format (EcmaScript Modules) is no-34c311.txt b/crates/turbopack-tests/tests/execution/turbopack/basic/node-default-import/issues/Specified module format (EcmaScript Modules) is no-34c311.txt index 8ab52b5ba3073..4c5829599758c 100644 --- a/crates/turbopack-tests/tests/execution/turbopack/basic/node-default-import/issues/Specified module format (EcmaScript Modules) is no-34c311.txt +++ b/crates/turbopack-tests/tests/execution/turbopack/basic/node-default-import/issues/Specified module format (EcmaScript Modules) is no-34c311.txt @@ -1,3 +1,14 @@ -warning - [module type] [project]/crates/turbopack-tests/tests/execution/turbopack/basic/node-default-import/input/node_modules/esm-package/invalid-exports.js Specified module format (EcmaScript Modules) is not matching the module format of the source code (CommonJs) - The EcmaScript module format was specified in the package.json that is affecting this source file or by using an special extension, but it looks like that CommonJs syntax is used in the source code. - Exports made by CommonJs syntax will lead to a runtime error, since the module is in EcmaScript mode. Either change the "type" field in the package.json or replace CommonJs syntax with EcmaScript import/export syntax in the source file. \ No newline at end of file +PlainIssue { + severity: Warning, + context: "[project]/crates/turbopack-tests/tests/execution/turbopack/basic/node-default-import/input/node_modules/esm-package/invalid-exports.js", + category: "module type", + title: "Specified module format (EcmaScript Modules) is not matching the module format of the source code (CommonJs)", + description: "The EcmaScript module format was specified in the package.json that is affecting this source file or by using an special extension, but it looks like that CommonJs syntax is used in the source code.\nExports made by CommonJs syntax will lead to a runtime error, since the module is in EcmaScript mode. Either change the \"type\" field in the package.json or replace CommonJs syntax with EcmaScript import/export syntax in the source file.", + detail: "", + documentation_link: "", + source: None, + sub_issues: [], + processing_path: Some( + [], + ), +} \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot.rs b/crates/turbopack-tests/tests/snapshot.rs index f34b993c8fb01..29a14698e6d65 100644 --- a/crates/turbopack-tests/tests/snapshot.rs +++ b/crates/turbopack-tests/tests/snapshot.rs @@ -11,7 +11,9 @@ use std::{ use anyhow::{bail, Context, Result}; use dunce::canonicalize; use serde::Deserialize; -use turbo_tasks::{unit, ReadRef, TryJoinIterExt, TurboTasks, Value, ValueToString, Vc}; +use turbo_tasks::{ + debug::ValueDebug, unit, ReadRef, TryJoinIterExt, TurboTasks, Value, ValueToString, Vc, +}; use turbo_tasks_env::DotenvProcessEnv; use turbo_tasks_fs::{ json::parse_json_with_source_context, util::sys_to_unix, DiskFileSystem, FileSystem, @@ -146,7 +148,12 @@ async fn run(resource: PathBuf) -> Result<()> { let plain_issues = captured_issues .iter_with_shortest_path() - .map(|(issue_vc, path)| async move { issue_vc.into_plain(path).await }) + .map(|(issue_vc, path)| async move { + Ok(( + issue_vc.into_plain(path).await?, + issue_vc.into_plain(path).dbg().await?, + )) + }) .try_join() .await?; diff --git a/crates/turbopack-tests/tests/snapshot/export-alls/cjs-2/issues/unexpected export __star__-c9d8a6.txt b/crates/turbopack-tests/tests/snapshot/export-alls/cjs-2/issues/unexpected export __star__-c9d8a6.txt index 351a91de29c3e..4d82202bd482f 100644 --- a/crates/turbopack-tests/tests/snapshot/export-alls/cjs-2/issues/unexpected export __star__-c9d8a6.txt +++ b/crates/turbopack-tests/tests/snapshot/export-alls/cjs-2/issues/unexpected export __star__-c9d8a6.txt @@ -1,3 +1,14 @@ -warning - [analyze] [project]/crates/turbopack-tests/tests/snapshot/export-alls/cjs-2/input/commonjs.js unexpected export * - export * used with module [project]/crates/turbopack-tests/tests/snapshot/export-alls/cjs-2/input/commonjs.js (ecmascript) which is a CommonJS module with exports only available at runtime - List all export names manually (`export { a, b, c } from "...") or rewrite the module to ESM, to avoid the additional runtime code.` \ No newline at end of file +PlainIssue { + severity: Warning, + context: "[project]/crates/turbopack-tests/tests/snapshot/export-alls/cjs-2/input/commonjs.js", + category: "analyze", + title: "unexpected export *", + description: "export * used with module [project]/crates/turbopack-tests/tests/snapshot/export-alls/cjs-2/input/commonjs.js (ecmascript) which is a CommonJS module with exports only available at runtime\nList all export names manually (`export { a, b, c } from \"...\") or rewrite the module to ESM, to avoid the additional runtime code.`", + detail: "", + documentation_link: "", + source: None, + sub_issues: [], + processing_path: Some( + [], + ), +} \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/export-alls/cjs-script/issues/unexpected export __star__-38cf67.txt b/crates/turbopack-tests/tests/snapshot/export-alls/cjs-script/issues/unexpected export __star__-38cf67.txt index 31e8dda48183a..2e59a9c516941 100644 --- a/crates/turbopack-tests/tests/snapshot/export-alls/cjs-script/issues/unexpected export __star__-38cf67.txt +++ b/crates/turbopack-tests/tests/snapshot/export-alls/cjs-script/issues/unexpected export __star__-38cf67.txt @@ -1,3 +1,14 @@ -warning - [analyze] [project]/crates/turbopack-tests/tests/snapshot/export-alls/cjs-script/input/exported.cjs unexpected export * - export * used with module [project]/crates/turbopack-tests/tests/snapshot/export-alls/cjs-script/input/exported.cjs (ecmascript) which is a CommonJS module with exports only available at runtime - List all export names manually (`export { a, b, c } from "...") or rewrite the module to ESM, to avoid the additional runtime code.` \ No newline at end of file +PlainIssue { + severity: Warning, + context: "[project]/crates/turbopack-tests/tests/snapshot/export-alls/cjs-script/input/exported.cjs", + category: "analyze", + title: "unexpected export *", + description: "export * used with module [project]/crates/turbopack-tests/tests/snapshot/export-alls/cjs-script/input/exported.cjs (ecmascript) which is a CommonJS module with exports only available at runtime\nList all export names manually (`export { a, b, c } from \"...\") or rewrite the module to ESM, to avoid the additional runtime code.`", + detail: "", + documentation_link: "", + source: None, + sub_issues: [], + processing_path: Some( + [], + ), +} \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/imports/json/issues/Code generation for chunk item errored-5567c6.txt b/crates/turbopack-tests/tests/snapshot/imports/json/issues/Code generation for chunk item errored-5567c6.txt index 3abc098754023..f2c3813dddcbe 100644 --- a/crates/turbopack-tests/tests/snapshot/imports/json/issues/Code generation for chunk item errored-5567c6.txt +++ b/crates/turbopack-tests/tests/snapshot/imports/json/issues/Code generation for chunk item errored-5567c6.txt @@ -1,18 +1,14 @@ -error - [code generation] [project]/crates/turbopack-tests/tests/snapshot/imports/json/input/invalid.json Code generation for chunk item errored - An error occurred while generating the chunk item [project]/crates/turbopack-tests/tests/snapshot/imports/json/input/invalid.json (json) - - Caused by: - - Unable to make a module from invalid JSON: expected `,` or `}` at line 3 column 26 - - Debug info: - - An error occurred while generating the chunk item [project]/crates/turbopack-tests/tests/snapshot/imports/json/input/invalid.json (json) - - Execution of ::content failed - - Unable to make a module from invalid JSON: expected `,` or `}` at line 3 column 26 - at nested.? - 1 | { - 2 | "nested": { - | v - 3 + "this-is": "invalid" // lint-staged will remove trailing commas, so here's a comment - | ^ - 4 | } - 5 | } \ No newline at end of file +PlainIssue { + severity: Error, + context: "[project]/crates/turbopack-tests/tests/snapshot/imports/json/input/invalid.json", + category: "code generation", + title: "Code generation for chunk item errored", + description: "An error occurred while generating the chunk item [project]/crates/turbopack-tests/tests/snapshot/imports/json/input/invalid.json (json)\n\nCaused by:\n- Unable to make a module from invalid JSON: expected `,` or `}` at line 3 column 26\n\nDebug info:\n- An error occurred while generating the chunk item [project]/crates/turbopack-tests/tests/snapshot/imports/json/input/invalid.json (json)\n- Execution of ::content failed\n- Unable to make a module from invalid JSON: expected `,` or `}` at line 3 column 26\n at nested.?\n 1 | {\n 2 | \"nested\": {\n | v\n 3 + \"this-is\": \"invalid\" // lint-staged will remove trailing commas, so here's a comment\n | ^\n 4 | }\n 5 | }", + detail: "", + documentation_link: "", + source: None, + sub_issues: [], + processing_path: Some( + [], + ), +} \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/imports/resolve_error_cjs/issues/Error resolving commonjs request-b97684.txt b/crates/turbopack-tests/tests/snapshot/imports/resolve_error_cjs/issues/Error resolving commonjs request-b97684.txt index 3c8e795ebaed1..968f52b5d3a18 100644 --- a/crates/turbopack-tests/tests/snapshot/imports/resolve_error_cjs/issues/Error resolving commonjs request-b97684.txt +++ b/crates/turbopack-tests/tests/snapshot/imports/resolve_error_cjs/issues/Error resolving commonjs request-b97684.txt @@ -1,16 +1,28 @@ -error - [resolve] [project]/crates/turbopack-tests/tests/snapshot/imports/resolve_error_cjs/input/index.js /crates/turbopack-tests/tests/snapshot/imports/resolve_error_cjs/input/index.js:1:13 Error resolving commonjs request - + v----------------------------v - 1 + const dne = require("does-not-exist/path"); - + ^----------------------------^ - 2 | - 3 | console.log(dne); - 4 | - - unable to resolve module "does-not-exist" with subpath "/path" - - | It was not possible to find the requested file. - | Parsed request as written in source code: module "does-not-exist" with subpath "/path" - | Path where resolving has started: [project]/crates/turbopack-tests/tests/snapshot/imports/resolve_error_cjs/input/index.js - | Type of request: commonjs request - | Import map: No import map entry - | \ No newline at end of file +PlainIssue { + severity: Error, + context: "[project]/crates/turbopack-tests/tests/snapshot/imports/resolve_error_cjs/input/index.js", + category: "resolve", + title: "Error resolving commonjs request", + description: "unable to resolve module \"does-not-exist\" with subpath \"/path\"", + detail: "It was not possible to find the requested file.\nParsed request as written in source code: module \"does-not-exist\" with subpath \"/path\"\nPath where resolving has started: [project]/crates/turbopack-tests/tests/snapshot/imports/resolve_error_cjs/input/index.js\nType of request: commonjs request\nImport map: No import map entry\n", + documentation_link: "", + source: Some( + PlainIssueSource { + asset: PlainSource { + ident: "[project]/crates/turbopack-tests/tests/snapshot/imports/resolve_error_cjs/input/index.js", + }, + start: SourcePos { + line: 0, + column: 13, + }, + end: SourcePos { + line: 0, + column: 43, + }, + }, + ), + sub_issues: [], + processing_path: Some( + [], + ), +} \ No newline at end of file diff --git a/crates/turbopack-tests/tests/snapshot/imports/resolve_error_esm/issues/Error resolving EcmaScript Modules request-aff400.txt b/crates/turbopack-tests/tests/snapshot/imports/resolve_error_esm/issues/Error resolving EcmaScript Modules request-aff400.txt index 1e1abc39b0f62..4258654d1eba2 100644 --- a/crates/turbopack-tests/tests/snapshot/imports/resolve_error_esm/issues/Error resolving EcmaScript Modules request-aff400.txt +++ b/crates/turbopack-tests/tests/snapshot/imports/resolve_error_esm/issues/Error resolving EcmaScript Modules request-aff400.txt @@ -1,9 +1,14 @@ -error - [resolve] [project]/crates/turbopack-tests/tests/snapshot/imports/resolve_error_esm/input/index.js Error resolving EcmaScript Modules request - unable to resolve module "does-not-exist" with subpath "/path" - - | It was not possible to find the requested file. - | Parsed request as written in source code: module "does-not-exist" with subpath "/path" - | Path where resolving has started: [project]/crates/turbopack-tests/tests/snapshot/imports/resolve_error_esm/input/index.js - | Type of request: EcmaScript Modules request - | Import map: No import map entry - | \ No newline at end of file +PlainIssue { + severity: Error, + context: "[project]/crates/turbopack-tests/tests/snapshot/imports/resolve_error_esm/input/index.js", + category: "resolve", + title: "Error resolving EcmaScript Modules request", + description: "unable to resolve module \"does-not-exist\" with subpath \"/path\"", + detail: "It was not possible to find the requested file.\nParsed request as written in source code: module \"does-not-exist\" with subpath \"/path\"\nPath where resolving has started: [project]/crates/turbopack-tests/tests/snapshot/imports/resolve_error_esm/input/index.js\nType of request: EcmaScript Modules request\nImport map: No import map entry\n", + documentation_link: "", + source: None, + sub_issues: [], + processing_path: Some( + [], + ), +} \ No newline at end of file From 732dd0158b64e110c38c90a31c6d1d1ba9fc9dd9 Mon Sep 17 00:00:00 2001 From: hrmny Date: Thu, 20 Jul 2023 16:38:31 +0200 Subject: [PATCH 16/16] glob fixes, though it seems it's fully recursive --- crates/turbopack-tests/build.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/crates/turbopack-tests/build.rs b/crates/turbopack-tests/build.rs index 2fe041a8dc58b..dff0f12de7bad 100644 --- a/crates/turbopack-tests/build.rs +++ b/crates/turbopack-tests/build.rs @@ -3,8 +3,7 @@ use turbo_tasks_build::{generate_register, rerun_if_glob}; fn main() { generate_register(); // The test/snapshot crate need to be rebuilt if any snapshots are added. - // Unfortunately, we can't have the build.rs file operate differently on - // each file, so the entire turbopack crate needs to be rebuilt. - rerun_if_glob("tests/execution/*/*/*/input", "tests/execution"); - rerun_if_glob("tests/snapshot/*/*/input", "tests/snapshot"); + rerun_if_glob("tests/execution/*/*/*", "tests/execution"); + rerun_if_glob("tests/execution/*/*/__skipped__/*", "tests/execution"); + rerun_if_glob("tests/snapshot/*/*", "tests/snapshot"); }