@atlaspack/query 2.14.5-canary.14 → 2.14.5-canary.140
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 +150 -0
- package/lib/bin.js +3 -0
- package/lib/cli.js +36 -26
- package/lib/deep-imports.js +9 -7
- package/lib/index.js +49 -61
- package/package.json +5 -6
- package/src/bin.js +2 -1
- package/src/{cli.js → cli.ts} +65 -41
- package/src/{deep-imports.js → deep-imports.ts} +28 -31
- package/src/{index.js → index.ts} +71 -84
- package/tsconfig.json +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,155 @@
|
|
|
1
1
|
# @atlaspack/query
|
|
2
2
|
|
|
3
|
+
## 2.14.22
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`069de47`](https://github.com/atlassian-labs/atlaspack/commit/069de478e64fb5889f6f2ce023eb510782767fbd)]:
|
|
8
|
+
- @atlaspack/core@2.20.0
|
|
9
|
+
- @atlaspack/cache@3.2.16
|
|
10
|
+
- @atlaspack/graph@3.5.10
|
|
11
|
+
|
|
12
|
+
## 2.14.21
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [[`a0b959f`](https://github.com/atlassian-labs/atlaspack/commit/a0b959fbf61fc3f820ff03c7e8988945fe40a91a)]:
|
|
17
|
+
- @atlaspack/core@2.19.2
|
|
18
|
+
- @atlaspack/cache@3.2.15
|
|
19
|
+
- @atlaspack/graph@3.5.9
|
|
20
|
+
|
|
21
|
+
## 2.14.20
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- Updated dependencies []:
|
|
26
|
+
- @atlaspack/cache@3.2.14
|
|
27
|
+
- @atlaspack/core@2.19.1
|
|
28
|
+
- @atlaspack/graph@3.5.8
|
|
29
|
+
|
|
30
|
+
## 2.14.19
|
|
31
|
+
|
|
32
|
+
### Patch Changes
|
|
33
|
+
|
|
34
|
+
- Updated dependencies [[`dbb4072`](https://github.com/atlassian-labs/atlaspack/commit/dbb40721ebeb45990a14ba04e6b44e7f836fb32d), [`c4415a4`](https://github.com/atlassian-labs/atlaspack/commit/c4415a455543d984ca28452c2cb87a794d22497c), [`f0f7c71`](https://github.com/atlassian-labs/atlaspack/commit/f0f7c7168a1d3d18c6f30d2daed611275692b7c5), [`c9631af`](https://github.com/atlassian-labs/atlaspack/commit/c9631aff284b2c1c27e8a52f9da392ce65d666e8), [`18a57cf`](https://github.com/atlassian-labs/atlaspack/commit/18a57cf8a4789b2de5ad8e2676f317a26cc91417), [`3ba1aee`](https://github.com/atlassian-labs/atlaspack/commit/3ba1aee6a794a26b2f0255aaf6d003981532d0ae)]:
|
|
35
|
+
- @atlaspack/core@2.19.0
|
|
36
|
+
- @atlaspack/cache@3.2.13
|
|
37
|
+
- @atlaspack/graph@3.5.7
|
|
38
|
+
|
|
39
|
+
## 2.14.18
|
|
40
|
+
|
|
41
|
+
### Patch Changes
|
|
42
|
+
|
|
43
|
+
- Updated dependencies []:
|
|
44
|
+
- @atlaspack/cache@3.2.12
|
|
45
|
+
- @atlaspack/core@2.18.8
|
|
46
|
+
|
|
47
|
+
## 2.14.17
|
|
48
|
+
|
|
49
|
+
### Patch Changes
|
|
50
|
+
|
|
51
|
+
- Updated dependencies [[`1ff31f1`](https://github.com/atlassian-labs/atlaspack/commit/1ff31f10391c48780c9fcfc243b4e828a1b285e0), [`e8a60ff`](https://github.com/atlassian-labs/atlaspack/commit/e8a60ffbea41caef265786bbf73349771760081c)]:
|
|
52
|
+
- @atlaspack/core@2.18.7
|
|
53
|
+
- @atlaspack/cache@3.2.11
|
|
54
|
+
- @atlaspack/graph@3.5.6
|
|
55
|
+
|
|
56
|
+
## 2.14.16
|
|
57
|
+
|
|
58
|
+
### Patch Changes
|
|
59
|
+
|
|
60
|
+
- Updated dependencies [[`5ded263`](https://github.com/atlassian-labs/atlaspack/commit/5ded263c7f11b866e8885b81c73e20dd060b25be), [`74fd942`](https://github.com/atlassian-labs/atlaspack/commit/74fd94236ac697207082c4b755b079e56f5564fb)]:
|
|
61
|
+
- @atlaspack/core@2.18.6
|
|
62
|
+
- @atlaspack/cache@3.2.10
|
|
63
|
+
- @atlaspack/graph@3.5.5
|
|
64
|
+
|
|
65
|
+
## 2.14.15
|
|
66
|
+
|
|
67
|
+
### Patch Changes
|
|
68
|
+
|
|
69
|
+
- Updated dependencies [[`644b157`](https://github.com/atlassian-labs/atlaspack/commit/644b157dee72a871acc2d0facf0b87b8eea51956)]:
|
|
70
|
+
- @atlaspack/core@2.18.5
|
|
71
|
+
- @atlaspack/cache@3.2.9
|
|
72
|
+
- @atlaspack/graph@3.5.4
|
|
73
|
+
|
|
74
|
+
## 2.14.14
|
|
75
|
+
|
|
76
|
+
### Patch Changes
|
|
77
|
+
|
|
78
|
+
- Updated dependencies [[`ef3d622`](https://github.com/atlassian-labs/atlaspack/commit/ef3d6228f4e006702198a19c61e051d194d325cb), [`6b1f5ff`](https://github.com/atlassian-labs/atlaspack/commit/6b1f5fff68d7131fae075e14f4d2c02606dc6058), [`26aa9c5`](https://github.com/atlassian-labs/atlaspack/commit/26aa9c599d2be45ce1438a74c5fa22f39b9b554b), [`c8f7df4`](https://github.com/atlassian-labs/atlaspack/commit/c8f7df4eadfc4718040fceb065dae6e96a4051e7), [`0501255`](https://github.com/atlassian-labs/atlaspack/commit/05012550da35b05ce7d356a8cc29311e7f9afdca)]:
|
|
79
|
+
- @atlaspack/core@2.18.4
|
|
80
|
+
- @atlaspack/cache@3.2.8
|
|
81
|
+
- @atlaspack/graph@3.5.3
|
|
82
|
+
|
|
83
|
+
## 2.14.13
|
|
84
|
+
|
|
85
|
+
### Patch Changes
|
|
86
|
+
|
|
87
|
+
- Updated dependencies []:
|
|
88
|
+
- @atlaspack/cache@3.2.7
|
|
89
|
+
- @atlaspack/core@2.18.3
|
|
90
|
+
- @atlaspack/graph@3.5.2
|
|
91
|
+
|
|
92
|
+
## 2.14.12
|
|
93
|
+
|
|
94
|
+
### Patch Changes
|
|
95
|
+
|
|
96
|
+
- Updated dependencies []:
|
|
97
|
+
- @atlaspack/cache@3.2.6
|
|
98
|
+
- @atlaspack/core@2.18.2
|
|
99
|
+
- @atlaspack/graph@3.5.1
|
|
100
|
+
|
|
101
|
+
## 2.14.11
|
|
102
|
+
|
|
103
|
+
### Patch Changes
|
|
104
|
+
|
|
105
|
+
- Updated dependencies [[`1b52b99`](https://github.com/atlassian-labs/atlaspack/commit/1b52b99db4298b04c1a6eb0f97994d75a2d436f9)]:
|
|
106
|
+
- @atlaspack/graph@3.5.0
|
|
107
|
+
- @atlaspack/core@2.18.1
|
|
108
|
+
|
|
109
|
+
## 2.14.10
|
|
110
|
+
|
|
111
|
+
### Patch Changes
|
|
112
|
+
|
|
113
|
+
- Updated dependencies [[`51aba5f`](https://github.com/atlassian-labs/atlaspack/commit/51aba5fc0e49235ee06bbc3c376f48c3e7da5c4b), [`1e32d4e`](https://github.com/atlassian-labs/atlaspack/commit/1e32d4eae6b3af3968e8a0ef97d35b4347fd4196), [`0b2f6f5`](https://github.com/atlassian-labs/atlaspack/commit/0b2f6f55794d3ff6e2f5a41f963e7e5dd8ad9f8d), [`6dd4ccb`](https://github.com/atlassian-labs/atlaspack/commit/6dd4ccb753541de32322d881f973d571dd57e4ca)]:
|
|
114
|
+
- @atlaspack/core@2.18.0
|
|
115
|
+
- @atlaspack/cache@3.2.5
|
|
116
|
+
|
|
117
|
+
## 2.14.9
|
|
118
|
+
|
|
119
|
+
### Patch Changes
|
|
120
|
+
|
|
121
|
+
- Updated dependencies [[`1940859`](https://github.com/atlassian-labs/atlaspack/commit/194085942f0e86532e9d039fc3f8039badce4594), [`15b6155`](https://github.com/atlassian-labs/atlaspack/commit/15b61556e9114203ebbc9de94b864118ca764598), [`124b7ff`](https://github.com/atlassian-labs/atlaspack/commit/124b7fff44f71aac9fbad289a9a9509b3dfc9aaa), [`209692f`](https://github.com/atlassian-labs/atlaspack/commit/209692ffb11eae103a0d65c5e1118a5aa1625818), [`d04de26`](https://github.com/atlassian-labs/atlaspack/commit/d04de26af684d7abfba5091fbe3df16a12cd0ebc)]:
|
|
122
|
+
- @atlaspack/core@2.17.4
|
|
123
|
+
- @atlaspack/cache@3.2.4
|
|
124
|
+
- @atlaspack/graph@3.4.7
|
|
125
|
+
|
|
126
|
+
## 2.14.8
|
|
127
|
+
|
|
128
|
+
### Patch Changes
|
|
129
|
+
|
|
130
|
+
- Updated dependencies [[`30f6017`](https://github.com/atlassian-labs/atlaspack/commit/30f60175ba4d272c5fc193973c63bc298584775b), [`3a3e8e7`](https://github.com/atlassian-labs/atlaspack/commit/3a3e8e7be9e2dffd7304436d792f0f595d59665a), [`15c1e3c`](https://github.com/atlassian-labs/atlaspack/commit/15c1e3c0628bae4c768d76cf3afc53d6d0d7ce7c)]:
|
|
131
|
+
- @atlaspack/core@2.17.3
|
|
132
|
+
- @atlaspack/cache@3.2.3
|
|
133
|
+
- @atlaspack/graph@3.4.6
|
|
134
|
+
|
|
135
|
+
## 2.14.7
|
|
136
|
+
|
|
137
|
+
### Patch Changes
|
|
138
|
+
|
|
139
|
+
- Updated dependencies []:
|
|
140
|
+
- @atlaspack/cache@3.2.2
|
|
141
|
+
- @atlaspack/core@2.17.2
|
|
142
|
+
- @atlaspack/graph@3.4.5
|
|
143
|
+
|
|
144
|
+
## 2.14.6
|
|
145
|
+
|
|
146
|
+
### Patch Changes
|
|
147
|
+
|
|
148
|
+
- Updated dependencies []:
|
|
149
|
+
- @atlaspack/cache@3.2.1
|
|
150
|
+
- @atlaspack/core@2.17.1
|
|
151
|
+
- @atlaspack/graph@3.4.4
|
|
152
|
+
|
|
3
153
|
## 2.14.5
|
|
4
154
|
|
|
5
155
|
### Patch Changes
|
package/lib/bin.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
+
if (process.env.ATLASPACK_SOURCES === 'true' || process.env.ATLASPACK_BUILD_ENV === 'test' || process.env.ATLASPACK_SELF_BUILD) {
|
|
5
|
+
require('@atlaspack/babel-register');
|
|
6
|
+
}
|
|
4
7
|
const run = require('./cli').run;
|
|
5
8
|
require('v8-compile-cache');
|
|
6
9
|
run(process.argv.slice(2));
|
package/lib/cli.js
CHANGED
|
@@ -63,7 +63,7 @@ function _table() {
|
|
|
63
63
|
var _index = require("./index");
|
|
64
64
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
65
65
|
/* eslint-disable no-console, monorepo/no-internal-import */
|
|
66
|
-
|
|
66
|
+
|
|
67
67
|
const {
|
|
68
68
|
BundleGraph: {
|
|
69
69
|
bundleGraphEdgeTypes: bundleGraphEdgeTypes
|
|
@@ -488,6 +488,8 @@ async function run(input) {
|
|
|
488
488
|
let bundleId = (0, _nullthrows().default)(parseBundleLocator(v), 'Bundle not found');
|
|
489
489
|
let node = (0, _nullthrows().default)(bundleGraph._graph.getNodeByContentKey(bundleId), 'Bundle not found');
|
|
490
490
|
(0, _assert().default)(node.type === 'bundle', 'Node is not a bundle, but a ' + node.type);
|
|
491
|
+
|
|
492
|
+
// @ts-expect-error TS7006
|
|
491
493
|
bundleGraph.traverseAssets(node.value, asset => {
|
|
492
494
|
console.log(asset.id, asset.filePath);
|
|
493
495
|
});
|
|
@@ -500,6 +502,8 @@ async function run(input) {
|
|
|
500
502
|
let bundleId = (0, _nullthrows().default)(parseBundleLocator(v), 'Bundle not found');
|
|
501
503
|
let node = (0, _nullthrows().default)(bundleGraph._graph.getNodeByContentKey(bundleId), 'Bundle not found');
|
|
502
504
|
(0, _assert().default)(node.type === 'bundle', 'Node is not a bundle, but a ' + node.type);
|
|
505
|
+
|
|
506
|
+
// @ts-expect-error TS7006
|
|
503
507
|
bundleGraph.traverseBundle(node.value, node => {
|
|
504
508
|
if (node.type === 'asset') {
|
|
505
509
|
console.log(node.id, node.value.filePath);
|
|
@@ -546,23 +550,34 @@ async function run(input) {
|
|
|
546
550
|
console.log('# Incoming dependencies contained in referencing bundles (using this bundle as a shared bundle)');
|
|
547
551
|
let referencingBundles = bundleGraph.getReferencingBundles(bundleNode.value);
|
|
548
552
|
for (let incoming of bundleGraph._graph.getNodeIdsConnectedTo(assetNodeId)) {
|
|
549
|
-
if (
|
|
553
|
+
if (
|
|
554
|
+
// @ts-expect-error TS7006
|
|
555
|
+
referencingBundles.some(ref => bundleGraph._graph.hasEdge(bundleGraph._graph.getNodeIdByContentKey(ref.id), incoming, bundleGraphEdgeTypes.contains))) {
|
|
550
556
|
console.log(bundleGraph._graph.getNode(incoming));
|
|
551
557
|
}
|
|
552
558
|
}
|
|
553
559
|
}
|
|
554
|
-
function _getIncomingNodeOfType(
|
|
560
|
+
function _getIncomingNodeOfType(
|
|
561
|
+
// @ts-expect-error TS2304
|
|
562
|
+
bundleGraph,
|
|
563
|
+
// @ts-expect-error TS7006
|
|
564
|
+
node, type) {
|
|
555
565
|
if (!hasBundleGraph()) {
|
|
556
566
|
return;
|
|
557
567
|
}
|
|
558
568
|
(0, _assert().default)(bundleGraph != null);
|
|
559
569
|
const bundleGraphNodeId = bundleGraph._graph.getNodeIdByContentKey(node.id);
|
|
560
|
-
return bundleGraph._graph.getNodeIdsConnectedTo(bundleGraphNodeId, -1)
|
|
570
|
+
return bundleGraph._graph.getNodeIdsConnectedTo(bundleGraphNodeId, -1)
|
|
571
|
+
// @ts-expect-error TS7006
|
|
572
|
+
.map(id => (0, _nullthrows().default)(bundleGraph._graph.getNode(id)))
|
|
573
|
+
// @ts-expect-error TS7006
|
|
574
|
+
.find(node => node.type == type);
|
|
561
575
|
}
|
|
562
576
|
|
|
563
577
|
// We find the priority of a Bundle or BundleGroup by looking at its incoming dependencies.
|
|
564
578
|
// If a Bundle does not have an incoming dependency, we look for an incoming BundleGroup and its dependency
|
|
565
579
|
// e.g. Dep(priority = 1) -> BundleGroup -> Bundle means that the Bundle has priority 1.
|
|
580
|
+
// @ts-expect-error TS2304
|
|
566
581
|
function _getBundlePriority(bundleGraph, bundle) {
|
|
567
582
|
if (!hasBundleGraph()) {
|
|
568
583
|
return;
|
|
@@ -578,13 +593,19 @@ async function run(input) {
|
|
|
578
593
|
(0, _assert().default)(node.type === 'dependency', 'Not a dependency');
|
|
579
594
|
return node.value.priority;
|
|
580
595
|
}
|
|
596
|
+
|
|
597
|
+
// @ts-expect-error TS2304
|
|
581
598
|
function _findEntryBundle(bundleGraph, node) {
|
|
582
599
|
if (!hasBundleGraph()) {
|
|
583
600
|
return;
|
|
584
601
|
}
|
|
585
602
|
(0, _assert().default)(bundleGraph != null);
|
|
586
603
|
const bundleGraphNodeId = bundleGraph._graph.getNodeIdByContentKey(node.id);
|
|
587
|
-
const entryBundleGroup = bundleGraph._graph.getNodeIdsConnectedTo(bundleGraphNodeId, -1)
|
|
604
|
+
const entryBundleGroup = bundleGraph._graph.getNodeIdsConnectedTo(bundleGraphNodeId, -1)
|
|
605
|
+
// @ts-expect-error TS7006
|
|
606
|
+
.map(id => (0, _nullthrows().default)(bundleGraph._graph.getNode(id))).find(
|
|
607
|
+
// @ts-expect-error TS7006
|
|
608
|
+
node => node.type === 'bundle_group' && bundleGraph.isEntryBundleGroup(node.value));
|
|
588
609
|
return entryBundleGroup;
|
|
589
610
|
}
|
|
590
611
|
// eslint-disable-next-line no-unused-vars
|
|
@@ -612,12 +633,16 @@ async function run(input) {
|
|
|
612
633
|
let column = t.map(r => r[col]);
|
|
613
634
|
column.shift();
|
|
614
635
|
(0, _assert().default)(column != null);
|
|
615
|
-
return column.reduce(
|
|
636
|
+
return column.reduce(
|
|
637
|
+
// @ts-expect-error TS2365
|
|
638
|
+
(accumulator, currentValue) => accumulator + currentValue, initialValue);
|
|
616
639
|
}
|
|
617
640
|
table.push(['Totals', getColumnSum(table, 1), getColumnSum(table, 2), getColumnSum(table, 3)]);
|
|
618
641
|
_printStatsTable('Cache Info', table);
|
|
619
642
|
}
|
|
620
|
-
function timeSerialize(
|
|
643
|
+
function timeSerialize(
|
|
644
|
+
// @ts-expect-error TS2304
|
|
645
|
+
graph) {
|
|
621
646
|
let date = Date.now();
|
|
622
647
|
(0, _v().serialize)(graph);
|
|
623
648
|
date = Date.now() - date;
|
|
@@ -647,7 +672,7 @@ async function run(input) {
|
|
|
647
672
|
(0, _assert().default)(assetGraph != null);
|
|
648
673
|
for (let n of assetGraph.nodes) {
|
|
649
674
|
if (n && n.type in ag) {
|
|
650
|
-
//
|
|
675
|
+
// @ts-expect-error TS7053
|
|
651
676
|
ag[n.type]++;
|
|
652
677
|
}
|
|
653
678
|
}
|
|
@@ -678,11 +703,7 @@ async function run(input) {
|
|
|
678
703
|
bg.bundle_group++;
|
|
679
704
|
} else if ((n === null || n === void 0 ? void 0 : n.type) === 'bundle') {
|
|
680
705
|
bg.bundle++;
|
|
681
|
-
|
|
682
|
-
// $FlowFixMe
|
|
683
706
|
b_ext[n.value.type] = (b_ext[n.value.type] || 0) + 1;
|
|
684
|
-
|
|
685
|
-
// $FlowFixMe
|
|
686
707
|
const entry_group = _findEntryBundle(bundleGraph, n);
|
|
687
708
|
if (entry_group != null && !entries.has(entry_group.id)) {
|
|
688
709
|
b_type.entry++;
|
|
@@ -701,9 +722,7 @@ async function run(input) {
|
|
|
701
722
|
}
|
|
702
723
|
}
|
|
703
724
|
} else if ((n === null || n === void 0 ? void 0 : n.type) === 'asset') {
|
|
704
|
-
if (
|
|
705
|
-
// $FlowFixMe
|
|
706
|
-
fromProjectPathRelative(n.value.filePath).includes('node_modules')) {
|
|
725
|
+
if (fromProjectPathRelative(n.value.filePath).includes('node_modules')) {
|
|
707
726
|
bg.asset_node_modules++;
|
|
708
727
|
} else {
|
|
709
728
|
bg.asset_source++;
|
|
@@ -724,6 +743,7 @@ async function run(input) {
|
|
|
724
743
|
}
|
|
725
744
|
let sum_b_type = 0;
|
|
726
745
|
for (let k in b_type) {
|
|
746
|
+
// @ts-expect-error TS7053
|
|
727
747
|
sum_b_type += b_type[k];
|
|
728
748
|
}
|
|
729
749
|
(0, _assert().default)(bg.bundle == sum_b_type, `Bundles by type ${sum_b_type} does not equal total ${bg.bundle}`);
|
|
@@ -747,16 +767,10 @@ async function run(input) {
|
|
|
747
767
|
useColors: true,
|
|
748
768
|
useGlobal: true
|
|
749
769
|
});
|
|
750
|
-
// $FlowFixMe[prop-missing]
|
|
751
770
|
server.setupHistory(_path().default.join(_os().default.homedir(), '.parcel_query_history'), () => {});
|
|
752
|
-
|
|
753
|
-
// $FlowFixMe[prop-missing]
|
|
754
771
|
server.context.bundleGraph = bundleGraph;
|
|
755
|
-
// $FlowFixMe[prop-missing]
|
|
756
772
|
server.context.assetGraph = assetGraph;
|
|
757
|
-
// $FlowFixMe[prop-missing]
|
|
758
773
|
server.context.requestTracker = requestTracker;
|
|
759
|
-
// $FlowFixMe[prop-missing]
|
|
760
774
|
server.context.cacheInfo = cacheInfo;
|
|
761
775
|
for (let [name, cmd] of new Map([['getAsset', {
|
|
762
776
|
help: 'args: <id | public id | filepath>',
|
|
@@ -808,6 +822,7 @@ async function run(input) {
|
|
|
808
822
|
action: getBundle
|
|
809
823
|
}], ['findBundleReason', {
|
|
810
824
|
help: 'args: <bundle> <asset>. Why is the asset in the bundle',
|
|
825
|
+
// @ts-expect-error TS2556
|
|
811
826
|
action: v => findBundleReason(...v.split(' '))
|
|
812
827
|
}], ['getBundles', {
|
|
813
828
|
help: 'List all bundles',
|
|
@@ -828,16 +843,11 @@ async function run(input) {
|
|
|
828
843
|
help: 'args: <local>. Get the asset that defines the symbol with the given local name',
|
|
829
844
|
action: findAssetWithSymbol
|
|
830
845
|
}]])) {
|
|
831
|
-
// $FlowFixMe
|
|
832
846
|
server.context[name] = cmd.action;
|
|
833
|
-
// $FlowFixMe
|
|
834
847
|
server.defineCommand(name, {
|
|
835
|
-
// $FlowFixMe
|
|
836
848
|
help: '📦 ' + cmd.help,
|
|
837
849
|
action: v => {
|
|
838
|
-
// $FlowFixMe
|
|
839
850
|
server.clearBufferedCommand();
|
|
840
|
-
// $FlowFixMe
|
|
841
851
|
try {
|
|
842
852
|
cmd.action(v);
|
|
843
853
|
} finally {
|
package/lib/deep-imports.js
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
/* eslint-disable monorepo/no-internal-import */
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
const v = process.env.ATLASPACK_BUILD_ENV === 'production' || process.env.ATLASPACK_REGISTER_USE_SRC !== 'true' ? {
|
|
5
6
|
// Split up require specifier to outsmart packages/dev/babel-register/babel-plugin-module-translate.js
|
|
6
|
-
// $FlowFixMe(unsupported-syntax)
|
|
7
7
|
AssetGraph: require('@atlaspack/core' + '/lib/AssetGraph').default,
|
|
8
|
-
// $FlowFixMe(unsupported-syntax)
|
|
9
8
|
BundleGraph: require('@atlaspack/core' + '/lib/BundleGraph'),
|
|
10
|
-
// $FlowFixMe(unsupported-syntax)
|
|
11
9
|
RequestTracker: require('@atlaspack/core' + '/lib/RequestTracker'),
|
|
12
|
-
// $FlowFixMe(unsupported-syntax)
|
|
13
10
|
LMDBLiteCache: require('@atlaspack/cache' + '/lib/LMDBLiteCache').LMDBLiteCache,
|
|
14
|
-
// $FlowFixMe(unsupported-syntax)
|
|
15
11
|
Priority: require('@atlaspack/core' + '/lib/types').Priority,
|
|
16
|
-
// $FlowFixMe(unsupported-syntax)
|
|
17
12
|
fromProjectPathRelative: require('@atlaspack/core' + '/lib/projectPath').fromProjectPathRelative
|
|
13
|
+
} : {
|
|
14
|
+
AssetGraph: require('@atlaspack/core/src/AssetGraph').default,
|
|
15
|
+
BundleGraph: require('@atlaspack/core/src/BundleGraph'),
|
|
16
|
+
RequestTracker: require('@atlaspack/core/src/RequestTracker'),
|
|
17
|
+
LMDBLiteCache: require('@atlaspack/cache/src/LMDBLiteCache').LMDBLiteCache,
|
|
18
|
+
Priority: require('@atlaspack/core/src/types').Priority,
|
|
19
|
+
fromProjectPathRelative: require('@atlaspack/core/src/projectPath').fromProjectPathRelative
|
|
18
20
|
};
|
|
19
21
|
module.exports = v;
|
package/lib/index.js
CHANGED
|
@@ -4,20 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.loadGraphs = loadGraphs;
|
|
7
|
-
function _fs() {
|
|
8
|
-
const data = _interopRequireDefault(require("fs"));
|
|
9
|
-
_fs = function () {
|
|
10
|
-
return data;
|
|
11
|
-
};
|
|
12
|
-
return data;
|
|
13
|
-
}
|
|
14
|
-
function _path() {
|
|
15
|
-
const data = _interopRequireDefault(require("path"));
|
|
16
|
-
_path = function () {
|
|
17
|
-
return data;
|
|
18
|
-
};
|
|
19
|
-
return data;
|
|
20
|
-
}
|
|
21
7
|
function _v() {
|
|
22
8
|
const data = _interopRequireDefault(require("v8"));
|
|
23
9
|
_v = function () {
|
|
@@ -41,6 +27,7 @@ function _assert() {
|
|
|
41
27
|
}
|
|
42
28
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
43
29
|
/* eslint-disable no-console, monorepo/no-internal-import */
|
|
30
|
+
|
|
44
31
|
const {
|
|
45
32
|
AssetGraph,
|
|
46
33
|
BundleGraph: {
|
|
@@ -52,75 +39,70 @@ const {
|
|
|
52
39
|
requestGraphEdgeTypes
|
|
53
40
|
},
|
|
54
41
|
LMDBLiteCache
|
|
55
|
-
} = require('./deep-imports.js');
|
|
42
|
+
} = process.env.ATLASPACK_REGISTER_USE_SRC === 'true' ? require('./deep-imports.js') : require('./deep-imports.ts');
|
|
56
43
|
async function loadGraphs(cacheDir) {
|
|
57
44
|
let cacheInfo = new Map();
|
|
58
|
-
|
|
45
|
+
const cache = new LMDBLiteCache(cacheDir);
|
|
46
|
+
let requestGraphBlob;
|
|
47
|
+
let requestGraphKey;
|
|
48
|
+
let bundleGraphBlob;
|
|
49
|
+
let assetGraphBlob;
|
|
50
|
+
for (let key of cache.keys()) {
|
|
51
|
+
if (key.startsWith('Asset/')) {
|
|
52
|
+
continue;
|
|
53
|
+
} else if (key.startsWith('PackagerRunner/')) {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (key.startsWith('RequestTracker/') && key.endsWith('/RequestGraph')) {
|
|
57
|
+
requestGraphBlob = key;
|
|
58
|
+
requestGraphKey = key.split('/').slice(0, -1).join('/');
|
|
59
|
+
}
|
|
60
|
+
if (key.startsWith('BundleGraph/')) {
|
|
61
|
+
bundleGraphBlob = key;
|
|
62
|
+
}
|
|
63
|
+
if (key.startsWith('AssetGraph/')) {
|
|
64
|
+
assetGraphBlob = key;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
console.log({
|
|
59
68
|
requestGraphBlob,
|
|
60
69
|
bundleGraphBlob,
|
|
61
70
|
assetGraphBlob
|
|
62
|
-
}
|
|
63
|
-
let files = _fs().default.readdirSync(cacheDir);
|
|
64
|
-
let result = {};
|
|
65
|
-
let blobsToFind = [{
|
|
66
|
-
name: 'requestGraphBlob',
|
|
67
|
-
check: basename => basename.startsWith('requestGraph-') && !basename.startsWith('requestGraph-nodes')
|
|
68
|
-
}, {
|
|
69
|
-
name: 'bundleGraphBlob',
|
|
70
|
-
check: basename => basename.endsWith('BundleGraph-0')
|
|
71
|
-
}, {
|
|
72
|
-
name: 'assetGraphBlob',
|
|
73
|
-
check: basename => basename.endsWith('AssetGraph-0')
|
|
74
|
-
}];
|
|
75
|
-
for (let file of files) {
|
|
76
|
-
let basename = _path().default.basename(file);
|
|
77
|
-
let match = blobsToFind.find(({
|
|
78
|
-
check
|
|
79
|
-
}) => check(basename));
|
|
80
|
-
if (match) {
|
|
81
|
-
let stat = _fs().default.statSync(_path().default.join(cacheDir, file));
|
|
82
|
-
if (!match.mtime || stat.mtime > match.mtime) {
|
|
83
|
-
match.mtime = stat.mtime;
|
|
84
|
-
result[match.name] = file;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return result;
|
|
89
|
-
}();
|
|
90
|
-
const cache = new LMDBLiteCache(cacheDir);
|
|
71
|
+
});
|
|
91
72
|
|
|
92
73
|
// Get requestTracker
|
|
74
|
+
// @ts-expect-error TS7034
|
|
93
75
|
let requestTracker;
|
|
94
|
-
if (requestGraphBlob) {
|
|
76
|
+
if (requestGraphBlob != null && requestGraphKey != null) {
|
|
95
77
|
try {
|
|
96
78
|
var _cacheInfo$get;
|
|
97
|
-
let requestGraphKey = requestGraphBlob.slice(0, -'-0'.length);
|
|
98
79
|
let date = Date.now();
|
|
80
|
+
const buffer = await cache.getBlob(requestGraphBlob);
|
|
81
|
+
const deserializer = new (_v().default.Deserializer)(buffer);
|
|
82
|
+
console.log('Wire format version stored', deserializer.getWireFormatVersion());
|
|
99
83
|
let {
|
|
100
84
|
requestGraph,
|
|
101
85
|
bufferLength
|
|
102
|
-
} = await readAndDeserializeRequestGraph(cache,
|
|
86
|
+
} = await readAndDeserializeRequestGraph(cache, requestGraphBlob, requestGraphKey);
|
|
103
87
|
requestTracker = new RequestTracker({
|
|
104
88
|
graph: requestGraph,
|
|
105
|
-
// $FlowFixMe
|
|
106
89
|
farm: null,
|
|
107
|
-
// $FlowFixMe
|
|
108
90
|
options: null
|
|
109
91
|
});
|
|
110
92
|
let timeToDeserialize = Date.now() - date;
|
|
111
93
|
cacheInfo.set('RequestGraph', [bufferLength]);
|
|
112
94
|
(_cacheInfo$get = cacheInfo.get('RequestGraph')) === null || _cacheInfo$get === void 0 || _cacheInfo$get.push(timeToDeserialize);
|
|
113
95
|
} catch (e) {
|
|
114
|
-
console.
|
|
96
|
+
console.error('Error loading Request Graph\n', e);
|
|
115
97
|
}
|
|
116
98
|
}
|
|
117
99
|
|
|
118
100
|
// Get bundleGraph
|
|
119
101
|
let bundleGraph;
|
|
120
|
-
if (bundleGraphBlob) {
|
|
102
|
+
if (bundleGraphBlob != null) {
|
|
121
103
|
try {
|
|
122
104
|
var _cacheInfo$get2;
|
|
123
|
-
let file = await cache.
|
|
105
|
+
let file = await cache.getBlob(bundleGraphBlob);
|
|
124
106
|
let timeToDeserialize = Date.now();
|
|
125
107
|
let obj = _v().default.deserialize(file);
|
|
126
108
|
(0, _assert().default)(obj.bundleGraph != null);
|
|
@@ -129,17 +111,17 @@ async function loadGraphs(cacheDir) {
|
|
|
129
111
|
cacheInfo.set('BundleGraph', [Buffer.byteLength(file)]);
|
|
130
112
|
(_cacheInfo$get2 = cacheInfo.get('BundleGraph')) === null || _cacheInfo$get2 === void 0 || _cacheInfo$get2.push(timeToDeserialize);
|
|
131
113
|
} catch (e) {
|
|
132
|
-
console.
|
|
114
|
+
console.error('Error loading Bundle Graph\n', e);
|
|
133
115
|
}
|
|
134
116
|
}
|
|
135
117
|
|
|
136
118
|
// Get assetGraph
|
|
137
119
|
let assetGraph;
|
|
138
|
-
if (assetGraphBlob) {
|
|
120
|
+
if (assetGraphBlob != null) {
|
|
139
121
|
try {
|
|
140
122
|
var _cacheInfo$get3;
|
|
141
123
|
// TODO: this should be reviewed when `cachePerformanceImprovements` flag is removed, as we'll be writing files to LMDB cache instead of large blobs
|
|
142
|
-
let file = await cache.
|
|
124
|
+
let file = await cache.getBlob(assetGraphBlob);
|
|
143
125
|
let timeToDeserialize = Date.now();
|
|
144
126
|
let obj = _v().default.deserialize(file);
|
|
145
127
|
(0, _assert().default)(obj.assetGraph != null);
|
|
@@ -148,11 +130,16 @@ async function loadGraphs(cacheDir) {
|
|
|
148
130
|
cacheInfo.set('AssetGraph', [Buffer.byteLength(file)]);
|
|
149
131
|
(_cacheInfo$get3 = cacheInfo.get('AssetGraph')) === null || _cacheInfo$get3 === void 0 || _cacheInfo$get3.push(timeToDeserialize);
|
|
150
132
|
} catch (e) {
|
|
151
|
-
console.
|
|
133
|
+
console.error('Error loading Asset Graph\n', e);
|
|
152
134
|
}
|
|
153
135
|
}
|
|
154
136
|
function getSubRequests(id) {
|
|
155
|
-
return
|
|
137
|
+
return (
|
|
138
|
+
// @ts-expect-error TS7005
|
|
139
|
+
requestTracker.graph.getNodeIdsConnectedFrom(id, requestGraphEdgeTypes.subrequest)
|
|
140
|
+
// @ts-expect-error TS7006
|
|
141
|
+
.map(n => (0, _nullthrows().default)(requestTracker.graph.getNode(n)))
|
|
142
|
+
);
|
|
156
143
|
}
|
|
157
144
|
|
|
158
145
|
// Load graphs by finding the main subrequests and loading their results
|
|
@@ -163,14 +150,15 @@ async function loadGraphs(cacheDir) {
|
|
|
163
150
|
let buildRequestNode = (0, _nullthrows().default)(requestTracker.graph.getNode(buildRequestId));
|
|
164
151
|
(0, _assert().default)(buildRequestNode.type === 1 && buildRequestNode.requestType === 1);
|
|
165
152
|
let buildRequestSubRequests = getSubRequests(buildRequestId);
|
|
166
|
-
let writeBundlesRequest = buildRequestSubRequests.find(
|
|
153
|
+
let writeBundlesRequest = buildRequestSubRequests.find(
|
|
154
|
+
// @ts-expect-error TS7006
|
|
155
|
+
n => n.type === 1 && n.requestType === 11);
|
|
167
156
|
if (writeBundlesRequest != null) {
|
|
168
157
|
(0, _assert().default)(writeBundlesRequest.type === 1);
|
|
169
|
-
// $FlowFixMe[incompatible-cast]
|
|
170
158
|
bundleInfo = (0, _nullthrows().default)(writeBundlesRequest.result);
|
|
171
159
|
}
|
|
172
160
|
} catch (e) {
|
|
173
|
-
console.
|
|
161
|
+
console.error('Error loading bundleInfo\n', e);
|
|
174
162
|
}
|
|
175
163
|
return {
|
|
176
164
|
assetGraph,
|
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/query",
|
|
3
|
-
"version": "2.14.5-canary.
|
|
3
|
+
"version": "2.14.5-canary.140+43fdd2238",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
8
8
|
"scripts": {
|
|
9
|
-
"prepack": "./ensure-no-dev-lib.sh",
|
|
10
9
|
"dev:prepare": "rimraf ./lib/ && mkdir -p lib && cp ./bin/dev-bin.js ./lib/bin.js"
|
|
11
10
|
},
|
|
12
11
|
"repository": {
|
|
@@ -18,9 +17,9 @@
|
|
|
18
17
|
},
|
|
19
18
|
"main": "src/index.js",
|
|
20
19
|
"dependencies": {
|
|
21
|
-
"@atlaspack/cache": "3.1.1-canary.
|
|
22
|
-
"@atlaspack/core": "2.16.2-canary.
|
|
23
|
-
"@atlaspack/graph": "3.4.1-canary.
|
|
20
|
+
"@atlaspack/cache": "3.1.1-canary.140+43fdd2238",
|
|
21
|
+
"@atlaspack/core": "2.16.2-canary.140+43fdd2238",
|
|
22
|
+
"@atlaspack/graph": "3.4.1-canary.208+43fdd2238",
|
|
24
23
|
"nullthrows": "^1.1.1",
|
|
25
24
|
"table": "^6.8.1",
|
|
26
25
|
"v8-compile-cache": "^2.0.0"
|
|
@@ -31,5 +30,5 @@
|
|
|
31
30
|
"rimraf": "^5.0.5"
|
|
32
31
|
},
|
|
33
32
|
"type": "commonjs",
|
|
34
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "43fdd223860fbc97af17d68c65419b97412cb888"
|
|
35
34
|
}
|
package/src/bin.js
CHANGED
package/src/{cli.js → cli.ts}
RENAMED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @flow strict-local
|
|
2
1
|
/* eslint-disable no-console, monorepo/no-internal-import */
|
|
3
2
|
import type {ContentGraph, ContentKey, NodeId} from '@atlaspack/graph';
|
|
4
3
|
import type {BundleGraphEdgeType} from '@atlaspack/core/src/BundleGraph';
|
|
@@ -11,7 +10,6 @@ import os from 'os';
|
|
|
11
10
|
import nullthrows from 'nullthrows';
|
|
12
11
|
import invariant from 'assert';
|
|
13
12
|
import {serialize} from 'v8';
|
|
14
|
-
// $FlowFixMe
|
|
15
13
|
import {table} from 'table';
|
|
16
14
|
|
|
17
15
|
import {loadGraphs} from './index';
|
|
@@ -33,7 +31,7 @@ export async function run(input: string[]) {
|
|
|
33
31
|
|
|
34
32
|
try {
|
|
35
33
|
fs.accessSync(cacheDir);
|
|
36
|
-
} catch (e) {
|
|
34
|
+
} catch (e: any) {
|
|
37
35
|
console.error("Can't find cache dir", cacheDir);
|
|
38
36
|
process.exit(1);
|
|
39
37
|
}
|
|
@@ -85,7 +83,7 @@ export async function run(input: string[]) {
|
|
|
85
83
|
}
|
|
86
84
|
|
|
87
85
|
function parseAssetLocator(v: string) {
|
|
88
|
-
let id:
|
|
86
|
+
let id: string | null | undefined = null;
|
|
89
87
|
if (v.length === 16) {
|
|
90
88
|
id = v;
|
|
91
89
|
} else {
|
|
@@ -138,7 +136,7 @@ export async function run(input: string[]) {
|
|
|
138
136
|
}
|
|
139
137
|
|
|
140
138
|
function getAsset(v: string) {
|
|
141
|
-
let id:
|
|
139
|
+
let id: string | null | undefined = parseAssetLocator(v);
|
|
142
140
|
|
|
143
141
|
if (id == null) {
|
|
144
142
|
console.log(null);
|
|
@@ -151,7 +149,7 @@ export async function run(input: string[]) {
|
|
|
151
149
|
let asset = bundleGraph.getAssetById(id);
|
|
152
150
|
console.log('Public id', bundleGraph.getAssetPublicId(asset));
|
|
153
151
|
console.log(asset);
|
|
154
|
-
} catch (e) {
|
|
152
|
+
} catch (e: any) {
|
|
155
153
|
if (!hasAssetGraph()) {
|
|
156
154
|
return;
|
|
157
155
|
}
|
|
@@ -192,7 +190,7 @@ export async function run(input: string[]) {
|
|
|
192
190
|
bundleGraph.getAssetById(node.id),
|
|
193
191
|
)} ${fromProjectPathRelative(node.value.filePath)}`,
|
|
194
192
|
);
|
|
195
|
-
} catch (e) {
|
|
193
|
+
} catch (e: any) {
|
|
196
194
|
console.log(fromProjectPathRelative(node.value.filePath));
|
|
197
195
|
}
|
|
198
196
|
}
|
|
@@ -246,7 +244,7 @@ export async function run(input: string[]) {
|
|
|
246
244
|
bundleGraph.getAssetById(asset.id),
|
|
247
245
|
)} ${fromProjectPathRelative(asset.value.filePath)}`,
|
|
248
246
|
);
|
|
249
|
-
} catch (e) {
|
|
247
|
+
} catch (e: any) {
|
|
250
248
|
console.log(fromProjectPathRelative(asset.value.filePath));
|
|
251
249
|
}
|
|
252
250
|
if (binding === 'export' && asset.value.symbols) {
|
|
@@ -262,7 +260,7 @@ export async function run(input: string[]) {
|
|
|
262
260
|
bundleGraph.getAssetById(locAsset.id),
|
|
263
261
|
)} ${fromProjectPathRelative(locAsset.value.filePath)}`,
|
|
264
262
|
);
|
|
265
|
-
} catch (e) {
|
|
263
|
+
} catch (e: any) {
|
|
266
264
|
console.log(
|
|
267
265
|
`imported as ${symbolName} from ${fromProjectPathRelative(
|
|
268
266
|
locAsset.value.filePath,
|
|
@@ -311,12 +309,12 @@ export async function run(input: string[]) {
|
|
|
311
309
|
this.label = label;
|
|
312
310
|
this.suffix = suffix;
|
|
313
311
|
}
|
|
314
|
-
add(v: T, label
|
|
312
|
+
add(v: T, label?: string, suffix?: string): Paths<T> {
|
|
315
313
|
let next = new Paths(v, label, suffix);
|
|
316
314
|
this.children.push(next);
|
|
317
315
|
return next;
|
|
318
316
|
}
|
|
319
|
-
print(format: (T) => string, prefix = '') {
|
|
317
|
+
print(format: (arg1: T) => string, prefix = '') {
|
|
320
318
|
console.log(
|
|
321
319
|
`${prefix}${this.label} ${format(this.value)} ${this.suffix}`,
|
|
322
320
|
);
|
|
@@ -335,7 +333,14 @@ export async function run(input: string[]) {
|
|
|
335
333
|
let asset = nullthrows(parseAssetLocator(v), 'Asset not found');
|
|
336
334
|
|
|
337
335
|
let paths = new Paths<NodeId>(graph.getNodeIdByContentKey(asset), ' ');
|
|
338
|
-
let cb = (
|
|
336
|
+
let cb = (
|
|
337
|
+
id: NodeId,
|
|
338
|
+
ctx: {
|
|
339
|
+
lazyOutgoing: boolean;
|
|
340
|
+
paths: Paths<NodeId>;
|
|
341
|
+
},
|
|
342
|
+
revisiting: boolean,
|
|
343
|
+
) => {
|
|
339
344
|
let {paths, lazyOutgoing} = ctx;
|
|
340
345
|
let node = nullthrows(graph.getNode(id));
|
|
341
346
|
if (node.id === asset) return ctx;
|
|
@@ -356,7 +361,13 @@ export async function run(input: string[]) {
|
|
|
356
361
|
|
|
357
362
|
// like graph.dfs, but revisiting nodes and skipping its children
|
|
358
363
|
let seen = new Set();
|
|
359
|
-
function walk(
|
|
364
|
+
function walk(
|
|
365
|
+
id: NodeId,
|
|
366
|
+
ctx: {
|
|
367
|
+
lazyOutgoing: boolean;
|
|
368
|
+
paths: Paths<NodeId>;
|
|
369
|
+
},
|
|
370
|
+
) {
|
|
360
371
|
let revisiting = seen.has(id);
|
|
361
372
|
let newCtx = cb(id, ctx, revisiting);
|
|
362
373
|
if (revisiting) return;
|
|
@@ -434,7 +445,7 @@ export async function run(input: string[]) {
|
|
|
434
445
|
}
|
|
435
446
|
|
|
436
447
|
// eslint-disable-next-line no-unused-vars
|
|
437
|
-
function getBundles(_) {
|
|
448
|
+
function getBundles(_: any) {
|
|
438
449
|
if (!hasBundleGraph()) {
|
|
439
450
|
return;
|
|
440
451
|
}
|
|
@@ -549,6 +560,7 @@ export async function run(input: string[]) {
|
|
|
549
560
|
'Node is not a bundle, but a ' + node.type,
|
|
550
561
|
);
|
|
551
562
|
|
|
563
|
+
// @ts-expect-error TS7006
|
|
552
564
|
bundleGraph.traverseAssets(node.value, (asset) => {
|
|
553
565
|
console.log(asset.id, asset.filePath);
|
|
554
566
|
});
|
|
@@ -568,6 +580,7 @@ export async function run(input: string[]) {
|
|
|
568
580
|
'Node is not a bundle, but a ' + node.type,
|
|
569
581
|
);
|
|
570
582
|
|
|
583
|
+
// @ts-expect-error TS7006
|
|
571
584
|
bundleGraph.traverseBundle(node.value, (node) => {
|
|
572
585
|
if (node.type === 'asset') {
|
|
573
586
|
console.log(node.id, node.value.filePath);
|
|
@@ -667,6 +680,7 @@ export async function run(input: string[]) {
|
|
|
667
680
|
assetNodeId,
|
|
668
681
|
)) {
|
|
669
682
|
if (
|
|
683
|
+
// @ts-expect-error TS7006
|
|
670
684
|
referencingBundles.some((ref) =>
|
|
671
685
|
bundleGraph._graph.hasEdge(
|
|
672
686
|
bundleGraph._graph.getNodeIdByContentKey(ref.id),
|
|
@@ -680,22 +694,33 @@ export async function run(input: string[]) {
|
|
|
680
694
|
}
|
|
681
695
|
}
|
|
682
696
|
|
|
683
|
-
function _getIncomingNodeOfType(
|
|
697
|
+
function _getIncomingNodeOfType(
|
|
698
|
+
// @ts-expect-error TS2304
|
|
699
|
+
bundleGraph: BundleGraph,
|
|
700
|
+
// @ts-expect-error TS7006
|
|
701
|
+
node,
|
|
702
|
+
type: string,
|
|
703
|
+
) {
|
|
684
704
|
if (!hasBundleGraph()) {
|
|
685
705
|
return;
|
|
686
706
|
}
|
|
687
707
|
invariant(bundleGraph != null);
|
|
688
708
|
const bundleGraphNodeId = bundleGraph._graph.getNodeIdByContentKey(node.id);
|
|
689
|
-
return
|
|
690
|
-
.
|
|
691
|
-
|
|
692
|
-
|
|
709
|
+
return (
|
|
710
|
+
bundleGraph._graph
|
|
711
|
+
.getNodeIdsConnectedTo(bundleGraphNodeId, -1)
|
|
712
|
+
// @ts-expect-error TS7006
|
|
713
|
+
.map((id) => nullthrows(bundleGraph._graph.getNode(id)))
|
|
714
|
+
// @ts-expect-error TS7006
|
|
715
|
+
.find((node) => node.type == type)
|
|
716
|
+
);
|
|
693
717
|
}
|
|
694
718
|
|
|
695
719
|
// We find the priority of a Bundle or BundleGroup by looking at its incoming dependencies.
|
|
696
720
|
// If a Bundle does not have an incoming dependency, we look for an incoming BundleGroup and its dependency
|
|
697
721
|
// e.g. Dep(priority = 1) -> BundleGroup -> Bundle means that the Bundle has priority 1.
|
|
698
|
-
|
|
722
|
+
// @ts-expect-error TS2304
|
|
723
|
+
function _getBundlePriority(bundleGraph: BundleGraph, bundle: BundleNode) {
|
|
699
724
|
if (!hasBundleGraph()) {
|
|
700
725
|
return;
|
|
701
726
|
}
|
|
@@ -715,7 +740,8 @@ export async function run(input: string[]) {
|
|
|
715
740
|
return node.value.priority;
|
|
716
741
|
}
|
|
717
742
|
|
|
718
|
-
|
|
743
|
+
// @ts-expect-error TS2304
|
|
744
|
+
function _findEntryBundle(bundleGraph: BundleGraph, node: BundleNode) {
|
|
719
745
|
if (!hasBundleGraph()) {
|
|
720
746
|
return;
|
|
721
747
|
}
|
|
@@ -723,8 +749,10 @@ export async function run(input: string[]) {
|
|
|
723
749
|
const bundleGraphNodeId = bundleGraph._graph.getNodeIdByContentKey(node.id);
|
|
724
750
|
const entryBundleGroup = bundleGraph._graph
|
|
725
751
|
.getNodeIdsConnectedTo(bundleGraphNodeId, -1)
|
|
752
|
+
// @ts-expect-error TS7006
|
|
726
753
|
.map((id) => nullthrows(bundleGraph._graph.getNode(id)))
|
|
727
754
|
.find(
|
|
755
|
+
// @ts-expect-error TS7006
|
|
728
756
|
(node) =>
|
|
729
757
|
node.type === 'bundle_group' &&
|
|
730
758
|
bundleGraph.isEntryBundleGroup(node.value),
|
|
@@ -733,7 +761,7 @@ export async function run(input: string[]) {
|
|
|
733
761
|
return entryBundleGroup;
|
|
734
762
|
}
|
|
735
763
|
// eslint-disable-next-line no-unused-vars
|
|
736
|
-
function inspectCache(_) {
|
|
764
|
+
function inspectCache(_: any) {
|
|
737
765
|
// displays sizing of various entries of the cache
|
|
738
766
|
let table: Array<Array<string | number>> = [];
|
|
739
767
|
table.push([
|
|
@@ -767,6 +795,7 @@ export async function run(input: string[]) {
|
|
|
767
795
|
column.shift();
|
|
768
796
|
invariant(column != null);
|
|
769
797
|
return column.reduce(
|
|
798
|
+
// @ts-expect-error TS2365
|
|
770
799
|
(accumulator, currentValue) => accumulator + currentValue,
|
|
771
800
|
initialValue,
|
|
772
801
|
);
|
|
@@ -780,13 +809,19 @@ export async function run(input: string[]) {
|
|
|
780
809
|
_printStatsTable('Cache Info', table);
|
|
781
810
|
}
|
|
782
811
|
|
|
783
|
-
function timeSerialize(
|
|
812
|
+
function timeSerialize(
|
|
813
|
+
// @ts-expect-error TS2304
|
|
814
|
+
graph: AssetGraph | null | undefined | BundleGraph | RequestTracker,
|
|
815
|
+
) {
|
|
784
816
|
let date = Date.now();
|
|
785
817
|
serialize(graph);
|
|
786
818
|
date = Date.now() - date;
|
|
787
819
|
return date;
|
|
788
820
|
}
|
|
789
|
-
function _printStatsTable(
|
|
821
|
+
function _printStatsTable(
|
|
822
|
+
header: string,
|
|
823
|
+
data: Array<Array<string | number>> | Array<[string, unknown]>,
|
|
824
|
+
) {
|
|
790
825
|
const config = {
|
|
791
826
|
columnDefault: {
|
|
792
827
|
width: 18,
|
|
@@ -795,13 +830,13 @@ export async function run(input: string[]) {
|
|
|
795
830
|
alignment: 'center',
|
|
796
831
|
content: header,
|
|
797
832
|
},
|
|
798
|
-
};
|
|
833
|
+
} as const;
|
|
799
834
|
|
|
800
835
|
console.log(table(data, config));
|
|
801
836
|
}
|
|
802
837
|
|
|
803
838
|
// eslint-disable-next-line no-unused-vars
|
|
804
|
-
function stats(_) {
|
|
839
|
+
function stats(_: any) {
|
|
805
840
|
let ag = {
|
|
806
841
|
asset: 0,
|
|
807
842
|
dependency: 0,
|
|
@@ -812,7 +847,7 @@ export async function run(input: string[]) {
|
|
|
812
847
|
invariant(assetGraph != null);
|
|
813
848
|
for (let n of assetGraph.nodes) {
|
|
814
849
|
if (n && n.type in ag) {
|
|
815
|
-
//
|
|
850
|
+
// @ts-expect-error TS7053
|
|
816
851
|
ag[n.type]++;
|
|
817
852
|
}
|
|
818
853
|
}
|
|
@@ -839,7 +874,7 @@ export async function run(input: string[]) {
|
|
|
839
874
|
sync: 0,
|
|
840
875
|
};
|
|
841
876
|
|
|
842
|
-
let b_ext = {};
|
|
877
|
+
let b_ext: Record<string, any> = {};
|
|
843
878
|
|
|
844
879
|
const entries = new Set();
|
|
845
880
|
|
|
@@ -849,10 +884,8 @@ export async function run(input: string[]) {
|
|
|
849
884
|
} else if (n?.type === 'bundle') {
|
|
850
885
|
bg.bundle++;
|
|
851
886
|
|
|
852
|
-
// $FlowFixMe
|
|
853
887
|
b_ext[n.value.type] = (b_ext[n.value.type] || 0) + 1;
|
|
854
888
|
|
|
855
|
-
// $FlowFixMe
|
|
856
889
|
const entry_group = _findEntryBundle(bundleGraph, n);
|
|
857
890
|
|
|
858
891
|
if (entry_group != null && !entries.has(entry_group.id)) {
|
|
@@ -874,7 +907,6 @@ export async function run(input: string[]) {
|
|
|
874
907
|
}
|
|
875
908
|
} else if (n?.type === 'asset') {
|
|
876
909
|
if (
|
|
877
|
-
// $FlowFixMe
|
|
878
910
|
fromProjectPathRelative(n.value.filePath).includes('node_modules')
|
|
879
911
|
) {
|
|
880
912
|
bg.asset_node_modules++;
|
|
@@ -899,6 +931,7 @@ export async function run(input: string[]) {
|
|
|
899
931
|
|
|
900
932
|
let sum_b_type = 0;
|
|
901
933
|
for (let k in b_type) {
|
|
934
|
+
// @ts-expect-error TS7053
|
|
902
935
|
sum_b_type += b_type[k];
|
|
903
936
|
}
|
|
904
937
|
|
|
@@ -929,19 +962,14 @@ export async function run(input: string[]) {
|
|
|
929
962
|
});
|
|
930
963
|
|
|
931
964
|
const server = repl.start({useColors: true, useGlobal: true});
|
|
932
|
-
// $FlowFixMe[prop-missing]
|
|
933
965
|
server.setupHistory(
|
|
934
966
|
path.join(os.homedir(), '.parcel_query_history'),
|
|
935
967
|
() => {},
|
|
936
968
|
);
|
|
937
969
|
|
|
938
|
-
// $FlowFixMe[prop-missing]
|
|
939
970
|
server.context.bundleGraph = bundleGraph;
|
|
940
|
-
// $FlowFixMe[prop-missing]
|
|
941
971
|
server.context.assetGraph = assetGraph;
|
|
942
|
-
// $FlowFixMe[prop-missing]
|
|
943
972
|
server.context.requestTracker = requestTracker;
|
|
944
|
-
// $FlowFixMe[prop-missing]
|
|
945
973
|
server.context.cacheInfo = cacheInfo;
|
|
946
974
|
for (let [name, cmd] of new Map([
|
|
947
975
|
[
|
|
@@ -1060,6 +1088,7 @@ export async function run(input: string[]) {
|
|
|
1060
1088
|
'findBundleReason',
|
|
1061
1089
|
{
|
|
1062
1090
|
help: 'args: <bundle> <asset>. Why is the asset in the bundle',
|
|
1091
|
+
// @ts-expect-error TS2556
|
|
1063
1092
|
action: (v) => findBundleReason(...v.split(' ')),
|
|
1064
1093
|
},
|
|
1065
1094
|
],
|
|
@@ -1106,16 +1135,11 @@ export async function run(input: string[]) {
|
|
|
1106
1135
|
},
|
|
1107
1136
|
],
|
|
1108
1137
|
])) {
|
|
1109
|
-
// $FlowFixMe
|
|
1110
1138
|
server.context[name] = cmd.action;
|
|
1111
|
-
// $FlowFixMe
|
|
1112
1139
|
server.defineCommand(name, {
|
|
1113
|
-
// $FlowFixMe
|
|
1114
1140
|
help: '📦 ' + cmd.help,
|
|
1115
1141
|
action: (v) => {
|
|
1116
|
-
// $FlowFixMe
|
|
1117
1142
|
server.clearBufferedCommand();
|
|
1118
|
-
// $FlowFixMe
|
|
1119
1143
|
try {
|
|
1120
1144
|
cmd.action(v);
|
|
1121
1145
|
} finally {
|
|
@@ -1,34 +1,28 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
/* eslint-disable monorepo/no-internal-import */
|
|
3
|
-
import
|
|
4
|
-
import
|
|
2
|
+
import AssetGraph from '@atlaspack/core/src/AssetGraph';
|
|
3
|
+
import BundleGraph, {
|
|
5
4
|
bundleGraphEdgeTypes,
|
|
6
5
|
} from '@atlaspack/core/src/BundleGraph';
|
|
7
|
-
import
|
|
6
|
+
import RequestTracker, {
|
|
8
7
|
RequestGraph,
|
|
9
8
|
readAndDeserializeRequestGraph,
|
|
10
9
|
} from '@atlaspack/core/src/RequestTracker';
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
10
|
+
import {requestGraphEdgeTypes} from '@atlaspack/core/src/RequestTracker';
|
|
11
|
+
import {LMDBLiteCache} from '@atlaspack/cache/src/LMDBLiteCache';
|
|
12
|
+
import {Priority} from '@atlaspack/core/src/types';
|
|
13
|
+
import {fromProjectPathRelative} from '@atlaspack/core/src/projectPath';
|
|
15
14
|
|
|
16
15
|
const v =
|
|
17
|
-
process.env.ATLASPACK_BUILD_ENV === 'production'
|
|
16
|
+
process.env.ATLASPACK_BUILD_ENV === 'production' ||
|
|
17
|
+
process.env.ATLASPACK_REGISTER_USE_SRC !== 'true'
|
|
18
18
|
? {
|
|
19
19
|
// Split up require specifier to outsmart packages/dev/babel-register/babel-plugin-module-translate.js
|
|
20
|
-
// $FlowFixMe(unsupported-syntax)
|
|
21
20
|
AssetGraph: require('@atlaspack/core' + '/lib/AssetGraph').default,
|
|
22
|
-
// $FlowFixMe(unsupported-syntax)
|
|
23
21
|
BundleGraph: require('@atlaspack/core' + '/lib/BundleGraph'),
|
|
24
|
-
// $FlowFixMe(unsupported-syntax)
|
|
25
22
|
RequestTracker: require('@atlaspack/core' + '/lib/RequestTracker'),
|
|
26
|
-
// $FlowFixMe(unsupported-syntax)
|
|
27
23
|
LMDBLiteCache: require('@atlaspack/cache' + '/lib/LMDBLiteCache')
|
|
28
24
|
.LMDBLiteCache,
|
|
29
|
-
// $FlowFixMe(unsupported-syntax)
|
|
30
25
|
Priority: require('@atlaspack/core' + '/lib/types').Priority,
|
|
31
|
-
// $FlowFixMe(unsupported-syntax)
|
|
32
26
|
fromProjectPathRelative: require('@atlaspack/core' + '/lib/projectPath')
|
|
33
27
|
.fromProjectPathRelative,
|
|
34
28
|
}
|
|
@@ -43,21 +37,24 @@ const v =
|
|
|
43
37
|
.fromProjectPathRelative,
|
|
44
38
|
};
|
|
45
39
|
|
|
46
|
-
module.exports =
|
|
47
|
-
AssetGraph: AssetGraph
|
|
40
|
+
module.exports = v as {
|
|
41
|
+
AssetGraph: AssetGraph;
|
|
48
42
|
BundleGraph: {
|
|
49
|
-
default: BundleGraph
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
43
|
+
default: BundleGraph;
|
|
44
|
+
// @ts-expect-error TS2749
|
|
45
|
+
bundleGraphEdgeTypes: bundleGraphEdgeTypes;
|
|
46
|
+
};
|
|
53
47
|
RequestTracker: {
|
|
54
|
-
default: RequestTracker
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
48
|
+
default: RequestTracker;
|
|
49
|
+
// @ts-expect-error TS2749
|
|
50
|
+
readAndDeserializeRequestGraph: readAndDeserializeRequestGraph;
|
|
51
|
+
RequestGraph: RequestGraph;
|
|
52
|
+
// @ts-expect-error TS2749
|
|
53
|
+
requestGraphEdgeTypes: requestGraphEdgeTypes;
|
|
54
|
+
};
|
|
55
|
+
LMDBLiteCache: LMDBLiteCache;
|
|
56
|
+
// @ts-expect-error TS2749
|
|
57
|
+
Priority: Priority;
|
|
58
|
+
// @ts-expect-error TS2749
|
|
59
|
+
fromProjectPathRelative: fromProjectPathRelative;
|
|
60
|
+
};
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
// @flow strict-local
|
|
2
1
|
/* eslint-disable no-console, monorepo/no-internal-import */
|
|
3
2
|
import type {ContentKey, NodeId} from '@atlaspack/graph';
|
|
4
3
|
import type {PackagedBundleInfo} from '@atlaspack/core/src/types';
|
|
5
4
|
|
|
6
|
-
import fs from 'fs';
|
|
7
|
-
import path from 'path';
|
|
8
5
|
import v8 from 'v8';
|
|
9
6
|
import nullthrows from 'nullthrows';
|
|
10
7
|
import invariant from 'assert';
|
|
@@ -18,98 +15,86 @@ const {
|
|
|
18
15
|
requestGraphEdgeTypes,
|
|
19
16
|
},
|
|
20
17
|
LMDBLiteCache,
|
|
21
|
-
} =
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
name: 'bundleGraphBlob',
|
|
48
|
-
check: (basename) => basename.endsWith('BundleGraph-0'),
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
name: 'assetGraphBlob',
|
|
52
|
-
check: (basename) => basename.endsWith('AssetGraph-0'),
|
|
53
|
-
},
|
|
54
|
-
];
|
|
55
|
-
|
|
56
|
-
for (let file of files) {
|
|
57
|
-
let basename = path.basename(file);
|
|
58
|
-
let match = blobsToFind.find(({check}) => check(basename));
|
|
59
|
-
|
|
60
|
-
if (match) {
|
|
61
|
-
let stat = fs.statSync(path.join(cacheDir, file));
|
|
62
|
-
|
|
63
|
-
if (!match.mtime || stat.mtime > match.mtime) {
|
|
64
|
-
match.mtime = stat.mtime;
|
|
65
|
-
result[match.name] = file;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
18
|
+
} = process.env.ATLASPACK_REGISTER_USE_SRC === 'true'
|
|
19
|
+
? require('./deep-imports.js')
|
|
20
|
+
: require('./deep-imports.ts');
|
|
21
|
+
|
|
22
|
+
export async function loadGraphs(cacheDir: string): Promise<{
|
|
23
|
+
// @ts-expect-error TS2749
|
|
24
|
+
assetGraph: AssetGraph | null | undefined;
|
|
25
|
+
// @ts-expect-error TS2749
|
|
26
|
+
bundleGraph: BundleGraph | null | undefined;
|
|
27
|
+
// @ts-expect-error TS2749
|
|
28
|
+
requestTracker: RequestTracker | null | undefined;
|
|
29
|
+
bundleInfo: Map<ContentKey, PackagedBundleInfo> | null | undefined;
|
|
30
|
+
cacheInfo: Map<string, Array<string | number>> | null | undefined;
|
|
31
|
+
}> {
|
|
32
|
+
let cacheInfo: Map<string, Array<string | number>> = new Map();
|
|
33
|
+
const cache = new LMDBLiteCache(cacheDir);
|
|
34
|
+
|
|
35
|
+
let requestGraphBlob;
|
|
36
|
+
let requestGraphKey;
|
|
37
|
+
let bundleGraphBlob;
|
|
38
|
+
let assetGraphBlob;
|
|
39
|
+
for (let key of cache.keys()) {
|
|
40
|
+
if (key.startsWith('Asset/')) {
|
|
41
|
+
continue;
|
|
42
|
+
} else if (key.startsWith('PackagerRunner/')) {
|
|
43
|
+
continue;
|
|
68
44
|
}
|
|
69
45
|
|
|
70
|
-
|
|
46
|
+
if (key.startsWith('RequestTracker/') && key.endsWith('/RequestGraph')) {
|
|
47
|
+
requestGraphBlob = key;
|
|
48
|
+
requestGraphKey = key.split('/').slice(0, -1).join('/');
|
|
49
|
+
}
|
|
50
|
+
if (key.startsWith('BundleGraph/')) {
|
|
51
|
+
bundleGraphBlob = key;
|
|
52
|
+
}
|
|
53
|
+
if (key.startsWith('AssetGraph/')) {
|
|
54
|
+
assetGraphBlob = key;
|
|
55
|
+
}
|
|
71
56
|
}
|
|
72
57
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
let {requestGraphBlob, bundleGraphBlob, assetGraphBlob} =
|
|
76
|
-
getMostRecentCacheBlobs();
|
|
77
|
-
const cache = new LMDBLiteCache(cacheDir);
|
|
58
|
+
console.log({requestGraphBlob, bundleGraphBlob, assetGraphBlob});
|
|
78
59
|
|
|
79
60
|
// Get requestTracker
|
|
61
|
+
// @ts-expect-error TS7034
|
|
80
62
|
let requestTracker;
|
|
81
|
-
if (requestGraphBlob) {
|
|
63
|
+
if (requestGraphBlob != null && requestGraphKey != null) {
|
|
82
64
|
try {
|
|
83
|
-
let requestGraphKey = requestGraphBlob.slice(0, -'-0'.length);
|
|
84
65
|
let date = Date.now();
|
|
66
|
+
|
|
67
|
+
const buffer = await cache.getBlob(requestGraphBlob);
|
|
68
|
+
const deserializer = new v8.Deserializer(buffer);
|
|
69
|
+
console.log(
|
|
70
|
+
'Wire format version stored',
|
|
71
|
+
deserializer.getWireFormatVersion(),
|
|
72
|
+
);
|
|
73
|
+
|
|
85
74
|
let {requestGraph, bufferLength} = await readAndDeserializeRequestGraph(
|
|
86
75
|
cache,
|
|
76
|
+
requestGraphBlob,
|
|
87
77
|
requestGraphKey,
|
|
88
|
-
requestGraphKey.replace('requestGraph-', ''),
|
|
89
78
|
);
|
|
90
79
|
|
|
91
80
|
requestTracker = new RequestTracker({
|
|
92
81
|
graph: requestGraph,
|
|
93
|
-
// $FlowFixMe
|
|
94
82
|
farm: null,
|
|
95
|
-
// $FlowFixMe
|
|
96
83
|
options: null,
|
|
97
84
|
});
|
|
98
85
|
let timeToDeserialize = Date.now() - date;
|
|
99
86
|
cacheInfo.set('RequestGraph', [bufferLength]);
|
|
100
87
|
cacheInfo.get('RequestGraph')?.push(timeToDeserialize);
|
|
101
|
-
} catch (e) {
|
|
102
|
-
console.
|
|
88
|
+
} catch (e: any) {
|
|
89
|
+
console.error('Error loading Request Graph\n', e);
|
|
103
90
|
}
|
|
104
91
|
}
|
|
105
92
|
|
|
106
93
|
// Get bundleGraph
|
|
107
94
|
let bundleGraph;
|
|
108
|
-
if (bundleGraphBlob) {
|
|
95
|
+
if (bundleGraphBlob != null) {
|
|
109
96
|
try {
|
|
110
|
-
let file = await cache.
|
|
111
|
-
path.basename(bundleGraphBlob).slice(0, -'-0'.length),
|
|
112
|
-
);
|
|
97
|
+
let file = await cache.getBlob(bundleGraphBlob);
|
|
113
98
|
|
|
114
99
|
let timeToDeserialize = Date.now();
|
|
115
100
|
let obj = v8.deserialize(file);
|
|
@@ -119,19 +104,17 @@ export async function loadGraphs(cacheDir: string): Promise<{|
|
|
|
119
104
|
|
|
120
105
|
cacheInfo.set('BundleGraph', [Buffer.byteLength(file)]);
|
|
121
106
|
cacheInfo.get('BundleGraph')?.push(timeToDeserialize);
|
|
122
|
-
} catch (e) {
|
|
123
|
-
console.
|
|
107
|
+
} catch (e: any) {
|
|
108
|
+
console.error('Error loading Bundle Graph\n', e);
|
|
124
109
|
}
|
|
125
110
|
}
|
|
126
111
|
|
|
127
112
|
// Get assetGraph
|
|
128
113
|
let assetGraph;
|
|
129
|
-
if (assetGraphBlob) {
|
|
114
|
+
if (assetGraphBlob != null) {
|
|
130
115
|
try {
|
|
131
116
|
// TODO: this should be reviewed when `cachePerformanceImprovements` flag is removed, as we'll be writing files to LMDB cache instead of large blobs
|
|
132
|
-
let file = await cache.
|
|
133
|
-
path.basename(assetGraphBlob).slice(0, -'-0'.length),
|
|
134
|
-
);
|
|
117
|
+
let file = await cache.getBlob(assetGraphBlob);
|
|
135
118
|
|
|
136
119
|
let timeToDeserialize = Date.now();
|
|
137
120
|
let obj = v8.deserialize(file);
|
|
@@ -141,15 +124,19 @@ export async function loadGraphs(cacheDir: string): Promise<{|
|
|
|
141
124
|
|
|
142
125
|
cacheInfo.set('AssetGraph', [Buffer.byteLength(file)]);
|
|
143
126
|
cacheInfo.get('AssetGraph')?.push(timeToDeserialize);
|
|
144
|
-
} catch (e) {
|
|
145
|
-
console.
|
|
127
|
+
} catch (e: any) {
|
|
128
|
+
console.error('Error loading Asset Graph\n', e);
|
|
146
129
|
}
|
|
147
130
|
}
|
|
148
131
|
|
|
149
132
|
function getSubRequests(id: NodeId) {
|
|
150
|
-
return
|
|
151
|
-
|
|
152
|
-
|
|
133
|
+
return (
|
|
134
|
+
// @ts-expect-error TS7005
|
|
135
|
+
requestTracker.graph
|
|
136
|
+
.getNodeIdsConnectedFrom(id, requestGraphEdgeTypes.subrequest)
|
|
137
|
+
// @ts-expect-error TS7006
|
|
138
|
+
.map((n) => nullthrows(requestTracker.graph.getNode(n)))
|
|
139
|
+
);
|
|
153
140
|
}
|
|
154
141
|
|
|
155
142
|
// Load graphs by finding the main subrequests and loading their results
|
|
@@ -168,18 +155,18 @@ export async function loadGraphs(cacheDir: string): Promise<{|
|
|
|
168
155
|
let buildRequestSubRequests = getSubRequests(buildRequestId);
|
|
169
156
|
|
|
170
157
|
let writeBundlesRequest = buildRequestSubRequests.find(
|
|
158
|
+
// @ts-expect-error TS7006
|
|
171
159
|
(n) => n.type === 1 && n.requestType === 11,
|
|
172
160
|
);
|
|
173
161
|
if (writeBundlesRequest != null) {
|
|
174
162
|
invariant(writeBundlesRequest.type === 1);
|
|
175
|
-
|
|
176
|
-
bundleInfo = (nullthrows(writeBundlesRequest.result): Map<
|
|
163
|
+
bundleInfo = nullthrows(writeBundlesRequest.result) as Map<
|
|
177
164
|
ContentKey,
|
|
178
|
-
PackagedBundleInfo
|
|
179
|
-
|
|
165
|
+
PackagedBundleInfo
|
|
166
|
+
>;
|
|
180
167
|
}
|
|
181
|
-
} catch (e) {
|
|
182
|
-
console.
|
|
168
|
+
} catch (e: any) {
|
|
169
|
+
console.error('Error loading bundleInfo\n', e);
|
|
183
170
|
}
|
|
184
171
|
|
|
185
172
|
return {assetGraph, bundleGraph, requestTracker, bundleInfo, cacheInfo};
|
package/tsconfig.json
ADDED