@atlaspack/bundler-default 2.14.5-canary.17 → 2.14.5-canary.170

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.
@@ -1,11 +1,9 @@
1
- // @flow strict-local
2
-
3
- import {ALL_EDGE_TYPES, type NodeId} from '@atlaspack/graph';
1
+ import {ALL_EDGE_TYPES, NodeId} from '@atlaspack/graph';
4
2
  import type {
5
3
  Bundle as LegacyBundle,
6
4
  BundleGroup,
7
5
  MutableBundleGraph,
8
- } from '@atlaspack/types';
6
+ } from '@atlaspack/types-internal';
9
7
  import {getFeatureFlag} from '@atlaspack/feature-flags';
10
8
  import invariant from 'assert';
11
9
  import nullthrows from 'nullthrows';
@@ -25,11 +23,13 @@ export function decorateLegacyGraph(
25
23
  bundleGroupBundleIds,
26
24
  manualAssetToBundle,
27
25
  } = idealGraph;
26
+ // This line can be deleted once supportWebpackChunkName feature flag is removed.
28
27
  let entryBundleToBundleGroup: Map<NodeId, BundleGroup> = new Map();
29
28
  // Step Create Bundles: Create bundle groups, bundles, and shared bundles and add assets to them
30
29
  for (let [bundleNodeId, idealBundle] of idealBundleGraph.nodes.entries()) {
31
30
  if (!idealBundle || idealBundle === 'root') continue;
32
31
  let entryAsset = idealBundle.mainEntryAsset;
32
+ // This line can be deleted once supportWebpackChunkName feature flag is removed.
33
33
  let bundleGroup;
34
34
  let bundle;
35
35
 
@@ -52,18 +52,26 @@ export function decorateLegacyGraph(
52
52
  entryAsset != null,
53
53
  'Processing a bundleGroup with no entry asset',
54
54
  );
55
+
56
+ let bundleGroups = new Map();
55
57
  for (let dependency of dependencies) {
56
58
  bundleGroup = bundleGraph.createBundleGroup(
57
59
  dependency,
58
60
  idealBundle.target,
59
61
  );
62
+ bundleGroups.set(bundleGroup.entryAssetId, bundleGroup);
63
+ }
64
+ if (getFeatureFlag('supportWebpackChunkName')) {
65
+ invariant(bundleGroups.size > 0, 'No bundle groups created');
66
+ } else {
67
+ invariant(bundleGroup);
68
+ entryBundleToBundleGroup.set(bundleNodeId, bundleGroup);
60
69
  }
61
- invariant(bundleGroup);
62
- entryBundleToBundleGroup.set(bundleNodeId, bundleGroup);
63
70
 
64
71
  bundle = nullthrows(
65
72
  bundleGraph.createBundle({
66
73
  entryAsset: nullthrows(entryAsset),
74
+ bundleRoots: Array.from(idealBundle.bundleRoots),
67
75
  needsStableName: idealBundle.needsStableName,
68
76
  bundleBehavior: idealBundle.bundleBehavior,
69
77
  target: idealBundle.target,
@@ -71,7 +79,14 @@ export function decorateLegacyGraph(
71
79
  }),
72
80
  );
73
81
 
74
- bundleGraph.addBundleToBundleGroup(bundle, bundleGroup);
82
+ if (getFeatureFlag('supportWebpackChunkName')) {
83
+ for (let bundleGroup of bundleGroups.values()) {
84
+ bundleGraph.addBundleToBundleGroup(bundle, bundleGroup);
85
+ }
86
+ } else {
87
+ invariant(bundleGroup);
88
+ bundleGraph.addBundleToBundleGroup(bundle, bundleGroup);
89
+ }
75
90
  } else if (
76
91
  idealBundle.sourceBundles.size > 0 &&
77
92
  !idealBundle.mainEntryAsset
@@ -109,6 +124,7 @@ export function decorateLegacyGraph(
109
124
  bundle = nullthrows(
110
125
  bundleGraph.createBundle({
111
126
  entryAsset,
127
+ bundleRoots: Array.from(idealBundle.bundleRoots),
112
128
  needsStableName: idealBundle.needsStableName,
113
129
  bundleBehavior: idealBundle.bundleBehavior,
114
130
  target: idealBundle.target,
@@ -195,11 +211,13 @@ export function decorateLegacyGraph(
195
211
  }
196
212
  }
197
213
 
214
+ // @ts-expect-error TS2488
198
215
  for (let {type, from, to} of idealBundleGraph.getAllEdges()) {
199
216
  let sourceBundle = nullthrows(idealBundleGraph.getNode(from));
200
217
  if (sourceBundle === 'root') {
201
218
  continue;
202
219
  }
220
+ // @ts-expect-error TS2367
203
221
  invariant(sourceBundle !== 'root');
204
222
 
205
223
  let legacySourceBundle = nullthrows(
@@ -210,6 +228,7 @@ export function decorateLegacyGraph(
210
228
  if (targetBundle === 'root') {
211
229
  continue;
212
230
  }
231
+ // @ts-expect-error TS2367
213
232
  invariant(targetBundle !== 'root');
214
233
  let legacyTargetBundle = nullthrows(
215
234
  idealBundleToLegacyBundle.get(targetBundle),