@plasmicapp/loader-react 1.0.342 → 1.0.344

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.
@@ -215,11 +215,6 @@ function mergeBundles(target, from) {
215
215
  globalGroups: [...target.globalGroups, ...newGlobals]
216
216
  });
217
217
  }
218
- const existingExternals = new Set(target.external);
219
- const newExternals = target.external.filter((x) => !existingExternals.has(x));
220
- if (newExternals.length > 0) {
221
- target = __spreadProps(__spreadValues({}, target), { external: [...target.external, ...newExternals] });
222
- }
223
218
  const existingSplitIds = new Set(target.activeSplits.map((s) => s.id));
224
219
  const newSplits = (_a2 = from.activeSplits.filter((s) => !existingSplitIds.has(s.id))) != null ? _a2 : [];
225
220
  if (newSplits.length > 0) {
@@ -333,6 +328,18 @@ function getLookupSpecName(lookup) {
333
328
  function uniq(elements) {
334
329
  return Array.from(new Set(elements));
335
330
  }
331
+ function uniqBy(elements, iterator) {
332
+ const vis = /* @__PURE__ */ new Set();
333
+ const filtered = [];
334
+ for (const elt of elements) {
335
+ const key = iterator(elt);
336
+ if (!vis.has(key)) {
337
+ vis.add(key);
338
+ filtered.push(elt);
339
+ }
340
+ }
341
+ return filtered;
342
+ }
336
343
 
337
344
  // src/component-lookup.ts
338
345
  function getFirstCompMeta(metas, lookup) {
@@ -488,7 +495,6 @@ var BaseInternalPlasmicComponentLoader = class {
488
495
  },
489
496
  components: [],
490
497
  globalGroups: [],
491
- external: [],
492
498
  projects: [],
493
499
  activeSplits: [],
494
500
  bundleKey: null,
@@ -602,11 +608,50 @@ var BaseInternalPlasmicComponentLoader = class {
602
608
  return bundle;
603
609
  });
604
610
  }
605
- mergeBundle(bundle) {
606
- var _a2, _b;
607
- this.bundle = bundle;
608
- this.bundle.bundleKey = (_a2 = this.bundle.bundleKey) != null ? _a2 : null;
609
- (_b = this.onBundleMerged) == null ? void 0 : _b.call(this);
611
+ mergeBundle(newBundle) {
612
+ var _a2, _b, _c, _d, _e;
613
+ newBundle.bundleKey = (_a2 = newBundle.bundleKey) != null ? _a2 : null;
614
+ if (newBundle.bundleKey && this.bundle.bundleKey && newBundle.bundleKey !== this.bundle.bundleKey) {
615
+ console.warn(
616
+ `Plasmic Error: Different code export hashes. This can happen if your app is using different loaders with different project IDs or project versions.
617
+ Conflicting values:
618
+ ${newBundle.bundleKey}
619
+ ${this.bundle.bundleKey}`
620
+ );
621
+ }
622
+ const bundles = [this.bundle, newBundle];
623
+ this.bundle = {
624
+ activeSplits: uniqBy(
625
+ bundles.flatMap((bundle) => bundle.activeSplits),
626
+ (split) => split.id
627
+ ),
628
+ components: uniqBy(
629
+ bundles.flatMap((bundle) => bundle.components),
630
+ (c) => c.id
631
+ ),
632
+ globalGroups: uniqBy(
633
+ bundles.flatMap((bundle) => bundle.globalGroups),
634
+ (g) => g.id
635
+ ),
636
+ modules: {
637
+ browser: uniqBy(
638
+ bundles.flatMap((bundle) => bundle.modules.browser),
639
+ (m) => m.fileName
640
+ ),
641
+ server: uniqBy(
642
+ bundles.flatMap((bundle) => bundle.modules.server),
643
+ (m) => m.fileName
644
+ )
645
+ },
646
+ projects: uniqBy(
647
+ bundles.flatMap((bundle) => bundle.projects),
648
+ (p) => p.id
649
+ ),
650
+ // Avoid `undefined` as it cannot be serialized as JSON
651
+ bundleKey: (_c = (_b = newBundle.bundleKey) != null ? _b : this.bundle.bundleKey) != null ? _c : null,
652
+ deferChunksByDefault: (_d = newBundle.deferChunksByDefault) != null ? _d : false
653
+ };
654
+ (_e = this.onBundleMerged) == null ? void 0 : _e.call(this);
610
655
  }
611
656
  getBundle() {
612
657
  return this.bundle;
@@ -619,7 +664,6 @@ var BaseInternalPlasmicComponentLoader = class {
619
664
  },
620
665
  components: [],
621
666
  globalGroups: [],
622
- external: [],
623
667
  projects: [],
624
668
  activeSplits: [],
625
669
  bundleKey: null,