@atlaspack/core 2.16.2-canary.37 → 2.16.2-canary.371
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 +941 -0
- package/dist/AssetGraph.js +591 -0
- package/dist/Atlaspack.js +666 -0
- package/dist/AtlaspackConfig.js +324 -0
- package/dist/AtlaspackConfig.schema.js +117 -0
- package/dist/BundleGraph.js +1740 -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 +545 -0
- package/dist/ReporterRunner.js +151 -0
- package/dist/RequestTracker.js +1360 -0
- package/dist/SymbolPropagation.js +620 -0
- package/dist/TargetDescriptor.schema.js +143 -0
- package/dist/Transformation.js +514 -0
- package/dist/UncommittedAsset.js +315 -0
- package/dist/Validation.js +196 -0
- package/dist/applyRuntimes.js +383 -0
- package/dist/assetUtils.js +169 -0
- package/dist/atlaspack-v3/AtlaspackV3.js +74 -0
- package/dist/atlaspack-v3/NapiWorkerPool.js +81 -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 +98 -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 +64 -0
- package/dist/atlaspack-v3/worker/compat/plugin-logger.js +26 -0
- package/dist/atlaspack-v3/worker/compat/plugin-options.js +137 -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/side-effect-detector.js +243 -0
- package/dist/atlaspack-v3/worker/worker.js +381 -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 +371 -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 +439 -0
- package/dist/requests/AssetGraphRequestRust.js +273 -0
- package/dist/requests/AssetRequest.js +130 -0
- package/dist/requests/AtlaspackBuildRequest.js +92 -0
- package/dist/requests/AtlaspackConfigRequest.js +493 -0
- package/dist/requests/BundleGraphRequest.js +447 -0
- package/dist/requests/ConfigRequest.js +246 -0
- package/dist/requests/DevDepRequest.js +204 -0
- package/dist/requests/EntryRequest.js +314 -0
- package/dist/requests/PackageRequest.js +72 -0
- package/dist/requests/PathRequest.js +349 -0
- package/dist/requests/TargetRequest.js +1311 -0
- package/dist/requests/ValidationRequest.js +49 -0
- package/dist/requests/WriteBundleRequest.js +254 -0
- package/dist/requests/WriteBundlesRequest.js +184 -0
- package/dist/requests/asset-graph-diff.js +128 -0
- package/dist/requests/asset-graph-dot.js +131 -0
- package/dist/resolveOptions.js +269 -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 +94 -41
- package/lib/AtlaspackConfig.js +15 -3
- package/lib/AtlaspackConfig.schema.js +16 -5
- package/lib/BundleGraph.js +197 -32
- package/lib/CommittedAsset.js +7 -1
- 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 +90 -27
- package/lib/ReporterRunner.js +6 -9
- package/lib/RequestTracker.js +266 -156
- package/lib/SymbolPropagation.js +42 -18
- package/lib/TargetDescriptor.schema.js +7 -1
- package/lib/Transformation.js +66 -15
- package/lib/UncommittedAsset.js +33 -12
- package/lib/Validation.js +18 -2
- package/lib/applyRuntimes.js +96 -4
- package/lib/assetUtils.js +15 -5
- package/lib/atlaspack-v3/AtlaspackV3.js +52 -14
- package/lib/atlaspack-v3/NapiWorkerPool.js +28 -1
- 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 +31 -25
- package/lib/atlaspack-v3/worker/compat/dependency.js +4 -1
- package/lib/atlaspack-v3/worker/compat/environment.js +10 -7
- package/lib/atlaspack-v3/worker/compat/mutable-asset.js +15 -10
- package/lib/atlaspack-v3/worker/compat/plugin-config.js +13 -34
- package/lib/atlaspack-v3/worker/compat/plugin-options.js +16 -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/side-effect-detector.js +215 -0
- package/lib/atlaspack-v3/worker/worker.js +199 -71
- 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 +25 -22
- 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 +74 -27
- package/lib/requests/AssetGraphRequestRust.js +140 -64
- package/lib/requests/AssetRequest.js +23 -6
- package/lib/requests/AtlaspackBuildRequest.js +43 -4
- package/lib/requests/AtlaspackConfigRequest.js +27 -16
- package/lib/requests/BundleGraphRequest.js +41 -24
- package/lib/requests/ConfigRequest.js +53 -4
- package/lib/requests/DevDepRequest.js +31 -5
- package/lib/requests/EntryRequest.js +2 -0
- package/lib/requests/PackageRequest.js +16 -2
- package/lib/requests/PathRequest.js +24 -3
- package/lib/requests/TargetRequest.js +122 -57
- package/lib/requests/ValidationRequest.js +5 -1
- package/lib/requests/WriteBundleRequest.js +39 -11
- package/lib/requests/WriteBundlesRequest.js +51 -4
- package/lib/requests/asset-graph-diff.js +12 -7
- package/lib/requests/asset-graph-dot.js +1 -7
- package/lib/resolveOptions.js +38 -11
- 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 +53 -0
- package/lib/types/BundleGraph.d.ts +184 -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 +23 -0
- package/lib/types/PackagerRunner.d.ts +85 -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 +34 -0
- package/lib/types/atlaspack-v3/NapiWorkerPool.d.ts +13 -0
- package/lib/types/atlaspack-v3/fs.d.ts +12 -0
- package/lib/types/atlaspack-v3/index.d.ts +6 -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 +14 -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 +29 -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 +23 -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/side-effect-detector.d.ts +76 -0
- package/lib/types/atlaspack-v3/worker/worker.d.ts +80 -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 +72 -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 +76 -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 +33 -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 +67 -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 +32 -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 +495 -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 +30 -14
- package/package.json +25 -35
- package/src/{AssetGraph.js → AssetGraph.ts} +156 -52
- package/src/{Atlaspack.js → Atlaspack.ts} +134 -67
- package/src/{AtlaspackConfig.schema.js → AtlaspackConfig.schema.ts} +25 -19
- package/src/{AtlaspackConfig.js → AtlaspackConfig.ts} +78 -54
- package/src/{BundleGraph.js → BundleGraph.ts} +383 -140
- package/src/{CommittedAsset.js → CommittedAsset.ts} +15 -13
- 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} +179 -87
- package/src/{ReporterRunner.js → ReporterRunner.ts} +13 -18
- package/src/{RequestTracker.js → RequestTracker.ts} +572 -357
- package/src/{SymbolPropagation.js → SymbolPropagation.ts} +165 -57
- package/src/{TargetDescriptor.schema.js → TargetDescriptor.schema.ts} +7 -1
- package/src/{Transformation.js → Transformation.ts} +110 -65
- package/src/{UncommittedAsset.js → UncommittedAsset.ts} +60 -39
- package/src/{Validation.js → Validation.ts} +32 -17
- package/src/{applyRuntimes.js → applyRuntimes.ts} +133 -26
- package/src/{assetUtils.js → assetUtils.ts} +49 -36
- package/src/atlaspack-v3/AtlaspackV3.ts +143 -0
- package/src/atlaspack-v3/NapiWorkerPool.ts +91 -0
- package/src/atlaspack-v3/{fs.js → fs.ts} +3 -4
- package/src/atlaspack-v3/{index.js → index.ts} +3 -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.ts +102 -0
- package/src/atlaspack-v3/worker/compat/{dependency.js → dependency.ts} +13 -13
- 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} +21 -20
- package/src/atlaspack-v3/worker/compat/{plugin-config.js → plugin-config.ts} +25 -56
- 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} +19 -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/side-effect-detector.ts +298 -0
- package/src/atlaspack-v3/worker/worker.ts +531 -0
- 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} +41 -28
- package/src/public/{Bundle.js → Bundle.ts} +28 -29
- package/src/public/{BundleGraph.js → BundleGraph.ts} +103 -68
- 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} +129 -80
- package/src/requests/AssetGraphRequestRust.ts +364 -0
- package/src/requests/{AssetRequest.js → AssetRequest.ts} +24 -18
- package/src/requests/AtlaspackBuildRequest.ts +163 -0
- package/src/requests/{AtlaspackConfigRequest.js → AtlaspackConfigRequest.ts} +72 -58
- package/src/requests/{BundleGraphRequest.js → BundleGraphRequest.ts} +97 -79
- package/src/requests/{ConfigRequest.js → ConfigRequest.ts} +110 -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} +34 -22
- package/src/requests/{PathRequest.js → PathRequest.ts} +47 -37
- package/src/requests/{TargetRequest.js → TargetRequest.ts} +260 -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} +109 -37
- package/src/requests/{asset-graph-diff.js → asset-graph-diff.ts} +25 -21
- package/src/requests/{asset-graph-dot.js → asset-graph-dot.ts} +8 -12
- package/src/{resolveOptions.js → resolveOptions.ts} +59 -25
- 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 +650 -0
- package/src/{utils.js → utils.ts} +52 -21
- package/src/{worker.js → worker.ts} +50 -42
- 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} +76 -16
- 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} +66 -92
- package/test/fixtures/config-with-reporters/.parcelrc +7 -0
- package/test/fixtures/custom-targets/package.json +6 -0
- package/test/public/Config.test.ts +104 -0
- package/test/requests/AssetGraphRequestRust.test.ts +443 -0
- 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 +60 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/index.d.ts +0 -30
- package/src/atlaspack-v3/AtlaspackV3.js +0 -87
- package/src/atlaspack-v3/NapiWorkerPool.js +0 -53
- package/src/atlaspack-v3/jsCallable.js +0 -18
- package/src/atlaspack-v3/worker/compat/bitflags.js +0 -100
- package/src/atlaspack-v3/worker/worker.js +0 -362
- package/src/index.js +0 -13
- package/src/requests/AssetGraphRequestRust.js +0 -263
- package/src/requests/AtlaspackBuildRequest.js +0 -111
- 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
- package/test/requests/AssetGraphRequestRust.test.js +0 -411
|
@@ -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;
|
|
92
|
+
};
|
|
93
|
+
|
|
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>;
|
|
79
109
|
};
|
|
80
110
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
type InternalSymbolResolution = {|
|
|
84
|
-
asset: Asset,
|
|
85
|
-
exportSymbol: string,
|
|
86
|
-
symbol: ?Symbol | false,
|
|
87
|
-
loc: ?InternalSourceLocation,
|
|
88
|
-
|};
|
|
89
|
-
|
|
90
|
-
type InternalExportSymbolResolution = {|
|
|
91
|
-
...InternalSymbolResolution,
|
|
92
|
-
+exportAs: Symbol | string,
|
|
93
|
-
|};
|
|
94
|
-
|
|
95
|
-
type BundleGraphOpts = {|
|
|
96
|
-
graph: ContentGraphOpts<BundleGraphNode, BundleGraphEdgeType>,
|
|
97
|
-
bundleContentHashes: Map<string, string>,
|
|
98
|
-
assetPublicIds: Set<string>,
|
|
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> {
|
|
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
|
);
|
|
@@ -392,17 +391,28 @@ export default class BundleGraph {
|
|
|
392
391
|
local,
|
|
393
392
|
loc: reexportAllLoc,
|
|
394
393
|
});
|
|
394
|
+
|
|
395
395
|
if (node.value.sourceAssetId != null) {
|
|
396
|
-
let sourceAssetId
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
396
|
+
let sourceAssetId: NodeId;
|
|
397
|
+
|
|
398
|
+
if (getFeatureFlag('sourceAssetIdBundleGraphFix')) {
|
|
399
|
+
[sourceAssetId] =
|
|
400
|
+
assetGraph.getNodeIdsConnectedTo(nodeId);
|
|
401
|
+
} else {
|
|
402
|
+
sourceAssetId = assetGraph.getNodeIdByContentKey(
|
|
403
|
+
node.value.sourceAssetId,
|
|
404
|
+
);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
let sourceAsset = nullthrows(
|
|
408
|
+
graph.getNode(
|
|
409
|
+
nullthrows(
|
|
410
|
+
assetGraphNodeIdToBundleGraphNodeId.get(
|
|
411
|
+
sourceAssetId,
|
|
412
|
+
),
|
|
400
413
|
),
|
|
401
414
|
),
|
|
402
415
|
);
|
|
403
|
-
let sourceAsset = nullthrows(
|
|
404
|
-
graph.getNode(sourceAssetId),
|
|
405
|
-
);
|
|
406
416
|
invariant(sourceAsset.type === 'asset');
|
|
407
417
|
let sourceAssetSymbols = sourceAsset.value.symbols;
|
|
408
418
|
if (sourceAssetSymbols) {
|
|
@@ -421,8 +431,9 @@ export default class BundleGraph {
|
|
|
421
431
|
}
|
|
422
432
|
let usedSymbolsUp = new Map(
|
|
423
433
|
[...node.usedSymbolsUp]
|
|
424
|
-
|
|
425
|
-
.
|
|
434
|
+
// @ts-expect-error TS2769
|
|
435
|
+
.filter(([k]: [any]) => target.has(k) || k === '*')
|
|
436
|
+
.map(([k, v]: [any, any]) => [target.get(k) ?? k, v]),
|
|
426
437
|
);
|
|
427
438
|
return {
|
|
428
439
|
asset,
|
|
@@ -478,6 +489,7 @@ export default class BundleGraph {
|
|
|
478
489
|
}
|
|
479
490
|
walk(nullthrows(assetGraph.rootNodeId));
|
|
480
491
|
|
|
492
|
+
// @ts-expect-error TS2488
|
|
481
493
|
for (let edge of assetGraph.getAllEdges()) {
|
|
482
494
|
if (assetGroupIds.has(edge.from)) {
|
|
483
495
|
continue;
|
|
@@ -502,10 +514,22 @@ export default class BundleGraph {
|
|
|
502
514
|
continue;
|
|
503
515
|
}
|
|
504
516
|
|
|
505
|
-
let to: Array<NodeId> = dependencies.get(edge.to)?.map(
|
|
517
|
+
let to: Array<NodeId> = dependencies.get(edge.to)?.map(
|
|
518
|
+
(
|
|
519
|
+
v:
|
|
520
|
+
| {
|
|
521
|
+
asset: null;
|
|
522
|
+
dep: NodeId;
|
|
523
|
+
}
|
|
524
|
+
| {
|
|
525
|
+
asset: ContentKey;
|
|
526
|
+
dep: NodeId;
|
|
527
|
+
},
|
|
528
|
+
) => v.dep,
|
|
529
|
+
) ??
|
|
506
530
|
assetGroupIds
|
|
507
531
|
.get(edge.to)
|
|
508
|
-
?.map((id) =>
|
|
532
|
+
?.map((id: NodeId) =>
|
|
509
533
|
nullthrows(assetGraphNodeIdToBundleGraphNodeId.get(id)),
|
|
510
534
|
) ?? [nullthrows(assetGraphNodeIdToBundleGraphNodeId.get(edge.to))];
|
|
511
535
|
|
|
@@ -549,29 +573,32 @@ export default class BundleGraph {
|
|
|
549
573
|
|
|
550
574
|
createBundle(
|
|
551
575
|
opts:
|
|
552
|
-
| {
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
576
|
+
| {
|
|
577
|
+
readonly entryAsset: Asset;
|
|
578
|
+
readonly bundleRoots?: Array<Asset>;
|
|
579
|
+
readonly target: Target;
|
|
580
|
+
readonly needsStableName?: boolean | null | undefined;
|
|
581
|
+
readonly bundleBehavior?: IBundleBehavior | null | undefined;
|
|
582
|
+
readonly shouldContentHash: boolean;
|
|
583
|
+
readonly env: EnvironmentRef;
|
|
584
|
+
}
|
|
585
|
+
| {
|
|
586
|
+
readonly type: string;
|
|
587
|
+
readonly env: EnvironmentRef;
|
|
588
|
+
readonly uniqueKey: string;
|
|
589
|
+
readonly target: Target;
|
|
590
|
+
readonly needsStableName?: boolean | null | undefined;
|
|
591
|
+
readonly bundleBehavior?: IBundleBehavior | null | undefined;
|
|
592
|
+
readonly isSplittable?: boolean | null | undefined;
|
|
593
|
+
readonly pipeline?: string | null | undefined;
|
|
594
|
+
readonly shouldContentHash: boolean;
|
|
595
|
+
},
|
|
571
596
|
): Bundle {
|
|
597
|
+
// @ts-expect-error TS2339
|
|
572
598
|
let {entryAsset, target} = opts;
|
|
573
599
|
let bundleId = hashString(
|
|
574
600
|
'bundle:' +
|
|
601
|
+
// @ts-expect-error TS2339
|
|
575
602
|
(opts.entryAsset ? opts.entryAsset.id : opts.uniqueKey) +
|
|
576
603
|
fromProjectPathRelative(target.distDir) +
|
|
577
604
|
(opts.bundleBehavior ?? ''),
|
|
@@ -603,19 +630,24 @@ export default class BundleGraph {
|
|
|
603
630
|
hashReference: opts.shouldContentHash
|
|
604
631
|
? HASH_REF_PREFIX + bundleId
|
|
605
632
|
: bundleId.slice(-8),
|
|
633
|
+
// @ts-expect-error TS2339
|
|
606
634
|
type: opts.entryAsset ? opts.entryAsset.type : opts.type,
|
|
607
635
|
env: opts.env,
|
|
608
636
|
entryAssetIds: entryAsset ? [entryAsset.id] : [],
|
|
609
637
|
mainEntryId: entryAsset?.id,
|
|
638
|
+
// @ts-expect-error TS2339
|
|
610
639
|
pipeline: opts.entryAsset ? opts.entryAsset.pipeline : opts.pipeline,
|
|
611
640
|
needsStableName: opts.needsStableName,
|
|
612
641
|
bundleBehavior:
|
|
613
642
|
opts.bundleBehavior != null
|
|
614
643
|
? BundleBehavior[opts.bundleBehavior]
|
|
615
644
|
: null,
|
|
645
|
+
// @ts-expect-error TS2339
|
|
616
646
|
isSplittable: opts.entryAsset
|
|
617
|
-
?
|
|
618
|
-
|
|
647
|
+
? // @ts-expect-error TS2339
|
|
648
|
+
opts.entryAsset.isBundleSplittable
|
|
649
|
+
: // @ts-expect-error TS2339
|
|
650
|
+
opts.isSplittable,
|
|
619
651
|
isPlaceholder,
|
|
620
652
|
target,
|
|
621
653
|
name: null,
|
|
@@ -626,9 +658,11 @@ export default class BundleGraph {
|
|
|
626
658
|
|
|
627
659
|
let bundleNodeId = this._graph.addNodeByContentKey(bundleId, bundleNode);
|
|
628
660
|
|
|
661
|
+
// @ts-expect-error TS2339
|
|
629
662
|
if (opts.entryAsset) {
|
|
630
663
|
this._graph.addEdge(
|
|
631
664
|
bundleNodeId,
|
|
665
|
+
// @ts-expect-error TS2339
|
|
632
666
|
this._graph.getNodeIdByContentKey(opts.entryAsset.id),
|
|
633
667
|
);
|
|
634
668
|
}
|
|
@@ -661,10 +695,13 @@ export default class BundleGraph {
|
|
|
661
695
|
for (let [bundleGroupNodeId, bundleGroupNode] of this._graph
|
|
662
696
|
.getNodeIdsConnectedFrom(dependencyNodeId)
|
|
663
697
|
.map((id) => [id, nullthrows(this._graph.getNode(id))])
|
|
664
|
-
|
|
698
|
+
// @ts-expect-error TS2769
|
|
699
|
+
.filter(([, node]: [any, any]) => node.type === 'bundle_group')) {
|
|
700
|
+
// @ts-expect-error TS2339
|
|
665
701
|
invariant(bundleGroupNode.type === 'bundle_group');
|
|
666
702
|
this._graph.addEdge(
|
|
667
703
|
bundleNodeId,
|
|
704
|
+
// @ts-expect-error TS2345
|
|
668
705
|
bundleGroupNodeId,
|
|
669
706
|
bundleGraphEdgeTypes.bundle,
|
|
670
707
|
);
|
|
@@ -693,7 +730,7 @@ export default class BundleGraph {
|
|
|
693
730
|
addAssetGraphToBundle(
|
|
694
731
|
asset: Asset,
|
|
695
732
|
bundle: Bundle,
|
|
696
|
-
shouldSkipDependency: (Dependency) => boolean = (d) =>
|
|
733
|
+
shouldSkipDependency: (arg1: Dependency) => boolean = (d: Dependency) =>
|
|
697
734
|
this.isDependencySkipped(d),
|
|
698
735
|
) {
|
|
699
736
|
let assetNodeId = this._graph.getNodeIdByContentKey(asset.id);
|
|
@@ -726,10 +763,13 @@ export default class BundleGraph {
|
|
|
726
763
|
for (let [bundleGroupNodeId, bundleGroupNode] of this._graph
|
|
727
764
|
.getNodeIdsConnectedFrom(nodeId)
|
|
728
765
|
.map((id) => [id, nullthrows(this._graph.getNode(id))])
|
|
729
|
-
|
|
766
|
+
// @ts-expect-error TS2769
|
|
767
|
+
.filter(([, node]: [any, any]) => node.type === 'bundle_group')) {
|
|
768
|
+
// @ts-expect-error TS2339
|
|
730
769
|
invariant(bundleGroupNode.type === 'bundle_group');
|
|
731
770
|
this._graph.addEdge(
|
|
732
771
|
bundleNodeId,
|
|
772
|
+
// @ts-expect-error TS2345
|
|
733
773
|
bundleGroupNodeId,
|
|
734
774
|
bundleGraphEdgeTypes.bundle,
|
|
735
775
|
);
|
|
@@ -769,7 +809,7 @@ export default class BundleGraph {
|
|
|
769
809
|
addEntryToBundle(
|
|
770
810
|
asset: Asset,
|
|
771
811
|
bundle: Bundle,
|
|
772
|
-
shouldSkipDependency?: (Dependency) => boolean,
|
|
812
|
+
shouldSkipDependency?: (arg1: Dependency) => boolean,
|
|
773
813
|
) {
|
|
774
814
|
this.addAssetGraphToBundle(asset, bundle, shouldSkipDependency);
|
|
775
815
|
if (!bundle.entryAssetIds.includes(asset.id)) {
|
|
@@ -836,11 +876,18 @@ export default class BundleGraph {
|
|
|
836
876
|
|
|
837
877
|
resolveAsyncDependency(
|
|
838
878
|
dependency: Dependency,
|
|
839
|
-
bundle
|
|
840
|
-
):
|
|
841
|
-
| {
|
|
842
|
-
|
|
843
|
-
|
|
879
|
+
bundle?: Bundle | null,
|
|
880
|
+
):
|
|
881
|
+
| {
|
|
882
|
+
type: 'bundle_group';
|
|
883
|
+
value: BundleGroup;
|
|
884
|
+
}
|
|
885
|
+
| {
|
|
886
|
+
type: 'asset';
|
|
887
|
+
value: Asset;
|
|
888
|
+
}
|
|
889
|
+
| null
|
|
890
|
+
| undefined {
|
|
844
891
|
let depNodeId = this._graph.getNodeIdByContentKey(dependency.id);
|
|
845
892
|
let bundleNodeId =
|
|
846
893
|
bundle != null ? this._graph.getNodeIdByContentKey(bundle.id) : null;
|
|
@@ -899,7 +946,10 @@ export default class BundleGraph {
|
|
|
899
946
|
}
|
|
900
947
|
|
|
901
948
|
// eslint-disable-next-line no-unused-vars
|
|
902
|
-
getReferencedBundle(
|
|
949
|
+
getReferencedBundle(
|
|
950
|
+
dependency: Dependency,
|
|
951
|
+
fromBundle: Bundle,
|
|
952
|
+
): Bundle | null | undefined {
|
|
903
953
|
let dependencyNodeId = this._graph.getNodeIdByContentKey(dependency.id);
|
|
904
954
|
|
|
905
955
|
// Find an attached bundle via a reference edge (e.g. from createAssetReference).
|
|
@@ -931,8 +981,12 @@ export default class BundleGraph {
|
|
|
931
981
|
return this.getBundlesInBundleGroup(node.value, {
|
|
932
982
|
includeInline: true,
|
|
933
983
|
}).find((b) => {
|
|
934
|
-
|
|
935
|
-
|
|
984
|
+
if (getFeatureFlag('supportWebpackChunkName')) {
|
|
985
|
+
return b.entryAssetIds.some((id) => id === node.value.entryAssetId);
|
|
986
|
+
} else {
|
|
987
|
+
let mainEntryId = b.entryAssetIds[b.entryAssetIds.length - 1];
|
|
988
|
+
return mainEntryId != null && node.value.entryAssetId === mainEntryId;
|
|
989
|
+
}
|
|
936
990
|
});
|
|
937
991
|
}
|
|
938
992
|
}
|
|
@@ -1226,7 +1280,10 @@ export default class BundleGraph {
|
|
|
1226
1280
|
});
|
|
1227
1281
|
}
|
|
1228
1282
|
|
|
1229
|
-
getResolvedAsset(
|
|
1283
|
+
getResolvedAsset(
|
|
1284
|
+
dep: Dependency,
|
|
1285
|
+
bundle?: Bundle | null,
|
|
1286
|
+
): Asset | null | undefined {
|
|
1230
1287
|
let assets = this.getDependencyAssets(dep);
|
|
1231
1288
|
let firstAsset = assets[0];
|
|
1232
1289
|
let resolved =
|
|
@@ -1240,7 +1297,7 @@ export default class BundleGraph {
|
|
|
1240
1297
|
|
|
1241
1298
|
// If a resolution still hasn't been found, return the first referenced asset.
|
|
1242
1299
|
if (resolved == null) {
|
|
1243
|
-
let potential = [];
|
|
1300
|
+
let potential: Array<Asset> = [];
|
|
1244
1301
|
this._graph.traverse(
|
|
1245
1302
|
(nodeId, _, traversal) => {
|
|
1246
1303
|
let node = nullthrows(this._graph.getNode(nodeId));
|
|
@@ -1255,6 +1312,7 @@ export default class BundleGraph {
|
|
|
1255
1312
|
);
|
|
1256
1313
|
|
|
1257
1314
|
if (bundle) {
|
|
1315
|
+
// @ts-expect-error TS2322
|
|
1258
1316
|
resolved = potential.find((a) => a.type === bundle.type);
|
|
1259
1317
|
}
|
|
1260
1318
|
resolved ||= potential[0];
|
|
@@ -1276,7 +1334,7 @@ export default class BundleGraph {
|
|
|
1276
1334
|
bundle: Bundle,
|
|
1277
1335
|
visit: GraphVisitor<Asset, TContext>,
|
|
1278
1336
|
startAsset?: Asset,
|
|
1279
|
-
):
|
|
1337
|
+
): TContext | null | undefined {
|
|
1280
1338
|
return this.traverseBundle(
|
|
1281
1339
|
bundle,
|
|
1282
1340
|
mapVisitor((node) => (node.type === 'asset' ? node.value : null), visit),
|
|
@@ -1359,7 +1417,8 @@ export default class BundleGraph {
|
|
|
1359
1417
|
|
|
1360
1418
|
if (
|
|
1361
1419
|
descendant.type !== bundle.type ||
|
|
1362
|
-
descendant.env.context !==
|
|
1420
|
+
fromEnvironmentId(descendant.env).context !==
|
|
1421
|
+
fromEnvironmentId(bundle.env).context
|
|
1363
1422
|
) {
|
|
1364
1423
|
actions.skipChildren();
|
|
1365
1424
|
return;
|
|
@@ -1376,6 +1435,158 @@ export default class BundleGraph {
|
|
|
1376
1435
|
});
|
|
1377
1436
|
}
|
|
1378
1437
|
|
|
1438
|
+
// New method: Fast checks only (no caching of results)
|
|
1439
|
+
isAssetReferencedFastCheck(bundle: Bundle, asset: Asset): boolean | null {
|
|
1440
|
+
// Fast Check #1: If asset is in multiple bundles in same target, it's referenced
|
|
1441
|
+
let bundlesWithAsset = this.getBundlesWithAsset(asset).filter(
|
|
1442
|
+
(b) =>
|
|
1443
|
+
b.target.name === bundle.target.name &&
|
|
1444
|
+
b.target.distDir === bundle.target.distDir,
|
|
1445
|
+
);
|
|
1446
|
+
|
|
1447
|
+
if (bundlesWithAsset.length > 1) {
|
|
1448
|
+
return true;
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1451
|
+
// Fast Check #2: If asset is referenced by any async/conditional dependency, it's referenced
|
|
1452
|
+
let assetNodeId = nullthrows(this._graph.getNodeIdByContentKey(asset.id));
|
|
1453
|
+
|
|
1454
|
+
if (
|
|
1455
|
+
this._graph
|
|
1456
|
+
.getNodeIdsConnectedTo(assetNodeId, bundleGraphEdgeTypes.references)
|
|
1457
|
+
.map((id) => this._graph.getNode(id))
|
|
1458
|
+
.some(
|
|
1459
|
+
(node) =>
|
|
1460
|
+
node?.type === 'dependency' &&
|
|
1461
|
+
(node.value.priority === Priority.lazy ||
|
|
1462
|
+
node.value.priority === Priority.conditional) &&
|
|
1463
|
+
node.value.specifierType !== SpecifierType.url,
|
|
1464
|
+
)
|
|
1465
|
+
) {
|
|
1466
|
+
return true;
|
|
1467
|
+
}
|
|
1468
|
+
|
|
1469
|
+
// Fast checks failed - return null to indicate expensive computation needed
|
|
1470
|
+
return null;
|
|
1471
|
+
}
|
|
1472
|
+
|
|
1473
|
+
getReferencedAssets(bundle: Bundle): Set<Asset> {
|
|
1474
|
+
let referencedAssets = new Set<Asset>();
|
|
1475
|
+
|
|
1476
|
+
// Build a map of all assets in this bundle with their dependencies
|
|
1477
|
+
// This allows us to check all assets in a single traversal
|
|
1478
|
+
let assetDependenciesMap = new Map<Asset, Array<Dependency>>();
|
|
1479
|
+
|
|
1480
|
+
this.traverseAssets(bundle, (asset) => {
|
|
1481
|
+
// Always do fast checks (no caching)
|
|
1482
|
+
let fastCheckResult = this.isAssetReferencedFastCheck(bundle, asset);
|
|
1483
|
+
|
|
1484
|
+
if (fastCheckResult === true) {
|
|
1485
|
+
referencedAssets.add(asset);
|
|
1486
|
+
return;
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1489
|
+
// Fast checks failed (fastCheckResult === null), need expensive computation
|
|
1490
|
+
// Check if it's actually referenced via traversal
|
|
1491
|
+
|
|
1492
|
+
// Store dependencies for later batch checking
|
|
1493
|
+
let dependencies = this._graph
|
|
1494
|
+
.getNodeIdsConnectedTo(
|
|
1495
|
+
nullthrows(this._graph.getNodeIdByContentKey(asset.id)),
|
|
1496
|
+
)
|
|
1497
|
+
.map((id) => nullthrows(this._graph.getNode(id)))
|
|
1498
|
+
.filter((node) => node.type === 'dependency')
|
|
1499
|
+
.map((node) => {
|
|
1500
|
+
invariant(node.type === 'dependency');
|
|
1501
|
+
return node.value;
|
|
1502
|
+
});
|
|
1503
|
+
|
|
1504
|
+
if (dependencies.length > 0) {
|
|
1505
|
+
assetDependenciesMap.set(asset, dependencies);
|
|
1506
|
+
}
|
|
1507
|
+
});
|
|
1508
|
+
|
|
1509
|
+
// If no assets need the expensive check, return early
|
|
1510
|
+
if (assetDependenciesMap.size === 0) {
|
|
1511
|
+
return referencedAssets;
|
|
1512
|
+
}
|
|
1513
|
+
|
|
1514
|
+
// Get the assets we need to check once
|
|
1515
|
+
let assetsToCheck = Array.from(assetDependenciesMap.keys());
|
|
1516
|
+
|
|
1517
|
+
// Helper function to check if all assets from assetDependenciesMap are in referencedAssets
|
|
1518
|
+
const allAssetsReferenced = (): boolean =>
|
|
1519
|
+
assetsToCheck.length <= referencedAssets.size &&
|
|
1520
|
+
assetsToCheck.every((asset) => referencedAssets.has(asset));
|
|
1521
|
+
|
|
1522
|
+
// Do ONE traversal to check all remaining assets
|
|
1523
|
+
// We can share visitedBundles across all assets because we check every asset
|
|
1524
|
+
// against every visited bundle, which matches the original per-asset behavior
|
|
1525
|
+
let siblingBundles = new Set(
|
|
1526
|
+
this.getBundleGroupsContainingBundle(bundle).flatMap((bundleGroup) =>
|
|
1527
|
+
this.getBundlesInBundleGroup(bundleGroup, {includeInline: true}),
|
|
1528
|
+
),
|
|
1529
|
+
);
|
|
1530
|
+
|
|
1531
|
+
let visitedBundles: Set<Bundle> = new Set();
|
|
1532
|
+
|
|
1533
|
+
// Single traversal from all referencers
|
|
1534
|
+
for (let referencer of siblingBundles) {
|
|
1535
|
+
this.traverseBundles((descendant, _, actions) => {
|
|
1536
|
+
if (descendant.id === bundle.id) {
|
|
1537
|
+
return;
|
|
1538
|
+
}
|
|
1539
|
+
|
|
1540
|
+
if (visitedBundles.has(descendant)) {
|
|
1541
|
+
actions.skipChildren();
|
|
1542
|
+
return;
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
visitedBundles.add(descendant);
|
|
1546
|
+
|
|
1547
|
+
if (
|
|
1548
|
+
descendant.type !== bundle.type ||
|
|
1549
|
+
fromEnvironmentId(descendant.env).context !==
|
|
1550
|
+
fromEnvironmentId(bundle.env).context
|
|
1551
|
+
) {
|
|
1552
|
+
// Don't skip children - they might be the right type!
|
|
1553
|
+
return;
|
|
1554
|
+
}
|
|
1555
|
+
|
|
1556
|
+
// Check ALL assets at once in this descendant bundle
|
|
1557
|
+
for (let [asset, dependencies] of assetDependenciesMap) {
|
|
1558
|
+
// Skip if already marked as referenced
|
|
1559
|
+
if (referencedAssets.has(asset)) {
|
|
1560
|
+
continue;
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1563
|
+
// Check if this descendant bundle references the asset
|
|
1564
|
+
if (
|
|
1565
|
+
!this.bundleHasAsset(descendant, asset) &&
|
|
1566
|
+
dependencies.some((dependency) =>
|
|
1567
|
+
this.bundleHasDependency(descendant, dependency),
|
|
1568
|
+
)
|
|
1569
|
+
) {
|
|
1570
|
+
referencedAssets.add(asset);
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1574
|
+
// If all assets from assetDependenciesMap are now marked as referenced, we can stop early
|
|
1575
|
+
if (allAssetsReferenced()) {
|
|
1576
|
+
actions.stop();
|
|
1577
|
+
return;
|
|
1578
|
+
}
|
|
1579
|
+
}, referencer);
|
|
1580
|
+
|
|
1581
|
+
// If all assets from assetDependenciesMap are referenced, no need to check more sibling bundles
|
|
1582
|
+
if (allAssetsReferenced()) {
|
|
1583
|
+
break;
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
|
|
1587
|
+
return referencedAssets;
|
|
1588
|
+
}
|
|
1589
|
+
|
|
1379
1590
|
hasParentBundleOfType(bundle: Bundle, type: string): boolean {
|
|
1380
1591
|
let parents = this.getParentBundles(bundle);
|
|
1381
1592
|
return (
|
|
@@ -1400,10 +1611,11 @@ export default class BundleGraph {
|
|
|
1400
1611
|
// If a bundle's environment is isolated, it can't access assets present
|
|
1401
1612
|
// in any ancestor bundles. Don't consider any assets reachable.
|
|
1402
1613
|
if (
|
|
1403
|
-
ISOLATED_ENVS.has(bundle.env.context) ||
|
|
1614
|
+
ISOLATED_ENVS.has(fromEnvironmentId(bundle.env).context) ||
|
|
1404
1615
|
!bundle.isSplittable ||
|
|
1405
1616
|
bundle.bundleBehavior === BundleBehavior.isolated ||
|
|
1406
|
-
bundle.bundleBehavior === BundleBehavior.inline
|
|
1617
|
+
bundle.bundleBehavior === BundleBehavior.inline ||
|
|
1618
|
+
bundle.bundleBehavior === BundleBehavior.inlineIsolated
|
|
1407
1619
|
) {
|
|
1408
1620
|
return false;
|
|
1409
1621
|
}
|
|
@@ -1420,6 +1632,7 @@ export default class BundleGraph {
|
|
|
1420
1632
|
b.id !== bundle.id &&
|
|
1421
1633
|
b.bundleBehavior !== BundleBehavior.isolated &&
|
|
1422
1634
|
b.bundleBehavior !== BundleBehavior.inline &&
|
|
1635
|
+
b.bundleBehavior !== BundleBehavior.inlineIsolated &&
|
|
1423
1636
|
this.bundleHasAsset(b, asset),
|
|
1424
1637
|
)
|
|
1425
1638
|
) {
|
|
@@ -1438,7 +1651,8 @@ export default class BundleGraph {
|
|
|
1438
1651
|
if (
|
|
1439
1652
|
bundleNode.type !== 'bundle' ||
|
|
1440
1653
|
bundleNode.value.bundleBehavior === BundleBehavior.isolated ||
|
|
1441
|
-
bundleNode.value.bundleBehavior === BundleBehavior.inline
|
|
1654
|
+
bundleNode.value.bundleBehavior === BundleBehavior.inline ||
|
|
1655
|
+
bundleNode.value.bundleBehavior === BundleBehavior.inlineIsolated
|
|
1442
1656
|
) {
|
|
1443
1657
|
return false;
|
|
1444
1658
|
}
|
|
@@ -1454,7 +1668,8 @@ export default class BundleGraph {
|
|
|
1454
1668
|
node.type === 'root' ||
|
|
1455
1669
|
(node.type === 'bundle' &&
|
|
1456
1670
|
(node.value.id === bundle.id ||
|
|
1457
|
-
node.value.env.context !==
|
|
1671
|
+
fromEnvironmentId(node.value.env).context !==
|
|
1672
|
+
fromEnvironmentId(bundle.env).context))
|
|
1458
1673
|
) {
|
|
1459
1674
|
isReachable = false;
|
|
1460
1675
|
actions.stop();
|
|
@@ -1469,6 +1684,7 @@ export default class BundleGraph {
|
|
|
1469
1684
|
b.id !== bundle.id &&
|
|
1470
1685
|
b.bundleBehavior !== BundleBehavior.isolated &&
|
|
1471
1686
|
b.bundleBehavior !== BundleBehavior.inline &&
|
|
1687
|
+
b.bundleBehavior !== BundleBehavior.inlineIsolated &&
|
|
1472
1688
|
this.bundleHasAsset(b, asset),
|
|
1473
1689
|
)
|
|
1474
1690
|
) {
|
|
@@ -1493,7 +1709,7 @@ export default class BundleGraph {
|
|
|
1493
1709
|
bundle: Bundle,
|
|
1494
1710
|
visit: GraphVisitor<AssetNode | DependencyNode, TContext>,
|
|
1495
1711
|
startAsset?: Asset,
|
|
1496
|
-
):
|
|
1712
|
+
): TContext | null | undefined {
|
|
1497
1713
|
let entries = !startAsset;
|
|
1498
1714
|
let bundleNodeId = this._graph.getNodeIdByContentKey(bundle.id);
|
|
1499
1715
|
|
|
@@ -1531,7 +1747,8 @@ export default class BundleGraph {
|
|
|
1531
1747
|
|
|
1532
1748
|
let sorted =
|
|
1533
1749
|
entries && bundle.entryAssetIds.length > 0
|
|
1534
|
-
?
|
|
1750
|
+
? // @ts-expect-error TS2345
|
|
1751
|
+
children.sort(([, a]: [any, any], [, b]: [any, any]) => {
|
|
1535
1752
|
let aIndex = bundle.entryAssetIds.indexOf(a.id);
|
|
1536
1753
|
let bIndex = bundle.entryAssetIds.indexOf(b.id);
|
|
1537
1754
|
|
|
@@ -1550,7 +1767,8 @@ export default class BundleGraph {
|
|
|
1550
1767
|
: children;
|
|
1551
1768
|
|
|
1552
1769
|
entries = false;
|
|
1553
|
-
|
|
1770
|
+
// @ts-expect-error TS2345
|
|
1771
|
+
return sorted.map(([id]: [any]) => id);
|
|
1554
1772
|
},
|
|
1555
1773
|
});
|
|
1556
1774
|
}
|
|
@@ -1558,7 +1776,7 @@ export default class BundleGraph {
|
|
|
1558
1776
|
traverse<TContext>(
|
|
1559
1777
|
visit: GraphVisitor<AssetNode | DependencyNode, TContext>,
|
|
1560
1778
|
start?: Asset,
|
|
1561
|
-
):
|
|
1779
|
+
): TContext | null | undefined {
|
|
1562
1780
|
return this._graph.filteredTraverse(
|
|
1563
1781
|
(nodeId) => {
|
|
1564
1782
|
let node = nullthrows(this._graph.getNode(nodeId));
|
|
@@ -1574,7 +1792,7 @@ export default class BundleGraph {
|
|
|
1574
1792
|
|
|
1575
1793
|
getChildBundles(bundle: Bundle): Array<Bundle> {
|
|
1576
1794
|
let siblings = new Set(this.getReferencedBundles(bundle));
|
|
1577
|
-
let bundles = [];
|
|
1795
|
+
let bundles: Array<Bundle> = [];
|
|
1578
1796
|
this.traverseBundles((b, _, actions) => {
|
|
1579
1797
|
if (bundle.id === b.id) {
|
|
1580
1798
|
return;
|
|
@@ -1591,8 +1809,8 @@ export default class BundleGraph {
|
|
|
1591
1809
|
|
|
1592
1810
|
traverseBundles<TContext>(
|
|
1593
1811
|
visit: GraphVisitor<Bundle, TContext>,
|
|
1594
|
-
startBundle
|
|
1595
|
-
):
|
|
1812
|
+
startBundle?: Bundle | null,
|
|
1813
|
+
): TContext | null | undefined {
|
|
1596
1814
|
return this._graph.filteredTraverse(
|
|
1597
1815
|
(nodeId) => {
|
|
1598
1816
|
let node = nullthrows(this._graph.getNode(nodeId));
|
|
@@ -1604,12 +1822,13 @@ export default class BundleGraph {
|
|
|
1604
1822
|
);
|
|
1605
1823
|
}
|
|
1606
1824
|
|
|
1607
|
-
getBundles(opts?: {
|
|
1608
|
-
let bundles = [];
|
|
1825
|
+
getBundles(opts?: {includeInline: boolean}): Array<Bundle> {
|
|
1826
|
+
let bundles: Array<Bundle> = [];
|
|
1609
1827
|
this.traverseBundles((bundle) => {
|
|
1610
1828
|
if (
|
|
1611
1829
|
opts?.includeInline ||
|
|
1612
|
-
bundle.bundleBehavior !== BundleBehavior.inline
|
|
1830
|
+
(bundle.bundleBehavior !== BundleBehavior.inline &&
|
|
1831
|
+
bundle.bundleBehavior !== BundleBehavior.inlineIsolated)
|
|
1613
1832
|
) {
|
|
1614
1833
|
bundles.push(bundle);
|
|
1615
1834
|
}
|
|
@@ -1679,7 +1898,9 @@ export default class BundleGraph {
|
|
|
1679
1898
|
|
|
1680
1899
|
getBundlesInBundleGroup(
|
|
1681
1900
|
bundleGroup: BundleGroup,
|
|
1682
|
-
opts?: {
|
|
1901
|
+
opts?: {
|
|
1902
|
+
includeInline: boolean;
|
|
1903
|
+
},
|
|
1683
1904
|
): Array<Bundle> {
|
|
1684
1905
|
let bundles: Set<Bundle> = new Set();
|
|
1685
1906
|
for (let bundleNodeId of this._graph.getNodeIdsConnectedFrom(
|
|
@@ -1691,7 +1912,8 @@ export default class BundleGraph {
|
|
|
1691
1912
|
let bundle = bundleNode.value;
|
|
1692
1913
|
if (
|
|
1693
1914
|
opts?.includeInline ||
|
|
1694
|
-
bundle.bundleBehavior !== BundleBehavior.inline
|
|
1915
|
+
(bundle.bundleBehavior !== BundleBehavior.inline &&
|
|
1916
|
+
bundle.bundleBehavior !== BundleBehavior.inlineIsolated)
|
|
1695
1917
|
) {
|
|
1696
1918
|
bundles.add(bundle);
|
|
1697
1919
|
}
|
|
@@ -1708,7 +1930,10 @@ export default class BundleGraph {
|
|
|
1708
1930
|
|
|
1709
1931
|
getReferencedBundles(
|
|
1710
1932
|
bundle: Bundle,
|
|
1711
|
-
opts?: {
|
|
1933
|
+
opts?: {
|
|
1934
|
+
recursive?: boolean;
|
|
1935
|
+
includeInline?: boolean;
|
|
1936
|
+
},
|
|
1712
1937
|
): Array<Bundle> {
|
|
1713
1938
|
let recursive = opts?.recursive ?? true;
|
|
1714
1939
|
let includeInline = opts?.includeInline ?? false;
|
|
@@ -1726,7 +1951,8 @@ export default class BundleGraph {
|
|
|
1726
1951
|
|
|
1727
1952
|
if (
|
|
1728
1953
|
includeInline ||
|
|
1729
|
-
node.value.bundleBehavior !== BundleBehavior.inline
|
|
1954
|
+
(node.value.bundleBehavior !== BundleBehavior.inline &&
|
|
1955
|
+
node.value.bundleBehavior !== BundleBehavior.inlineIsolated)
|
|
1730
1956
|
) {
|
|
1731
1957
|
referencedBundles.add(node.value);
|
|
1732
1958
|
}
|
|
@@ -1746,6 +1972,7 @@ export default class BundleGraph {
|
|
|
1746
1972
|
),
|
|
1747
1973
|
});
|
|
1748
1974
|
|
|
1975
|
+
// @ts-expect-error TS2322
|
|
1749
1976
|
return [...referencedBundles];
|
|
1750
1977
|
}
|
|
1751
1978
|
|
|
@@ -1768,7 +1995,7 @@ export default class BundleGraph {
|
|
|
1768
1995
|
});
|
|
1769
1996
|
}
|
|
1770
1997
|
|
|
1771
|
-
getAssetWithDependency(dep: Dependency):
|
|
1998
|
+
getAssetWithDependency(dep: Dependency): Asset | null | undefined {
|
|
1772
1999
|
if (!this._graph.hasContentKey(dep.id)) {
|
|
1773
2000
|
return null;
|
|
1774
2001
|
}
|
|
@@ -1777,6 +2004,7 @@ export default class BundleGraph {
|
|
|
1777
2004
|
let count = 0;
|
|
1778
2005
|
this._graph.forEachNodeIdConnectedTo(
|
|
1779
2006
|
this._graph.getNodeIdByContentKey(dep.id),
|
|
2007
|
+
// @ts-expect-error TS2345
|
|
1780
2008
|
(node) => {
|
|
1781
2009
|
res = node;
|
|
1782
2010
|
count += 1;
|
|
@@ -1817,16 +2045,16 @@ export default class BundleGraph {
|
|
|
1817
2045
|
|
|
1818
2046
|
filteredTraverse<TValue, TContext>(
|
|
1819
2047
|
bundleNodeId: NodeId,
|
|
1820
|
-
filter: (NodeId, TraversalActions) =>
|
|
2048
|
+
filter: (arg1: NodeId, arg2: TraversalActions) => TValue | null | undefined,
|
|
1821
2049
|
visit: GraphVisitor<TValue, TContext>,
|
|
1822
|
-
):
|
|
2050
|
+
): TContext | null | undefined {
|
|
1823
2051
|
return this._graph.filteredTraverse(filter, visit, bundleNodeId);
|
|
1824
2052
|
}
|
|
1825
2053
|
|
|
1826
2054
|
getSymbolResolution(
|
|
1827
2055
|
asset: Asset,
|
|
1828
2056
|
symbol: Symbol,
|
|
1829
|
-
boundary
|
|
2057
|
+
boundary?: Bundle | null,
|
|
1830
2058
|
): InternalSymbolResolution {
|
|
1831
2059
|
let assetOutside = boundary && !this.bundleHasAsset(boundary, asset);
|
|
1832
2060
|
|
|
@@ -1853,7 +2081,7 @@ export default class BundleGraph {
|
|
|
1853
2081
|
}
|
|
1854
2082
|
// If this is a re-export, find the original module.
|
|
1855
2083
|
let symbolLookup = new Map(
|
|
1856
|
-
[...depSymbols].map(([key, val]) => [val.local, key]),
|
|
2084
|
+
[...depSymbols].map(([key, val]: [any, any]) => [val.local, key]),
|
|
1857
2085
|
);
|
|
1858
2086
|
let depSymbol = symbolLookup.get(identifier);
|
|
1859
2087
|
if (depSymbol != null) {
|
|
@@ -1971,17 +2199,20 @@ export default class BundleGraph {
|
|
|
1971
2199
|
let result = identifier;
|
|
1972
2200
|
if (skipped) {
|
|
1973
2201
|
// ... and it was excluded (by symbol propagation) or deferred.
|
|
2202
|
+
// @ts-expect-error TS2322
|
|
1974
2203
|
result = false;
|
|
1975
2204
|
} else {
|
|
1976
2205
|
// ... and there is no single reexport, but it might still be exported:
|
|
1977
2206
|
if (found) {
|
|
1978
2207
|
// Fallback to namespace access, because of a bundle boundary.
|
|
2208
|
+
// @ts-expect-error TS2322
|
|
1979
2209
|
result = null;
|
|
1980
2210
|
} else if (result === undefined) {
|
|
1981
2211
|
// If not exported explicitly by the asset (= would have to be in * or a reexport-all) ...
|
|
1982
2212
|
if (nonStaticDependency || asset.symbols?.has('*')) {
|
|
1983
2213
|
// ... and if there are non-statically analyzable dependencies or it's a CJS asset,
|
|
1984
2214
|
// fallback to namespace access.
|
|
2215
|
+
// @ts-expect-error TS2322
|
|
1985
2216
|
result = null;
|
|
1986
2217
|
}
|
|
1987
2218
|
// (It shouldn't be possible for the symbol to be in a reexport-all and to end up here).
|
|
@@ -2019,13 +2250,13 @@ export default class BundleGraph {
|
|
|
2019
2250
|
|
|
2020
2251
|
getExportedSymbols(
|
|
2021
2252
|
asset: Asset,
|
|
2022
|
-
boundary
|
|
2253
|
+
boundary?: Bundle | null,
|
|
2023
2254
|
): Array<InternalExportSymbolResolution> {
|
|
2024
2255
|
if (!asset.symbols) {
|
|
2025
2256
|
return [];
|
|
2026
2257
|
}
|
|
2027
2258
|
|
|
2028
|
-
let symbols = [];
|
|
2259
|
+
let symbols: Array<InternalExportSymbolResolution> = [];
|
|
2029
2260
|
|
|
2030
2261
|
for (let symbol of asset.symbols.keys()) {
|
|
2031
2262
|
symbols.push({
|
|
@@ -2076,9 +2307,9 @@ export default class BundleGraph {
|
|
|
2076
2307
|
}
|
|
2077
2308
|
|
|
2078
2309
|
getInlineBundles(bundle: Bundle): Array<Bundle> {
|
|
2079
|
-
let bundles = [];
|
|
2310
|
+
let bundles: Array<Bundle> = [];
|
|
2080
2311
|
let seen = new Set();
|
|
2081
|
-
let addReferencedBundles = (bundle) => {
|
|
2312
|
+
let addReferencedBundles = (bundle: Bundle) => {
|
|
2082
2313
|
if (seen.has(bundle.id)) {
|
|
2083
2314
|
return;
|
|
2084
2315
|
}
|
|
@@ -2089,7 +2320,10 @@ export default class BundleGraph {
|
|
|
2089
2320
|
includeInline: true,
|
|
2090
2321
|
});
|
|
2091
2322
|
for (let referenced of referencedBundles) {
|
|
2092
|
-
if (
|
|
2323
|
+
if (
|
|
2324
|
+
referenced.bundleBehavior === BundleBehavior.inline ||
|
|
2325
|
+
referenced.bundleBehavior === BundleBehavior.inlineIsolated
|
|
2326
|
+
) {
|
|
2093
2327
|
bundles.push(referenced);
|
|
2094
2328
|
addReferencedBundles(referenced);
|
|
2095
2329
|
}
|
|
@@ -2099,7 +2333,10 @@ export default class BundleGraph {
|
|
|
2099
2333
|
addReferencedBundles(bundle);
|
|
2100
2334
|
|
|
2101
2335
|
this.traverseBundles((childBundle, _, traversal) => {
|
|
2102
|
-
if (
|
|
2336
|
+
if (
|
|
2337
|
+
childBundle.bundleBehavior === BundleBehavior.inline ||
|
|
2338
|
+
childBundle.bundleBehavior === BundleBehavior.inlineIsolated
|
|
2339
|
+
) {
|
|
2103
2340
|
bundles.push(childBundle);
|
|
2104
2341
|
} else if (childBundle.id !== bundle.id) {
|
|
2105
2342
|
traversal.skipChildren();
|
|
@@ -2128,7 +2365,9 @@ export default class BundleGraph {
|
|
|
2128
2365
|
hash.writeString(referencedBundle.id);
|
|
2129
2366
|
}
|
|
2130
2367
|
|
|
2131
|
-
hash.writeString(
|
|
2368
|
+
hash.writeString(
|
|
2369
|
+
JSON.stringify(objectSortedEntriesDeep(fromEnvironmentId(bundle.env))),
|
|
2370
|
+
);
|
|
2132
2371
|
return hash.finish();
|
|
2133
2372
|
}
|
|
2134
2373
|
|
|
@@ -2172,7 +2411,7 @@ export default class BundleGraph {
|
|
|
2172
2411
|
}
|
|
2173
2412
|
}
|
|
2174
2413
|
|
|
2175
|
-
getUsedSymbolsAsset(asset: Asset):
|
|
2414
|
+
getUsedSymbolsAsset(asset: Asset): ReadonlySet<Symbol> | null | undefined {
|
|
2176
2415
|
let node = this._graph.getNodeByContentKey(asset.id);
|
|
2177
2416
|
invariant(node && node.type === 'asset');
|
|
2178
2417
|
return node.value.symbols
|
|
@@ -2180,7 +2419,9 @@ export default class BundleGraph {
|
|
|
2180
2419
|
: null;
|
|
2181
2420
|
}
|
|
2182
2421
|
|
|
2183
|
-
getUsedSymbolsDependency(
|
|
2422
|
+
getUsedSymbolsDependency(
|
|
2423
|
+
dep: Dependency,
|
|
2424
|
+
): ReadonlySet<Symbol> | null | undefined {
|
|
2184
2425
|
let node = this._graph.getNodeByContentKey(dep.id);
|
|
2185
2426
|
invariant(node && node.type === 'dependency');
|
|
2186
2427
|
return node.value.symbols
|
|
@@ -2228,6 +2469,7 @@ export default class BundleGraph {
|
|
|
2228
2469
|
}
|
|
2229
2470
|
}
|
|
2230
2471
|
|
|
2472
|
+
// @ts-expect-error TS2488
|
|
2231
2473
|
for (let edge of other._graph.getAllEdges()) {
|
|
2232
2474
|
this._graph.addEdge(
|
|
2233
2475
|
nullthrows(otherGraphIdToThisNodeId.get(edge.from)),
|
|
@@ -2272,7 +2514,7 @@ export default class BundleGraph {
|
|
|
2272
2514
|
bundleGraphEdgeTypes.bundle,
|
|
2273
2515
|
);
|
|
2274
2516
|
|
|
2275
|
-
let entries = [];
|
|
2517
|
+
let entries: Array<FilePath> = [];
|
|
2276
2518
|
for (let bundleGroupId of entryBundleGroupIds) {
|
|
2277
2519
|
let bundleGroupNode = this._graph.getNode(bundleGroupId);
|
|
2278
2520
|
invariant(bundleGroupNode?.type === 'bundle_group');
|
|
@@ -2312,6 +2554,7 @@ export default class BundleGraph {
|
|
|
2312
2554
|
),
|
|
2313
2555
|
});
|
|
2314
2556
|
|
|
2557
|
+
// @ts-expect-error TS2322
|
|
2315
2558
|
return [...referencedBundles];
|
|
2316
2559
|
}
|
|
2317
2560
|
}
|