@atlaspack/core 2.12.1-dev.3450 → 2.12.1-dev.3460
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/AssetGraph.js +5 -1
- package/lib/Atlaspack.js +2 -2
- package/lib/Dependency.js +1 -1
- package/lib/PackagerRunner.js +45 -3
- package/lib/SymbolPropagation.js +25 -36
- package/lib/assetUtils.js +1 -1
- package/lib/atlaspack-v3/fs.js +31 -29
- package/lib/atlaspack-v3/index.js +2 -2
- package/lib/atlaspack-v3/jsCallable.js +9 -4
- package/lib/atlaspack-v3/worker/compat/asset-symbols.js +192 -0
- package/lib/atlaspack-v3/worker/compat/bitflags.js +84 -0
- package/lib/atlaspack-v3/worker/compat/dependency.js +44 -0
- package/lib/atlaspack-v3/worker/compat/environment.js +68 -0
- package/lib/atlaspack-v3/worker/compat/index.js +104 -0
- package/lib/atlaspack-v3/worker/compat/mutable-asset.js +144 -0
- package/lib/atlaspack-v3/worker/compat/plugin-config.js +58 -0
- package/lib/atlaspack-v3/worker/compat/plugin-logger.js +29 -0
- package/lib/atlaspack-v3/worker/compat/plugin-options.js +113 -0
- package/lib/atlaspack-v3/worker/compat/plugin-tracer.js +12 -0
- package/lib/atlaspack-v3/worker/compat/target.js +17 -0
- package/lib/atlaspack-v3/worker/worker.js +115 -127
- package/lib/projectPath.js +12 -4
- package/lib/requests/ConfigRequest.js +1 -1
- package/lib/requests/WriteBundleRequest.js +15 -15
- package/package.json +23 -16
- package/src/AssetGraph.js +15 -13
- package/src/Atlaspack.js +5 -6
- package/src/AtlaspackConfig.js +11 -9
- package/src/AtlaspackConfig.schema.js +1 -1
- package/src/BundleGraph.js +83 -79
- package/src/CommittedAsset.js +1 -1
- package/src/Dependency.js +1 -1
- package/src/PackagerRunner.js +56 -8
- package/src/ReporterRunner.js +4 -4
- package/src/RequestTracker.js +18 -18
- package/src/SymbolPropagation.js +40 -52
- package/src/Transformation.js +12 -12
- package/src/UncommittedAsset.js +2 -2
- package/src/Validation.js +5 -5
- package/src/applyRuntimes.js +2 -2
- package/src/assetUtils.js +1 -1
- package/src/atlaspack-v3/AtlaspackV3.js +1 -1
- package/src/atlaspack-v3/fs.js +39 -25
- package/src/atlaspack-v3/index.js +1 -1
- package/src/atlaspack-v3/jsCallable.js +11 -10
- package/src/atlaspack-v3/worker/compat/asset-symbols.js +225 -0
- package/src/atlaspack-v3/worker/compat/bitflags.js +100 -0
- package/src/atlaspack-v3/worker/compat/dependency.js +83 -0
- package/src/atlaspack-v3/worker/compat/environment.js +92 -0
- package/src/atlaspack-v3/worker/compat/index.js +10 -0
- package/src/atlaspack-v3/worker/compat/mutable-asset.js +184 -0
- package/src/atlaspack-v3/worker/compat/plugin-config.js +94 -0
- package/src/atlaspack-v3/worker/compat/plugin-logger.js +47 -0
- package/src/atlaspack-v3/worker/compat/plugin-options.js +137 -0
- package/src/atlaspack-v3/worker/compat/plugin-tracer.js +11 -0
- package/src/atlaspack-v3/worker/compat/target.js +27 -0
- package/src/atlaspack-v3/worker/worker.js +148 -134
- package/src/dumpGraphToGraphViz.js +1 -1
- package/src/loadDotEnv.js +1 -1
- package/src/projectPath.js +12 -4
- package/src/public/Asset.js +1 -1
- package/src/public/Bundle.js +3 -3
- package/src/public/BundleGraph.js +20 -20
- package/src/public/Config.js +1 -1
- package/src/public/MutableBundleGraph.js +8 -8
- package/src/requests/AssetGraphRequest.js +10 -10
- package/src/requests/AssetGraphRequestRust.js +3 -3
- package/src/requests/AssetRequest.js +3 -3
- package/src/requests/AtlaspackConfigRequest.js +5 -3
- package/src/requests/BundleGraphRequest.js +6 -6
- package/src/requests/ConfigRequest.js +5 -5
- package/src/requests/DevDepRequest.js +7 -7
- package/src/requests/EntryRequest.js +2 -2
- package/src/requests/TargetRequest.js +9 -8
- package/src/requests/ValidationRequest.js +2 -2
- package/src/requests/WriteBundleRequest.js +26 -20
- package/src/requests/WriteBundlesRequest.js +6 -6
- package/src/requests/asset-graph-diff.js +4 -4
- package/src/resolveOptions.js +3 -3
- package/src/serializer.js +2 -2
- package/src/serializerCore.browser.js +3 -2
- package/src/serializerCore.js +2 -2
- package/src/utils.js +2 -2
- package/test/AtlaspackConfigRequest.test.js +1 -1
- package/test/BundleGraph.test.js +3 -3
- package/test/Dependency.test.js +28 -0
- package/test/PublicMutableBundleGraph.test.js +2 -2
- package/test/RequestTracker.test.js +7 -6
- package/test/SymbolPropagation.test.js +9 -9
- package/test/requests/ConfigRequest.test.js +3 -6
- package/test/utils.test.js +1 -1
- package/lib/atlaspack-v3/worker/compat.js +0 -57
- package/src/atlaspack-v3/worker/compat.js +0 -82
- package/test/requests/WriteBundleRequest.test.js +0 -132
package/src/AtlaspackConfig.js
CHANGED
|
@@ -154,7 +154,7 @@ export default class AtlaspackConfig {
|
|
|
154
154
|
loadPlugins<T>(
|
|
155
155
|
plugins: PureAtlaspackConfigPipeline,
|
|
156
156
|
): Promise<Array<LoadedPlugin<T>>> {
|
|
157
|
-
return Promise.all(plugins.map(p => this.loadPlugin<T>(p)));
|
|
157
|
+
return Promise.all(plugins.map((p) => this.loadPlugin<T>(p)));
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
async getResolvers(): Promise<Array<LoadedPlugin<Resolver<mixed>>>> {
|
|
@@ -181,7 +181,7 @@ export default class AtlaspackConfig {
|
|
|
181
181
|
getValidatorNames(filePath: ProjectPath): Array<string> {
|
|
182
182
|
let validators: PureAtlaspackConfigPipeline =
|
|
183
183
|
this._getValidatorNodes(filePath);
|
|
184
|
-
return validators.map(v => v.packageName);
|
|
184
|
+
return validators.map((v) => v.packageName);
|
|
185
185
|
}
|
|
186
186
|
|
|
187
187
|
getValidators(
|
|
@@ -193,8 +193,8 @@ export default class AtlaspackConfig {
|
|
|
193
193
|
|
|
194
194
|
getNamedPipelines(): $ReadOnlyArray<string> {
|
|
195
195
|
return Object.keys(this.transformers)
|
|
196
|
-
.filter(glob => glob.includes(':'))
|
|
197
|
-
.map(glob => glob.split(':')[0]);
|
|
196
|
+
.filter((glob) => glob.includes(':'))
|
|
197
|
+
.map((glob) => glob.split(':')[0]);
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
async getTransformers(
|
|
@@ -278,7 +278,9 @@ export default class AtlaspackConfig {
|
|
|
278
278
|
// Pipelines for bundles come from their entry assets, so the pipeline likely exists in transformers.
|
|
279
279
|
if (pipeline) {
|
|
280
280
|
let prefix = pipeline + ':';
|
|
281
|
-
if (
|
|
281
|
+
if (
|
|
282
|
+
!Object.keys(this.optimizers).some((glob) => glob.startsWith(prefix))
|
|
283
|
+
) {
|
|
282
284
|
pipeline = null;
|
|
283
285
|
}
|
|
284
286
|
}
|
|
@@ -294,7 +296,7 @@ export default class AtlaspackConfig {
|
|
|
294
296
|
|
|
295
297
|
getOptimizerNames(filePath: FilePath, pipeline: ?string): Array<string> {
|
|
296
298
|
let optimizers = this._getOptimizerNodes(filePath, pipeline);
|
|
297
|
-
return optimizers.map(o => o.packageName);
|
|
299
|
+
return optimizers.map((o) => o.packageName);
|
|
298
300
|
}
|
|
299
301
|
|
|
300
302
|
getOptimizers(
|
|
@@ -435,7 +437,7 @@ export default class AtlaspackConfig {
|
|
|
435
437
|
configsWithPlugin = new Set(getConfigPaths(this.options, plugins));
|
|
436
438
|
} else {
|
|
437
439
|
configsWithPlugin = new Set(
|
|
438
|
-
Object.keys(plugins).flatMap(k =>
|
|
440
|
+
Object.keys(plugins).flatMap((k) =>
|
|
439
441
|
Array.isArray(plugins[k])
|
|
440
442
|
? getConfigPaths(this.options, plugins[k])
|
|
441
443
|
: [getConfigPath(this.options, plugins[k])],
|
|
@@ -451,7 +453,7 @@ export default class AtlaspackConfig {
|
|
|
451
453
|
|
|
452
454
|
let seenKey = false;
|
|
453
455
|
let codeFrames = await Promise.all(
|
|
454
|
-
[...configsWithPlugin].map(async filePath => {
|
|
456
|
+
[...configsWithPlugin].map(async (filePath) => {
|
|
455
457
|
let configContents = await this.options.inputFS.readFile(
|
|
456
458
|
filePath,
|
|
457
459
|
'utf8',
|
|
@@ -481,7 +483,7 @@ export default class AtlaspackConfig {
|
|
|
481
483
|
|
|
482
484
|
function getConfigPaths(options, nodes) {
|
|
483
485
|
return nodes
|
|
484
|
-
.map(node => (node !== '...' ? getConfigPath(options, node) : null))
|
|
486
|
+
.map((node) => (node !== '...' ? getConfigPath(options, node) : null))
|
|
485
487
|
.filter(Boolean);
|
|
486
488
|
}
|
|
487
489
|
|
|
@@ -96,7 +96,7 @@ export default {
|
|
|
96
96
|
},
|
|
97
97
|
bundler: {
|
|
98
98
|
type: 'string',
|
|
99
|
-
__validate: (validatePluginName('bundler', 'bundler'): string => void),
|
|
99
|
+
__validate: (validatePluginName('bundler', 'bundler'): (string) => void),
|
|
100
100
|
},
|
|
101
101
|
resolvers: (pipelineSchema('resolver', 'resolvers'): SchemaEntity),
|
|
102
102
|
transformers: (mapPipelineSchema(
|
package/src/BundleGraph.js
CHANGED
|
@@ -190,7 +190,7 @@ export default class BundleGraph {
|
|
|
190
190
|
: null;
|
|
191
191
|
invariant(assetGraphRootNode != null && assetGraphRootNode.type === 'root');
|
|
192
192
|
|
|
193
|
-
assetGraph.dfsFast(nodeId => {
|
|
193
|
+
assetGraph.dfsFast((nodeId) => {
|
|
194
194
|
let node = assetGraph.getNode(nodeId);
|
|
195
195
|
|
|
196
196
|
if (node != null && node.type === 'asset') {
|
|
@@ -199,7 +199,7 @@ export default class BundleGraph {
|
|
|
199
199
|
// If one already exists, use it.
|
|
200
200
|
let publicId = publicIdByAssetId.get(assetId);
|
|
201
201
|
if (publicId == null) {
|
|
202
|
-
publicId = getPublicId(assetId, existing =>
|
|
202
|
+
publicId = getPublicId(assetId, (existing) =>
|
|
203
203
|
assetPublicIds.has(existing),
|
|
204
204
|
);
|
|
205
205
|
publicIdByAssetId.set(assetId, publicId);
|
|
@@ -252,7 +252,9 @@ export default class BundleGraph {
|
|
|
252
252
|
const condHash = hashString(
|
|
253
253
|
`${key}:${ifTruePlaceholder}:${ifFalsePlaceholder}`,
|
|
254
254
|
);
|
|
255
|
-
const condPublicId = getPublicId(condHash, v =>
|
|
255
|
+
const condPublicId = getPublicId(condHash, (v) =>
|
|
256
|
+
conditions.has(v),
|
|
257
|
+
);
|
|
256
258
|
|
|
257
259
|
if (conditions.has(condHash)) {
|
|
258
260
|
throw new Error('Unexpected duplicate asset');
|
|
@@ -497,10 +499,10 @@ export default class BundleGraph {
|
|
|
497
499
|
continue;
|
|
498
500
|
}
|
|
499
501
|
|
|
500
|
-
let to: Array<NodeId> = dependencies.get(edge.to)?.map(v => v.dep) ??
|
|
502
|
+
let to: Array<NodeId> = dependencies.get(edge.to)?.map((v) => v.dep) ??
|
|
501
503
|
assetGroupIds
|
|
502
504
|
.get(edge.to)
|
|
503
|
-
?.map(id =>
|
|
505
|
+
?.map((id) =>
|
|
504
506
|
nullthrows(assetGraphNodeIdToBundleGraphNodeId.get(id)),
|
|
505
507
|
) ?? [nullthrows(assetGraphNodeIdToBundleGraphNodeId.get(edge.to))];
|
|
506
508
|
|
|
@@ -578,7 +580,7 @@ export default class BundleGraph {
|
|
|
578
580
|
return existing.value;
|
|
579
581
|
}
|
|
580
582
|
|
|
581
|
-
let publicId = getPublicId(bundleId, existing =>
|
|
583
|
+
let publicId = getPublicId(bundleId, (existing) =>
|
|
582
584
|
this._bundlePublicIds.has(existing),
|
|
583
585
|
);
|
|
584
586
|
this._bundlePublicIds.add(publicId);
|
|
@@ -655,7 +657,7 @@ export default class BundleGraph {
|
|
|
655
657
|
|
|
656
658
|
for (let [bundleGroupNodeId, bundleGroupNode] of this._graph
|
|
657
659
|
.getNodeIdsConnectedFrom(dependencyNodeId)
|
|
658
|
-
.map(id => [id, nullthrows(this._graph.getNode(id))])
|
|
660
|
+
.map((id) => [id, nullthrows(this._graph.getNode(id))])
|
|
659
661
|
.filter(([, node]) => node.type === 'bundle_group')) {
|
|
660
662
|
invariant(bundleGroupNode.type === 'bundle_group');
|
|
661
663
|
this._graph.addEdge(
|
|
@@ -673,8 +675,8 @@ export default class BundleGraph {
|
|
|
673
675
|
dependencyNodeId,
|
|
674
676
|
bundleGraphEdgeTypes.references,
|
|
675
677
|
)
|
|
676
|
-
.map(id => nullthrows(this._graph.getNode(id)))
|
|
677
|
-
.some(node => node.type === 'bundle')
|
|
678
|
+
.map((id) => nullthrows(this._graph.getNode(id)))
|
|
679
|
+
.some((node) => node.type === 'bundle')
|
|
678
680
|
) {
|
|
679
681
|
this._graph.addEdge(
|
|
680
682
|
bundleNodeId,
|
|
@@ -688,7 +690,7 @@ export default class BundleGraph {
|
|
|
688
690
|
addAssetGraphToBundle(
|
|
689
691
|
asset: Asset,
|
|
690
692
|
bundle: Bundle,
|
|
691
|
-
shouldSkipDependency: Dependency => boolean = d =>
|
|
693
|
+
shouldSkipDependency: (Dependency) => boolean = (d) =>
|
|
692
694
|
this.isDependencySkipped(d),
|
|
693
695
|
) {
|
|
694
696
|
let assetNodeId = this._graph.getNodeIdByContentKey(asset.id);
|
|
@@ -720,7 +722,7 @@ export default class BundleGraph {
|
|
|
720
722
|
if (node.type === 'dependency') {
|
|
721
723
|
for (let [bundleGroupNodeId, bundleGroupNode] of this._graph
|
|
722
724
|
.getNodeIdsConnectedFrom(nodeId)
|
|
723
|
-
.map(id => [id, nullthrows(this._graph.getNode(id))])
|
|
725
|
+
.map((id) => [id, nullthrows(this._graph.getNode(id))])
|
|
724
726
|
.filter(([, node]) => node.type === 'bundle_group')) {
|
|
725
727
|
invariant(bundleGroupNode.type === 'bundle_group');
|
|
726
728
|
this._graph.addEdge(
|
|
@@ -735,8 +737,8 @@ export default class BundleGraph {
|
|
|
735
737
|
if (
|
|
736
738
|
this._graph
|
|
737
739
|
.getNodeIdsConnectedFrom(nodeId, bundleGraphEdgeTypes.references)
|
|
738
|
-
.map(id => nullthrows(this._graph.getNode(id)))
|
|
739
|
-
.some(node => node.type === 'bundle')
|
|
740
|
+
.map((id) => nullthrows(this._graph.getNode(id)))
|
|
741
|
+
.some((node) => node.type === 'bundle')
|
|
740
742
|
) {
|
|
741
743
|
this._graph.addEdge(
|
|
742
744
|
bundleNodeId,
|
|
@@ -764,7 +766,7 @@ export default class BundleGraph {
|
|
|
764
766
|
addEntryToBundle(
|
|
765
767
|
asset: Asset,
|
|
766
768
|
bundle: Bundle,
|
|
767
|
-
shouldSkipDependency?: Dependency => boolean,
|
|
769
|
+
shouldSkipDependency?: (Dependency) => boolean,
|
|
768
770
|
) {
|
|
769
771
|
this.addAssetGraphToBundle(asset, bundle, shouldSkipDependency);
|
|
770
772
|
if (!bundle.entryAssetIds.includes(asset.id)) {
|
|
@@ -821,9 +823,9 @@ export default class BundleGraph {
|
|
|
821
823
|
this._graph.getNodeIdByContentKey(getBundleGroupId(bundleGroup)),
|
|
822
824
|
bundleGraphEdgeTypes.bundle,
|
|
823
825
|
)
|
|
824
|
-
.map(id => nullthrows(this._graph.getNode(id)))
|
|
825
|
-
.filter(node => node.type === 'bundle')
|
|
826
|
-
.map(node => {
|
|
826
|
+
.map((id) => nullthrows(this._graph.getNode(id)))
|
|
827
|
+
.filter((node) => node.type === 'bundle')
|
|
828
|
+
.map((node) => {
|
|
827
829
|
invariant(node.type === 'bundle');
|
|
828
830
|
return node.value;
|
|
829
831
|
});
|
|
@@ -879,8 +881,8 @@ export default class BundleGraph {
|
|
|
879
881
|
|
|
880
882
|
let node = this._graph
|
|
881
883
|
.getNodeIdsConnectedFrom(this._graph.getNodeIdByContentKey(dependency.id))
|
|
882
|
-
.map(id => nullthrows(this._graph.getNode(id)))
|
|
883
|
-
.find(node => node.type === 'bundle_group');
|
|
884
|
+
.map((id) => nullthrows(this._graph.getNode(id)))
|
|
885
|
+
.find((node) => node.type === 'bundle_group');
|
|
884
886
|
|
|
885
887
|
if (node == null) {
|
|
886
888
|
return;
|
|
@@ -903,13 +905,13 @@ export default class BundleGraph {
|
|
|
903
905
|
dependencyNodeId,
|
|
904
906
|
bundleGraphEdgeTypes.references,
|
|
905
907
|
)
|
|
906
|
-
.map(id => nullthrows(this._graph.getNode(id)))
|
|
907
|
-
.filter(node => node.type === 'bundle');
|
|
908
|
+
.map((id) => nullthrows(this._graph.getNode(id)))
|
|
909
|
+
.filter((node) => node.type === 'bundle');
|
|
908
910
|
|
|
909
911
|
if (bundleNodes.length) {
|
|
910
912
|
let bundleNode =
|
|
911
913
|
bundleNodes.find(
|
|
912
|
-
b => b.type === 'bundle' && b.value.type === fromBundle.type,
|
|
914
|
+
(b) => b.type === 'bundle' && b.value.type === fromBundle.type,
|
|
913
915
|
) || bundleNodes[0];
|
|
914
916
|
invariant(bundleNode.type === 'bundle');
|
|
915
917
|
return bundleNode.value;
|
|
@@ -918,14 +920,14 @@ export default class BundleGraph {
|
|
|
918
920
|
// If this dependency is async, there will be a bundle group attached to it.
|
|
919
921
|
let node = this._graph
|
|
920
922
|
.getNodeIdsConnectedFrom(dependencyNodeId)
|
|
921
|
-
.map(id => nullthrows(this._graph.getNode(id)))
|
|
922
|
-
.find(node => node.type === 'bundle_group');
|
|
923
|
+
.map((id) => nullthrows(this._graph.getNode(id)))
|
|
924
|
+
.find((node) => node.type === 'bundle_group');
|
|
923
925
|
|
|
924
926
|
if (node != null) {
|
|
925
927
|
invariant(node.type === 'bundle_group');
|
|
926
928
|
return this.getBundlesInBundleGroup(node.value, {
|
|
927
929
|
includeInline: true,
|
|
928
|
-
}).find(b => {
|
|
930
|
+
}).find((b) => {
|
|
929
931
|
let mainEntryId = b.entryAssetIds[b.entryAssetIds.length - 1];
|
|
930
932
|
return mainEntryId != null && node.value.entryAssetId === mainEntryId;
|
|
931
933
|
});
|
|
@@ -1087,7 +1089,7 @@ export default class BundleGraph {
|
|
|
1087
1089
|
|
|
1088
1090
|
assert(
|
|
1089
1091
|
bundlesInGroup.every(
|
|
1090
|
-
bundle => this.getBundleGroupsContainingBundle(bundle).length > 0,
|
|
1092
|
+
(bundle) => this.getBundleGroupsContainingBundle(bundle).length > 0,
|
|
1091
1093
|
),
|
|
1092
1094
|
);
|
|
1093
1095
|
}
|
|
@@ -1096,8 +1098,8 @@ export default class BundleGraph {
|
|
|
1096
1098
|
let bundleNodeId = this._graph.getNodeIdByContentKey(bundle.id);
|
|
1097
1099
|
for (let bundleGroupNode of this._graph
|
|
1098
1100
|
.getNodeIdsConnectedFrom(this._graph.getNodeIdByContentKey(dependency.id))
|
|
1099
|
-
.map(id => nullthrows(this._graph.getNode(id)))
|
|
1100
|
-
.filter(node => node.type === 'bundle_group')) {
|
|
1101
|
+
.map((id) => nullthrows(this._graph.getNode(id)))
|
|
1102
|
+
.filter((node) => node.type === 'bundle_group')) {
|
|
1101
1103
|
let bundleGroupNodeId = this._graph.getNodeIdByContentKey(
|
|
1102
1104
|
bundleGroupNode.id,
|
|
1103
1105
|
);
|
|
@@ -1114,9 +1116,9 @@ export default class BundleGraph {
|
|
|
1114
1116
|
|
|
1115
1117
|
let inboundDependencies = this._graph
|
|
1116
1118
|
.getNodeIdsConnectedTo(bundleGroupNodeId)
|
|
1117
|
-
.map(id => nullthrows(this._graph.getNode(id)))
|
|
1118
|
-
.filter(node => node.type === 'dependency')
|
|
1119
|
-
.map(node => {
|
|
1119
|
+
.map((id) => nullthrows(this._graph.getNode(id)))
|
|
1120
|
+
.filter((node) => node.type === 'dependency')
|
|
1121
|
+
.map((node) => {
|
|
1120
1122
|
invariant(node.type === 'dependency');
|
|
1121
1123
|
return node.value;
|
|
1122
1124
|
});
|
|
@@ -1126,7 +1128,7 @@ export default class BundleGraph {
|
|
|
1126
1128
|
// this bundle and the group is safe to remove.
|
|
1127
1129
|
if (
|
|
1128
1130
|
inboundDependencies.every(
|
|
1129
|
-
dependency =>
|
|
1131
|
+
(dependency) =>
|
|
1130
1132
|
dependency.specifierType !== SpecifierType.url &&
|
|
1131
1133
|
(!this.bundleHasDependency(bundle, dependency) ||
|
|
1132
1134
|
this._graph.hasEdge(
|
|
@@ -1180,9 +1182,9 @@ export default class BundleGraph {
|
|
|
1180
1182
|
this._graph.getNodeIdByContentKey(asset.id),
|
|
1181
1183
|
bundleGraphEdgeTypes.contains,
|
|
1182
1184
|
)
|
|
1183
|
-
.map(id => nullthrows(this._graph.getNode(id)))
|
|
1184
|
-
.filter(node => node.type === 'bundle')
|
|
1185
|
-
.map(node => {
|
|
1185
|
+
.map((id) => nullthrows(this._graph.getNode(id)))
|
|
1186
|
+
.filter((node) => node.type === 'bundle')
|
|
1187
|
+
.map((node) => {
|
|
1186
1188
|
invariant(node.type === 'bundle');
|
|
1187
1189
|
return node.value;
|
|
1188
1190
|
});
|
|
@@ -1194,9 +1196,9 @@ export default class BundleGraph {
|
|
|
1194
1196
|
nullthrows(this._graph.getNodeIdByContentKey(dependency.id)),
|
|
1195
1197
|
bundleGraphEdgeTypes.contains,
|
|
1196
1198
|
)
|
|
1197
|
-
.map(id => nullthrows(this._graph.getNode(id)))
|
|
1198
|
-
.filter(node => node.type === 'bundle')
|
|
1199
|
-
.map(node => {
|
|
1199
|
+
.map((id) => nullthrows(this._graph.getNode(id)))
|
|
1200
|
+
.filter((node) => node.type === 'bundle')
|
|
1201
|
+
.map((node) => {
|
|
1200
1202
|
invariant(node.type === 'bundle');
|
|
1201
1203
|
return node.value;
|
|
1202
1204
|
});
|
|
@@ -1205,9 +1207,9 @@ export default class BundleGraph {
|
|
|
1205
1207
|
getDependencyAssets(dependency: Dependency): Array<Asset> {
|
|
1206
1208
|
return this._graph
|
|
1207
1209
|
.getNodeIdsConnectedFrom(this._graph.getNodeIdByContentKey(dependency.id))
|
|
1208
|
-
.map(id => nullthrows(this._graph.getNode(id)))
|
|
1209
|
-
.filter(node => node.type === 'asset')
|
|
1210
|
-
.map(node => {
|
|
1210
|
+
.map((id) => nullthrows(this._graph.getNode(id)))
|
|
1211
|
+
.filter((node) => node.type === 'asset')
|
|
1212
|
+
.map((node) => {
|
|
1211
1213
|
invariant(node.type === 'asset');
|
|
1212
1214
|
return node.value;
|
|
1213
1215
|
});
|
|
@@ -1221,8 +1223,8 @@ export default class BundleGraph {
|
|
|
1221
1223
|
bundle == null
|
|
1222
1224
|
? firstAsset
|
|
1223
1225
|
: // Otherwise, find the first asset that belongs to this bundle.
|
|
1224
|
-
assets.find(asset => this.bundleHasAsset(bundle, asset)) ||
|
|
1225
|
-
assets.find(a => a.type === bundle.type) ||
|
|
1226
|
+
assets.find((asset) => this.bundleHasAsset(bundle, asset)) ||
|
|
1227
|
+
assets.find((a) => a.type === bundle.type) ||
|
|
1226
1228
|
firstAsset;
|
|
1227
1229
|
|
|
1228
1230
|
// If a resolution still hasn't been found, return the first referenced asset.
|
|
@@ -1242,7 +1244,7 @@ export default class BundleGraph {
|
|
|
1242
1244
|
);
|
|
1243
1245
|
|
|
1244
1246
|
if (bundle) {
|
|
1245
|
-
resolved = potential.find(a => a.type === bundle.type);
|
|
1247
|
+
resolved = potential.find((a) => a.type === bundle.type);
|
|
1246
1248
|
}
|
|
1247
1249
|
resolved ||= potential[0];
|
|
1248
1250
|
}
|
|
@@ -1252,7 +1254,7 @@ export default class BundleGraph {
|
|
|
1252
1254
|
|
|
1253
1255
|
getDependencies(asset: Asset): Array<Dependency> {
|
|
1254
1256
|
let nodeId = this._graph.getNodeIdByContentKey(asset.id);
|
|
1255
|
-
return this._graph.getNodeIdsConnectedFrom(nodeId).map(id => {
|
|
1257
|
+
return this._graph.getNodeIdsConnectedFrom(nodeId).map((id) => {
|
|
1256
1258
|
let node = nullthrows(this._graph.getNode(id));
|
|
1257
1259
|
invariant(node.type === 'dependency');
|
|
1258
1260
|
return node.value;
|
|
@@ -1266,7 +1268,7 @@ export default class BundleGraph {
|
|
|
1266
1268
|
): ?TContext {
|
|
1267
1269
|
return this.traverseBundle(
|
|
1268
1270
|
bundle,
|
|
1269
|
-
mapVisitor(node => (node.type === 'asset' ? node.value : null), visit),
|
|
1271
|
+
mapVisitor((node) => (node.type === 'asset' ? node.value : null), visit),
|
|
1270
1272
|
startAsset,
|
|
1271
1273
|
);
|
|
1272
1274
|
}
|
|
@@ -1275,7 +1277,7 @@ export default class BundleGraph {
|
|
|
1275
1277
|
// If the asset is available in multiple bundles in the same target, it's referenced.
|
|
1276
1278
|
if (
|
|
1277
1279
|
this.getBundlesWithAsset(asset).filter(
|
|
1278
|
-
b => b.target.distDir === bundle.target.distDir,
|
|
1280
|
+
(b) => b.target.distDir === bundle.target.distDir,
|
|
1279
1281
|
).length > 1
|
|
1280
1282
|
) {
|
|
1281
1283
|
return true;
|
|
@@ -1286,9 +1288,9 @@ export default class BundleGraph {
|
|
|
1286
1288
|
if (
|
|
1287
1289
|
this._graph
|
|
1288
1290
|
.getNodeIdsConnectedTo(assetNodeId, bundleGraphEdgeTypes.references)
|
|
1289
|
-
.map(id => this._graph.getNode(id))
|
|
1291
|
+
.map((id) => this._graph.getNode(id))
|
|
1290
1292
|
.some(
|
|
1291
|
-
node =>
|
|
1293
|
+
(node) =>
|
|
1292
1294
|
node?.type === 'dependency' &&
|
|
1293
1295
|
(node.value.priority === Priority.lazy ||
|
|
1294
1296
|
node.value.priority === Priority.conditional) &&
|
|
@@ -1301,9 +1303,9 @@ export default class BundleGraph {
|
|
|
1301
1303
|
|
|
1302
1304
|
let dependencies = this._graph
|
|
1303
1305
|
.getNodeIdsConnectedTo(assetNodeId)
|
|
1304
|
-
.map(id => nullthrows(this._graph.getNode(id)))
|
|
1305
|
-
.filter(node => node.type === 'dependency')
|
|
1306
|
-
.map(node => {
|
|
1306
|
+
.map((id) => nullthrows(this._graph.getNode(id)))
|
|
1307
|
+
.filter((node) => node.type === 'dependency')
|
|
1308
|
+
.map((node) => {
|
|
1307
1309
|
invariant(node.type === 'dependency');
|
|
1308
1310
|
return node.value;
|
|
1309
1311
|
});
|
|
@@ -1311,7 +1313,7 @@ export default class BundleGraph {
|
|
|
1311
1313
|
const bundleHasReference = (bundle: Bundle) => {
|
|
1312
1314
|
return (
|
|
1313
1315
|
!this.bundleHasAsset(bundle, asset) &&
|
|
1314
|
-
dependencies.some(dependency =>
|
|
1316
|
+
dependencies.some((dependency) =>
|
|
1315
1317
|
this.bundleHasDependency(bundle, dependency),
|
|
1316
1318
|
)
|
|
1317
1319
|
);
|
|
@@ -1319,7 +1321,7 @@ export default class BundleGraph {
|
|
|
1319
1321
|
|
|
1320
1322
|
let visitedBundles: Set<Bundle> = new Set();
|
|
1321
1323
|
let siblingBundles = new Set(
|
|
1322
|
-
this.getBundleGroupsContainingBundle(bundle).flatMap(bundleGroup =>
|
|
1324
|
+
this.getBundleGroupsContainingBundle(bundle).flatMap((bundleGroup) =>
|
|
1323
1325
|
this.getBundlesInBundleGroup(bundleGroup, {includeInline: true}),
|
|
1324
1326
|
),
|
|
1325
1327
|
);
|
|
@@ -1328,7 +1330,7 @@ export default class BundleGraph {
|
|
|
1328
1330
|
// by referencers, or descendants of its referencers use the asset without
|
|
1329
1331
|
// an explicit reference edge. This can happen if e.g. the asset has been
|
|
1330
1332
|
// deduplicated.
|
|
1331
|
-
return [...siblingBundles].some(referencer => {
|
|
1333
|
+
return [...siblingBundles].some((referencer) => {
|
|
1332
1334
|
let isReferenced = false;
|
|
1333
1335
|
this.traverseBundles((descendant, _, actions) => {
|
|
1334
1336
|
if (descendant.id === bundle.id) {
|
|
@@ -1363,7 +1365,9 @@ export default class BundleGraph {
|
|
|
1363
1365
|
|
|
1364
1366
|
hasParentBundleOfType(bundle: Bundle, type: string): boolean {
|
|
1365
1367
|
let parents = this.getParentBundles(bundle);
|
|
1366
|
-
return
|
|
1368
|
+
return (
|
|
1369
|
+
parents.length > 0 && parents.every((parent) => parent.type === type)
|
|
1370
|
+
);
|
|
1367
1371
|
}
|
|
1368
1372
|
|
|
1369
1373
|
getParentBundles(bundle: Bundle): Array<Bundle> {
|
|
@@ -1394,12 +1398,12 @@ export default class BundleGraph {
|
|
|
1394
1398
|
// For an asset to be reachable from a bundle, it must either exist in a sibling bundle,
|
|
1395
1399
|
// or in an ancestor bundle group reachable from all parent bundles.
|
|
1396
1400
|
let bundleGroups = this.getBundleGroupsContainingBundle(bundle);
|
|
1397
|
-
return bundleGroups.every(bundleGroup => {
|
|
1401
|
+
return bundleGroups.every((bundleGroup) => {
|
|
1398
1402
|
// If the asset is in any sibling bundles of the original bundle, it is reachable.
|
|
1399
1403
|
let bundles = this.getBundlesInBundleGroup(bundleGroup);
|
|
1400
1404
|
if (
|
|
1401
1405
|
bundles.some(
|
|
1402
|
-
b =>
|
|
1406
|
+
(b) =>
|
|
1403
1407
|
b.id !== bundle.id &&
|
|
1404
1408
|
b.bundleBehavior !== BundleBehavior.isolated &&
|
|
1405
1409
|
b.bundleBehavior !== BundleBehavior.inline &&
|
|
@@ -1416,7 +1420,7 @@ export default class BundleGraph {
|
|
|
1416
1420
|
);
|
|
1417
1421
|
|
|
1418
1422
|
// Check that every parent bundle has a bundle group in its ancestry that contains the asset.
|
|
1419
|
-
return parentBundleNodes.every(bundleNodeId => {
|
|
1423
|
+
return parentBundleNodes.every((bundleNodeId) => {
|
|
1420
1424
|
let bundleNode = nullthrows(this._graph.getNode(bundleNodeId));
|
|
1421
1425
|
if (
|
|
1422
1426
|
bundleNode.type !== 'bundle' ||
|
|
@@ -1448,7 +1452,7 @@ export default class BundleGraph {
|
|
|
1448
1452
|
let childBundles = this.getBundlesInBundleGroup(node.value);
|
|
1449
1453
|
if (
|
|
1450
1454
|
childBundles.some(
|
|
1451
|
-
b =>
|
|
1455
|
+
(b) =>
|
|
1452
1456
|
b.id !== bundle.id &&
|
|
1453
1457
|
b.bundleBehavior !== BundleBehavior.isolated &&
|
|
1454
1458
|
b.bundleBehavior !== BundleBehavior.inline &&
|
|
@@ -1507,10 +1511,10 @@ export default class BundleGraph {
|
|
|
1507
1511
|
startNodeId: startAsset
|
|
1508
1512
|
? this._graph.getNodeIdByContentKey(startAsset.id)
|
|
1509
1513
|
: bundleNodeId,
|
|
1510
|
-
getChildren: nodeId => {
|
|
1514
|
+
getChildren: (nodeId) => {
|
|
1511
1515
|
let children = this._graph
|
|
1512
1516
|
.getNodeIdsConnectedFrom(nodeId)
|
|
1513
|
-
.map(id => [id, nullthrows(this._graph.getNode(id))]);
|
|
1517
|
+
.map((id) => [id, nullthrows(this._graph.getNode(id))]);
|
|
1514
1518
|
|
|
1515
1519
|
let sorted =
|
|
1516
1520
|
entries && bundle.entryAssetIds.length > 0
|
|
@@ -1543,7 +1547,7 @@ export default class BundleGraph {
|
|
|
1543
1547
|
start?: Asset,
|
|
1544
1548
|
): ?TContext {
|
|
1545
1549
|
return this._graph.filteredTraverse(
|
|
1546
|
-
nodeId => {
|
|
1550
|
+
(nodeId) => {
|
|
1547
1551
|
let node = nullthrows(this._graph.getNode(nodeId));
|
|
1548
1552
|
if (node.type === 'asset' || node.type === 'dependency') {
|
|
1549
1553
|
return node;
|
|
@@ -1577,7 +1581,7 @@ export default class BundleGraph {
|
|
|
1577
1581
|
startBundle: ?Bundle,
|
|
1578
1582
|
): ?TContext {
|
|
1579
1583
|
return this._graph.filteredTraverse(
|
|
1580
|
-
nodeId => {
|
|
1584
|
+
(nodeId) => {
|
|
1581
1585
|
let node = nullthrows(this._graph.getNode(nodeId));
|
|
1582
1586
|
return node.type === 'bundle' ? node.value : null;
|
|
1583
1587
|
},
|
|
@@ -1589,7 +1593,7 @@ export default class BundleGraph {
|
|
|
1589
1593
|
|
|
1590
1594
|
getBundles(opts?: {|includeInline: boolean|}): Array<Bundle> {
|
|
1591
1595
|
let bundles = [];
|
|
1592
|
-
this.traverseBundles(bundle => {
|
|
1596
|
+
this.traverseBundles((bundle) => {
|
|
1593
1597
|
if (
|
|
1594
1598
|
opts?.includeInline ||
|
|
1595
1599
|
bundle.bundleBehavior !== BundleBehavior.inline
|
|
@@ -1622,7 +1626,7 @@ export default class BundleGraph {
|
|
|
1622
1626
|
|
|
1623
1627
|
this._graph.traverseAncestors(
|
|
1624
1628
|
this._graph.getNodeIdByContentKey(bundle.id),
|
|
1625
|
-
nodeId => {
|
|
1629
|
+
(nodeId) => {
|
|
1626
1630
|
let node = nullthrows(this._graph.getNode(nodeId));
|
|
1627
1631
|
if (node.type === 'bundle' && node.value.id !== bundle.id) {
|
|
1628
1632
|
referencingBundles.add(node.value);
|
|
@@ -1652,9 +1656,9 @@ export default class BundleGraph {
|
|
|
1652
1656
|
nullthrows(this._graph.getNodeIdByContentKey(bundle.id)),
|
|
1653
1657
|
bundleGraphEdgeTypes.bundle,
|
|
1654
1658
|
)
|
|
1655
|
-
.map(id => nullthrows(this._graph.getNode(id)))
|
|
1656
|
-
.filter(node => node.type === 'bundle_group')
|
|
1657
|
-
.map(node => {
|
|
1659
|
+
.map((id) => nullthrows(this._graph.getNode(id)))
|
|
1660
|
+
.filter((node) => node.type === 'bundle_group')
|
|
1661
|
+
.map((node) => {
|
|
1658
1662
|
invariant(node.type === 'bundle_group');
|
|
1659
1663
|
return node.value;
|
|
1660
1664
|
});
|
|
@@ -1719,7 +1723,7 @@ export default class BundleGraph {
|
|
|
1719
1723
|
}
|
|
1720
1724
|
},
|
|
1721
1725
|
startNodeId: this._graph.getNodeIdByContentKey(bundle.id),
|
|
1722
|
-
getChildren: nodeId =>
|
|
1726
|
+
getChildren: (nodeId) =>
|
|
1723
1727
|
// Shared bundles seem to depend on being used in the opposite order
|
|
1724
1728
|
// they were added.
|
|
1725
1729
|
// TODO: Should this be the case?
|
|
@@ -1743,9 +1747,9 @@ export default class BundleGraph {
|
|
|
1743
1747
|
this._graph.getNodeIdByContentKey(asset.id),
|
|
1744
1748
|
ALL_EDGE_TYPES,
|
|
1745
1749
|
)
|
|
1746
|
-
.map(id => nullthrows(this._graph.getNode(id)))
|
|
1747
|
-
.filter(n => n.type === 'dependency')
|
|
1748
|
-
.map(n => {
|
|
1750
|
+
.map((id) => nullthrows(this._graph.getNode(id)))
|
|
1751
|
+
.filter((n) => n.type === 'dependency')
|
|
1752
|
+
.map((n) => {
|
|
1749
1753
|
invariant(n.type === 'dependency');
|
|
1750
1754
|
return n.value;
|
|
1751
1755
|
});
|
|
@@ -2017,8 +2021,8 @@ export default class BundleGraph {
|
|
|
2017
2021
|
let resolved = this.getResolvedAsset(dep, boundary);
|
|
2018
2022
|
if (!resolved) continue;
|
|
2019
2023
|
let exported = this.getExportedSymbols(resolved, boundary)
|
|
2020
|
-
.filter(s => s.exportSymbol !== 'default')
|
|
2021
|
-
.map(s =>
|
|
2024
|
+
.filter((s) => s.exportSymbol !== 'default')
|
|
2025
|
+
.map((s) =>
|
|
2022
2026
|
s.exportSymbol !== '*' ? {...s, exportAs: s.exportSymbol} : s,
|
|
2023
2027
|
);
|
|
2024
2028
|
symbols.push(...exported);
|
|
@@ -2036,7 +2040,7 @@ export default class BundleGraph {
|
|
|
2036
2040
|
|
|
2037
2041
|
let hash = new Hash();
|
|
2038
2042
|
// TODO: sort??
|
|
2039
|
-
this.traverseAssets(bundle, asset => {
|
|
2043
|
+
this.traverseAssets(bundle, (asset) => {
|
|
2040
2044
|
{
|
|
2041
2045
|
hash.writeString(
|
|
2042
2046
|
[this.getAssetPublicId(asset), asset.id, asset.outputHash].join(':'),
|
|
@@ -2052,7 +2056,7 @@ export default class BundleGraph {
|
|
|
2052
2056
|
getInlineBundles(bundle: Bundle): Array<Bundle> {
|
|
2053
2057
|
let bundles = [];
|
|
2054
2058
|
let seen = new Set();
|
|
2055
|
-
let addReferencedBundles = bundle => {
|
|
2059
|
+
let addReferencedBundles = (bundle) => {
|
|
2056
2060
|
if (seen.has(bundle.id)) {
|
|
2057
2061
|
return;
|
|
2058
2062
|
}
|
|
@@ -2219,8 +2223,8 @@ export default class BundleGraph {
|
|
|
2219
2223
|
),
|
|
2220
2224
|
bundleGraphEdgeTypes.bundle,
|
|
2221
2225
|
)
|
|
2222
|
-
.map(id => nullthrows(this._graph.getNode(id)))
|
|
2223
|
-
.some(n => n.type === 'root');
|
|
2226
|
+
.map((id) => nullthrows(this._graph.getNode(id)))
|
|
2227
|
+
.some((n) => n.type === 'root');
|
|
2224
2228
|
}
|
|
2225
2229
|
|
|
2226
2230
|
/**
|
package/src/CommittedAsset.js
CHANGED
|
@@ -131,7 +131,7 @@ export default class CommittedAsset {
|
|
|
131
131
|
if (this.ast == null) {
|
|
132
132
|
this.ast = this.options.cache
|
|
133
133
|
.getBlob(this.value.astKey)
|
|
134
|
-
.then(serializedAst => deserializeRaw(serializedAst));
|
|
134
|
+
.then((serializedAst) => deserializeRaw(serializedAst));
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
return this.ast;
|