@atlaspack/core 2.16.2-canary.21 → 2.16.2-canary.211
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 +561 -0
- package/dist/AssetGraph.js +591 -0
- package/dist/Atlaspack.js +656 -0
- package/dist/AtlaspackConfig.js +324 -0
- package/dist/AtlaspackConfig.schema.js +108 -0
- package/dist/BundleGraph.js +1628 -0
- package/dist/CommittedAsset.js +142 -0
- package/dist/Dependency.js +125 -0
- package/dist/Environment.js +132 -0
- package/dist/EnvironmentManager.js +108 -0
- package/dist/IdentifierRegistry.js +38 -0
- package/dist/InternalConfig.js +37 -0
- package/dist/PackagerRunner.js +531 -0
- package/dist/ReporterRunner.js +151 -0
- package/dist/RequestTracker.js +1368 -0
- package/dist/SymbolPropagation.js +617 -0
- package/dist/TargetDescriptor.schema.js +143 -0
- package/dist/Transformation.js +487 -0
- package/dist/UncommittedAsset.js +315 -0
- package/dist/Validation.js +196 -0
- package/dist/applyRuntimes.js +305 -0
- package/dist/assetUtils.js +168 -0
- package/dist/atlaspack-v3/AtlaspackV3.js +70 -0
- package/dist/atlaspack-v3/NapiWorkerPool.js +57 -0
- package/dist/atlaspack-v3/fs.js +52 -0
- package/dist/atlaspack-v3/index.js +25 -0
- package/dist/atlaspack-v3/jsCallable.js +16 -0
- package/dist/atlaspack-v3/worker/compat/asset-symbols.js +190 -0
- package/dist/atlaspack-v3/worker/compat/bitflags.js +94 -0
- package/dist/atlaspack-v3/worker/compat/dependency.js +43 -0
- package/dist/atlaspack-v3/worker/compat/environment.js +57 -0
- package/dist/atlaspack-v3/worker/compat/index.js +25 -0
- package/dist/atlaspack-v3/worker/compat/mutable-asset.js +152 -0
- package/dist/atlaspack-v3/worker/compat/plugin-config.js +76 -0
- package/dist/atlaspack-v3/worker/compat/plugin-logger.js +26 -0
- package/dist/atlaspack-v3/worker/compat/plugin-options.js +122 -0
- package/dist/atlaspack-v3/worker/compat/plugin-tracer.js +10 -0
- package/dist/atlaspack-v3/worker/compat/target.js +14 -0
- package/dist/atlaspack-v3/worker/worker.js +292 -0
- package/dist/constants.js +17 -0
- package/dist/dumpGraphToGraphViz.js +281 -0
- package/dist/index.js +62 -0
- package/dist/loadAtlaspackPlugin.js +128 -0
- package/dist/loadDotEnv.js +41 -0
- package/dist/projectPath.js +83 -0
- package/dist/public/Asset.js +279 -0
- package/dist/public/Bundle.js +224 -0
- package/dist/public/BundleGraph.js +359 -0
- package/dist/public/BundleGroup.js +53 -0
- package/dist/public/Config.js +286 -0
- package/dist/public/Dependency.js +138 -0
- package/dist/public/Environment.js +278 -0
- package/dist/public/MutableBundleGraph.js +277 -0
- package/dist/public/PluginOptions.js +80 -0
- package/dist/public/Symbols.js +248 -0
- package/dist/public/Target.js +69 -0
- package/dist/registerCoreWithSerializer.js +38 -0
- package/dist/requests/AssetGraphRequest.js +429 -0
- package/dist/requests/AssetGraphRequestRust.js +246 -0
- package/dist/requests/AssetRequest.js +130 -0
- package/dist/requests/AtlaspackBuildRequest.js +60 -0
- package/dist/requests/AtlaspackConfigRequest.js +490 -0
- package/dist/requests/BundleGraphRequest.js +441 -0
- package/dist/requests/ConfigRequest.js +222 -0
- package/dist/requests/DevDepRequest.js +204 -0
- package/dist/requests/EntryRequest.js +314 -0
- package/dist/requests/PackageRequest.js +65 -0
- package/dist/requests/PathRequest.js +349 -0
- package/dist/requests/TargetRequest.js +1310 -0
- package/dist/requests/ValidationRequest.js +49 -0
- package/dist/requests/WriteBundleRequest.js +254 -0
- package/dist/requests/WriteBundlesRequest.js +165 -0
- package/dist/requests/asset-graph-diff.js +126 -0
- package/dist/requests/asset-graph-dot.js +131 -0
- package/dist/resolveOptions.js +268 -0
- package/dist/rustWorkerThreadDylibHack.js +19 -0
- package/dist/serializerCore.browser.js +43 -0
- package/dist/summarizeRequest.js +39 -0
- package/dist/types.js +31 -0
- package/dist/utils.js +172 -0
- package/dist/worker.js +123 -0
- package/lib/AssetGraph.js +111 -14
- package/lib/Atlaspack.js +82 -35
- package/lib/AtlaspackConfig.js +15 -3
- package/lib/AtlaspackConfig.schema.js +7 -5
- package/lib/BundleGraph.js +83 -30
- package/lib/CommittedAsset.js +6 -0
- package/lib/Dependency.js +8 -2
- package/lib/Environment.js +15 -8
- package/lib/EnvironmentManager.js +143 -0
- package/lib/IdentifierRegistry.js +1 -3
- package/lib/InternalConfig.js +3 -2
- package/lib/PackagerRunner.js +66 -23
- package/lib/ReporterRunner.js +6 -9
- package/lib/RequestTracker.js +256 -139
- package/lib/SymbolPropagation.js +22 -3
- package/lib/TargetDescriptor.schema.js +7 -1
- package/lib/Transformation.js +16 -9
- package/lib/UncommittedAsset.js +30 -9
- package/lib/Validation.js +18 -2
- package/lib/applyRuntimes.js +9 -1
- package/lib/assetUtils.js +7 -4
- package/lib/atlaspack-v3/AtlaspackV3.js +32 -7
- package/lib/atlaspack-v3/NapiWorkerPool.js +3 -0
- package/lib/atlaspack-v3/fs.js +3 -1
- package/lib/atlaspack-v3/index.js +28 -1
- package/lib/atlaspack-v3/jsCallable.js +0 -2
- package/lib/atlaspack-v3/worker/compat/asset-symbols.js +7 -4
- package/lib/atlaspack-v3/worker/compat/bitflags.js +7 -6
- package/lib/atlaspack-v3/worker/compat/dependency.js +3 -0
- package/lib/atlaspack-v3/worker/compat/environment.js +10 -7
- package/lib/atlaspack-v3/worker/compat/mutable-asset.js +14 -9
- package/lib/atlaspack-v3/worker/compat/plugin-config.js +8 -10
- package/lib/atlaspack-v3/worker/compat/plugin-options.js +1 -0
- package/lib/atlaspack-v3/worker/compat/plugin-tracer.js +3 -0
- package/lib/atlaspack-v3/worker/compat/target.js +2 -0
- package/lib/atlaspack-v3/worker/index.js +3 -0
- package/lib/atlaspack-v3/worker/worker.js +34 -6
- package/lib/constants.js +0 -1
- package/lib/dumpGraphToGraphViz.js +71 -16
- package/lib/index.js +45 -1
- package/lib/loadDotEnv.js +4 -1
- package/lib/projectPath.js +5 -0
- package/lib/public/Asset.js +21 -11
- package/lib/public/Bundle.js +15 -16
- package/lib/public/BundleGraph.js +10 -4
- package/lib/public/BundleGroup.js +4 -5
- package/lib/public/Config.js +118 -17
- package/lib/public/Dependency.js +8 -6
- package/lib/public/Environment.js +12 -7
- package/lib/public/MutableBundleGraph.js +54 -12
- package/lib/public/PluginOptions.js +2 -2
- package/lib/public/Symbols.js +11 -11
- package/lib/public/Target.js +7 -6
- package/lib/registerCoreWithSerializer.js +5 -3
- package/lib/requests/AssetGraphRequest.js +41 -4
- package/lib/requests/AssetGraphRequestRust.js +29 -14
- package/lib/requests/AssetRequest.js +23 -6
- package/lib/requests/AtlaspackBuildRequest.js +6 -2
- package/lib/requests/AtlaspackConfigRequest.js +12 -11
- package/lib/requests/BundleGraphRequest.js +29 -18
- package/lib/requests/ConfigRequest.js +28 -4
- package/lib/requests/DevDepRequest.js +31 -5
- package/lib/requests/EntryRequest.js +2 -0
- package/lib/requests/PackageRequest.js +7 -2
- package/lib/requests/PathRequest.js +24 -3
- package/lib/requests/TargetRequest.js +120 -56
- package/lib/requests/ValidationRequest.js +5 -1
- package/lib/requests/WriteBundleRequest.js +39 -11
- package/lib/requests/WriteBundlesRequest.js +24 -2
- package/lib/requests/asset-graph-diff.js +8 -3
- package/lib/requests/asset-graph-dot.js +1 -7
- package/lib/resolveOptions.js +36 -10
- package/lib/rustWorkerThreadDylibHack.js +0 -1
- package/lib/types/AssetGraph.d.ts +80 -0
- package/lib/types/Atlaspack.d.ts +52 -0
- package/lib/types/AtlaspackConfig.d.ts +65 -0
- package/lib/types/AtlaspackConfig.schema.d.ts +46 -0
- package/lib/types/BundleGraph.d.ts +182 -0
- package/lib/types/CommittedAsset.d.ts +23 -0
- package/lib/types/Dependency.d.ts +44 -0
- package/lib/types/Environment.d.ts +11 -0
- package/lib/types/EnvironmentManager.d.ts +37 -0
- package/lib/types/IdentifierRegistry.d.ts +6 -0
- package/lib/types/InternalConfig.d.ts +24 -0
- package/lib/types/PackagerRunner.d.ts +80 -0
- package/lib/types/ReporterRunner.d.ts +25 -0
- package/lib/types/RequestTracker.d.ts +385 -0
- package/lib/types/SymbolPropagation.d.ts +11 -0
- package/lib/types/TargetDescriptor.schema.d.ts +5 -0
- package/lib/types/Transformation.d.ts +72 -0
- package/lib/types/UncommittedAsset.d.ts +61 -0
- package/lib/types/Validation.d.ts +37 -0
- package/lib/types/applyRuntimes.d.ts +25 -0
- package/lib/types/assetUtils.d.ts +42 -0
- package/lib/types/atlaspack-v3/AtlaspackV3.d.ts +26 -0
- package/lib/types/atlaspack-v3/NapiWorkerPool.d.ts +12 -0
- package/lib/types/atlaspack-v3/fs.d.ts +12 -0
- package/lib/types/atlaspack-v3/index.d.ts +5 -0
- package/lib/types/atlaspack-v3/jsCallable.d.ts +1 -0
- package/lib/types/atlaspack-v3/worker/compat/asset-symbols.d.ts +51 -0
- package/lib/types/atlaspack-v3/worker/compat/bitflags.d.ts +15 -0
- package/lib/types/atlaspack-v3/worker/compat/dependency.d.ts +25 -0
- package/lib/types/atlaspack-v3/worker/compat/environment.d.ts +27 -0
- package/{src/atlaspack-v3/worker/compat/index.js → lib/types/atlaspack-v3/worker/compat/index.d.ts} +0 -1
- package/lib/types/atlaspack-v3/worker/compat/mutable-asset.d.ts +49 -0
- package/lib/types/atlaspack-v3/worker/compat/plugin-config.d.ts +37 -0
- package/lib/types/atlaspack-v3/worker/compat/plugin-logger.d.ts +9 -0
- package/lib/types/atlaspack-v3/worker/compat/plugin-options.d.ts +22 -0
- package/lib/types/atlaspack-v3/worker/compat/plugin-tracer.d.ts +5 -0
- package/lib/types/atlaspack-v3/worker/compat/target.d.ts +11 -0
- package/lib/types/atlaspack-v3/worker/worker.d.ts +58 -0
- package/lib/types/constants.d.ts +13 -0
- package/lib/types/dumpGraphToGraphViz.d.ts +10 -0
- package/lib/types/index.d.ts +8 -0
- package/lib/types/loadAtlaspackPlugin.d.ts +8 -0
- package/lib/types/loadDotEnv.d.ts +3 -0
- package/lib/types/projectPath.d.ts +19 -0
- package/lib/types/public/Asset.d.ts +74 -0
- package/lib/types/public/Bundle.d.ts +45 -0
- package/lib/types/public/BundleGraph.d.ts +70 -0
- package/lib/types/public/BundleGroup.d.ts +12 -0
- package/lib/types/public/Config.d.ts +75 -0
- package/lib/types/public/Dependency.d.ts +32 -0
- package/lib/types/public/Environment.d.ts +34 -0
- package/lib/types/public/MutableBundleGraph.d.ts +26 -0
- package/lib/types/public/PluginOptions.d.ts +25 -0
- package/lib/types/public/Symbols.d.ts +81 -0
- package/lib/types/public/Target.d.ts +16 -0
- package/lib/types/registerCoreWithSerializer.d.ts +2 -0
- package/lib/types/requests/AssetGraphRequest.d.ts +74 -0
- package/lib/types/requests/AssetGraphRequestRust.d.ts +21 -0
- package/lib/types/requests/AssetRequest.d.ts +16 -0
- package/lib/types/requests/AtlaspackBuildRequest.d.ts +29 -0
- package/lib/types/requests/AtlaspackConfigRequest.d.ts +45 -0
- package/lib/types/requests/BundleGraphRequest.d.ts +28 -0
- package/lib/types/requests/ConfigRequest.d.ts +59 -0
- package/lib/types/requests/DevDepRequest.d.ts +30 -0
- package/lib/types/requests/EntryRequest.d.ts +36 -0
- package/lib/types/requests/PackageRequest.d.ts +27 -0
- package/lib/types/requests/PathRequest.d.ts +48 -0
- package/lib/types/requests/TargetRequest.d.ts +48 -0
- package/lib/types/requests/ValidationRequest.d.ts +20 -0
- package/lib/types/requests/WriteBundleRequest.d.ts +28 -0
- package/lib/types/requests/WriteBundlesRequest.d.ts +26 -0
- package/lib/types/requests/asset-graph-diff.d.ts +1 -0
- package/lib/types/requests/asset-graph-dot.d.ts +9 -0
- package/lib/types/resolveOptions.d.ts +3 -0
- package/lib/types/rustWorkerThreadDylibHack.d.ts +9 -0
- package/lib/types/serializerCore.browser.d.ts +3 -0
- package/lib/types/summarizeRequest.d.ts +10 -0
- package/lib/types/types.d.ts +493 -0
- package/lib/types/utils.d.ts +23 -0
- package/lib/types/worker.d.ts +44 -0
- package/lib/types.js +8 -1
- package/lib/utils.js +17 -2
- package/lib/worker.js +29 -13
- package/package.json +24 -34
- package/src/{AssetGraph.js → AssetGraph.ts} +156 -52
- package/src/{Atlaspack.js → Atlaspack.ts} +113 -60
- package/src/{AtlaspackConfig.schema.js → AtlaspackConfig.schema.ts} +16 -19
- package/src/{AtlaspackConfig.js → AtlaspackConfig.ts} +78 -54
- package/src/{BundleGraph.js → BundleGraph.ts} +213 -133
- package/src/{CommittedAsset.js → CommittedAsset.ts} +14 -12
- package/src/{Dependency.js → Dependency.ts} +59 -42
- package/src/{Environment.js → Environment.ts} +24 -15
- package/src/EnvironmentManager.ts +154 -0
- package/src/{IdentifierRegistry.js → IdentifierRegistry.ts} +1 -4
- package/src/{InternalConfig.js → InternalConfig.ts} +22 -23
- package/src/{PackagerRunner.js → PackagerRunner.ts} +149 -81
- package/src/{ReporterRunner.js → ReporterRunner.ts} +13 -18
- package/src/{RequestTracker.js → RequestTracker.ts} +558 -336
- package/src/{SymbolPropagation.js → SymbolPropagation.ts} +137 -39
- package/src/{TargetDescriptor.schema.js → TargetDescriptor.schema.ts} +7 -1
- package/src/{Transformation.js → Transformation.ts} +67 -61
- package/src/{UncommittedAsset.js → UncommittedAsset.ts} +57 -36
- package/src/{Validation.js → Validation.ts} +32 -17
- package/src/{applyRuntimes.js → applyRuntimes.ts} +35 -26
- package/src/{assetUtils.js → assetUtils.ts} +47 -35
- package/src/atlaspack-v3/AtlaspackV3.ts +122 -0
- package/src/atlaspack-v3/{NapiWorkerPool.js → NapiWorkerPool.ts} +10 -5
- package/src/atlaspack-v3/{fs.js → fs.ts} +3 -4
- package/src/atlaspack-v3/{index.js → index.ts} +2 -4
- package/src/atlaspack-v3/jsCallable.ts +14 -0
- package/src/atlaspack-v3/worker/compat/{asset-symbols.js → asset-symbols.ts} +40 -30
- package/src/atlaspack-v3/worker/compat/{bitflags.js → bitflags.ts} +9 -10
- package/src/atlaspack-v3/worker/compat/{dependency.js → dependency.ts} +12 -12
- package/src/atlaspack-v3/worker/compat/{environment.js → environment.ts} +13 -9
- package/src/atlaspack-v3/worker/compat/index.ts +9 -0
- package/src/atlaspack-v3/worker/compat/{mutable-asset.js → mutable-asset.ts} +20 -19
- package/src/atlaspack-v3/worker/compat/{plugin-config.js → plugin-config.ts} +27 -26
- package/src/atlaspack-v3/worker/compat/{plugin-logger.js → plugin-logger.ts} +0 -2
- package/src/atlaspack-v3/worker/compat/{plugin-options.js → plugin-options.ts} +4 -5
- package/src/atlaspack-v3/worker/compat/{plugin-tracer.js → plugin-tracer.ts} +2 -2
- package/src/atlaspack-v3/worker/compat/{target.js → target.ts} +3 -4
- package/src/atlaspack-v3/worker/index.js +2 -1
- package/src/atlaspack-v3/worker/{worker.js → worker.ts} +94 -65
- package/src/{constants.js → constants.ts} +0 -3
- package/src/{dumpGraphToGraphViz.js → dumpGraphToGraphViz.ts} +73 -28
- package/src/index.ts +18 -0
- package/src/{loadAtlaspackPlugin.js → loadAtlaspackPlugin.ts} +8 -9
- package/src/{loadDotEnv.js → loadDotEnv.ts} +2 -2
- package/src/{projectPath.js → projectPath.ts} +20 -9
- package/src/public/{Asset.js → Asset.ts} +40 -27
- package/src/public/{Bundle.js → Bundle.ts} +28 -29
- package/src/public/{BundleGraph.js → BundleGraph.ts} +81 -50
- package/src/public/{BundleGroup.js → BundleGroup.ts} +7 -10
- package/src/public/{Config.js → Config.ts} +171 -33
- package/src/public/{Dependency.js → Dependency.ts} +20 -17
- package/src/public/{Environment.js → Environment.ts} +28 -17
- package/src/public/{MutableBundleGraph.js → MutableBundleGraph.ts} +55 -24
- package/src/public/{PluginOptions.js → PluginOptions.ts} +6 -6
- package/src/public/{Symbols.js → Symbols.ts} +75 -36
- package/src/public/{Target.js → Target.ts} +10 -8
- package/src/{registerCoreWithSerializer.js → registerCoreWithSerializer.ts} +9 -7
- package/src/requests/{AssetGraphRequest.js → AssetGraphRequest.ts} +83 -48
- package/src/requests/{AssetGraphRequestRust.js → AssetGraphRequestRust.ts} +36 -29
- package/src/requests/{AssetRequest.js → AssetRequest.ts} +24 -18
- package/src/requests/{AtlaspackBuildRequest.js → AtlaspackBuildRequest.ts} +30 -31
- package/src/requests/{AtlaspackConfigRequest.js → AtlaspackConfigRequest.ts} +58 -51
- package/src/requests/{BundleGraphRequest.js → BundleGraphRequest.ts} +66 -57
- package/src/requests/{ConfigRequest.js → ConfigRequest.ts} +71 -50
- package/src/requests/{DevDepRequest.js → DevDepRequest.ts} +60 -35
- package/src/requests/{EntryRequest.js → EntryRequest.ts} +36 -31
- package/src/requests/{PackageRequest.js → PackageRequest.ts} +21 -21
- package/src/requests/{PathRequest.js → PathRequest.ts} +47 -37
- package/src/requests/{TargetRequest.js → TargetRequest.ts} +259 -179
- package/src/requests/{ValidationRequest.js → ValidationRequest.ts} +18 -17
- package/src/requests/{WriteBundleRequest.js → WriteBundleRequest.ts} +77 -49
- package/src/requests/{WriteBundlesRequest.js → WriteBundlesRequest.ts} +77 -34
- package/src/requests/{asset-graph-diff.js → asset-graph-diff.ts} +14 -14
- package/src/requests/{asset-graph-dot.js → asset-graph-dot.ts} +8 -12
- package/src/{resolveOptions.js → resolveOptions.ts} +56 -24
- package/src/{rustWorkerThreadDylibHack.js → rustWorkerThreadDylibHack.ts} +1 -4
- package/src/{serializerCore.browser.js → serializerCore.browser.ts} +2 -3
- package/src/{summarizeRequest.js → summarizeRequest.ts} +17 -5
- package/src/types.ts +647 -0
- package/src/{utils.js → utils.ts} +52 -21
- package/src/{worker.js → worker.ts} +49 -41
- package/test/{AssetGraph.test.js → AssetGraph.test.ts} +37 -8
- package/test/{Atlaspack.test.js → Atlaspack.test.ts} +5 -10
- package/test/{AtlaspackConfig.test.js → AtlaspackConfig.test.ts} +0 -5
- package/test/{AtlaspackConfigRequest.test.js → AtlaspackConfigRequest.test.ts} +3 -15
- package/test/{BundleGraph.test.js → BundleGraph.test.ts} +8 -13
- package/test/{Dependency.test.js → Dependency.test.ts} +2 -3
- package/test/{EntryRequest.test.js → EntryRequest.test.ts} +1 -6
- package/test/Environment.test.ts +153 -0
- package/test/EnvironmentManager.test.ts +188 -0
- package/test/{IdentifierRegistry.test.js → IdentifierRegistry.test.ts} +2 -4
- package/test/{InternalAsset.test.js → InternalAsset.test.ts} +2 -7
- package/test/PackagerRunner.test.ts +0 -0
- package/test/{PublicAsset.test.js → PublicAsset.test.ts} +2 -7
- package/test/{PublicBundle.test.js → PublicBundle.test.ts} +1 -2
- package/test/{PublicDependency.test.js → PublicDependency.test.ts} +0 -2
- package/test/PublicEnvironment.test.ts +49 -0
- package/test/{PublicMutableBundleGraph.test.js → PublicMutableBundleGraph.test.ts} +6 -11
- package/test/{RequestTracker.test.js → RequestTracker.test.ts} +314 -59
- package/test/{SymbolPropagation.test.js → SymbolPropagation.test.ts} +124 -74
- package/test/{TargetRequest.test.js → TargetRequest.test.ts} +54 -92
- package/test/public/Config.test.ts +104 -0
- package/test/requests/{AssetGraphRequestRust.test.js → AssetGraphRequestRust.test.ts} +163 -134
- package/test/requests/{ConfigRequest.test.js → ConfigRequest.test.ts} +202 -13
- package/test/requests/{DevDepRequest.test.js → DevDepRequest.test.ts} +0 -2
- package/test/{test-utils.js → test-utils.ts} +4 -11
- package/test/{utils.test.js → utils.test.ts} +1 -3
- package/tsconfig.json +57 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/index.d.ts +0 -30
- package/src/atlaspack-v3/AtlaspackV3.js +0 -87
- package/src/atlaspack-v3/jsCallable.js +0 -18
- package/src/index.js +0 -13
- package/src/types.js +0 -600
- package/test/Environment.test.js +0 -119
- package/test/PackagerRunner.test.js +0 -27
- package/test/PublicEnvironment.test.js +0 -27
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
// @flow strict-local
|
|
2
|
-
|
|
3
1
|
import type {
|
|
4
2
|
GraphVisitor,
|
|
5
3
|
FilePath,
|
|
6
|
-
Symbol,
|
|
7
4
|
TraversalActions,
|
|
8
5
|
BundleBehavior as IBundleBehavior,
|
|
9
6
|
ConditionMeta,
|
|
7
|
+
Symbol,
|
|
10
8
|
} from '@atlaspack/types';
|
|
11
9
|
import type {
|
|
12
10
|
ContentKey,
|
|
@@ -24,7 +22,6 @@ import type {
|
|
|
24
22
|
BundleNode,
|
|
25
23
|
Dependency,
|
|
26
24
|
DependencyNode,
|
|
27
|
-
Environment,
|
|
28
25
|
InternalSourceLocation,
|
|
29
26
|
Target,
|
|
30
27
|
Condition,
|
|
@@ -49,6 +46,8 @@ import {ISOLATED_ENVS} from './public/Environment';
|
|
|
49
46
|
import {fromProjectPath, fromProjectPathRelative} from './projectPath';
|
|
50
47
|
import {HASH_REF_PREFIX} from './constants';
|
|
51
48
|
import {getFeatureFlag} from '@atlaspack/feature-flags';
|
|
49
|
+
import {fromEnvironmentId} from './EnvironmentManager';
|
|
50
|
+
import type {EnvironmentRef} from './EnvironmentManager';
|
|
52
51
|
|
|
53
52
|
export const bundleGraphEdgeTypes = {
|
|
54
53
|
// A lack of an edge type indicates to follow the edge while traversing
|
|
@@ -76,46 +75,46 @@ export const bundleGraphEdgeTypes = {
|
|
|
76
75
|
// This type is used to mark an edge between a bundle and a conditional bundle.
|
|
77
76
|
// This allows efficient discovery of conditional bundles in packaging
|
|
78
77
|
conditional: 5,
|
|
78
|
+
} as const;
|
|
79
|
+
|
|
80
|
+
export type BundleGraphEdgeType =
|
|
81
|
+
(typeof bundleGraphEdgeTypes)[keyof typeof bundleGraphEdgeTypes];
|
|
82
|
+
|
|
83
|
+
type InternalSymbolResolution = {
|
|
84
|
+
asset: Asset;
|
|
85
|
+
exportSymbol: string;
|
|
86
|
+
symbol: Symbol | null | undefined | false;
|
|
87
|
+
loc: InternalSourceLocation | null | undefined;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
type InternalExportSymbolResolution = InternalSymbolResolution & {
|
|
91
|
+
readonly exportAs: Symbol | string;
|
|
79
92
|
};
|
|
80
93
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
publicIdByAssetId: Map<string, string>,
|
|
100
|
-
conditions: Map<string, Condition>,
|
|
101
|
-
|};
|
|
102
|
-
|
|
103
|
-
type SerializedBundleGraph = {|
|
|
104
|
-
$$raw: true,
|
|
105
|
-
graph: SerializedContentGraph<BundleGraphNode, BundleGraphEdgeType>,
|
|
106
|
-
bundleContentHashes: Map<string, string>,
|
|
107
|
-
assetPublicIds: Set<string>,
|
|
108
|
-
publicIdByAssetId: Map<string, string>,
|
|
109
|
-
conditions: Map<string, Condition>,
|
|
110
|
-
|};
|
|
111
|
-
|
|
112
|
-
function makeReadOnlySet<T>(set: Set<T>): $ReadOnlySet<T> {
|
|
94
|
+
type BundleGraphOpts = {
|
|
95
|
+
graph: ContentGraphOpts<BundleGraphNode, BundleGraphEdgeType>;
|
|
96
|
+
bundleContentHashes: Map<string, string>;
|
|
97
|
+
assetPublicIds: Set<string>;
|
|
98
|
+
publicIdByAssetId: Map<string, string>;
|
|
99
|
+
conditions: Map<string, Condition>;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
type SerializedBundleGraph = {
|
|
103
|
+
$$raw: true;
|
|
104
|
+
graph: SerializedContentGraph<BundleGraphNode, BundleGraphEdgeType>;
|
|
105
|
+
bundleContentHashes: Map<string, string>;
|
|
106
|
+
assetPublicIds: Set<string>;
|
|
107
|
+
publicIdByAssetId: Map<string, string>;
|
|
108
|
+
conditions: Map<string, Condition>;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
function makeReadOnlySet<T>(set: Set<T>): ReadonlySet<T> {
|
|
113
112
|
return new Proxy(set, {
|
|
114
|
-
get(target
|
|
113
|
+
get(target: Set<T>, property: string) {
|
|
115
114
|
if (property === 'delete' || property === 'add' || property === 'clear') {
|
|
116
115
|
return undefined;
|
|
117
116
|
} else {
|
|
118
|
-
//
|
|
117
|
+
// @ts-expect-error TS7053
|
|
119
118
|
let value = target[property];
|
|
120
119
|
return typeof value === 'function' ? value.bind(target) : value;
|
|
121
120
|
}
|
|
@@ -155,13 +154,13 @@ export default class BundleGraph {
|
|
|
155
154
|
assetPublicIds,
|
|
156
155
|
bundleContentHashes,
|
|
157
156
|
conditions,
|
|
158
|
-
}: {
|
|
159
|
-
graph: ContentGraph<BundleGraphNode, BundleGraphEdgeType
|
|
160
|
-
publicIdByAssetId: Map<string, string
|
|
161
|
-
assetPublicIds: Set<string
|
|
162
|
-
bundleContentHashes: Map<string, string
|
|
163
|
-
conditions: Map<string, Condition
|
|
164
|
-
|
|
157
|
+
}: {
|
|
158
|
+
graph: ContentGraph<BundleGraphNode, BundleGraphEdgeType>;
|
|
159
|
+
publicIdByAssetId: Map<string, string>;
|
|
160
|
+
assetPublicIds: Set<string>;
|
|
161
|
+
bundleContentHashes: Map<string, string>;
|
|
162
|
+
conditions: Map<string, Condition>;
|
|
163
|
+
}) {
|
|
165
164
|
this._graph = graph;
|
|
166
165
|
this._assetPublicIds = assetPublicIds;
|
|
167
166
|
this._publicIdByAssetId = publicIdByAssetId;
|
|
@@ -219,8 +218,8 @@ export default class BundleGraph {
|
|
|
219
218
|
// code need to be mapped to the "real" dependencies, so we need access to a map of placeholders
|
|
220
219
|
// to dependencies
|
|
221
220
|
const dep = node.value;
|
|
222
|
-
//
|
|
223
|
-
const placeholder: string |
|
|
221
|
+
// @ts-expect-error TS2322
|
|
222
|
+
const placeholder: string | undefined = dep.meta?.placeholder;
|
|
224
223
|
if (placeholder != null) {
|
|
225
224
|
placeholderToDependency.set(placeholder, dep);
|
|
226
225
|
}
|
|
@@ -228,7 +227,7 @@ export default class BundleGraph {
|
|
|
228
227
|
});
|
|
229
228
|
|
|
230
229
|
let walkVisited = new Set();
|
|
231
|
-
function walk(nodeId) {
|
|
230
|
+
function walk(nodeId: NodeId) {
|
|
232
231
|
if (walkVisited.has(nodeId)) return;
|
|
233
232
|
walkVisited.add(nodeId);
|
|
234
233
|
|
|
@@ -237,8 +236,7 @@ export default class BundleGraph {
|
|
|
237
236
|
if (getFeatureFlag('conditionalBundlingApi') && node.type === 'asset') {
|
|
238
237
|
const asset = node.value;
|
|
239
238
|
if (Array.isArray(asset.meta.conditions)) {
|
|
240
|
-
|
|
241
|
-
for (const condition of (asset.meta.conditions: ConditionMeta[])) {
|
|
239
|
+
for (const condition of asset.meta.conditions as ConditionMeta[]) {
|
|
242
240
|
// Resolve the placeholders that were attached to the asset in JSTransformer to dependencies,
|
|
243
241
|
// as well as create a public id for the condition.
|
|
244
242
|
const {
|
|
@@ -246,10 +244,9 @@ export default class BundleGraph {
|
|
|
246
244
|
ifTruePlaceholder,
|
|
247
245
|
ifFalsePlaceholder,
|
|
248
246
|
}: {
|
|
249
|
-
key: string
|
|
250
|
-
ifTruePlaceholder: string
|
|
251
|
-
ifFalsePlaceholder: string
|
|
252
|
-
...
|
|
247
|
+
key: string;
|
|
248
|
+
ifTruePlaceholder: string;
|
|
249
|
+
ifFalsePlaceholder: string;
|
|
253
250
|
} = condition;
|
|
254
251
|
|
|
255
252
|
const condHash = hashString(
|
|
@@ -283,7 +280,7 @@ export default class BundleGraph {
|
|
|
283
280
|
if (
|
|
284
281
|
node.type === 'dependency' &&
|
|
285
282
|
node.value.symbols != null &&
|
|
286
|
-
node.value.env.shouldScopeHoist &&
|
|
283
|
+
fromEnvironmentId(node.value.env).shouldScopeHoist &&
|
|
287
284
|
// Disable in dev mode because this feature is at odds with safeToIncrementallyBundle
|
|
288
285
|
isProduction
|
|
289
286
|
) {
|
|
@@ -333,7 +330,7 @@ export default class BundleGraph {
|
|
|
333
330
|
// Don't retarget because this cannot be resolved without also changing the asset symbols
|
|
334
331
|
// (and the asset content itself).
|
|
335
332
|
[...targets].every(
|
|
336
|
-
([, t]) => new Set([...t.values()]).size === t.size,
|
|
333
|
+
([, t]: [any, any]) => new Set([...t.values()]).size === t.size,
|
|
337
334
|
)
|
|
338
335
|
) {
|
|
339
336
|
let isReexportAll = nodeValueSymbols.get('*')?.local === '*';
|
|
@@ -351,13 +348,15 @@ export default class BundleGraph {
|
|
|
351
348
|
value: {
|
|
352
349
|
...node.value,
|
|
353
350
|
symbols: new Map(
|
|
354
|
-
|
|
351
|
+
// @ts-expect-error TS2769
|
|
352
|
+
[...nodeValueSymbols].filter(([k]: [any]) =>
|
|
355
353
|
externalSymbols.has(k),
|
|
356
354
|
),
|
|
357
355
|
),
|
|
358
356
|
},
|
|
359
357
|
usedSymbolsUp: new Map(
|
|
360
|
-
|
|
358
|
+
// @ts-expect-error TS2769
|
|
359
|
+
[...node.usedSymbolsUp].filter(([k]: [any]) =>
|
|
361
360
|
externalSymbols.has(k),
|
|
362
361
|
),
|
|
363
362
|
),
|
|
@@ -365,7 +364,7 @@ export default class BundleGraph {
|
|
|
365
364
|
excluded: externalSymbols.size === 0,
|
|
366
365
|
}),
|
|
367
366
|
},
|
|
368
|
-
...[...targets].map(([asset, target]) => {
|
|
367
|
+
...[...targets].map(([asset, target]: [any, any]) => {
|
|
369
368
|
let newNodeId = hashString(
|
|
370
369
|
node.id + [...target.keys()].join(','),
|
|
371
370
|
);
|
|
@@ -421,8 +420,9 @@ export default class BundleGraph {
|
|
|
421
420
|
}
|
|
422
421
|
let usedSymbolsUp = new Map(
|
|
423
422
|
[...node.usedSymbolsUp]
|
|
424
|
-
|
|
425
|
-
.
|
|
423
|
+
// @ts-expect-error TS2769
|
|
424
|
+
.filter(([k]: [any]) => target.has(k) || k === '*')
|
|
425
|
+
.map(([k, v]: [any, any]) => [target.get(k) ?? k, v]),
|
|
426
426
|
);
|
|
427
427
|
return {
|
|
428
428
|
asset,
|
|
@@ -478,6 +478,7 @@ export default class BundleGraph {
|
|
|
478
478
|
}
|
|
479
479
|
walk(nullthrows(assetGraph.rootNodeId));
|
|
480
480
|
|
|
481
|
+
// @ts-expect-error TS2488
|
|
481
482
|
for (let edge of assetGraph.getAllEdges()) {
|
|
482
483
|
if (assetGroupIds.has(edge.from)) {
|
|
483
484
|
continue;
|
|
@@ -502,10 +503,22 @@ export default class BundleGraph {
|
|
|
502
503
|
continue;
|
|
503
504
|
}
|
|
504
505
|
|
|
505
|
-
let to: Array<NodeId> = dependencies.get(edge.to)?.map(
|
|
506
|
+
let to: Array<NodeId> = dependencies.get(edge.to)?.map(
|
|
507
|
+
(
|
|
508
|
+
v:
|
|
509
|
+
| {
|
|
510
|
+
asset: null;
|
|
511
|
+
dep: NodeId;
|
|
512
|
+
}
|
|
513
|
+
| {
|
|
514
|
+
asset: ContentKey;
|
|
515
|
+
dep: NodeId;
|
|
516
|
+
},
|
|
517
|
+
) => v.dep,
|
|
518
|
+
) ??
|
|
506
519
|
assetGroupIds
|
|
507
520
|
.get(edge.to)
|
|
508
|
-
?.map((id) =>
|
|
521
|
+
?.map((id: NodeId) =>
|
|
509
522
|
nullthrows(assetGraphNodeIdToBundleGraphNodeId.get(id)),
|
|
510
523
|
) ?? [nullthrows(assetGraphNodeIdToBundleGraphNodeId.get(edge.to))];
|
|
511
524
|
|
|
@@ -549,29 +562,32 @@ export default class BundleGraph {
|
|
|
549
562
|
|
|
550
563
|
createBundle(
|
|
551
564
|
opts:
|
|
552
|
-
| {
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
565
|
+
| {
|
|
566
|
+
readonly entryAsset: Asset;
|
|
567
|
+
readonly bundleRoots?: Array<Asset>;
|
|
568
|
+
readonly target: Target;
|
|
569
|
+
readonly needsStableName?: boolean | null | undefined;
|
|
570
|
+
readonly bundleBehavior?: IBundleBehavior | null | undefined;
|
|
571
|
+
readonly shouldContentHash: boolean;
|
|
572
|
+
readonly env: EnvironmentRef;
|
|
573
|
+
}
|
|
574
|
+
| {
|
|
575
|
+
readonly type: string;
|
|
576
|
+
readonly env: EnvironmentRef;
|
|
577
|
+
readonly uniqueKey: string;
|
|
578
|
+
readonly target: Target;
|
|
579
|
+
readonly needsStableName?: boolean | null | undefined;
|
|
580
|
+
readonly bundleBehavior?: IBundleBehavior | null | undefined;
|
|
581
|
+
readonly isSplittable?: boolean | null | undefined;
|
|
582
|
+
readonly pipeline?: string | null | undefined;
|
|
583
|
+
readonly shouldContentHash: boolean;
|
|
584
|
+
},
|
|
571
585
|
): Bundle {
|
|
586
|
+
// @ts-expect-error TS2339
|
|
572
587
|
let {entryAsset, target} = opts;
|
|
573
588
|
let bundleId = hashString(
|
|
574
589
|
'bundle:' +
|
|
590
|
+
// @ts-expect-error TS2339
|
|
575
591
|
(opts.entryAsset ? opts.entryAsset.id : opts.uniqueKey) +
|
|
576
592
|
fromProjectPathRelative(target.distDir) +
|
|
577
593
|
(opts.bundleBehavior ?? ''),
|
|
@@ -603,19 +619,24 @@ export default class BundleGraph {
|
|
|
603
619
|
hashReference: opts.shouldContentHash
|
|
604
620
|
? HASH_REF_PREFIX + bundleId
|
|
605
621
|
: bundleId.slice(-8),
|
|
622
|
+
// @ts-expect-error TS2339
|
|
606
623
|
type: opts.entryAsset ? opts.entryAsset.type : opts.type,
|
|
607
624
|
env: opts.env,
|
|
608
625
|
entryAssetIds: entryAsset ? [entryAsset.id] : [],
|
|
609
626
|
mainEntryId: entryAsset?.id,
|
|
627
|
+
// @ts-expect-error TS2339
|
|
610
628
|
pipeline: opts.entryAsset ? opts.entryAsset.pipeline : opts.pipeline,
|
|
611
629
|
needsStableName: opts.needsStableName,
|
|
612
630
|
bundleBehavior:
|
|
613
631
|
opts.bundleBehavior != null
|
|
614
632
|
? BundleBehavior[opts.bundleBehavior]
|
|
615
633
|
: null,
|
|
634
|
+
// @ts-expect-error TS2339
|
|
616
635
|
isSplittable: opts.entryAsset
|
|
617
|
-
?
|
|
618
|
-
|
|
636
|
+
? // @ts-expect-error TS2339
|
|
637
|
+
opts.entryAsset.isBundleSplittable
|
|
638
|
+
: // @ts-expect-error TS2339
|
|
639
|
+
opts.isSplittable,
|
|
619
640
|
isPlaceholder,
|
|
620
641
|
target,
|
|
621
642
|
name: null,
|
|
@@ -626,9 +647,11 @@ export default class BundleGraph {
|
|
|
626
647
|
|
|
627
648
|
let bundleNodeId = this._graph.addNodeByContentKey(bundleId, bundleNode);
|
|
628
649
|
|
|
650
|
+
// @ts-expect-error TS2339
|
|
629
651
|
if (opts.entryAsset) {
|
|
630
652
|
this._graph.addEdge(
|
|
631
653
|
bundleNodeId,
|
|
654
|
+
// @ts-expect-error TS2339
|
|
632
655
|
this._graph.getNodeIdByContentKey(opts.entryAsset.id),
|
|
633
656
|
);
|
|
634
657
|
}
|
|
@@ -661,10 +684,13 @@ export default class BundleGraph {
|
|
|
661
684
|
for (let [bundleGroupNodeId, bundleGroupNode] of this._graph
|
|
662
685
|
.getNodeIdsConnectedFrom(dependencyNodeId)
|
|
663
686
|
.map((id) => [id, nullthrows(this._graph.getNode(id))])
|
|
664
|
-
|
|
687
|
+
// @ts-expect-error TS2769
|
|
688
|
+
.filter(([, node]: [any, any]) => node.type === 'bundle_group')) {
|
|
689
|
+
// @ts-expect-error TS2339
|
|
665
690
|
invariant(bundleGroupNode.type === 'bundle_group');
|
|
666
691
|
this._graph.addEdge(
|
|
667
692
|
bundleNodeId,
|
|
693
|
+
// @ts-expect-error TS2345
|
|
668
694
|
bundleGroupNodeId,
|
|
669
695
|
bundleGraphEdgeTypes.bundle,
|
|
670
696
|
);
|
|
@@ -693,7 +719,7 @@ export default class BundleGraph {
|
|
|
693
719
|
addAssetGraphToBundle(
|
|
694
720
|
asset: Asset,
|
|
695
721
|
bundle: Bundle,
|
|
696
|
-
shouldSkipDependency: (Dependency) => boolean = (d) =>
|
|
722
|
+
shouldSkipDependency: (arg1: Dependency) => boolean = (d: Dependency) =>
|
|
697
723
|
this.isDependencySkipped(d),
|
|
698
724
|
) {
|
|
699
725
|
let assetNodeId = this._graph.getNodeIdByContentKey(asset.id);
|
|
@@ -726,10 +752,13 @@ export default class BundleGraph {
|
|
|
726
752
|
for (let [bundleGroupNodeId, bundleGroupNode] of this._graph
|
|
727
753
|
.getNodeIdsConnectedFrom(nodeId)
|
|
728
754
|
.map((id) => [id, nullthrows(this._graph.getNode(id))])
|
|
729
|
-
|
|
755
|
+
// @ts-expect-error TS2769
|
|
756
|
+
.filter(([, node]: [any, any]) => node.type === 'bundle_group')) {
|
|
757
|
+
// @ts-expect-error TS2339
|
|
730
758
|
invariant(bundleGroupNode.type === 'bundle_group');
|
|
731
759
|
this._graph.addEdge(
|
|
732
760
|
bundleNodeId,
|
|
761
|
+
// @ts-expect-error TS2345
|
|
733
762
|
bundleGroupNodeId,
|
|
734
763
|
bundleGraphEdgeTypes.bundle,
|
|
735
764
|
);
|
|
@@ -769,7 +798,7 @@ export default class BundleGraph {
|
|
|
769
798
|
addEntryToBundle(
|
|
770
799
|
asset: Asset,
|
|
771
800
|
bundle: Bundle,
|
|
772
|
-
shouldSkipDependency?: (Dependency) => boolean,
|
|
801
|
+
shouldSkipDependency?: (arg1: Dependency) => boolean,
|
|
773
802
|
) {
|
|
774
803
|
this.addAssetGraphToBundle(asset, bundle, shouldSkipDependency);
|
|
775
804
|
if (!bundle.entryAssetIds.includes(asset.id)) {
|
|
@@ -836,11 +865,18 @@ export default class BundleGraph {
|
|
|
836
865
|
|
|
837
866
|
resolveAsyncDependency(
|
|
838
867
|
dependency: Dependency,
|
|
839
|
-
bundle
|
|
840
|
-
):
|
|
841
|
-
| {
|
|
842
|
-
|
|
843
|
-
|
|
868
|
+
bundle?: Bundle | null,
|
|
869
|
+
):
|
|
870
|
+
| {
|
|
871
|
+
type: 'bundle_group';
|
|
872
|
+
value: BundleGroup;
|
|
873
|
+
}
|
|
874
|
+
| {
|
|
875
|
+
type: 'asset';
|
|
876
|
+
value: Asset;
|
|
877
|
+
}
|
|
878
|
+
| null
|
|
879
|
+
| undefined {
|
|
844
880
|
let depNodeId = this._graph.getNodeIdByContentKey(dependency.id);
|
|
845
881
|
let bundleNodeId =
|
|
846
882
|
bundle != null ? this._graph.getNodeIdByContentKey(bundle.id) : null;
|
|
@@ -899,7 +935,10 @@ export default class BundleGraph {
|
|
|
899
935
|
}
|
|
900
936
|
|
|
901
937
|
// eslint-disable-next-line no-unused-vars
|
|
902
|
-
getReferencedBundle(
|
|
938
|
+
getReferencedBundle(
|
|
939
|
+
dependency: Dependency,
|
|
940
|
+
fromBundle: Bundle,
|
|
941
|
+
): Bundle | null | undefined {
|
|
903
942
|
let dependencyNodeId = this._graph.getNodeIdByContentKey(dependency.id);
|
|
904
943
|
|
|
905
944
|
// Find an attached bundle via a reference edge (e.g. from createAssetReference).
|
|
@@ -931,8 +970,12 @@ export default class BundleGraph {
|
|
|
931
970
|
return this.getBundlesInBundleGroup(node.value, {
|
|
932
971
|
includeInline: true,
|
|
933
972
|
}).find((b) => {
|
|
934
|
-
|
|
935
|
-
|
|
973
|
+
if (getFeatureFlag('supportWebpackChunkName')) {
|
|
974
|
+
return b.entryAssetIds.some((id) => id === node.value.entryAssetId);
|
|
975
|
+
} else {
|
|
976
|
+
let mainEntryId = b.entryAssetIds[b.entryAssetIds.length - 1];
|
|
977
|
+
return mainEntryId != null && node.value.entryAssetId === mainEntryId;
|
|
978
|
+
}
|
|
936
979
|
});
|
|
937
980
|
}
|
|
938
981
|
}
|
|
@@ -1226,7 +1269,10 @@ export default class BundleGraph {
|
|
|
1226
1269
|
});
|
|
1227
1270
|
}
|
|
1228
1271
|
|
|
1229
|
-
getResolvedAsset(
|
|
1272
|
+
getResolvedAsset(
|
|
1273
|
+
dep: Dependency,
|
|
1274
|
+
bundle?: Bundle | null,
|
|
1275
|
+
): Asset | null | undefined {
|
|
1230
1276
|
let assets = this.getDependencyAssets(dep);
|
|
1231
1277
|
let firstAsset = assets[0];
|
|
1232
1278
|
let resolved =
|
|
@@ -1240,7 +1286,7 @@ export default class BundleGraph {
|
|
|
1240
1286
|
|
|
1241
1287
|
// If a resolution still hasn't been found, return the first referenced asset.
|
|
1242
1288
|
if (resolved == null) {
|
|
1243
|
-
let potential = [];
|
|
1289
|
+
let potential: Array<Asset> = [];
|
|
1244
1290
|
this._graph.traverse(
|
|
1245
1291
|
(nodeId, _, traversal) => {
|
|
1246
1292
|
let node = nullthrows(this._graph.getNode(nodeId));
|
|
@@ -1255,6 +1301,7 @@ export default class BundleGraph {
|
|
|
1255
1301
|
);
|
|
1256
1302
|
|
|
1257
1303
|
if (bundle) {
|
|
1304
|
+
// @ts-expect-error TS2322
|
|
1258
1305
|
resolved = potential.find((a) => a.type === bundle.type);
|
|
1259
1306
|
}
|
|
1260
1307
|
resolved ||= potential[0];
|
|
@@ -1276,7 +1323,7 @@ export default class BundleGraph {
|
|
|
1276
1323
|
bundle: Bundle,
|
|
1277
1324
|
visit: GraphVisitor<Asset, TContext>,
|
|
1278
1325
|
startAsset?: Asset,
|
|
1279
|
-
):
|
|
1326
|
+
): TContext | null | undefined {
|
|
1280
1327
|
return this.traverseBundle(
|
|
1281
1328
|
bundle,
|
|
1282
1329
|
mapVisitor((node) => (node.type === 'asset' ? node.value : null), visit),
|
|
@@ -1359,7 +1406,8 @@ export default class BundleGraph {
|
|
|
1359
1406
|
|
|
1360
1407
|
if (
|
|
1361
1408
|
descendant.type !== bundle.type ||
|
|
1362
|
-
descendant.env.context !==
|
|
1409
|
+
fromEnvironmentId(descendant.env).context !==
|
|
1410
|
+
fromEnvironmentId(bundle.env).context
|
|
1363
1411
|
) {
|
|
1364
1412
|
actions.skipChildren();
|
|
1365
1413
|
return;
|
|
@@ -1400,10 +1448,11 @@ export default class BundleGraph {
|
|
|
1400
1448
|
// If a bundle's environment is isolated, it can't access assets present
|
|
1401
1449
|
// in any ancestor bundles. Don't consider any assets reachable.
|
|
1402
1450
|
if (
|
|
1403
|
-
ISOLATED_ENVS.has(bundle.env.context) ||
|
|
1451
|
+
ISOLATED_ENVS.has(fromEnvironmentId(bundle.env).context) ||
|
|
1404
1452
|
!bundle.isSplittable ||
|
|
1405
1453
|
bundle.bundleBehavior === BundleBehavior.isolated ||
|
|
1406
|
-
bundle.bundleBehavior === BundleBehavior.inline
|
|
1454
|
+
bundle.bundleBehavior === BundleBehavior.inline ||
|
|
1455
|
+
bundle.bundleBehavior === BundleBehavior.inlineIsolated
|
|
1407
1456
|
) {
|
|
1408
1457
|
return false;
|
|
1409
1458
|
}
|
|
@@ -1420,6 +1469,7 @@ export default class BundleGraph {
|
|
|
1420
1469
|
b.id !== bundle.id &&
|
|
1421
1470
|
b.bundleBehavior !== BundleBehavior.isolated &&
|
|
1422
1471
|
b.bundleBehavior !== BundleBehavior.inline &&
|
|
1472
|
+
b.bundleBehavior !== BundleBehavior.inlineIsolated &&
|
|
1423
1473
|
this.bundleHasAsset(b, asset),
|
|
1424
1474
|
)
|
|
1425
1475
|
) {
|
|
@@ -1438,7 +1488,8 @@ export default class BundleGraph {
|
|
|
1438
1488
|
if (
|
|
1439
1489
|
bundleNode.type !== 'bundle' ||
|
|
1440
1490
|
bundleNode.value.bundleBehavior === BundleBehavior.isolated ||
|
|
1441
|
-
bundleNode.value.bundleBehavior === BundleBehavior.inline
|
|
1491
|
+
bundleNode.value.bundleBehavior === BundleBehavior.inline ||
|
|
1492
|
+
bundleNode.value.bundleBehavior === BundleBehavior.inlineIsolated
|
|
1442
1493
|
) {
|
|
1443
1494
|
return false;
|
|
1444
1495
|
}
|
|
@@ -1454,7 +1505,8 @@ export default class BundleGraph {
|
|
|
1454
1505
|
node.type === 'root' ||
|
|
1455
1506
|
(node.type === 'bundle' &&
|
|
1456
1507
|
(node.value.id === bundle.id ||
|
|
1457
|
-
node.value.env.context !==
|
|
1508
|
+
fromEnvironmentId(node.value.env).context !==
|
|
1509
|
+
fromEnvironmentId(bundle.env).context))
|
|
1458
1510
|
) {
|
|
1459
1511
|
isReachable = false;
|
|
1460
1512
|
actions.stop();
|
|
@@ -1469,6 +1521,7 @@ export default class BundleGraph {
|
|
|
1469
1521
|
b.id !== bundle.id &&
|
|
1470
1522
|
b.bundleBehavior !== BundleBehavior.isolated &&
|
|
1471
1523
|
b.bundleBehavior !== BundleBehavior.inline &&
|
|
1524
|
+
b.bundleBehavior !== BundleBehavior.inlineIsolated &&
|
|
1472
1525
|
this.bundleHasAsset(b, asset),
|
|
1473
1526
|
)
|
|
1474
1527
|
) {
|
|
@@ -1493,7 +1546,7 @@ export default class BundleGraph {
|
|
|
1493
1546
|
bundle: Bundle,
|
|
1494
1547
|
visit: GraphVisitor<AssetNode | DependencyNode, TContext>,
|
|
1495
1548
|
startAsset?: Asset,
|
|
1496
|
-
):
|
|
1549
|
+
): TContext | null | undefined {
|
|
1497
1550
|
let entries = !startAsset;
|
|
1498
1551
|
let bundleNodeId = this._graph.getNodeIdByContentKey(bundle.id);
|
|
1499
1552
|
|
|
@@ -1531,7 +1584,8 @@ export default class BundleGraph {
|
|
|
1531
1584
|
|
|
1532
1585
|
let sorted =
|
|
1533
1586
|
entries && bundle.entryAssetIds.length > 0
|
|
1534
|
-
?
|
|
1587
|
+
? // @ts-expect-error TS2345
|
|
1588
|
+
children.sort(([, a]: [any, any], [, b]: [any, any]) => {
|
|
1535
1589
|
let aIndex = bundle.entryAssetIds.indexOf(a.id);
|
|
1536
1590
|
let bIndex = bundle.entryAssetIds.indexOf(b.id);
|
|
1537
1591
|
|
|
@@ -1550,7 +1604,8 @@ export default class BundleGraph {
|
|
|
1550
1604
|
: children;
|
|
1551
1605
|
|
|
1552
1606
|
entries = false;
|
|
1553
|
-
|
|
1607
|
+
// @ts-expect-error TS2345
|
|
1608
|
+
return sorted.map(([id]: [any]) => id);
|
|
1554
1609
|
},
|
|
1555
1610
|
});
|
|
1556
1611
|
}
|
|
@@ -1558,7 +1613,7 @@ export default class BundleGraph {
|
|
|
1558
1613
|
traverse<TContext>(
|
|
1559
1614
|
visit: GraphVisitor<AssetNode | DependencyNode, TContext>,
|
|
1560
1615
|
start?: Asset,
|
|
1561
|
-
):
|
|
1616
|
+
): TContext | null | undefined {
|
|
1562
1617
|
return this._graph.filteredTraverse(
|
|
1563
1618
|
(nodeId) => {
|
|
1564
1619
|
let node = nullthrows(this._graph.getNode(nodeId));
|
|
@@ -1574,7 +1629,7 @@ export default class BundleGraph {
|
|
|
1574
1629
|
|
|
1575
1630
|
getChildBundles(bundle: Bundle): Array<Bundle> {
|
|
1576
1631
|
let siblings = new Set(this.getReferencedBundles(bundle));
|
|
1577
|
-
let bundles = [];
|
|
1632
|
+
let bundles: Array<Bundle> = [];
|
|
1578
1633
|
this.traverseBundles((b, _, actions) => {
|
|
1579
1634
|
if (bundle.id === b.id) {
|
|
1580
1635
|
return;
|
|
@@ -1591,8 +1646,8 @@ export default class BundleGraph {
|
|
|
1591
1646
|
|
|
1592
1647
|
traverseBundles<TContext>(
|
|
1593
1648
|
visit: GraphVisitor<Bundle, TContext>,
|
|
1594
|
-
startBundle
|
|
1595
|
-
):
|
|
1649
|
+
startBundle?: Bundle | null,
|
|
1650
|
+
): TContext | null | undefined {
|
|
1596
1651
|
return this._graph.filteredTraverse(
|
|
1597
1652
|
(nodeId) => {
|
|
1598
1653
|
let node = nullthrows(this._graph.getNode(nodeId));
|
|
@@ -1604,12 +1659,13 @@ export default class BundleGraph {
|
|
|
1604
1659
|
);
|
|
1605
1660
|
}
|
|
1606
1661
|
|
|
1607
|
-
getBundles(opts?: {
|
|
1608
|
-
let bundles = [];
|
|
1662
|
+
getBundles(opts?: {includeInline: boolean}): Array<Bundle> {
|
|
1663
|
+
let bundles: Array<Bundle> = [];
|
|
1609
1664
|
this.traverseBundles((bundle) => {
|
|
1610
1665
|
if (
|
|
1611
1666
|
opts?.includeInline ||
|
|
1612
|
-
bundle.bundleBehavior !== BundleBehavior.inline
|
|
1667
|
+
(bundle.bundleBehavior !== BundleBehavior.inline &&
|
|
1668
|
+
bundle.bundleBehavior !== BundleBehavior.inlineIsolated)
|
|
1613
1669
|
) {
|
|
1614
1670
|
bundles.push(bundle);
|
|
1615
1671
|
}
|
|
@@ -1679,7 +1735,9 @@ export default class BundleGraph {
|
|
|
1679
1735
|
|
|
1680
1736
|
getBundlesInBundleGroup(
|
|
1681
1737
|
bundleGroup: BundleGroup,
|
|
1682
|
-
opts?: {
|
|
1738
|
+
opts?: {
|
|
1739
|
+
includeInline: boolean;
|
|
1740
|
+
},
|
|
1683
1741
|
): Array<Bundle> {
|
|
1684
1742
|
let bundles: Set<Bundle> = new Set();
|
|
1685
1743
|
for (let bundleNodeId of this._graph.getNodeIdsConnectedFrom(
|
|
@@ -1691,7 +1749,8 @@ export default class BundleGraph {
|
|
|
1691
1749
|
let bundle = bundleNode.value;
|
|
1692
1750
|
if (
|
|
1693
1751
|
opts?.includeInline ||
|
|
1694
|
-
bundle.bundleBehavior !== BundleBehavior.inline
|
|
1752
|
+
(bundle.bundleBehavior !== BundleBehavior.inline &&
|
|
1753
|
+
bundle.bundleBehavior !== BundleBehavior.inlineIsolated)
|
|
1695
1754
|
) {
|
|
1696
1755
|
bundles.add(bundle);
|
|
1697
1756
|
}
|
|
@@ -1708,7 +1767,10 @@ export default class BundleGraph {
|
|
|
1708
1767
|
|
|
1709
1768
|
getReferencedBundles(
|
|
1710
1769
|
bundle: Bundle,
|
|
1711
|
-
opts?: {
|
|
1770
|
+
opts?: {
|
|
1771
|
+
recursive?: boolean;
|
|
1772
|
+
includeInline?: boolean;
|
|
1773
|
+
},
|
|
1712
1774
|
): Array<Bundle> {
|
|
1713
1775
|
let recursive = opts?.recursive ?? true;
|
|
1714
1776
|
let includeInline = opts?.includeInline ?? false;
|
|
@@ -1726,7 +1788,8 @@ export default class BundleGraph {
|
|
|
1726
1788
|
|
|
1727
1789
|
if (
|
|
1728
1790
|
includeInline ||
|
|
1729
|
-
node.value.bundleBehavior !== BundleBehavior.inline
|
|
1791
|
+
(node.value.bundleBehavior !== BundleBehavior.inline &&
|
|
1792
|
+
node.value.bundleBehavior !== BundleBehavior.inlineIsolated)
|
|
1730
1793
|
) {
|
|
1731
1794
|
referencedBundles.add(node.value);
|
|
1732
1795
|
}
|
|
@@ -1746,6 +1809,7 @@ export default class BundleGraph {
|
|
|
1746
1809
|
),
|
|
1747
1810
|
});
|
|
1748
1811
|
|
|
1812
|
+
// @ts-expect-error TS2322
|
|
1749
1813
|
return [...referencedBundles];
|
|
1750
1814
|
}
|
|
1751
1815
|
|
|
@@ -1768,7 +1832,7 @@ export default class BundleGraph {
|
|
|
1768
1832
|
});
|
|
1769
1833
|
}
|
|
1770
1834
|
|
|
1771
|
-
getAssetWithDependency(dep: Dependency):
|
|
1835
|
+
getAssetWithDependency(dep: Dependency): Asset | null | undefined {
|
|
1772
1836
|
if (!this._graph.hasContentKey(dep.id)) {
|
|
1773
1837
|
return null;
|
|
1774
1838
|
}
|
|
@@ -1777,6 +1841,7 @@ export default class BundleGraph {
|
|
|
1777
1841
|
let count = 0;
|
|
1778
1842
|
this._graph.forEachNodeIdConnectedTo(
|
|
1779
1843
|
this._graph.getNodeIdByContentKey(dep.id),
|
|
1844
|
+
// @ts-expect-error TS2345
|
|
1780
1845
|
(node) => {
|
|
1781
1846
|
res = node;
|
|
1782
1847
|
count += 1;
|
|
@@ -1817,16 +1882,16 @@ export default class BundleGraph {
|
|
|
1817
1882
|
|
|
1818
1883
|
filteredTraverse<TValue, TContext>(
|
|
1819
1884
|
bundleNodeId: NodeId,
|
|
1820
|
-
filter: (NodeId, TraversalActions) =>
|
|
1885
|
+
filter: (arg1: NodeId, arg2: TraversalActions) => TValue | null | undefined,
|
|
1821
1886
|
visit: GraphVisitor<TValue, TContext>,
|
|
1822
|
-
):
|
|
1887
|
+
): TContext | null | undefined {
|
|
1823
1888
|
return this._graph.filteredTraverse(filter, visit, bundleNodeId);
|
|
1824
1889
|
}
|
|
1825
1890
|
|
|
1826
1891
|
getSymbolResolution(
|
|
1827
1892
|
asset: Asset,
|
|
1828
1893
|
symbol: Symbol,
|
|
1829
|
-
boundary
|
|
1894
|
+
boundary?: Bundle | null,
|
|
1830
1895
|
): InternalSymbolResolution {
|
|
1831
1896
|
let assetOutside = boundary && !this.bundleHasAsset(boundary, asset);
|
|
1832
1897
|
|
|
@@ -1853,7 +1918,7 @@ export default class BundleGraph {
|
|
|
1853
1918
|
}
|
|
1854
1919
|
// If this is a re-export, find the original module.
|
|
1855
1920
|
let symbolLookup = new Map(
|
|
1856
|
-
[...depSymbols].map(([key, val]) => [val.local, key]),
|
|
1921
|
+
[...depSymbols].map(([key, val]: [any, any]) => [val.local, key]),
|
|
1857
1922
|
);
|
|
1858
1923
|
let depSymbol = symbolLookup.get(identifier);
|
|
1859
1924
|
if (depSymbol != null) {
|
|
@@ -1971,17 +2036,20 @@ export default class BundleGraph {
|
|
|
1971
2036
|
let result = identifier;
|
|
1972
2037
|
if (skipped) {
|
|
1973
2038
|
// ... and it was excluded (by symbol propagation) or deferred.
|
|
2039
|
+
// @ts-expect-error TS2322
|
|
1974
2040
|
result = false;
|
|
1975
2041
|
} else {
|
|
1976
2042
|
// ... and there is no single reexport, but it might still be exported:
|
|
1977
2043
|
if (found) {
|
|
1978
2044
|
// Fallback to namespace access, because of a bundle boundary.
|
|
2045
|
+
// @ts-expect-error TS2322
|
|
1979
2046
|
result = null;
|
|
1980
2047
|
} else if (result === undefined) {
|
|
1981
2048
|
// If not exported explicitly by the asset (= would have to be in * or a reexport-all) ...
|
|
1982
2049
|
if (nonStaticDependency || asset.symbols?.has('*')) {
|
|
1983
2050
|
// ... and if there are non-statically analyzable dependencies or it's a CJS asset,
|
|
1984
2051
|
// fallback to namespace access.
|
|
2052
|
+
// @ts-expect-error TS2322
|
|
1985
2053
|
result = null;
|
|
1986
2054
|
}
|
|
1987
2055
|
// (It shouldn't be possible for the symbol to be in a reexport-all and to end up here).
|
|
@@ -2019,13 +2087,13 @@ export default class BundleGraph {
|
|
|
2019
2087
|
|
|
2020
2088
|
getExportedSymbols(
|
|
2021
2089
|
asset: Asset,
|
|
2022
|
-
boundary
|
|
2090
|
+
boundary?: Bundle | null,
|
|
2023
2091
|
): Array<InternalExportSymbolResolution> {
|
|
2024
2092
|
if (!asset.symbols) {
|
|
2025
2093
|
return [];
|
|
2026
2094
|
}
|
|
2027
2095
|
|
|
2028
|
-
let symbols = [];
|
|
2096
|
+
let symbols: Array<InternalExportSymbolResolution> = [];
|
|
2029
2097
|
|
|
2030
2098
|
for (let symbol of asset.symbols.keys()) {
|
|
2031
2099
|
symbols.push({
|
|
@@ -2076,9 +2144,9 @@ export default class BundleGraph {
|
|
|
2076
2144
|
}
|
|
2077
2145
|
|
|
2078
2146
|
getInlineBundles(bundle: Bundle): Array<Bundle> {
|
|
2079
|
-
let bundles = [];
|
|
2147
|
+
let bundles: Array<Bundle> = [];
|
|
2080
2148
|
let seen = new Set();
|
|
2081
|
-
let addReferencedBundles = (bundle) => {
|
|
2149
|
+
let addReferencedBundles = (bundle: Bundle) => {
|
|
2082
2150
|
if (seen.has(bundle.id)) {
|
|
2083
2151
|
return;
|
|
2084
2152
|
}
|
|
@@ -2089,7 +2157,10 @@ export default class BundleGraph {
|
|
|
2089
2157
|
includeInline: true,
|
|
2090
2158
|
});
|
|
2091
2159
|
for (let referenced of referencedBundles) {
|
|
2092
|
-
if (
|
|
2160
|
+
if (
|
|
2161
|
+
referenced.bundleBehavior === BundleBehavior.inline ||
|
|
2162
|
+
referenced.bundleBehavior === BundleBehavior.inlineIsolated
|
|
2163
|
+
) {
|
|
2093
2164
|
bundles.push(referenced);
|
|
2094
2165
|
addReferencedBundles(referenced);
|
|
2095
2166
|
}
|
|
@@ -2099,7 +2170,10 @@ export default class BundleGraph {
|
|
|
2099
2170
|
addReferencedBundles(bundle);
|
|
2100
2171
|
|
|
2101
2172
|
this.traverseBundles((childBundle, _, traversal) => {
|
|
2102
|
-
if (
|
|
2173
|
+
if (
|
|
2174
|
+
childBundle.bundleBehavior === BundleBehavior.inline ||
|
|
2175
|
+
childBundle.bundleBehavior === BundleBehavior.inlineIsolated
|
|
2176
|
+
) {
|
|
2103
2177
|
bundles.push(childBundle);
|
|
2104
2178
|
} else if (childBundle.id !== bundle.id) {
|
|
2105
2179
|
traversal.skipChildren();
|
|
@@ -2128,7 +2202,9 @@ export default class BundleGraph {
|
|
|
2128
2202
|
hash.writeString(referencedBundle.id);
|
|
2129
2203
|
}
|
|
2130
2204
|
|
|
2131
|
-
hash.writeString(
|
|
2205
|
+
hash.writeString(
|
|
2206
|
+
JSON.stringify(objectSortedEntriesDeep(fromEnvironmentId(bundle.env))),
|
|
2207
|
+
);
|
|
2132
2208
|
return hash.finish();
|
|
2133
2209
|
}
|
|
2134
2210
|
|
|
@@ -2172,7 +2248,7 @@ export default class BundleGraph {
|
|
|
2172
2248
|
}
|
|
2173
2249
|
}
|
|
2174
2250
|
|
|
2175
|
-
getUsedSymbolsAsset(asset: Asset):
|
|
2251
|
+
getUsedSymbolsAsset(asset: Asset): ReadonlySet<Symbol> | null | undefined {
|
|
2176
2252
|
let node = this._graph.getNodeByContentKey(asset.id);
|
|
2177
2253
|
invariant(node && node.type === 'asset');
|
|
2178
2254
|
return node.value.symbols
|
|
@@ -2180,7 +2256,9 @@ export default class BundleGraph {
|
|
|
2180
2256
|
: null;
|
|
2181
2257
|
}
|
|
2182
2258
|
|
|
2183
|
-
getUsedSymbolsDependency(
|
|
2259
|
+
getUsedSymbolsDependency(
|
|
2260
|
+
dep: Dependency,
|
|
2261
|
+
): ReadonlySet<Symbol> | null | undefined {
|
|
2184
2262
|
let node = this._graph.getNodeByContentKey(dep.id);
|
|
2185
2263
|
invariant(node && node.type === 'dependency');
|
|
2186
2264
|
return node.value.symbols
|
|
@@ -2228,6 +2306,7 @@ export default class BundleGraph {
|
|
|
2228
2306
|
}
|
|
2229
2307
|
}
|
|
2230
2308
|
|
|
2309
|
+
// @ts-expect-error TS2488
|
|
2231
2310
|
for (let edge of other._graph.getAllEdges()) {
|
|
2232
2311
|
this._graph.addEdge(
|
|
2233
2312
|
nullthrows(otherGraphIdToThisNodeId.get(edge.from)),
|
|
@@ -2272,7 +2351,7 @@ export default class BundleGraph {
|
|
|
2272
2351
|
bundleGraphEdgeTypes.bundle,
|
|
2273
2352
|
);
|
|
2274
2353
|
|
|
2275
|
-
let entries = [];
|
|
2354
|
+
let entries: Array<FilePath> = [];
|
|
2276
2355
|
for (let bundleGroupId of entryBundleGroupIds) {
|
|
2277
2356
|
let bundleGroupNode = this._graph.getNode(bundleGroupId);
|
|
2278
2357
|
invariant(bundleGroupNode?.type === 'bundle_group');
|
|
@@ -2312,6 +2391,7 @@ export default class BundleGraph {
|
|
|
2312
2391
|
),
|
|
2313
2392
|
});
|
|
2314
2393
|
|
|
2394
|
+
// @ts-expect-error TS2322
|
|
2315
2395
|
return [...referencedBundles];
|
|
2316
2396
|
}
|
|
2317
2397
|
}
|