remote-components 0.0.31 → 0.0.32

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
@@ -502,7 +502,6 @@ function handleTurbopackModule(bundle, moduleId, id) {
502
502
  }
503
503
  const exports = {};
504
504
  const moduleExports = { exports };
505
- const exportNames = /* @__PURE__ */ new Set();
506
505
  if (!self.__remote_components_turbopack_modules__) {
507
506
  self.__remote_components_turbopack_modules__ = {};
508
507
  }
@@ -538,31 +537,53 @@ function handleTurbopackModule(bundle, moduleId, id) {
538
537
  };
539
538
  }
540
539
  },
541
- // define exports
542
- s(m) {
543
- let mod = m;
544
- if (Array.isArray(m)) {
545
- mod = {};
546
- const keys = [];
547
- for (const current of m) {
548
- if (typeof current === "string") {
549
- keys.push(current);
550
- } else if (typeof current === "function") {
551
- while (keys.length > 0) {
552
- const key = keys.shift();
553
- if (key) {
554
- mod[key] = current;
555
- }
540
+ // esm
541
+ s(bindings, esmId) {
542
+ let mod = exports;
543
+ if (typeof esmId === "string" || typeof esmId === "number") {
544
+ if (!self.__remote_components_turbopack_modules__) {
545
+ self.__remote_components_turbopack_modules__ = {};
546
+ }
547
+ if (!self.__remote_components_turbopack_modules__[bundle]) {
548
+ self.__remote_components_turbopack_modules__[bundle] = {};
549
+ }
550
+ if (!self.__remote_components_turbopack_modules__[bundle][esmId]) {
551
+ self.__remote_components_turbopack_modules__[bundle][esmId] = {};
552
+ }
553
+ mod = self.__remote_components_turbopack_modules__[bundle][esmId];
554
+ }
555
+ Object.defineProperty(mod, "__esModule", { value: true });
556
+ if (Array.isArray(bindings)) {
557
+ let i = 0;
558
+ while (i < bindings.length) {
559
+ const propName = bindings[i++];
560
+ const tagOrFunc = bindings[i++];
561
+ if (typeof tagOrFunc === "number") {
562
+ Object.defineProperty(mod, propName, {
563
+ value: bindings[i++],
564
+ enumerable: true,
565
+ writable: false
566
+ });
567
+ } else {
568
+ const getterFn = tagOrFunc;
569
+ if (typeof bindings[i] === "function") {
570
+ const setterFn = bindings[i++];
571
+ Object.defineProperty(mod, propName, {
572
+ get: getterFn,
573
+ set: setterFn,
574
+ enumerable: true
575
+ });
576
+ } else {
577
+ Object.defineProperty(mod, propName, {
578
+ get: getterFn,
579
+ enumerable: true
580
+ });
556
581
  }
557
582
  }
558
583
  }
559
584
  }
560
- for (const [key, value] of Object.entries(mod)) {
561
- exports[key] = value;
562
- exportNames.add(key);
563
- }
564
585
  },
565
- // import ESM
586
+ // import
566
587
  i(importId) {
567
588
  let mod;
568
589
  if (typeof importId === "string") {
@@ -586,7 +607,10 @@ function handleTurbopackModule(bundle, moduleId, id) {
586
607
  } else {
587
608
  mod = self.__webpack_require__?.(`[${bundle}] ${importId}`);
588
609
  }
589
- if (!("default" in mod) && mod.toString() !== "[object Module]") {
610
+ if (typeof mod !== "object") {
611
+ mod = { default: mod };
612
+ } else if (!("default" in mod) && // eslint-disable-next-line @typescript-eslint/no-base-to-string
613
+ mod.toString() !== "[object Module]") {
590
614
  try {
591
615
  mod.default = mod;
592
616
  } catch {
@@ -605,7 +629,7 @@ function handleTurbopackModule(bundle, moduleId, id) {
605
629
  return self.__webpack_require__?.(`[${bundle}] ${vid}`);
606
630
  });
607
631
  } else {
608
- exports.default = value;
632
+ moduleExports.exports = value;
609
633
  }
610
634
  },
611
635
  // async module initializer
@@ -649,11 +673,6 @@ function handleTurbopackModule(bundle, moduleId, id) {
649
673
  moduleExports,
650
674
  exports
651
675
  );
652
- for (const name of exportNames) {
653
- if (typeof exports[name] === "function") {
654
- exports[name] = exports[name]();
655
- }
656
- }
657
676
  if (self.__remote_components_turbopack_modules__[bundle][moduleId] !== moduleExports.exports) {
658
677
  self.__remote_components_turbopack_modules__[bundle][moduleId] = moduleExports.exports;
659
678
  }