@atlaspack/graph 3.4.1-dev.16 → 3.4.1-dev.161
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 +85 -0
- package/benchmark/BitSet.js +37 -0
- package/lib/AdjacencyList.js +2 -1
- package/lib/BitSet.js +36 -4
- package/lib/Graph.js +3 -2
- package/package.json +10 -3
- package/src/BitSet.js +31 -0
- package/test/BitSet.test.js +42 -0
- package/test/Graph.test.js +26 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,90 @@
|
|
|
1
1
|
# @atlaspack/graph
|
|
2
2
|
|
|
3
|
+
## 3.5.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`644b157`](https://github.com/atlassian-labs/atlaspack/commit/644b157dee72a871acc2d0facf0b87b8eea51956)]:
|
|
8
|
+
- @atlaspack/feature-flags@2.18.2
|
|
9
|
+
|
|
10
|
+
## 3.5.3
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [[`26aa9c5`](https://github.com/atlassian-labs/atlaspack/commit/26aa9c599d2be45ce1438a74c5fa22f39b9b554b), [`0501255`](https://github.com/atlassian-labs/atlaspack/commit/05012550da35b05ce7d356a8cc29311e7f9afdca)]:
|
|
15
|
+
- @atlaspack/feature-flags@2.18.1
|
|
16
|
+
|
|
17
|
+
## 3.5.2
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies [[`10fbcfb`](https://github.com/atlassian-labs/atlaspack/commit/10fbcfbfa49c7a83da5d7c40983e36e87f524a75), [`85c52d3`](https://github.com/atlassian-labs/atlaspack/commit/85c52d3f7717b3c84a118d18ab98cfbfd71dcbd2)]:
|
|
22
|
+
- @atlaspack/feature-flags@2.18.0
|
|
23
|
+
|
|
24
|
+
## 3.5.1
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- Updated dependencies [[`73ea3c4`](https://github.com/atlassian-labs/atlaspack/commit/73ea3c4d85d4401fdd15abcbf988237e890e7ad3), [`b1b3693`](https://github.com/atlassian-labs/atlaspack/commit/b1b369317c66f8a431c170df2ebba4fa5b2e38ef)]:
|
|
29
|
+
- @atlaspack/feature-flags@2.17.0
|
|
30
|
+
|
|
31
|
+
## 3.5.0
|
|
32
|
+
|
|
33
|
+
### Minor Changes
|
|
34
|
+
|
|
35
|
+
- [#600](https://github.com/atlassian-labs/atlaspack/pull/600) [`1b52b99`](https://github.com/atlassian-labs/atlaspack/commit/1b52b99db4298b04c1a6eb0f97994d75a2d436f9) Thanks [@mattcompiles](https://github.com/mattcompiles)! - Add static intersect, size and equals methods to BitSet
|
|
36
|
+
|
|
37
|
+
## 3.4.7
|
|
38
|
+
|
|
39
|
+
### Patch Changes
|
|
40
|
+
|
|
41
|
+
- Updated dependencies [[`209692f`](https://github.com/atlassian-labs/atlaspack/commit/209692ffb11eae103a0d65c5e1118a5aa1625818), [`f4da1e1`](https://github.com/atlassian-labs/atlaspack/commit/f4da1e120e73eeb5e8b8927f05e88f04d6148c7b)]:
|
|
42
|
+
- @atlaspack/feature-flags@2.16.0
|
|
43
|
+
|
|
44
|
+
## 3.4.6
|
|
45
|
+
|
|
46
|
+
### Patch Changes
|
|
47
|
+
|
|
48
|
+
- Updated dependencies [[`30f6017`](https://github.com/atlassian-labs/atlaspack/commit/30f60175ba4d272c5fc193973c63bc298584775b)]:
|
|
49
|
+
- @atlaspack/feature-flags@2.15.1
|
|
50
|
+
|
|
51
|
+
## 3.4.5
|
|
52
|
+
|
|
53
|
+
### Patch Changes
|
|
54
|
+
|
|
55
|
+
- Updated dependencies [[`a1773d2`](https://github.com/atlassian-labs/atlaspack/commit/a1773d2a62d0ef7805ac7524621dcabcc1afe929)]:
|
|
56
|
+
- @atlaspack/feature-flags@2.15.0
|
|
57
|
+
|
|
58
|
+
## 3.4.4
|
|
59
|
+
|
|
60
|
+
### Patch Changes
|
|
61
|
+
|
|
62
|
+
- Updated dependencies [[`e0f5337`](https://github.com/atlassian-labs/atlaspack/commit/e0f533757bd1019dbd108a04952c87da15286e09)]:
|
|
63
|
+
- @atlaspack/feature-flags@2.14.4
|
|
64
|
+
|
|
65
|
+
## 3.4.3
|
|
66
|
+
|
|
67
|
+
### Patch Changes
|
|
68
|
+
|
|
69
|
+
- Updated dependencies [[`11d6f16`](https://github.com/atlassian-labs/atlaspack/commit/11d6f16b6397dee2f217167e5c98b39edb63f7a7)]:
|
|
70
|
+
- @atlaspack/feature-flags@2.14.3
|
|
71
|
+
|
|
72
|
+
## 3.4.2
|
|
73
|
+
|
|
74
|
+
### Patch Changes
|
|
75
|
+
|
|
76
|
+
- Updated dependencies [[`9b85d3e`](https://github.com/atlassian-labs/atlaspack/commit/9b85d3e645b10bd027eed2304afc970a5ba40062), [`17b9579`](https://github.com/atlassian-labs/atlaspack/commit/17b9579484eced0ed8f23e2aba6d23b3c7238c39), [`8f4e6c1`](https://github.com/atlassian-labs/atlaspack/commit/8f4e6c1b0e7c1fd48624afda48c1dcc599f1460f)]:
|
|
77
|
+
- @atlaspack/feature-flags@2.14.2
|
|
78
|
+
|
|
79
|
+
## 3.4.1
|
|
80
|
+
|
|
81
|
+
### Patch Changes
|
|
82
|
+
|
|
83
|
+
- [#478](https://github.com/atlassian-labs/atlaspack/pull/478) [`570493b`](https://github.com/atlassian-labs/atlaspack/commit/570493beaf754e7985aebc7daaaf6dfcfa8fe56b) Thanks [@yamadapc](https://github.com/yamadapc)! - The first attempt at Version Packages didn't include the built artifacts.
|
|
84
|
+
This has hopefully been fixed, so this change will force those packages to re-release.
|
|
85
|
+
- Updated dependencies [[`4aab060`](https://github.com/atlassian-labs/atlaspack/commit/4aab0605c0d4ee8e0dcc3ffa1162eae5b360b677), [`e1422ad`](https://github.com/atlassian-labs/atlaspack/commit/e1422ad0a801faaa4bc4f1023bed042ffe236e9b), [`570493b`](https://github.com/atlassian-labs/atlaspack/commit/570493beaf754e7985aebc7daaaf6dfcfa8fe56b)]:
|
|
86
|
+
- @atlaspack/feature-flags@2.14.1
|
|
87
|
+
|
|
3
88
|
## 3.4.0
|
|
4
89
|
|
|
5
90
|
### Minor Changes
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* BitSets are primarily used for performance reasons, so we want to be able to
|
|
3
|
+
* validate that changes we make to it are performace improvements.
|
|
4
|
+
*
|
|
5
|
+
* This file exists as a ready-made playground for benchmarking changes you may
|
|
6
|
+
* want to make to the BitSet implementation.
|
|
7
|
+
*
|
|
8
|
+
* Run with `yarn workspace @atlaspack/graph benchmark` from the root
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// Needed to make Flow work in the benchmarks
|
|
12
|
+
require('@atlaspack/babel-register');
|
|
13
|
+
|
|
14
|
+
const {BitSet} = require('../src/BitSet.js');
|
|
15
|
+
const b = require('benny');
|
|
16
|
+
|
|
17
|
+
function createBitSetWithEntries(capacity, entries) {
|
|
18
|
+
let bitSet = new BitSet(capacity);
|
|
19
|
+
for (const index of entries) {
|
|
20
|
+
bitSet.add(index);
|
|
21
|
+
}
|
|
22
|
+
return bitSet;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
let bundleIndices = [4334, 348, 2145, 480, 747, 1446, 326, 2791, 2658, 1334];
|
|
26
|
+
|
|
27
|
+
let bundleBitSet = createBitSetWithEntries(5000, bundleIndices);
|
|
28
|
+
|
|
29
|
+
b.suite(
|
|
30
|
+
'BitSet - size',
|
|
31
|
+
b.add('Control', () => {
|
|
32
|
+
bundleBitSet.size();
|
|
33
|
+
}),
|
|
34
|
+
b.configure({minSamples: 100}),
|
|
35
|
+
b.cycle(),
|
|
36
|
+
b.complete(),
|
|
37
|
+
);
|
package/lib/AdjacencyList.js
CHANGED
|
@@ -1359,7 +1359,8 @@ function link(from, to, type, edges, nodes, unloadFactor = DEFAULT_PARAMS.unload
|
|
|
1359
1359
|
// Since the space occupied by deleted edges isn't reclaimed,
|
|
1360
1360
|
// we include them in our count to avoid overflowing the `edges` array.
|
|
1361
1361
|
let deletes = edges.deletes;
|
|
1362
|
-
|
|
1362
|
+
let total = count + deletes;
|
|
1363
|
+
if (edges.getLoad(total) >= 1) {
|
|
1363
1364
|
if (edges.getLoad(deletes) >= unloadFactor && edges.getLoad(count) < unloadFactor) {
|
|
1364
1365
|
// If we have a significant number of deletes, reclaim the space.
|
|
1365
1366
|
return LinkResult.TooManyDeletes;
|
package/lib/BitSet.js
CHANGED
|
@@ -9,7 +9,8 @@ function ctz32(n) {
|
|
|
9
9
|
if (n === 0) {
|
|
10
10
|
return 32;
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
let reversed = n & -n;
|
|
13
|
+
return 31 - Math.clz32(reversed);
|
|
13
14
|
}
|
|
14
15
|
class BitSet {
|
|
15
16
|
constructor(maxBits) {
|
|
@@ -25,17 +26,28 @@ class BitSet {
|
|
|
25
26
|
res.union(b);
|
|
26
27
|
return res;
|
|
27
28
|
}
|
|
29
|
+
static intersect(a, b) {
|
|
30
|
+
let res = a.clone();
|
|
31
|
+
res.intersect(b);
|
|
32
|
+
return res;
|
|
33
|
+
}
|
|
28
34
|
get capacity() {
|
|
29
35
|
return this.bits.length * 32;
|
|
30
36
|
}
|
|
31
37
|
add(bit) {
|
|
32
|
-
|
|
38
|
+
let i = bit >>> 5;
|
|
39
|
+
let b = bit & 31;
|
|
40
|
+
this.bits[i] |= 1 << b;
|
|
33
41
|
}
|
|
34
42
|
delete(bit) {
|
|
35
|
-
|
|
43
|
+
let i = bit >>> 5;
|
|
44
|
+
let b = bit & 31;
|
|
45
|
+
this.bits[i] &= ~(1 << b);
|
|
36
46
|
}
|
|
37
47
|
has(bit) {
|
|
38
|
-
|
|
48
|
+
let i = bit >>> 5;
|
|
49
|
+
let b = bit & 31;
|
|
50
|
+
return Boolean(this.bits[i] & 1 << b);
|
|
39
51
|
}
|
|
40
52
|
empty() {
|
|
41
53
|
for (let k = 0; k < this.bits.length; k++) {
|
|
@@ -63,6 +75,26 @@ class BitSet {
|
|
|
63
75
|
this.bits[i] &= ~other.bits[i];
|
|
64
76
|
}
|
|
65
77
|
}
|
|
78
|
+
size() {
|
|
79
|
+
let bits = this.bits;
|
|
80
|
+
let setBitsCount = 0;
|
|
81
|
+
for (let k = 0; k < bits.length; k++) {
|
|
82
|
+
let chunk = bits[k];
|
|
83
|
+
while (chunk !== 0) {
|
|
84
|
+
chunk &= chunk - 1; // Clear the least significant bit set
|
|
85
|
+
setBitsCount++;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return setBitsCount;
|
|
89
|
+
}
|
|
90
|
+
equals(other) {
|
|
91
|
+
for (let i = 0; i < this.bits.length; i++) {
|
|
92
|
+
if (this.bits[i] !== other.bits[i]) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
66
98
|
forEach(fn) {
|
|
67
99
|
// https://lemire.me/blog/2018/02/21/iterating-over-set-bits-quickly/
|
|
68
100
|
let bits = this.bits;
|
package/lib/Graph.js
CHANGED
|
@@ -324,6 +324,7 @@ class Graph {
|
|
|
324
324
|
}
|
|
325
325
|
}
|
|
326
326
|
this._visited = visited;
|
|
327
|
+
return;
|
|
327
328
|
}
|
|
328
329
|
|
|
329
330
|
/**
|
|
@@ -506,7 +507,7 @@ class Graph {
|
|
|
506
507
|
exports.default = Graph;
|
|
507
508
|
function mapVisitor(filter, visit) {
|
|
508
509
|
function makeEnter(visit) {
|
|
509
|
-
return function (nodeId, context, actions) {
|
|
510
|
+
return function mappedEnter(nodeId, context, actions) {
|
|
510
511
|
let value = filter(nodeId, actions);
|
|
511
512
|
if (value != null) {
|
|
512
513
|
return visit(value, context, actions);
|
|
@@ -521,7 +522,7 @@ function mapVisitor(filter, visit) {
|
|
|
521
522
|
mapped.enter = makeEnter(visit.enter);
|
|
522
523
|
}
|
|
523
524
|
if (visit.exit != null) {
|
|
524
|
-
mapped.exit = function (nodeId, context, actions) {
|
|
525
|
+
mapped.exit = function mappedExit(nodeId, context, actions) {
|
|
525
526
|
let exit = visit.exit;
|
|
526
527
|
if (!exit) {
|
|
527
528
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/graph",
|
|
3
|
-
"version": "3.4.1-dev.
|
|
3
|
+
"version": "3.4.1-dev.161+207d003c0",
|
|
4
4
|
"description": "Blazing fast, zero configuration web application bundler",
|
|
5
5
|
"license": "(MIT OR Apache-2.0)",
|
|
6
6
|
"publishConfig": {
|
|
@@ -15,10 +15,17 @@
|
|
|
15
15
|
"engines": {
|
|
16
16
|
"node": ">= 16.0.0"
|
|
17
17
|
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"benchmark": "node ./benchmark/BitSet.js"
|
|
20
|
+
},
|
|
18
21
|
"dependencies": {
|
|
19
|
-
"@atlaspack/feature-flags": "2.14.1-dev.
|
|
22
|
+
"@atlaspack/feature-flags": "2.14.1-dev.161+207d003c0",
|
|
20
23
|
"nullthrows": "^1.1.1"
|
|
21
24
|
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@atlaspack/babel-register": "2.14.1",
|
|
27
|
+
"benny": "^3.7.1"
|
|
28
|
+
},
|
|
22
29
|
"type": "commonjs",
|
|
23
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "207d003c0f1d4ffa6a1c52d2f8841d998616c523"
|
|
24
31
|
}
|
package/src/BitSet.js
CHANGED
|
@@ -28,6 +28,12 @@ export class BitSet {
|
|
|
28
28
|
return res;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
static intersect(a: BitSet, b: BitSet): BitSet {
|
|
32
|
+
let res = a.clone();
|
|
33
|
+
res.intersect(b);
|
|
34
|
+
return res;
|
|
35
|
+
}
|
|
36
|
+
|
|
31
37
|
get capacity(): number {
|
|
32
38
|
return this.bits.length * 32;
|
|
33
39
|
}
|
|
@@ -82,6 +88,31 @@ export class BitSet {
|
|
|
82
88
|
}
|
|
83
89
|
}
|
|
84
90
|
|
|
91
|
+
size(): number {
|
|
92
|
+
let bits = this.bits;
|
|
93
|
+
let setBitsCount = 0;
|
|
94
|
+
|
|
95
|
+
for (let k = 0; k < bits.length; k++) {
|
|
96
|
+
let chunk = bits[k];
|
|
97
|
+
|
|
98
|
+
while (chunk !== 0) {
|
|
99
|
+
chunk &= chunk - 1; // Clear the least significant bit set
|
|
100
|
+
setBitsCount++;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return setBitsCount;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
equals(other: BitSet): boolean {
|
|
108
|
+
for (let i = 0; i < this.bits.length; i++) {
|
|
109
|
+
if (this.bits[i] !== other.bits[i]) {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
|
|
85
116
|
forEach(fn: (bit: number) => void) {
|
|
86
117
|
// https://lemire.me/blog/2018/02/21/iterating-over-set-bits-quickly/
|
|
87
118
|
let bits = this.bits;
|
package/test/BitSet.test.js
CHANGED
|
@@ -107,4 +107,46 @@ describe('BitSet', () => {
|
|
|
107
107
|
assertValues(set2, [3, 5]);
|
|
108
108
|
assertValues(set3, [1, 3, 5]);
|
|
109
109
|
});
|
|
110
|
+
|
|
111
|
+
it('BitSet.intersect should create a new BitSet with the intersect', () => {
|
|
112
|
+
let set1 = new BitSet(5);
|
|
113
|
+
set1.add(1);
|
|
114
|
+
set1.add(3);
|
|
115
|
+
|
|
116
|
+
let set2 = new BitSet(5);
|
|
117
|
+
set2.add(3);
|
|
118
|
+
set2.add(5);
|
|
119
|
+
|
|
120
|
+
let set3 = BitSet.intersect(set1, set2);
|
|
121
|
+
assertValues(set1, [1, 3]);
|
|
122
|
+
assertValues(set2, [3, 5]);
|
|
123
|
+
assertValues(set3, [3]);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it('should identify equality with another BitSet', () => {
|
|
127
|
+
let set1 = new BitSet(5);
|
|
128
|
+
set1.add(1);
|
|
129
|
+
set1.add(3);
|
|
130
|
+
|
|
131
|
+
let set2 = new BitSet(5);
|
|
132
|
+
set2.add(3);
|
|
133
|
+
set2.add(5);
|
|
134
|
+
|
|
135
|
+
let set3 = set1.clone();
|
|
136
|
+
|
|
137
|
+
assert(set1.equals(set3));
|
|
138
|
+
assert(!set1.equals(set2));
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it('should calculate size of BitSet', () => {
|
|
142
|
+
let set1 = new BitSet(5);
|
|
143
|
+
set1.add(1);
|
|
144
|
+
set1.add(3);
|
|
145
|
+
|
|
146
|
+
assert.equal(set1.size(), 2);
|
|
147
|
+
|
|
148
|
+
set1.add(3);
|
|
149
|
+
set1.add(4);
|
|
150
|
+
assert.equal(set1.size(), 3);
|
|
151
|
+
});
|
|
110
152
|
});
|
package/test/Graph.test.js
CHANGED
|
@@ -528,12 +528,17 @@ describe('Graph', () => {
|
|
|
528
528
|
getChildren,
|
|
529
529
|
});
|
|
530
530
|
|
|
531
|
-
assert.deepEqual(
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
[
|
|
536
|
-
|
|
531
|
+
assert.deepEqual(
|
|
532
|
+
contexts.map((values) =>
|
|
533
|
+
values.map((v) => (v != null ? v : undefined)),
|
|
534
|
+
),
|
|
535
|
+
[
|
|
536
|
+
[0, undefined],
|
|
537
|
+
[1, 'node-0-created-context'],
|
|
538
|
+
[2, 'node-1-created-context'],
|
|
539
|
+
[3, 'node-2-created-context'],
|
|
540
|
+
],
|
|
541
|
+
);
|
|
537
542
|
assert.equal(result, undefined);
|
|
538
543
|
});
|
|
539
544
|
});
|
|
@@ -572,16 +577,21 @@ describe('Graph', () => {
|
|
|
572
577
|
getChildren,
|
|
573
578
|
});
|
|
574
579
|
|
|
575
|
-
assert.deepEqual(
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
[
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
580
|
+
assert.deepEqual(
|
|
581
|
+
contexts.map((values) =>
|
|
582
|
+
values.map((v) => (v != null ? v : undefined)),
|
|
583
|
+
),
|
|
584
|
+
[
|
|
585
|
+
[0, undefined],
|
|
586
|
+
[1, 'node-0-created-context'],
|
|
587
|
+
[2, 'node-1-created-context'],
|
|
588
|
+
['exit', 2, 'node-2-created-context'],
|
|
589
|
+
[3, 'node-1-created-context'],
|
|
590
|
+
['exit', 3, 'node-3-created-context'],
|
|
591
|
+
['exit', 1, 'node-1-created-context'],
|
|
592
|
+
['exit', 0, 'node-0-created-context'],
|
|
593
|
+
],
|
|
594
|
+
);
|
|
585
595
|
assert.equal(result, undefined);
|
|
586
596
|
});
|
|
587
597
|
});
|