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.
package/dist/html/host.js CHANGED
@@ -265,6 +265,7 @@ var init_const = __esm({
265
265
  // src/shared/client/chunk-loader.ts
266
266
  function createChunkLoader(runtime) {
267
267
  return function __turbopack_chunk_load__(chunkId, scriptBundle) {
268
+ logDebug("ChunkLoader", `Loading chunk: "${chunkId}"`);
268
269
  const self = globalThis;
269
270
  const {
270
271
  bundle,
@@ -274,8 +275,14 @@ function createChunkLoader(runtime) {
274
275
  bundle: scriptBundle ?? "",
275
276
  id: chunkId
276
277
  };
278
+ logDebug(
279
+ "ChunkLoader",
280
+ `Parsed chunk - bundle: "${bundle}", path: "${path}", prefix: "${prefix}"`
281
+ );
277
282
  const remoteRuntime = self.__remote_webpack_require__?.[bundle ?? "default"] ? self.__remote_webpack_require__[bundle ?? "default"]?.type || "webpack" : runtime;
283
+ logDebug("ChunkLoader", `Remote runtime: "${remoteRuntime}"`);
278
284
  if (remoteRuntime === RUNTIME_WEBPACK) {
285
+ logDebug("ChunkLoader", "Skipping chunk load - webpack runtime detected");
279
286
  return Promise.resolve(void 0);
280
287
  }
281
288
  const url = new URL(
@@ -286,14 +293,17 @@ function createChunkLoader(runtime) {
286
293
  self.__remote_bundle_url__?.[bundle ?? "default"] ?? new URL(location.origin)
287
294
  ).href;
288
295
  if (url.endsWith(".css")) {
296
+ logDebug("ChunkLoader", `Skipping CSS file: "${url}"`);
289
297
  return;
290
298
  }
291
299
  if (!self.__remote_components_turbopack_chunk_loader_promise__) {
292
300
  self.__remote_components_turbopack_chunk_loader_promise__ = {};
293
301
  }
294
302
  if (self.__remote_components_turbopack_chunk_loader_promise__[url]) {
303
+ logDebug("ChunkLoader", `Returning cached promise for: "${url}"`);
295
304
  return self.__remote_components_turbopack_chunk_loader_promise__[url];
296
305
  }
306
+ logDebug("ChunkLoader", `Fetching chunk from: "${url}"`);
297
307
  self.__remote_components_turbopack_chunk_loader_promise__[url] = new Promise((resolve, reject) => {
298
308
  fetch(url).then((res) => res.text()).then((code) => {
299
309
  if (code.includes("globalThis.TURBOPACK")) {
@@ -305,7 +315,12 @@ function createChunkLoader(runtime) {
305
315
  };
306
316
  }
307
317
  async function handleTurbopackChunk(code, bundle, url) {
318
+ logDebug(
319
+ "ChunkLoader",
320
+ `Handling Turbopack chunk - bundle: "${bundle}", url: "${url}"`
321
+ );
308
322
  if (/importScripts\(\.\.\.self.TURBOPACK_NEXT_CHUNK_URLS/.test(code)) {
323
+ logDebug("ChunkLoader", `Skipping worker chunk: "${url}"`);
309
324
  const preloadLinks = document.querySelectorAll(
310
325
  `link[rel="preload"][href="${new URL(url).pathname}"]`
311
326
  );
@@ -314,6 +329,7 @@ async function handleTurbopackChunk(code, bundle, url) {
314
329
  }
315
330
  const self = globalThis;
316
331
  const bundleKey = getBundleKey(bundle);
332
+ logDebug("ChunkLoader", `Bundle key: "${bundleKey}"`);
317
333
  const transformedCode = code.replace(/globalThis\.TURBOPACK/g, `globalThis.TURBOPACK_${bundleKey}`).replace(
318
334
  /TURBOPACK_WORKER_LOCATION/g,
319
335
  `TURBOPACK_WORKER_LOCATION_${bundleKey}`
@@ -333,6 +349,7 @@ async function handleTurbopackChunk(code, bundle, url) {
333
349
  )
334
350
  ).href}$1$2.js.map`
335
351
  );
352
+ logDebug("ChunkLoader", `Creating blob script for: "${url}"`);
336
353
  await new Promise((scriptResolve, scriptReject) => {
337
354
  const blob = new Blob([transformedCode], {
338
355
  type: "application/javascript; charset=UTF-8"
@@ -359,10 +376,18 @@ async function handleTurbopackChunk(code, bundle, url) {
359
376
  document.head.appendChild(script);
360
377
  });
361
378
  const chunkLists = self[`TURBOPACK_${bundleKey}_CHUNK_LISTS`];
379
+ logDebug(
380
+ "ChunkLoader",
381
+ `Processing chunk lists for bundle "${bundle}": ${chunkLists?.length ?? 0} lists`
382
+ );
362
383
  const loadChunkLists = [];
363
384
  while (chunkLists?.length) {
364
385
  const { chunks } = chunkLists.shift() ?? { chunks: [] };
365
386
  if (chunks.length > 0) {
387
+ logDebug(
388
+ "ChunkLoader",
389
+ `Loading ${chunks.length} additional chunks for bundle "${bundle}": [${chunks.join(", ")}]`
390
+ );
366
391
  chunks.forEach((id) => {
367
392
  const chunkLoadResult = self.__webpack_chunk_load__?.(
368
393
  `[${bundle}] ${url.slice(0, url.indexOf("/_next"))}/_next/${id}`
@@ -374,6 +399,10 @@ async function handleTurbopackChunk(code, bundle, url) {
374
399
  }
375
400
  }
376
401
  if (loadChunkLists.length > 0) {
402
+ logDebug(
403
+ "ChunkLoader",
404
+ `Waiting for ${loadChunkLists.length} additional chunks to load`
405
+ );
377
406
  await Promise.all(loadChunkLists);
378
407
  }
379
408
  }
@@ -381,6 +410,7 @@ var init_chunk_loader = __esm({
381
410
  "src/shared/client/chunk-loader.ts"() {
382
411
  "use strict";
383
412
  init_error();
413
+ init_logger();
384
414
  init_const();
385
415
  }
386
416
  });