@atlaspack/core 2.12.1-canary.3452 → 2.12.1-canary.3454
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/lib/SymbolPropagation.js +25 -36
- package/lib/projectPath.js +12 -4
- package/package.json +16 -16
- package/src/SymbolPropagation.js +32 -48
- package/src/projectPath.js +12 -4
- package/test/requests/ConfigRequest.test.js +1 -4
package/lib/SymbolPropagation.js
CHANGED
|
@@ -438,15 +438,7 @@ function propagateSymbolsDown(assetGraph, changedAssets, assetGroupsWithRemovedP
|
|
|
438
438
|
wasNodeDirty = node.usedSymbolsDownDirty;
|
|
439
439
|
node.usedSymbolsDownDirty = false;
|
|
440
440
|
} else if (node.type === 'asset' && node.usedSymbolsDownDirty) {
|
|
441
|
-
visit(node, assetGraph
|
|
442
|
-
let dep = assetGraph.getNodeByContentKey(d.id);
|
|
443
|
-
(0, _assert().default)(dep && dep.type === 'dependency');
|
|
444
|
-
return dep;
|
|
445
|
-
}), outgoing.map(dep => {
|
|
446
|
-
let depNode = (0, _nullthrows().default)(assetGraph.getNode(dep));
|
|
447
|
-
(0, _assert().default)(depNode.type === 'dependency');
|
|
448
|
-
return depNode;
|
|
449
|
-
}));
|
|
441
|
+
visit(node, incomingDependencyNodesFromAsset(assetGraph, node.value), dependencyNodesFromIds(assetGraph, outgoing));
|
|
450
442
|
node.usedSymbolsDownDirty = false;
|
|
451
443
|
}
|
|
452
444
|
for (let child of outgoing) {
|
|
@@ -494,23 +486,15 @@ function propagateSymbolsUp(assetGraph, changedAssets, changedDepsUsedSymbolsUpD
|
|
|
494
486
|
let rootNodeId = (0, _nullthrows().default)(assetGraph.rootNodeId, 'A root node is required to traverse');
|
|
495
487
|
const nodeVisitor = nodeId => {
|
|
496
488
|
let node = (0, _nullthrows().default)(assetGraph.getNode(nodeId));
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
let child
|
|
500
|
-
if (node.type === 'asset') {
|
|
501
|
-
(0, _assert().default)(child.type === 'dependency');
|
|
489
|
+
if (node.type === 'asset') {
|
|
490
|
+
let outgoing = outgoingDependencyNodesFromAsset(assetGraph, nodeId);
|
|
491
|
+
for (let child of outgoing) {
|
|
502
492
|
if (child.usedSymbolsUpDirtyUp) {
|
|
503
493
|
node.usedSymbolsUpDirty = true;
|
|
504
494
|
child.usedSymbolsUpDirtyUp = false;
|
|
505
495
|
}
|
|
506
496
|
}
|
|
507
|
-
|
|
508
|
-
if (node.type === 'asset') {
|
|
509
|
-
let incoming = assetGraph.getIncomingDependencies(node.value).map(d => {
|
|
510
|
-
let n = assetGraph.getNodeByContentKey(d.id);
|
|
511
|
-
(0, _assert().default)(n && n.type === 'dependency');
|
|
512
|
-
return n;
|
|
513
|
-
});
|
|
497
|
+
let incoming = incomingDependencyNodesFromAsset(assetGraph, node.value);
|
|
514
498
|
for (let dep of incoming) {
|
|
515
499
|
if (dep.usedSymbolsUpDirtyDown) {
|
|
516
500
|
dep.usedSymbolsUpDirtyDown = false;
|
|
@@ -518,11 +502,7 @@ function propagateSymbolsUp(assetGraph, changedAssets, changedDepsUsedSymbolsUpD
|
|
|
518
502
|
}
|
|
519
503
|
}
|
|
520
504
|
if (node.usedSymbolsUpDirty) {
|
|
521
|
-
let e = visit(node, incoming, outgoing
|
|
522
|
-
let depNode = (0, _nullthrows().default)(assetGraph.getNode(depNodeId));
|
|
523
|
-
(0, _assert().default)(depNode.type === 'dependency');
|
|
524
|
-
return depNode;
|
|
525
|
-
}));
|
|
505
|
+
let e = visit(node, incoming, outgoing);
|
|
526
506
|
if (e.length > 0) {
|
|
527
507
|
node.usedSymbolsUpDirty = true;
|
|
528
508
|
errors.set(nodeId, e);
|
|
@@ -548,22 +528,14 @@ function propagateSymbolsUp(assetGraph, changedAssets, changedDepsUsedSymbolsUpD
|
|
|
548
528
|
let queuedNodeId = setPop(queue);
|
|
549
529
|
let node = (0, _nullthrows().default)(assetGraph.getNode(queuedNodeId));
|
|
550
530
|
if (node.type === 'asset') {
|
|
551
|
-
let incoming = assetGraph
|
|
552
|
-
let depNode = assetGraph.getNodeByContentKey(dep.id);
|
|
553
|
-
(0, _assert().default)(depNode && depNode.type === 'dependency');
|
|
554
|
-
return depNode;
|
|
555
|
-
});
|
|
531
|
+
let incoming = incomingDependencyNodesFromAsset(assetGraph, node.value);
|
|
556
532
|
for (let dep of incoming) {
|
|
557
533
|
if (dep.usedSymbolsUpDirtyDown) {
|
|
558
534
|
dep.usedSymbolsUpDirtyDown = false;
|
|
559
535
|
node.usedSymbolsUpDirty = true;
|
|
560
536
|
}
|
|
561
537
|
}
|
|
562
|
-
let outgoing = assetGraph
|
|
563
|
-
let depNode = (0, _nullthrows().default)(assetGraph.getNode(depNodeId));
|
|
564
|
-
(0, _assert().default)(depNode.type === 'dependency');
|
|
565
|
-
return depNode;
|
|
566
|
-
});
|
|
538
|
+
let outgoing = outgoingDependencyNodesFromAsset(assetGraph, queuedNodeId);
|
|
567
539
|
for (let dep of outgoing) {
|
|
568
540
|
if (dep.usedSymbolsUpDirtyUp) {
|
|
569
541
|
node.usedSymbolsUpDirty = true;
|
|
@@ -622,4 +594,21 @@ function setPop(set) {
|
|
|
622
594
|
let v = (0, _nullthrows().default)(set.values().next().value);
|
|
623
595
|
set.delete(v);
|
|
624
596
|
return v;
|
|
597
|
+
}
|
|
598
|
+
function outgoingDependencyNodesFromAsset(assetGraph, assetNode) {
|
|
599
|
+
return dependencyNodesFromIds(assetGraph, assetGraph.getNodeIdsConnectedFrom(assetNode));
|
|
600
|
+
}
|
|
601
|
+
function dependencyNodesFromIds(assetGraph, dependencyIds) {
|
|
602
|
+
return dependencyIds.map(depNodeId => {
|
|
603
|
+
let depNode = (0, _nullthrows().default)(assetGraph.getNode(depNodeId));
|
|
604
|
+
(0, _assert().default)(depNode.type === 'dependency');
|
|
605
|
+
return depNode;
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
function incomingDependencyNodesFromAsset(assetGraph, assetNodeValue) {
|
|
609
|
+
return assetGraph.getIncomingDependencies(assetNodeValue).map(d => {
|
|
610
|
+
let n = assetGraph.getNodeByContentKey(d.id);
|
|
611
|
+
(0, _assert().default)(n && n.type === 'dependency');
|
|
612
|
+
return n;
|
|
613
|
+
});
|
|
625
614
|
}
|
package/lib/projectPath.js
CHANGED
|
@@ -27,14 +27,22 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
27
27
|
* A path that's relative to the project root.
|
|
28
28
|
*/
|
|
29
29
|
function toProjectPath_(projectRoot, p) {
|
|
30
|
+
// If the file path is not provided, then treat it as though it is already from the project root
|
|
30
31
|
if (p == null) {
|
|
31
32
|
return p;
|
|
32
33
|
}
|
|
33
34
|
|
|
34
|
-
// If the file is
|
|
35
|
-
//
|
|
36
|
-
//
|
|
37
|
-
//
|
|
35
|
+
// If the file path is already relative and it does not begin with . then treat the path as if it
|
|
36
|
+
// is already from the project root. This prevents relative paths from being processed twice,
|
|
37
|
+
// most often within `toInternalSourceLocation` when handling loc types from symbols and asset
|
|
38
|
+
// dependencies.
|
|
39
|
+
if (p[0] !== '.' && !_path().default.isAbsolute(p)) {
|
|
40
|
+
return p;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// If the file is outside the project root, store an absolute path rather than a relative one.
|
|
44
|
+
// This way if the project root is moved, the file references still work. Accessing files outside
|
|
45
|
+
// the project root is not portable anyway.
|
|
38
46
|
let relative = (0, _utils().relativePath)(projectRoot, p, false);
|
|
39
47
|
if (relative.startsWith('..')) {
|
|
40
48
|
return process.platform === 'win32' ? (0, _utils().normalizeSeparators)(p) : p;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/core",
|
|
3
|
-
"version": "2.12.1-canary.
|
|
3
|
+
"version": "2.12.1-canary.3454+731e572aa",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -20,20 +20,20 @@
|
|
|
20
20
|
"check-ts": "tsc --noEmit index.d.ts"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@atlaspack/cache": "2.12.1-canary.
|
|
24
|
-
"@atlaspack/diagnostic": "2.12.1-canary.
|
|
25
|
-
"@atlaspack/events": "2.12.1-canary.
|
|
26
|
-
"@atlaspack/feature-flags": "2.12.1-canary.
|
|
27
|
-
"@atlaspack/fs": "2.12.1-canary.
|
|
28
|
-
"@atlaspack/graph": "3.2.1-canary.
|
|
29
|
-
"@atlaspack/logger": "2.12.1-canary.
|
|
30
|
-
"@atlaspack/package-manager": "2.12.1-canary.
|
|
31
|
-
"@atlaspack/plugin": "2.12.1-canary.
|
|
32
|
-
"@atlaspack/profiler": "2.12.1-canary.
|
|
33
|
-
"@atlaspack/rust": "2.12.1-canary.
|
|
34
|
-
"@atlaspack/types": "2.12.1-canary.
|
|
35
|
-
"@atlaspack/utils": "2.12.1-canary.
|
|
36
|
-
"@atlaspack/workers": "2.12.1-canary.
|
|
23
|
+
"@atlaspack/cache": "2.12.1-canary.3454+731e572aa",
|
|
24
|
+
"@atlaspack/diagnostic": "2.12.1-canary.3454+731e572aa",
|
|
25
|
+
"@atlaspack/events": "2.12.1-canary.3454+731e572aa",
|
|
26
|
+
"@atlaspack/feature-flags": "2.12.1-canary.3454+731e572aa",
|
|
27
|
+
"@atlaspack/fs": "2.12.1-canary.3454+731e572aa",
|
|
28
|
+
"@atlaspack/graph": "3.2.1-canary.3454+731e572aa",
|
|
29
|
+
"@atlaspack/logger": "2.12.1-canary.3454+731e572aa",
|
|
30
|
+
"@atlaspack/package-manager": "2.12.1-canary.3454+731e572aa",
|
|
31
|
+
"@atlaspack/plugin": "2.12.1-canary.3454+731e572aa",
|
|
32
|
+
"@atlaspack/profiler": "2.12.1-canary.3454+731e572aa",
|
|
33
|
+
"@atlaspack/rust": "2.12.1-canary.3454+731e572aa",
|
|
34
|
+
"@atlaspack/types": "2.12.1-canary.3454+731e572aa",
|
|
35
|
+
"@atlaspack/utils": "2.12.1-canary.3454+731e572aa",
|
|
36
|
+
"@atlaspack/workers": "2.12.1-canary.3454+731e572aa",
|
|
37
37
|
"@mischnic/json-sourcemap": "^0.1.0",
|
|
38
38
|
"@parcel/source-map": "^2.1.1",
|
|
39
39
|
"base-x": "^3.0.8",
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"browser": {
|
|
58
58
|
"./src/serializerCore.js": "./src/serializerCore.browser.js"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "731e572aae21fde994cedbf6485fbfbc1d497078"
|
|
61
61
|
}
|
package/src/SymbolPropagation.js
CHANGED
|
@@ -558,16 +558,8 @@ function propagateSymbolsDown(
|
|
|
558
558
|
} else if (node.type === 'asset' && node.usedSymbolsDownDirty) {
|
|
559
559
|
visit(
|
|
560
560
|
node,
|
|
561
|
-
assetGraph
|
|
562
|
-
|
|
563
|
-
invariant(dep && dep.type === 'dependency');
|
|
564
|
-
return dep;
|
|
565
|
-
}),
|
|
566
|
-
outgoing.map((dep) => {
|
|
567
|
-
let depNode = nullthrows(assetGraph.getNode(dep));
|
|
568
|
-
invariant(depNode.type === 'dependency');
|
|
569
|
-
return depNode;
|
|
570
|
-
}),
|
|
561
|
+
incomingDependencyNodesFromAsset(assetGraph, node.value),
|
|
562
|
+
dependencyNodesFromIds(assetGraph, outgoing),
|
|
571
563
|
);
|
|
572
564
|
node.usedSymbolsDownDirty = false;
|
|
573
565
|
}
|
|
@@ -645,27 +637,16 @@ function propagateSymbolsUp(
|
|
|
645
637
|
|
|
646
638
|
const nodeVisitor = (nodeId) => {
|
|
647
639
|
let node = nullthrows(assetGraph.getNode(nodeId));
|
|
648
|
-
let outgoing = assetGraph.getNodeIdsConnectedFrom(nodeId);
|
|
649
640
|
|
|
650
|
-
|
|
651
|
-
let
|
|
652
|
-
|
|
653
|
-
invariant(child.type === 'dependency');
|
|
641
|
+
if (node.type === 'asset') {
|
|
642
|
+
let outgoing = outgoingDependencyNodesFromAsset(assetGraph, nodeId);
|
|
643
|
+
for (let child of outgoing) {
|
|
654
644
|
if (child.usedSymbolsUpDirtyUp) {
|
|
655
645
|
node.usedSymbolsUpDirty = true;
|
|
656
646
|
child.usedSymbolsUpDirtyUp = false;
|
|
657
647
|
}
|
|
658
648
|
}
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
if (node.type === 'asset') {
|
|
662
|
-
let incoming = assetGraph
|
|
663
|
-
.getIncomingDependencies(node.value)
|
|
664
|
-
.map((d) => {
|
|
665
|
-
let n = assetGraph.getNodeByContentKey(d.id);
|
|
666
|
-
invariant(n && n.type === 'dependency');
|
|
667
|
-
return n;
|
|
668
|
-
});
|
|
649
|
+
let incoming = incomingDependencyNodesFromAsset(assetGraph, node.value);
|
|
669
650
|
for (let dep of incoming) {
|
|
670
651
|
if (dep.usedSymbolsUpDirtyDown) {
|
|
671
652
|
dep.usedSymbolsUpDirtyDown = false;
|
|
@@ -673,15 +654,7 @@ function propagateSymbolsUp(
|
|
|
673
654
|
}
|
|
674
655
|
}
|
|
675
656
|
if (node.usedSymbolsUpDirty) {
|
|
676
|
-
let e = visit(
|
|
677
|
-
node,
|
|
678
|
-
incoming,
|
|
679
|
-
outgoing.map((depNodeId) => {
|
|
680
|
-
let depNode = nullthrows(assetGraph.getNode(depNodeId));
|
|
681
|
-
invariant(depNode.type === 'dependency');
|
|
682
|
-
return depNode;
|
|
683
|
-
}),
|
|
684
|
-
);
|
|
657
|
+
let e = visit(node, incoming, outgoing);
|
|
685
658
|
if (e.length > 0) {
|
|
686
659
|
node.usedSymbolsUpDirty = true;
|
|
687
660
|
errors.set(nodeId, e);
|
|
@@ -708,26 +681,14 @@ function propagateSymbolsUp(
|
|
|
708
681
|
let queuedNodeId = setPop(queue);
|
|
709
682
|
let node = nullthrows(assetGraph.getNode(queuedNodeId));
|
|
710
683
|
if (node.type === 'asset') {
|
|
711
|
-
let incoming = assetGraph
|
|
712
|
-
.getIncomingDependencies(node.value)
|
|
713
|
-
.map((dep) => {
|
|
714
|
-
let depNode = assetGraph.getNodeByContentKey(dep.id);
|
|
715
|
-
invariant(depNode && depNode.type === 'dependency');
|
|
716
|
-
return depNode;
|
|
717
|
-
});
|
|
684
|
+
let incoming = incomingDependencyNodesFromAsset(assetGraph, node.value);
|
|
718
685
|
for (let dep of incoming) {
|
|
719
686
|
if (dep.usedSymbolsUpDirtyDown) {
|
|
720
687
|
dep.usedSymbolsUpDirtyDown = false;
|
|
721
688
|
node.usedSymbolsUpDirty = true;
|
|
722
689
|
}
|
|
723
690
|
}
|
|
724
|
-
let outgoing = assetGraph
|
|
725
|
-
.getNodeIdsConnectedFrom(queuedNodeId)
|
|
726
|
-
.map((depNodeId) => {
|
|
727
|
-
let depNode = nullthrows(assetGraph.getNode(depNodeId));
|
|
728
|
-
invariant(depNode.type === 'dependency');
|
|
729
|
-
return depNode;
|
|
730
|
-
});
|
|
691
|
+
let outgoing = outgoingDependencyNodesFromAsset(assetGraph, queuedNodeId);
|
|
731
692
|
for (let dep of outgoing) {
|
|
732
693
|
if (dep.usedSymbolsUpDirtyUp) {
|
|
733
694
|
node.usedSymbolsUpDirty = true;
|
|
@@ -799,3 +760,26 @@ function setPop<T>(set: Set<T>): T {
|
|
|
799
760
|
set.delete(v);
|
|
800
761
|
return v;
|
|
801
762
|
}
|
|
763
|
+
|
|
764
|
+
function outgoingDependencyNodesFromAsset(assetGraph, assetNode) {
|
|
765
|
+
return dependencyNodesFromIds(
|
|
766
|
+
assetGraph,
|
|
767
|
+
assetGraph.getNodeIdsConnectedFrom(assetNode),
|
|
768
|
+
);
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
function dependencyNodesFromIds(assetGraph, dependencyIds) {
|
|
772
|
+
return dependencyIds.map((depNodeId) => {
|
|
773
|
+
let depNode = nullthrows(assetGraph.getNode(depNodeId));
|
|
774
|
+
invariant(depNode.type === 'dependency');
|
|
775
|
+
return depNode;
|
|
776
|
+
});
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
function incomingDependencyNodesFromAsset(assetGraph, assetNodeValue) {
|
|
780
|
+
return assetGraph.getIncomingDependencies(assetNodeValue).map((d) => {
|
|
781
|
+
let n = assetGraph.getNodeByContentKey(d.id);
|
|
782
|
+
invariant(n && n.type === 'dependency');
|
|
783
|
+
return n;
|
|
784
|
+
});
|
|
785
|
+
}
|
package/src/projectPath.js
CHANGED
|
@@ -9,14 +9,22 @@ import {relativePath, normalizeSeparators} from '@atlaspack/utils';
|
|
|
9
9
|
export opaque type ProjectPath = string;
|
|
10
10
|
|
|
11
11
|
function toProjectPath_(projectRoot: FilePath, p: FilePath): ProjectPath {
|
|
12
|
+
// If the file path is not provided, then treat it as though it is already from the project root
|
|
12
13
|
if (p == null) {
|
|
13
14
|
return p;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
// If the file is
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
//
|
|
17
|
+
// If the file path is already relative and it does not begin with . then treat the path as if it
|
|
18
|
+
// is already from the project root. This prevents relative paths from being processed twice,
|
|
19
|
+
// most often within `toInternalSourceLocation` when handling loc types from symbols and asset
|
|
20
|
+
// dependencies.
|
|
21
|
+
if (p[0] !== '.' && !path.isAbsolute(p)) {
|
|
22
|
+
return p;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// If the file is outside the project root, store an absolute path rather than a relative one.
|
|
26
|
+
// This way if the project root is moved, the file references still work. Accessing files outside
|
|
27
|
+
// the project root is not portable anyway.
|
|
20
28
|
let relative = relativePath(projectRoot, p, false);
|
|
21
29
|
if (relative.startsWith('..')) {
|
|
22
30
|
return process.platform === 'win32' ? normalizeSeparators(p) : p;
|
|
@@ -229,10 +229,7 @@ describe('ConfigRequest tests', () => {
|
|
|
229
229
|
invalidateOnConfigKeyChange: [
|
|
230
230
|
{
|
|
231
231
|
configKey: 'key1',
|
|
232
|
-
filePath: toProjectPath(
|
|
233
|
-
projectRoot,
|
|
234
|
-
path.join('project_root', 'config.json'),
|
|
235
|
-
),
|
|
232
|
+
filePath: toProjectPath(projectRoot, 'config.json'),
|
|
236
233
|
},
|
|
237
234
|
],
|
|
238
235
|
});
|