@atlaspack/bundler-default 3.0.1 → 3.0.3
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 +24 -0
- package/lib/bundleMerge.js +12 -10
- package/lib/idealGraph.js +3 -5
- package/package.json +5 -5
- package/src/bundleMerge.js +11 -17
- package/src/idealGraph.js +4 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @atlaspack/bundler-default
|
|
2
2
|
|
|
3
|
+
## 3.0.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#622](https://github.com/atlassian-labs/atlaspack/pull/622) [`e39c6cf`](https://github.com/atlassian-labs/atlaspack/commit/e39c6cf05f7e95ce5420dbcea66f401b1cbd397c) Thanks [@benjervis](https://github.com/benjervis)! - Change the overlap calculation system in findMergeCandidates to improve performance
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`10fbcfb`](https://github.com/atlassian-labs/atlaspack/commit/10fbcfbfa49c7a83da5d7c40983e36e87f524a75), [`85c52d3`](https://github.com/atlassian-labs/atlaspack/commit/85c52d3f7717b3c84a118d18ab98cfbfd71dcbd2), [`e39c6cf`](https://github.com/atlassian-labs/atlaspack/commit/e39c6cf05f7e95ce5420dbcea66f401b1cbd397c)]:
|
|
10
|
+
- @atlaspack/feature-flags@2.18.0
|
|
11
|
+
- @atlaspack/utils@2.15.0
|
|
12
|
+
- @atlaspack/graph@3.5.2
|
|
13
|
+
- @atlaspack/plugin@2.14.12
|
|
14
|
+
|
|
15
|
+
## 3.0.2
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [#613](https://github.com/atlassian-labs/atlaspack/pull/613) [`4ca19d8`](https://github.com/atlassian-labs/atlaspack/commit/4ca19d8060dfcd279183e4039f2ecb43334ac44c) Thanks [@marcins](https://github.com/marcins)! - Ensure that constant modules are correctly included in MSBs even if they wouldn't otherwise be.
|
|
20
|
+
|
|
21
|
+
- Updated dependencies [[`73ea3c4`](https://github.com/atlassian-labs/atlaspack/commit/73ea3c4d85d4401fdd15abcbf988237e890e7ad3), [`b1b3693`](https://github.com/atlassian-labs/atlaspack/commit/b1b369317c66f8a431c170df2ebba4fa5b2e38ef)]:
|
|
22
|
+
- @atlaspack/feature-flags@2.17.0
|
|
23
|
+
- @atlaspack/graph@3.5.1
|
|
24
|
+
- @atlaspack/utils@2.14.11
|
|
25
|
+
- @atlaspack/plugin@2.14.11
|
|
26
|
+
|
|
3
27
|
## 3.0.1
|
|
4
28
|
|
|
5
29
|
### Patch Changes
|
package/lib/bundleMerge.js
CHANGED
|
@@ -25,6 +25,13 @@ function _graph() {
|
|
|
25
25
|
};
|
|
26
26
|
return data;
|
|
27
27
|
}
|
|
28
|
+
function _utils() {
|
|
29
|
+
const data = require("@atlaspack/utils");
|
|
30
|
+
_utils = function () {
|
|
31
|
+
return data;
|
|
32
|
+
};
|
|
33
|
+
return data;
|
|
34
|
+
}
|
|
28
35
|
var _memoize = require("./memoize");
|
|
29
36
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
30
37
|
function getBundlesForBundleGroup(bundleGraph, bundleGroupId) {
|
|
@@ -37,16 +44,16 @@ function getBundlesForBundleGroup(bundleGraph, bundleGroupId) {
|
|
|
37
44
|
}, bundleGroupId);
|
|
38
45
|
return count;
|
|
39
46
|
}
|
|
40
|
-
let
|
|
41
|
-
let allSourceBundles =
|
|
42
|
-
let sharedSourceBundles =
|
|
43
|
-
return sharedSourceBundles.size
|
|
47
|
+
let getBundleOverlap = (sourceBundlesA, sourceBundlesB) => {
|
|
48
|
+
let allSourceBundles = (0, _utils().setUnion)(sourceBundlesA, sourceBundlesB);
|
|
49
|
+
let sharedSourceBundles = (0, _utils().setIntersectStatic)(sourceBundlesA, sourceBundlesB);
|
|
50
|
+
return sharedSourceBundles.size / allSourceBundles.size;
|
|
44
51
|
};
|
|
45
52
|
|
|
46
53
|
// Returns a decimal showing the proportion source bundles are common to
|
|
47
54
|
// both bundles versus the total number of source bundles.
|
|
48
55
|
function checkBundleThreshold(bundleA, bundleB, threshold) {
|
|
49
|
-
return
|
|
56
|
+
return getBundleOverlap(bundleA.bundle.sourceBundles, bundleB.bundle.sourceBundles) >= threshold;
|
|
50
57
|
}
|
|
51
58
|
let checkSharedSourceBundles = (0, _memoize.memoize)((bundle, importantAncestorBundles) => {
|
|
52
59
|
return importantAncestorBundles.every(ancestorId => bundle.sourceBundles.has(ancestorId));
|
|
@@ -100,14 +107,9 @@ function getPossibleMergeCandidates(bundleGraph, bundles) {
|
|
|
100
107
|
let mergeCandidates = bundles.map(bundleId => {
|
|
101
108
|
let bundle = bundleGraph.getNode(bundleId);
|
|
102
109
|
(0, _assert().default)(bundle && bundle !== 'root', 'Bundle should exist');
|
|
103
|
-
let sourceBundleBitSet = new (_graph().BitSet)(bundleGraph.nodes.length);
|
|
104
|
-
for (let sourceBundle of bundle.sourceBundles) {
|
|
105
|
-
sourceBundleBitSet.add(sourceBundle);
|
|
106
|
-
}
|
|
107
110
|
return {
|
|
108
111
|
id: bundleId,
|
|
109
112
|
bundle,
|
|
110
|
-
sourceBundleBitSet,
|
|
111
113
|
contentKey: bundleId.toString()
|
|
112
114
|
};
|
|
113
115
|
});
|
package/lib/idealGraph.js
CHANGED
|
@@ -161,17 +161,15 @@ function createIdealGraph(assetGraph, config, entries, logger) {
|
|
|
161
161
|
assetGraph.traverse((node, _, actions) => {
|
|
162
162
|
if (node.type === 'asset' && (!Array.isArray(c.types) || c.types.includes(node.value.type))) {
|
|
163
163
|
let projectRelativePath = _path().default.relative(config.projectRoot, node.value.filePath);
|
|
164
|
-
if (!assetRegexes.some(regex => regex.test(projectRelativePath))) {
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
164
|
|
|
168
165
|
// We track all matching MSB's for constant modules as they are never duplicated
|
|
169
166
|
// and need to be assigned to all matching bundles
|
|
170
167
|
if (node.value.meta.isConstantModule === true) {
|
|
171
168
|
constantModuleToMSB.get(node.value).push(c);
|
|
172
169
|
}
|
|
173
|
-
|
|
174
|
-
|
|
170
|
+
if (assetRegexes.some(regex => regex.test(projectRelativePath))) {
|
|
171
|
+
manualAssetToConfig.set(node.value, c);
|
|
172
|
+
}
|
|
175
173
|
}
|
|
176
174
|
if (node.type === 'dependency' && (node.value.priority === 'lazy' || (0, _featureFlags().getFeatureFlag)('conditionalBundlingApi') && node.value.priority === 'conditional') && parentAsset) {
|
|
177
175
|
// Don't walk past the bundle group assets
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/bundler-default",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.3",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"publishConfig": {
|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@atlaspack/diagnostic": "2.14.1",
|
|
20
|
-
"@atlaspack/feature-flags": "2.
|
|
21
|
-
"@atlaspack/graph": "3.5.
|
|
22
|
-
"@atlaspack/plugin": "2.14.
|
|
20
|
+
"@atlaspack/feature-flags": "2.18.0",
|
|
21
|
+
"@atlaspack/graph": "3.5.2",
|
|
22
|
+
"@atlaspack/plugin": "2.14.12",
|
|
23
23
|
"@atlaspack/rust": "3.3.5",
|
|
24
|
-
"@atlaspack/utils": "2.
|
|
24
|
+
"@atlaspack/utils": "2.15.0",
|
|
25
25
|
"nullthrows": "^1.1.1",
|
|
26
26
|
"many-keys-map": "^1.0.3"
|
|
27
27
|
}
|
package/src/bundleMerge.js
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import invariant from 'assert';
|
|
4
4
|
import nullthrows from 'nullthrows';
|
|
5
|
-
import {ContentGraph
|
|
5
|
+
import {ContentGraph} from '@atlaspack/graph';
|
|
6
6
|
import type {NodeId} from '@atlaspack/graph';
|
|
7
|
+
import {setUnion, setIntersectStatic} from '@atlaspack/utils';
|
|
7
8
|
import type {Bundle, IdealBundleGraph} from './idealGraph';
|
|
8
9
|
import {memoize, clearCaches} from './memoize';
|
|
9
10
|
|
|
@@ -20,14 +21,14 @@ function getBundlesForBundleGroup(
|
|
|
20
21
|
return count;
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
let
|
|
24
|
-
sourceBundlesA:
|
|
25
|
-
sourceBundlesB:
|
|
24
|
+
let getBundleOverlap = (
|
|
25
|
+
sourceBundlesA: Set<NodeId>,
|
|
26
|
+
sourceBundlesB: Set<NodeId>,
|
|
26
27
|
): number => {
|
|
27
|
-
let allSourceBundles =
|
|
28
|
-
let sharedSourceBundles =
|
|
28
|
+
let allSourceBundles = setUnion(sourceBundlesA, sourceBundlesB);
|
|
29
|
+
let sharedSourceBundles = setIntersectStatic(sourceBundlesA, sourceBundlesB);
|
|
29
30
|
|
|
30
|
-
return sharedSourceBundles.size
|
|
31
|
+
return sharedSourceBundles.size / allSourceBundles.size;
|
|
31
32
|
};
|
|
32
33
|
|
|
33
34
|
// Returns a decimal showing the proportion source bundles are common to
|
|
@@ -38,9 +39,9 @@ function checkBundleThreshold(
|
|
|
38
39
|
threshold: number,
|
|
39
40
|
): boolean {
|
|
40
41
|
return (
|
|
41
|
-
|
|
42
|
-
bundleA.
|
|
43
|
-
bundleB.
|
|
42
|
+
getBundleOverlap(
|
|
43
|
+
bundleA.bundle.sourceBundles,
|
|
44
|
+
bundleB.bundle.sourceBundles,
|
|
44
45
|
) >= threshold
|
|
45
46
|
);
|
|
46
47
|
}
|
|
@@ -147,7 +148,6 @@ function getMergeClusters(
|
|
|
147
148
|
type MergeCandidate = {|
|
|
148
149
|
bundle: Bundle,
|
|
149
150
|
id: NodeId,
|
|
150
|
-
sourceBundleBitSet: BitSet,
|
|
151
151
|
contentKey: string,
|
|
152
152
|
|};
|
|
153
153
|
function getPossibleMergeCandidates(
|
|
@@ -158,15 +158,9 @@ function getPossibleMergeCandidates(
|
|
|
158
158
|
let bundle = bundleGraph.getNode(bundleId);
|
|
159
159
|
invariant(bundle && bundle !== 'root', 'Bundle should exist');
|
|
160
160
|
|
|
161
|
-
let sourceBundleBitSet = new BitSet(bundleGraph.nodes.length);
|
|
162
|
-
for (let sourceBundle of bundle.sourceBundles) {
|
|
163
|
-
sourceBundleBitSet.add(sourceBundle);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
161
|
return {
|
|
167
162
|
id: bundleId,
|
|
168
163
|
bundle,
|
|
169
|
-
sourceBundleBitSet,
|
|
170
164
|
contentKey: bundleId.toString(),
|
|
171
165
|
};
|
|
172
166
|
});
|
package/src/idealGraph.js
CHANGED
|
@@ -204,17 +204,16 @@ export function createIdealGraph(
|
|
|
204
204
|
config.projectRoot,
|
|
205
205
|
node.value.filePath,
|
|
206
206
|
);
|
|
207
|
-
if (!assetRegexes.some((regex) => regex.test(projectRelativePath))) {
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
207
|
|
|
211
208
|
// We track all matching MSB's for constant modules as they are never duplicated
|
|
212
209
|
// and need to be assigned to all matching bundles
|
|
213
210
|
if (node.value.meta.isConstantModule === true) {
|
|
214
211
|
constantModuleToMSB.get(node.value).push(c);
|
|
215
212
|
}
|
|
216
|
-
|
|
217
|
-
|
|
213
|
+
|
|
214
|
+
if (assetRegexes.some((regex) => regex.test(projectRelativePath))) {
|
|
215
|
+
manualAssetToConfig.set(node.value, c);
|
|
216
|
+
}
|
|
218
217
|
}
|
|
219
218
|
|
|
220
219
|
if (
|