remote-components 0.0.42 → 0.0.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -287,6 +287,7 @@ var init_const = __esm({
287
287
  // src/shared/client/chunk-loader.ts
288
288
  function createChunkLoader(runtime) {
289
289
  return function __turbopack_chunk_load__(chunkId, scriptBundle) {
290
+ logDebug("ChunkLoader", `Loading chunk: "${chunkId}"`);
290
291
  const self = globalThis;
291
292
  const {
292
293
  bundle,
@@ -296,8 +297,14 @@ function createChunkLoader(runtime) {
296
297
  bundle: scriptBundle ?? "",
297
298
  id: chunkId
298
299
  };
300
+ logDebug(
301
+ "ChunkLoader",
302
+ `Parsed chunk - bundle: "${bundle}", path: "${path}", prefix: "${prefix}"`
303
+ );
299
304
  const remoteRuntime = self.__remote_webpack_require__?.[bundle ?? "default"] ? self.__remote_webpack_require__[bundle ?? "default"]?.type || "webpack" : runtime;
305
+ logDebug("ChunkLoader", `Remote runtime: "${remoteRuntime}"`);
300
306
  if (remoteRuntime === RUNTIME_WEBPACK) {
307
+ logDebug("ChunkLoader", "Skipping chunk load - webpack runtime detected");
301
308
  return Promise.resolve(void 0);
302
309
  }
303
310
  const url = new URL(
@@ -308,14 +315,17 @@ function createChunkLoader(runtime) {
308
315
  self.__remote_bundle_url__?.[bundle ?? "default"] ?? new URL(location.origin)
309
316
  ).href;
310
317
  if (url.endsWith(".css")) {
318
+ logDebug("ChunkLoader", `Skipping CSS file: "${url}"`);
311
319
  return;
312
320
  }
313
321
  if (!self.__remote_components_turbopack_chunk_loader_promise__) {
314
322
  self.__remote_components_turbopack_chunk_loader_promise__ = {};
315
323
  }
316
324
  if (self.__remote_components_turbopack_chunk_loader_promise__[url]) {
325
+ logDebug("ChunkLoader", `Returning cached promise for: "${url}"`);
317
326
  return self.__remote_components_turbopack_chunk_loader_promise__[url];
318
327
  }
328
+ logDebug("ChunkLoader", `Fetching chunk from: "${url}"`);
319
329
  self.__remote_components_turbopack_chunk_loader_promise__[url] = new Promise((resolve, reject) => {
320
330
  fetch(url).then((res) => res.text()).then((code) => {
321
331
  if (code.includes("globalThis.TURBOPACK")) {
@@ -327,7 +337,12 @@ function createChunkLoader(runtime) {
327
337
  };
328
338
  }
329
339
  async function handleTurbopackChunk(code, bundle, url) {
340
+ logDebug(
341
+ "ChunkLoader",
342
+ `Handling Turbopack chunk - bundle: "${bundle}", url: "${url}"`
343
+ );
330
344
  if (/importScripts\(\.\.\.self.TURBOPACK_NEXT_CHUNK_URLS/.test(code)) {
345
+ logDebug("ChunkLoader", `Skipping worker chunk: "${url}"`);
331
346
  const preloadLinks = document.querySelectorAll(
332
347
  `link[rel="preload"][href="${new URL(url).pathname}"]`
333
348
  );
@@ -336,6 +351,7 @@ async function handleTurbopackChunk(code, bundle, url) {
336
351
  }
337
352
  const self = globalThis;
338
353
  const bundleKey = getBundleKey(bundle);
354
+ logDebug("ChunkLoader", `Bundle key: "${bundleKey}"`);
339
355
  const transformedCode = code.replace(/globalThis\.TURBOPACK/g, `globalThis.TURBOPACK_${bundleKey}`).replace(
340
356
  /TURBOPACK_WORKER_LOCATION/g,
341
357
  `TURBOPACK_WORKER_LOCATION_${bundleKey}`
@@ -355,6 +371,7 @@ async function handleTurbopackChunk(code, bundle, url) {
355
371
  )
356
372
  ).href}$1$2.js.map`
357
373
  );
374
+ logDebug("ChunkLoader", `Creating blob script for: "${url}"`);
358
375
  await new Promise((scriptResolve, scriptReject) => {
359
376
  const blob = new Blob([transformedCode], {
360
377
  type: "application/javascript; charset=UTF-8"
@@ -381,10 +398,18 @@ async function handleTurbopackChunk(code, bundle, url) {
381
398
  document.head.appendChild(script);
382
399
  });
383
400
  const chunkLists = self[`TURBOPACK_${bundleKey}_CHUNK_LISTS`];
401
+ logDebug(
402
+ "ChunkLoader",
403
+ `Processing chunk lists for bundle "${bundle}": ${chunkLists?.length ?? 0} lists`
404
+ );
384
405
  const loadChunkLists = [];
385
406
  while (chunkLists?.length) {
386
407
  const { chunks } = chunkLists.shift() ?? { chunks: [] };
387
408
  if (chunks.length > 0) {
409
+ logDebug(
410
+ "ChunkLoader",
411
+ `Loading ${chunks.length} additional chunks for bundle "${bundle}": [${chunks.join(", ")}]`
412
+ );
388
413
  chunks.forEach((id) => {
389
414
  const chunkLoadResult = self.__webpack_chunk_load__?.(
390
415
  `[${bundle}] ${url.slice(0, url.indexOf("/_next"))}/_next/${id}`
@@ -396,6 +421,10 @@ async function handleTurbopackChunk(code, bundle, url) {
396
421
  }
397
422
  }
398
423
  if (loadChunkLists.length > 0) {
424
+ logDebug(
425
+ "ChunkLoader",
426
+ `Waiting for ${loadChunkLists.length} additional chunks to load`
427
+ );
399
428
  await Promise.all(loadChunkLists);
400
429
  }
401
430
  }
@@ -403,6 +432,7 @@ var init_chunk_loader = __esm({
403
432
  "src/shared/client/chunk-loader.ts"() {
404
433
  "use strict";
405
434
  init_error();
435
+ init_logger();
406
436
  init_const();
407
437
  }
408
438
  });