@atlaspack/bundler-default 2.14.5-canary.20 → 2.14.5-canary.200
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/CHANGELOG.md +411 -0
- package/lib/DefaultBundler.js +6 -1
- package/lib/MonolithicBundler.js +11 -3
- package/lib/bundleMerge.js +106 -37
- package/lib/bundlerConfig.js +51 -5
- package/lib/decorateLegacyGraph.js +24 -3
- package/lib/idealGraph.js +426 -50
- package/lib/memoize.js +39 -0
- package/lib/stats.js +85 -0
- package/lib/types/DefaultBundler.d.ts +18 -0
- package/lib/types/MonolithicBundler.d.ts +2 -0
- package/lib/types/bundleMerge.d.ts +9 -0
- package/lib/types/bundlerConfig.d.ts +36 -0
- package/lib/types/decorateLegacyGraph.d.ts +3 -0
- package/lib/types/idealGraph.d.ts +40 -0
- package/lib/types/memoize.d.ts +2 -0
- package/lib/types/stats.d.ts +16 -0
- package/package.json +21 -12
- package/src/{DefaultBundler.js → DefaultBundler.ts} +21 -6
- package/src/{MonolithicBundler.js → MonolithicBundler.ts} +17 -5
- package/src/bundleMerge.ts +250 -0
- package/src/{bundlerConfig.js → bundlerConfig.ts} +105 -44
- package/src/{decorateLegacyGraph.js → decorateLegacyGraph.ts} +26 -7
- package/src/{idealGraph.js → idealGraph.ts} +669 -102
- package/src/memoize.ts +32 -0
- package/src/stats.ts +97 -0
- package/tsconfig.json +4 -0
- package/src/bundleMerge.js +0 -103
package/lib/bundlerConfig.js
CHANGED
|
@@ -39,14 +39,13 @@ function resolveModeConfig(config, mode) {
|
|
|
39
39
|
for (const key of Object.keys(config)) {
|
|
40
40
|
if (key === 'development' || key === 'production') {
|
|
41
41
|
if (key === mode) {
|
|
42
|
+
// @ts-expect-error TS2322
|
|
42
43
|
modeConfig = config[key];
|
|
43
44
|
}
|
|
44
45
|
} else {
|
|
45
46
|
generalConfig[key] = config[key];
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
|
-
|
|
49
|
-
// $FlowFixMe Not sure how to convince flow here...
|
|
50
49
|
return {
|
|
51
50
|
...generalConfig,
|
|
52
51
|
...modeConfig
|
|
@@ -61,7 +60,7 @@ const HTTP_OPTIONS = {
|
|
|
61
60
|
minBundleSize: 30000,
|
|
62
61
|
maxParallelRequests: 6,
|
|
63
62
|
disableSharedBundles: false,
|
|
64
|
-
|
|
63
|
+
sharedBundleMerge: []
|
|
65
64
|
},
|
|
66
65
|
'2': {
|
|
67
66
|
minBundles: 1,
|
|
@@ -69,7 +68,7 @@ const HTTP_OPTIONS = {
|
|
|
69
68
|
minBundleSize: 20000,
|
|
70
69
|
maxParallelRequests: 25,
|
|
71
70
|
disableSharedBundles: false,
|
|
72
|
-
|
|
71
|
+
sharedBundleMerge: []
|
|
73
72
|
}
|
|
74
73
|
};
|
|
75
74
|
const CONFIG_SCHEMA = {
|
|
@@ -110,6 +109,50 @@ const CONFIG_SCHEMA = {
|
|
|
110
109
|
additionalProperties: false
|
|
111
110
|
}
|
|
112
111
|
},
|
|
112
|
+
sharedBundleMerge: {
|
|
113
|
+
type: 'array',
|
|
114
|
+
items: {
|
|
115
|
+
type: 'object',
|
|
116
|
+
properties: {
|
|
117
|
+
overlapThreshold: {
|
|
118
|
+
type: 'number'
|
|
119
|
+
},
|
|
120
|
+
maxBundleSize: {
|
|
121
|
+
type: 'number'
|
|
122
|
+
},
|
|
123
|
+
sourceBundles: {
|
|
124
|
+
type: 'array',
|
|
125
|
+
items: {
|
|
126
|
+
type: 'string'
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
minBundlesInGroup: {
|
|
130
|
+
type: 'number'
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
additionalProperties: false
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
asyncBundleMerge: {
|
|
137
|
+
type: 'object',
|
|
138
|
+
properties: {
|
|
139
|
+
bundleSize: {
|
|
140
|
+
type: 'number',
|
|
141
|
+
required: true
|
|
142
|
+
},
|
|
143
|
+
maxOverfetchSize: {
|
|
144
|
+
type: 'number',
|
|
145
|
+
required: true
|
|
146
|
+
},
|
|
147
|
+
ignore: {
|
|
148
|
+
type: 'array',
|
|
149
|
+
items: {
|
|
150
|
+
type: 'string'
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
additionalProperties: false
|
|
155
|
+
},
|
|
113
156
|
minBundles: {
|
|
114
157
|
type: 'number'
|
|
115
158
|
},
|
|
@@ -148,6 +191,7 @@ async function loadBundlerConfig(config, options, logger) {
|
|
|
148
191
|
...HTTP_OPTIONS['2'],
|
|
149
192
|
projectRoot: options.projectRoot
|
|
150
193
|
};
|
|
194
|
+
// @ts-expect-error TS2322
|
|
151
195
|
return modDefault;
|
|
152
196
|
}
|
|
153
197
|
(0, _assert().default)(((_conf = conf) === null || _conf === void 0 ? void 0 : _conf.contents) != null);
|
|
@@ -188,11 +232,13 @@ async function loadBundlerConfig(config, options, logger) {
|
|
|
188
232
|
prependKey: `/${(0, _diagnostic().encodeJSONKeyComponent)('@atlaspack/bundler-default')}`
|
|
189
233
|
}, '@atlaspack/bundler-default', 'Invalid config for @atlaspack/bundler-default');
|
|
190
234
|
let http = modeConfig.http ?? 2;
|
|
235
|
+
// @ts-expect-error TS7053
|
|
191
236
|
let defaults = HTTP_OPTIONS[http];
|
|
192
237
|
return {
|
|
193
238
|
minBundles: modeConfig.minBundles ?? defaults.minBundles,
|
|
194
239
|
minBundleSize: modeConfig.minBundleSize ?? defaults.minBundleSize,
|
|
195
|
-
|
|
240
|
+
sharedBundleMerge: modeConfig.sharedBundleMerge ?? defaults.sharedBundleMerge,
|
|
241
|
+
asyncBundleMerge: modeConfig.asyncBundleMerge,
|
|
196
242
|
maxParallelRequests: modeConfig.maxParallelRequests ?? defaults.maxParallelRequests,
|
|
197
243
|
projectRoot: options.projectRoot,
|
|
198
244
|
disableSharedBundles: modeConfig.disableSharedBundles ?? defaults.disableSharedBundles,
|
|
@@ -42,11 +42,13 @@ function decorateLegacyGraph(idealGraph, bundleGraph) {
|
|
|
42
42
|
bundleGroupBundleIds,
|
|
43
43
|
manualAssetToBundle
|
|
44
44
|
} = idealGraph;
|
|
45
|
+
// This line can be deleted once supportWebpackChunkName feature flag is removed.
|
|
45
46
|
let entryBundleToBundleGroup = new Map();
|
|
46
47
|
// Step Create Bundles: Create bundle groups, bundles, and shared bundles and add assets to them
|
|
47
48
|
for (let [bundleNodeId, idealBundle] of idealBundleGraph.nodes.entries()) {
|
|
48
49
|
if (!idealBundle || idealBundle === 'root') continue;
|
|
49
50
|
let entryAsset = idealBundle.mainEntryAsset;
|
|
51
|
+
// This line can be deleted once supportWebpackChunkName feature flag is removed.
|
|
50
52
|
let bundleGroup;
|
|
51
53
|
let bundle;
|
|
52
54
|
if (bundleGroupBundleIds.has(bundleNodeId)) {
|
|
@@ -57,19 +59,33 @@ function decorateLegacyGraph(idealGraph, bundleGraph) {
|
|
|
57
59
|
return dependency.value;
|
|
58
60
|
});
|
|
59
61
|
(0, _assert().default)(entryAsset != null, 'Processing a bundleGroup with no entry asset');
|
|
62
|
+
let bundleGroups = new Map();
|
|
60
63
|
for (let dependency of dependencies) {
|
|
61
64
|
bundleGroup = bundleGraph.createBundleGroup(dependency, idealBundle.target);
|
|
65
|
+
bundleGroups.set(bundleGroup.entryAssetId, bundleGroup);
|
|
66
|
+
}
|
|
67
|
+
if ((0, _featureFlags().getFeatureFlag)('supportWebpackChunkName')) {
|
|
68
|
+
(0, _assert().default)(bundleGroups.size > 0, 'No bundle groups created');
|
|
69
|
+
} else {
|
|
70
|
+
(0, _assert().default)(bundleGroup);
|
|
71
|
+
entryBundleToBundleGroup.set(bundleNodeId, bundleGroup);
|
|
62
72
|
}
|
|
63
|
-
(0, _assert().default)(bundleGroup);
|
|
64
|
-
entryBundleToBundleGroup.set(bundleNodeId, bundleGroup);
|
|
65
73
|
bundle = (0, _nullthrows().default)(bundleGraph.createBundle({
|
|
66
74
|
entryAsset: (0, _nullthrows().default)(entryAsset),
|
|
75
|
+
bundleRoots: Array.from(idealBundle.bundleRoots),
|
|
67
76
|
needsStableName: idealBundle.needsStableName,
|
|
68
77
|
bundleBehavior: idealBundle.bundleBehavior,
|
|
69
78
|
target: idealBundle.target,
|
|
70
79
|
manualSharedBundle: idealBundle.manualSharedBundle
|
|
71
80
|
}));
|
|
72
|
-
|
|
81
|
+
if ((0, _featureFlags().getFeatureFlag)('supportWebpackChunkName')) {
|
|
82
|
+
for (let bundleGroup of bundleGroups.values()) {
|
|
83
|
+
bundleGraph.addBundleToBundleGroup(bundle, bundleGroup);
|
|
84
|
+
}
|
|
85
|
+
} else {
|
|
86
|
+
(0, _assert().default)(bundleGroup);
|
|
87
|
+
bundleGraph.addBundleToBundleGroup(bundle, bundleGroup);
|
|
88
|
+
}
|
|
73
89
|
} else if (idealBundle.sourceBundles.size > 0 && !idealBundle.mainEntryAsset) {
|
|
74
90
|
let uniqueKey = idealBundle.uniqueKey != null ? idealBundle.uniqueKey : [...idealBundle.assets].map(asset => asset.id).join(',');
|
|
75
91
|
bundle = (0, _nullthrows().default)(bundleGraph.createBundle({
|
|
@@ -95,6 +111,7 @@ function decorateLegacyGraph(idealGraph, bundleGraph) {
|
|
|
95
111
|
(0, _assert().default)(entryAsset != null);
|
|
96
112
|
bundle = (0, _nullthrows().default)(bundleGraph.createBundle({
|
|
97
113
|
entryAsset,
|
|
114
|
+
bundleRoots: Array.from(idealBundle.bundleRoots),
|
|
98
115
|
needsStableName: idealBundle.needsStableName,
|
|
99
116
|
bundleBehavior: idealBundle.bundleBehavior,
|
|
100
117
|
target: idealBundle.target,
|
|
@@ -162,6 +179,8 @@ function decorateLegacyGraph(idealGraph, bundleGraph) {
|
|
|
162
179
|
bundleGraph.createAssetReference(dependency, asset, legacyBundle);
|
|
163
180
|
}
|
|
164
181
|
}
|
|
182
|
+
|
|
183
|
+
// @ts-expect-error TS2488
|
|
165
184
|
for (let {
|
|
166
185
|
type,
|
|
167
186
|
from,
|
|
@@ -171,12 +190,14 @@ function decorateLegacyGraph(idealGraph, bundleGraph) {
|
|
|
171
190
|
if (sourceBundle === 'root') {
|
|
172
191
|
continue;
|
|
173
192
|
}
|
|
193
|
+
// @ts-expect-error TS2367
|
|
174
194
|
(0, _assert().default)(sourceBundle !== 'root');
|
|
175
195
|
let legacySourceBundle = (0, _nullthrows().default)(idealBundleToLegacyBundle.get(sourceBundle));
|
|
176
196
|
let targetBundle = (0, _nullthrows().default)(idealBundleGraph.getNode(to));
|
|
177
197
|
if (targetBundle === 'root') {
|
|
178
198
|
continue;
|
|
179
199
|
}
|
|
200
|
+
// @ts-expect-error TS2367
|
|
180
201
|
(0, _assert().default)(targetBundle !== 'root');
|
|
181
202
|
let legacyTargetBundle = (0, _nullthrows().default)(idealBundleToLegacyBundle.get(targetBundle));
|
|
182
203
|
if ((0, _featureFlags().getFeatureFlag)('conditionalBundlingApi') && type === _idealGraph.idealBundleGraphEdges.conditional) {
|