Commit 7b2d8614 authored by Luke Sandberg's avatar Luke Sandberg

Turbopack: extract WASM and Worker loading into importable `@turbopack/wasm-*`…

Turbopack: extract WASM and Worker loading into importable `@turbopack/wasm-*` and `@turbopack/worker-*` modules

Follow the pattern of #92549 (base64 extraction) to move rarely-used WASM loading
and Worker creation logic out of the always-shipped runtime into on-demand modules.

WASM loading is split into three environment-specific modules:
- `@turbopack/wasm-node` (uses fs/stream for Node.js)
- `@turbopack/wasm-dom` (uses fetch for browsers)
- `@turbopack/wasm-edge` (uses pre-compiled edge modules)

Worker creation is split into two modules:
- `@turbopack/worker-browser` (Web Worker / SharedWorker via URL params)
- `@turbopack/worker-node` (worker_threads with forwarded globals)

The runtime now exposes four new context shortcuts (`w`, `u`, `X`, `b`) that
provide environment-specific primitives (chunk URL resolution, asset suffix,
forwarded globals, chunk path resolution) which the extracted modules consume
via `__turbopack_*__` free variables.
Co-Authored-By: 's avatarClaude <noreply@anthropic.com>
parent ce33784b
......@@ -68,19 +68,6 @@ interface RuntimeBackend {
* Returns the same Promise for the same chunk URL.
*/
loadChunkCached: (sourceType: SourceType, chunkUrl: ChunkUrl) => Promise<void>
loadWebAssembly: (
sourceType: SourceType,
sourceData: SourceData,
wasmChunkPath: ChunkPath,
edgeModule: () => WebAssembly.Module,
importsObj: WebAssembly.Imports
) => Promise<Exports>
loadWebAssemblyModule: (
sourceType: SourceType,
sourceData: SourceData,
wasmChunkPath: ChunkPath,
edgeModule: () => WebAssembly.Module
) => Promise<WebAssembly.Module>
}
interface DevRuntimeBackend {
......@@ -290,51 +277,37 @@ function exportUrl(
browserContextPrototype.q = exportUrl
/**
* Creates a worker by instantiating the given WorkerConstructor with the
* appropriate URL and options.
*
* The entrypoint is a pre-compiled worker runtime file. The params configure
* which module chunks to load and which module to run as the entry point.
*
* The params are a JSON array of the following structure:
* `[TURBOPACK_NEXT_CHUNK_URLS, ASSET_SUFFIX, ...WORKER_FORWARDED_GLOBALS values]`
*
* @param WorkerConstructor The Worker or SharedWorker constructor
* @param entrypoint URL path to the worker entrypoint chunk
* @param moduleChunks list of module chunk paths to load
* @param workerOptions options to pass to the Worker constructor (optional)
* Returns the full chunk URL for a chunk path, including CHUNK_BASE_PATH prefix
* and ASSET_SUFFIX. Used by extracted worker/wasm modules.
*/
function createWorker(
WorkerConstructor: { new (url: URL, options?: object): Worker },
entrypoint: ChunkPath,
moduleChunks: ChunkPath[],
workerOptions?: object
): Worker {
const isSharedWorker = WorkerConstructor.name === 'SharedWorker'
const chunkUrls = moduleChunks
.map((chunk) => getChunkRelativeUrl(chunk))
.reverse()
const params: unknown[] = [chunkUrls, ASSET_SUFFIX]
for (const globalName of WORKER_FORWARDED_GLOBALS) {
params.push((globalThis as Record<string, unknown>)[globalName])
}
function chunkUrl(chunkPath: ChunkPath): ChunkUrl {
return getChunkRelativeUrl(chunkPath)
}
browserContextPrototype.w = chunkUrl
const url = new URL(getChunkRelativeUrl(entrypoint), location.origin)
const paramsJson = JSON.stringify(params)
if (isSharedWorker) {
url.searchParams.set('params', paramsJson)
} else {
url.hash = '#params=' + encodeURIComponent(paramsJson)
}
/**
* Returns the ASSET_SUFFIX string. Used by extracted worker modules.
*/
function assetSuffix(): string {
return ASSET_SUFFIX
}
browserContextPrototype.X = assetSuffix
/**
* Returns the list of worker-forwarded global names.
*/
function forwardedGlobals(): string[] {
return WORKER_FORWARDED_GLOBALS
}
browserContextPrototype.b = forwardedGlobals
// Remove type: "module" from options since our worker entrypoint is not a module
const options = workerOptions
? { ...workerOptions, type: undefined }
: undefined
return new WorkerConstructor(url, options)
/**
* Resolves a chunk path. On browser, returns the path as-is (not applicable).
*/
function resolveChunkPath(chunkPath: string): string {
return chunkPath
}
browserContextPrototype.b = createWorker
browserContextPrototype.u = resolveChunkPath
/**
* Instantiates a runtime module.
......@@ -435,33 +408,3 @@ function isJs(chunkUrlOrPath: ChunkUrl | ChunkPath): boolean {
function isCss(chunkUrl: ChunkUrl): boolean {
return endsWithExtension(chunkUrl, '.css')
}
function loadWebAssembly(
this: TurbopackBaseContext<Module>,
chunkPath: ChunkPath,
edgeModule: () => WebAssembly.Module,
importsObj: WebAssembly.Imports
): Promise<Exports> {
return BACKEND.loadWebAssembly(
SourceType.Parent,
this.m.id,
chunkPath,
edgeModule,
importsObj
)
}
contextPrototype.w = loadWebAssembly
function loadWebAssemblyModule(
this: TurbopackBaseContext<Module>,
chunkPath: ChunkPath,
edgeModule: () => WebAssembly.Module
): Promise<WebAssembly.Module> {
return BACKEND.loadWebAssemblyModule(
SourceType.Parent,
this.m.id,
chunkPath,
edgeModule
)
}
contextPrototype.u = loadWebAssemblyModule
......@@ -74,34 +74,6 @@ const chunkResolvers: Map<ChunkUrl, ChunkResolver> = new Map()
loadChunkCached(sourceType: SourceType, chunkUrl: ChunkUrl) {
return doLoadChunk(sourceType, chunkUrl)
},
async loadWebAssembly(
_sourceType: SourceType,
_sourceData: SourceData,
wasmChunkPath: ChunkPath,
_edgeModule: () => WebAssembly.Module,
importsObj: WebAssembly.Imports
): Promise<Exports> {
const req = fetchWebAssembly(wasmChunkPath)
const { instance } = await WebAssembly.instantiateStreaming(
req,
importsObj
)
return instance.exports
},
async loadWebAssemblyModule(
_sourceType: SourceType,
_sourceData: SourceData,
wasmChunkPath: ChunkPath,
_edgeModule: () => WebAssembly.Module
): Promise<WebAssembly.Module> {
const req = fetchWebAssembly(wasmChunkPath)
return await WebAssembly.compileStreaming(req)
},
}
function getOrCreateResolver(chunkUrl: ChunkUrl): ChunkResolver {
......@@ -229,8 +201,4 @@ const chunkResolvers: Map<ChunkUrl, ChunkResolver> = new Map()
resolver.loadingStarted = true
return resolver.promise
}
function fetchWebAssembly(wasmChunkPath: ChunkPath) {
return fetch(getChunkRelativeUrl(wasmChunkPath))
}
})()
......@@ -56,27 +56,6 @@ let BACKEND: RuntimeBackend
loadChunkCached(_sourceType: SourceType, _chunkUrl: ChunkUrl) {
throw new Error('chunk loading is not supported')
},
async loadWebAssembly(
_sourceType: SourceType,
_sourceData: SourceData,
chunkPath: ChunkPath,
edgeModule: () => WebAssembly.Module,
imports: WebAssembly.Imports
): Promise<Exports> {
const module = await loadEdgeWasm(chunkPath, edgeModule)
return await WebAssembly.instantiate(module, imports)
},
async loadWebAssemblyModule(
_sourceType: SourceType,
_sourceData: SourceData,
chunkPath: ChunkPath,
edgeModule: () => WebAssembly.Module
): Promise<WebAssembly.Module> {
return loadEdgeWasm(chunkPath, edgeModule)
},
}
const registeredChunks: Set<ChunkPath> = new Set()
......@@ -149,22 +128,4 @@ let BACKEND: RuntimeBackend
getOrInstantiateRuntimeModule(chunkPath, moduleId)
}
}
async function loadEdgeWasm(
chunkPath: ChunkPath,
edgeModule: () => WebAssembly.Module
): Promise<WebAssembly.Module> {
let module
try {
module = edgeModule()
} catch (_e) {}
if (!module) {
throw new Error(
`dynamically loading WebAssembly is not supported in this runtime as global was not injected for chunk '${chunkPath}'`
)
}
return module
}
})()
......@@ -27,7 +27,6 @@ nodeContextPrototype.M = moduleFactories
// Cast moduleCache to ModuleWithDirection for production mode
nodeContextPrototype.c = moduleCache as ModuleCache<ModuleWithDirection>
nodeContextPrototype.R = resolvePathFromModule
nodeContextPrototype.b = createWorker
nodeContextPrototype.C = clearChunkCache
function instantiateModule(
......
......@@ -36,7 +36,6 @@ nodeDevContextPrototype.q = exportUrl
nodeDevContextPrototype.M = moduleFactories
nodeDevContextPrototype.c = devModuleCache
nodeDevContextPrototype.R = resolvePathFromModule
nodeDevContextPrototype.b = createWorker
nodeDevContextPrototype.C = clearChunkCache
/**
......
......@@ -3,7 +3,6 @@
/// <reference path="../../shared/runtime/runtime-utils.ts" />
/// <reference path="../../shared-node/base-externals-utils.ts" />
/// <reference path="../../shared-node/node-externals-utils.ts" />
/// <reference path="../../shared-node/node-wasm-utils.ts" />
/// <reference path="./nodejs-globals.d.ts" />
/**
......@@ -143,58 +142,39 @@ function loadChunkAsyncByUrl<TModule extends Module>(
}
contextPrototype.L = loadChunkAsyncByUrl
function loadWebAssembly(
chunkPath: ChunkPath,
_edgeModule: () => WebAssembly.Module,
imports: WebAssembly.Imports
) {
const resolved = path.resolve(RUNTIME_ROOT, chunkPath)
return instantiateWebAssemblyFromPath(resolved, imports)
/**
* Returns the chunk path as-is. On Node.js, chunks are loaded by path.
*/
function chunkUrl(chunkPath: ChunkPath): string {
return chunkPath
}
contextPrototype.w = loadWebAssembly
contextPrototype.w = chunkUrl
function loadWebAssemblyModule(
chunkPath: ChunkPath,
_edgeModule: () => WebAssembly.Module
) {
const resolved = path.resolve(RUNTIME_ROOT, chunkPath)
return compileWebAssemblyFromPath(resolved)
/**
* Resolves a chunk path to an absolute filesystem path using RUNTIME_ROOT.
*/
function resolveChunkPath(chunkPath: string): string {
return path.resolve(RUNTIME_ROOT, chunkPath)
}
contextPrototype.u = loadWebAssemblyModule
contextPrototype.u = resolveChunkPath
/**
* Creates a Node.js worker thread by instantiating the given WorkerConstructor
* with the appropriate path and options, including forwarded globals.
*
* @param WorkerConstructor The Worker constructor from worker_threads
* @param workerPath Path to the worker entry chunk
* @param workerOptions options to pass to the Worker constructor (optional)
* Returns the list of worker-forwarded global names.
*/
function createWorker(
WorkerConstructor: { new (path: string, options?: object): unknown },
workerPath: string,
workerOptions?: { workerData?: unknown; [key: string]: unknown }
): unknown {
// Build the forwarded globals object
const forwardedGlobals: Record<string, unknown> = {}
for (const name of WORKER_FORWARDED_GLOBALS) {
forwardedGlobals[name] = (globalThis as Record<string, unknown>)[name]
}
// Merge workerData with forwarded globals
const existingWorkerData = workerOptions?.workerData || {}
const options = {
...workerOptions,
workerData: {
...(typeof existingWorkerData === 'object' ? existingWorkerData : {}),
__turbopack_globals__: forwardedGlobals,
},
}
function forwardedGlobals(): string[] {
return typeof WORKER_FORWARDED_GLOBALS !== 'undefined'
? WORKER_FORWARDED_GLOBALS
: []
}
contextPrototype.b = forwardedGlobals
return new WorkerConstructor(workerPath, options)
/**
* Returns the asset suffix (empty string on Node.js).
*/
function assetSuffix(): string {
return ''
}
contextPrototype.X = assetSuffix
const regexJsUrl = /\.js(?:\?[^#]*)?(?:#.*)?$/
/**
......
......@@ -63,15 +63,10 @@ type DynamicExport = (
type LoadChunk = (chunkPath: ChunkPath) => Promise<any> | undefined
type LoadChunkByUrl = (chunkUrl: ChunkUrl) => Promise<any> | undefined
type LoadWebAssembly = (
wasmChunkPath: ChunkPath,
edgeModule: () => WebAssembly.Module,
imports: WebAssembly.Imports
) => Exports
type LoadWebAssemblyModule = (
wasmChunkPath: ChunkPath,
edgeModule: () => WebAssembly.Module
) => WebAssembly.Module
type ChunkUrlResolver = (chunkPath: ChunkPath) => string
type ChunkPathResolver = (chunkPath: string) => string
type ForwardedGlobals = () => string[]
type AssetSuffix = () => string
type ModuleCache<M> = Record<ModuleId, M>
// TODO properly type values here
......@@ -97,11 +92,6 @@ type AsyncModule = (
) => void
type ResolveAbsolutePath = (modulePath?: string) => string
type GetWorkerURL = (
entrypoint: ChunkPath,
moduleChunks: ChunkPath[],
shared: boolean
) => URL
type ExternalRequire = (
id: DependencySpecifier,
......@@ -145,11 +135,12 @@ interface TurbopackBaseContext<M> {
M: ModuleFactories
l: LoadChunk
L: LoadChunkByUrl
w: LoadWebAssembly
u: LoadWebAssemblyModule
w: ChunkUrlResolver
u: ChunkPathResolver
P: ResolveAbsolutePath
U: RelativeURL
b: GetWorkerURL
b: ForwardedGlobals
X: AssetSuffix
x: ExternalRequire
y: ExternalImport
z: CommonJsRequire
......
/**
* Browser DOM WebAssembly loading module.
* Only included when a .wasm file is actually imported.
*/
'use turbopack no side effects'
declare function __turbopack_chunk_url__(chunkPath: string): string
export async function instantiateWebAssembly(
chunkPath: string,
_edgeModule: () => WebAssembly.Module,
imports: WebAssembly.Imports
): Promise<Record<string, unknown>> {
const url = __turbopack_chunk_url__(chunkPath)
const req = fetch(url)
const { instance } = await WebAssembly.instantiateStreaming(req, imports)
return instance.exports
}
export async function compileWebAssembly(
chunkPath: string,
_edgeModule: () => WebAssembly.Module
): Promise<WebAssembly.Module> {
const url = __turbopack_chunk_url__(chunkPath)
const req = fetch(url)
return await WebAssembly.compileStreaming(req)
}
/**
* Edge runtime WebAssembly loading module.
* Only included when a .wasm file is actually imported.
*/
'use turbopack no side effects'
async function loadEdgeWasm(
chunkPath: string,
edgeModule: () => WebAssembly.Module
): Promise<WebAssembly.Module> {
let module
try {
module = edgeModule()
} catch (_e) {}
if (!module) {
throw new Error(
`dynamically loading WebAssembly is not supported in this runtime as global was not injected for chunk '${chunkPath}'`
)
}
return module
}
export async function instantiateWebAssembly(
chunkPath: string,
edgeModule: () => WebAssembly.Module,
imports: WebAssembly.Imports
): Promise<Record<string, unknown>> {
const module = await loadEdgeWasm(chunkPath, edgeModule)
const instance = await WebAssembly.instantiate(module, imports)
return instance.exports
}
export async function compileWebAssembly(
chunkPath: string,
edgeModule: () => WebAssembly.Module
): Promise<WebAssembly.Module> {
return loadEdgeWasm(chunkPath, edgeModule)
}
/* eslint-disable @typescript-eslint/no-unused-vars */
/**
* Node.js WebAssembly loading module.
* Only included when a .wasm file is actually imported.
*/
/// <reference path="../shared/runtime/runtime-utils.ts" />
'use turbopack no side effects'
declare function __turbopack_resolve_chunk_path__(path: string): string
function readWebAssemblyAsResponse(path: string) {
const { createReadStream } = require('fs') as typeof import('fs')
......@@ -16,24 +23,25 @@ function readWebAssemblyAsResponse(path: string) {
})
}
async function compileWebAssemblyFromPath(
path: string
): Promise<WebAssembly.Module> {
const response = readWebAssemblyAsResponse(path)
export async function instantiateWebAssembly(
chunkPath: string,
_edgeModule: () => WebAssembly.Module,
imports: WebAssembly.Imports
): Promise<Record<string, unknown>> {
const resolved = __turbopack_resolve_chunk_path__(chunkPath)
const response = readWebAssemblyAsResponse(resolved)
return await WebAssembly.compileStreaming(response)
}
const { instance } = await WebAssembly.instantiateStreaming(response, imports)
async function instantiateWebAssemblyFromPath(
path: string,
importsObj: WebAssembly.Imports
): Promise<Exports> {
const response = readWebAssemblyAsResponse(path)
return instance.exports
}
const { instance } = await WebAssembly.instantiateStreaming(
response,
importsObj
)
export async function compileWebAssembly(
chunkPath: string,
_edgeModule: () => WebAssembly.Module
): Promise<WebAssembly.Module> {
const resolved = __turbopack_resolve_chunk_path__(chunkPath)
const response = readWebAssemblyAsResponse(resolved)
return instance.exports
return await WebAssembly.compileStreaming(response)
}
/**
* Browser worker creation module.
* Only included when a Web Worker or SharedWorker is actually used.
*/
'use turbopack no side effects'
declare function __turbopack_chunk_url__(chunkPath: string): string
declare function __turbopack_forwarded_globals__(): string[]
declare function __turbopack_asset_suffix__(): string
/**
* Creates a worker by instantiating the given WorkerConstructor with the
* appropriate URL and options.
*
* The entrypoint is a pre-compiled worker runtime file. The params configure
* which module chunks to load and which module to run as the entry point.
*
* The params are a JSON array of the following structure:
* `[TURBOPACK_NEXT_CHUNK_URLS, ASSET_SUFFIX, ...WORKER_FORWARDED_GLOBALS values]`
*
* @param WorkerConstructor The Worker or SharedWorker constructor
* @param entrypoint URL path to the worker entrypoint chunk
* @param moduleChunks list of module chunk paths to load
* @param workerOptions options to pass to the Worker constructor (optional)
*/
export function createWorker(
WorkerConstructor: { new (url: URL, options?: object): Worker },
entrypoint: string,
moduleChunks: string[],
workerOptions?: object
): Worker {
const isSharedWorker = WorkerConstructor.name === 'SharedWorker'
const chunkUrls = moduleChunks
.map((chunk) => __turbopack_chunk_url__(chunk))
.reverse()
const params: unknown[] = [chunkUrls, __turbopack_asset_suffix__()]
for (const globalName of __turbopack_forwarded_globals__()) {
params.push((globalThis as Record<string, unknown>)[globalName])
}
const url = new URL(__turbopack_chunk_url__(entrypoint), location.origin)
const paramsJson = JSON.stringify(params)
if (isSharedWorker) {
url.searchParams.set('params', paramsJson)
} else {
url.hash = '#params=' + encodeURIComponent(paramsJson)
}
// Remove type: "module" from options since our worker entrypoint is not a module
const options = workerOptions
? { ...workerOptions, type: undefined }
: undefined
return new WorkerConstructor(url, options)
}
/**
* Node.js worker creation module.
* Only included when a Node.js worker_threads Worker is actually used.
*/
'use turbopack no side effects'
declare function __turbopack_forwarded_globals__(): string[]
/**
* Creates a Node.js worker thread by instantiating the given WorkerConstructor
* with the appropriate path and options, including forwarded globals.
*
* @param WorkerConstructor The Worker constructor from worker_threads
* @param workerPath Path to the worker entry chunk
* @param workerOptions options to pass to the Worker constructor (optional)
*/
export function createWorker(
WorkerConstructor: { new (path: string, options?: object): unknown },
workerPath: string,
workerOptions?: { workerData?: unknown; [key: string]: unknown }
): unknown {
// Build the forwarded globals object
const forwardedGlobals: Record<string, unknown> = {}
for (const name of __turbopack_forwarded_globals__()) {
forwardedGlobals[name] = (globalThis as Record<string, unknown>)[name]
}
// Merge workerData with forwarded globals
const existingWorkerData = workerOptions?.workerData || {}
const options = {
...workerOptions,
workerData: {
...(typeof existingWorkerData === 'object' ? existingWorkerData : {}),
__turbopack_globals__: forwardedGlobals,
},
}
return new WorkerConstructor(workerPath, options)
}
......@@ -204,16 +204,6 @@ pub async fn get_browser_runtime_code(
.await?,
);
}
if *environment.supports_wasm().await? {
code.push_code(
&*embed_static_code(
asset_context,
rcstr!("shared-node/node-wasm-utils.ts"),
generate_source_map,
)
.await?,
);
}
for backend_code in runtime_backend_code {
code.push_code(
......
......@@ -64,7 +64,45 @@ pub async fn turbopack_runtime_import_map() -> Result<Vc<ImportMap>> {
// Exact alias: @turbopack/base64
import_map.insert_exact_alias(
rcstr!("@turbopack/base64"),
ImportMapping::PrimaryAlternative(rcstr!("./shared/base64.ts"), Some(embed_root))
ImportMapping::PrimaryAlternative(rcstr!("./shared/base64.ts"), Some(embed_root.clone()))
.resolved_cell(),
);
// WebAssembly loading modules (per-environment)
import_map.insert_exact_alias(
rcstr!("@turbopack/wasm-node"),
ImportMapping::PrimaryAlternative(
rcstr!("./shared/wasm-node.ts"),
Some(embed_root.clone()),
)
.resolved_cell(),
);
import_map.insert_exact_alias(
rcstr!("@turbopack/wasm-dom"),
ImportMapping::PrimaryAlternative(rcstr!("./shared/wasm-dom.ts"), Some(embed_root.clone()))
.resolved_cell(),
);
import_map.insert_exact_alias(
rcstr!("@turbopack/wasm-edge"),
ImportMapping::PrimaryAlternative(
rcstr!("./shared/wasm-edge.ts"),
Some(embed_root.clone()),
)
.resolved_cell(),
);
// Worker creation modules (per-environment)
import_map.insert_exact_alias(
rcstr!("@turbopack/worker-browser"),
ImportMapping::PrimaryAlternative(
rcstr!("./shared/worker-browser.ts"),
Some(embed_root.clone()),
)
.resolved_cell(),
);
import_map.insert_exact_alias(
rcstr!("@turbopack/worker-node"),
ImportMapping::PrimaryAlternative(rcstr!("./shared/worker-node.ts"), Some(embed_root))
.resolved_cell(),
);
......
......@@ -32,11 +32,6 @@ pub async fn get_nodejs_runtime_code(
rcstr!("shared-node/node-externals-utils.ts"),
generate_source_map,
);
let shared_node_wasm_utils_code = embed_static_code(
asset_context,
rcstr!("shared-node/node-wasm-utils.ts"),
generate_source_map,
);
// Runtime base is shared between production and development
let runtime_base_code = embed_static_code(
......@@ -49,7 +44,6 @@ pub async fn get_nodejs_runtime_code(
code.push_code(&*shared_runtime_utils_code.await?);
code.push_code(&*shared_base_external_utils_code.await?);
code.push_code(&*shared_node_external_utils_code.await?);
code.push_code(&*shared_node_wasm_utils_code.await?);
code.push_code(&*runtime_base_code.await?);
match runtime_type {
......
......@@ -83,20 +83,21 @@ pub const TURBOPACK_DYNAMIC: &TurbopackRuntimeFunctionShortcut = make_shortcut!(
pub const TURBOPACK_RESOLVE_ABSOLUTE_PATH: &TurbopackRuntimeFunctionShortcut = make_shortcut!("P");
pub const TURBOPACK_RELATIVE_URL: &TurbopackRuntimeFunctionShortcut = make_shortcut!("U");
pub const TURBOPACK_RESOLVE_MODULE_ID_PATH: &TurbopackRuntimeFunctionShortcut = make_shortcut!("R");
pub const TURBOPACK_CREATE_WORKER: &TurbopackRuntimeFunctionShortcut = make_shortcut!("b");
pub const TURBOPACK_ASYNC_MODULE: &TurbopackRuntimeFunctionShortcut = make_shortcut!("a");
pub const TURBOPACK_EXTERNAL_REQUIRE: &TurbopackRuntimeFunctionShortcut = make_shortcut!("x");
pub const TURBOPACK_EXTERNAL_IMPORT: &TurbopackRuntimeFunctionShortcut = make_shortcut!("y");
pub const TURBOPACK_REFRESH: &TurbopackRuntimeFunctionShortcut = make_shortcut!("k");
pub const TURBOPACK_REQUIRE_STUB: &TurbopackRuntimeFunctionShortcut = make_shortcut!("z");
pub const TURBOPACK_REQUIRE_REAL: &TurbopackRuntimeFunctionShortcut = make_shortcut!("t");
pub const TURBOPACK_WASM: &TurbopackRuntimeFunctionShortcut = make_shortcut!("w");
pub const TURBOPACK_WASM_MODULE: &TurbopackRuntimeFunctionShortcut = make_shortcut!("u");
pub const TURBOPACK_GLOBAL: &TurbopackRuntimeFunctionShortcut = make_shortcut!("g");
pub const TURBOPACK_CHUNK_URL: &TurbopackRuntimeFunctionShortcut = make_shortcut!("w");
pub const TURBOPACK_RESOLVE_CHUNK_PATH: &TurbopackRuntimeFunctionShortcut = make_shortcut!("u");
pub const TURBOPACK_FORWARDED_GLOBALS: &TurbopackRuntimeFunctionShortcut = make_shortcut!("b");
pub const TURBOPACK_ASSET_SUFFIX: &TurbopackRuntimeFunctionShortcut = make_shortcut!("X");
/// Adding an entry to this list will automatically ensure that `__turbopack_XXX__` can be called
/// from user code (by inserting a replacement into free_var_references)
pub const TURBOPACK_RUNTIME_FUNCTION_SHORTCUTS: [(&str, &TurbopackRuntimeFunctionShortcut); 23] = [
pub const TURBOPACK_RUNTIME_FUNCTION_SHORTCUTS: [(&str, &TurbopackRuntimeFunctionShortcut); 24] = [
("__turbopack_require__", TURBOPACK_REQUIRE),
("__turbopack_module_context__", TURBOPACK_MODULE_CONTEXT),
("__turbopack_import__", TURBOPACK_IMPORT),
......@@ -117,7 +118,6 @@ pub const TURBOPACK_RUNTIME_FUNCTION_SHORTCUTS: [(&str, &TurbopackRuntimeFunctio
"__turbopack_resolve_module_id_path__",
TURBOPACK_RESOLVE_MODULE_ID_PATH,
),
("__turbopack_create_worker__", TURBOPACK_CREATE_WORKER),
("__turbopack_external_require__", TURBOPACK_EXTERNAL_REQUIRE),
("__turbopack_external_import__", TURBOPACK_EXTERNAL_IMPORT),
("__turbopack_refresh__", TURBOPACK_REFRESH),
......@@ -127,6 +127,14 @@ pub const TURBOPACK_RUNTIME_FUNCTION_SHORTCUTS: [(&str, &TurbopackRuntimeFunctio
"__turbopack_clear_chunk_cache__",
TURBOPACK_CLEAR_CHUNK_CACHE,
),
("__turbopack_wasm__", TURBOPACK_WASM),
("__turbopack_wasm_module__", TURBOPACK_WASM_MODULE),
("__turbopack_chunk_url__", TURBOPACK_CHUNK_URL),
(
"__turbopack_resolve_chunk_path__",
TURBOPACK_RESOLVE_CHUNK_PATH,
),
(
"__turbopack_forwarded_globals__",
TURBOPACK_FORWARDED_GLOBALS,
),
("__turbopack_asset_suffix__", TURBOPACK_ASSET_SUFFIX),
];
use anyhow::{Result, bail};
use indoc::formatdoc;
use turbo_rcstr::rcstr;
use turbo_rcstr::{RcStr, rcstr};
use turbo_tasks::{ResolvedVc, TryJoinIterExt, ValueToString, Vc};
use turbopack_core::{
chunk::{
AsyncModuleInfo, ChunkData, ChunkGroupType, ChunkableModule, ChunkingContext,
ChunkingContextExt, ChunkingType, ChunksData, EvaluatableAsset,
ChunkingContextExt, ChunkingType, ChunksData, EvaluatableAsset, ModuleChunkItemIdExt,
availability_info::AvailabilityInfo,
},
context::AssetContext,
environment::ChunkLoading,
ident::AssetIdent,
module::{Module, ModuleSideEffects},
module_graph::{ModuleGraph, chunk_group_info::ChunkGroup},
output::{OutputAsset, OutputAssets, OutputAssetsWithReferenced},
reference::{ModuleReference, ModuleReferences},
resolve::ModuleResolveResult,
reference::{ModuleReference, ModuleReferences, SingleChunkableModuleReference},
reference_type::{EcmaScriptModulesReferenceSubType, ReferenceType},
resolve::{ExportUsage, ModuleResolveResult, parse::Request},
};
use super::worker_type::WorkerType;
......@@ -23,7 +25,7 @@ use crate::{
EcmascriptChunkItemContent, EcmascriptChunkItemOptions, EcmascriptChunkPlaceable,
EcmascriptExports, data::EcmascriptChunkData, ecmascript_chunk_item,
},
runtime_functions::{TURBOPACK_CREATE_WORKER, TURBOPACK_EXPORT_VALUE},
runtime_functions::{TURBOPACK_EXPORT_VALUE, TURBOPACK_REQUIRE},
utils::StringifyJs,
};
......@@ -52,6 +54,49 @@ impl WorkerLoaderModule {
})
}
/// Resolves the `@turbopack/worker-*` helper module for the current environment.
#[turbo_tasks::function]
async fn worker_helper_module(&self) -> Result<Vc<Box<dyn Module>>> {
let environment = self.asset_context.compile_time_info().environment();
let chunk_loading = &*environment.chunk_loading().await?;
let helper_request: RcStr = match chunk_loading {
ChunkLoading::NodeJs => rcstr!("@turbopack/worker-node"),
ChunkLoading::Edge | ChunkLoading::Dom => rcstr!("@turbopack/worker-browser"),
};
let origin_path = self.inner.ident().path().owned().await?;
let request = Request::parse_string(helper_request.clone());
let resolve_options = self.asset_context.resolve_options(origin_path.clone());
let result = self.asset_context.resolve_asset(
origin_path,
request,
resolve_options,
ReferenceType::EcmaScriptModules(EcmaScriptModulesReferenceSubType::Import),
);
let module = result.first_module().await?;
let Some(module) = *module else {
bail!(
"Could not resolve worker helper module '{}'",
helper_request
);
};
Ok(*module)
}
/// Gets the worker helper module as an EcmascriptChunkPlaceable.
#[turbo_tasks::function]
async fn worker_helper_placeable(
self: Vc<Self>,
) -> Result<Vc<Box<dyn EcmascriptChunkPlaceable>>> {
let module = self.worker_helper_module().to_resolved().await?;
let Some(placeable) = ResolvedVc::try_sidecast::<Box<dyn EcmascriptChunkPlaceable>>(module)
else {
bail!("Worker helper module was not processed into an EcmascriptChunkPlaceable");
};
Ok(*placeable)
}
#[turbo_tasks::function]
async fn chunk_group(
self: Vc<Self>,
......@@ -160,11 +205,25 @@ impl Module for WorkerLoaderModule {
#[turbo_tasks::function]
async fn references(self: Vc<Self>) -> Result<Vc<ModuleReferences>> {
let this = self.await?;
Ok(Vc::cell(vec![ResolvedVc::upcast(
let worker_ref =
WorkerModuleReference::new(*ResolvedVc::upcast(this.inner), this.worker_type)
.to_resolved()
.await?,
)]))
.await?;
// Add a reference to the worker helper module so it's included in the chunk
let helper_module = self.worker_helper_module().to_resolved().await?;
let helper_ref = SingleChunkableModuleReference::new(
*helper_module,
rcstr!("worker helper"),
ExportUsage::all(),
)
.to_resolved()
.await?;
Ok(Vc::cell(vec![
ResolvedVc::upcast(worker_ref),
ResolvedVc::upcast(helper_ref),
]))
}
#[turbo_tasks::function]
......@@ -219,10 +278,9 @@ impl EcmascriptChunkPlaceable for WorkerLoaderModule {
inner_code: formatdoc! {
r#"
{TURBOPACK_EXPORT_VALUE}(function(Ctor, opts) {{
return {TURBOPACK_CREATE_WORKER}(Ctor, __dirname + "/" + {worker_path:#}, opts);
return Ctor;
}});
"#,
worker_path = StringifyJs(&"a_fake_path_for_size_estimation"),
}
.into(),
options,
......@@ -231,6 +289,10 @@ impl EcmascriptChunkPlaceable for WorkerLoaderModule {
.cell());
}
// Get the worker helper module's chunk item ID for use in TURBOPACK_REQUIRE
let helper_placeable = self.worker_helper_placeable();
let helper_id = helper_placeable.chunk_item_id(chunking_context).await?;
let code = match this.worker_type {
WorkerType::WebWorker | WorkerType::SharedWebWorker => {
// For web workers, generate code that exports a function to create the worker.
......@@ -255,10 +317,12 @@ impl EcmascriptChunkPlaceable for WorkerLoaderModule {
formatdoc! {
r#"
var createWorker = {TURBOPACK_REQUIRE}({helper_id}).createWorker;
{TURBOPACK_EXPORT_VALUE}(function(Ctor, opts) {{
return {TURBOPACK_CREATE_WORKER}(Ctor, {entrypoint}, {chunks}, opts);
return createWorker(Ctor, {entrypoint}, {chunks}, opts);
}});
"#,
helper_id = StringifyJs(&helper_id),
entrypoint = StringifyJs(&entrypoint_path),
chunks = StringifyJs(&chunks_data),
}
......@@ -288,10 +352,12 @@ impl EcmascriptChunkPlaceable for WorkerLoaderModule {
// directory
formatdoc! {
r#"
var createWorker = {TURBOPACK_REQUIRE}({helper_id}).createWorker;
{TURBOPACK_EXPORT_VALUE}(function(Ctor, opts) {{
return {TURBOPACK_CREATE_WORKER}(Ctor, __dirname + "/" + {worker_path:#}, opts);
return createWorker(Ctor, __dirname + "/" + {worker_path:#}, opts);
}});
"#,
helper_id = StringifyJs(&helper_id),
worker_path = StringifyJs(entry_path.file_name()),
}
}
......
;!function(){try { var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&((e._debugIds|| (e._debugIds={}))[n]="6a138f62-859e-e13c-84a0-d111b048d46a")}catch(e){}}();
;!function(){try { var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&((e._debugIds|| (e._debugIds={}))[n]="f4476787-0394-ca0a-ac3d-03d90c7ca07d")}catch(e){}}();
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([
"output/1i9t_crates_turbopack-tests_tests_snapshot_debug-ids_browser_input_index_19boa0e.js",
{"otherChunks":["output/1do3_crates_turbopack-tests_tests_snapshot_debug-ids_browser_input_index_03ibyvs.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/debug-ids/browser/input/index.js [test] (ecmascript)"]}
......@@ -12,7 +12,6 @@ var CHUNK_BASE_PATH = "";
var RELATIVE_ROOT_PATH = "../../../../../../..";
var RUNTIME_PUBLIC_PATH = "";
var ASSET_SUFFIX = "";
var CROSS_ORIGIN = null;
var WORKER_FORWARDED_GLOBALS = [];
/**
* This file contains runtime types and functions that are shared between all
......@@ -733,44 +732,30 @@ browserContextPrototype.P = resolveAbsolutePath;
}
browserContextPrototype.q = exportUrl;
/**
* Creates a worker by instantiating the given WorkerConstructor with the
* appropriate URL and options.
*
* The entrypoint is a pre-compiled worker runtime file. The params configure
* which module chunks to load and which module to run as the entry point.
*
* The params are a JSON array of the following structure:
* `[TURBOPACK_NEXT_CHUNK_URLS, ASSET_SUFFIX, ...WORKER_FORWARDED_GLOBALS values]`
*
* @param WorkerConstructor The Worker or SharedWorker constructor
* @param entrypoint URL path to the worker entrypoint chunk
* @param moduleChunks list of module chunk paths to load
* @param workerOptions options to pass to the Worker constructor (optional)
*/ function createWorker(WorkerConstructor, entrypoint, moduleChunks, workerOptions) {
const isSharedWorker = WorkerConstructor.name === 'SharedWorker';
const chunkUrls = moduleChunks.map((chunk)=>getChunkRelativeUrl(chunk)).reverse();
const params = [
chunkUrls,
ASSET_SUFFIX
];
for (const globalName of WORKER_FORWARDED_GLOBALS){
params.push(globalThis[globalName]);
}
const url = new URL(getChunkRelativeUrl(entrypoint), location.origin);
const paramsJson = JSON.stringify(params);
if (isSharedWorker) {
url.searchParams.set('params', paramsJson);
} else {
url.hash = '#params=' + encodeURIComponent(paramsJson);
}
// Remove type: "module" from options since our worker entrypoint is not a module
const options = workerOptions ? {
...workerOptions,
type: undefined
} : undefined;
return new WorkerConstructor(url, options);
* Returns the full chunk URL for a chunk path, including CHUNK_BASE_PATH prefix
* and ASSET_SUFFIX. Used by extracted worker/wasm modules.
*/ function chunkUrl(chunkPath) {
return getChunkRelativeUrl(chunkPath);
}
browserContextPrototype.w = chunkUrl;
/**
* Returns the ASSET_SUFFIX string. Used by extracted worker modules.
*/ function assetSuffix() {
return ASSET_SUFFIX;
}
browserContextPrototype.b = createWorker;
browserContextPrototype.X = assetSuffix;
/**
* Returns the list of worker-forwarded global names.
*/ function forwardedGlobals() {
return WORKER_FORWARDED_GLOBALS;
}
browserContextPrototype.b = forwardedGlobals;
/**
* Resolves a chunk path. On browser, returns the path as-is (not applicable).
*/ function resolveChunkPath(chunkPath) {
return chunkPath;
}
browserContextPrototype.u = resolveChunkPath;
/**
* Instantiates a runtime module.
*/ function instantiateRuntimeModule(moduleId, chunkPath) {
......@@ -841,14 +826,6 @@ function isJs(chunkUrlOrPath) {
function isCss(chunkUrl) {
return endsWithExtension(chunkUrl, '.css');
}
function loadWebAssembly(chunkPath, edgeModule, importsObj) {
return BACKEND.loadWebAssembly(SourceType.Parent, this.m.id, chunkPath, edgeModule, importsObj);
}
contextPrototype.w = loadWebAssembly;
function loadWebAssemblyModule(chunkPath, edgeModule) {
return BACKEND.loadWebAssemblyModule(SourceType.Parent, this.m.id, chunkPath, edgeModule);
}
contextPrototype.u = loadWebAssemblyModule;
/// <reference path="./runtime-utils.ts" />
/// <reference path="./runtime-types.d.ts" />
/// <reference path="./dev-extensions.ts" />
......@@ -2006,15 +1983,6 @@ let BACKEND;
* has been loaded.
*/ loadChunkCached (sourceType, chunkUrl) {
return doLoadChunk(sourceType, chunkUrl);
},
async loadWebAssembly (_sourceType, _sourceData, wasmChunkPath, _edgeModule, importsObj) {
const req = fetchWebAssembly(wasmChunkPath);
const { instance } = await WebAssembly.instantiateStreaming(req, importsObj);
return instance.exports;
},
async loadWebAssemblyModule (_sourceType, _sourceData, wasmChunkPath, _edgeModule) {
const req = fetchWebAssembly(wasmChunkPath);
return await WebAssembly.compileStreaming(req);
}
};
function getOrCreateResolver(chunkUrl) {
......@@ -2084,7 +2052,6 @@ let BACKEND;
} else {
const link = document.createElement('link');
link.rel = 'stylesheet';
link.crossOrigin = CROSS_ORIGIN;
link.href = chunkUrl;
link.onerror = ()=>{
resolver.reject();
......@@ -2109,7 +2076,6 @@ let BACKEND;
}
} else {
const script = document.createElement('script');
script.crossOrigin = CROSS_ORIGIN;
script.src = chunkUrl;
// We'll only mark the chunk as loaded once the script has been executed,
// which happens in `registerChunk`. Hence the absence of `resolve()` in
......@@ -2127,9 +2093,6 @@ let BACKEND;
resolver.loadingStarted = true;
return resolver.promise;
}
function fetchWebAssembly(wasmChunkPath) {
return fetch(getChunkRelativeUrl(wasmChunkPath));
}
})();
/**
* This file contains the runtime code specific to the Turbopack development
......@@ -2185,7 +2148,6 @@ let DEV_BACKEND;
}
const link = document.createElement('link');
link.rel = 'stylesheet';
link.crossOrigin = CROSS_ORIGIN;
if (navigator.userAgent.includes('Firefox') || navigator.userAgent.includes('Safari') && !navigator.userAgent.includes('Chrome') && !navigator.userAgent.includes('Chromium')) {
// Firefox won't reload CSS files that were previously loaded on the
// current page: https://bugzilla.mozilla.org/show_bug.cgi?id=1037506
......@@ -2247,5 +2209,5 @@ chunkListsToRegister.forEach(registerChunkList);
})();
//# debugId=6a138f62-859e-e13c-84a0-d111b048d46a
//# debugId=f4476787-0394-ca0a-ac3d-03d90c7ca07d
//# sourceMappingURL=1do3_crates_turbopack-tests_tests_snapshot_debug-ids_browser_input_index_19boa0e.js.map
\ No newline at end of file
......@@ -640,31 +640,9 @@ const ABSOLUTE_ROOT = path.resolve(__filename, relativePathToDistRoot);
return ABSOLUTE_ROOT;
}
Context.prototype.P = resolveAbsolutePath;
/* eslint-disable @typescript-eslint/no-unused-vars */ /// <reference path="../shared/runtime/runtime-utils.ts" />
function readWebAssemblyAsResponse(path) {
const { createReadStream } = require('fs');
const { Readable } = require('stream');
const stream = createReadStream(path);
// @ts-ignore unfortunately there's a slight type mismatch with the stream.
return new Response(Readable.toWeb(stream), {
headers: {
'content-type': 'application/wasm'
}
});
}
async function compileWebAssemblyFromPath(path) {
const response = readWebAssemblyAsResponse(path);
return await WebAssembly.compileStreaming(response);
}
async function instantiateWebAssemblyFromPath(path, importsObj) {
const response = readWebAssemblyAsResponse(path);
const { instance } = await WebAssembly.instantiateStreaming(response, importsObj);
return instance.exports;
}
/* eslint-disable @typescript-eslint/no-unused-vars */ /// <reference path="../../shared/runtime/runtime-utils.ts" />
/// <reference path="../../shared-node/base-externals-utils.ts" />
/// <reference path="../../shared-node/node-externals-utils.ts" />
/// <reference path="../../shared-node/node-wasm-utils.ts" />
/// <reference path="./nodejs-globals.d.ts" />
/**
* Base Node.js runtime shared between production and development.
......@@ -768,40 +746,30 @@ function loadChunkAsyncByUrl(chunkUrl) {
return loadChunkAsync.call(this, path1);
}
contextPrototype.L = loadChunkAsyncByUrl;
function loadWebAssembly(chunkPath, _edgeModule, imports) {
const resolved = path.resolve(RUNTIME_ROOT, chunkPath);
return instantiateWebAssemblyFromPath(resolved, imports);
/**
* Returns the chunk path as-is. On Node.js, chunks are loaded by path.
*/ function chunkUrl(chunkPath) {
return chunkPath;
}
contextPrototype.w = loadWebAssembly;
function loadWebAssemblyModule(chunkPath, _edgeModule) {
const resolved = path.resolve(RUNTIME_ROOT, chunkPath);
return compileWebAssemblyFromPath(resolved);
contextPrototype.w = chunkUrl;
/**
* Resolves a chunk path to an absolute filesystem path using RUNTIME_ROOT.
*/ function resolveChunkPath(chunkPath) {
return path.resolve(RUNTIME_ROOT, chunkPath);
}
contextPrototype.u = loadWebAssemblyModule;
contextPrototype.u = resolveChunkPath;
/**
* Creates a Node.js worker thread by instantiating the given WorkerConstructor
* with the appropriate path and options, including forwarded globals.
*
* @param WorkerConstructor The Worker constructor from worker_threads
* @param workerPath Path to the worker entry chunk
* @param workerOptions options to pass to the Worker constructor (optional)
*/ function createWorker(WorkerConstructor, workerPath, workerOptions) {
// Build the forwarded globals object
const forwardedGlobals = {};
for (const name of WORKER_FORWARDED_GLOBALS){
forwardedGlobals[name] = globalThis[name];
}
// Merge workerData with forwarded globals
const existingWorkerData = workerOptions?.workerData || {};
const options = {
...workerOptions,
workerData: {
...typeof existingWorkerData === 'object' ? existingWorkerData : {},
__turbopack_globals__: forwardedGlobals
}
};
return new WorkerConstructor(workerPath, options);
* Returns the list of worker-forwarded global names.
*/ function forwardedGlobals() {
return typeof WORKER_FORWARDED_GLOBALS !== 'undefined' ? WORKER_FORWARDED_GLOBALS : [];
}
contextPrototype.b = forwardedGlobals;
/**
* Returns the asset suffix (empty string on Node.js).
*/ function assetSuffix() {
return '';
}
contextPrototype.X = assetSuffix;
const regexJsUrl = /\.js(?:\?[^#]*)?(?:#.*)?$/;
/**
* Checks if a given path/URL ends with .js, optionally followed by ?query or #fragment.
......@@ -1523,7 +1491,6 @@ nodeDevContextPrototype.q = exportUrl;
nodeDevContextPrototype.M = moduleFactories;
nodeDevContextPrototype.c = devModuleCache;
nodeDevContextPrototype.R = resolvePathFromModule;
nodeDevContextPrototype.b = createWorker;
nodeDevContextPrototype.C = clearChunkCache;
/**
* Instantiates a module in development mode using shared HMR logic.
......
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/0_9x_turbopack-tests_tests_snapshot_imports_ignore-comments_input_vercel_mjs_0r_m8l7._.js",
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/0_9x_turbopack-tests_tests_snapshot_imports_ignore-comments_input_vercel_mjs_1uszc59._.js",
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/imports/ignore-comments/input/vercel.mjs [test] (ecmascript, async loader)", ((__turbopack_context__) => {
__turbopack_context__.v((parentImport) => {
......
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([
"output/0rv8_turbopack-tests_tests_snapshot_imports_ignore-comments_input_index_1aqs1qt.js",
{"otherChunks":["output/0_9x_turbopack-tests_tests_snapshot_imports_ignore-comments_input_vercel_mjs_0r_m8l7._.js","output/1do3_crates_turbopack-tests_tests_snapshot_imports_ignore-comments_input_09jmqs-._.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/imports/ignore-comments/input/index.js [test] (ecmascript)"]}
"output/0rv8_turbopack-tests_tests_snapshot_imports_ignore-comments_input_index_1br45df.js",
{"otherChunks":["output/0_9x_turbopack-tests_tests_snapshot_imports_ignore-comments_input_vercel_mjs_1uszc59._.js","output/[root-of-the-server]__1gnyf0f._.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/imports/ignore-comments/input/index.js [test] (ecmascript)"]}
]);
// Dummy runtime
\ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/1do3_crates_turbopack-tests_tests_snapshot_imports_ignore-comments_input_09jmqs-._.js",
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/[root-of-the-server]__1gnyf0f._.js",
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/imports/ignore-comments/input/vercel.cjs [test] (ecmascript)", ((__turbopack_context__, module, exports) => {
module.exports = 'turbopack';
......@@ -6,10 +6,47 @@ module.exports = 'turbopack';
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/imports/ignore-comments/input/vercel.cjs (static in ecmascript)", ((__turbopack_context__) => {
__turbopack_context__.q("/static/vercel.0kkt412gy5vj6.cjs");}),
"[turbopack]/shared/worker-browser.ts [test] (ecmascript)", ((__turbopack_context__) => {
"use strict";
__turbopack_context__.s([
"createWorker",
()=>createWorker
]);
/**
* Browser worker creation module.
* Only included when a Web Worker or SharedWorker is actually used.
*/ /* eslint-disable @typescript-eslint/no-unused-vars */ 'use turbopack no side effects';
function createWorker(WorkerConstructor, entrypoint, moduleChunks, workerOptions) {
const isSharedWorker = WorkerConstructor.name === 'SharedWorker';
const chunkUrls = moduleChunks.map((chunk)=>__turbopack_chunk_url__(chunk)).reverse();
const params = [
chunkUrls,
__turbopack_asset_suffix__()
];
for (const globalName of __turbopack_forwarded_globals__()){
params.push(globalThis[globalName]);
}
const url = new URL(__turbopack_chunk_url__(entrypoint), location.origin);
const paramsJson = JSON.stringify(params);
if (isSharedWorker) {
url.searchParams.set('params', paramsJson);
} else {
url.hash = '#params=' + encodeURIComponent(paramsJson);
}
// Remove type: "module" from options since our worker entrypoint is not a module
const options = workerOptions ? {
...workerOptions,
type: undefined
} : undefined;
return new WorkerConstructor(url, options);
}
}),
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/imports/ignore-comments/input/vercel.cjs [test] (ecmascript, worker loader)", ((__turbopack_context__) => {
var createWorker = __turbopack_context__.r("[turbopack]/shared/worker-browser.ts [test] (ecmascript)").createWorker;
__turbopack_context__.v(function(Ctor, opts) {
return __turbopack_context__.b(Ctor, "output/0uxq_crates_turbopack-tests_tests_snapshot_imports_ignore-comments_output_0uy0mni._.js", ["output/0_9x_turbopack-tests_tests_snapshot_imports_ignore-comments_input_vercel_cjs_0j-fab5._.js","output/0rv8_turbopack-tests_tests_snapshot_imports_ignore-comments_input_vercel_cjs_02p77ng._.js"], opts);
return createWorker(Ctor, "output/0uxq_crates_turbopack-tests_tests_snapshot_imports_ignore-comments_output_0uy0mni._.js", ["output/0_9x_turbopack-tests_tests_snapshot_imports_ignore-comments_input_vercel_cjs_0j-fab5._.js","output/0rv8_turbopack-tests_tests_snapshot_imports_ignore-comments_input_vercel_cjs_02p77ng._.js"], opts);
});
}),
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/imports/ignore-comments/input/ignore-worker.cjs (static in ecmascript)", ((__turbopack_context__) => {
......@@ -45,4 +82,4 @@ function foo(plugin) {
}),
]);
//# sourceMappingURL=1do3_crates_turbopack-tests_tests_snapshot_imports_ignore-comments_input_09jmqs-._.js.map
\ No newline at end of file
//# sourceMappingURL=%5Broot-of-the-server%5D__1gnyf0f._.js.map
\ No newline at end of file
......@@ -3,5 +3,6 @@
"sources": [],
"sections": [
{"offset": {"line": 3, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/imports/ignore-comments/input/vercel.cjs"],"sourcesContent":["module.exports = 'turbopack'\n"],"names":["module","exports"],"mappings":"AAAAA,OAAOC,OAAO,GAAG"}},
{"offset": {"line": 20, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/imports/ignore-comments/input/index.js"],"sourcesContent":["import('./vercel.mjs').then(console.log)\nimport(/* webpackIgnore: false */ './vercel.mjs').then(console.log)\nconsole.log(require('./vercel.cjs'))\nnew Worker(\n /* turbopackIgnore: false */ new URL('./vercel.cjs', import.meta.url)\n)\n\n// turbopack shouldn't attempt to bundle these, and they should be preserved in the output\nimport(/* webpackIgnore: true */ './ignore.mjs')\nimport(/* turbopackIgnore: true */ './ignore.mjs')\n\n// this should work for cjs requires too\nrequire(/* webpackIgnore: true */ './ignore.cjs')\nrequire(/* turbopackIgnore: true */ './ignore.cjs')\n\nnew Worker(\n /* turbopackIgnore: true */ new URL('./ignore-worker.cjs', import.meta.url)\n)\nnew Worker(\n /* webpackIgnore: true */ new URL('./ignore-worker.cjs', import.meta.url)\n)\n\nexport function foo(plugin) {\n return require(/* turbopackIgnore: true */ plugin)\n}\n"],"names":["then","console","log","Worker","require","foo","plugin"],"mappings":";;;;;;;;;AAAA,gKAAuBA,IAAI,CAACC,QAAQC,GAAG;AACvC,gKAAkDF,IAAI,CAACC,QAAQC,GAAG;AAClED,QAAQC,GAAG;AACX,iKAAIC;AAIJ,0FAA0F;AAC1F,MAAM,CAAC,uBAAuB,GAAG;AACjC,MAAM,CAAC,yBAAyB,GAAG;AAEnC,wCAAwC;AACxCC,QAAQ,uBAAuB,GAAG;AAClCA,QAAQ,yBAAyB,GAAG;AAEpC,IAAID;AAGJ,IAAIA;AAIG,SAASE,IAAIC,MAAM;IACxB,OAAOF,QAAQ,yBAAyB,GAAGE;AAC7C"}}]
{"offset": {"line": 11, "column": 0}, "map": {"version":3,"sources":["turbopack:///[turbopack]/shared/worker-browser.ts"],"sourcesContent":["/**\n * Browser worker creation module.\n * Only included when a Web Worker or SharedWorker is actually used.\n */\n\n/* eslint-disable @typescript-eslint/no-unused-vars */\n\n'use turbopack no side effects'\n\ndeclare function __turbopack_chunk_url__(chunkPath: string): string\ndeclare function __turbopack_forwarded_globals__(): string[]\ndeclare function __turbopack_asset_suffix__(): string\n\n/**\n * Creates a worker by instantiating the given WorkerConstructor with the\n * appropriate URL and options.\n *\n * The entrypoint is a pre-compiled worker runtime file. The params configure\n * which module chunks to load and which module to run as the entry point.\n *\n * The params are a JSON array of the following structure:\n * `[TURBOPACK_NEXT_CHUNK_URLS, ASSET_SUFFIX, ...WORKER_FORWARDED_GLOBALS values]`\n *\n * @param WorkerConstructor The Worker or SharedWorker constructor\n * @param entrypoint URL path to the worker entrypoint chunk\n * @param moduleChunks list of module chunk paths to load\n * @param workerOptions options to pass to the Worker constructor (optional)\n */\nexport function createWorker(\n WorkerConstructor: { new (url: URL, options?: object): Worker },\n entrypoint: string,\n moduleChunks: string[],\n workerOptions?: object\n): Worker {\n const isSharedWorker = WorkerConstructor.name === 'SharedWorker'\n\n const chunkUrls = moduleChunks\n .map((chunk) => __turbopack_chunk_url__(chunk))\n .reverse()\n const params: unknown[] = [chunkUrls, __turbopack_asset_suffix__()]\n for (const globalName of __turbopack_forwarded_globals__()) {\n params.push((globalThis as Record<string, unknown>)[globalName])\n }\n\n const url = new URL(__turbopack_chunk_url__(entrypoint), location.origin)\n const paramsJson = JSON.stringify(params)\n if (isSharedWorker) {\n url.searchParams.set('params', paramsJson)\n } else {\n url.hash = '#params=' + encodeURIComponent(paramsJson)\n }\n\n // Remove type: \"module\" from options since our worker entrypoint is not a module\n const options = workerOptions\n ? { ...workerOptions, type: undefined }\n : undefined\n return new WorkerConstructor(url, options)\n}\n"],"names":["createWorker","WorkerConstructor","entrypoint","moduleChunks","workerOptions","isSharedWorker","name","chunkUrls","map","chunk","__turbopack_chunk_url__","reverse","params","__turbopack_asset_suffix__","globalName","__turbopack_forwarded_globals__","push","globalThis","url","URL","location","origin","paramsJson","JSON","stringify","searchParams","set","hash","encodeURIComponent","options","type","undefined"],"mappings":";;;;AAAA;;;CAGC,GAED,oDAAoD,GAEpD;AAqBO,SAASA,aACdC,iBAA+D,EAC/DC,UAAkB,EAClBC,YAAsB,EACtBC,aAAsB;IAEtB,MAAMC,iBAAiBJ,kBAAkBK,IAAI,KAAK;IAElD,MAAMC,YAAYJ,aACfK,GAAG,CAAC,CAACC,QAAUC,wBAAwBD,QACvCE,OAAO;IACV,MAAMC,SAAoB;QAACL;QAAWM;KAA6B;IACnE,KAAK,MAAMC,cAAcC,kCAAmC;QAC1DH,OAAOI,IAAI,CAAC,AAACC,UAAsC,CAACH,WAAW;IACjE;IAEA,MAAMI,MAAM,IAAIC,IAAIT,wBAAwBR,aAAakB,SAASC,MAAM;IACxE,MAAMC,aAAaC,KAAKC,SAAS,CAACZ;IAClC,IAAIP,gBAAgB;QAClBa,IAAIO,YAAY,CAACC,GAAG,CAAC,UAAUJ;IACjC,OAAO;QACLJ,IAAIS,IAAI,GAAG,aAAaC,mBAAmBN;IAC7C;IAEA,iFAAiF;IACjF,MAAMO,UAAUzB,gBACZ;QAAE,GAAGA,aAAa;QAAE0B,MAAMC;IAAU,IACpCA;IACJ,OAAO,IAAI9B,kBAAkBiB,KAAKW;AACpC","ignoreList":[0]}},
{"offset": {"line": 57, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/imports/ignore-comments/input/index.js"],"sourcesContent":["import('./vercel.mjs').then(console.log)\nimport(/* webpackIgnore: false */ './vercel.mjs').then(console.log)\nconsole.log(require('./vercel.cjs'))\nnew Worker(\n /* turbopackIgnore: false */ new URL('./vercel.cjs', import.meta.url)\n)\n\n// turbopack shouldn't attempt to bundle these, and they should be preserved in the output\nimport(/* webpackIgnore: true */ './ignore.mjs')\nimport(/* turbopackIgnore: true */ './ignore.mjs')\n\n// this should work for cjs requires too\nrequire(/* webpackIgnore: true */ './ignore.cjs')\nrequire(/* turbopackIgnore: true */ './ignore.cjs')\n\nnew Worker(\n /* turbopackIgnore: true */ new URL('./ignore-worker.cjs', import.meta.url)\n)\nnew Worker(\n /* webpackIgnore: true */ new URL('./ignore-worker.cjs', import.meta.url)\n)\n\nexport function foo(plugin) {\n return require(/* turbopackIgnore: true */ plugin)\n}\n"],"names":["then","console","log","Worker","require","foo","plugin"],"mappings":";;;;;;;;;AAAA,gKAAuBA,IAAI,CAACC,QAAQC,GAAG;AACvC,gKAAkDF,IAAI,CAACC,QAAQC,GAAG;AAClED,QAAQC,GAAG;AACX,iKAAIC;AAIJ,0FAA0F;AAC1F,MAAM,CAAC,uBAAuB,GAAG;AACjC,MAAM,CAAC,yBAAyB,GAAG;AAEnC,wCAAwC;AACxCC,QAAQ,uBAAuB,GAAG;AAClCA,QAAQ,yBAAyB,GAAG;AAEpC,IAAID;AAGJ,IAAIA;AAIG,SAASE,IAAIC,MAAM;IACxB,OAAOF,QAAQ,yBAAyB,GAAGE;AAC7C"}}]
}
\ No newline at end of file
......@@ -640,31 +640,9 @@ const ABSOLUTE_ROOT = path.resolve(__filename, relativePathToDistRoot);
return ABSOLUTE_ROOT;
}
Context.prototype.P = resolveAbsolutePath;
/* eslint-disable @typescript-eslint/no-unused-vars */ /// <reference path="../shared/runtime/runtime-utils.ts" />
function readWebAssemblyAsResponse(path) {
const { createReadStream } = require('fs');
const { Readable } = require('stream');
const stream = createReadStream(path);
// @ts-ignore unfortunately there's a slight type mismatch with the stream.
return new Response(Readable.toWeb(stream), {
headers: {
'content-type': 'application/wasm'
}
});
}
async function compileWebAssemblyFromPath(path) {
const response = readWebAssemblyAsResponse(path);
return await WebAssembly.compileStreaming(response);
}
async function instantiateWebAssemblyFromPath(path, importsObj) {
const response = readWebAssemblyAsResponse(path);
const { instance } = await WebAssembly.instantiateStreaming(response, importsObj);
return instance.exports;
}
/* eslint-disable @typescript-eslint/no-unused-vars */ /// <reference path="../../shared/runtime/runtime-utils.ts" />
/// <reference path="../../shared-node/base-externals-utils.ts" />
/// <reference path="../../shared-node/node-externals-utils.ts" />
/// <reference path="../../shared-node/node-wasm-utils.ts" />
/// <reference path="./nodejs-globals.d.ts" />
/**
* Base Node.js runtime shared between production and development.
......@@ -768,40 +746,30 @@ function loadChunkAsyncByUrl(chunkUrl) {
return loadChunkAsync.call(this, path1);
}
contextPrototype.L = loadChunkAsyncByUrl;
function loadWebAssembly(chunkPath, _edgeModule, imports) {
const resolved = path.resolve(RUNTIME_ROOT, chunkPath);
return instantiateWebAssemblyFromPath(resolved, imports);
/**
* Returns the chunk path as-is. On Node.js, chunks are loaded by path.
*/ function chunkUrl(chunkPath) {
return chunkPath;
}
contextPrototype.w = loadWebAssembly;
function loadWebAssemblyModule(chunkPath, _edgeModule) {
const resolved = path.resolve(RUNTIME_ROOT, chunkPath);
return compileWebAssemblyFromPath(resolved);
contextPrototype.w = chunkUrl;
/**
* Resolves a chunk path to an absolute filesystem path using RUNTIME_ROOT.
*/ function resolveChunkPath(chunkPath) {
return path.resolve(RUNTIME_ROOT, chunkPath);
}
contextPrototype.u = loadWebAssemblyModule;
contextPrototype.u = resolveChunkPath;
/**
* Creates a Node.js worker thread by instantiating the given WorkerConstructor
* with the appropriate path and options, including forwarded globals.
*
* @param WorkerConstructor The Worker constructor from worker_threads
* @param workerPath Path to the worker entry chunk
* @param workerOptions options to pass to the Worker constructor (optional)
*/ function createWorker(WorkerConstructor, workerPath, workerOptions) {
// Build the forwarded globals object
const forwardedGlobals = {};
for (const name of WORKER_FORWARDED_GLOBALS){
forwardedGlobals[name] = globalThis[name];
}
// Merge workerData with forwarded globals
const existingWorkerData = workerOptions?.workerData || {};
const options = {
...workerOptions,
workerData: {
...typeof existingWorkerData === 'object' ? existingWorkerData : {},
__turbopack_globals__: forwardedGlobals
}
};
return new WorkerConstructor(workerPath, options);
* Returns the list of worker-forwarded global names.
*/ function forwardedGlobals() {
return typeof WORKER_FORWARDED_GLOBALS !== 'undefined' ? WORKER_FORWARDED_GLOBALS : [];
}
contextPrototype.b = forwardedGlobals;
/**
* Returns the asset suffix (empty string on Node.js).
*/ function assetSuffix() {
return '';
}
contextPrototype.X = assetSuffix;
const regexJsUrl = /\.js(?:\?[^#]*)?(?:#.*)?$/;
/**
* Checks if a given path/URL ends with .js, optionally followed by ?query or #fragment.
......@@ -821,7 +789,6 @@ nodeContextPrototype.M = moduleFactories;
// Cast moduleCache to ModuleWithDirection for production mode
nodeContextPrototype.c = moduleCache;
nodeContextPrototype.R = resolvePathFromModule;
nodeContextPrototype.b = createWorker;
nodeContextPrototype.C = clearChunkCache;
function instantiateModule(id, sourceType, sourceData) {
const moduleFactory = moduleFactories.get(id);
......
......@@ -5,7 +5,6 @@
{"offset": {"line": 4, "column": 0}, "map": {"version":3,"sources":["turbopack:///[turbopack]/shared/runtime/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 @typescript-eslint/no-unused-vars */\n\n/// <reference path=\"./runtime-types.d.ts\" />\n\ntype EsmNamespaceObject = Record<string, any>\n\n/**\n * Describes why a module was instantiated.\n * Shared between browser and Node.js runtimes.\n */\nenum SourceType {\n /**\n * The module was instantiated because it was included in an evaluated chunk's\n * runtime.\n * SourceData is a ChunkPath.\n */\n Runtime = 0,\n /**\n * The module was instantiated because a parent module imported it.\n * SourceData is a ModuleId.\n */\n Parent = 1,\n /**\n * The module was instantiated because it was included in a chunk's hot module\n * update.\n * SourceData is an array of ModuleIds or undefined.\n */\n Update = 2,\n}\n\ntype SourceData = ChunkPath | ModuleId | ModuleId[] | undefined\n\n// @ts-ignore Defined in `dev-base.ts`\ndeclare function getOrInstantiateModuleFromParent<M>(\n id: ModuleId,\n sourceModule: M\n): M\n\n// @ts-ignore Defined in `hmr-runtime.ts` (dev mode only)\ndeclare let devModuleCache: Record<ModuleId, any> | undefined\n\n/**\n * Flag indicating which module object type to create when a module is merged. Set to `true`\n * by each runtime that uses ModuleWithDirection (browser dev-base.ts, nodejs dev-base.ts,\n * nodejs build-base.ts). Browser production (build-base.ts) leaves it as `false` since it\n * uses plain Module objects.\n */\nlet createModuleWithDirectionFlag = false\n\nconst REEXPORTED_OBJECTS = new WeakMap<Module, ReexportedObjects>()\n\n/**\n * Constructs the `__turbopack_context__` object for a module.\n */\nfunction Context(\n this: TurbopackBaseContext<Module>,\n module: Module,\n exports: Exports\n) {\n this.m = module\n // We need to store this here instead of accessing it from the module object to:\n // 1. Make it available to factories directly, since we rewrite `this` to\n // `__turbopack_context__.e` in CJS modules.\n // 2. Support async modules which rewrite `module.exports` to a promise, so we\n // can still access the original exports object from functions like\n // `esmExport`\n // Ideally we could find a new approach for async modules and drop this property altogether.\n this.e = exports\n}\nconst contextPrototype = Context.prototype as TurbopackBaseContext<Module>\n\ntype ModuleContextMap = Record<ModuleId, ModuleContextEntry>\n\ninterface ModuleContextEntry {\n id: () => ModuleId\n module: () => any\n}\n\ninterface ModuleContext {\n // require call\n (moduleId: string): Exports | EsmNamespaceObject\n\n // async import call\n import(moduleId: string): Promise<Exports | EsmNamespaceObject>\n\n keys(): ModuleId[]\n\n resolve(moduleId: string): ModuleId\n}\n\ntype GetOrInstantiateModuleFromParent<M extends Module> = (\n moduleId: M['id'],\n parentModule: M\n) => M\n\ndeclare function getOrInstantiateRuntimeModule(\n chunkPath: ChunkPath,\n moduleId: ModuleId\n): Module\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<any>\n) {\n if (!hasOwnProperty.call(obj, name)) Object.defineProperty(obj, name, options)\n}\n\nfunction getOverwrittenModule(\n moduleCache: ModuleCache<Module>,\n id: ModuleId\n): Module {\n let module = moduleCache[id]\n if (!module) {\n if (createModuleWithDirectionFlag) {\n // set in development modes for hmr support\n module = createModuleWithDirection(id)\n } else {\n module = createModuleObject(id)\n }\n moduleCache[id] = module\n }\n return module\n}\n\n/**\n * Creates the module object. Only done here to ensure all module objects have the same shape.\n */\nfunction createModuleObject(id: ModuleId): Module {\n return {\n exports: {},\n error: undefined,\n id,\n namespaceObject: undefined,\n }\n}\n\nfunction createModuleWithDirection(id: ModuleId): ModuleWithDirection {\n return {\n exports: {},\n error: undefined,\n id,\n namespaceObject: undefined,\n parents: [],\n children: [],\n }\n}\n\ntype BindingTag = 0\nconst BindingTag_Value = 0 as BindingTag\n\n// an arbitrary sequence of bindings as\n// - a prop name\n// - BindingTag_Value, a value to be bound directly, or\n// - 1 or 2 functions to bind as getters and sdetters\ntype EsmBindings = Array<\n string | BindingTag | (() => unknown) | ((v: unknown) => void) | unknown\n>\n\n/**\n * Adds the getters to the exports object.\n */\nfunction esm(exports: Exports, bindings: EsmBindings) {\n defineProp(exports, '__esModule', { value: true })\n if (toStringTag) defineProp(exports, toStringTag, { value: 'Module' })\n let i = 0\n while (i < bindings.length) {\n const propName = bindings[i++] as string\n const tagOrFunction = bindings[i++]\n if (typeof tagOrFunction === 'number') {\n if (tagOrFunction === BindingTag_Value) {\n defineProp(exports, propName, {\n value: bindings[i++],\n enumerable: true,\n writable: false,\n })\n } else {\n throw new Error(`unexpected tag: ${tagOrFunction}`)\n }\n } else {\n const getterFn = tagOrFunction as () => unknown\n if (typeof bindings[i] === 'function') {\n const setterFn = bindings[i++] as (v: unknown) => void\n defineProp(exports, propName, {\n get: getterFn,\n set: setterFn,\n enumerable: true,\n })\n } else {\n defineProp(exports, propName, {\n get: getterFn,\n enumerable: true,\n })\n }\n }\n }\n Object.seal(exports)\n}\n\n/**\n * Makes the module an ESM with exports\n */\nfunction esmExport(\n this: TurbopackBaseContext<Module>,\n bindings: EsmBindings,\n id: ModuleId | undefined\n) {\n let module: Module\n let exports: Module['exports']\n if (id != null) {\n module = getOverwrittenModule(this.c, id)\n exports = module.exports\n } else {\n module = this.m\n exports = this.e\n }\n module.namespaceObject = exports\n esm(exports, bindings)\n}\ncontextPrototype.s = esmExport\n\ntype ReexportedObjects = Record<PropertyKey, unknown>[]\nfunction ensureDynamicExports(\n module: Module,\n exports: Exports\n): ReexportedObjects {\n let reexportedObjects: ReexportedObjects | undefined =\n REEXPORTED_OBJECTS.get(module)\n\n if (!reexportedObjects) {\n REEXPORTED_OBJECTS.set(module, (reexportedObjects = []))\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 return reexportedObjects\n}\n\n/**\n * Dynamically exports properties from an object\n */\nfunction dynamicExport(\n this: TurbopackBaseContext<Module>,\n object: Record<string, any>,\n id: ModuleId | undefined\n) {\n let module: Module\n let exports: Exports\n if (id != null) {\n module = getOverwrittenModule(this.c, id)\n exports = module.exports\n } else {\n module = this.m\n exports = this.e\n }\n const reexportedObjects = ensureDynamicExports(module, exports)\n\n if (typeof object === 'object' && object !== null) {\n reexportedObjects.push(object)\n }\n}\ncontextPrototype.j = dynamicExport\n\nfunction exportValue(\n this: TurbopackBaseContext<Module>,\n value: any,\n id: ModuleId | undefined\n) {\n let module: Module\n if (id != null) {\n module = getOverwrittenModule(this.c, id)\n } else {\n module = this.m\n }\n module.exports = value\n}\ncontextPrototype.v = exportValue\n\nfunction exportNamespace(\n this: TurbopackBaseContext<Module>,\n namespace: any,\n id: ModuleId | undefined\n) {\n let module: Module\n if (id != null) {\n module = getOverwrittenModule(this.c, id)\n } else {\n module = this.m\n }\n module.exports = module.namespaceObject = namespace\n}\ncontextPrototype.n = exportNamespace\n\nfunction createGetter(obj: Record<string | symbol, any>, 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 bindings: EsmBindings = []\n let defaultLocation = -1\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 bindings.push(key, createGetter(raw, key))\n if (defaultLocation === -1 && key === 'default') {\n defaultLocation = bindings.length - 1\n }\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 && defaultLocation >= 0)) {\n // Replace the binding with one for the namespace itself in order to preserve iteration order.\n if (defaultLocation >= 0) {\n // Replace the getter with the value\n bindings.splice(defaultLocation, 1, BindingTag_Value, raw)\n } else {\n bindings.push('default', BindingTag_Value, raw)\n }\n }\n\n esm(ns, bindings)\n return ns\n}\n\nfunction createNS(raw: Module['exports']): EsmNamespaceObject {\n if (typeof raw === 'function') {\n return function (this: any, ...args: any[]) {\n return raw.apply(this, args)\n }\n } else {\n return Object.create(null)\n }\n}\n\nfunction esmImport(\n this: TurbopackBaseContext<Module>,\n id: ModuleId\n): Exclude<Module['namespaceObject'], undefined> {\n const module = getOrInstantiateModuleFromParent(id, this.m)\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 createNS(raw),\n raw && (raw as any).__esModule\n ))\n}\ncontextPrototype.i = esmImport\n\nfunction asyncLoader(\n this: TurbopackBaseContext<Module>,\n moduleId: ModuleId\n): Promise<Exports> {\n const loader = this.r(moduleId) as (\n importFunction: EsmImport\n ) => Promise<Exports>\n return loader(esmImport.bind(this))\n}\ncontextPrototype.A = asyncLoader\n\n// Add a simple runtime require so that environments without one can still pass\n// `typeof require` CommonJS checks so that exports are correctly registered.\nconst runtimeRequire =\n // @ts-ignore\n typeof require === 'function'\n ? // @ts-ignore\n require\n : function require() {\n throw new Error('Unexpected use of runtime require')\n }\ncontextPrototype.t = runtimeRequire\n\nfunction commonJsRequire(\n this: TurbopackBaseContext<Module>,\n id: ModuleId\n): Exports {\n return getOrInstantiateModuleFromParent(id, this.m).exports\n}\ncontextPrototype.r = commonJsRequire\n\n/**\n * Remove fragments and query parameters since they are never part of the context map keys\n *\n * This matches how we parse patterns at resolving time. Arguably we should only do this for\n * strings passed to `import` but the resolve does it for `import` and `require` and so we do\n * here as well.\n */\nfunction parseRequest(request: string): string {\n // Per the URI spec fragments can contain `?` characters, so we should trim it off first\n // https://datatracker.ietf.org/doc/html/rfc3986#section-3.5\n const hashIndex = request.indexOf('#')\n if (hashIndex !== -1) {\n request = request.substring(0, hashIndex)\n }\n\n const queryIndex = request.indexOf('?')\n if (queryIndex !== -1) {\n request = request.substring(0, queryIndex)\n }\n\n return request\n}\n/**\n * `require.context` and require/import expression runtime.\n */\nfunction moduleContext(map: ModuleContextMap): ModuleContext {\n function moduleContext(id: string): Exports {\n id = parseRequest(id)\n if (hasOwnProperty.call(map, id)) {\n return map[id].module()\n }\n\n const e = new Error(`Cannot find module '${id}'`)\n ;(e as any).code = 'MODULE_NOT_FOUND'\n throw e\n }\n\n moduleContext.keys = (): string[] => {\n return Object.keys(map)\n }\n\n moduleContext.resolve = (id: string): ModuleId => {\n id = parseRequest(id)\n if (hasOwnProperty.call(map, id)) {\n return map[id].id()\n }\n\n const e = new Error(`Cannot find module '${id}'`)\n ;(e as any).code = 'MODULE_NOT_FOUND'\n throw e\n }\n\n moduleContext.import = async (id: string) => {\n return await (moduleContext(id) as Promise<Exports>)\n }\n\n return moduleContext\n}\ncontextPrototype.f = moduleContext\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<T = any>(maybePromise: any): maybePromise is Promise<T> {\n return (\n maybePromise != null &&\n typeof maybePromise === 'object' &&\n 'then' in maybePromise &&\n typeof maybePromise.then === 'function'\n )\n}\n\nfunction isAsyncModuleExt<T extends {}>(obj: T): obj is AsyncModuleExt & T {\n return turbopackQueues in obj\n}\n\nfunction createPromise<T>() {\n let resolve: (value: T | PromiseLike<T>) => void\n let reject: (reason?: any) => void\n\n const promise = new Promise<T>((res, rej) => {\n reject = rej\n resolve = res\n })\n\n return {\n promise,\n resolve: resolve!,\n reject: reject!,\n }\n}\n\n// Load the CompressedmoduleFactories of a chunk into the `moduleFactories` Map.\n// The CompressedModuleFactories format is\n// - 1 or more module ids\n// - a module factory function\n// So walking this is a little complex but the flat structure is also fast to\n// traverse, we can use `typeof` operators to distinguish the two cases.\nfunction installCompressedModuleFactories(\n chunkModules: CompressedModuleFactories,\n offset: number,\n moduleFactories: ModuleFactories,\n newModuleId?: (id: ModuleId) => void\n) {\n let i = offset\n while (i < chunkModules.length) {\n let end = i + 1\n // Find our factory function\n while (\n end < chunkModules.length &&\n typeof chunkModules[end] !== 'function'\n ) {\n end++\n }\n if (end === chunkModules.length) {\n throw new Error('malformed chunk format, expected a factory function')\n }\n\n // Install the factory for each module ID that doesn't already have one.\n // When some IDs in this group already have a factory, reuse that existing\n // group factory for the missing IDs to keep all IDs in the group consistent.\n // Otherwise, install the factory from this chunk.\n const moduleFactoryFn = chunkModules[end] as Function\n let existingGroupFactory: Function | undefined = undefined\n for (let j = i; j < end; j++) {\n const id = chunkModules[j] as ModuleId\n const existingFactory = moduleFactories.get(id)\n if (existingFactory) {\n existingGroupFactory = existingFactory\n break\n }\n }\n const factoryToInstall = existingGroupFactory ?? moduleFactoryFn\n\n let didInstallFactory = false\n for (let j = i; j < end; j++) {\n const id = chunkModules[j] as ModuleId\n if (!moduleFactories.has(id)) {\n if (!didInstallFactory) {\n if (factoryToInstall === moduleFactoryFn) {\n applyModuleFactoryName(moduleFactoryFn)\n }\n didInstallFactory = true\n }\n moduleFactories.set(id, factoryToInstall)\n newModuleId?.(id)\n }\n }\n i = end + 1 // end is pointing at the last factory advance to the next id or the end of the array.\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\nconst enum QueueStatus {\n Unknown = -1,\n Unresolved = 0,\n Resolved = 1,\n}\n\ntype AsyncQueueFn = (() => void) & { queueCount: number }\ntype AsyncQueue = AsyncQueueFn[] & {\n status: QueueStatus\n}\n\nfunction resolveQueue(queue?: AsyncQueue) {\n if (queue && queue.status !== QueueStatus.Resolved) {\n queue.status = QueueStatus.Resolved\n queue.forEach((fn) => fn.queueCount--)\n queue.forEach((fn) => (fn.queueCount-- ? fn.queueCount++ : fn()))\n }\n}\n\ntype Dep = Exports | AsyncModulePromise | Promise<Exports>\n\ntype AsyncModuleExt = {\n [turbopackQueues]: (fn: (queue: AsyncQueue) => void) => void\n [turbopackExports]: Exports\n [turbopackError]?: any\n}\n\ntype AsyncModulePromise<T = Exports> = Promise<T> & AsyncModuleExt\n\nfunction wrapDeps(deps: Dep[]): AsyncModuleExt[] {\n return deps.map((dep): AsyncModuleExt => {\n if (dep !== null && typeof dep === 'object') {\n if (isAsyncModuleExt(dep)) return dep\n if (isPromise(dep)) {\n const queue: AsyncQueue = Object.assign([], {\n status: QueueStatus.Unresolved,\n })\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 return {\n [turbopackExports]: dep,\n [turbopackQueues]: () => {},\n }\n })\n}\n\nfunction asyncModule(\n this: TurbopackBaseContext<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 module = this.m\n const queue: AsyncQueue | undefined = hasAwait\n ? Object.assign([], { status: QueueStatus.Unknown })\n : undefined\n\n const depQueues: Set<AsyncQueue> = new Set()\n\n const { resolve, reject, promise: rawPromise } = createPromise<Exports>()\n\n const promise: AsyncModulePromise = Object.assign(rawPromise, {\n [turbopackExports]: module.exports,\n [turbopackQueues]: (fn) => {\n queue && fn(queue)\n depQueues.forEach(fn)\n promise['catch'](() => {})\n },\n } satisfies AsyncModuleExt)\n\n const attributes: PropertyDescriptor = {\n get(): any {\n return promise\n },\n set(v: any) {\n // Calling `esmExport` leads to this.\n if (v !== promise) {\n promise[turbopackExports] = v\n }\n },\n }\n\n Object.defineProperty(module, 'exports', attributes)\n Object.defineProperty(module, 'namespaceObject', attributes)\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.status === QueueStatus.Unresolved) {\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(promise[turbopackExports])\n }\n\n resolveQueue(queue)\n }\n\n body(handleAsyncDependencies, asyncResult)\n\n if (queue && queue.status === QueueStatus.Unknown) {\n queue.status = QueueStatus.Unresolved\n }\n}\ncontextPrototype.a = asyncModule\n\n/**\n * A pseudo \"fake\" URL object to resolve to its relative path.\n *\n * When UrlRewriteBehavior is set to relative, calls to the `new URL()` will construct url without base using this\n * runtime function to generate context-agnostic urls between different rendering context, i.e ssr / client to avoid\n * hydration mismatch.\n *\n * This is based on webpack's existing implementation:\n * https://github.com/webpack/webpack/blob/87660921808566ef3b8796f8df61bd79fc026108/lib/runtime/RelativeUrlRuntimeModule.js\n */\nconst relativeURL = function relativeURL(this: any, inputUrl: string) {\n const realUrl = new URL(inputUrl, 'x:/')\n const values: Record<string, any> = {}\n for (const key in realUrl) values[key] = (realUrl as any)[key]\n values.href = inputUrl\n values.pathname = inputUrl.replace(/[?#].*/, '')\n values.origin = values.protocol = ''\n values.toString = values.toJSON = (..._args: Array<any>) => inputUrl\n for (const key in values)\n Object.defineProperty(this, key, {\n enumerable: true,\n configurable: true,\n value: values[key],\n })\n}\nrelativeURL.prototype = URL.prototype\ncontextPrototype.U = relativeURL\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\n/**\n * Constructs an error message for when a module factory is not available.\n */\nfunction factoryNotAvailableMessage(\n moduleId: ModuleId,\n sourceType: SourceType,\n sourceData: SourceData\n): string {\n let instantiationReason: string\n switch (sourceType) {\n case SourceType.Runtime:\n instantiationReason = `as a runtime entry of chunk ${sourceData}`\n break\n case SourceType.Parent:\n instantiationReason = `because it was required from module ${sourceData}`\n break\n case SourceType.Update:\n instantiationReason = 'because of an HMR update'\n break\n default:\n invariant(\n sourceType,\n (sourceType) => `Unknown source type: ${sourceType}`\n )\n }\n return `Module ${moduleId} was instantiated ${instantiationReason}, but the module factory is not available.`\n}\n\n/**\n * A stub function to make `require` available but non-functional in ESM.\n */\nfunction requireStub(_moduleId: ModuleId): never {\n throw new Error('dynamic usage of require is not supported')\n}\ncontextPrototype.z = requireStub\n\n// Make `globalThis` available to the module in a way that cannot be shadowed by a local variable.\ncontextPrototype.g = globalThis\n\ntype ContextConstructor<M> = {\n new (module: Module, exports: Exports): TurbopackBaseContext<M>\n}\n\nfunction applyModuleFactoryName(factory: Function) {\n // Give the module factory a nice name to improve stack traces.\n Object.defineProperty(factory, 'name', {\n value: 'module evaluation',\n })\n}\n"],"names":["SourceType","createModuleWithDirectionFlag","REEXPORTED_OBJECTS","WeakMap","Context","module","exports","m","e","contextPrototype","prototype","hasOwnProperty","Object","toStringTag","Symbol","defineProp","obj","name","options","call","defineProperty","getOverwrittenModule","moduleCache","id","createModuleWithDirection","createModuleObject","error","undefined","namespaceObject","parents","children","BindingTag_Value","esm","bindings","value","i","length","propName","tagOrFunction","enumerable","writable","Error","getterFn","setterFn","get","set","seal","esmExport","c","s","ensureDynamicExports","reexportedObjects","Proxy","target","prop","Reflect","ownKeys","keys","key","includes","push","dynamicExport","object","j","exportValue","v","exportNamespace","namespace","n","createGetter","getProto","getPrototypeOf","__proto__","LEAF_PROTOTYPES","interopEsm","raw","ns","allowExportDefault","defaultLocation","current","getOwnPropertyNames","splice","createNS","args","apply","create","esmImport","getOrInstantiateModuleFromParent","__esModule","asyncLoader","moduleId","loader","r","bind","A","runtimeRequire","require","require1","t","commonJsRequire","parseRequest","request","hashIndex","indexOf","substring","queryIndex","moduleContext","map","code","resolve","import","f","getChunkPath","chunkData","path","isPromise","maybePromise","then","isAsyncModuleExt","turbopackQueues","createPromise","reject","promise","Promise","res","rej","installCompressedModuleFactories","chunkModules","offset","moduleFactories","newModuleId","end","moduleFactoryFn","existingGroupFactory","existingFactory","factoryToInstall","didInstallFactory","has","applyModuleFactoryName","turbopackExports","turbopackError","resolveQueue","queue","status","forEach","fn","queueCount","wrapDeps","deps","dep","assign","err","asyncModule","body","hasAwait","depQueues","Set","rawPromise","attributes","handleAsyncDependencies","currentDeps","getResult","d","fnQueue","q","add","asyncResult","a","relativeURL","inputUrl","realUrl","URL","values","href","pathname","replace","origin","protocol","toString","toJSON","_args","configurable","U","invariant","never","computeMessage","factoryNotAvailableMessage","sourceType","sourceData","instantiationReason","requireStub","_moduleId","z","g","globalThis","factory"],"mappings":"AAAA;;;;;CAKC,GAED,oDAAoD,GAEpD,6CAA6C;AAI7C;;;CAGC,GACD,IAAA,AAAKA,oCAAAA;IACH;;;;GAIC;IAED;;;GAGC;IAED;;;;GAIC;WAhBEA;EAAAA;AA+BL;;;;;CAKC,GACD,IAAIC,gCAAgC;AAEpC,MAAMC,qBAAqB,IAAIC;AAE/B;;CAEC,GACD,SAASC,QAEPC,MAAc,EACdC,OAAgB;IAEhB,IAAI,CAACC,CAAC,G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AC,GAAGd;AAErB;;CAEC,GACD,SAASe,UAAUC,KAAY,EAAEC,cAAoC;IACnE,MAAM,IAAIhJ,MAAM,CAAC,WAAW,EAAEgJ,eAAeD,QAAQ;AACvD;AAEA;;CAEC,GACD,SAASE,2BACPhG,QAAkB,EAClBiG,UAAsB,EACtBC,UAAsB;IAEtB,IAAIC;IACJ,OAAQF;QACN;YACEE,sBAAsB,CAAC,4BAA4B,EAAED,YAAY;YACjE;QACF;YACEC,sBAAsB,CAAC,oCAAoC,EAAED,YAAY;YACzE;QACF;YACEC,sBAAsB;YACtB;QACF;YACEN,UACEI,YACA,CAACA,aAAe,CAAC,qBAAqB,EAAEA,YAAY;IAE1D;IACA,OAAO,CAAC,OAAO,EAAEjG,SAAS,kBAAkB,EAAEmG,oBAAoB,0CAA0C,CAAC;AAC/G;AAEA;;CAEC,GACD,SAASC,YAAYC,SAAmB;IACtC,MAAM,IAAItJ,MAAM;AAClB;AACAhC,iBAAiBuL,CAAC,GAAGF;AAErB,kGAAkG;AAClGrL,iBAAiBwL,CAAC,GAAGC;AAMrB,SAASxD,uBAAuByD,OAAiB;IAC/C,+DAA+D;IAC/DvL,OAAOQ,cAAc,CAAC+K,SAAS,QAAQ;QACrCjK,OAAO;IACT;AACF","ignoreList":[0]}},
{"offset": {"line": 580, "column": 0}, "map": {"version":3,"sources":["turbopack:///[turbopack]/shared-node/base-externals-utils.ts"],"sourcesContent":["/// <reference path=\"../shared/runtime/runtime-utils.ts\" />\n\n/// A 'base' utilities to support runtime can have externals.\n/// Currently this is for node.js / edge runtime both.\n/// If a fn requires node.js specific behavior, it should be placed in `node-external-utils` instead.\n\nasync function externalImport(id: DependencySpecifier) {\n let raw\n try {\n raw = await import(id)\n } catch (err) {\n // TODO(alexkirsz) This can happen when a client-side module tries to load\n // an external module we don't provide a shim for (e.g. querystring, url).\n // For now, we fail semi-silently, but in the future this should be a\n // compilation error.\n throw new Error(`Failed to load external module ${id}: ${err}`)\n }\n\n if (raw && raw.__esModule && raw.default && 'default' in raw.default) {\n return interopEsm(raw.default, createNS(raw), true)\n }\n\n return raw\n}\ncontextPrototype.y = externalImport\n\nfunction externalRequire(\n id: ModuleId,\n thunk: () => any,\n esm: boolean = false\n): Exports | EsmNamespaceObject {\n let raw\n try {\n raw = thunk()\n } catch (err) {\n // TODO(alexkirsz) This can happen when a client-side module tries to load\n // an external module we don't provide a shim for (e.g. querystring, url).\n // For now, we fail semi-silently, but in the future this should be a\n // compilation error.\n throw new Error(`Failed to load external module ${id}: ${err}`)\n }\n\n if (!esm || raw.__esModule) {\n return raw\n }\n\n return interopEsm(raw, createNS(raw), true)\n}\n\nexternalRequire.resolve = (\n id: string,\n options?: {\n paths?: string[]\n }\n) => {\n return require.resolve(id, options)\n}\ncontextPrototype.x = externalRequire\n"],"names":["externalImport","id","raw","err","Error","__esModule","default","interopEsm","createNS","contextPrototype","y","externalRequire","thunk","esm","resolve","options","require","x"],"mappings":"AAAA,2DAA2D;AAE3D,6DAA6D;AAC7D,sDAAsD;AACtD,qGAAqG;AAErG,eAAeA,eAAeC,EAAuB;IACnD,IAAIC;IACJ,IAAI;QACFA,MAAM,MAAM,MAAM,CAACD;IACrB,EAAE,OAAOE,KAAK;QACZ,0EAA0E;QAC1E,0EAA0E;QAC1E,qEAAqE;QACrE,qBAAqB;QACrB,MAAM,IAAIC,MAAM,CAAC,+BAA+B,EAAEH,GAAG,EAAE,EAAEE,KAAK;IAChE;IAEA,IAAID,OAAOA,IAAIG,UAAU,IAAIH,IAAII,OAAO,IAAI,aAAaJ,IAAII,OAAO,EAAE;QACpE,OAAOC,WAAWL,IAAII,OAAO,EAAEE,SAASN,MAAM;IAChD;IAEA,OAAOA;AACT;AACAO,iBAAiBC,CAAC,GAAGV;AAErB,SAASW,gBACPV,EAAY,EACZW,KAAgB,EAChBC,MAAe,KAAK;IAEpB,IAAIX;IACJ,IAAI;QACFA,MAAMU;IACR,EAAE,OAAOT,KAAK;QACZ,0EAA0E;QAC1E,0EAA0E;QAC1E,qEAAqE;QACrE,qBAAqB;QACrB,MAAM,IAAIC,MAAM,CAAC,+BAA+B,EAAEH,GAAG,EAAE,EAAEE,KAAK;IAChE;IAEA,IAAI,CAACU,OAAOX,IAAIG,UAAU,EAAE;QAC1B,OAAOH;IACT;IAEA,OAAOK,WAAWL,KAAKM,SAASN,MAAM;AACxC;AAEAS,gBAAgBG,OAAO,GAAG,CACxBb,IACAc;IAIA,OAAOC,QAAQF,OAAO,CAACb,IAAIc;AAC7B;AACAN,iBAAiBQ,CAAC,GAAGN","ignoreList":[0]}},
{"offset": {"line": 621, "column": 0}, "map": {"version":3,"sources":["turbopack:///[turbopack]/shared-node/node-externals-utils.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\n\ndeclare var RUNTIME_PUBLIC_PATH: string\ndeclare var RELATIVE_ROOT_PATH: string\ndeclare var ASSET_PREFIX: string\n\nconst path = require('path')\n\nconst relativePathToRuntimeRoot = path.relative(RUNTIME_PUBLIC_PATH, '.')\n// Compute the relative path to the `distDir`.\nconst relativePathToDistRoot = path.join(\n relativePathToRuntimeRoot,\n RELATIVE_ROOT_PATH\n)\nconst RUNTIME_ROOT = path.resolve(__filename, relativePathToRuntimeRoot)\n// Compute the absolute path to the root, by stripping distDir from the absolute path to this file.\nconst ABSOLUTE_ROOT = path.resolve(__filename, relativePathToDistRoot)\n\n/**\n * Returns an absolute path to the given module path.\n * Module path should be relative, either path to a file or a directory.\n *\n * This fn allows to calculate an absolute path for some global static values, such as\n * `__dirname` or `import.meta.url` that Turbopack will not embeds in compile time.\n * See ImportMetaBinding::code_generation for the usage.\n */\nfunction resolveAbsolutePath(modulePath?: string): string {\n if (modulePath) {\n return path.join(ABSOLUTE_ROOT, modulePath)\n }\n return ABSOLUTE_ROOT\n}\nContext.prototype.P = resolveAbsolutePath\n"],"names":["path","require","relativePathToRuntimeRoot","relative","RUNTIME_PUBLIC_PATH","relativePathToDistRoot","join","RELATIVE_ROOT_PATH","RUNTIME_ROOT","resolve","__filename","ABSOLUTE_ROOT","resolveAbsolutePath","modulePath","Context","prototype","P"],"mappings":"AAAA,oDAAoD,GAMpD,MAAMA,OAAOC,QAAQ;AAErB,MAAMC,4BAA4BF,KAAKG,QAAQ,CAACC,qBAAqB;AACrE,8CAA8C;AAC9C,MAAMC,yBAAyBL,KAAKM,IAAI,CACtCJ,2BACAK;AAEF,MAAMC,eAAeR,KAAKS,OAAO,CAACC,YAAYR;AAC9C,mGAAmG;AACnG,MAAMS,gBAAgBX,KAAKS,OAAO,CAACC,YAAYL;AAE/C;;;;;;;CAOC,GACD,SAASO,oBAAoBC,UAAmB;IAC9C,IAAIA,YAAY;QACd,OAAOb,KAAKM,IAAI,CAACK,eAAeE;IAClC;IACA,OAAOF;AACT;AACAG,QAAQC,SAAS,CAACC,CAAC,GAAGJ","ignoreList":[0]}},
{"offset": {"line": 642, "column": 0}, "map": {"version":3,"sources":["turbopack:///[turbopack]/shared-node/node-wasm-utils.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\n\n/// <reference path=\"../shared/runtime/runtime-utils.ts\" />\n\nfunction readWebAssemblyAsResponse(path: string) {\n const { createReadStream } = require('fs') as typeof import('fs')\n const { Readable } = require('stream') as typeof import('stream')\n\n const stream = createReadStream(path)\n\n // @ts-ignore unfortunately there's a slight type mismatch with the stream.\n return new Response(Readable.toWeb(stream), {\n headers: {\n 'content-type': 'application/wasm',\n },\n })\n}\n\nasync function compileWebAssemblyFromPath(\n path: string\n): Promise<WebAssembly.Module> {\n const response = readWebAssemblyAsResponse(path)\n\n return await WebAssembly.compileStreaming(response)\n}\n\nasync function instantiateWebAssemblyFromPath(\n path: string,\n importsObj: WebAssembly.Imports\n): Promise<Exports> {\n const response = readWebAssemblyAsResponse(path)\n\n const { instance } = await WebAssembly.instantiateStreaming(\n response,\n importsObj\n )\n\n return instance.exports\n}\n"],"names":["readWebAssemblyAsResponse","path","createReadStream","require","Readable","stream","Response","toWeb","headers","compileWebAssemblyFromPath","response","WebAssembly","compileStreaming","instantiateWebAssemblyFromPath","importsObj","instance","instantiateStreaming","exports"],"mappings":"AAAA,oDAAoD,GAEpD,2DAA2D;AAE3D,SAASA,0BAA0BC,IAAY;IAC7C,MAAM,EAAEC,gBAAgB,EAAE,GAAGC,QAAQ;IACrC,MAAM,EAAEC,QAAQ,EAAE,GAAGD,QAAQ;IAE7B,MAAME,SAASH,iBAAiBD;IAEhC,2EAA2E;IAC3E,OAAO,IAAIK,SAASF,SAASG,KAAK,CAACF,SAAS;QAC1CG,SAAS;YACP,gBAAgB;QAClB;IACF;AACF;AAEA,eAAeC,2BACbR,IAAY;IAEZ,MAAMS,WAAWV,0BAA0BC;IAE3C,OAAO,MAAMU,YAAYC,gBAAgB,CAACF;AAC5C;AAEA,eAAeG,+BACbZ,IAAY,EACZa,UAA+B;IAE/B,MAAMJ,WAAWV,0BAA0BC;IAE3C,MAAM,EAAEc,QAAQ,EAAE,GAAG,MAAMJ,YAAYK,oBAAoB,CACzDN,UACAI;IAGF,OAAOC,SAASE,OAAO;AACzB","ignoreList":[0]}},
{"offset": {"line": 663, "column": 0}, "map": {"version":3,"sources":["turbopack:///[turbopack]/nodejs/runtime/runtime-base.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\n\n/// <reference path=\"../../shared/runtime/runtime-utils.ts\" />\n/// <reference path=\"../../shared-node/base-externals-utils.ts\" />\n/// <reference path=\"../../shared-node/node-externals-utils.ts\" />\n/// <reference path=\"../../shared-node/node-wasm-utils.ts\" />\n/// <reference path=\"./nodejs-globals.d.ts\" />\n\n/**\n * Base Node.js runtime shared between production and development.\n * Contains chunk loading, module caching, and other non-HMR functionality.\n */\n\nprocess.env.TURBOPACK = '1'\n\nconst url = require('url') as typeof import('url')\n\nconst moduleFactories: ModuleFactories = new Map()\nconst moduleCache: ModuleCache<Module> = Object.create(null)\n\n/**\n * Returns an absolute path to the given module's id.\n */\nfunction resolvePathFromModule(\n this: TurbopackBaseContext<Module>,\n moduleId: string\n): string {\n const exported = this.r(moduleId)\n const exportedPath = exported?.default ?? exported\n if (typeof exportedPath !== 'string') {\n return exported as any\n }\n\n const strippedAssetPrefix = exportedPath.slice(ASSET_PREFIX.length)\n const resolved = path.resolve(RUNTIME_ROOT, strippedAssetPrefix)\n\n return url.pathToFileURL(resolved).href\n}\n\n/**\n * Exports a URL value. No suffix is added in Node.js runtime.\n */\nfunction exportUrl(\n this: TurbopackBaseContext<Module>,\n urlValue: string,\n id: ModuleId | undefined\n) {\n exportValue.call(this, urlValue, id)\n}\n\nfunction loadRuntimeChunk(sourcePath: ChunkPath, chunkData: ChunkData): void {\n if (typeof chunkData === 'string') {\n loadRuntimeChunkPath(sourcePath, chunkData)\n } else {\n loadRuntimeChunkPath(sourcePath, chunkData.path)\n }\n}\n\nconst loadedChunks = new Set<ChunkPath>()\nconst unsupportedLoadChunk = Promise.resolve(undefined)\nconst loadedChunk: Promise<void> = Promise.resolve(undefined)\nconst chunkCache = new Map<ChunkPath, Promise<void>>()\n\nfunction clearChunkCache() {\n chunkCache.clear()\n loadedChunks.clear()\n}\n\nfunction loadRuntimeChunkPath(\n sourcePath: ChunkPath,\n chunkPath: ChunkPath\n): void {\n if (!isJs(chunkPath)) {\n // We only support loading JS chunks in Node.js.\n // This branch can be hit when trying to load a CSS chunk.\n return\n }\n\n if (loadedChunks.has(chunkPath)) {\n return\n }\n\n try {\n const resolved = path.resolve(RUNTIME_ROOT, chunkPath)\n const chunkModules: CompressedModuleFactories = require(resolved)\n installCompressedModuleFactories(chunkModules, 0, moduleFactories)\n loadedChunks.add(chunkPath)\n } catch (cause) {\n let errorMessage = `Failed to load chunk ${chunkPath}`\n\n if (sourcePath) {\n errorMessage += ` from runtime for chunk ${sourcePath}`\n }\n\n const error = new Error(errorMessage, { cause })\n error.name = 'ChunkLoadError'\n throw error\n }\n}\n\nfunction loadChunkAsync<TModule extends Module>(\n this: TurbopackBaseContext<TModule>,\n chunkData: ChunkData\n): Promise<void> {\n const chunkPath = typeof chunkData === 'string' ? chunkData : chunkData.path\n if (!isJs(chunkPath)) {\n // We only support loading JS chunks in Node.js.\n // This branch can be hit when trying to load a CSS chunk.\n return unsupportedLoadChunk\n }\n\n let entry = chunkCache.get(chunkPath)\n if (entry === undefined) {\n try {\n // resolve to an absolute path to simplify `require` handling\n const resolved = path.resolve(RUNTIME_ROOT, chunkPath)\n // TODO: consider switching to `import()` to enable concurrent chunk loading and async file io\n // However this is incompatible with hot reloading (since `import` doesn't use the require cache)\n const chunkModules: CompressedModuleFactories = require(resolved)\n installCompressedModuleFactories(chunkModules, 0, moduleFactories)\n entry = loadedChunk\n } catch (cause) {\n const errorMessage = `Failed to load chunk ${chunkPath} from module ${this.m.id}`\n const error = new Error(errorMessage, { cause })\n error.name = 'ChunkLoadError'\n\n // Cache the failure promise, future requests will also get this same rejection\n entry = Promise.reject(error)\n }\n chunkCache.set(chunkPath, entry)\n }\n // TODO: Return an instrumented Promise that React can use instead of relying on referential equality.\n return entry\n}\ncontextPrototype.l = loadChunkAsync\n\nfunction loadChunkAsyncByUrl<TModule extends Module>(\n this: TurbopackBaseContext<TModule>,\n chunkUrl: string\n) {\n const path = url.fileURLToPath(new URL(chunkUrl, RUNTIME_ROOT)) as ChunkPath\n return loadChunkAsync.call(this, path)\n}\ncontextPrototype.L = loadChunkAsyncByUrl\n\nfunction loadWebAssembly(\n chunkPath: ChunkPath,\n _edgeModule: () => WebAssembly.Module,\n imports: WebAssembly.Imports\n) {\n const resolved = path.resolve(RUNTIME_ROOT, chunkPath)\n\n return instantiateWebAssemblyFromPath(resolved, imports)\n}\ncontextPrototype.w = loadWebAssembly\n\nfunction loadWebAssemblyModule(\n chunkPath: ChunkPath,\n _edgeModule: () => WebAssembly.Module\n) {\n const resolved = path.resolve(RUNTIME_ROOT, chunkPath)\n\n return compileWebAssemblyFromPath(resolved)\n}\ncontextPrototype.u = loadWebAssemblyModule\n\n/**\n * Creates a Node.js worker thread by instantiating the given WorkerConstructor\n * with the appropriate path and options, including forwarded globals.\n *\n * @param WorkerConstructor The Worker constructor from worker_threads\n * @param workerPath Path to the worker entry chunk\n * @param workerOptions options to pass to the Worker constructor (optional)\n */\nfunction createWorker(\n WorkerConstructor: { new (path: string, options?: object): unknown },\n workerPath: string,\n workerOptions?: { workerData?: unknown; [key: string]: unknown }\n): unknown {\n // Build the forwarded globals object\n const forwardedGlobals: Record<string, unknown> = {}\n for (const name of WORKER_FORWARDED_GLOBALS) {\n forwardedGlobals[name] = (globalThis as Record<string, unknown>)[name]\n }\n\n // Merge workerData with forwarded globals\n const existingWorkerData = workerOptions?.workerData || {}\n const options = {\n ...workerOptions,\n workerData: {\n ...(typeof existingWorkerData === 'object' ? existingWorkerData : {}),\n __turbopack_globals__: forwardedGlobals,\n },\n }\n\n return new WorkerConstructor(workerPath, options)\n}\n\nconst regexJsUrl = /\\.js(?:\\?[^#]*)?(?:#.*)?$/\n/**\n * Checks if a given path/URL ends with .js, optionally followed by ?query or #fragment.\n */\nfunction isJs(chunkUrlOrPath: ChunkUrl | ChunkPath): boolean {\n return regexJsUrl.test(chunkUrlOrPath)\n}\n"],"names":["process","env","TURBOPACK","url","require","moduleFactories","Map","moduleCache","Object","create","resolvePathFromModule","moduleId","exported","r","exportedPath","default","strippedAssetPrefix","slice","ASSET_PREFIX","length","resolved","path","resolve","RUNTIME_ROOT","pathToFileURL","href","exportUrl","urlValue","id","exportValue","call","loadRuntimeChunk","sourcePath","chunkData","loadRuntimeChunkPath","loadedChunks","Set","unsupportedLoadChunk","Promise","undefined","loadedChunk","chunkCache","clearChunkCache","clear","chunkPath","isJs","has","chunkModules","installCompressedModuleFactories","add","cause","errorMessage","error","Error","name","loadChunkAsync","entry","get","m","reject","set","contextPrototype","l","loadChunkAsyncByUrl","chunkUrl","path1","fileURLToPath","URL","L","loadWebAssembly","_edgeModule","imports","instantiateWebAssemblyFromPath","w","loadWebAssemblyModule","compileWebAssemblyFromPath","u","createWorker","WorkerConstructor","workerPath","workerOptions","forwardedGlobals","WORKER_FORWARDED_GLOBALS","globalThis","existingWorkerData","workerData","options","__turbopack_globals__","regexJsUrl","chunkUrlOrPath","test"],"mappings":"AAAA,oDAAoD,GAEpD,8DAA8D;AAC9D,kEAAkE;AAClE,kEAAkE;AAClE,6DAA6D;AAC7D,8CAA8C;AAE9C;;;CAGC,GAEDA,QAAQC,GAAG,CAACC,SAAS,GAAG;AAExB,MAAMC,MAAMC,QAAQ;AAEpB,MAAMC,kBAAmC,IAAIC;AAC7C,MAAMC,cAAmCC,OAAOC,MAAM,CAAC;AAEvD;;CAEC,GACD,SAASC,sBAEPC,QAAgB;IAEhB,MAAMC,WAAW,IAAI,CAACC,CAAC,CAACF;IACxB,MAAMG,eAAeF,UAAUG,WAAWH;IAC1C,IAAI,OAAOE,iBAAiB,UAAU;QACpC,OAAOF;IACT;IAEA,MAAMI,sBAAsBF,aAAaG,KAAK,CAACC,aAAaC,MAAM;IAClE,MAAMC,WAAWC,KAAKC,OAAO,CAACC,cAAcP;IAE5C,OAAOb,IAAIqB,aAAa,CAACJ,UAAUK,IAAI;AACzC;AAEA;;CAEC,GACD,SAASC,UAEPC,QAAgB,EAChBC,EAAwB;IAExBC,YAAYC,IAAI,CAAC,IAAI,EAAEH,UAAUC;AACnC;AAEA,SAASG,iBAAiBC,UAAqB,EAAEC,SAAoB;IACnE,IAAI,OAAOA,cAAc,UAAU;QACjCC,qBAAqBF,YAAYC;IACnC,OAAO;QACLC,qBAAqBF,YAAYC,UAAUZ,IAAI;IACjD;AACF;AAEA,MAAMc,eAAe,IAAIC;AACzB,MAAMC,uBAAuBC,QAAQhB,OAAO,CAACiB;AAC7C,MAAMC,cAA6BF,QAAQhB,OAAO,CAACiB;AACnD,MAAME,aAAa,IAAInC;AAEvB,SAASoC;IACPD,WAAWE,KAAK;IAChBR,aAAaQ,KAAK;AACpB;AAEA,SAAST,qBACPF,UAAqB,EACrBY,SAAoB;IAEpB,IAAI,CAACC,KAAKD,YAAY;QACpB,gDAAgD;QAChD,0DAA0D;Q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iBC,CAAC,GAAGP;AAErB,SAASQ,oBAEPC,QAAgB;IAEhB,MAAMC,QAAO9D,IAAI+D,aAAa,CAAC,IAAIC,IAAIH,UAAUzC;IACjD,OAAOgC,eAAezB,IAAI,CAAC,IAAI,EAAEmC;AACnC;AACAJ,iBAAiBO,CAAC,GAAGL;AAErB,SAASM,gBACPzB,SAAoB,EACpB0B,WAAqC,EACrCC,OAA4B;IAE5B,MAAMnD,WAAWC,KAAKC,OAAO,CAACC,cAAcqB;IAE5C,OAAO4B,+BAA+BpD,UAAUmD;AAClD;AACAV,iBAAiBY,CAAC,GAAGJ;AAErB,SAASK,sBACP9B,SAAoB,EACpB0B,WAAqC;IAErC,MAAMlD,WAAWC,KAAKC,OAAO,CAACC,cAAcqB;IAE5C,OAAO+B,2BAA2BvD;AACpC;AACAyC,iBAAiBe,CAAC,GAAGF;AAErB;;;;;;;CAOC,GACD,SAASG,aACPC,iBAAoE,EACpEC,UAAkB,EAClBC,aAAgE;IAEhE,qCAAqC;IACrC,MAAMC,mBAA4C,CAAC;IACnD,KAAK,MAAM3B,QAAQ4B,yBAA0B;QAC3CD,gBAAgB,CAAC3B,KAAK,GAAG,AAAC6B,UAAsC,CAAC7B,KAAK;IACxE;IAEA,0CAA0C;IAC1C,MAAM8B,qBAAqBJ,eAAeK,cAAc,CAAC;IACzD,MAAMC,UAAU;QACd,GAAGN,aAAa;QAChBK,YAAY;YACV,GAAI,OAAOD,uBAAuB,WAAWA,qBAAqB,CAAC,CAAC;YACpEG,uBAAuBN;QACzB;IACF;IAEA,OAAO,IAAIH,kBAAkBC,YAAYO;AAC3C;AAEA,MAAME,aAAa;AACnB;;CAEC,GACD,SAAS3C,KAAK4C,cAAoC;IAChD,OAAOD,WAAWE,IAAI,CAACD;AACzB","ignoreList":[0]}},
{"offset": {"line": 810, "column": 0}, "map": {"version":3,"sources":["turbopack:///[turbopack]/nodejs/runtime/build-base.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\n\n/// <reference path=\"./runtime-base.ts\" />\n\n/**\n * Production Node.js runtime.\n * Uses ModuleWithDirection and simple module instantiation without HMR support.\n */\n\n// moduleCache and moduleFactories are declared in runtime-base.ts\n\n// this is read in runtime-utils.ts so it creates a module with direction for hmr\ncreateModuleWithDirectionFlag = true\n\ninterface TurbopackNodeBuildContext\n extends TurbopackBaseContext<ModuleWithDirection> {\n R: ResolvePathFromModule\n x: ExternalRequire\n y: ExternalImport\n C: typeof clearChunkCache\n}\n\nconst nodeContextPrototype = Context.prototype as TurbopackNodeBuildContext\n\nnodeContextPrototype.q = exportUrl\nnodeContextPrototype.M = moduleFactories\n// Cast moduleCache to ModuleWithDirection for production mode\nnodeContextPrototype.c = moduleCache as ModuleCache<ModuleWithDirection>\nnodeContextPrototype.R = resolvePathFromModule\nnodeContextPrototype.b = createWorker\nnodeContextPrototype.C = clearChunkCache\n\nfunction instantiateModule(\n id: ModuleId,\n sourceType: SourceType,\n sourceData: SourceData\n): ModuleWithDirection {\n const moduleFactory = moduleFactories.get(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 throw new Error(factoryNotAvailableMessage(id, sourceType, sourceData))\n }\n\n const module: ModuleWithDirection = createModuleWithDirection(id)\n const exports = module.exports\n moduleCache[id] = module\n\n const context =\n new (Context as any as ContextConstructor<ModuleWithDirection>)(\n module,\n exports\n )\n // NOTE(alexkirsz) This can fail when the module encounters a runtime error.\n try {\n moduleFactory(context, module, exports)\n } catch (error) {\n module.error = error as any\n throw error\n }\n\n ;(module as any).loaded = true\n if (module.namespaceObject && module.exports !== module.namespaceObject) {\n // in case of a circular dependency: cjs1 -> esm2 -> cjs1\n interopEsm(module.exports, module.namespaceObject)\n }\n\n return module\n}\n\n/**\n * Retrieves a module from the cache, or instantiate it if it is not cached.\n */\n// @ts-ignore\nfunction getOrInstantiateModuleFromParent(\n id: ModuleId,\n sourceModule: ModuleWithDirection\n): ModuleWithDirection {\n const module = moduleCache[id]\n\n if (module) {\n if (module.error) {\n throw module.error\n }\n\n return module\n }\n\n return instantiateModule(id, SourceType.Parent, sourceModule.id)\n}\n\n/**\n * Instantiates a runtime module.\n */\nfunction instantiateRuntimeModule(\n chunkPath: ChunkPath,\n moduleId: ModuleId\n): ModuleWithDirection {\n return instantiateModule(moduleId, SourceType.Runtime, chunkPath)\n}\n\n/**\n * Retrieves a module from the cache, or instantiate it as a runtime module if it is not cached.\n */\n// @ts-ignore TypeScript doesn't separate this module space from the browser runtime\nfunction getOrInstantiateRuntimeModule(\n chunkPath: ChunkPath,\n moduleId: ModuleId\n): ModuleWithDirection {\n const module = moduleCache[moduleId]\n\n if (module) {\n if (module.error) {\n throw module.error\n }\n return module\n }\n\n return instantiateRuntimeModule(chunkPath, moduleId)\n}\n\nmodule.exports = (sourcePath: ChunkPath) => ({\n m: (id: ModuleId) => getOrInstantiateRuntimeModule(sourcePath, id),\n c: (chunkData: ChunkData) => loadRuntimeChunk(sourcePath, chunkData),\n})\n"],"names":["createModuleWithDirectionFlag","nodeContextPrototype","Context","prototype","q","exportUrl","M","moduleFactories","c","moduleCache","R","resolvePathFromModule","b","createWorker","C","clearChunkCache","instantiateModule","id","sourceType","sourceData","moduleFactory","get","Error","factoryNotAvailableMessage","module1","createModuleWithDirection","exports","context","error","loaded","namespaceObject","interopEsm","getOrInstantiateModuleFromParent","sourceModule","SourceType","Parent","instantiateRuntimeModule","chunkPath","moduleId","Runtime","getOrInstantiateRuntimeModule","module","sourcePath","m","chunkData","loadRuntimeChunk"],"mappings":"AAAA,oDAAoD,GAEpD,0CAA0C;AAE1C;;;CAGC,GAED,kEAAkE;AAElE,iFAAiF;AACjFA,gCAAgC;AAUhC,MAAMC,uBAAuBC,QAAQC,SAAS;AAE9CF,qBAAqBG,CAAC,GAAGC;AACzBJ,qBAAqBK,CAAC,GAAGC;AACzB,8DAA8D;AAC9DN,qBAAqBO,CAAC,G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,SAAoB,EACpBC,QAAkB;IAElB,MAAMd,UAASf,WAAW,CAAC6B,SAAS;IAEpC,IAAId,SAAQ;QACV,IAAIA,QAAOI,KAAK,EAAE;YAChB,MAAMJ,QAAOI,KAAK;QACpB;QACA,OAAOJ;IACT;IAEA,OAAOY,yBAAyBC,WAAWC;AAC7C;AAEAG,OAAOf,OAAO,GAAG,CAACgB,aAA0B,CAAC;QAC3CC,GAAG,CAAC1B,KAAiBuB,8BAA8BE,YAAYzB;QAC/DT,GAAG,CAACoC,YAAyBC,iBAAiBH,YAAYE;IAC5D,CAAC","ignoreList":[0]}}]
{"offset": {"line": 642, "column": 0}, "map": {"version":3,"sources":["turbopack:///[turbopack]/nodejs/runtime/runtime-base.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\n\n/// <reference path=\"../../shared/runtime/runtime-utils.ts\" />\n/// <reference path=\"../../shared-node/base-externals-utils.ts\" />\n/// <reference path=\"../../shared-node/node-externals-utils.ts\" />\n/// <reference path=\"./nodejs-globals.d.ts\" />\n\n/**\n * Base Node.js runtime shared between production and development.\n * Contains chunk loading, module caching, and other non-HMR functionality.\n */\n\nprocess.env.TURBOPACK = '1'\n\nconst url = require('url') as typeof import('url')\n\nconst moduleFactories: ModuleFactories = new Map()\nconst moduleCache: ModuleCache<Module> = Object.create(null)\n\n/**\n * Returns an absolute path to the given module's id.\n */\nfunction resolvePathFromModule(\n this: TurbopackBaseContext<Module>,\n moduleId: string\n): string {\n const exported = this.r(moduleId)\n const exportedPath = exported?.default ?? exported\n if (typeof exportedPath !== 'string') {\n return exported as any\n }\n\n const strippedAssetPrefix = exportedPath.slice(ASSET_PREFIX.length)\n const resolved = path.resolve(RUNTIME_ROOT, strippedAssetPrefix)\n\n return url.pathToFileURL(resolved).href\n}\n\n/**\n * Exports a URL value. No suffix is added in Node.js runtime.\n */\nfunction exportUrl(\n this: TurbopackBaseContext<Module>,\n urlValue: string,\n id: ModuleId | undefined\n) {\n exportValue.call(this, urlValue, id)\n}\n\nfunction loadRuntimeChunk(sourcePath: ChunkPath, chunkData: ChunkData): void {\n if (typeof chunkData === 'string') {\n loadRuntimeChunkPath(sourcePath, chunkData)\n } else {\n loadRuntimeChunkPath(sourcePath, chunkData.path)\n }\n}\n\nconst loadedChunks = new Set<ChunkPath>()\nconst unsupportedLoadChunk = Promise.resolve(undefined)\nconst loadedChunk: Promise<void> = Promise.resolve(undefined)\nconst chunkCache = new Map<ChunkPath, Promise<void>>()\n\nfunction clearChunkCache() {\n chunkCache.clear()\n loadedChunks.clear()\n}\n\nfunction loadRuntimeChunkPath(\n sourcePath: ChunkPath,\n chunkPath: ChunkPath\n): void {\n if (!isJs(chunkPath)) {\n // We only support loading JS chunks in Node.js.\n // This branch can be hit when trying to load a CSS chunk.\n return\n }\n\n if (loadedChunks.has(chunkPath)) {\n return\n }\n\n try {\n const resolved = path.resolve(RUNTIME_ROOT, chunkPath)\n const chunkModules: CompressedModuleFactories = require(resolved)\n installCompressedModuleFactories(chunkModules, 0, moduleFactories)\n loadedChunks.add(chunkPath)\n } catch (cause) {\n let errorMessage = `Failed to load chunk ${chunkPath}`\n\n if (sourcePath) {\n errorMessage += ` from runtime for chunk ${sourcePath}`\n }\n\n const error = new Error(errorMessage, { cause })\n error.name = 'ChunkLoadError'\n throw error\n }\n}\n\nfunction loadChunkAsync<TModule extends Module>(\n this: TurbopackBaseContext<TModule>,\n chunkData: ChunkData\n): Promise<void> {\n const chunkPath = typeof chunkData === 'string' ? chunkData : chunkData.path\n if (!isJs(chunkPath)) {\n // We only support loading JS chunks in Node.js.\n // This branch can be hit when trying to load a CSS chunk.\n return unsupportedLoadChunk\n }\n\n let entry = chunkCache.get(chunkPath)\n if (entry === undefined) {\n try {\n // resolve to an absolute path to simplify `require` handling\n const resolved = path.resolve(RUNTIME_ROOT, chunkPath)\n // TODO: consider switching to `import()` to enable concurrent chunk loading and async file io\n // However this is incompatible with hot reloading (since `import` doesn't use the require cache)\n const chunkModules: CompressedModuleFactories = require(resolved)\n installCompressedModuleFactories(chunkModules, 0, moduleFactories)\n entry = loadedChunk\n } catch (cause) {\n const errorMessage = `Failed to load chunk ${chunkPath} from module ${this.m.id}`\n const error = new Error(errorMessage, { cause })\n error.name = 'ChunkLoadError'\n\n // Cache the failure promise, future requests will also get this same rejection\n entry = Promise.reject(error)\n }\n chunkCache.set(chunkPath, entry)\n }\n // TODO: Return an instrumented Promise that React can use instead of relying on referential equality.\n return entry\n}\ncontextPrototype.l = loadChunkAsync\n\nfunction loadChunkAsyncByUrl<TModule extends Module>(\n this: TurbopackBaseContext<TModule>,\n chunkUrl: string\n) {\n const path = url.fileURLToPath(new URL(chunkUrl, RUNTIME_ROOT)) as ChunkPath\n return loadChunkAsync.call(this, path)\n}\ncontextPrototype.L = loadChunkAsyncByUrl\n\n/**\n * Returns the chunk path as-is. On Node.js, chunks are loaded by path.\n */\nfunction chunkUrl(chunkPath: ChunkPath): string {\n return chunkPath\n}\ncontextPrototype.w = chunkUrl\n\n/**\n * Resolves a chunk path to an absolute filesystem path using RUNTIME_ROOT.\n */\nfunction resolveChunkPath(chunkPath: string): string {\n return path.resolve(RUNTIME_ROOT, chunkPath)\n}\ncontextPrototype.u = resolveChunkPath\n\n/**\n * Returns the list of worker-forwarded global names.\n */\nfunction forwardedGlobals(): string[] {\n return typeof WORKER_FORWARDED_GLOBALS !== 'undefined'\n ? WORKER_FORWARDED_GLOBALS\n : []\n}\ncontextPrototype.b = forwardedGlobals\n\n/**\n * Returns the asset suffix (empty string on Node.js).\n */\nfunction assetSuffix(): string {\n return ''\n}\ncontextPrototype.X = assetSuffix\n\nconst regexJsUrl = /\\.js(?:\\?[^#]*)?(?:#.*)?$/\n/**\n * Checks if a given path/URL ends with .js, optionally followed by ?query or #fragment.\n */\nfunction isJs(chunkUrlOrPath: ChunkUrl | ChunkPath): boolean {\n return regexJsUrl.test(chunkUrlOrPath)\n}\n"],"names":["process","env","TURBOPACK","url","require","moduleFactories","Map","moduleCache","Object","create","resolvePathFromModule","moduleId","exported","r","exportedPath","default","strippedAssetPrefix","slice","ASSET_PREFIX","length","resolved","path","resolve","RUNTIME_ROOT","pathToFileURL","href","exportUrl","urlValue","id","exportValue","call","loadRuntimeChunk","sourcePath","chunkData","loadRuntimeChunkPath","loadedChunks","Set","unsupportedLoadChunk","Promise","undefined","loadedChunk","chunkCache","clearChunkCache","clear","chunkPath","isJs","has","chunkModules","installCompressedModuleFactories","add","cause","errorMessage","error","Error","name","loadChunkAsync","entry","get","m","reject","set","contextPrototype","l","loadChunkAsyncByUrl","chunkUrl","path1","fileURLToPath","URL","L","w","resolveChunkPath","u","forwardedGlobals","WORKER_FORWARDED_GLOBALS","b","assetSuffix","X","regexJsUrl","chunkUrlOrPath","test"],"mappings":"AAAA,oDAAoD,GAEpD,8DAA8D;AAC9D,kEAAkE;AAClE,kEAAkE;AAClE,8CAA8C;AAE9C;;;CAGC,GAEDA,QAAQC,GAAG,CAACC,SAAS,GAAG;AAExB,MAAMC,MAAMC,QAAQ;AAEpB,MAAMC,kBAAmC,IAAIC;AAC7C,MAAMC,cAAmCC,OAAOC,MAAM,CAAC;AAEvD;;CAEC,GACD,SAASC,sBAEPC,QAAgB;IAEhB,MAAMC,WAAW,IAAI,CAACC,CAAC,CAACF;IACxB,MAAMG,eAAeF,UAAUG,WAAWH;IAC1C,IAAI,OAAOE,iBAAiB,UAAU;QACpC,OAAOF;IACT;IAEA,MAAMI,sBAAsBF,aAAaG,KAAK,CAACC,aAAaC,MAAM;IAClE,MAAMC,WAAWC,KAAKC,OAAO,CAACC,cAAcP;IAE5C,OAAOb,IAAIqB,aAAa,CAACJ,UAAUK,IAAI;AACzC;AAEA;;CAEC,GACD,SAASC,UAEPC,QAAgB,EAChBC,EAAwB;IAExBC,YAAYC,IAAI,CAAC,IAAI,EAAEH,UAAUC;AACnC;AAEA,SAASG,iBAAiBC,UAAqB,EAAEC,SAAoB;IACnE,IAAI,OAAOA,cAAc,UAAU;QACjCC,qBAAqBF,YAAYC;IACnC,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AClDmD,QAAQhB;QACV,EAAE,OAAOU,OAAO;YACd,MAAMC,eAAe,CAAC,qBAAqB,EAAEP,UAAU,aAAa,EAAE,IAAI,CAACc,CAAC,CAAC9B,EAAE,EAAE;YACjF,MAAMwB,QAAQ,IAAIC,MAAMF,cAAc;gBAAED;YAAM;YAC9CE,MAAME,IAAI,GAAG;YAEb,+EAA+E;YAC/EE,QAAQlB,QAAQqB,MAAM,CAACP;QACzB;QACAX,WAAWmB,GAAG,CAAChB,WAAWY;IAC5B;IACA,sGAAsG;IACtG,OAAOA;AACT;AACAK,iBAAiBC,CAAC,GAAGP;AAErB,SAASQ,oBAEPC,QAAgB;IAEhB,MAAMC,QAAO9D,IAAI+D,aAAa,CAAC,IAAIC,IAAIH,UAAUzC;IACjD,OAAOgC,eAAezB,IAAI,CAAC,IAAI,EAAEmC;AACnC;AACAJ,iBAAiBO,CAAC,GAAGL;AAErB;;CAEC,GACD,SAASC,SAASpB,SAAoB;IACpC,OAAOA;AACT;AACAiB,iBAAiBQ,CAAC,GAAGL;AAErB;;CAEC,GACD,SAASM,iBAAiB1B,SAAiB;IACzC,OAAOvB,KAAKC,OAAO,CAACC,cAAcqB;AACpC;AACAiB,iBAAiBU,CAAC,GAAGD;AAErB;;CAEC,GACD,SAASE;IACP,OAAO,OAAOC,6BAA6B,cACvCA,2BACA,EAAE;AACR;AACAZ,iBAAiBa,CAAC,GAAGF;AAErB;;CAEC,GACD,SAASG;IACP,OAAO;AACT;AACAd,iBAAiBe,CAAC,GAAGD;AAErB,MAAME,aAAa;AACnB;;CAEC,GACD,SAAShC,KAAKiC,cAAoC;IAChD,OAAOD,WAAWE,IAAI,CAACD;AACzB","ignoreList":[0]}},
{"offset": {"line": 778, "column": 0}, "map": {"version":3,"sources":["turbopack:///[turbopack]/nodejs/runtime/build-base.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\n\n/// <reference path=\"./runtime-base.ts\" />\n\n/**\n * Production Node.js runtime.\n * Uses ModuleWithDirection and simple module instantiation without HMR support.\n */\n\n// moduleCache and moduleFactories are declared in runtime-base.ts\n\n// this is read in runtime-utils.ts so it creates a module with direction for hmr\ncreateModuleWithDirectionFlag = true\n\ninterface TurbopackNodeBuildContext\n extends TurbopackBaseContext<ModuleWithDirection> {\n R: ResolvePathFromModule\n x: ExternalRequire\n y: ExternalImport\n C: typeof clearChunkCache\n}\n\nconst nodeContextPrototype = Context.prototype as TurbopackNodeBuildContext\n\nnodeContextPrototype.q = exportUrl\nnodeContextPrototype.M = moduleFactories\n// Cast moduleCache to ModuleWithDirection for production mode\nnodeContextPrototype.c = moduleCache as ModuleCache<ModuleWithDirection>\nnodeContextPrototype.R = resolvePathFromModule\nnodeContextPrototype.C = clearChunkCache\n\nfunction instantiateModule(\n id: ModuleId,\n sourceType: SourceType,\n sourceData: SourceData\n): ModuleWithDirection {\n const moduleFactory = moduleFactories.get(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 throw new Error(factoryNotAvailableMessage(id, sourceType, sourceData))\n }\n\n const module: ModuleWithDirection = createModuleWithDirection(id)\n const exports = module.exports\n moduleCache[id] = module\n\n const context =\n new (Context as any as ContextConstructor<ModuleWithDirection>)(\n module,\n exports\n )\n // NOTE(alexkirsz) This can fail when the module encounters a runtime error.\n try {\n moduleFactory(context, module, exports)\n } catch (error) {\n module.error = error as any\n throw error\n }\n\n ;(module as any).loaded = true\n if (module.namespaceObject && module.exports !== module.namespaceObject) {\n // in case of a circular dependency: cjs1 -> esm2 -> cjs1\n interopEsm(module.exports, module.namespaceObject)\n }\n\n return module\n}\n\n/**\n * Retrieves a module from the cache, or instantiate it if it is not cached.\n */\n// @ts-ignore\nfunction getOrInstantiateModuleFromParent(\n id: ModuleId,\n sourceModule: ModuleWithDirection\n): ModuleWithDirection {\n const module = moduleCache[id]\n\n if (module) {\n if (module.error) {\n throw module.error\n }\n\n return module\n }\n\n return instantiateModule(id, SourceType.Parent, sourceModule.id)\n}\n\n/**\n * Instantiates a runtime module.\n */\nfunction instantiateRuntimeModule(\n chunkPath: ChunkPath,\n moduleId: ModuleId\n): ModuleWithDirection {\n return instantiateModule(moduleId, SourceType.Runtime, chunkPath)\n}\n\n/**\n * Retrieves a module from the cache, or instantiate it as a runtime module if it is not cached.\n */\n// @ts-ignore TypeScript doesn't separate this module space from the browser runtime\nfunction getOrInstantiateRuntimeModule(\n chunkPath: ChunkPath,\n moduleId: ModuleId\n): ModuleWithDirection {\n const module = moduleCache[moduleId]\n\n if (module) {\n if (module.error) {\n throw module.error\n }\n return module\n }\n\n return instantiateRuntimeModule(chunkPath, moduleId)\n}\n\nmodule.exports = (sourcePath: ChunkPath) => ({\n m: (id: ModuleId) => getOrInstantiateRuntimeModule(sourcePath, id),\n c: (chunkData: ChunkData) => loadRuntimeChunk(sourcePath, chunkData),\n})\n"],"names":["createModuleWithDirectionFlag","nodeContextPrototype","Context","prototype","q","exportUrl","M","moduleFactories","c","moduleCache","R","resolvePathFromModule","C","clearChunkCache","instantiateModule","id","sourceType","sourceData","moduleFactory","get","Error","factoryNotAvailableMessage","module1","createModuleWithDirection","exports","context","error","loaded","namespaceObject","interopEsm","getOrInstantiateModuleFromParent","sourceModule","SourceType","Parent","instantiateRuntimeModule","chunkPath","moduleId","Runtime","getOrInstantiateRuntimeModule","module","sourcePath","m","chunkData","loadRuntimeChunk"],"mappings":"AAAA,oDAAoD,GAEpD,0CAA0C;AAE1C;;;CAGC,GAED,kEAAkE;AAElE,iFAAiF;AACjFA,gCAAgC;AAUhC,MAAMC,uBAAuBC,QAAQC,SAAS;AAE9CF,qBAAqBG,CAAC,GAAGC;AACzBJ,qBAAqBK,CAAC,GAAGC;AACzB,8DAA8D;AAC9DN,qBAAqBO,CAAC,GAAGC;AACzBR,qBAAqBS,CAAC,GAAGC;AACzBV,qBAAqBW,CAAC,GAAGC;AAEzB,SAASC,kBACPC,EA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AMJ,QAAOI,KAAK;QACpB;QACA,OAAOJ;IACT;IAEA,OAAOY,yBAAyBC,WAAWC;AAC7C;AAEAG,OAAOf,OAAO,GAAG,CAACgB,aAA0B,CAAC;QAC3CC,GAAG,CAAC1B,KAAiBuB,8BAA8BE,YAAYzB;QAC/DP,GAAG,CAACkC,YAAyBC,iBAAiBH,YAAYE;IAC5D,CAAC","ignoreList":[0]}}]
}
\ No newline at end of file
......@@ -732,44 +732,30 @@ browserContextPrototype.P = resolveAbsolutePath;
}
browserContextPrototype.q = exportUrl;
/**
* Creates a worker by instantiating the given WorkerConstructor with the
* appropriate URL and options.
*
* The entrypoint is a pre-compiled worker runtime file. The params configure
* which module chunks to load and which module to run as the entry point.
*
* The params are a JSON array of the following structure:
* `[TURBOPACK_NEXT_CHUNK_URLS, ASSET_SUFFIX, ...WORKER_FORWARDED_GLOBALS values]`
*
* @param WorkerConstructor The Worker or SharedWorker constructor
* @param entrypoint URL path to the worker entrypoint chunk
* @param moduleChunks list of module chunk paths to load
* @param workerOptions options to pass to the Worker constructor (optional)
*/ function createWorker(WorkerConstructor, entrypoint, moduleChunks, workerOptions) {
const isSharedWorker = WorkerConstructor.name === 'SharedWorker';
const chunkUrls = moduleChunks.map((chunk)=>getChunkRelativeUrl(chunk)).reverse();
const params = [
chunkUrls,
ASSET_SUFFIX
];
for (const globalName of WORKER_FORWARDED_GLOBALS){
params.push(globalThis[globalName]);
}
const url = new URL(getChunkRelativeUrl(entrypoint), location.origin);
const paramsJson = JSON.stringify(params);
if (isSharedWorker) {
url.searchParams.set('params', paramsJson);
} else {
url.hash = '#params=' + encodeURIComponent(paramsJson);
}
// Remove type: "module" from options since our worker entrypoint is not a module
const options = workerOptions ? {
...workerOptions,
type: undefined
} : undefined;
return new WorkerConstructor(url, options);
* Returns the full chunk URL for a chunk path, including CHUNK_BASE_PATH prefix
* and ASSET_SUFFIX. Used by extracted worker/wasm modules.
*/ function chunkUrl(chunkPath) {
return getChunkRelativeUrl(chunkPath);
}
browserContextPrototype.w = chunkUrl;
/**
* Returns the ASSET_SUFFIX string. Used by extracted worker modules.
*/ function assetSuffix() {
return ASSET_SUFFIX;
}
browserContextPrototype.b = createWorker;
browserContextPrototype.X = assetSuffix;
/**
* Returns the list of worker-forwarded global names.
*/ function forwardedGlobals() {
return WORKER_FORWARDED_GLOBALS;
}
browserContextPrototype.b = forwardedGlobals;
/**
* Resolves a chunk path. On browser, returns the path as-is (not applicable).
*/ function resolveChunkPath(chunkPath) {
return chunkPath;
}
browserContextPrototype.u = resolveChunkPath;
/**
* Instantiates a runtime module.
*/ function instantiateRuntimeModule(moduleId, chunkPath) {
......@@ -840,14 +826,6 @@ function isJs(chunkUrlOrPath) {
function isCss(chunkUrl) {
return endsWithExtension(chunkUrl, '.css');
}
function loadWebAssembly(chunkPath, edgeModule, importsObj) {
return BACKEND.loadWebAssembly(SourceType.Parent, this.m.id, chunkPath, edgeModule, importsObj);
}
contextPrototype.w = loadWebAssembly;
function loadWebAssemblyModule(chunkPath, edgeModule) {
return BACKEND.loadWebAssemblyModule(SourceType.Parent, this.m.id, chunkPath, edgeModule);
}
contextPrototype.u = loadWebAssemblyModule;
/// <reference path="./runtime-utils.ts" />
/// <reference path="./runtime-types.d.ts" />
/// <reference path="./dev-extensions.ts" />
......@@ -2005,15 +1983,6 @@ let BACKEND;
* has been loaded.
*/ loadChunkCached (sourceType, chunkUrl) {
return doLoadChunk(sourceType, chunkUrl);
},
async loadWebAssembly (_sourceType, _sourceData, wasmChunkPath, _edgeModule, importsObj) {
const req = fetchWebAssembly(wasmChunkPath);
const { instance } = await WebAssembly.instantiateStreaming(req, importsObj);
return instance.exports;
},
async loadWebAssemblyModule (_sourceType, _sourceData, wasmChunkPath, _edgeModule) {
const req = fetchWebAssembly(wasmChunkPath);
return await WebAssembly.compileStreaming(req);
}
};
function getOrCreateResolver(chunkUrl) {
......@@ -2126,9 +2095,6 @@ let BACKEND;
resolver.loadingStarted = true;
return resolver.promise;
}
function fetchWebAssembly(wasmChunkPath) {
return fetch(getChunkRelativeUrl(wasmChunkPath));
}
})();
/**
* This file contains the runtime code specific to the Turbopack development
......
......@@ -877,58 +877,6 @@ function _async_to_generator(fn) {
});
};
}
function _define_property(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _object_spread(target) {
for(var i = 1; i < arguments.length; i++){
var source = arguments[i] != null ? arguments[i] : {};
var ownKeys = Object.keys(source);
if (typeof Object.getOwnPropertySymbols === "function") {
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
}));
}
ownKeys.forEach(function(key) {
_define_property(target, key, source[key]);
});
}
return target;
}
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
if (enumerableOnly) {
symbols = symbols.filter(function(sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
}
keys.push.apply(keys, symbols);
}
return keys;
}
function _object_spread_props(target, source) {
source = source != null ? source : {};
if (Object.getOwnPropertyDescriptors) {
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
} else {
ownKeys(Object(source)).forEach(function(key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
return target;
}
function _ts_generator(thisArg, body) {
var f, y, t, _ = {
label: 0,
......@@ -1282,62 +1230,30 @@ browserContextPrototype.P = resolveAbsolutePath;
}
browserContextPrototype.q = exportUrl;
/**
* Creates a worker by instantiating the given WorkerConstructor with the
* appropriate URL and options.
*
* The entrypoint is a pre-compiled worker runtime file. The params configure
* which module chunks to load and which module to run as the entry point.
*
* The params are a JSON array of the following structure:
* `[TURBOPACK_NEXT_CHUNK_URLS, ASSET_SUFFIX, ...WORKER_FORWARDED_GLOBALS values]`
*
* @param WorkerConstructor The Worker or SharedWorker constructor
* @param entrypoint URL path to the worker entrypoint chunk
* @param moduleChunks list of module chunk paths to load
* @param workerOptions options to pass to the Worker constructor (optional)
*/ function createWorker(WorkerConstructor, entrypoint, moduleChunks, workerOptions) {
var isSharedWorker = WorkerConstructor.name === 'SharedWorker';
var chunkUrls = moduleChunks.map(function(chunk) {
return getChunkRelativeUrl(chunk);
}).reverse();
var params = [
chunkUrls,
ASSET_SUFFIX
];
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
try {
for(var _iterator = WORKER_FORWARDED_GLOBALS[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
var globalName = _step.value;
params.push(globalThis[globalName]);
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally{
try {
if (!_iteratorNormalCompletion && _iterator.return != null) {
_iterator.return();
}
} finally{
if (_didIteratorError) {
throw _iteratorError;
}
}
}
var url = new URL(getChunkRelativeUrl(entrypoint), location.origin);
var paramsJson = JSON.stringify(params);
if (isSharedWorker) {
url.searchParams.set('params', paramsJson);
} else {
url.hash = '#params=' + encodeURIComponent(paramsJson);
}
// Remove type: "module" from options since our worker entrypoint is not a module
var options = workerOptions ? _object_spread_props(_object_spread({}, workerOptions), {
type: undefined
}) : undefined;
return new WorkerConstructor(url, options);
* Returns the full chunk URL for a chunk path, including CHUNK_BASE_PATH prefix
* and ASSET_SUFFIX. Used by extracted worker/wasm modules.
*/ function chunkUrl(chunkPath) {
return getChunkRelativeUrl(chunkPath);
}
browserContextPrototype.w = chunkUrl;
/**
* Returns the ASSET_SUFFIX string. Used by extracted worker modules.
*/ function assetSuffix() {
return ASSET_SUFFIX;
}
browserContextPrototype.X = assetSuffix;
/**
* Returns the list of worker-forwarded global names.
*/ function forwardedGlobals() {
return WORKER_FORWARDED_GLOBALS;
}
browserContextPrototype.b = createWorker;
browserContextPrototype.b = forwardedGlobals;
/**
* Resolves a chunk path. On browser, returns the path as-is (not applicable).
*/ function resolveChunkPath(chunkPath) {
return chunkPath;
}
browserContextPrototype.u = resolveChunkPath;
/**
* Instantiates a runtime module.
*/ function instantiateRuntimeModule(moduleId, chunkPath) {
......@@ -1354,8 +1270,8 @@ function getPathFromScript(chunkScript) {
if (typeof chunkScript === 'string') {
return chunkScript;
}
var chunkUrl = chunkScript.src;
var src = decodeURIComponent(chunkUrl.replace(/[?#].*$/, ''));
var _$chunkUrl = chunkScript.src;
var src = decodeURIComponent(_$chunkUrl.replace(/[?#].*$/, ''));
var path = src.startsWith(CHUNK_BASE_PATH) ? src.slice(CHUNK_BASE_PATH.length) : src;
return path;
}
......@@ -1410,14 +1326,6 @@ function isJs(chunkUrlOrPath) {
function isCss(chunkUrl) {
return endsWithExtension(chunkUrl, '.css');
}
function loadWebAssembly(chunkPath, edgeModule, importsObj) {
return BACKEND.loadWebAssembly(SourceType.Parent, this.m.id, chunkPath, edgeModule, importsObj);
}
contextPrototype.w = loadWebAssembly;
function loadWebAssemblyModule(chunkPath, edgeModule) {
return BACKEND.loadWebAssemblyModule(SourceType.Parent, this.m.id, chunkPath, edgeModule);
}
contextPrototype.u = loadWebAssemblyModule;
/// <reference path="./runtime-base.ts" />
/// <reference path="./dummy.ts" />
var moduleCache = {};
......@@ -1719,47 +1627,6 @@ var BACKEND;
* has been loaded.
*/ loadChunkCached: function loadChunkCached(sourceType, chunkUrl) {
return doLoadChunk(sourceType, chunkUrl);
},
loadWebAssembly: function loadWebAssembly(_sourceType, _sourceData, wasmChunkPath, _edgeModule, importsObj) {
return _async_to_generator(function() {
var req, instance;
return _ts_generator(this, function(_state) {
switch(_state.label){
case 0:
req = fetchWebAssembly(wasmChunkPath);
return [
4,
WebAssembly.instantiateStreaming(req, importsObj)
];
case 1:
instance = _state.sent().instance;
return [
2,
instance.exports
];
}
});
})();
},
loadWebAssemblyModule: function loadWebAssemblyModule(_sourceType, _sourceData, wasmChunkPath, _edgeModule) {
return _async_to_generator(function() {
var req;
return _ts_generator(this, function(_state) {
switch(_state.label){
case 0:
req = fetchWebAssembly(wasmChunkPath);
return [
4,
WebAssembly.compileStreaming(req)
];
case 1:
return [
2,
_state.sent()
];
}
});
})();
}
};
function getOrCreateResolver(chunkUrl) {
......@@ -1889,9 +1756,6 @@ var BACKEND;
resolver.loadingStarted = true;
return resolver.promise;
}
function fetchWebAssembly(wasmChunkPath) {
return fetch(getChunkRelativeUrl(wasmChunkPath));
}
})();
var chunksToRegister = globalThis["TURBOPACK"];
globalThis["TURBOPACK"] = { push: registerChunk };
......
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([
"output/1i9t_crates_turbopack-tests_tests_snapshot_workers_basic_input_index_09-gc7x.js",
{"otherChunks":["output/turbopack_crates_turbopack-tests_tests_snapshot_workers_basic_input_0z18is9._.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/workers/basic/input/index.js [test] (ecmascript)"]}
"output/1i9t_crates_turbopack-tests_tests_snapshot_workers_basic_input_index_0s9gn-l.js",
{"otherChunks":["output/[root-of-the-server]__08j45iv._.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/workers/basic/input/index.js [test] (ecmascript)"]}
]);
(() => {
if (!Array.isArray(globalThis["TURBOPACK"])) {
......@@ -732,44 +732,30 @@ browserContextPrototype.P = resolveAbsolutePath;
}
browserContextPrototype.q = exportUrl;
/**
* Creates a worker by instantiating the given WorkerConstructor with the
* appropriate URL and options.
*
* The entrypoint is a pre-compiled worker runtime file. The params configure
* which module chunks to load and which module to run as the entry point.
*
* The params are a JSON array of the following structure:
* `[TURBOPACK_NEXT_CHUNK_URLS, ASSET_SUFFIX, ...WORKER_FORWARDED_GLOBALS values]`
*
* @param WorkerConstructor The Worker or SharedWorker constructor
* @param entrypoint URL path to the worker entrypoint chunk
* @param moduleChunks list of module chunk paths to load
* @param workerOptions options to pass to the Worker constructor (optional)
*/ function createWorker(WorkerConstructor, entrypoint, moduleChunks, workerOptions) {
const isSharedWorker = WorkerConstructor.name === 'SharedWorker';
const chunkUrls = moduleChunks.map((chunk)=>getChunkRelativeUrl(chunk)).reverse();
const params = [
chunkUrls,
ASSET_SUFFIX
];
for (const globalName of WORKER_FORWARDED_GLOBALS){
params.push(globalThis[globalName]);
}
const url = new URL(getChunkRelativeUrl(entrypoint), location.origin);
const paramsJson = JSON.stringify(params);
if (isSharedWorker) {
url.searchParams.set('params', paramsJson);
} else {
url.hash = '#params=' + encodeURIComponent(paramsJson);
}
// Remove type: "module" from options since our worker entrypoint is not a module
const options = workerOptions ? {
...workerOptions,
type: undefined
} : undefined;
return new WorkerConstructor(url, options);
* Returns the full chunk URL for a chunk path, including CHUNK_BASE_PATH prefix
* and ASSET_SUFFIX. Used by extracted worker/wasm modules.
*/ function chunkUrl(chunkPath) {
return getChunkRelativeUrl(chunkPath);
}
browserContextPrototype.w = chunkUrl;
/**
* Returns the ASSET_SUFFIX string. Used by extracted worker modules.
*/ function assetSuffix() {
return ASSET_SUFFIX;
}
browserContextPrototype.b = createWorker;
browserContextPrototype.X = assetSuffix;
/**
* Returns the list of worker-forwarded global names.
*/ function forwardedGlobals() {
return WORKER_FORWARDED_GLOBALS;
}
browserContextPrototype.b = forwardedGlobals;
/**
* Resolves a chunk path. On browser, returns the path as-is (not applicable).
*/ function resolveChunkPath(chunkPath) {
return chunkPath;
}
browserContextPrototype.u = resolveChunkPath;
/**
* Instantiates a runtime module.
*/ function instantiateRuntimeModule(moduleId, chunkPath) {
......@@ -840,14 +826,6 @@ function isJs(chunkUrlOrPath) {
function isCss(chunkUrl) {
return endsWithExtension(chunkUrl, '.css');
}
function loadWebAssembly(chunkPath, edgeModule, importsObj) {
return BACKEND.loadWebAssembly(SourceType.Parent, this.m.id, chunkPath, edgeModule, importsObj);
}
contextPrototype.w = loadWebAssembly;
function loadWebAssemblyModule(chunkPath, edgeModule) {
return BACKEND.loadWebAssemblyModule(SourceType.Parent, this.m.id, chunkPath, edgeModule);
}
contextPrototype.u = loadWebAssemblyModule;
/// <reference path="./runtime-utils.ts" />
/// <reference path="./runtime-types.d.ts" />
/// <reference path="./dev-extensions.ts" />
......@@ -2005,15 +1983,6 @@ let BACKEND;
* has been loaded.
*/ loadChunkCached (sourceType, chunkUrl) {
return doLoadChunk(sourceType, chunkUrl);
},
async loadWebAssembly (_sourceType, _sourceData, wasmChunkPath, _edgeModule, importsObj) {
const req = fetchWebAssembly(wasmChunkPath);
const { instance } = await WebAssembly.instantiateStreaming(req, importsObj);
return instance.exports;
},
async loadWebAssemblyModule (_sourceType, _sourceData, wasmChunkPath, _edgeModule) {
const req = fetchWebAssembly(wasmChunkPath);
return await WebAssembly.compileStreaming(req);
}
};
function getOrCreateResolver(chunkUrl) {
......@@ -2126,9 +2095,6 @@ let BACKEND;
resolver.loadingStarted = true;
return resolver.promise;
}
function fetchWebAssembly(wasmChunkPath) {
return fetch(getChunkRelativeUrl(wasmChunkPath));
}
})();
/**
* This file contains the runtime code specific to the Turbopack development
......@@ -2246,4 +2212,4 @@ chunkListsToRegister.forEach(registerChunkList);
})();
//# sourceMappingURL=1do3_crates_turbopack-tests_tests_snapshot_workers_basic_input_index_09-gc7x.js.map
\ No newline at end of file
//# sourceMappingURL=1do3_crates_turbopack-tests_tests_snapshot_workers_basic_input_index_0s9gn-l.js.map
\ No newline at end of file
......@@ -732,44 +732,30 @@ browserContextPrototype.P = resolveAbsolutePath;
}
browserContextPrototype.q = exportUrl;
/**
* Creates a worker by instantiating the given WorkerConstructor with the
* appropriate URL and options.
*
* The entrypoint is a pre-compiled worker runtime file. The params configure
* which module chunks to load and which module to run as the entry point.
*
* The params are a JSON array of the following structure:
* `[TURBOPACK_NEXT_CHUNK_URLS, ASSET_SUFFIX, ...WORKER_FORWARDED_GLOBALS values]`
*
* @param WorkerConstructor The Worker or SharedWorker constructor
* @param entrypoint URL path to the worker entrypoint chunk
* @param moduleChunks list of module chunk paths to load
* @param workerOptions options to pass to the Worker constructor (optional)
*/ function createWorker(WorkerConstructor, entrypoint, moduleChunks, workerOptions) {
const isSharedWorker = WorkerConstructor.name === 'SharedWorker';
const chunkUrls = moduleChunks.map((chunk)=>getChunkRelativeUrl(chunk)).reverse();
const params = [
chunkUrls,
ASSET_SUFFIX
];
for (const globalName of WORKER_FORWARDED_GLOBALS){
params.push(globalThis[globalName]);
}
const url = new URL(getChunkRelativeUrl(entrypoint), location.origin);
const paramsJson = JSON.stringify(params);
if (isSharedWorker) {
url.searchParams.set('params', paramsJson);
} else {
url.hash = '#params=' + encodeURIComponent(paramsJson);
}
// Remove type: "module" from options since our worker entrypoint is not a module
const options = workerOptions ? {
...workerOptions,
type: undefined
} : undefined;
return new WorkerConstructor(url, options);
* Returns the full chunk URL for a chunk path, including CHUNK_BASE_PATH prefix
* and ASSET_SUFFIX. Used by extracted worker/wasm modules.
*/ function chunkUrl(chunkPath) {
return getChunkRelativeUrl(chunkPath);
}
browserContextPrototype.w = chunkUrl;
/**
* Returns the ASSET_SUFFIX string. Used by extracted worker modules.
*/ function assetSuffix() {
return ASSET_SUFFIX;
}
browserContextPrototype.b = createWorker;
browserContextPrototype.X = assetSuffix;
/**
* Returns the list of worker-forwarded global names.
*/ function forwardedGlobals() {
return WORKER_FORWARDED_GLOBALS;
}
browserContextPrototype.b = forwardedGlobals;
/**
* Resolves a chunk path. On browser, returns the path as-is (not applicable).
*/ function resolveChunkPath(chunkPath) {
return chunkPath;
}
browserContextPrototype.u = resolveChunkPath;
/**
* Instantiates a runtime module.
*/ function instantiateRuntimeModule(moduleId, chunkPath) {
......@@ -840,14 +826,6 @@ function isJs(chunkUrlOrPath) {
function isCss(chunkUrl) {
return endsWithExtension(chunkUrl, '.css');
}
function loadWebAssembly(chunkPath, edgeModule, importsObj) {
return BACKEND.loadWebAssembly(SourceType.Parent, this.m.id, chunkPath, edgeModule, importsObj);
}
contextPrototype.w = loadWebAssembly;
function loadWebAssemblyModule(chunkPath, edgeModule) {
return BACKEND.loadWebAssemblyModule(SourceType.Parent, this.m.id, chunkPath, edgeModule);
}
contextPrototype.u = loadWebAssemblyModule;
/// <reference path="./runtime-utils.ts" />
/// <reference path="./runtime-types.d.ts" />
/// <reference path="./dev-extensions.ts" />
......@@ -2005,15 +1983,6 @@ let BACKEND;
* has been loaded.
*/ loadChunkCached (sourceType, chunkUrl) {
return doLoadChunk(sourceType, chunkUrl);
},
async loadWebAssembly (_sourceType, _sourceData, wasmChunkPath, _edgeModule, importsObj) {
const req = fetchWebAssembly(wasmChunkPath);
const { instance } = await WebAssembly.instantiateStreaming(req, importsObj);
return instance.exports;
},
async loadWebAssemblyModule (_sourceType, _sourceData, wasmChunkPath, _edgeModule) {
const req = fetchWebAssembly(wasmChunkPath);
return await WebAssembly.compileStreaming(req);
}
};
function getOrCreateResolver(chunkUrl) {
......@@ -2126,9 +2095,6 @@ let BACKEND;
resolver.loadingStarted = true;
return resolver.promise;
}
function fetchWebAssembly(wasmChunkPath) {
return fetch(getChunkRelativeUrl(wasmChunkPath));
}
})();
/**
* This file contains the runtime code specific to the Turbopack development
......
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/turbopack_crates_turbopack-tests_tests_snapshot_workers_basic_input_0z18is9._.js",
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/[root-of-the-server]__08j45iv._.js",
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/workers/basic/input/worker.js (static in ecmascript)", ((__turbopack_context__) => {
__turbopack_context__.q("/static/worker.2-qnq-strt8dn.js");}),
"[turbopack]/shared/worker-browser.ts [test] (ecmascript)", ((__turbopack_context__) => {
"use strict";
__turbopack_context__.s([
"createWorker",
()=>createWorker
]);
/**
* Browser worker creation module.
* Only included when a Web Worker or SharedWorker is actually used.
*/ /* eslint-disable @typescript-eslint/no-unused-vars */ 'use turbopack no side effects';
function createWorker(WorkerConstructor, entrypoint, moduleChunks, workerOptions) {
const isSharedWorker = WorkerConstructor.name === 'SharedWorker';
const chunkUrls = moduleChunks.map((chunk)=>__turbopack_chunk_url__(chunk)).reverse();
const params = [
chunkUrls,
__turbopack_asset_suffix__()
];
for (const globalName of __turbopack_forwarded_globals__()){
params.push(globalThis[globalName]);
}
const url = new URL(__turbopack_chunk_url__(entrypoint), location.origin);
const paramsJson = JSON.stringify(params);
if (isSharedWorker) {
url.searchParams.set('params', paramsJson);
} else {
url.hash = '#params=' + encodeURIComponent(paramsJson);
}
// Remove type: "module" from options since our worker entrypoint is not a module
const options = workerOptions ? {
...workerOptions,
type: undefined
} : undefined;
return new WorkerConstructor(url, options);
}
}),
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/workers/basic/input/worker.js [test] (ecmascript, worker loader)", ((__turbopack_context__) => {
var createWorker = __turbopack_context__.r("[turbopack]/shared/worker-browser.ts [test] (ecmascript)").createWorker;
__turbopack_context__.v(function(Ctor, opts) {
return __turbopack_context__.b(Ctor, "output/0uxq_crates_turbopack-tests_tests_snapshot_workers_basic_output_0uy0mni._.js", ["output/1do3_crates_turbopack-tests_tests_snapshot_workers_basic_input_worker_11ygioo.js","output/1i9t_crates_turbopack-tests_tests_snapshot_workers_basic_input_worker_0yr5fg0.js"], opts);
return createWorker(Ctor, "output/0uxq_crates_turbopack-tests_tests_snapshot_workers_basic_output_0uy0mni._.js", ["output/1do3_crates_turbopack-tests_tests_snapshot_workers_basic_input_worker_11ygioo.js","output/1i9t_crates_turbopack-tests_tests_snapshot_workers_basic_input_worker_0yr5fg0.js"], opts);
});
}),
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/workers/basic/input/index.js [test] (ecmascript)", ((__turbopack_context__, module, exports) => {
......@@ -21,4 +58,4 @@ __turbopack_context__.r("[project]/turbopack/crates/turbopack-tests/tests/snapsh
}),
]);
//# sourceMappingURL=turbopack_crates_turbopack-tests_tests_snapshot_workers_basic_input_0z18is9._.js.map
\ No newline at end of file
//# sourceMappingURL=%5Broot-of-the-server%5D__08j45iv._.js.map
\ No newline at end of file
{
"version": 3,
"sources": [],
"sections": [
{"offset": {"line": 7, "column": 0}, "map": {"version":3,"sources":["turbopack:///[turbopack]/shared/worker-browser.ts"],"sourcesContent":["/**\n * Browser worker creation module.\n * Only included when a Web Worker or SharedWorker is actually used.\n */\n\n/* eslint-disable @typescript-eslint/no-unused-vars */\n\n'use turbopack no side effects'\n\ndeclare function __turbopack_chunk_url__(chunkPath: string): string\ndeclare function __turbopack_forwarded_globals__(): string[]\ndeclare function __turbopack_asset_suffix__(): string\n\n/**\n * Creates a worker by instantiating the given WorkerConstructor with the\n * appropriate URL and options.\n *\n * The entrypoint is a pre-compiled worker runtime file. The params configure\n * which module chunks to load and which module to run as the entry point.\n *\n * The params are a JSON array of the following structure:\n * `[TURBOPACK_NEXT_CHUNK_URLS, ASSET_SUFFIX, ...WORKER_FORWARDED_GLOBALS values]`\n *\n * @param WorkerConstructor The Worker or SharedWorker constructor\n * @param entrypoint URL path to the worker entrypoint chunk\n * @param moduleChunks list of module chunk paths to load\n * @param workerOptions options to pass to the Worker constructor (optional)\n */\nexport function createWorker(\n WorkerConstructor: { new (url: URL, options?: object): Worker },\n entrypoint: string,\n moduleChunks: string[],\n workerOptions?: object\n): Worker {\n const isSharedWorker = WorkerConstructor.name === 'SharedWorker'\n\n const chunkUrls = moduleChunks\n .map((chunk) => __turbopack_chunk_url__(chunk))\n .reverse()\n const params: unknown[] = [chunkUrls, __turbopack_asset_suffix__()]\n for (const globalName of __turbopack_forwarded_globals__()) {\n params.push((globalThis as Record<string, unknown>)[globalName])\n }\n\n const url = new URL(__turbopack_chunk_url__(entrypoint), location.origin)\n const paramsJson = JSON.stringify(params)\n if (isSharedWorker) {\n url.searchParams.set('params', paramsJson)\n } else {\n url.hash = '#params=' + encodeURIComponent(paramsJson)\n }\n\n // Remove type: \"module\" from options since our worker entrypoint is not a module\n const options = workerOptions\n ? { ...workerOptions, type: undefined }\n : undefined\n return new WorkerConstructor(url, options)\n}\n"],"names":["createWorker","WorkerConstructor","entrypoint","moduleChunks","workerOptions","isSharedWorker","name","chunkUrls","map","chunk","__turbopack_chunk_url__","reverse","params","__turbopack_asset_suffix__","globalName","__turbopack_forwarded_globals__","push","globalThis","url","URL","location","origin","paramsJson","JSON","stringify","searchParams","set","hash","encodeURIComponent","options","type","undefined"],"mappings":";;;;AAAA;;;CAGC,GAED,oDAAoD,GAEpD;AAqBO,SAASA,aACdC,iBAA+D,EAC/DC,UAAkB,EAClBC,YAAsB,EACtBC,aAAsB;IAEtB,MAAMC,iBAAiBJ,kBAAkBK,IAAI,KAAK;IAElD,MAAMC,YAAYJ,aACfK,GAAG,CAAC,CAACC,QAAUC,wBAAwBD,QACvCE,OAAO;IACV,MAAMC,SAAoB;QAACL;QAAWM;KAA6B;IACnE,KAAK,MAAMC,cAAcC,kCAAmC;QAC1DH,OAAOI,IAAI,CAAC,AAACC,UAAsC,CAACH,WAAW;IACjE;IAEA,MAAMI,MAAM,IAAIC,IAAIT,wBAAwBR,aAAakB,SAASC,MAAM;IACxE,MAAMC,aAAaC,KAAKC,SAAS,CAACZ;IAClC,IAAIP,gBAAgB;QAClBa,IAAIO,YAAY,CAACC,GAAG,CAAC,UAAUJ;IACjC,OAAO;QACLJ,IAAIS,IAAI,GAAG,aAAaC,mBAAmBN;IAC7C;IAEA,iFAAiF;IACjF,MAAMO,UAAUzB,gBACZ;QAAE,GAAGA,aAAa;QAAE0B,MAAMC;IAAU,IACpCA;IACJ,OAAO,IAAI9B,kBAAkBiB,KAAKW;AACpC","ignoreList":[0]}},
{"offset": {"line": 49, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/workers/basic/input/index.js"],"sourcesContent":["console.log('index.js')\nconst url = new URL('./worker.js', import.meta.url)\nnew Worker(url)\n"],"names":["console","log","url","Worker"],"mappings":";;;;;AAAAA,QAAQC,GAAG,CAAC;AACZ,MAAMC;AACN,sJAAIC"}}]
}
\ No newline at end of file
{
"version": 3,
"sources": [],
"sections": [
{"offset": {"line": 12, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/workers/basic/input/index.js"],"sourcesContent":["console.log('index.js')\nconst url = new URL('./worker.js', import.meta.url)\nnew Worker(url)\n"],"names":["console","log","url","Worker"],"mappings":";;;;;AAAAA,QAAQC,GAAG,CAAC;AACZ,MAAMC;AACN,sJAAIC"}}]
}
\ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([
"output/1i9t_crates_turbopack-tests_tests_snapshot_workers_shared_input_index_0arnewp.js",
{"otherChunks":["output/turbopack_crates_turbopack-tests_tests_snapshot_workers_shared_input_0g-vw3t._.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/workers/shared/input/index.js [test] (ecmascript)"]}
"output/1i9t_crates_turbopack-tests_tests_snapshot_workers_shared_input_index_1eutg7d.js",
{"otherChunks":["output/[root-of-the-server]__09q-mwc._.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/workers/shared/input/index.js [test] (ecmascript)"]}
]);
(() => {
if (!Array.isArray(globalThis["TURBOPACK"])) {
......@@ -732,44 +732,30 @@ browserContextPrototype.P = resolveAbsolutePath;
}
browserContextPrototype.q = exportUrl;
/**
* Creates a worker by instantiating the given WorkerConstructor with the
* appropriate URL and options.
*
* The entrypoint is a pre-compiled worker runtime file. The params configure
* which module chunks to load and which module to run as the entry point.
*
* The params are a JSON array of the following structure:
* `[TURBOPACK_NEXT_CHUNK_URLS, ASSET_SUFFIX, ...WORKER_FORWARDED_GLOBALS values]`
*
* @param WorkerConstructor The Worker or SharedWorker constructor
* @param entrypoint URL path to the worker entrypoint chunk
* @param moduleChunks list of module chunk paths to load
* @param workerOptions options to pass to the Worker constructor (optional)
*/ function createWorker(WorkerConstructor, entrypoint, moduleChunks, workerOptions) {
const isSharedWorker = WorkerConstructor.name === 'SharedWorker';
const chunkUrls = moduleChunks.map((chunk)=>getChunkRelativeUrl(chunk)).reverse();
const params = [
chunkUrls,
ASSET_SUFFIX
];
for (const globalName of WORKER_FORWARDED_GLOBALS){
params.push(globalThis[globalName]);
}
const url = new URL(getChunkRelativeUrl(entrypoint), location.origin);
const paramsJson = JSON.stringify(params);
if (isSharedWorker) {
url.searchParams.set('params', paramsJson);
} else {
url.hash = '#params=' + encodeURIComponent(paramsJson);
}
// Remove type: "module" from options since our worker entrypoint is not a module
const options = workerOptions ? {
...workerOptions,
type: undefined
} : undefined;
return new WorkerConstructor(url, options);
* Returns the full chunk URL for a chunk path, including CHUNK_BASE_PATH prefix
* and ASSET_SUFFIX. Used by extracted worker/wasm modules.
*/ function chunkUrl(chunkPath) {
return getChunkRelativeUrl(chunkPath);
}
browserContextPrototype.w = chunkUrl;
/**
* Returns the ASSET_SUFFIX string. Used by extracted worker modules.
*/ function assetSuffix() {
return ASSET_SUFFIX;
}
browserContextPrototype.b = createWorker;
browserContextPrototype.X = assetSuffix;
/**
* Returns the list of worker-forwarded global names.
*/ function forwardedGlobals() {
return WORKER_FORWARDED_GLOBALS;
}
browserContextPrototype.b = forwardedGlobals;
/**
* Resolves a chunk path. On browser, returns the path as-is (not applicable).
*/ function resolveChunkPath(chunkPath) {
return chunkPath;
}
browserContextPrototype.u = resolveChunkPath;
/**
* Instantiates a runtime module.
*/ function instantiateRuntimeModule(moduleId, chunkPath) {
......@@ -840,14 +826,6 @@ function isJs(chunkUrlOrPath) {
function isCss(chunkUrl) {
return endsWithExtension(chunkUrl, '.css');
}
function loadWebAssembly(chunkPath, edgeModule, importsObj) {
return BACKEND.loadWebAssembly(SourceType.Parent, this.m.id, chunkPath, edgeModule, importsObj);
}
contextPrototype.w = loadWebAssembly;
function loadWebAssemblyModule(chunkPath, edgeModule) {
return BACKEND.loadWebAssemblyModule(SourceType.Parent, this.m.id, chunkPath, edgeModule);
}
contextPrototype.u = loadWebAssemblyModule;
/// <reference path="./runtime-utils.ts" />
/// <reference path="./runtime-types.d.ts" />
/// <reference path="./dev-extensions.ts" />
......@@ -2005,15 +1983,6 @@ let BACKEND;
* has been loaded.
*/ loadChunkCached (sourceType, chunkUrl) {
return doLoadChunk(sourceType, chunkUrl);
},
async loadWebAssembly (_sourceType, _sourceData, wasmChunkPath, _edgeModule, importsObj) {
const req = fetchWebAssembly(wasmChunkPath);
const { instance } = await WebAssembly.instantiateStreaming(req, importsObj);
return instance.exports;
},
async loadWebAssemblyModule (_sourceType, _sourceData, wasmChunkPath, _edgeModule) {
const req = fetchWebAssembly(wasmChunkPath);
return await WebAssembly.compileStreaming(req);
}
};
function getOrCreateResolver(chunkUrl) {
......@@ -2126,9 +2095,6 @@ let BACKEND;
resolver.loadingStarted = true;
return resolver.promise;
}
function fetchWebAssembly(wasmChunkPath) {
return fetch(getChunkRelativeUrl(wasmChunkPath));
}
})();
/**
* This file contains the runtime code specific to the Turbopack development
......@@ -2246,4 +2212,4 @@ chunkListsToRegister.forEach(registerChunkList);
})();
//# sourceMappingURL=1do3_crates_turbopack-tests_tests_snapshot_workers_shared_input_index_0arnewp.js.map
\ No newline at end of file
//# sourceMappingURL=1do3_crates_turbopack-tests_tests_snapshot_workers_shared_input_index_1eutg7d.js.map
\ No newline at end of file
......@@ -732,44 +732,30 @@ browserContextPrototype.P = resolveAbsolutePath;
}
browserContextPrototype.q = exportUrl;
/**
* Creates a worker by instantiating the given WorkerConstructor with the
* appropriate URL and options.
*
* The entrypoint is a pre-compiled worker runtime file. The params configure
* which module chunks to load and which module to run as the entry point.
*
* The params are a JSON array of the following structure:
* `[TURBOPACK_NEXT_CHUNK_URLS, ASSET_SUFFIX, ...WORKER_FORWARDED_GLOBALS values]`
*
* @param WorkerConstructor The Worker or SharedWorker constructor
* @param entrypoint URL path to the worker entrypoint chunk
* @param moduleChunks list of module chunk paths to load
* @param workerOptions options to pass to the Worker constructor (optional)
*/ function createWorker(WorkerConstructor, entrypoint, moduleChunks, workerOptions) {
const isSharedWorker = WorkerConstructor.name === 'SharedWorker';
const chunkUrls = moduleChunks.map((chunk)=>getChunkRelativeUrl(chunk)).reverse();
const params = [
chunkUrls,
ASSET_SUFFIX
];
for (const globalName of WORKER_FORWARDED_GLOBALS){
params.push(globalThis[globalName]);
}
const url = new URL(getChunkRelativeUrl(entrypoint), location.origin);
const paramsJson = JSON.stringify(params);
if (isSharedWorker) {
url.searchParams.set('params', paramsJson);
} else {
url.hash = '#params=' + encodeURIComponent(paramsJson);
}
// Remove type: "module" from options since our worker entrypoint is not a module
const options = workerOptions ? {
...workerOptions,
type: undefined
} : undefined;
return new WorkerConstructor(url, options);
* Returns the full chunk URL for a chunk path, including CHUNK_BASE_PATH prefix
* and ASSET_SUFFIX. Used by extracted worker/wasm modules.
*/ function chunkUrl(chunkPath) {
return getChunkRelativeUrl(chunkPath);
}
browserContextPrototype.w = chunkUrl;
/**
* Returns the ASSET_SUFFIX string. Used by extracted worker modules.
*/ function assetSuffix() {
return ASSET_SUFFIX;
}
browserContextPrototype.b = createWorker;
browserContextPrototype.X = assetSuffix;
/**
* Returns the list of worker-forwarded global names.
*/ function forwardedGlobals() {
return WORKER_FORWARDED_GLOBALS;
}
browserContextPrototype.b = forwardedGlobals;
/**
* Resolves a chunk path. On browser, returns the path as-is (not applicable).
*/ function resolveChunkPath(chunkPath) {
return chunkPath;
}
browserContextPrototype.u = resolveChunkPath;
/**
* Instantiates a runtime module.
*/ function instantiateRuntimeModule(moduleId, chunkPath) {
......@@ -840,14 +826,6 @@ function isJs(chunkUrlOrPath) {
function isCss(chunkUrl) {
return endsWithExtension(chunkUrl, '.css');
}
function loadWebAssembly(chunkPath, edgeModule, importsObj) {
return BACKEND.loadWebAssembly(SourceType.Parent, this.m.id, chunkPath, edgeModule, importsObj);
}
contextPrototype.w = loadWebAssembly;
function loadWebAssemblyModule(chunkPath, edgeModule) {
return BACKEND.loadWebAssemblyModule(SourceType.Parent, this.m.id, chunkPath, edgeModule);
}
contextPrototype.u = loadWebAssemblyModule;
/// <reference path="./runtime-utils.ts" />
/// <reference path="./runtime-types.d.ts" />
/// <reference path="./dev-extensions.ts" />
......@@ -2005,15 +1983,6 @@ let BACKEND;
* has been loaded.
*/ loadChunkCached (sourceType, chunkUrl) {
return doLoadChunk(sourceType, chunkUrl);
},
async loadWebAssembly (_sourceType, _sourceData, wasmChunkPath, _edgeModule, importsObj) {
const req = fetchWebAssembly(wasmChunkPath);
const { instance } = await WebAssembly.instantiateStreaming(req, importsObj);
return instance.exports;
},
async loadWebAssemblyModule (_sourceType, _sourceData, wasmChunkPath, _edgeModule) {
const req = fetchWebAssembly(wasmChunkPath);
return await WebAssembly.compileStreaming(req);
}
};
function getOrCreateResolver(chunkUrl) {
......@@ -2126,9 +2095,6 @@ let BACKEND;
resolver.loadingStarted = true;
return resolver.promise;
}
function fetchWebAssembly(wasmChunkPath) {
return fetch(getChunkRelativeUrl(wasmChunkPath));
}
})();
/**
* This file contains the runtime code specific to the Turbopack development
......
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/turbopack_crates_turbopack-tests_tests_snapshot_workers_shared_input_0g-vw3t._.js",
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/[root-of-the-server]__09q-mwc._.js",
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/workers/shared/input/worker.js (static in ecmascript)", ((__turbopack_context__) => {
__turbopack_context__.q("/static/worker.1n36e5vaxakik.js");}),
"[turbopack]/shared/worker-browser.ts [test] (ecmascript)", ((__turbopack_context__) => {
"use strict";
__turbopack_context__.s([
"createWorker",
()=>createWorker
]);
/**
* Browser worker creation module.
* Only included when a Web Worker or SharedWorker is actually used.
*/ /* eslint-disable @typescript-eslint/no-unused-vars */ 'use turbopack no side effects';
function createWorker(WorkerConstructor, entrypoint, moduleChunks, workerOptions) {
const isSharedWorker = WorkerConstructor.name === 'SharedWorker';
const chunkUrls = moduleChunks.map((chunk)=>__turbopack_chunk_url__(chunk)).reverse();
const params = [
chunkUrls,
__turbopack_asset_suffix__()
];
for (const globalName of __turbopack_forwarded_globals__()){
params.push(globalThis[globalName]);
}
const url = new URL(__turbopack_chunk_url__(entrypoint), location.origin);
const paramsJson = JSON.stringify(params);
if (isSharedWorker) {
url.searchParams.set('params', paramsJson);
} else {
url.hash = '#params=' + encodeURIComponent(paramsJson);
}
// Remove type: "module" from options since our worker entrypoint is not a module
const options = workerOptions ? {
...workerOptions,
type: undefined
} : undefined;
return new WorkerConstructor(url, options);
}
}),
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/workers/shared/input/worker.js [test] (ecmascript, worker loader)", ((__turbopack_context__) => {
var createWorker = __turbopack_context__.r("[turbopack]/shared/worker-browser.ts [test] (ecmascript)").createWorker;
__turbopack_context__.v(function(Ctor, opts) {
return __turbopack_context__.b(Ctor, "output/0uxq_crates_turbopack-tests_tests_snapshot_workers_shared_output_0uy0mni._.js", ["output/1do3_crates_turbopack-tests_tests_snapshot_workers_shared_input_worker_1u1i0a1.js","output/1i9t_crates_turbopack-tests_tests_snapshot_workers_shared_input_worker_1xw116u.js"], opts);
return createWorker(Ctor, "output/0uxq_crates_turbopack-tests_tests_snapshot_workers_shared_output_0uy0mni._.js", ["output/1do3_crates_turbopack-tests_tests_snapshot_workers_shared_input_worker_1u1i0a1.js","output/1i9t_crates_turbopack-tests_tests_snapshot_workers_shared_input_worker_1xw116u.js"], opts);
});
}),
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/workers/shared/input/index.js [test] (ecmascript)", ((__turbopack_context__, module, exports) => {
......@@ -20,4 +57,4 @@ __turbopack_context__.r("[project]/turbopack/crates/turbopack-tests/tests/snapsh
}),
]);
//# sourceMappingURL=turbopack_crates_turbopack-tests_tests_snapshot_workers_shared_input_0g-vw3t._.js.map
\ No newline at end of file
//# sourceMappingURL=%5Broot-of-the-server%5D__09q-mwc._.js.map
\ No newline at end of file
{
"version": 3,
"sources": [],
"sections": [
{"offset": {"line": 7, "column": 0}, "map": {"version":3,"sources":["turbopack:///[turbopack]/shared/worker-browser.ts"],"sourcesContent":["/**\n * Browser worker creation module.\n * Only included when a Web Worker or SharedWorker is actually used.\n */\n\n/* eslint-disable @typescript-eslint/no-unused-vars */\n\n'use turbopack no side effects'\n\ndeclare function __turbopack_chunk_url__(chunkPath: string): string\ndeclare function __turbopack_forwarded_globals__(): string[]\ndeclare function __turbopack_asset_suffix__(): string\n\n/**\n * Creates a worker by instantiating the given WorkerConstructor with the\n * appropriate URL and options.\n *\n * The entrypoint is a pre-compiled worker runtime file. The params configure\n * which module chunks to load and which module to run as the entry point.\n *\n * The params are a JSON array of the following structure:\n * `[TURBOPACK_NEXT_CHUNK_URLS, ASSET_SUFFIX, ...WORKER_FORWARDED_GLOBALS values]`\n *\n * @param WorkerConstructor The Worker or SharedWorker constructor\n * @param entrypoint URL path to the worker entrypoint chunk\n * @param moduleChunks list of module chunk paths to load\n * @param workerOptions options to pass to the Worker constructor (optional)\n */\nexport function createWorker(\n WorkerConstructor: { new (url: URL, options?: object): Worker },\n entrypoint: string,\n moduleChunks: string[],\n workerOptions?: object\n): Worker {\n const isSharedWorker = WorkerConstructor.name === 'SharedWorker'\n\n const chunkUrls = moduleChunks\n .map((chunk) => __turbopack_chunk_url__(chunk))\n .reverse()\n const params: unknown[] = [chunkUrls, __turbopack_asset_suffix__()]\n for (const globalName of __turbopack_forwarded_globals__()) {\n params.push((globalThis as Record<string, unknown>)[globalName])\n }\n\n const url = new URL(__turbopack_chunk_url__(entrypoint), location.origin)\n const paramsJson = JSON.stringify(params)\n if (isSharedWorker) {\n url.searchParams.set('params', paramsJson)\n } else {\n url.hash = '#params=' + encodeURIComponent(paramsJson)\n }\n\n // Remove type: \"module\" from options since our worker entrypoint is not a module\n const options = workerOptions\n ? { ...workerOptions, type: undefined }\n : undefined\n return new WorkerConstructor(url, options)\n}\n"],"names":["createWorker","WorkerConstructor","entrypoint","moduleChunks","workerOptions","isSharedWorker","name","chunkUrls","map","chunk","__turbopack_chunk_url__","reverse","params","__turbopack_asset_suffix__","globalName","__turbopack_forwarded_globals__","push","globalThis","url","URL","location","origin","paramsJson","JSON","stringify","searchParams","set","hash","encodeURIComponent","options","type","undefined"],"mappings":";;;;AAAA;;;CAGC,GAED,oDAAoD,GAEpD;AAqBO,SAASA,aACdC,iBAA+D,EAC/DC,UAAkB,EAClBC,YAAsB,EACtBC,aAAsB;IAEtB,MAAMC,iBAAiBJ,kBAAkBK,IAAI,KAAK;IAElD,MAAMC,YAAYJ,aACfK,GAAG,CAAC,CAACC,QAAUC,wBAAwBD,QACvCE,OAAO;IACV,MAAMC,SAAoB;QAACL;QAAWM;KAA6B;IACnE,KAAK,MAAMC,cAAcC,kCAAmC;QAC1DH,OAAOI,IAAI,CAAC,AAACC,UAAsC,CAACH,WAAW;IACjE;IAEA,MAAMI,MAAM,IAAIC,IAAIT,wBAAwBR,aAAakB,SAASC,MAAM;IACxE,MAAMC,aAAaC,KAAKC,SAAS,CAACZ;IAClC,IAAIP,gBAAgB;QAClBa,IAAIO,YAAY,CAACC,GAAG,CAAC,UAAUJ;IACjC,OAAO;QACLJ,IAAIS,IAAI,GAAG,aAAaC,mBAAmBN;IAC7C;IAEA,iFAAiF;IACjF,MAAMO,UAAUzB,gBACZ;QAAE,GAAGA,aAAa;QAAE0B,MAAMC;IAAU,IACpCA;IACJ,OAAO,IAAI9B,kBAAkBiB,KAAKW;AACpC","ignoreList":[0]}},
{"offset": {"line": 49, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/workers/shared/input/index.js"],"sourcesContent":["const url = new URL('./worker.js', import.meta.url)\nnew SharedWorker(url)\n"],"names":["url","SharedWorker"],"mappings":";;;;;AAAA,MAAMA;AACN,uJAAIC"}}]
}
\ No newline at end of file
{
"version": 3,
"sources": [],
"sections": [
{"offset": {"line": 12, "column": 0}, "map": {"version":3,"sources":["turbopack:///[project]/turbopack/crates/turbopack-tests/tests/snapshot/workers/shared/input/index.js"],"sourcesContent":["const url = new URL('./worker.js', import.meta.url)\nnew SharedWorker(url)\n"],"names":["url","SharedWorker"],"mappings":";;;;;AAAA,MAAMA;AACN,uJAAIC"}}]
}
\ No newline at end of file
......@@ -5,18 +5,34 @@ use indoc::{formatdoc, writedoc};
use turbo_rcstr::RcStr;
use turbo_tasks::Vc;
use turbo_tasks_fs::{File, FileContent};
use turbopack_core::{asset::AssetContent, source::Source, virtual_source::VirtualSource};
use turbopack_core::{
asset::AssetContent, context::AssetContext, environment::ChunkLoading, source::Source,
virtual_source::VirtualSource,
};
use turbopack_ecmascript::utils::StringifyJs;
use crate::{analysis::analyze, source::WebAssemblySource, wasm_edge_var_name};
/// Determines the `@turbopack/wasm-*` module name based on the environment.
async fn wasm_module_name(asset_context: Vc<Box<dyn AssetContext>>) -> Result<&'static str> {
let environment = asset_context.compile_time_info().environment();
let chunk_loading = &*environment.chunk_loading().await?;
Ok(match chunk_loading {
ChunkLoading::NodeJs => "@turbopack/wasm-node",
ChunkLoading::Edge => "@turbopack/wasm-edge",
ChunkLoading::Dom => "@turbopack/wasm-dom",
})
}
/// Create a javascript loader to instantiate the WebAssembly module with the
/// necessary imports and exports to be processed by [turbopack_ecmascript].
#[turbo_tasks::function]
pub(crate) async fn instantiating_loader_source(
source: Vc<WebAssemblySource>,
asset_context: Vc<Box<dyn AssetContext>>,
) -> Result<Vc<Box<dyn Source>>> {
let analysis = analyze(source).await?;
let wasm_module = wasm_module_name(asset_context).await?;
let mut code = String::new();
......@@ -37,6 +53,11 @@ pub(crate) async fn instantiating_loader_source(
}
writeln!(imports_obj, "}}")?;
writeln!(
code,
"import {{ instantiateWebAssembly }} from {:?};",
wasm_module
)?;
writeln!(code, "import wasmPath from \"WASM_PATH\";")?;
writeln!(code)?;
......@@ -44,7 +65,7 @@ pub(crate) async fn instantiating_loader_source(
writedoc!(
code,
r#"
const {{ {exports} }} = await __turbopack_wasm__(wasmPath, () => {edgeVariable}, {imports});
const {{ {exports} }} = await instantiateWebAssembly(wasmPath, () => {edgeVariable}, {imports});
export {{ {exports} }};
"#,
......@@ -66,15 +87,20 @@ pub(crate) async fn instantiating_loader_source(
#[turbo_tasks::function]
pub(crate) async fn compiling_loader_source(
source: Vc<WebAssemblySource>,
asset_context: Vc<Box<dyn AssetContext>>,
) -> Result<Vc<Box<dyn Source>>> {
let wasm_module = wasm_module_name(asset_context).await?;
let code: RcStr = formatdoc! {
r#"
import {{ compileWebAssembly }} from {:?};
import wasmPath from "WASM_PATH";
const mod = await __turbopack_wasm_module__(wasmPath, () => {edgeVariable});
const mod = await compileWebAssembly(wasmPath, () => {edgeVariable});
export default mod;
"#,
wasm_module,
edgeVariable = wasm_edge_var_name(Vc::upcast(source)).await?
}
.into();
......
......@@ -63,9 +63,9 @@ impl WebAssemblyModuleAsset {
let query = &self.source.ident().await?.query;
let loader_source = if query == "?module" {
compiling_loader_source(*self.source)
compiling_loader_source(*self.source, *self.asset_context)
} else {
instantiating_loader_source(*self.source)
instantiating_loader_source(*self.source, *self.asset_context)
};
let module = self.asset_context.process(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment