diff --git a/crates/turbopack-dev/js/src/runtime.dom.js b/crates/turbopack-dev/js/src/runtime.dom.js index 096dc614ea188..9bd599879f916 100644 --- a/crates/turbopack-dev/js/src/runtime.dom.js +++ b/crates/turbopack-dev/js/src/runtime.dom.js @@ -17,10 +17,7 @@ let BACKEND; } for (const otherChunkData of params.otherChunks) { - const otherChunkPath = - typeof otherChunkData === "string" - ? otherChunkData - : otherChunkData.path; + const otherChunkPath = getChunkPath(otherChunkData); if (otherChunkPath.endsWith(".css")) { // Mark all CSS chunks within the same chunk group as this chunk as loaded. // They are just injected as tag and have to way to communicate completion. diff --git a/crates/turbopack-dev/js/src/runtime.js b/crates/turbopack-dev/js/src/runtime.js index 78cf8a7640109..ffddfc1f23008 100644 --- a/crates/turbopack-dev/js/src/runtime.js +++ b/crates/turbopack-dev/js/src/runtime.js @@ -1335,6 +1335,16 @@ function getOrInstantiateRuntimeModule(moduleId, chunkPath) { return instantiateModule(moduleId, { type: SourceTypeRuntime, chunkPath }); } +/** + * Returns the path of a chunk defined by its data. + * + * @param {ChunkData} chunkData + * @returns {ChunkPath} the chunk path + */ +function getChunkPath(chunkData) { + return typeof chunkData === "string" ? chunkData : chunkData.path; +} + /** * Subscribes to chunk list updates from the update server and applies them. * @@ -1347,11 +1357,7 @@ function registerChunkList(chunkList) { ]); // Adding chunks to chunk lists and vice versa. - const chunks = new Set( - chunkList.chunks.map((chunkData) => - typeof chunkData === "string" ? chunkData : chunkData.path - ) - ); + const chunks = new Set(chunkList.chunks.map(getChunkPath)); chunkListChunksMap.set(chunkList.path, chunks); for (const chunkPath of chunks) { let chunkChunkLists = chunkChunkListsMap.get(chunkPath); diff --git a/crates/turbopack-dev/js/src/runtime.nodejs.js b/crates/turbopack-dev/js/src/runtime.nodejs.js index 562d98b461177..a53e866db9429 100644 --- a/crates/turbopack-dev/js/src/runtime.nodejs.js +++ b/crates/turbopack-dev/js/src/runtime.nodejs.js @@ -14,15 +14,10 @@ let BACKEND; if (params.runtimeModuleIds.length > 0) { for (const otherChunkData of params.otherChunks) { - loadChunk( - typeof otherChunkData === "string" - ? otherChunkData - : otherChunkData.path, - { - type: SourceTypeRuntime, - chunkPath, - } - ); + loadChunk(getChunkPath(otherChunkData), { + type: SourceTypeRuntime, + chunkPath, + }); } for (const moduleId of params.runtimeModuleIds) { diff --git a/crates/turbopack-dev/js/src/runtime.none.js b/crates/turbopack-dev/js/src/runtime.none.js index 1d2e4f07ce45e..cb84502bf4b0d 100644 --- a/crates/turbopack-dev/js/src/runtime.none.js +++ b/crates/turbopack-dev/js/src/runtime.none.js @@ -68,10 +68,7 @@ let BACKEND; }; for (const otherChunkData of otherChunks) { - const otherChunkPath = - typeof otherChunkData === "string" - ? otherChunkData - : otherChunkData.path; + const otherChunkPath = getChunkPath(otherChunkData); if (registeredChunks.has(otherChunkPath)) { continue; } diff --git a/crates/turbopack-dev/js/types/backend.d.ts b/crates/turbopack-dev/js/types/backend.d.ts index 50ae5c81afed2..01dde590586c6 100644 --- a/crates/turbopack-dev/js/types/backend.d.ts +++ b/crates/turbopack-dev/js/types/backend.d.ts @@ -12,6 +12,7 @@ declare global { declare const RUNTIME_PARAMS: DevRuntimeParams; declare const getFirstModuleChunk: GetFirstModuleChunk; declare const getOrInstantiateRuntimeModule: GetOrInstantiateRuntimeModule; + declare const getChunkPath: GetChunkPath; declare const loadChunk: InternalLoadChunk; declare const SourceTypeRuntime: SourceType.Runtime; declare const SourceTypeParent: SourceType.Parent; diff --git a/crates/turbopack-dev/js/types/index.d.ts b/crates/turbopack-dev/js/types/index.d.ts index 4fd3fa50e56b9..d4b50d7702162 100644 --- a/crates/turbopack-dev/js/types/index.d.ts +++ b/crates/turbopack-dev/js/types/index.d.ts @@ -157,6 +157,8 @@ export interface TurbopackGlobals { TURBOPACK_CHUNK_LISTS?: ChunkList[]; } +export type GetChunkPath = (chunkData: ChunkData) => ChunkPath; + export type GetFirstModuleChunk = (moduleId: ModuleId) => ChunkPath | null; export type GetOrInstantiateRuntimeModule = ( moduleId: ModuleId, diff --git a/crates/turbopack-tests/tests/snapshot/basic/async_chunk/output/crates_turbopack-tests_tests_snapshot_basic_async_chunk_input_index_0d348e.js b/crates/turbopack-tests/tests/snapshot/basic/async_chunk/output/crates_turbopack-tests_tests_snapshot_basic_async_chunk_input_index_0d348e.js index 9bfe147fbed44..dfefc4c6dee0a 100644 --- a/crates/turbopack-tests/tests/snapshot/basic/async_chunk/output/crates_turbopack-tests_tests_snapshot_basic_async_chunk_input_index_0d348e.js +++ b/crates/turbopack-tests/tests/snapshot/basic/async_chunk/output/crates_turbopack-tests_tests_snapshot_basic_async_chunk_input_index_0d348e.js @@ -1344,6 +1344,16 @@ function getOrInstantiateRuntimeModule(moduleId, chunkPath) { return instantiateModule(moduleId, { type: SourceTypeRuntime, chunkPath }); } +/** + * Returns the path of a chunk defined by its data. + * + * @param {ChunkData} chunkData + * @returns {ChunkPath} the chunk path + */ +function getChunkPath(chunkData) { + return typeof chunkData === "string" ? chunkData : chunkData.path; +} + /** * Subscribes to chunk list updates from the update server and applies them. * @@ -1356,11 +1366,7 @@ function registerChunkList(chunkList) { ]); // Adding chunks to chunk lists and vice versa. - const chunks = new Set( - chunkList.chunks.map((chunkData) => - typeof chunkData === "string" ? chunkData : chunkData.path - ) - ); + const chunks = new Set(chunkList.chunks.map(getChunkPath)); chunkListChunksMap.set(chunkList.path, chunks); for (const chunkPath of chunks) { let chunkChunkLists = chunkChunkListsMap.get(chunkPath); @@ -1436,10 +1442,7 @@ let BACKEND; } for (const otherChunkData of params.otherChunks) { - const otherChunkPath = - typeof otherChunkData === "string" - ? otherChunkData - : otherChunkData.path; + const otherChunkPath = getChunkPath(otherChunkData); if (otherChunkPath.endsWith(".css")) { // Mark all CSS chunks within the same chunk group as this chunk as loaded. // They are just injected as tag and have to way to communicate completion. diff --git a/crates/turbopack-tests/tests/snapshot/basic/chunked/output/crates_turbopack-tests_tests_snapshot_basic_chunked_input_index_e77e9f.js b/crates/turbopack-tests/tests/snapshot/basic/chunked/output/crates_turbopack-tests_tests_snapshot_basic_chunked_input_index_e77e9f.js index 3a444973d3dcc..72d3b9e56c79b 100644 --- a/crates/turbopack-tests/tests/snapshot/basic/chunked/output/crates_turbopack-tests_tests_snapshot_basic_chunked_input_index_e77e9f.js +++ b/crates/turbopack-tests/tests/snapshot/basic/chunked/output/crates_turbopack-tests_tests_snapshot_basic_chunked_input_index_e77e9f.js @@ -1344,6 +1344,16 @@ function getOrInstantiateRuntimeModule(moduleId, chunkPath) { return instantiateModule(moduleId, { type: SourceTypeRuntime, chunkPath }); } +/** + * Returns the path of a chunk defined by its data. + * + * @param {ChunkData} chunkData + * @returns {ChunkPath} the chunk path + */ +function getChunkPath(chunkData) { + return typeof chunkData === "string" ? chunkData : chunkData.path; +} + /** * Subscribes to chunk list updates from the update server and applies them. * @@ -1356,11 +1366,7 @@ function registerChunkList(chunkList) { ]); // Adding chunks to chunk lists and vice versa. - const chunks = new Set( - chunkList.chunks.map((chunkData) => - typeof chunkData === "string" ? chunkData : chunkData.path - ) - ); + const chunks = new Set(chunkList.chunks.map(getChunkPath)); chunkListChunksMap.set(chunkList.path, chunks); for (const chunkPath of chunks) { let chunkChunkLists = chunkChunkListsMap.get(chunkPath); @@ -1436,10 +1442,7 @@ let BACKEND; } for (const otherChunkData of params.otherChunks) { - const otherChunkPath = - typeof otherChunkData === "string" - ? otherChunkData - : otherChunkData.path; + const otherChunkPath = getChunkPath(otherChunkData); if (otherChunkPath.endsWith(".css")) { // Mark all CSS chunks within the same chunk group as this chunk as loaded. // They are just injected as tag and have to way to communicate completion. diff --git a/crates/turbopack-tests/tests/snapshot/basic/shebang/output/crates_turbopack-tests_tests_snapshot_basic_shebang_input_index_b1f0c2.js b/crates/turbopack-tests/tests/snapshot/basic/shebang/output/crates_turbopack-tests_tests_snapshot_basic_shebang_input_index_b1f0c2.js index 43b9b7faf4233..817643b59b9ec 100644 --- a/crates/turbopack-tests/tests/snapshot/basic/shebang/output/crates_turbopack-tests_tests_snapshot_basic_shebang_input_index_b1f0c2.js +++ b/crates/turbopack-tests/tests/snapshot/basic/shebang/output/crates_turbopack-tests_tests_snapshot_basic_shebang_input_index_b1f0c2.js @@ -1344,6 +1344,16 @@ function getOrInstantiateRuntimeModule(moduleId, chunkPath) { return instantiateModule(moduleId, { type: SourceTypeRuntime, chunkPath }); } +/** + * Returns the path of a chunk defined by its data. + * + * @param {ChunkData} chunkData + * @returns {ChunkPath} the chunk path + */ +function getChunkPath(chunkData) { + return typeof chunkData === "string" ? chunkData : chunkData.path; +} + /** * Subscribes to chunk list updates from the update server and applies them. * @@ -1356,11 +1366,7 @@ function registerChunkList(chunkList) { ]); // Adding chunks to chunk lists and vice versa. - const chunks = new Set( - chunkList.chunks.map((chunkData) => - typeof chunkData === "string" ? chunkData : chunkData.path - ) - ); + const chunks = new Set(chunkList.chunks.map(getChunkPath)); chunkListChunksMap.set(chunkList.path, chunks); for (const chunkPath of chunks) { let chunkChunkLists = chunkChunkListsMap.get(chunkPath); @@ -1436,10 +1442,7 @@ let BACKEND; } for (const otherChunkData of params.otherChunks) { - const otherChunkPath = - typeof otherChunkData === "string" - ? otherChunkData - : otherChunkData.path; + const otherChunkPath = getChunkPath(otherChunkData); if (otherChunkPath.endsWith(".css")) { // Mark all CSS chunks within the same chunk group as this chunk as loaded. // They are just injected as tag and have to way to communicate completion. diff --git a/crates/turbopack-tests/tests/snapshot/comptime/define/output/crates_turbopack-tests_tests_snapshot_comptime_define_input_index_6b0d2b.js b/crates/turbopack-tests/tests/snapshot/comptime/define/output/crates_turbopack-tests_tests_snapshot_comptime_define_input_index_6b0d2b.js index c194990ce934a..e9f24ff7a007b 100644 --- a/crates/turbopack-tests/tests/snapshot/comptime/define/output/crates_turbopack-tests_tests_snapshot_comptime_define_input_index_6b0d2b.js +++ b/crates/turbopack-tests/tests/snapshot/comptime/define/output/crates_turbopack-tests_tests_snapshot_comptime_define_input_index_6b0d2b.js @@ -1344,6 +1344,16 @@ function getOrInstantiateRuntimeModule(moduleId, chunkPath) { return instantiateModule(moduleId, { type: SourceTypeRuntime, chunkPath }); } +/** + * Returns the path of a chunk defined by its data. + * + * @param {ChunkData} chunkData + * @returns {ChunkPath} the chunk path + */ +function getChunkPath(chunkData) { + return typeof chunkData === "string" ? chunkData : chunkData.path; +} + /** * Subscribes to chunk list updates from the update server and applies them. * @@ -1356,11 +1366,7 @@ function registerChunkList(chunkList) { ]); // Adding chunks to chunk lists and vice versa. - const chunks = new Set( - chunkList.chunks.map((chunkData) => - typeof chunkData === "string" ? chunkData : chunkData.path - ) - ); + const chunks = new Set(chunkList.chunks.map(getChunkPath)); chunkListChunksMap.set(chunkList.path, chunks); for (const chunkPath of chunks) { let chunkChunkLists = chunkChunkListsMap.get(chunkPath); @@ -1436,10 +1442,7 @@ let BACKEND; } for (const otherChunkData of params.otherChunks) { - const otherChunkPath = - typeof otherChunkData === "string" - ? otherChunkData - : otherChunkData.path; + const otherChunkPath = getChunkPath(otherChunkData); if (otherChunkPath.endsWith(".css")) { // Mark all CSS chunks within the same chunk group as this chunk as loaded. // They are just injected as tag and have to way to communicate completion. diff --git a/crates/turbopack-tests/tests/snapshot/css/absolute-uri-import/output/crates_turbopack-tests_tests_snapshot_css_absolute-uri-import_input_index_fa9a30.js b/crates/turbopack-tests/tests/snapshot/css/absolute-uri-import/output/crates_turbopack-tests_tests_snapshot_css_absolute-uri-import_input_index_fa9a30.js index 0b4867d46cc84..7ef71163c5509 100644 --- a/crates/turbopack-tests/tests/snapshot/css/absolute-uri-import/output/crates_turbopack-tests_tests_snapshot_css_absolute-uri-import_input_index_fa9a30.js +++ b/crates/turbopack-tests/tests/snapshot/css/absolute-uri-import/output/crates_turbopack-tests_tests_snapshot_css_absolute-uri-import_input_index_fa9a30.js @@ -1344,6 +1344,16 @@ function getOrInstantiateRuntimeModule(moduleId, chunkPath) { return instantiateModule(moduleId, { type: SourceTypeRuntime, chunkPath }); } +/** + * Returns the path of a chunk defined by its data. + * + * @param {ChunkData} chunkData + * @returns {ChunkPath} the chunk path + */ +function getChunkPath(chunkData) { + return typeof chunkData === "string" ? chunkData : chunkData.path; +} + /** * Subscribes to chunk list updates from the update server and applies them. * @@ -1356,11 +1366,7 @@ function registerChunkList(chunkList) { ]); // Adding chunks to chunk lists and vice versa. - const chunks = new Set( - chunkList.chunks.map((chunkData) => - typeof chunkData === "string" ? chunkData : chunkData.path - ) - ); + const chunks = new Set(chunkList.chunks.map(getChunkPath)); chunkListChunksMap.set(chunkList.path, chunks); for (const chunkPath of chunks) { let chunkChunkLists = chunkChunkListsMap.get(chunkPath); @@ -1436,10 +1442,7 @@ let BACKEND; } for (const otherChunkData of params.otherChunks) { - const otherChunkPath = - typeof otherChunkData === "string" - ? otherChunkData - : otherChunkData.path; + const otherChunkPath = getChunkPath(otherChunkData); if (otherChunkPath.endsWith(".css")) { // Mark all CSS chunks within the same chunk group as this chunk as loaded. // They are just injected as tag and have to way to communicate completion. diff --git a/crates/turbopack-tests/tests/snapshot/css/css/output/crates_turbopack-tests_tests_snapshot_css_css_input_index_37a138.js b/crates/turbopack-tests/tests/snapshot/css/css/output/crates_turbopack-tests_tests_snapshot_css_css_input_index_37a138.js index d914043f49408..1c6db4cd478c6 100644 --- a/crates/turbopack-tests/tests/snapshot/css/css/output/crates_turbopack-tests_tests_snapshot_css_css_input_index_37a138.js +++ b/crates/turbopack-tests/tests/snapshot/css/css/output/crates_turbopack-tests_tests_snapshot_css_css_input_index_37a138.js @@ -1344,6 +1344,16 @@ function getOrInstantiateRuntimeModule(moduleId, chunkPath) { return instantiateModule(moduleId, { type: SourceTypeRuntime, chunkPath }); } +/** + * Returns the path of a chunk defined by its data. + * + * @param {ChunkData} chunkData + * @returns {ChunkPath} the chunk path + */ +function getChunkPath(chunkData) { + return typeof chunkData === "string" ? chunkData : chunkData.path; +} + /** * Subscribes to chunk list updates from the update server and applies them. * @@ -1356,11 +1366,7 @@ function registerChunkList(chunkList) { ]); // Adding chunks to chunk lists and vice versa. - const chunks = new Set( - chunkList.chunks.map((chunkData) => - typeof chunkData === "string" ? chunkData : chunkData.path - ) - ); + const chunks = new Set(chunkList.chunks.map(getChunkPath)); chunkListChunksMap.set(chunkList.path, chunks); for (const chunkPath of chunks) { let chunkChunkLists = chunkChunkListsMap.get(chunkPath); @@ -1436,10 +1442,7 @@ let BACKEND; } for (const otherChunkData of params.otherChunks) { - const otherChunkPath = - typeof otherChunkData === "string" - ? otherChunkData - : otherChunkData.path; + const otherChunkPath = getChunkPath(otherChunkData); if (otherChunkPath.endsWith(".css")) { // Mark all CSS chunks within the same chunk group as this chunk as loaded. // They are just injected as tag and have to way to communicate completion. diff --git a/crates/turbopack-tests/tests/snapshot/emotion/emotion/output/crates_turbopack-tests_tests_snapshot_emotion_emotion_input_index_b080c4.js b/crates/turbopack-tests/tests/snapshot/emotion/emotion/output/crates_turbopack-tests_tests_snapshot_emotion_emotion_input_index_b080c4.js index 608547341c98c..7282a81119f15 100644 --- a/crates/turbopack-tests/tests/snapshot/emotion/emotion/output/crates_turbopack-tests_tests_snapshot_emotion_emotion_input_index_b080c4.js +++ b/crates/turbopack-tests/tests/snapshot/emotion/emotion/output/crates_turbopack-tests_tests_snapshot_emotion_emotion_input_index_b080c4.js @@ -1344,6 +1344,16 @@ function getOrInstantiateRuntimeModule(moduleId, chunkPath) { return instantiateModule(moduleId, { type: SourceTypeRuntime, chunkPath }); } +/** + * Returns the path of a chunk defined by its data. + * + * @param {ChunkData} chunkData + * @returns {ChunkPath} the chunk path + */ +function getChunkPath(chunkData) { + return typeof chunkData === "string" ? chunkData : chunkData.path; +} + /** * Subscribes to chunk list updates from the update server and applies them. * @@ -1356,11 +1366,7 @@ function registerChunkList(chunkList) { ]); // Adding chunks to chunk lists and vice versa. - const chunks = new Set( - chunkList.chunks.map((chunkData) => - typeof chunkData === "string" ? chunkData : chunkData.path - ) - ); + const chunks = new Set(chunkList.chunks.map(getChunkPath)); chunkListChunksMap.set(chunkList.path, chunks); for (const chunkPath of chunks) { let chunkChunkLists = chunkChunkListsMap.get(chunkPath); @@ -1436,10 +1442,7 @@ let BACKEND; } for (const otherChunkData of params.otherChunks) { - const otherChunkPath = - typeof otherChunkData === "string" - ? otherChunkData - : otherChunkData.path; + const otherChunkPath = getChunkPath(otherChunkData); if (otherChunkPath.endsWith(".css")) { // Mark all CSS chunks within the same chunk group as this chunk as loaded. // They are just injected as tag and have to way to communicate completion. diff --git a/crates/turbopack-tests/tests/snapshot/env/env/output/crates_turbopack-tests_tests_snapshot_env_env_input_index_29a23f.js b/crates/turbopack-tests/tests/snapshot/env/env/output/crates_turbopack-tests_tests_snapshot_env_env_input_index_29a23f.js index ac5e32193b903..d0546aa2cb82b 100644 --- a/crates/turbopack-tests/tests/snapshot/env/env/output/crates_turbopack-tests_tests_snapshot_env_env_input_index_29a23f.js +++ b/crates/turbopack-tests/tests/snapshot/env/env/output/crates_turbopack-tests_tests_snapshot_env_env_input_index_29a23f.js @@ -1344,6 +1344,16 @@ function getOrInstantiateRuntimeModule(moduleId, chunkPath) { return instantiateModule(moduleId, { type: SourceTypeRuntime, chunkPath }); } +/** + * Returns the path of a chunk defined by its data. + * + * @param {ChunkData} chunkData + * @returns {ChunkPath} the chunk path + */ +function getChunkPath(chunkData) { + return typeof chunkData === "string" ? chunkData : chunkData.path; +} + /** * Subscribes to chunk list updates from the update server and applies them. * @@ -1356,11 +1366,7 @@ function registerChunkList(chunkList) { ]); // Adding chunks to chunk lists and vice versa. - const chunks = new Set( - chunkList.chunks.map((chunkData) => - typeof chunkData === "string" ? chunkData : chunkData.path - ) - ); + const chunks = new Set(chunkList.chunks.map(getChunkPath)); chunkListChunksMap.set(chunkList.path, chunks); for (const chunkPath of chunks) { let chunkChunkLists = chunkChunkListsMap.get(chunkPath); @@ -1436,10 +1442,7 @@ let BACKEND; } for (const otherChunkData of params.otherChunks) { - const otherChunkPath = - typeof otherChunkData === "string" - ? otherChunkData - : otherChunkData.path; + const otherChunkPath = getChunkPath(otherChunkData); if (otherChunkPath.endsWith(".css")) { // Mark all CSS chunks within the same chunk group as this chunk as loaded. // They are just injected as tag and have to way to communicate completion. diff --git a/crates/turbopack-tests/tests/snapshot/evaluated_entrry/runtime_entry/output/a587c_tests_snapshot_evaluated_entrry_runtime_entry_input_index_f59cc7.js b/crates/turbopack-tests/tests/snapshot/evaluated_entrry/runtime_entry/output/a587c_tests_snapshot_evaluated_entrry_runtime_entry_input_index_f59cc7.js index 78eb31053940c..a9294fe195abe 100644 --- a/crates/turbopack-tests/tests/snapshot/evaluated_entrry/runtime_entry/output/a587c_tests_snapshot_evaluated_entrry_runtime_entry_input_index_f59cc7.js +++ b/crates/turbopack-tests/tests/snapshot/evaluated_entrry/runtime_entry/output/a587c_tests_snapshot_evaluated_entrry_runtime_entry_input_index_f59cc7.js @@ -1344,6 +1344,16 @@ function getOrInstantiateRuntimeModule(moduleId, chunkPath) { return instantiateModule(moduleId, { type: SourceTypeRuntime, chunkPath }); } +/** + * Returns the path of a chunk defined by its data. + * + * @param {ChunkData} chunkData + * @returns {ChunkPath} the chunk path + */ +function getChunkPath(chunkData) { + return typeof chunkData === "string" ? chunkData : chunkData.path; +} + /** * Subscribes to chunk list updates from the update server and applies them. * @@ -1356,11 +1366,7 @@ function registerChunkList(chunkList) { ]); // Adding chunks to chunk lists and vice versa. - const chunks = new Set( - chunkList.chunks.map((chunkData) => - typeof chunkData === "string" ? chunkData : chunkData.path - ) - ); + const chunks = new Set(chunkList.chunks.map(getChunkPath)); chunkListChunksMap.set(chunkList.path, chunks); for (const chunkPath of chunks) { let chunkChunkLists = chunkChunkListsMap.get(chunkPath); @@ -1436,10 +1442,7 @@ let BACKEND; } for (const otherChunkData of params.otherChunks) { - const otherChunkPath = - typeof otherChunkData === "string" - ? otherChunkData - : otherChunkData.path; + const otherChunkPath = getChunkPath(otherChunkData); if (otherChunkPath.endsWith(".css")) { // Mark all CSS chunks within the same chunk group as this chunk as loaded. // They are just injected as tag and have to way to communicate completion. diff --git a/crates/turbopack-tests/tests/snapshot/example/example/output/crates_turbopack-tests_tests_snapshot_example_example_input_index_78b6bf.js b/crates/turbopack-tests/tests/snapshot/example/example/output/crates_turbopack-tests_tests_snapshot_example_example_input_index_78b6bf.js index cd2097eb65f4b..4ca8b99c666f4 100644 --- a/crates/turbopack-tests/tests/snapshot/example/example/output/crates_turbopack-tests_tests_snapshot_example_example_input_index_78b6bf.js +++ b/crates/turbopack-tests/tests/snapshot/example/example/output/crates_turbopack-tests_tests_snapshot_example_example_input_index_78b6bf.js @@ -1344,6 +1344,16 @@ function getOrInstantiateRuntimeModule(moduleId, chunkPath) { return instantiateModule(moduleId, { type: SourceTypeRuntime, chunkPath }); } +/** + * Returns the path of a chunk defined by its data. + * + * @param {ChunkData} chunkData + * @returns {ChunkPath} the chunk path + */ +function getChunkPath(chunkData) { + return typeof chunkData === "string" ? chunkData : chunkData.path; +} + /** * Subscribes to chunk list updates from the update server and applies them. * @@ -1356,11 +1366,7 @@ function registerChunkList(chunkList) { ]); // Adding chunks to chunk lists and vice versa. - const chunks = new Set( - chunkList.chunks.map((chunkData) => - typeof chunkData === "string" ? chunkData : chunkData.path - ) - ); + const chunks = new Set(chunkList.chunks.map(getChunkPath)); chunkListChunksMap.set(chunkList.path, chunks); for (const chunkPath of chunks) { let chunkChunkLists = chunkChunkListsMap.get(chunkPath); @@ -1436,10 +1442,7 @@ let BACKEND; } for (const otherChunkData of params.otherChunks) { - const otherChunkPath = - typeof otherChunkData === "string" - ? otherChunkData - : otherChunkData.path; + const otherChunkPath = getChunkPath(otherChunkData); if (otherChunkPath.endsWith(".css")) { // Mark all CSS chunks within the same chunk group as this chunk as loaded. // They are just injected as tag and have to way to communicate completion. diff --git a/crates/turbopack-tests/tests/snapshot/export-alls/cjs-2/output/crates_turbopack-tests_tests_snapshot_export-alls_cjs-2_input_index_289ae7.js b/crates/turbopack-tests/tests/snapshot/export-alls/cjs-2/output/crates_turbopack-tests_tests_snapshot_export-alls_cjs-2_input_index_289ae7.js index f1ac7ad9750fd..dfdfa2d317574 100644 --- a/crates/turbopack-tests/tests/snapshot/export-alls/cjs-2/output/crates_turbopack-tests_tests_snapshot_export-alls_cjs-2_input_index_289ae7.js +++ b/crates/turbopack-tests/tests/snapshot/export-alls/cjs-2/output/crates_turbopack-tests_tests_snapshot_export-alls_cjs-2_input_index_289ae7.js @@ -1344,6 +1344,16 @@ function getOrInstantiateRuntimeModule(moduleId, chunkPath) { return instantiateModule(moduleId, { type: SourceTypeRuntime, chunkPath }); } +/** + * Returns the path of a chunk defined by its data. + * + * @param {ChunkData} chunkData + * @returns {ChunkPath} the chunk path + */ +function getChunkPath(chunkData) { + return typeof chunkData === "string" ? chunkData : chunkData.path; +} + /** * Subscribes to chunk list updates from the update server and applies them. * @@ -1356,11 +1366,7 @@ function registerChunkList(chunkList) { ]); // Adding chunks to chunk lists and vice versa. - const chunks = new Set( - chunkList.chunks.map((chunkData) => - typeof chunkData === "string" ? chunkData : chunkData.path - ) - ); + const chunks = new Set(chunkList.chunks.map(getChunkPath)); chunkListChunksMap.set(chunkList.path, chunks); for (const chunkPath of chunks) { let chunkChunkLists = chunkChunkListsMap.get(chunkPath); @@ -1436,10 +1442,7 @@ let BACKEND; } for (const otherChunkData of params.otherChunks) { - const otherChunkPath = - typeof otherChunkData === "string" - ? otherChunkData - : otherChunkData.path; + const otherChunkPath = getChunkPath(otherChunkData); if (otherChunkPath.endsWith(".css")) { // Mark all CSS chunks within the same chunk group as this chunk as loaded. // They are just injected as tag and have to way to communicate completion. diff --git a/crates/turbopack-tests/tests/snapshot/export-alls/cjs-script/output/crates_turbopack-tests_tests_snapshot_export-alls_cjs-script_input_index_3e96b7.js b/crates/turbopack-tests/tests/snapshot/export-alls/cjs-script/output/crates_turbopack-tests_tests_snapshot_export-alls_cjs-script_input_index_3e96b7.js index 3f9317ade2303..20af450552005 100644 --- a/crates/turbopack-tests/tests/snapshot/export-alls/cjs-script/output/crates_turbopack-tests_tests_snapshot_export-alls_cjs-script_input_index_3e96b7.js +++ b/crates/turbopack-tests/tests/snapshot/export-alls/cjs-script/output/crates_turbopack-tests_tests_snapshot_export-alls_cjs-script_input_index_3e96b7.js @@ -1344,6 +1344,16 @@ function getOrInstantiateRuntimeModule(moduleId, chunkPath) { return instantiateModule(moduleId, { type: SourceTypeRuntime, chunkPath }); } +/** + * Returns the path of a chunk defined by its data. + * + * @param {ChunkData} chunkData + * @returns {ChunkPath} the chunk path + */ +function getChunkPath(chunkData) { + return typeof chunkData === "string" ? chunkData : chunkData.path; +} + /** * Subscribes to chunk list updates from the update server and applies them. * @@ -1356,11 +1366,7 @@ function registerChunkList(chunkList) { ]); // Adding chunks to chunk lists and vice versa. - const chunks = new Set( - chunkList.chunks.map((chunkData) => - typeof chunkData === "string" ? chunkData : chunkData.path - ) - ); + const chunks = new Set(chunkList.chunks.map(getChunkPath)); chunkListChunksMap.set(chunkList.path, chunks); for (const chunkPath of chunks) { let chunkChunkLists = chunkChunkListsMap.get(chunkPath); @@ -1436,10 +1442,7 @@ let BACKEND; } for (const otherChunkData of params.otherChunks) { - const otherChunkPath = - typeof otherChunkData === "string" - ? otherChunkData - : otherChunkData.path; + const otherChunkPath = getChunkPath(otherChunkData); if (otherChunkPath.endsWith(".css")) { // Mark all CSS chunks within the same chunk group as this chunk as loaded. // They are just injected as tag and have to way to communicate completion. diff --git a/crates/turbopack-tests/tests/snapshot/import-meta/cjs/output/crates_turbopack-tests_tests_snapshot_import-meta_cjs_input_index_537553.js b/crates/turbopack-tests/tests/snapshot/import-meta/cjs/output/crates_turbopack-tests_tests_snapshot_import-meta_cjs_input_index_537553.js index c33f2386d6e5b..7fd3ab34963b0 100644 --- a/crates/turbopack-tests/tests/snapshot/import-meta/cjs/output/crates_turbopack-tests_tests_snapshot_import-meta_cjs_input_index_537553.js +++ b/crates/turbopack-tests/tests/snapshot/import-meta/cjs/output/crates_turbopack-tests_tests_snapshot_import-meta_cjs_input_index_537553.js @@ -1344,6 +1344,16 @@ function getOrInstantiateRuntimeModule(moduleId, chunkPath) { return instantiateModule(moduleId, { type: SourceTypeRuntime, chunkPath }); } +/** + * Returns the path of a chunk defined by its data. + * + * @param {ChunkData} chunkData + * @returns {ChunkPath} the chunk path + */ +function getChunkPath(chunkData) { + return typeof chunkData === "string" ? chunkData : chunkData.path; +} + /** * Subscribes to chunk list updates from the update server and applies them. * @@ -1356,11 +1366,7 @@ function registerChunkList(chunkList) { ]); // Adding chunks to chunk lists and vice versa. - const chunks = new Set( - chunkList.chunks.map((chunkData) => - typeof chunkData === "string" ? chunkData : chunkData.path - ) - ); + const chunks = new Set(chunkList.chunks.map(getChunkPath)); chunkListChunksMap.set(chunkList.path, chunks); for (const chunkPath of chunks) { let chunkChunkLists = chunkChunkListsMap.get(chunkPath); @@ -1436,10 +1442,7 @@ let BACKEND; } for (const otherChunkData of params.otherChunks) { - const otherChunkPath = - typeof otherChunkData === "string" - ? otherChunkData - : otherChunkData.path; + const otherChunkPath = getChunkPath(otherChunkData); if (otherChunkPath.endsWith(".css")) { // Mark all CSS chunks within the same chunk group as this chunk as loaded. // They are just injected as tag and have to way to communicate completion. diff --git a/crates/turbopack-tests/tests/snapshot/import-meta/esm-multiple/output/79fb1_turbopack-tests_tests_snapshot_import-meta_esm-multiple_input_index_c00392.js b/crates/turbopack-tests/tests/snapshot/import-meta/esm-multiple/output/79fb1_turbopack-tests_tests_snapshot_import-meta_esm-multiple_input_index_c00392.js index d7c31ccddc823..9cceba5997a20 100644 --- a/crates/turbopack-tests/tests/snapshot/import-meta/esm-multiple/output/79fb1_turbopack-tests_tests_snapshot_import-meta_esm-multiple_input_index_c00392.js +++ b/crates/turbopack-tests/tests/snapshot/import-meta/esm-multiple/output/79fb1_turbopack-tests_tests_snapshot_import-meta_esm-multiple_input_index_c00392.js @@ -1344,6 +1344,16 @@ function getOrInstantiateRuntimeModule(moduleId, chunkPath) { return instantiateModule(moduleId, { type: SourceTypeRuntime, chunkPath }); } +/** + * Returns the path of a chunk defined by its data. + * + * @param {ChunkData} chunkData + * @returns {ChunkPath} the chunk path + */ +function getChunkPath(chunkData) { + return typeof chunkData === "string" ? chunkData : chunkData.path; +} + /** * Subscribes to chunk list updates from the update server and applies them. * @@ -1356,11 +1366,7 @@ function registerChunkList(chunkList) { ]); // Adding chunks to chunk lists and vice versa. - const chunks = new Set( - chunkList.chunks.map((chunkData) => - typeof chunkData === "string" ? chunkData : chunkData.path - ) - ); + const chunks = new Set(chunkList.chunks.map(getChunkPath)); chunkListChunksMap.set(chunkList.path, chunks); for (const chunkPath of chunks) { let chunkChunkLists = chunkChunkListsMap.get(chunkPath); @@ -1436,10 +1442,7 @@ let BACKEND; } for (const otherChunkData of params.otherChunks) { - const otherChunkPath = - typeof otherChunkData === "string" - ? otherChunkData - : otherChunkData.path; + const otherChunkPath = getChunkPath(otherChunkData); if (otherChunkPath.endsWith(".css")) { // Mark all CSS chunks within the same chunk group as this chunk as loaded. // They are just injected as tag and have to way to communicate completion. diff --git a/crates/turbopack-tests/tests/snapshot/import-meta/esm-mutable/output/crates_turbopack-tests_tests_snapshot_import-meta_esm-mutable_input_index_6c9201.js b/crates/turbopack-tests/tests/snapshot/import-meta/esm-mutable/output/crates_turbopack-tests_tests_snapshot_import-meta_esm-mutable_input_index_6c9201.js index 27f8b87b42a74..4c3ffc7acd89a 100644 --- a/crates/turbopack-tests/tests/snapshot/import-meta/esm-mutable/output/crates_turbopack-tests_tests_snapshot_import-meta_esm-mutable_input_index_6c9201.js +++ b/crates/turbopack-tests/tests/snapshot/import-meta/esm-mutable/output/crates_turbopack-tests_tests_snapshot_import-meta_esm-mutable_input_index_6c9201.js @@ -1344,6 +1344,16 @@ function getOrInstantiateRuntimeModule(moduleId, chunkPath) { return instantiateModule(moduleId, { type: SourceTypeRuntime, chunkPath }); } +/** + * Returns the path of a chunk defined by its data. + * + * @param {ChunkData} chunkData + * @returns {ChunkPath} the chunk path + */ +function getChunkPath(chunkData) { + return typeof chunkData === "string" ? chunkData : chunkData.path; +} + /** * Subscribes to chunk list updates from the update server and applies them. * @@ -1356,11 +1366,7 @@ function registerChunkList(chunkList) { ]); // Adding chunks to chunk lists and vice versa. - const chunks = new Set( - chunkList.chunks.map((chunkData) => - typeof chunkData === "string" ? chunkData : chunkData.path - ) - ); + const chunks = new Set(chunkList.chunks.map(getChunkPath)); chunkListChunksMap.set(chunkList.path, chunks); for (const chunkPath of chunks) { let chunkChunkLists = chunkChunkListsMap.get(chunkPath); @@ -1436,10 +1442,7 @@ let BACKEND; } for (const otherChunkData of params.otherChunks) { - const otherChunkPath = - typeof otherChunkData === "string" - ? otherChunkData - : otherChunkData.path; + const otherChunkPath = getChunkPath(otherChunkData); if (otherChunkPath.endsWith(".css")) { // Mark all CSS chunks within the same chunk group as this chunk as loaded. // They are just injected as tag and have to way to communicate completion. diff --git a/crates/turbopack-tests/tests/snapshot/import-meta/esm-object/output/crates_turbopack-tests_tests_snapshot_import-meta_esm-object_input_index_6fcf7d.js b/crates/turbopack-tests/tests/snapshot/import-meta/esm-object/output/crates_turbopack-tests_tests_snapshot_import-meta_esm-object_input_index_6fcf7d.js index faac64e630af4..e2239eb309425 100644 --- a/crates/turbopack-tests/tests/snapshot/import-meta/esm-object/output/crates_turbopack-tests_tests_snapshot_import-meta_esm-object_input_index_6fcf7d.js +++ b/crates/turbopack-tests/tests/snapshot/import-meta/esm-object/output/crates_turbopack-tests_tests_snapshot_import-meta_esm-object_input_index_6fcf7d.js @@ -1344,6 +1344,16 @@ function getOrInstantiateRuntimeModule(moduleId, chunkPath) { return instantiateModule(moduleId, { type: SourceTypeRuntime, chunkPath }); } +/** + * Returns the path of a chunk defined by its data. + * + * @param {ChunkData} chunkData + * @returns {ChunkPath} the chunk path + */ +function getChunkPath(chunkData) { + return typeof chunkData === "string" ? chunkData : chunkData.path; +} + /** * Subscribes to chunk list updates from the update server and applies them. * @@ -1356,11 +1366,7 @@ function registerChunkList(chunkList) { ]); // Adding chunks to chunk lists and vice versa. - const chunks = new Set( - chunkList.chunks.map((chunkData) => - typeof chunkData === "string" ? chunkData : chunkData.path - ) - ); + const chunks = new Set(chunkList.chunks.map(getChunkPath)); chunkListChunksMap.set(chunkList.path, chunks); for (const chunkPath of chunks) { let chunkChunkLists = chunkChunkListsMap.get(chunkPath); @@ -1436,10 +1442,7 @@ let BACKEND; } for (const otherChunkData of params.otherChunks) { - const otherChunkPath = - typeof otherChunkData === "string" - ? otherChunkData - : otherChunkData.path; + const otherChunkPath = getChunkPath(otherChunkData); if (otherChunkPath.endsWith(".css")) { // Mark all CSS chunks within the same chunk group as this chunk as loaded. // They are just injected as tag and have to way to communicate completion. diff --git a/crates/turbopack-tests/tests/snapshot/import-meta/esm/output/crates_turbopack-tests_tests_snapshot_import-meta_esm_input_index_c4c88a.js b/crates/turbopack-tests/tests/snapshot/import-meta/esm/output/crates_turbopack-tests_tests_snapshot_import-meta_esm_input_index_c4c88a.js index 6dcf9bf73e3b5..602c009420ba9 100644 --- a/crates/turbopack-tests/tests/snapshot/import-meta/esm/output/crates_turbopack-tests_tests_snapshot_import-meta_esm_input_index_c4c88a.js +++ b/crates/turbopack-tests/tests/snapshot/import-meta/esm/output/crates_turbopack-tests_tests_snapshot_import-meta_esm_input_index_c4c88a.js @@ -1344,6 +1344,16 @@ function getOrInstantiateRuntimeModule(moduleId, chunkPath) { return instantiateModule(moduleId, { type: SourceTypeRuntime, chunkPath }); } +/** + * Returns the path of a chunk defined by its data. + * + * @param {ChunkData} chunkData + * @returns {ChunkPath} the chunk path + */ +function getChunkPath(chunkData) { + return typeof chunkData === "string" ? chunkData : chunkData.path; +} + /** * Subscribes to chunk list updates from the update server and applies them. * @@ -1356,11 +1366,7 @@ function registerChunkList(chunkList) { ]); // Adding chunks to chunk lists and vice versa. - const chunks = new Set( - chunkList.chunks.map((chunkData) => - typeof chunkData === "string" ? chunkData : chunkData.path - ) - ); + const chunks = new Set(chunkList.chunks.map(getChunkPath)); chunkListChunksMap.set(chunkList.path, chunks); for (const chunkPath of chunks) { let chunkChunkLists = chunkChunkListsMap.get(chunkPath); @@ -1436,10 +1442,7 @@ let BACKEND; } for (const otherChunkData of params.otherChunks) { - const otherChunkPath = - typeof otherChunkData === "string" - ? otherChunkData - : otherChunkData.path; + const otherChunkPath = getChunkPath(otherChunkData); if (otherChunkPath.endsWith(".css")) { // Mark all CSS chunks within the same chunk group as this chunk as loaded. // They are just injected as tag and have to way to communicate completion. diff --git a/crates/turbopack-tests/tests/snapshot/import-meta/url/output/crates_turbopack-tests_tests_snapshot_import-meta_url_input_index_988b57.js b/crates/turbopack-tests/tests/snapshot/import-meta/url/output/crates_turbopack-tests_tests_snapshot_import-meta_url_input_index_988b57.js index a2a1801ef2f4b..d0727ccc7c60b 100644 --- a/crates/turbopack-tests/tests/snapshot/import-meta/url/output/crates_turbopack-tests_tests_snapshot_import-meta_url_input_index_988b57.js +++ b/crates/turbopack-tests/tests/snapshot/import-meta/url/output/crates_turbopack-tests_tests_snapshot_import-meta_url_input_index_988b57.js @@ -1344,6 +1344,16 @@ function getOrInstantiateRuntimeModule(moduleId, chunkPath) { return instantiateModule(moduleId, { type: SourceTypeRuntime, chunkPath }); } +/** + * Returns the path of a chunk defined by its data. + * + * @param {ChunkData} chunkData + * @returns {ChunkPath} the chunk path + */ +function getChunkPath(chunkData) { + return typeof chunkData === "string" ? chunkData : chunkData.path; +} + /** * Subscribes to chunk list updates from the update server and applies them. * @@ -1356,11 +1366,7 @@ function registerChunkList(chunkList) { ]); // Adding chunks to chunk lists and vice versa. - const chunks = new Set( - chunkList.chunks.map((chunkData) => - typeof chunkData === "string" ? chunkData : chunkData.path - ) - ); + const chunks = new Set(chunkList.chunks.map(getChunkPath)); chunkListChunksMap.set(chunkList.path, chunks); for (const chunkPath of chunks) { let chunkChunkLists = chunkChunkListsMap.get(chunkPath); @@ -1436,10 +1442,7 @@ let BACKEND; } for (const otherChunkData of params.otherChunks) { - const otherChunkPath = - typeof otherChunkData === "string" - ? otherChunkData - : otherChunkData.path; + const otherChunkPath = getChunkPath(otherChunkData); if (otherChunkPath.endsWith(".css")) { // Mark all CSS chunks within the same chunk group as this chunk as loaded. // They are just injected as tag and have to way to communicate completion. diff --git a/crates/turbopack-tests/tests/snapshot/imports/dynamic/output/crates_turbopack-tests_tests_snapshot_imports_dynamic_input_index_45c162.js b/crates/turbopack-tests/tests/snapshot/imports/dynamic/output/crates_turbopack-tests_tests_snapshot_imports_dynamic_input_index_45c162.js index 01a060945b3ad..c3a6520e29733 100644 --- a/crates/turbopack-tests/tests/snapshot/imports/dynamic/output/crates_turbopack-tests_tests_snapshot_imports_dynamic_input_index_45c162.js +++ b/crates/turbopack-tests/tests/snapshot/imports/dynamic/output/crates_turbopack-tests_tests_snapshot_imports_dynamic_input_index_45c162.js @@ -1344,6 +1344,16 @@ function getOrInstantiateRuntimeModule(moduleId, chunkPath) { return instantiateModule(moduleId, { type: SourceTypeRuntime, chunkPath }); } +/** + * Returns the path of a chunk defined by its data. + * + * @param {ChunkData} chunkData + * @returns {ChunkPath} the chunk path + */ +function getChunkPath(chunkData) { + return typeof chunkData === "string" ? chunkData : chunkData.path; +} + /** * Subscribes to chunk list updates from the update server and applies them. * @@ -1356,11 +1366,7 @@ function registerChunkList(chunkList) { ]); // Adding chunks to chunk lists and vice versa. - const chunks = new Set( - chunkList.chunks.map((chunkData) => - typeof chunkData === "string" ? chunkData : chunkData.path - ) - ); + const chunks = new Set(chunkList.chunks.map(getChunkPath)); chunkListChunksMap.set(chunkList.path, chunks); for (const chunkPath of chunks) { let chunkChunkLists = chunkChunkListsMap.get(chunkPath); @@ -1436,10 +1442,7 @@ let BACKEND; } for (const otherChunkData of params.otherChunks) { - const otherChunkPath = - typeof otherChunkData === "string" - ? otherChunkData - : otherChunkData.path; + const otherChunkPath = getChunkPath(otherChunkData); if (otherChunkPath.endsWith(".css")) { // Mark all CSS chunks within the same chunk group as this chunk as loaded. // They are just injected as tag and have to way to communicate completion. diff --git a/crates/turbopack-tests/tests/snapshot/imports/json/output/crates_turbopack-tests_tests_snapshot_imports_json_input_index_961ae2.js b/crates/turbopack-tests/tests/snapshot/imports/json/output/crates_turbopack-tests_tests_snapshot_imports_json_input_index_961ae2.js index cbf9eb6b9fb79..4c618a5352631 100644 --- a/crates/turbopack-tests/tests/snapshot/imports/json/output/crates_turbopack-tests_tests_snapshot_imports_json_input_index_961ae2.js +++ b/crates/turbopack-tests/tests/snapshot/imports/json/output/crates_turbopack-tests_tests_snapshot_imports_json_input_index_961ae2.js @@ -1344,6 +1344,16 @@ function getOrInstantiateRuntimeModule(moduleId, chunkPath) { return instantiateModule(moduleId, { type: SourceTypeRuntime, chunkPath }); } +/** + * Returns the path of a chunk defined by its data. + * + * @param {ChunkData} chunkData + * @returns {ChunkPath} the chunk path + */ +function getChunkPath(chunkData) { + return typeof chunkData === "string" ? chunkData : chunkData.path; +} + /** * Subscribes to chunk list updates from the update server and applies them. * @@ -1356,11 +1366,7 @@ function registerChunkList(chunkList) { ]); // Adding chunks to chunk lists and vice versa. - const chunks = new Set( - chunkList.chunks.map((chunkData) => - typeof chunkData === "string" ? chunkData : chunkData.path - ) - ); + const chunks = new Set(chunkList.chunks.map(getChunkPath)); chunkListChunksMap.set(chunkList.path, chunks); for (const chunkPath of chunks) { let chunkChunkLists = chunkChunkListsMap.get(chunkPath); @@ -1436,10 +1442,7 @@ let BACKEND; } for (const otherChunkData of params.otherChunks) { - const otherChunkPath = - typeof otherChunkData === "string" - ? otherChunkData - : otherChunkData.path; + const otherChunkPath = getChunkPath(otherChunkData); if (otherChunkPath.endsWith(".css")) { // Mark all CSS chunks within the same chunk group as this chunk as loaded. // They are just injected as tag and have to way to communicate completion. diff --git a/crates/turbopack-tests/tests/snapshot/imports/resolve_error_cjs/output/79fb1_turbopack-tests_tests_snapshot_imports_resolve_error_cjs_input_index_f8412b.js b/crates/turbopack-tests/tests/snapshot/imports/resolve_error_cjs/output/79fb1_turbopack-tests_tests_snapshot_imports_resolve_error_cjs_input_index_f8412b.js index 12e9a12e8e4ee..e501bb1659f3b 100644 --- a/crates/turbopack-tests/tests/snapshot/imports/resolve_error_cjs/output/79fb1_turbopack-tests_tests_snapshot_imports_resolve_error_cjs_input_index_f8412b.js +++ b/crates/turbopack-tests/tests/snapshot/imports/resolve_error_cjs/output/79fb1_turbopack-tests_tests_snapshot_imports_resolve_error_cjs_input_index_f8412b.js @@ -1344,6 +1344,16 @@ function getOrInstantiateRuntimeModule(moduleId, chunkPath) { return instantiateModule(moduleId, { type: SourceTypeRuntime, chunkPath }); } +/** + * Returns the path of a chunk defined by its data. + * + * @param {ChunkData} chunkData + * @returns {ChunkPath} the chunk path + */ +function getChunkPath(chunkData) { + return typeof chunkData === "string" ? chunkData : chunkData.path; +} + /** * Subscribes to chunk list updates from the update server and applies them. * @@ -1356,11 +1366,7 @@ function registerChunkList(chunkList) { ]); // Adding chunks to chunk lists and vice versa. - const chunks = new Set( - chunkList.chunks.map((chunkData) => - typeof chunkData === "string" ? chunkData : chunkData.path - ) - ); + const chunks = new Set(chunkList.chunks.map(getChunkPath)); chunkListChunksMap.set(chunkList.path, chunks); for (const chunkPath of chunks) { let chunkChunkLists = chunkChunkListsMap.get(chunkPath); @@ -1436,10 +1442,7 @@ let BACKEND; } for (const otherChunkData of params.otherChunks) { - const otherChunkPath = - typeof otherChunkData === "string" - ? otherChunkData - : otherChunkData.path; + const otherChunkPath = getChunkPath(otherChunkData); if (otherChunkPath.endsWith(".css")) { // Mark all CSS chunks within the same chunk group as this chunk as loaded. // They are just injected as tag and have to way to communicate completion. diff --git a/crates/turbopack-tests/tests/snapshot/imports/resolve_error_esm/output/79fb1_turbopack-tests_tests_snapshot_imports_resolve_error_esm_input_index_0b3e45.js b/crates/turbopack-tests/tests/snapshot/imports/resolve_error_esm/output/79fb1_turbopack-tests_tests_snapshot_imports_resolve_error_esm_input_index_0b3e45.js index adf55c6f32c5a..c1cb5fcf9679f 100644 --- a/crates/turbopack-tests/tests/snapshot/imports/resolve_error_esm/output/79fb1_turbopack-tests_tests_snapshot_imports_resolve_error_esm_input_index_0b3e45.js +++ b/crates/turbopack-tests/tests/snapshot/imports/resolve_error_esm/output/79fb1_turbopack-tests_tests_snapshot_imports_resolve_error_esm_input_index_0b3e45.js @@ -1344,6 +1344,16 @@ function getOrInstantiateRuntimeModule(moduleId, chunkPath) { return instantiateModule(moduleId, { type: SourceTypeRuntime, chunkPath }); } +/** + * Returns the path of a chunk defined by its data. + * + * @param {ChunkData} chunkData + * @returns {ChunkPath} the chunk path + */ +function getChunkPath(chunkData) { + return typeof chunkData === "string" ? chunkData : chunkData.path; +} + /** * Subscribes to chunk list updates from the update server and applies them. * @@ -1356,11 +1366,7 @@ function registerChunkList(chunkList) { ]); // Adding chunks to chunk lists and vice versa. - const chunks = new Set( - chunkList.chunks.map((chunkData) => - typeof chunkData === "string" ? chunkData : chunkData.path - ) - ); + const chunks = new Set(chunkList.chunks.map(getChunkPath)); chunkListChunksMap.set(chunkList.path, chunks); for (const chunkPath of chunks) { let chunkChunkLists = chunkChunkListsMap.get(chunkPath); @@ -1436,10 +1442,7 @@ let BACKEND; } for (const otherChunkData of params.otherChunks) { - const otherChunkPath = - typeof otherChunkData === "string" - ? otherChunkData - : otherChunkData.path; + const otherChunkPath = getChunkPath(otherChunkData); if (otherChunkPath.endsWith(".css")) { // Mark all CSS chunks within the same chunk group as this chunk as loaded. // They are just injected as tag and have to way to communicate completion. diff --git a/crates/turbopack-tests/tests/snapshot/imports/static-and-dynamic/output/79fb1_turbopack-tests_tests_snapshot_imports_static-and-dynamic_input_index_ec8693.js b/crates/turbopack-tests/tests/snapshot/imports/static-and-dynamic/output/79fb1_turbopack-tests_tests_snapshot_imports_static-and-dynamic_input_index_ec8693.js index ae3639770e5af..985faa3885cd3 100644 --- a/crates/turbopack-tests/tests/snapshot/imports/static-and-dynamic/output/79fb1_turbopack-tests_tests_snapshot_imports_static-and-dynamic_input_index_ec8693.js +++ b/crates/turbopack-tests/tests/snapshot/imports/static-and-dynamic/output/79fb1_turbopack-tests_tests_snapshot_imports_static-and-dynamic_input_index_ec8693.js @@ -1344,6 +1344,16 @@ function getOrInstantiateRuntimeModule(moduleId, chunkPath) { return instantiateModule(moduleId, { type: SourceTypeRuntime, chunkPath }); } +/** + * Returns the path of a chunk defined by its data. + * + * @param {ChunkData} chunkData + * @returns {ChunkPath} the chunk path + */ +function getChunkPath(chunkData) { + return typeof chunkData === "string" ? chunkData : chunkData.path; +} + /** * Subscribes to chunk list updates from the update server and applies them. * @@ -1356,11 +1366,7 @@ function registerChunkList(chunkList) { ]); // Adding chunks to chunk lists and vice versa. - const chunks = new Set( - chunkList.chunks.map((chunkData) => - typeof chunkData === "string" ? chunkData : chunkData.path - ) - ); + const chunks = new Set(chunkList.chunks.map(getChunkPath)); chunkListChunksMap.set(chunkList.path, chunks); for (const chunkPath of chunks) { let chunkChunkLists = chunkChunkListsMap.get(chunkPath); @@ -1436,10 +1442,7 @@ let BACKEND; } for (const otherChunkData of params.otherChunks) { - const otherChunkPath = - typeof otherChunkData === "string" - ? otherChunkData - : otherChunkData.path; + const otherChunkPath = getChunkPath(otherChunkData); if (otherChunkPath.endsWith(".css")) { // Mark all CSS chunks within the same chunk group as this chunk as loaded. // They are just injected as tag and have to way to communicate completion. diff --git a/crates/turbopack-tests/tests/snapshot/imports/static/output/crates_turbopack-tests_tests_snapshot_imports_static_input_index_885269.js b/crates/turbopack-tests/tests/snapshot/imports/static/output/crates_turbopack-tests_tests_snapshot_imports_static_input_index_885269.js index 6ccb766445cd1..758d90cc19e84 100644 --- a/crates/turbopack-tests/tests/snapshot/imports/static/output/crates_turbopack-tests_tests_snapshot_imports_static_input_index_885269.js +++ b/crates/turbopack-tests/tests/snapshot/imports/static/output/crates_turbopack-tests_tests_snapshot_imports_static_input_index_885269.js @@ -1344,6 +1344,16 @@ function getOrInstantiateRuntimeModule(moduleId, chunkPath) { return instantiateModule(moduleId, { type: SourceTypeRuntime, chunkPath }); } +/** + * Returns the path of a chunk defined by its data. + * + * @param {ChunkData} chunkData + * @returns {ChunkPath} the chunk path + */ +function getChunkPath(chunkData) { + return typeof chunkData === "string" ? chunkData : chunkData.path; +} + /** * Subscribes to chunk list updates from the update server and applies them. * @@ -1356,11 +1366,7 @@ function registerChunkList(chunkList) { ]); // Adding chunks to chunk lists and vice versa. - const chunks = new Set( - chunkList.chunks.map((chunkData) => - typeof chunkData === "string" ? chunkData : chunkData.path - ) - ); + const chunks = new Set(chunkList.chunks.map(getChunkPath)); chunkListChunksMap.set(chunkList.path, chunks); for (const chunkPath of chunks) { let chunkChunkLists = chunkChunkListsMap.get(chunkPath); @@ -1436,10 +1442,7 @@ let BACKEND; } for (const otherChunkData of params.otherChunks) { - const otherChunkPath = - typeof otherChunkData === "string" - ? otherChunkData - : otherChunkData.path; + const otherChunkPath = getChunkPath(otherChunkData); if (otherChunkPath.endsWith(".css")) { // Mark all CSS chunks within the same chunk group as this chunk as loaded. // They are just injected as tag and have to way to communicate completion. diff --git a/crates/turbopack-tests/tests/snapshot/node/node_protocol_external/output/79fb1_turbopack-tests_tests_snapshot_node_node_protocol_external_input_index_667edf.js b/crates/turbopack-tests/tests/snapshot/node/node_protocol_external/output/79fb1_turbopack-tests_tests_snapshot_node_node_protocol_external_input_index_667edf.js index d5c07402fb825..414f13777fc47 100644 --- a/crates/turbopack-tests/tests/snapshot/node/node_protocol_external/output/79fb1_turbopack-tests_tests_snapshot_node_node_protocol_external_input_index_667edf.js +++ b/crates/turbopack-tests/tests/snapshot/node/node_protocol_external/output/79fb1_turbopack-tests_tests_snapshot_node_node_protocol_external_input_index_667edf.js @@ -1344,6 +1344,16 @@ function getOrInstantiateRuntimeModule(moduleId, chunkPath) { return instantiateModule(moduleId, { type: SourceTypeRuntime, chunkPath }); } +/** + * Returns the path of a chunk defined by its data. + * + * @param {ChunkData} chunkData + * @returns {ChunkPath} the chunk path + */ +function getChunkPath(chunkData) { + return typeof chunkData === "string" ? chunkData : chunkData.path; +} + /** * Subscribes to chunk list updates from the update server and applies them. * @@ -1356,11 +1366,7 @@ function registerChunkList(chunkList) { ]); // Adding chunks to chunk lists and vice versa. - const chunks = new Set( - chunkList.chunks.map((chunkData) => - typeof chunkData === "string" ? chunkData : chunkData.path - ) - ); + const chunks = new Set(chunkList.chunks.map(getChunkPath)); chunkListChunksMap.set(chunkList.path, chunks); for (const chunkPath of chunks) { let chunkChunkLists = chunkChunkListsMap.get(chunkPath); @@ -1436,10 +1442,7 @@ let BACKEND; } for (const otherChunkData of params.otherChunks) { - const otherChunkPath = - typeof otherChunkData === "string" - ? otherChunkData - : otherChunkData.path; + const otherChunkPath = getChunkPath(otherChunkData); if (otherChunkPath.endsWith(".css")) { // Mark all CSS chunks within the same chunk group as this chunk as loaded. // They are just injected as tag and have to way to communicate completion. diff --git a/crates/turbopack-tests/tests/snapshot/styled_components/styled_components/output/a587c_tests_snapshot_styled_components_styled_components_input_index_afc482.js b/crates/turbopack-tests/tests/snapshot/styled_components/styled_components/output/a587c_tests_snapshot_styled_components_styled_components_input_index_afc482.js index 4e5535e428533..946fb6151612a 100644 --- a/crates/turbopack-tests/tests/snapshot/styled_components/styled_components/output/a587c_tests_snapshot_styled_components_styled_components_input_index_afc482.js +++ b/crates/turbopack-tests/tests/snapshot/styled_components/styled_components/output/a587c_tests_snapshot_styled_components_styled_components_input_index_afc482.js @@ -1344,6 +1344,16 @@ function getOrInstantiateRuntimeModule(moduleId, chunkPath) { return instantiateModule(moduleId, { type: SourceTypeRuntime, chunkPath }); } +/** + * Returns the path of a chunk defined by its data. + * + * @param {ChunkData} chunkData + * @returns {ChunkPath} the chunk path + */ +function getChunkPath(chunkData) { + return typeof chunkData === "string" ? chunkData : chunkData.path; +} + /** * Subscribes to chunk list updates from the update server and applies them. * @@ -1356,11 +1366,7 @@ function registerChunkList(chunkList) { ]); // Adding chunks to chunk lists and vice versa. - const chunks = new Set( - chunkList.chunks.map((chunkData) => - typeof chunkData === "string" ? chunkData : chunkData.path - ) - ); + const chunks = new Set(chunkList.chunks.map(getChunkPath)); chunkListChunksMap.set(chunkList.path, chunks); for (const chunkPath of chunks) { let chunkChunkLists = chunkChunkListsMap.get(chunkPath); @@ -1436,10 +1442,7 @@ let BACKEND; } for (const otherChunkData of params.otherChunks) { - const otherChunkPath = - typeof otherChunkData === "string" - ? otherChunkData - : otherChunkData.path; + const otherChunkPath = getChunkPath(otherChunkData); if (otherChunkPath.endsWith(".css")) { // Mark all CSS chunks within the same chunk group as this chunk as loaded. // They are just injected as tag and have to way to communicate completion. diff --git a/crates/turbopack-tests/tests/snapshot/swc_transforms/mono_transforms/output/a587c_tests_snapshot_swc_transforms_mono_transforms_input_packages_app_index_4a3d65.js b/crates/turbopack-tests/tests/snapshot/swc_transforms/mono_transforms/output/a587c_tests_snapshot_swc_transforms_mono_transforms_input_packages_app_index_4a3d65.js index 1ec1ffda64655..da59552a935a0 100644 --- a/crates/turbopack-tests/tests/snapshot/swc_transforms/mono_transforms/output/a587c_tests_snapshot_swc_transforms_mono_transforms_input_packages_app_index_4a3d65.js +++ b/crates/turbopack-tests/tests/snapshot/swc_transforms/mono_transforms/output/a587c_tests_snapshot_swc_transforms_mono_transforms_input_packages_app_index_4a3d65.js @@ -1344,6 +1344,16 @@ function getOrInstantiateRuntimeModule(moduleId, chunkPath) { return instantiateModule(moduleId, { type: SourceTypeRuntime, chunkPath }); } +/** + * Returns the path of a chunk defined by its data. + * + * @param {ChunkData} chunkData + * @returns {ChunkPath} the chunk path + */ +function getChunkPath(chunkData) { + return typeof chunkData === "string" ? chunkData : chunkData.path; +} + /** * Subscribes to chunk list updates from the update server and applies them. * @@ -1356,11 +1366,7 @@ function registerChunkList(chunkList) { ]); // Adding chunks to chunk lists and vice versa. - const chunks = new Set( - chunkList.chunks.map((chunkData) => - typeof chunkData === "string" ? chunkData : chunkData.path - ) - ); + const chunks = new Set(chunkList.chunks.map(getChunkPath)); chunkListChunksMap.set(chunkList.path, chunks); for (const chunkPath of chunks) { let chunkChunkLists = chunkChunkListsMap.get(chunkPath); @@ -1436,10 +1442,7 @@ let BACKEND; } for (const otherChunkData of params.otherChunks) { - const otherChunkPath = - typeof otherChunkData === "string" - ? otherChunkData - : otherChunkData.path; + const otherChunkPath = getChunkPath(otherChunkData); if (otherChunkPath.endsWith(".css")) { // Mark all CSS chunks within the same chunk group as this chunk as loaded. // They are just injected as tag and have to way to communicate completion. diff --git a/crates/turbopack-tests/tests/snapshot/swc_transforms/preset_env/output/79fb1_turbopack-tests_tests_snapshot_swc_transforms_preset_env_input_index_9dcfd0.js b/crates/turbopack-tests/tests/snapshot/swc_transforms/preset_env/output/79fb1_turbopack-tests_tests_snapshot_swc_transforms_preset_env_input_index_9dcfd0.js index 02704048d03a4..6fa5e16476412 100644 --- a/crates/turbopack-tests/tests/snapshot/swc_transforms/preset_env/output/79fb1_turbopack-tests_tests_snapshot_swc_transforms_preset_env_input_index_9dcfd0.js +++ b/crates/turbopack-tests/tests/snapshot/swc_transforms/preset_env/output/79fb1_turbopack-tests_tests_snapshot_swc_transforms_preset_env_input_index_9dcfd0.js @@ -1344,6 +1344,16 @@ function getOrInstantiateRuntimeModule(moduleId, chunkPath) { return instantiateModule(moduleId, { type: SourceTypeRuntime, chunkPath }); } +/** + * Returns the path of a chunk defined by its data. + * + * @param {ChunkData} chunkData + * @returns {ChunkPath} the chunk path + */ +function getChunkPath(chunkData) { + return typeof chunkData === "string" ? chunkData : chunkData.path; +} + /** * Subscribes to chunk list updates from the update server and applies them. * @@ -1356,11 +1366,7 @@ function registerChunkList(chunkList) { ]); // Adding chunks to chunk lists and vice versa. - const chunks = new Set( - chunkList.chunks.map((chunkData) => - typeof chunkData === "string" ? chunkData : chunkData.path - ) - ); + const chunks = new Set(chunkList.chunks.map(getChunkPath)); chunkListChunksMap.set(chunkList.path, chunks); for (const chunkPath of chunks) { let chunkChunkLists = chunkChunkListsMap.get(chunkPath); @@ -1436,10 +1442,7 @@ let BACKEND; } for (const otherChunkData of params.otherChunks) { - const otherChunkPath = - typeof otherChunkData === "string" - ? otherChunkData - : otherChunkData.path; + const otherChunkPath = getChunkPath(otherChunkData); if (otherChunkPath.endsWith(".css")) { // Mark all CSS chunks within the same chunk group as this chunk as loaded. // They are just injected as tag and have to way to communicate completion. diff --git a/crates/turbopack-tests/tests/snapshot/typescript/jsconfig-baseurl/output/79fb1_turbopack-tests_tests_snapshot_typescript_jsconfig-baseurl_input_index_8f1e58.js b/crates/turbopack-tests/tests/snapshot/typescript/jsconfig-baseurl/output/79fb1_turbopack-tests_tests_snapshot_typescript_jsconfig-baseurl_input_index_8f1e58.js index 0537e91bfd18f..9562a9162af06 100644 --- a/crates/turbopack-tests/tests/snapshot/typescript/jsconfig-baseurl/output/79fb1_turbopack-tests_tests_snapshot_typescript_jsconfig-baseurl_input_index_8f1e58.js +++ b/crates/turbopack-tests/tests/snapshot/typescript/jsconfig-baseurl/output/79fb1_turbopack-tests_tests_snapshot_typescript_jsconfig-baseurl_input_index_8f1e58.js @@ -1344,6 +1344,16 @@ function getOrInstantiateRuntimeModule(moduleId, chunkPath) { return instantiateModule(moduleId, { type: SourceTypeRuntime, chunkPath }); } +/** + * Returns the path of a chunk defined by its data. + * + * @param {ChunkData} chunkData + * @returns {ChunkPath} the chunk path + */ +function getChunkPath(chunkData) { + return typeof chunkData === "string" ? chunkData : chunkData.path; +} + /** * Subscribes to chunk list updates from the update server and applies them. * @@ -1356,11 +1366,7 @@ function registerChunkList(chunkList) { ]); // Adding chunks to chunk lists and vice versa. - const chunks = new Set( - chunkList.chunks.map((chunkData) => - typeof chunkData === "string" ? chunkData : chunkData.path - ) - ); + const chunks = new Set(chunkList.chunks.map(getChunkPath)); chunkListChunksMap.set(chunkList.path, chunks); for (const chunkPath of chunks) { let chunkChunkLists = chunkChunkListsMap.get(chunkPath); @@ -1436,10 +1442,7 @@ let BACKEND; } for (const otherChunkData of params.otherChunks) { - const otherChunkPath = - typeof otherChunkData === "string" - ? otherChunkData - : otherChunkData.path; + const otherChunkPath = getChunkPath(otherChunkData); if (otherChunkPath.endsWith(".css")) { // Mark all CSS chunks within the same chunk group as this chunk as loaded. // They are just injected as tag and have to way to communicate completion. diff --git a/crates/turbopack-tests/tests/snapshot/typescript/tsconfig-baseurl/output/a587c_tests_snapshot_typescript_tsconfig-baseurl_input_index.ts_0aa04e._.js b/crates/turbopack-tests/tests/snapshot/typescript/tsconfig-baseurl/output/a587c_tests_snapshot_typescript_tsconfig-baseurl_input_index.ts_0aa04e._.js index a6f57c394d8b5..78861e2374b9b 100644 --- a/crates/turbopack-tests/tests/snapshot/typescript/tsconfig-baseurl/output/a587c_tests_snapshot_typescript_tsconfig-baseurl_input_index.ts_0aa04e._.js +++ b/crates/turbopack-tests/tests/snapshot/typescript/tsconfig-baseurl/output/a587c_tests_snapshot_typescript_tsconfig-baseurl_input_index.ts_0aa04e._.js @@ -1344,6 +1344,16 @@ function getOrInstantiateRuntimeModule(moduleId, chunkPath) { return instantiateModule(moduleId, { type: SourceTypeRuntime, chunkPath }); } +/** + * Returns the path of a chunk defined by its data. + * + * @param {ChunkData} chunkData + * @returns {ChunkPath} the chunk path + */ +function getChunkPath(chunkData) { + return typeof chunkData === "string" ? chunkData : chunkData.path; +} + /** * Subscribes to chunk list updates from the update server and applies them. * @@ -1356,11 +1366,7 @@ function registerChunkList(chunkList) { ]); // Adding chunks to chunk lists and vice versa. - const chunks = new Set( - chunkList.chunks.map((chunkData) => - typeof chunkData === "string" ? chunkData : chunkData.path - ) - ); + const chunks = new Set(chunkList.chunks.map(getChunkPath)); chunkListChunksMap.set(chunkList.path, chunks); for (const chunkPath of chunks) { let chunkChunkLists = chunkChunkListsMap.get(chunkPath); @@ -1436,10 +1442,7 @@ let BACKEND; } for (const otherChunkData of params.otherChunks) { - const otherChunkPath = - typeof otherChunkData === "string" - ? otherChunkData - : otherChunkData.path; + const otherChunkPath = getChunkPath(otherChunkData); if (otherChunkPath.endsWith(".css")) { // Mark all CSS chunks within the same chunk group as this chunk as loaded. // They are just injected as tag and have to way to communicate completion.