@atlaspack/bundler-default 3.0.2 → 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 +12 -0
- package/lib/bundleMerge.js +12 -10
- package/package.json +5 -5
- package/src/bundleMerge.js +11 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
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
|
+
|
|
3
15
|
## 3.0.2
|
|
4
16
|
|
|
5
17
|
### 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/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
|
});
|