@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.
@@ -185,11 +185,6 @@ function mergeBundles(target, from) {
185
185
  globalGroups: [...target.globalGroups, ...newGlobals]
186
186
  });
187
187
  }
188
- const existingExternals = new Set(target.external);
189
- const newExternals = target.external.filter((x) => !existingExternals.has(x));
190
- if (newExternals.length > 0) {
191
- target = __spreadProps(__spreadValues({}, target), { external: [...target.external, ...newExternals] });
192
- }
193
188
  const existingSplitIds = new Set(target.activeSplits.map((s) => s.id));
194
189
  const newSplits = (_a2 = from.activeSplits.filter((s) => !existingSplitIds.has(s.id))) != null ? _a2 : [];
195
190
  if (newSplits.length > 0) {
@@ -303,6 +298,18 @@ function getLookupSpecName(lookup) {
303
298
  function uniq(elements) {
304
299
  return Array.from(new Set(elements));
305
300
  }
301
+ function uniqBy(elements, iterator) {
302
+ const vis = /* @__PURE__ */ new Set();
303
+ const filtered = [];
304
+ for (const elt of elements) {
305
+ const key = iterator(elt);
306
+ if (!vis.has(key)) {
307
+ vis.add(key);
308
+ filtered.push(elt);
309
+ }
310
+ }
311
+ return filtered;
312
+ }
306
313
 
307
314
  // src/component-lookup.ts
308
315
  function getFirstCompMeta(metas, lookup) {
@@ -458,7 +465,6 @@ var BaseInternalPlasmicComponentLoader = class {
458
465
  },
459
466
  components: [],
460
467
  globalGroups: [],
461
- external: [],
462
468
  projects: [],
463
469
  activeSplits: [],
464
470
  bundleKey: null,
@@ -572,11 +578,50 @@ var BaseInternalPlasmicComponentLoader = class {
572
578
  return bundle;
573
579
  });
574
580
  }
575
- mergeBundle(bundle) {
576
- var _a2, _b;
577
- this.bundle = bundle;
578
- this.bundle.bundleKey = (_a2 = this.bundle.bundleKey) != null ? _a2 : null;
579
- (_b = this.onBundleMerged) == null ? void 0 : _b.call(this);
581
+ mergeBundle(newBundle) {
582
+ var _a2, _b, _c, _d, _e;
583
+ newBundle.bundleKey = (_a2 = newBundle.bundleKey) != null ? _a2 : null;
584
+ if (newBundle.bundleKey && this.bundle.bundleKey && newBundle.bundleKey !== this.bundle.bundleKey) {
585
+ console.warn(
586
+ `Plasmic Error: Different code export hashes. This can happen if your app is using different loaders with different project IDs or project versions.
587
+ Conflicting values:
588
+ ${newBundle.bundleKey}
589
+ ${this.bundle.bundleKey}`
590
+ );
591
+ }
592
+ const bundles = [this.bundle, newBundle];
593
+ this.bundle = {
594
+ activeSplits: uniqBy(
595
+ bundles.flatMap((bundle) => bundle.activeSplits),
596
+ (split) => split.id
597
+ ),
598
+ components: uniqBy(
599
+ bundles.flatMap((bundle) => bundle.components),
600
+ (c) => c.id
601
+ ),
602
+ globalGroups: uniqBy(
603
+ bundles.flatMap((bundle) => bundle.globalGroups),
604
+ (g) => g.id
605
+ ),
606
+ modules: {
607
+ browser: uniqBy(
608
+ bundles.flatMap((bundle) => bundle.modules.browser),
609
+ (m) => m.fileName
610
+ ),
611
+ server: uniqBy(
612
+ bundles.flatMap((bundle) => bundle.modules.server),
613
+ (m) => m.fileName
614
+ )
615
+ },
616
+ projects: uniqBy(
617
+ bundles.flatMap((bundle) => bundle.projects),
618
+ (p) => p.id
619
+ ),
620
+ // Avoid `undefined` as it cannot be serialized as JSON
621
+ bundleKey: (_c = (_b = newBundle.bundleKey) != null ? _b : this.bundle.bundleKey) != null ? _c : null,
622
+ deferChunksByDefault: (_d = newBundle.deferChunksByDefault) != null ? _d : false
623
+ };
624
+ (_e = this.onBundleMerged) == null ? void 0 : _e.call(this);
580
625
  }
581
626
  getBundle() {
582
627
  return this.bundle;
@@ -589,7 +634,6 @@ var BaseInternalPlasmicComponentLoader = class {
589
634
  },
590
635
  components: [],
591
636
  globalGroups: [],
592
- external: [],
593
637
  projects: [],
594
638
  activeSplits: [],
595
639
  bundleKey: null,