@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
package/lib/BundleGraph.js
CHANGED
|
@@ -51,6 +51,7 @@ function _featureFlags() {
|
|
|
51
51
|
};
|
|
52
52
|
return data;
|
|
53
53
|
}
|
|
54
|
+
var _EnvironmentManager = require("./EnvironmentManager");
|
|
54
55
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
55
56
|
const bundleGraphEdgeTypes = exports.bundleGraphEdgeTypes = {
|
|
56
57
|
// A lack of an edge type indicates to follow the edge while traversing
|
|
@@ -85,7 +86,7 @@ function makeReadOnlySet(set) {
|
|
|
85
86
|
if (property === 'delete' || property === 'add' || property === 'clear') {
|
|
86
87
|
return undefined;
|
|
87
88
|
} else {
|
|
88
|
-
//
|
|
89
|
+
// @ts-expect-error TS7053
|
|
89
90
|
let value = target[property];
|
|
90
91
|
return typeof value === 'function' ? value.bind(target) : value;
|
|
91
92
|
}
|
|
@@ -167,7 +168,7 @@ class BundleGraph {
|
|
|
167
168
|
// code need to be mapped to the "real" dependencies, so we need access to a map of placeholders
|
|
168
169
|
// to dependencies
|
|
169
170
|
const dep = node.value;
|
|
170
|
-
//
|
|
171
|
+
// @ts-expect-error TS2322
|
|
171
172
|
const placeholder = (_dep$meta = dep.meta) === null || _dep$meta === void 0 ? void 0 : _dep$meta.placeholder;
|
|
172
173
|
if (placeholder != null) {
|
|
173
174
|
placeholderToDependency.set(placeholder, dep);
|
|
@@ -182,7 +183,6 @@ class BundleGraph {
|
|
|
182
183
|
if ((0, _featureFlags().getFeatureFlag)('conditionalBundlingApi') && node.type === 'asset') {
|
|
183
184
|
const asset = node.value;
|
|
184
185
|
if (Array.isArray(asset.meta.conditions)) {
|
|
185
|
-
// $FlowFixMe
|
|
186
186
|
for (const condition of asset.meta.conditions) {
|
|
187
187
|
// Resolve the placeholders that were attached to the asset in JSTransformer to dependencies,
|
|
188
188
|
// as well as create a public id for the condition.
|
|
@@ -207,7 +207,7 @@ class BundleGraph {
|
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
209
|
}
|
|
210
|
-
if (node.type === 'dependency' && node.value.symbols != null && node.value.env.shouldScopeHoist &&
|
|
210
|
+
if (node.type === 'dependency' && node.value.symbols != null && (0, _EnvironmentManager.fromEnvironmentId)(node.value.env).shouldScopeHoist &&
|
|
211
211
|
// Disable in dev mode because this feature is at odds with safeToIncrementallyBundle
|
|
212
212
|
isProduction) {
|
|
213
213
|
let nodeValueSymbols = node.value.symbols;
|
|
@@ -263,9 +263,13 @@ class BundleGraph {
|
|
|
263
263
|
...node,
|
|
264
264
|
value: {
|
|
265
265
|
...node.value,
|
|
266
|
-
symbols: new Map(
|
|
266
|
+
symbols: new Map(
|
|
267
|
+
// @ts-expect-error TS2769
|
|
268
|
+
[...nodeValueSymbols].filter(([k]) => externalSymbols.has(k)))
|
|
267
269
|
},
|
|
268
|
-
usedSymbolsUp: new Map(
|
|
270
|
+
usedSymbolsUp: new Map(
|
|
271
|
+
// @ts-expect-error TS2769
|
|
272
|
+
[...node.usedSymbolsUp].filter(([k]) => externalSymbols.has(k))),
|
|
269
273
|
usedSymbolsDown: new Set(),
|
|
270
274
|
excluded: externalSymbols.size === 0
|
|
271
275
|
})
|
|
@@ -294,8 +298,13 @@ class BundleGraph {
|
|
|
294
298
|
loc: reexportAllLoc
|
|
295
299
|
});
|
|
296
300
|
if (node.value.sourceAssetId != null) {
|
|
297
|
-
let sourceAssetId
|
|
298
|
-
|
|
301
|
+
let sourceAssetId;
|
|
302
|
+
if ((0, _featureFlags().getFeatureFlag)('sourceAssetIdBundleGraphFix')) {
|
|
303
|
+
[sourceAssetId] = assetGraph.getNodeIdsConnectedTo(nodeId);
|
|
304
|
+
} else {
|
|
305
|
+
sourceAssetId = assetGraph.getNodeIdByContentKey(node.value.sourceAssetId);
|
|
306
|
+
}
|
|
307
|
+
let sourceAsset = (0, _nullthrows().default)(graph.getNode((0, _nullthrows().default)(assetGraphNodeIdToBundleGraphNodeId.get(sourceAssetId))));
|
|
299
308
|
(0, _assert().default)(sourceAsset.type === 'asset');
|
|
300
309
|
let sourceAssetSymbols = sourceAsset.value.symbols;
|
|
301
310
|
if (sourceAssetSymbols) {
|
|
@@ -312,7 +321,9 @@ class BundleGraph {
|
|
|
312
321
|
}
|
|
313
322
|
}
|
|
314
323
|
}
|
|
315
|
-
let usedSymbolsUp = new Map([...node.usedSymbolsUp]
|
|
324
|
+
let usedSymbolsUp = new Map([...node.usedSymbolsUp]
|
|
325
|
+
// @ts-expect-error TS2769
|
|
326
|
+
.filter(([k]) => target.has(k) || k === '*').map(([k, v]) => [target.get(k) ?? k, v]));
|
|
316
327
|
return {
|
|
317
328
|
asset,
|
|
318
329
|
dep: graph.addNodeByContentKey(newNodeId, {
|
|
@@ -363,6 +374,8 @@ class BundleGraph {
|
|
|
363
374
|
}
|
|
364
375
|
}
|
|
365
376
|
walk((0, _nullthrows().default)(assetGraph.rootNodeId));
|
|
377
|
+
|
|
378
|
+
// @ts-expect-error TS2488
|
|
366
379
|
for (let edge of assetGraph.getAllEdges()) {
|
|
367
380
|
var _dependencies$get, _assetGroupIds$get;
|
|
368
381
|
if (assetGroupIds.has(edge.from)) {
|
|
@@ -416,11 +429,14 @@ class BundleGraph {
|
|
|
416
429
|
});
|
|
417
430
|
}
|
|
418
431
|
createBundle(opts) {
|
|
432
|
+
// @ts-expect-error TS2339
|
|
419
433
|
let {
|
|
420
434
|
entryAsset,
|
|
421
435
|
target
|
|
422
436
|
} = opts;
|
|
423
|
-
let bundleId = (0, _rust().hashString)('bundle:' + (
|
|
437
|
+
let bundleId = (0, _rust().hashString)('bundle:' + (
|
|
438
|
+
// @ts-expect-error TS2339
|
|
439
|
+
opts.entryAsset ? opts.entryAsset.id : opts.uniqueKey) + (0, _projectPath.fromProjectPathRelative)(target.distDir) + (opts.bundleBehavior ?? ''));
|
|
424
440
|
let existing = this._graph.getNodeByContentKey(bundleId);
|
|
425
441
|
if (existing != null) {
|
|
426
442
|
(0, _assert().default)(existing.type === 'bundle');
|
|
@@ -440,14 +456,21 @@ class BundleGraph {
|
|
|
440
456
|
value: {
|
|
441
457
|
id: bundleId,
|
|
442
458
|
hashReference: opts.shouldContentHash ? _constants.HASH_REF_PREFIX + bundleId : bundleId.slice(-8),
|
|
459
|
+
// @ts-expect-error TS2339
|
|
443
460
|
type: opts.entryAsset ? opts.entryAsset.type : opts.type,
|
|
444
461
|
env: opts.env,
|
|
445
462
|
entryAssetIds: entryAsset ? [entryAsset.id] : [],
|
|
446
463
|
mainEntryId: entryAsset === null || entryAsset === void 0 ? void 0 : entryAsset.id,
|
|
464
|
+
// @ts-expect-error TS2339
|
|
447
465
|
pipeline: opts.entryAsset ? opts.entryAsset.pipeline : opts.pipeline,
|
|
448
466
|
needsStableName: opts.needsStableName,
|
|
449
467
|
bundleBehavior: opts.bundleBehavior != null ? _types.BundleBehavior[opts.bundleBehavior] : null,
|
|
450
|
-
|
|
468
|
+
// @ts-expect-error TS2339
|
|
469
|
+
isSplittable: opts.entryAsset ?
|
|
470
|
+
// @ts-expect-error TS2339
|
|
471
|
+
opts.entryAsset.isBundleSplittable :
|
|
472
|
+
// @ts-expect-error TS2339
|
|
473
|
+
opts.isSplittable,
|
|
451
474
|
isPlaceholder,
|
|
452
475
|
target,
|
|
453
476
|
name: null,
|
|
@@ -456,8 +479,12 @@ class BundleGraph {
|
|
|
456
479
|
}
|
|
457
480
|
};
|
|
458
481
|
let bundleNodeId = this._graph.addNodeByContentKey(bundleId, bundleNode);
|
|
482
|
+
|
|
483
|
+
// @ts-expect-error TS2339
|
|
459
484
|
if (opts.entryAsset) {
|
|
460
|
-
this._graph.addEdge(bundleNodeId,
|
|
485
|
+
this._graph.addEdge(bundleNodeId,
|
|
486
|
+
// @ts-expect-error TS2339
|
|
487
|
+
this._graph.getNodeIdByContentKey(opts.entryAsset.id));
|
|
461
488
|
}
|
|
462
489
|
_assert().default;
|
|
463
490
|
return bundleNode.value;
|
|
@@ -470,9 +497,14 @@ class BundleGraph {
|
|
|
470
497
|
for (let dependency of dependencies) {
|
|
471
498
|
let dependencyNodeId = this._graph.getNodeIdByContentKey(dependency.id);
|
|
472
499
|
this._graph.addEdge(bundleNodeId, dependencyNodeId, bundleGraphEdgeTypes.contains);
|
|
473
|
-
for (let [bundleGroupNodeId, bundleGroupNode] of this._graph.getNodeIdsConnectedFrom(dependencyNodeId).map(id => [id, (0, _nullthrows().default)(this._graph.getNode(id))])
|
|
500
|
+
for (let [bundleGroupNodeId, bundleGroupNode] of this._graph.getNodeIdsConnectedFrom(dependencyNodeId).map(id => [id, (0, _nullthrows().default)(this._graph.getNode(id))])
|
|
501
|
+
// @ts-expect-error TS2769
|
|
502
|
+
.filter(([, node]) => node.type === 'bundle_group')) {
|
|
503
|
+
// @ts-expect-error TS2339
|
|
474
504
|
(0, _assert().default)(bundleGroupNode.type === 'bundle_group');
|
|
475
|
-
this._graph.addEdge(bundleNodeId,
|
|
505
|
+
this._graph.addEdge(bundleNodeId,
|
|
506
|
+
// @ts-expect-error TS2345
|
|
507
|
+
bundleGroupNodeId, bundleGraphEdgeTypes.bundle);
|
|
476
508
|
}
|
|
477
509
|
// If the dependency references a target bundle, add a reference edge from
|
|
478
510
|
// the source bundle to the dependency for easy traversal.
|
|
@@ -503,9 +535,14 @@ class BundleGraph {
|
|
|
503
535
|
this._graph.addEdge(bundleNodeId, nodeId, bundleGraphEdgeTypes.contains);
|
|
504
536
|
}
|
|
505
537
|
if (node.type === 'dependency') {
|
|
506
|
-
for (let [bundleGroupNodeId, bundleGroupNode] of this._graph.getNodeIdsConnectedFrom(nodeId).map(id => [id, (0, _nullthrows().default)(this._graph.getNode(id))])
|
|
538
|
+
for (let [bundleGroupNodeId, bundleGroupNode] of this._graph.getNodeIdsConnectedFrom(nodeId).map(id => [id, (0, _nullthrows().default)(this._graph.getNode(id))])
|
|
539
|
+
// @ts-expect-error TS2769
|
|
540
|
+
.filter(([, node]) => node.type === 'bundle_group')) {
|
|
541
|
+
// @ts-expect-error TS2339
|
|
507
542
|
(0, _assert().default)(bundleGroupNode.type === 'bundle_group');
|
|
508
|
-
this._graph.addEdge(bundleNodeId,
|
|
543
|
+
this._graph.addEdge(bundleNodeId,
|
|
544
|
+
// @ts-expect-error TS2345
|
|
545
|
+
bundleGroupNodeId, bundleGraphEdgeTypes.bundle);
|
|
509
546
|
}
|
|
510
547
|
|
|
511
548
|
// If the dependency references a target bundle, add a reference edge from
|
|
@@ -616,8 +653,12 @@ class BundleGraph {
|
|
|
616
653
|
return this.getBundlesInBundleGroup(node.value, {
|
|
617
654
|
includeInline: true
|
|
618
655
|
}).find(b => {
|
|
619
|
-
|
|
620
|
-
|
|
656
|
+
if ((0, _featureFlags().getFeatureFlag)('supportWebpackChunkName')) {
|
|
657
|
+
return b.entryAssetIds.some(id => id === node.value.entryAssetId);
|
|
658
|
+
} else {
|
|
659
|
+
let mainEntryId = b.entryAssetIds[b.entryAssetIds.length - 1];
|
|
660
|
+
return mainEntryId != null && node.value.entryAssetId === mainEntryId;
|
|
661
|
+
}
|
|
621
662
|
});
|
|
622
663
|
}
|
|
623
664
|
}
|
|
@@ -805,6 +846,7 @@ class BundleGraph {
|
|
|
805
846
|
}
|
|
806
847
|
}, this._graph.getNodeIdByContentKey(dep.id), bundleGraphEdgeTypes.references);
|
|
807
848
|
if (bundle) {
|
|
849
|
+
// @ts-expect-error TS2322
|
|
808
850
|
resolved = potential.find(a => a.type === bundle.type);
|
|
809
851
|
}
|
|
810
852
|
resolved ||= potential[0];
|
|
@@ -859,18 +901,126 @@ class BundleGraph {
|
|
|
859
901
|
return;
|
|
860
902
|
}
|
|
861
903
|
visitedBundles.add(descendant);
|
|
862
|
-
if (descendant.type !== bundle.type || descendant.env.context !== bundle.env.context) {
|
|
904
|
+
if (descendant.type !== bundle.type || (0, _EnvironmentManager.fromEnvironmentId)(descendant.env).context !== (0, _EnvironmentManager.fromEnvironmentId)(bundle.env).context) {
|
|
863
905
|
actions.skipChildren();
|
|
864
906
|
return;
|
|
865
907
|
}
|
|
866
908
|
if (bundleHasReference(descendant)) {
|
|
867
909
|
isReferenced = true;
|
|
868
910
|
actions.stop();
|
|
911
|
+
return;
|
|
869
912
|
}
|
|
870
913
|
}, referencer);
|
|
871
914
|
return isReferenced;
|
|
872
915
|
});
|
|
873
916
|
}
|
|
917
|
+
|
|
918
|
+
// New method: Fast checks only (no caching of results)
|
|
919
|
+
isAssetReferencedFastCheck(bundle, asset) {
|
|
920
|
+
// Fast Check #1: If asset is in multiple bundles in same target, it's referenced
|
|
921
|
+
let bundlesWithAsset = this.getBundlesWithAsset(asset).filter(b => b.target.name === bundle.target.name && b.target.distDir === bundle.target.distDir);
|
|
922
|
+
if (bundlesWithAsset.length > 1) {
|
|
923
|
+
return true;
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
// Fast Check #2: If asset is referenced by any async/conditional dependency, it's referenced
|
|
927
|
+
let assetNodeId = (0, _nullthrows().default)(this._graph.getNodeIdByContentKey(asset.id));
|
|
928
|
+
if (this._graph.getNodeIdsConnectedTo(assetNodeId, bundleGraphEdgeTypes.references).map(id => this._graph.getNode(id)).some(node => (node === null || node === void 0 ? void 0 : node.type) === 'dependency' && (node.value.priority === _types.Priority.lazy || node.value.priority === _types.Priority.conditional) && node.value.specifierType !== _types.SpecifierType.url)) {
|
|
929
|
+
return true;
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
// Fast checks failed - return null to indicate expensive computation needed
|
|
933
|
+
return null;
|
|
934
|
+
}
|
|
935
|
+
getReferencedAssets(bundle) {
|
|
936
|
+
let referencedAssets = new Set();
|
|
937
|
+
|
|
938
|
+
// Build a map of all assets in this bundle with their dependencies
|
|
939
|
+
// This allows us to check all assets in a single traversal
|
|
940
|
+
let assetDependenciesMap = new Map();
|
|
941
|
+
this.traverseAssets(bundle, asset => {
|
|
942
|
+
// Always do fast checks (no caching)
|
|
943
|
+
let fastCheckResult = this.isAssetReferencedFastCheck(bundle, asset);
|
|
944
|
+
if (fastCheckResult === true) {
|
|
945
|
+
referencedAssets.add(asset);
|
|
946
|
+
return;
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
// Fast checks failed (fastCheckResult === null), need expensive computation
|
|
950
|
+
// Check if it's actually referenced via traversal
|
|
951
|
+
|
|
952
|
+
// Store dependencies for later batch checking
|
|
953
|
+
let dependencies = this._graph.getNodeIdsConnectedTo((0, _nullthrows().default)(this._graph.getNodeIdByContentKey(asset.id))).map(id => (0, _nullthrows().default)(this._graph.getNode(id))).filter(node => node.type === 'dependency').map(node => {
|
|
954
|
+
(0, _assert().default)(node.type === 'dependency');
|
|
955
|
+
return node.value;
|
|
956
|
+
});
|
|
957
|
+
if (dependencies.length > 0) {
|
|
958
|
+
assetDependenciesMap.set(asset, dependencies);
|
|
959
|
+
}
|
|
960
|
+
});
|
|
961
|
+
|
|
962
|
+
// If no assets need the expensive check, return early
|
|
963
|
+
if (assetDependenciesMap.size === 0) {
|
|
964
|
+
return referencedAssets;
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
// Get the assets we need to check once
|
|
968
|
+
let assetsToCheck = Array.from(assetDependenciesMap.keys());
|
|
969
|
+
|
|
970
|
+
// Helper function to check if all assets from assetDependenciesMap are in referencedAssets
|
|
971
|
+
const allAssetsReferenced = () => assetsToCheck.length <= referencedAssets.size && assetsToCheck.every(asset => referencedAssets.has(asset));
|
|
972
|
+
|
|
973
|
+
// Do ONE traversal to check all remaining assets
|
|
974
|
+
// We can share visitedBundles across all assets because we check every asset
|
|
975
|
+
// against every visited bundle, which matches the original per-asset behavior
|
|
976
|
+
let siblingBundles = new Set(this.getBundleGroupsContainingBundle(bundle).flatMap(bundleGroup => this.getBundlesInBundleGroup(bundleGroup, {
|
|
977
|
+
includeInline: true
|
|
978
|
+
})));
|
|
979
|
+
let visitedBundles = new Set();
|
|
980
|
+
|
|
981
|
+
// Single traversal from all referencers
|
|
982
|
+
for (let referencer of siblingBundles) {
|
|
983
|
+
this.traverseBundles((descendant, _, actions) => {
|
|
984
|
+
if (descendant.id === bundle.id) {
|
|
985
|
+
return;
|
|
986
|
+
}
|
|
987
|
+
if (visitedBundles.has(descendant)) {
|
|
988
|
+
actions.skipChildren();
|
|
989
|
+
return;
|
|
990
|
+
}
|
|
991
|
+
visitedBundles.add(descendant);
|
|
992
|
+
if (descendant.type !== bundle.type || (0, _EnvironmentManager.fromEnvironmentId)(descendant.env).context !== (0, _EnvironmentManager.fromEnvironmentId)(bundle.env).context) {
|
|
993
|
+
// Don't skip children - they might be the right type!
|
|
994
|
+
return;
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
// Check ALL assets at once in this descendant bundle
|
|
998
|
+
for (let [asset, dependencies] of assetDependenciesMap) {
|
|
999
|
+
// Skip if already marked as referenced
|
|
1000
|
+
if (referencedAssets.has(asset)) {
|
|
1001
|
+
continue;
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
// Check if this descendant bundle references the asset
|
|
1005
|
+
if (!this.bundleHasAsset(descendant, asset) && dependencies.some(dependency => this.bundleHasDependency(descendant, dependency))) {
|
|
1006
|
+
referencedAssets.add(asset);
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
// If all assets from assetDependenciesMap are now marked as referenced, we can stop early
|
|
1011
|
+
if (allAssetsReferenced()) {
|
|
1012
|
+
actions.stop();
|
|
1013
|
+
return;
|
|
1014
|
+
}
|
|
1015
|
+
}, referencer);
|
|
1016
|
+
|
|
1017
|
+
// If all assets from assetDependenciesMap are referenced, no need to check more sibling bundles
|
|
1018
|
+
if (allAssetsReferenced()) {
|
|
1019
|
+
break;
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
return referencedAssets;
|
|
1023
|
+
}
|
|
874
1024
|
hasParentBundleOfType(bundle, type) {
|
|
875
1025
|
let parents = this.getParentBundles(bundle);
|
|
876
1026
|
return parents.length > 0 && parents.every(parent => parent.type === type);
|
|
@@ -887,7 +1037,7 @@ class BundleGraph {
|
|
|
887
1037
|
isAssetReachableFromBundle(asset, bundle) {
|
|
888
1038
|
// If a bundle's environment is isolated, it can't access assets present
|
|
889
1039
|
// in any ancestor bundles. Don't consider any assets reachable.
|
|
890
|
-
if (_Environment.ISOLATED_ENVS.has(bundle.env.context) || !bundle.isSplittable || bundle.bundleBehavior === _types.BundleBehavior.isolated || bundle.bundleBehavior === _types.BundleBehavior.inline) {
|
|
1040
|
+
if (_Environment.ISOLATED_ENVS.has((0, _EnvironmentManager.fromEnvironmentId)(bundle.env).context) || !bundle.isSplittable || bundle.bundleBehavior === _types.BundleBehavior.isolated || bundle.bundleBehavior === _types.BundleBehavior.inline || bundle.bundleBehavior === _types.BundleBehavior.inlineIsolated) {
|
|
891
1041
|
return false;
|
|
892
1042
|
}
|
|
893
1043
|
|
|
@@ -897,7 +1047,7 @@ class BundleGraph {
|
|
|
897
1047
|
return bundleGroups.every(bundleGroup => {
|
|
898
1048
|
// If the asset is in any sibling bundles of the original bundle, it is reachable.
|
|
899
1049
|
let bundles = this.getBundlesInBundleGroup(bundleGroup);
|
|
900
|
-
if (bundles.some(b => b.id !== bundle.id && b.bundleBehavior !== _types.BundleBehavior.isolated && b.bundleBehavior !== _types.BundleBehavior.inline && this.bundleHasAsset(b, asset))) {
|
|
1050
|
+
if (bundles.some(b => b.id !== bundle.id && b.bundleBehavior !== _types.BundleBehavior.isolated && b.bundleBehavior !== _types.BundleBehavior.inline && b.bundleBehavior !== _types.BundleBehavior.inlineIsolated && this.bundleHasAsset(b, asset))) {
|
|
901
1051
|
return true;
|
|
902
1052
|
}
|
|
903
1053
|
|
|
@@ -907,7 +1057,7 @@ class BundleGraph {
|
|
|
907
1057
|
// Check that every parent bundle has a bundle group in its ancestry that contains the asset.
|
|
908
1058
|
return parentBundleNodes.every(bundleNodeId => {
|
|
909
1059
|
let bundleNode = (0, _nullthrows().default)(this._graph.getNode(bundleNodeId));
|
|
910
|
-
if (bundleNode.type !== 'bundle' || bundleNode.value.bundleBehavior === _types.BundleBehavior.isolated || bundleNode.value.bundleBehavior === _types.BundleBehavior.inline) {
|
|
1060
|
+
if (bundleNode.type !== 'bundle' || bundleNode.value.bundleBehavior === _types.BundleBehavior.isolated || bundleNode.value.bundleBehavior === _types.BundleBehavior.inline || bundleNode.value.bundleBehavior === _types.BundleBehavior.inlineIsolated) {
|
|
911
1061
|
return false;
|
|
912
1062
|
}
|
|
913
1063
|
let isReachable = true;
|
|
@@ -915,15 +1065,16 @@ class BundleGraph {
|
|
|
915
1065
|
let node = (0, _nullthrows().default)(this._graph.getNode(nodeId));
|
|
916
1066
|
// If we've reached the root or a context change without
|
|
917
1067
|
// finding this asset in the ancestry, it is not reachable.
|
|
918
|
-
if (node.type === 'root' || node.type === 'bundle' && (node.value.id === bundle.id || node.value.env.context !== bundle.env.context)) {
|
|
1068
|
+
if (node.type === 'root' || node.type === 'bundle' && (node.value.id === bundle.id || (0, _EnvironmentManager.fromEnvironmentId)(node.value.env).context !== (0, _EnvironmentManager.fromEnvironmentId)(bundle.env).context)) {
|
|
919
1069
|
isReachable = false;
|
|
920
1070
|
actions.stop();
|
|
921
1071
|
return;
|
|
922
1072
|
}
|
|
923
1073
|
if (node.type === 'bundle_group') {
|
|
924
1074
|
let childBundles = this.getBundlesInBundleGroup(node.value);
|
|
925
|
-
if (childBundles.some(b => b.id !== bundle.id && b.bundleBehavior !== _types.BundleBehavior.isolated && b.bundleBehavior !== _types.BundleBehavior.inline && this.bundleHasAsset(b, asset))) {
|
|
1075
|
+
if (childBundles.some(b => b.id !== bundle.id && b.bundleBehavior !== _types.BundleBehavior.isolated && b.bundleBehavior !== _types.BundleBehavior.inline && b.bundleBehavior !== _types.BundleBehavior.inlineIsolated && this.bundleHasAsset(b, asset))) {
|
|
926
1076
|
actions.skipChildren();
|
|
1077
|
+
return;
|
|
927
1078
|
}
|
|
928
1079
|
}
|
|
929
1080
|
}, [bundleGraphEdgeTypes.references, bundleGraphEdgeTypes.bundle]);
|
|
@@ -958,7 +1109,9 @@ class BundleGraph {
|
|
|
958
1109
|
startNodeId: startAsset ? this._graph.getNodeIdByContentKey(startAsset.id) : bundleNodeId,
|
|
959
1110
|
getChildren: nodeId => {
|
|
960
1111
|
let children = this._graph.getNodeIdsConnectedFrom(nodeId).map(id => [id, (0, _nullthrows().default)(this._graph.getNode(id))]);
|
|
961
|
-
let sorted = entries && bundle.entryAssetIds.length > 0 ?
|
|
1112
|
+
let sorted = entries && bundle.entryAssetIds.length > 0 ?
|
|
1113
|
+
// @ts-expect-error TS2345
|
|
1114
|
+
children.sort(([, a], [, b]) => {
|
|
962
1115
|
let aIndex = bundle.entryAssetIds.indexOf(a.id);
|
|
963
1116
|
let bIndex = bundle.entryAssetIds.indexOf(b.id);
|
|
964
1117
|
if (aIndex === bIndex) {
|
|
@@ -973,6 +1126,7 @@ class BundleGraph {
|
|
|
973
1126
|
return aIndex - bIndex;
|
|
974
1127
|
}) : children;
|
|
975
1128
|
entries = false;
|
|
1129
|
+
// @ts-expect-error TS2345
|
|
976
1130
|
return sorted.map(([id]) => id);
|
|
977
1131
|
}
|
|
978
1132
|
});
|
|
@@ -1010,7 +1164,7 @@ class BundleGraph {
|
|
|
1010
1164
|
getBundles(opts) {
|
|
1011
1165
|
let bundles = [];
|
|
1012
1166
|
this.traverseBundles(bundle => {
|
|
1013
|
-
if (opts !== null && opts !== void 0 && opts.includeInline || bundle.bundleBehavior !== _types.BundleBehavior.inline) {
|
|
1167
|
+
if (opts !== null && opts !== void 0 && opts.includeInline || bundle.bundleBehavior !== _types.BundleBehavior.inline && bundle.bundleBehavior !== _types.BundleBehavior.inlineIsolated) {
|
|
1014
1168
|
bundles.push(bundle);
|
|
1015
1169
|
}
|
|
1016
1170
|
});
|
|
@@ -1061,7 +1215,7 @@ class BundleGraph {
|
|
|
1061
1215
|
let bundleNode = (0, _nullthrows().default)(this._graph.getNode(bundleNodeId));
|
|
1062
1216
|
(0, _assert().default)(bundleNode.type === 'bundle');
|
|
1063
1217
|
let bundle = bundleNode.value;
|
|
1064
|
-
if (opts !== null && opts !== void 0 && opts.includeInline || bundle.bundleBehavior !== _types.BundleBehavior.inline) {
|
|
1218
|
+
if (opts !== null && opts !== void 0 && opts.includeInline || bundle.bundleBehavior !== _types.BundleBehavior.inline && bundle.bundleBehavior !== _types.BundleBehavior.inlineIsolated) {
|
|
1065
1219
|
bundles.add(bundle);
|
|
1066
1220
|
}
|
|
1067
1221
|
for (let referencedBundle of this.getReferencedBundles(bundle, {
|
|
@@ -1085,7 +1239,7 @@ class BundleGraph {
|
|
|
1085
1239
|
if (node.value.id === bundle.id) {
|
|
1086
1240
|
return;
|
|
1087
1241
|
}
|
|
1088
|
-
if (includeInline || node.value.bundleBehavior !== _types.BundleBehavior.inline) {
|
|
1242
|
+
if (includeInline || node.value.bundleBehavior !== _types.BundleBehavior.inline && node.value.bundleBehavior !== _types.BundleBehavior.inlineIsolated) {
|
|
1089
1243
|
referencedBundles.add(node.value);
|
|
1090
1244
|
}
|
|
1091
1245
|
if (!recursive) {
|
|
@@ -1099,6 +1253,8 @@ class BundleGraph {
|
|
|
1099
1253
|
// TODO: Should this be the case?
|
|
1100
1254
|
this._graph.getNodeIdsConnectedFrom(nodeId, bundleGraphEdgeTypes.references)
|
|
1101
1255
|
});
|
|
1256
|
+
|
|
1257
|
+
// @ts-expect-error TS2322
|
|
1102
1258
|
return [...referencedBundles];
|
|
1103
1259
|
}
|
|
1104
1260
|
getIncomingDependencies(asset) {
|
|
@@ -1118,7 +1274,9 @@ class BundleGraph {
|
|
|
1118
1274
|
}
|
|
1119
1275
|
let res = null;
|
|
1120
1276
|
let count = 0;
|
|
1121
|
-
this._graph.forEachNodeIdConnectedTo(this._graph.getNodeIdByContentKey(dep.id),
|
|
1277
|
+
this._graph.forEachNodeIdConnectedTo(this._graph.getNodeIdByContentKey(dep.id),
|
|
1278
|
+
// @ts-expect-error TS2345
|
|
1279
|
+
node => {
|
|
1122
1280
|
res = node;
|
|
1123
1281
|
count += 1;
|
|
1124
1282
|
if (count > 1) {
|
|
@@ -1282,11 +1440,13 @@ class BundleGraph {
|
|
|
1282
1440
|
let result = identifier;
|
|
1283
1441
|
if (skipped) {
|
|
1284
1442
|
// ... and it was excluded (by symbol propagation) or deferred.
|
|
1443
|
+
// @ts-expect-error TS2322
|
|
1285
1444
|
result = false;
|
|
1286
1445
|
} else {
|
|
1287
1446
|
// ... and there is no single reexport, but it might still be exported:
|
|
1288
1447
|
if (found) {
|
|
1289
1448
|
// Fallback to namespace access, because of a bundle boundary.
|
|
1449
|
+
// @ts-expect-error TS2322
|
|
1290
1450
|
result = null;
|
|
1291
1451
|
} else if (result === undefined) {
|
|
1292
1452
|
var _asset$symbols5;
|
|
@@ -1294,6 +1454,7 @@ class BundleGraph {
|
|
|
1294
1454
|
if (nonStaticDependency || (_asset$symbols5 = asset.symbols) !== null && _asset$symbols5 !== void 0 && _asset$symbols5.has('*')) {
|
|
1295
1455
|
// ... and if there are non-statically analyzable dependencies or it's a CJS asset,
|
|
1296
1456
|
// fallback to namespace access.
|
|
1457
|
+
// @ts-expect-error TS2322
|
|
1297
1458
|
result = null;
|
|
1298
1459
|
}
|
|
1299
1460
|
// (It shouldn't be possible for the symbol to be in a reexport-all and to end up here).
|
|
@@ -1381,7 +1542,7 @@ class BundleGraph {
|
|
|
1381
1542
|
includeInline: true
|
|
1382
1543
|
});
|
|
1383
1544
|
for (let referenced of referencedBundles) {
|
|
1384
|
-
if (referenced.bundleBehavior === _types.BundleBehavior.inline) {
|
|
1545
|
+
if (referenced.bundleBehavior === _types.BundleBehavior.inline || referenced.bundleBehavior === _types.BundleBehavior.inlineIsolated) {
|
|
1385
1546
|
bundles.push(referenced);
|
|
1386
1547
|
addReferencedBundles(referenced);
|
|
1387
1548
|
}
|
|
@@ -1389,7 +1550,7 @@ class BundleGraph {
|
|
|
1389
1550
|
};
|
|
1390
1551
|
addReferencedBundles(bundle);
|
|
1391
1552
|
this.traverseBundles((childBundle, _, traversal) => {
|
|
1392
|
-
if (childBundle.bundleBehavior === _types.BundleBehavior.inline) {
|
|
1553
|
+
if (childBundle.bundleBehavior === _types.BundleBehavior.inline || childBundle.bundleBehavior === _types.BundleBehavior.inlineIsolated) {
|
|
1393
1554
|
bundles.push(childBundle);
|
|
1394
1555
|
} else if (childBundle.id !== bundle.id) {
|
|
1395
1556
|
traversal.skipChildren();
|
|
@@ -1410,7 +1571,7 @@ class BundleGraph {
|
|
|
1410
1571
|
for (let referencedBundle of this.getReferencedBundles(bundle)) {
|
|
1411
1572
|
hash.writeString(referencedBundle.id);
|
|
1412
1573
|
}
|
|
1413
|
-
hash.writeString(JSON.stringify((0, _utils().objectSortedEntriesDeep)(bundle.env)));
|
|
1574
|
+
hash.writeString(JSON.stringify((0, _utils().objectSortedEntriesDeep)((0, _EnvironmentManager.fromEnvironmentId)(bundle.env))));
|
|
1414
1575
|
return hash.finish();
|
|
1415
1576
|
}
|
|
1416
1577
|
getBundleGraphHash() {
|
|
@@ -1469,6 +1630,8 @@ class BundleGraph {
|
|
|
1469
1630
|
otherGraphIdToThisNodeId.set(otherNodeId, updateNodeId);
|
|
1470
1631
|
}
|
|
1471
1632
|
}
|
|
1633
|
+
|
|
1634
|
+
// @ts-expect-error TS2488
|
|
1472
1635
|
for (let edge of other._graph.getAllEdges()) {
|
|
1473
1636
|
this._graph.addEdge((0, _nullthrows().default)(otherGraphIdToThisNodeId.get(edge.from)), (0, _nullthrows().default)(otherGraphIdToThisNodeId.get(edge.to)), edge.type);
|
|
1474
1637
|
}
|
|
@@ -1521,6 +1684,8 @@ class BundleGraph {
|
|
|
1521
1684
|
startNodeId: this._graph.getNodeIdByContentKey(bundle.id),
|
|
1522
1685
|
getChildren: nodeId => this._graph.getNodeIdsConnectedFrom(nodeId, bundleGraphEdgeTypes.conditional)
|
|
1523
1686
|
});
|
|
1687
|
+
|
|
1688
|
+
// @ts-expect-error TS2322
|
|
1524
1689
|
return [...referencedBundles];
|
|
1525
1690
|
}
|
|
1526
1691
|
}
|
package/lib/CommittedAsset.js
CHANGED
|
@@ -26,7 +26,7 @@ function _utils() {
|
|
|
26
26
|
return data;
|
|
27
27
|
}
|
|
28
28
|
function _sourceMap() {
|
|
29
|
-
const data = _interopRequireDefault(require("@
|
|
29
|
+
const data = _interopRequireDefault(require("@atlaspack/source-map"));
|
|
30
30
|
_sourceMap = function () {
|
|
31
31
|
return data;
|
|
32
32
|
};
|
|
@@ -74,6 +74,7 @@ class CommittedAsset {
|
|
|
74
74
|
if (typeof content === 'string' || content instanceof Buffer) {
|
|
75
75
|
return content.toString();
|
|
76
76
|
} else if (content != null) {
|
|
77
|
+
// @ts-expect-error TS2345
|
|
77
78
|
this.content = (0, _utils().bufferStream)(content);
|
|
78
79
|
return (await this.content).toString();
|
|
79
80
|
}
|
|
@@ -86,7 +87,10 @@ class CommittedAsset {
|
|
|
86
87
|
} else if (typeof content === 'string' || content instanceof Buffer) {
|
|
87
88
|
return Buffer.from(content);
|
|
88
89
|
}
|
|
90
|
+
|
|
91
|
+
// @ts-expect-error TS2345
|
|
89
92
|
this.content = (0, _utils().bufferStream)(content);
|
|
93
|
+
// @ts-expect-error TS2322
|
|
90
94
|
return this.content;
|
|
91
95
|
}
|
|
92
96
|
getStream() {
|
|
@@ -125,6 +129,8 @@ class CommittedAsset {
|
|
|
125
129
|
}
|
|
126
130
|
})();
|
|
127
131
|
}
|
|
132
|
+
|
|
133
|
+
// @ts-expect-error TS2322
|
|
128
134
|
return this.mapBuffer ?? Promise.resolve();
|
|
129
135
|
}
|
|
130
136
|
getMap() {
|
package/lib/Dependency.js
CHANGED
|
@@ -24,6 +24,7 @@ function _assert() {
|
|
|
24
24
|
return data;
|
|
25
25
|
}
|
|
26
26
|
var _IdentifierRegistry = require("./IdentifierRegistry");
|
|
27
|
+
var _EnvironmentManager = require("./EnvironmentManager");
|
|
27
28
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
28
29
|
function createDependencyId({
|
|
29
30
|
sourceAssetId,
|
|
@@ -41,8 +42,11 @@ function createDependencyId({
|
|
|
41
42
|
const params = {
|
|
42
43
|
sourceAssetId,
|
|
43
44
|
specifier,
|
|
44
|
-
environmentId: env
|
|
45
|
-
target
|
|
45
|
+
environmentId: (0, _EnvironmentManager.toEnvironmentId)(env),
|
|
46
|
+
target: target != null ? {
|
|
47
|
+
...target,
|
|
48
|
+
env: (0, _EnvironmentManager.fromEnvironmentId)(target.env)
|
|
49
|
+
} : null,
|
|
46
50
|
pipeline,
|
|
47
51
|
specifierType: _types.SpecifierType[specifierType],
|
|
48
52
|
bundleBehavior,
|
|
@@ -121,7 +125,9 @@ function convertConditions(conditions, dep) {
|
|
|
121
125
|
let packageConditions = 0;
|
|
122
126
|
let customConditions = [];
|
|
123
127
|
for (let condition of conditions) {
|
|
128
|
+
// @ts-expect-error TS7053
|
|
124
129
|
if (_types.ExportsCondition[condition]) {
|
|
130
|
+
// @ts-expect-error TS7053
|
|
125
131
|
packageConditions |= _types.ExportsCondition[condition];
|
|
126
132
|
} else {
|
|
127
133
|
customConditions.push(condition);
|
package/lib/Environment.js
CHANGED
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createEnvironment = createEnvironment;
|
|
7
|
+
exports.getEnvironmentHash = getEnvironmentHash;
|
|
7
8
|
exports.mergeEnvironments = mergeEnvironments;
|
|
8
9
|
function _rust() {
|
|
9
10
|
const data = require("@atlaspack/rust");
|
|
@@ -15,6 +16,7 @@ function _rust() {
|
|
|
15
16
|
var _utils = require("./utils");
|
|
16
17
|
var _Environment = _interopRequireWildcard(require("./public/Environment"));
|
|
17
18
|
var _IdentifierRegistry = require("./IdentifierRegistry");
|
|
19
|
+
var _EnvironmentManager = require("./EnvironmentManager");
|
|
18
20
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
19
21
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
20
22
|
const DEFAULT_ENGINES = {
|
|
@@ -32,7 +34,8 @@ function createEnvironment({
|
|
|
32
34
|
shouldScopeHoist = false,
|
|
33
35
|
sourceMap,
|
|
34
36
|
unstableSingleFileOutput = false,
|
|
35
|
-
loc
|
|
37
|
+
loc,
|
|
38
|
+
customEnv
|
|
36
39
|
} = {
|
|
37
40
|
/*::...null*/
|
|
38
41
|
}) {
|
|
@@ -57,8 +60,10 @@ function createEnvironment({
|
|
|
57
60
|
case 'browser':
|
|
58
61
|
case 'web-worker':
|
|
59
62
|
case 'service-worker':
|
|
63
|
+
case 'tesseract':
|
|
60
64
|
case 'electron-renderer':
|
|
61
65
|
engines = {
|
|
66
|
+
// @ts-expect-error TS2322
|
|
62
67
|
browsers: DEFAULT_ENGINES.browsers
|
|
63
68
|
};
|
|
64
69
|
break;
|
|
@@ -76,6 +81,7 @@ function createEnvironment({
|
|
|
76
81
|
case 'browser':
|
|
77
82
|
case 'web-worker':
|
|
78
83
|
case 'service-worker':
|
|
84
|
+
case 'tesseract':
|
|
79
85
|
default:
|
|
80
86
|
includeNodeModules = true;
|
|
81
87
|
break;
|
|
@@ -96,6 +102,7 @@ function createEnvironment({
|
|
|
96
102
|
let res = {
|
|
97
103
|
id: '',
|
|
98
104
|
context,
|
|
105
|
+
// @ts-expect-error TS2322
|
|
99
106
|
engines,
|
|
100
107
|
includeNodeModules,
|
|
101
108
|
outputFormat,
|
|
@@ -105,21 +112,20 @@ function createEnvironment({
|
|
|
105
112
|
shouldScopeHoist,
|
|
106
113
|
sourceMap,
|
|
107
114
|
unstableSingleFileOutput,
|
|
108
|
-
loc
|
|
115
|
+
loc,
|
|
116
|
+
customEnv
|
|
109
117
|
};
|
|
110
118
|
res.id = getEnvironmentHash(res);
|
|
111
|
-
return Object.freeze(res);
|
|
119
|
+
return (0, _EnvironmentManager.toEnvironmentRef)(Object.freeze(res));
|
|
112
120
|
}
|
|
113
121
|
function mergeEnvironments(projectRoot, a, b) {
|
|
114
122
|
// If merging the same object, avoid copying.
|
|
115
123
|
if (a === b || !b) {
|
|
116
|
-
return a;
|
|
124
|
+
return (0, _EnvironmentManager.toEnvironmentRef)(a);
|
|
117
125
|
}
|
|
118
126
|
if (b instanceof _Environment.default) {
|
|
119
|
-
return (0, _Environment.environmentToInternalEnvironment)(b);
|
|
127
|
+
return (0, _EnvironmentManager.toEnvironmentRef)((0, _Environment.environmentToInternalEnvironment)(b));
|
|
120
128
|
}
|
|
121
|
-
|
|
122
|
-
// $FlowFixMe - ignore the `id` that is already on a
|
|
123
129
|
return createEnvironment({
|
|
124
130
|
...a,
|
|
125
131
|
...b,
|
|
@@ -136,7 +142,8 @@ function getEnvironmentHash(env) {
|
|
|
136
142
|
isLibrary: env.isLibrary,
|
|
137
143
|
shouldOptimize: env.shouldOptimize,
|
|
138
144
|
shouldScopeHoist: env.shouldScopeHoist,
|
|
139
|
-
sourceMap: env.sourceMap
|
|
145
|
+
sourceMap: env.sourceMap,
|
|
146
|
+
customEnv: env.customEnv
|
|
140
147
|
};
|
|
141
148
|
const id = (0, _rust().createEnvironmentId)(data);
|
|
142
149
|
_IdentifierRegistry.identifierRegistry.addIdentifier('environment', id, data);
|