Unverified Commit bb65e78a authored by Tobias Koppers's avatar Tobias Koppers Committed by GitHub

Turbopack: avoid embedding deployment ID into the turbopack runtime (#86370)

### What?

* add support for multiple options for chunk suffix
* Use FromScriptSrc chunk suffix to avoid depending on deployment id
* fix passing chunk suffix to WebWorkers initial chunks
parent f0af7cd0
...@@ -1144,7 +1144,6 @@ impl Project { ...@@ -1144,7 +1144,6 @@ impl Project {
client_root: self.client_relative_path().owned().await?, client_root: self.client_relative_path().owned().await?,
client_root_to_root_path: rcstr!("/ROOT"), client_root_to_root_path: rcstr!("/ROOT"),
asset_prefix: self.next_config().computed_asset_prefix(), asset_prefix: self.next_config().computed_asset_prefix(),
chunk_suffix_path: self.next_config().chunk_suffix_path(),
environment: self.client_compile_time_info().environment(), environment: self.client_compile_time_info().environment(),
module_id_strategy: self.module_ids(), module_id_strategy: self.module_ids(),
export_usage: self.export_usage(), export_usage: self.export_usage(),
......
...@@ -14,7 +14,7 @@ use turbopack::{ ...@@ -14,7 +14,7 @@ use turbopack::{
resolve_options_context::ResolveOptionsContext, resolve_options_context::ResolveOptionsContext,
}; };
use turbopack_browser::{ use turbopack_browser::{
BrowserChunkingContext, ContentHashing, CurrentChunkMethod, BrowserChunkingContext, ChunkSuffix, ContentHashing, CurrentChunkMethod,
react_refresh::assert_can_resolve_react_refresh, react_refresh::assert_can_resolve_react_refresh,
}; };
use turbopack_core::{ use turbopack_core::{
...@@ -414,7 +414,6 @@ pub struct ClientChunkingContextOptions { ...@@ -414,7 +414,6 @@ pub struct ClientChunkingContextOptions {
pub client_root: FileSystemPath, pub client_root: FileSystemPath,
pub client_root_to_root_path: RcStr, pub client_root_to_root_path: RcStr,
pub asset_prefix: Vc<RcStr>, pub asset_prefix: Vc<RcStr>,
pub chunk_suffix_path: Vc<Option<RcStr>>,
pub environment: Vc<Environment>, pub environment: Vc<Environment>,
pub module_id_strategy: Vc<Box<dyn ModuleIdStrategy>>, pub module_id_strategy: Vc<Box<dyn ModuleIdStrategy>>,
pub export_usage: Vc<OptionExportUsageInfo>, pub export_usage: Vc<OptionExportUsageInfo>,
...@@ -437,7 +436,6 @@ pub async fn get_client_chunking_context( ...@@ -437,7 +436,6 @@ pub async fn get_client_chunking_context(
client_root, client_root,
client_root_to_root_path, client_root_to_root_path,
asset_prefix, asset_prefix,
chunk_suffix_path,
environment, environment,
module_id_strategy, module_id_strategy,
export_usage, export_usage,
...@@ -452,7 +450,6 @@ pub async fn get_client_chunking_context( ...@@ -452,7 +450,6 @@ pub async fn get_client_chunking_context(
let next_mode = mode.await?; let next_mode = mode.await?;
let asset_prefix = asset_prefix.owned().await?; let asset_prefix = asset_prefix.owned().await?;
let chunk_suffix_path = chunk_suffix_path.to_resolved().await?;
let mut builder = BrowserChunkingContext::builder( let mut builder = BrowserChunkingContext::builder(
root_path, root_path,
client_root.clone(), client_root.clone(),
...@@ -464,7 +461,7 @@ pub async fn get_client_chunking_context( ...@@ -464,7 +461,7 @@ pub async fn get_client_chunking_context(
next_mode.runtime_type(), next_mode.runtime_type(),
) )
.chunk_base_path(Some(asset_prefix.clone())) .chunk_base_path(Some(asset_prefix.clone()))
.chunk_suffix_path(chunk_suffix_path) .chunk_suffix(ChunkSuffix::FromScriptSrc.resolved_cell())
.minify_type(if *minify.await? { .minify_type(if *minify.await? {
MinifyType::Minify { MinifyType::Minify {
mangle: (!*no_mangling.await?).then_some(MangleType::OptimalSize), mangle: (!*no_mangling.await?).then_some(MangleType::OptimalSize),
......
...@@ -33,7 +33,7 @@ use turbopack_ecmascript::{ ...@@ -33,7 +33,7 @@ use turbopack_ecmascript::{
chunk::EcmascriptChunk, chunk::EcmascriptChunk,
manifest::{chunk_asset::ManifestAsyncModule, loader_item::ManifestLoaderChunkItem}, manifest::{chunk_asset::ManifestAsyncModule, loader_item::ManifestLoaderChunkItem},
}; };
use turbopack_ecmascript_runtime::RuntimeType; use turbopack_ecmascript_runtime::{ChunkSuffix, RuntimeType};
use crate::ecmascript::{ use crate::ecmascript::{
chunk::EcmascriptBrowserChunk, chunk::EcmascriptBrowserChunk,
...@@ -130,8 +130,8 @@ impl BrowserChunkingContextBuilder { ...@@ -130,8 +130,8 @@ impl BrowserChunkingContextBuilder {
self self
} }
pub fn chunk_suffix_path(mut self, chunk_suffix_path: ResolvedVc<Option<RcStr>>) -> Self { pub fn chunk_suffix(mut self, chunk_suffix: ResolvedVc<ChunkSuffix>) -> Self {
self.chunking_context.chunk_suffix_path = Some(chunk_suffix_path); self.chunking_context.chunk_suffix = Some(chunk_suffix);
self self
} }
...@@ -253,9 +253,9 @@ pub struct BrowserChunkingContext { ...@@ -253,9 +253,9 @@ pub struct BrowserChunkingContext {
/// Base path that will be prepended to all chunk URLs when loading them. /// Base path that will be prepended to all chunk URLs when loading them.
/// This path will not appear in chunk paths or chunk data. /// This path will not appear in chunk paths or chunk data.
chunk_base_path: Option<RcStr>, chunk_base_path: Option<RcStr>,
/// Suffix path that will be appended to all chunk URLs when loading them. /// Suffix that will be appended to all chunk URLs when loading them.
/// This path will not appear in chunk paths or chunk data. /// This path will not appear in chunk paths or chunk data.
chunk_suffix_path: Option<ResolvedVc<Option<RcStr>>>, chunk_suffix: Option<ResolvedVc<ChunkSuffix>>,
/// URL prefix that will be prepended to all static asset URLs when loading /// URL prefix that will be prepended to all static asset URLs when loading
/// them. /// them.
asset_base_path: Option<RcStr>, asset_base_path: Option<RcStr>,
...@@ -322,7 +322,7 @@ impl BrowserChunkingContext { ...@@ -322,7 +322,7 @@ impl BrowserChunkingContext {
asset_root_path, asset_root_path,
asset_root_paths: Default::default(), asset_root_paths: Default::default(),
chunk_base_path: None, chunk_base_path: None,
chunk_suffix_path: None, chunk_suffix: None,
asset_base_path: None, asset_base_path: None,
asset_base_paths: Default::default(), asset_base_paths: Default::default(),
enable_hot_module_replacement: false, enable_hot_module_replacement: false,
...@@ -425,11 +425,11 @@ impl BrowserChunkingContext { ...@@ -425,11 +425,11 @@ impl BrowserChunkingContext {
/// Returns the asset suffix path. /// Returns the asset suffix path.
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn chunk_suffix_path(&self) -> Vc<Option<RcStr>> { pub fn chunk_suffix(&self) -> Vc<ChunkSuffix> {
if let Some(chunk_suffix_path) = self.chunk_suffix_path { if let Some(chunk_suffix) = self.chunk_suffix {
*chunk_suffix_path *chunk_suffix
} else { } else {
Vc::cell(None) ChunkSuffix::None.cell()
} }
} }
......
...@@ -173,7 +173,7 @@ impl EcmascriptBrowserEvaluateChunk { ...@@ -173,7 +173,7 @@ impl EcmascriptBrowserEvaluateChunk {
let runtime_code = turbopack_ecmascript_runtime::get_browser_runtime_code( let runtime_code = turbopack_ecmascript_runtime::get_browser_runtime_code(
environment, environment,
this.chunking_context.chunk_base_path(), this.chunking_context.chunk_base_path(),
this.chunking_context.chunk_suffix_path(), this.chunking_context.chunk_suffix(),
runtime_type, runtime_type,
output_root_to_root_path, output_root_to_root_path,
source_maps, source_maps,
......
...@@ -10,3 +10,4 @@ pub mod react_refresh; ...@@ -10,3 +10,4 @@ pub mod react_refresh;
pub use chunking_context::{ pub use chunking_context::{
BrowserChunkingContext, BrowserChunkingContextBuilder, ContentHashing, CurrentChunkMethod, BrowserChunkingContext, BrowserChunkingContextBuilder, ContentHashing, CurrentChunkMethod,
}; };
pub use turbopack_ecmascript_runtime::ChunkSuffix;
...@@ -29,4 +29,3 @@ turbo-tasks-fs = { workspace = true } ...@@ -29,4 +29,3 @@ turbo-tasks-fs = { workspace = true }
turbopack = { workspace = true } turbopack = { workspace = true }
turbopack-core = { workspace = true } turbopack-core = { workspace = true }
turbopack-ecmascript = { workspace = true } turbopack-ecmascript = { workspace = true }
...@@ -13,13 +13,15 @@ ...@@ -13,13 +13,15 @@
// Used in WebWorkers to tell the runtime about the chunk base path // Used in WebWorkers to tell the runtime about the chunk base path
declare var TURBOPACK_WORKER_LOCATION: string declare var TURBOPACK_WORKER_LOCATION: string
// Used in WebWorkers to tell the runtime about the chunk suffix
declare var TURBOPACK_CHUNK_SUFFIX: string
// Used in WebWorkers to tell the runtime about the current chunk url since it can't be detected via document.currentScript // Used in WebWorkers to tell the runtime about the current chunk url since it can't be detected via document.currentScript
// Note it's stored in reversed order to use push and pop // Note it's stored in reversed order to use push and pop
declare var TURBOPACK_NEXT_CHUNK_URLS: ChunkUrl[] | undefined declare var TURBOPACK_NEXT_CHUNK_URLS: ChunkUrl[] | undefined
// Injected by rust code // Injected by rust code
declare var CHUNK_BASE_PATH: string declare var CHUNK_BASE_PATH: string
declare var CHUNK_SUFFIX_PATH: string declare var CHUNK_SUFFIX: string
interface TurbopackBrowserBaseContext<M> extends TurbopackBaseContext<M> { interface TurbopackBrowserBaseContext<M> extends TurbopackBaseContext<M> {
R: ResolvePathFromModule R: ResolvePathFromModule
...@@ -322,8 +324,9 @@ function getWorkerBlobURL(chunks: ChunkPath[]): string { ...@@ -322,8 +324,9 @@ function getWorkerBlobURL(chunks: ChunkPath[]): string {
// It is important to reverse the array so when bootstrapping we can infer what chunk is being // It is important to reverse the array so when bootstrapping we can infer what chunk is being
// evaluated by poping urls off of this array. See `getPathFromScript` // evaluated by poping urls off of this array. See `getPathFromScript`
let bootstrap = `self.TURBOPACK_WORKER_LOCATION = ${JSON.stringify(location.origin)}; let bootstrap = `self.TURBOPACK_WORKER_LOCATION = ${JSON.stringify(location.origin)};
self.TURBOPACK_CHUNK_SUFFIX = ${JSON.stringify(CHUNK_SUFFIX)};
self.TURBOPACK_NEXT_CHUNK_URLS = ${JSON.stringify(chunks.reverse().map(getChunkRelativeUrl), null, 2)}; self.TURBOPACK_NEXT_CHUNK_URLS = ${JSON.stringify(chunks.reverse().map(getChunkRelativeUrl), null, 2)};
importScripts(...self.TURBOPACK_NEXT_CHUNK_URLS.map(c => self.TURBOPACK_WORKER_LOCATION + c).reverse());` importScripts(...self.TURBOPACK_NEXT_CHUNK_URLS.map(c => self.TURBOPACK_WORKER_LOCATION + c + self.TURBOPACK_CHUNK_SUFFIX).reverse());`
let blob = new Blob([bootstrap], { type: 'text/javascript' }) let blob = new Blob([bootstrap], { type: 'text/javascript' })
return URL.createObjectURL(blob) return URL.createObjectURL(blob)
} }
...@@ -345,7 +348,7 @@ function getChunkRelativeUrl(chunkPath: ChunkPath | ChunkListPath): ChunkUrl { ...@@ -345,7 +348,7 @@ function getChunkRelativeUrl(chunkPath: ChunkPath | ChunkListPath): ChunkUrl {
return `${CHUNK_BASE_PATH}${chunkPath return `${CHUNK_BASE_PATH}${chunkPath
.split('/') .split('/')
.map((p) => encodeURIComponent(p)) .map((p) => encodeURIComponent(p))
.join('/')}${CHUNK_SUFFIX_PATH}` as ChunkUrl .join('/')}${CHUNK_SUFFIX}` as ChunkUrl
} }
/** /**
......
...@@ -111,7 +111,7 @@ let DEV_BACKEND: DevRuntimeBackend ...@@ -111,7 +111,7 @@ let DEV_BACKEND: DevRuntimeBackend
function _eval({ code, url, map }: EcmascriptModuleEntry): ModuleFactory { function _eval({ code, url, map }: EcmascriptModuleEntry): ModuleFactory {
code += `\n\n//# sourceURL=${encodeURI( code += `\n\n//# sourceURL=${encodeURI(
location.origin + CHUNK_BASE_PATH + url + CHUNK_SUFFIX_PATH location.origin + CHUNK_BASE_PATH + url + CHUNK_SUFFIX
)}` )}`
if (map) { if (map) {
code += `\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,${btoa( code += `\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,${btoa(
......
...@@ -11,14 +11,16 @@ use turbopack_core::{ ...@@ -11,14 +11,16 @@ use turbopack_core::{
}; };
use turbopack_ecmascript::utils::StringifyJs; use turbopack_ecmascript::utils::StringifyJs;
use crate::{RuntimeType, asset_context::get_runtime_asset_context, embed_js::embed_static_code}; use crate::{
ChunkSuffix, RuntimeType, asset_context::get_runtime_asset_context, embed_js::embed_static_code,
};
/// Returns the code for the ECMAScript runtime. /// Returns the code for the ECMAScript runtime.
#[turbo_tasks::function] #[turbo_tasks::function]
pub async fn get_browser_runtime_code( pub async fn get_browser_runtime_code(
environment: ResolvedVc<Environment>, environment: ResolvedVc<Environment>,
chunk_base_path: Vc<Option<RcStr>>, chunk_base_path: Vc<Option<RcStr>>,
chunk_suffix_path: Vc<Option<RcStr>>, chunk_suffix: Vc<ChunkSuffix>,
runtime_type: RuntimeType, runtime_type: RuntimeType,
output_root_to_root_path: RcStr, output_root_to_root_path: RcStr,
generate_source_map: bool, generate_source_map: bool,
...@@ -80,10 +82,7 @@ pub async fn get_browser_runtime_code( ...@@ -80,10 +82,7 @@ pub async fn get_browser_runtime_code(
let relative_root_path = output_root_to_root_path; let relative_root_path = output_root_to_root_path;
let chunk_base_path = chunk_base_path.await?; let chunk_base_path = chunk_base_path.await?;
let chunk_base_path = chunk_base_path.as_ref().map_or_else(|| "", |f| f.as_str()); let chunk_base_path = chunk_base_path.as_ref().map_or_else(|| "", |f| f.as_str());
let chunk_suffix_path = chunk_suffix_path.await?; let chunk_suffix = chunk_suffix.await?;
let chunk_suffix_path = chunk_suffix_path
.as_ref()
.map_or_else(|| "", |f| f.as_str());
writedoc!( writedoc!(
code, code,
...@@ -94,16 +93,42 @@ pub async fn get_browser_runtime_code( ...@@ -94,16 +93,42 @@ pub async fn get_browser_runtime_code(
}} }}
const CHUNK_BASE_PATH = {}; const CHUNK_BASE_PATH = {};
const CHUNK_SUFFIX_PATH = {};
const RELATIVE_ROOT_PATH = {}; const RELATIVE_ROOT_PATH = {};
const RUNTIME_PUBLIC_PATH = {}; const RUNTIME_PUBLIC_PATH = {};
"#, "#,
StringifyJs(chunk_base_path), StringifyJs(chunk_base_path),
StringifyJs(chunk_suffix_path),
StringifyJs(relative_root_path.as_str()), StringifyJs(relative_root_path.as_str()),
StringifyJs(chunk_base_path), StringifyJs(chunk_base_path),
)?; )?;
match &*chunk_suffix {
ChunkSuffix::None => {
writedoc!(
code,
r#"
const CHUNK_SUFFIX = "";
"#
)?;
}
ChunkSuffix::Constant(suffix) => {
writedoc!(
code,
r#"
const CHUNK_SUFFIX = {};
"#,
StringifyJs(suffix.as_str())
)?;
}
ChunkSuffix::FromScriptSrc => {
writedoc!(
code,
r#"
const CHUNK_SUFFIX = (self.TURBOPACK_CHUNK_SUFFIX ?? document?.currentScript?.getAttribute?.('src')?.replace(/^(.*(?=\?)|^.*$)/, "")) || "";
"#
)?;
}
}
code.push_code(&*shared_runtime_utils_code.await?); code.push_code(&*shared_runtime_utils_code.await?);
for runtime_code in runtime_base_code { for runtime_code in runtime_base_code {
code.push_code( code.push_code(
......
use turbo_rcstr::RcStr;
#[turbo_tasks::value(shared)]
pub enum ChunkSuffix {
/// No suffix.
None,
/// A constant suffix to append to chunk URLs.
Constant(RcStr),
/// Use the query string of the `src` attribute of the current script tag as a suffix for chunk
/// loading.
FromScriptSrc,
}
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
pub(crate) mod asset_context; pub(crate) mod asset_context;
pub(crate) mod browser_runtime; pub(crate) mod browser_runtime;
pub(crate) mod chunk_suffix;
#[cfg(feature = "test")] #[cfg(feature = "test")]
pub(crate) mod dummy_runtime; pub(crate) mod dummy_runtime;
pub(crate) mod embed_js; pub(crate) mod embed_js;
...@@ -10,6 +11,7 @@ pub(crate) mod nodejs_runtime; ...@@ -10,6 +11,7 @@ pub(crate) mod nodejs_runtime;
pub(crate) mod runtime_type; pub(crate) mod runtime_type;
pub use browser_runtime::get_browser_runtime_code; pub use browser_runtime::get_browser_runtime_code;
pub use chunk_suffix::ChunkSuffix;
#[cfg(feature = "test")] #[cfg(feature = "test")]
pub use dummy_runtime::get_dummy_runtime_code; pub use dummy_runtime::get_dummy_runtime_code;
pub use embed_js::{embed_file, embed_file_path, embed_fs}; pub use embed_js::{embed_file, embed_file_path, embed_fs};
......
;!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]="9cc3c4ae-b6b3-7945-3645-c0e627a5103b")}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]="683a00e2-39b4-f14a-ae2f-75a281be4c75")}catch(e){}}();
(globalThis.TURBOPACK || (globalThis.TURBOPACK = [])).push([ (globalThis.TURBOPACK || (globalThis.TURBOPACK = [])).push([
"output/ba425_crates_turbopack-tests_tests_snapshot_debug-ids_browser_input_index_0151fefb.js", "output/ba425_crates_turbopack-tests_tests_snapshot_debug-ids_browser_input_index_0151fefb.js",
{"otherChunks":["output/aaf3a_crates_turbopack-tests_tests_snapshot_debug-ids_browser_input_index_0b8736b3.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/debug-ids/browser/input/index.js [test] (ecmascript)"]} {"otherChunks":["output/aaf3a_crates_turbopack-tests_tests_snapshot_debug-ids_browser_input_index_0b8736b3.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/debug-ids/browser/input/index.js [test] (ecmascript)"]}
...@@ -9,9 +9,9 @@ if (!Array.isArray(globalThis.TURBOPACK)) { ...@@ -9,9 +9,9 @@ if (!Array.isArray(globalThis.TURBOPACK)) {
} }
const CHUNK_BASE_PATH = ""; const CHUNK_BASE_PATH = "";
const CHUNK_SUFFIX_PATH = "";
const RELATIVE_ROOT_PATH = "../../../../../../.."; const RELATIVE_ROOT_PATH = "../../../../../../..";
const RUNTIME_PUBLIC_PATH = ""; const RUNTIME_PUBLIC_PATH = "";
const CHUNK_SUFFIX = "";
/** /**
* This file contains runtime types and functions that are shared between all * This file contains runtime types and functions that are shared between all
* TurboPack ECMAScript runtimes. * TurboPack ECMAScript runtimes.
...@@ -667,8 +667,9 @@ browserContextPrototype.P = resolveAbsolutePath; ...@@ -667,8 +667,9 @@ browserContextPrototype.P = resolveAbsolutePath;
// It is important to reverse the array so when bootstrapping we can infer what chunk is being // It is important to reverse the array so when bootstrapping we can infer what chunk is being
// evaluated by poping urls off of this array. See `getPathFromScript` // evaluated by poping urls off of this array. See `getPathFromScript`
let bootstrap = `self.TURBOPACK_WORKER_LOCATION = ${JSON.stringify(location.origin)}; let bootstrap = `self.TURBOPACK_WORKER_LOCATION = ${JSON.stringify(location.origin)};
self.TURBOPACK_CHUNK_SUFFIX = ${JSON.stringify(CHUNK_SUFFIX)};
self.TURBOPACK_NEXT_CHUNK_URLS = ${JSON.stringify(chunks.reverse().map(getChunkRelativeUrl), null, 2)}; self.TURBOPACK_NEXT_CHUNK_URLS = ${JSON.stringify(chunks.reverse().map(getChunkRelativeUrl), null, 2)};
importScripts(...self.TURBOPACK_NEXT_CHUNK_URLS.map(c => self.TURBOPACK_WORKER_LOCATION + c).reverse());`; importScripts(...self.TURBOPACK_NEXT_CHUNK_URLS.map(c => self.TURBOPACK_WORKER_LOCATION + c + self.TURBOPACK_CHUNK_SUFFIX).reverse());`;
let blob = new Blob([ let blob = new Blob([
bootstrap bootstrap
], { ], {
...@@ -685,7 +686,7 @@ browserContextPrototype.b = getWorkerBlobURL; ...@@ -685,7 +686,7 @@ browserContextPrototype.b = getWorkerBlobURL;
/** /**
* Returns the URL relative to the origin where a chunk can be fetched from. * Returns the URL relative to the origin where a chunk can be fetched from.
*/ function getChunkRelativeUrl(chunkPath) { */ function getChunkRelativeUrl(chunkPath) {
return `${CHUNK_BASE_PATH}${chunkPath.split('/').map((p)=>encodeURIComponent(p)).join('/')}${CHUNK_SUFFIX_PATH}`; return `${CHUNK_BASE_PATH}${chunkPath.split('/').map((p)=>encodeURIComponent(p)).join('/')}${CHUNK_SUFFIX}`;
} }
function getPathFromScript(chunkScript) { function getPathFromScript(chunkScript) {
if (typeof chunkScript === 'string') { if (typeof chunkScript === 'string') {
...@@ -1816,7 +1817,7 @@ let DEV_BACKEND; ...@@ -1816,7 +1817,7 @@ let DEV_BACKEND;
} }
})(); })();
function _eval({ code, url, map }) { function _eval({ code, url, map }) {
code += `\n\n//# sourceURL=${encodeURI(location.origin + CHUNK_BASE_PATH + url + CHUNK_SUFFIX_PATH)}`; code += `\n\n//# sourceURL=${encodeURI(location.origin + CHUNK_BASE_PATH + url + CHUNK_SUFFIX)}`;
if (map) { if (map) {
code += `\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,${btoa(// btoa doesn't handle nonlatin characters, so escape them as \x sequences code += `\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,${btoa(// btoa doesn't handle nonlatin characters, so escape them as \x sequences
// See https://stackoverflow.com/a/26603875 // See https://stackoverflow.com/a/26603875
...@@ -1834,5 +1835,5 @@ chunkListsToRegister.forEach(registerChunkList); ...@@ -1834,5 +1835,5 @@ chunkListsToRegister.forEach(registerChunkList);
})(); })();
//# debugId=9cc3c4ae-b6b3-7945-3645-c0e627a5103b //# debugId=683a00e2-39b4-f14a-ae2f-75a281be4c75
//# sourceMappingURL=aaf3a_crates_turbopack-tests_tests_snapshot_debug-ids_browser_input_index_0151fefb.js.map //# sourceMappingURL=aaf3a_crates_turbopack-tests_tests_snapshot_debug-ids_browser_input_index_0151fefb.js.map
\ No newline at end of file
...@@ -8,9 +8,9 @@ if (!Array.isArray(globalThis.TURBOPACK)) { ...@@ -8,9 +8,9 @@ if (!Array.isArray(globalThis.TURBOPACK)) {
} }
const CHUNK_BASE_PATH = ""; const CHUNK_BASE_PATH = "";
const CHUNK_SUFFIX_PATH = "";
const RELATIVE_ROOT_PATH = "../../../../../../.."; const RELATIVE_ROOT_PATH = "../../../../../../..";
const RUNTIME_PUBLIC_PATH = ""; const RUNTIME_PUBLIC_PATH = "";
const CHUNK_SUFFIX = "";
/** /**
* This file contains runtime types and functions that are shared between all * This file contains runtime types and functions that are shared between all
* TurboPack ECMAScript runtimes. * TurboPack ECMAScript runtimes.
...@@ -666,8 +666,9 @@ browserContextPrototype.P = resolveAbsolutePath; ...@@ -666,8 +666,9 @@ browserContextPrototype.P = resolveAbsolutePath;
// It is important to reverse the array so when bootstrapping we can infer what chunk is being // It is important to reverse the array so when bootstrapping we can infer what chunk is being
// evaluated by poping urls off of this array. See `getPathFromScript` // evaluated by poping urls off of this array. See `getPathFromScript`
let bootstrap = `self.TURBOPACK_WORKER_LOCATION = ${JSON.stringify(location.origin)}; let bootstrap = `self.TURBOPACK_WORKER_LOCATION = ${JSON.stringify(location.origin)};
self.TURBOPACK_CHUNK_SUFFIX = ${JSON.stringify(CHUNK_SUFFIX)};
self.TURBOPACK_NEXT_CHUNK_URLS = ${JSON.stringify(chunks.reverse().map(getChunkRelativeUrl), null, 2)}; self.TURBOPACK_NEXT_CHUNK_URLS = ${JSON.stringify(chunks.reverse().map(getChunkRelativeUrl), null, 2)};
importScripts(...self.TURBOPACK_NEXT_CHUNK_URLS.map(c => self.TURBOPACK_WORKER_LOCATION + c).reverse());`; importScripts(...self.TURBOPACK_NEXT_CHUNK_URLS.map(c => self.TURBOPACK_WORKER_LOCATION + c + self.TURBOPACK_CHUNK_SUFFIX).reverse());`;
let blob = new Blob([ let blob = new Blob([
bootstrap bootstrap
], { ], {
...@@ -684,7 +685,7 @@ browserContextPrototype.b = getWorkerBlobURL; ...@@ -684,7 +685,7 @@ browserContextPrototype.b = getWorkerBlobURL;
/** /**
* Returns the URL relative to the origin where a chunk can be fetched from. * Returns the URL relative to the origin where a chunk can be fetched from.
*/ function getChunkRelativeUrl(chunkPath) { */ function getChunkRelativeUrl(chunkPath) {
return `${CHUNK_BASE_PATH}${chunkPath.split('/').map((p)=>encodeURIComponent(p)).join('/')}${CHUNK_SUFFIX_PATH}`; return `${CHUNK_BASE_PATH}${chunkPath.split('/').map((p)=>encodeURIComponent(p)).join('/')}${CHUNK_SUFFIX}`;
} }
function getPathFromScript(chunkScript) { function getPathFromScript(chunkScript) {
if (typeof chunkScript === 'string') { if (typeof chunkScript === 'string') {
...@@ -1815,7 +1816,7 @@ let DEV_BACKEND; ...@@ -1815,7 +1816,7 @@ let DEV_BACKEND;
} }
})(); })();
function _eval({ code, url, map }) { function _eval({ code, url, map }) {
code += `\n\n//# sourceURL=${encodeURI(location.origin + CHUNK_BASE_PATH + url + CHUNK_SUFFIX_PATH)}`; code += `\n\n//# sourceURL=${encodeURI(location.origin + CHUNK_BASE_PATH + url + CHUNK_SUFFIX)}`;
if (map) { if (map) {
code += `\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,${btoa(// btoa doesn't handle nonlatin characters, so escape them as \x sequences code += `\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,${btoa(// btoa doesn't handle nonlatin characters, so escape them as \x sequences
// See https://stackoverflow.com/a/26603875 // See https://stackoverflow.com/a/26603875
......
...@@ -8,9 +8,9 @@ if (!Array.isArray(globalThis.TURBOPACK)) { ...@@ -8,9 +8,9 @@ if (!Array.isArray(globalThis.TURBOPACK)) {
} }
const CHUNK_BASE_PATH = ""; const CHUNK_BASE_PATH = "";
const CHUNK_SUFFIX_PATH = "";
const RELATIVE_ROOT_PATH = "../../../../../../.."; const RELATIVE_ROOT_PATH = "../../../../../../..";
const RUNTIME_PUBLIC_PATH = ""; const RUNTIME_PUBLIC_PATH = "";
const CHUNK_SUFFIX = "";
/** /**
* This file contains runtime types and functions that are shared between all * This file contains runtime types and functions that are shared between all
* TurboPack ECMAScript runtimes. * TurboPack ECMAScript runtimes.
...@@ -1148,8 +1148,9 @@ browserContextPrototype.P = resolveAbsolutePath; ...@@ -1148,8 +1148,9 @@ browserContextPrototype.P = resolveAbsolutePath;
// It is important to reverse the array so when bootstrapping we can infer what chunk is being // It is important to reverse the array so when bootstrapping we can infer what chunk is being
// evaluated by poping urls off of this array. See `getPathFromScript` // evaluated by poping urls off of this array. See `getPathFromScript`
var bootstrap = `self.TURBOPACK_WORKER_LOCATION = ${JSON.stringify(location.origin)}; var bootstrap = `self.TURBOPACK_WORKER_LOCATION = ${JSON.stringify(location.origin)};
self.TURBOPACK_CHUNK_SUFFIX = ${JSON.stringify(CHUNK_SUFFIX)};
self.TURBOPACK_NEXT_CHUNK_URLS = ${JSON.stringify(chunks.reverse().map(getChunkRelativeUrl), null, 2)}; self.TURBOPACK_NEXT_CHUNK_URLS = ${JSON.stringify(chunks.reverse().map(getChunkRelativeUrl), null, 2)};
importScripts(...self.TURBOPACK_NEXT_CHUNK_URLS.map(c => self.TURBOPACK_WORKER_LOCATION + c).reverse());`; importScripts(...self.TURBOPACK_NEXT_CHUNK_URLS.map(c => self.TURBOPACK_WORKER_LOCATION + c + self.TURBOPACK_CHUNK_SUFFIX).reverse());`;
var blob = new Blob([ var blob = new Blob([
bootstrap bootstrap
], { ], {
...@@ -1168,7 +1169,7 @@ browserContextPrototype.b = getWorkerBlobURL; ...@@ -1168,7 +1169,7 @@ browserContextPrototype.b = getWorkerBlobURL;
*/ function getChunkRelativeUrl(chunkPath) { */ function getChunkRelativeUrl(chunkPath) {
return `${CHUNK_BASE_PATH}${chunkPath.split('/').map(function(p) { return `${CHUNK_BASE_PATH}${chunkPath.split('/').map(function(p) {
return encodeURIComponent(p); return encodeURIComponent(p);
}).join('/')}${CHUNK_SUFFIX_PATH}`; }).join('/')}${CHUNK_SUFFIX}`;
} }
function getPathFromScript(chunkScript) { function getPathFromScript(chunkScript) {
if (typeof chunkScript === 'string') { if (typeof chunkScript === 'string') {
......
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