@atlaspack/core 2.16.2-canary.48 → 2.16.2-canary.481
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 +1324 -0
- package/dist/AssetGraph.js +523 -0
- package/dist/Atlaspack.js +701 -0
- package/dist/AtlaspackConfig.js +324 -0
- package/dist/AtlaspackConfig.schema.js +117 -0
- package/dist/BundleGraph.js +1906 -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 +470 -0
- package/dist/ReporterRunner.js +151 -0
- package/dist/RequestTracker.js +1297 -0
- package/dist/SymbolPropagation.js +624 -0
- package/dist/TargetDescriptor.schema.js +146 -0
- package/dist/Transformation.js +514 -0
- package/dist/UncommittedAsset.js +310 -0
- package/dist/Validation.js +196 -0
- package/dist/applyRuntimes.js +384 -0
- package/dist/assetUtils.js +169 -0
- package/dist/atlaspack-v3/AtlaspackV3.js +83 -0
- package/dist/atlaspack-v3/NapiWorkerPool.js +114 -0
- package/dist/atlaspack-v3/fs.js +53 -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 +24 -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-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 +398 -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 +430 -0
- package/dist/requests/AssetGraphRequestRust.js +471 -0
- package/dist/requests/AssetRequest.js +130 -0
- package/dist/requests/AtlaspackBuildRequest.js +98 -0
- package/dist/requests/AtlaspackConfigRequest.js +493 -0
- package/dist/requests/BundleGraphRequest.js +381 -0
- package/dist/requests/BundleGraphRequestRust.js +324 -0
- package/dist/requests/BundleGraphRequestUtils.js +262 -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 +89 -0
- package/dist/requests/PathRequest.js +349 -0
- package/dist/requests/TargetRequest.js +1316 -0
- package/dist/requests/ValidationRequest.js +49 -0
- package/dist/requests/WriteBundleRequest.js +522 -0
- package/dist/requests/WriteBundlesRequest.js +190 -0
- package/dist/requests/asset-graph-diff.js +128 -0
- package/dist/requests/asset-graph-dot.js +131 -0
- package/dist/resolveOptions.js +267 -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 +53 -15
- package/lib/Atlaspack.js +140 -56
- package/lib/AtlaspackConfig.js +17 -6
- package/lib/AtlaspackConfig.schema.js +16 -5
- package/lib/BundleGraph.js +390 -43
- package/lib/CommittedAsset.js +8 -2
- package/lib/Dependency.js +9 -3
- package/lib/Environment.js +16 -10
- package/lib/EnvironmentManager.js +143 -0
- package/lib/IdentifierRegistry.js +2 -4
- package/lib/InternalConfig.js +3 -2
- package/lib/PackagerRunner.js +46 -82
- package/lib/ReporterRunner.js +8 -12
- package/lib/RequestTracker.js +191 -152
- package/lib/SymbolPropagation.js +52 -29
- package/lib/TargetDescriptor.schema.js +10 -1
- package/lib/Transformation.js +68 -19
- package/lib/UncommittedAsset.js +17 -24
- package/lib/Validation.js +20 -5
- package/lib/applyRuntimes.js +98 -7
- package/lib/assetUtils.js +16 -6
- package/lib/atlaspack-v3/AtlaspackV3.js +58 -15
- package/lib/atlaspack-v3/NapiWorkerPool.js +63 -2
- package/lib/atlaspack-v3/fs.js +4 -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/index.js +0 -11
- package/lib/atlaspack-v3/worker/compat/mutable-asset.js +16 -11
- package/lib/atlaspack-v3/worker/compat/plugin-config.js +14 -35
- package/lib/atlaspack-v3/worker/compat/plugin-options.js +16 -2
- 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 +214 -0
- package/lib/atlaspack-v3/worker/worker.js +231 -79
- package/lib/constants.js +0 -1
- package/lib/dumpGraphToGraphViz.js +72 -17
- package/lib/index.js +46 -3
- package/lib/loadAtlaspackPlugin.js +2 -3
- package/lib/loadDotEnv.js +5 -2
- package/lib/projectPath.js +6 -1
- package/lib/public/Asset.js +22 -12
- package/lib/public/Bundle.js +16 -18
- package/lib/public/BundleGraph.js +27 -25
- package/lib/public/BundleGroup.js +5 -6
- package/lib/public/Config.js +118 -18
- package/lib/public/Dependency.js +9 -7
- package/lib/public/Environment.js +13 -8
- package/lib/public/MutableBundleGraph.js +56 -15
- package/lib/public/PluginOptions.js +2 -2
- package/lib/public/Symbols.js +12 -12
- package/lib/public/Target.js +8 -7
- package/lib/registerCoreWithSerializer.js +7 -4
- package/lib/requests/AssetGraphRequest.js +61 -40
- package/lib/requests/AssetGraphRequestRust.js +314 -82
- package/lib/requests/AssetRequest.js +24 -7
- package/lib/requests/AtlaspackBuildRequest.js +53 -7
- package/lib/requests/AtlaspackConfigRequest.js +29 -19
- package/lib/requests/BundleGraphRequest.js +61 -130
- package/lib/requests/BundleGraphRequestRust.js +381 -0
- package/lib/requests/BundleGraphRequestUtils.js +280 -0
- package/lib/requests/ConfigRequest.js +55 -7
- package/lib/requests/DevDepRequest.js +32 -6
- package/lib/requests/EntryRequest.js +4 -3
- package/lib/requests/PackageRequest.js +56 -12
- package/lib/requests/PathRequest.js +26 -6
- package/lib/requests/TargetRequest.js +129 -60
- package/lib/requests/ValidationRequest.js +6 -2
- package/lib/requests/WriteBundleRequest.js +329 -20
- package/lib/requests/WriteBundlesRequest.js +64 -10
- package/lib/requests/asset-graph-diff.js +13 -8
- package/lib/requests/asset-graph-dot.js +2 -8
- package/lib/resolveOptions.js +37 -14
- package/lib/rustWorkerThreadDylibHack.js +0 -1
- package/lib/serializerCore.browser.js +1 -2
- package/lib/summarizeRequest.js +1 -1
- package/lib/types/AssetGraph.d.ts +55 -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 +232 -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 +35 -0
- package/lib/types/atlaspack-v3/NapiWorkerPool.d.ts +13 -0
- package/lib/types/atlaspack-v3/fs.d.ts +13 -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 -2
- 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-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 +81 -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/BundleGraphRequestRust.d.ts +34 -0
- package/lib/types/requests/BundleGraphRequestUtils.d.ts +38 -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 +80 -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 +496 -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 +18 -3
- package/lib/worker.js +32 -15
- package/package.json +26 -36
- package/src/{AssetGraph.js → AssetGraph.ts} +87 -51
- package/src/{Atlaspack.js → Atlaspack.ts} +181 -72
- package/src/{AtlaspackConfig.schema.js → AtlaspackConfig.schema.ts} +25 -19
- package/src/{AtlaspackConfig.js → AtlaspackConfig.ts} +78 -54
- package/src/{BundleGraph.js → BundleGraph.ts} +575 -145
- 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} +114 -159
- package/src/{ReporterRunner.js → ReporterRunner.ts} +13 -18
- package/src/{RequestTracker.js → RequestTracker.ts} +444 -355
- package/src/{SymbolPropagation.js → SymbolPropagation.ts} +178 -61
- package/src/{TargetDescriptor.schema.js → TargetDescriptor.schema.ts} +10 -1
- package/src/{Transformation.js → Transformation.ts} +110 -65
- package/src/{UncommittedAsset.js → UncommittedAsset.ts} +45 -49
- package/src/{Validation.js → Validation.ts} +32 -17
- package/src/{applyRuntimes.js → applyRuntimes.ts} +135 -26
- package/src/{assetUtils.js → assetUtils.ts} +49 -36
- package/src/atlaspack-v3/AtlaspackV3.ts +183 -0
- package/src/atlaspack-v3/NapiWorkerPool.ts +129 -0
- package/src/atlaspack-v3/{fs.js → fs.ts} +8 -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 +8 -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-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 +548 -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} +117 -90
- package/src/requests/AssetGraphRequestRust.ts +557 -0
- package/src/requests/{AssetRequest.js → AssetRequest.ts} +24 -18
- package/src/requests/AtlaspackBuildRequest.ts +168 -0
- package/src/requests/{AtlaspackConfigRequest.js → AtlaspackConfigRequest.ts} +72 -58
- package/src/requests/{BundleGraphRequest.js → BundleGraphRequest.ts} +119 -199
- package/src/requests/BundleGraphRequestRust.ts +470 -0
- package/src/requests/BundleGraphRequestUtils.ts +323 -0
- 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} +52 -25
- package/src/requests/{PathRequest.js → PathRequest.ts} +47 -37
- package/src/requests/{TargetRequest.js → TargetRequest.ts} +265 -179
- package/src/requests/{ValidationRequest.js → ValidationRequest.ts} +18 -17
- package/src/requests/WriteBundleRequest.ts +734 -0
- package/src/requests/{WriteBundlesRequest.js → WriteBundlesRequest.ts} +134 -50
- 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} +57 -27
- 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 +651 -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} +5 -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} +136 -58
- package/test/{SymbolPropagation.test.js → SymbolPropagation.test.ts} +124 -74
- package/test/{TargetRequest.test.js → TargetRequest.test.ts} +91 -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/requests/WriteBundleRequest.test.ts +602 -0
- package/test/{test-utils.js → test-utils.ts} +3 -4
- 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/lib/atlaspack-v3/worker/compat/plugin-logger.js +0 -29
- 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/compat/plugin-logger.js +0 -47
- package/src/atlaspack-v3/worker/worker.js +0 -369
- package/src/index.js +0 -13
- package/src/requests/AssetGraphRequestRust.js +0 -263
- package/src/requests/AtlaspackBuildRequest.js +0 -111
- package/src/requests/WriteBundleRequest.js +0 -369
- 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
|
@@ -0,0 +1,557 @@
|
|
|
1
|
+
import invariant from 'assert';
|
|
2
|
+
|
|
3
|
+
import ThrowableDiagnostic from '@atlaspack/diagnostic';
|
|
4
|
+
import type {Async} from '@atlaspack/types';
|
|
5
|
+
import logger, {instrument} from '@atlaspack/logger';
|
|
6
|
+
import {getFeatureFlag} from '@atlaspack/feature-flags';
|
|
7
|
+
|
|
8
|
+
import AssetGraph from '../AssetGraph';
|
|
9
|
+
import type {AtlaspackV3} from '../atlaspack-v3';
|
|
10
|
+
import {report} from '../ReporterRunner';
|
|
11
|
+
import {requestTypes, StaticRunOpts} from '../RequestTracker';
|
|
12
|
+
import {propagateSymbols} from '../SymbolPropagation';
|
|
13
|
+
import type {
|
|
14
|
+
Environment,
|
|
15
|
+
Asset,
|
|
16
|
+
AssetGraphNode,
|
|
17
|
+
AssetNode,
|
|
18
|
+
DependencyNode,
|
|
19
|
+
} from '../types';
|
|
20
|
+
|
|
21
|
+
import type {
|
|
22
|
+
AssetGraphRequestInput,
|
|
23
|
+
AssetGraphRequestResult,
|
|
24
|
+
} from './AssetGraphRequest';
|
|
25
|
+
import {toEnvironmentRef} from '../EnvironmentManager';
|
|
26
|
+
import {getEnvironmentHash} from '../Environment';
|
|
27
|
+
import dumpGraphToGraphViz from '../dumpGraphToGraphViz';
|
|
28
|
+
import assert from 'assert';
|
|
29
|
+
|
|
30
|
+
type RunInput = {
|
|
31
|
+
input: AssetGraphRequestInput;
|
|
32
|
+
} & StaticRunOpts<AssetGraphRequestResult>;
|
|
33
|
+
|
|
34
|
+
type AssetGraphRequest = {
|
|
35
|
+
id: string;
|
|
36
|
+
readonly type: typeof requestTypes.asset_graph_request;
|
|
37
|
+
run: (arg1: RunInput) => Async<AssetGraphRequestResult>;
|
|
38
|
+
input: AssetGraphRequestInput;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
type SerializedAssetGraphDelta = {
|
|
42
|
+
nodes: Array<any>;
|
|
43
|
+
edges: Array<string>;
|
|
44
|
+
updates: Array<any>;
|
|
45
|
+
safeToSkipBundling: boolean;
|
|
46
|
+
hadPreviousGraph: boolean;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export function createAssetGraphRequestRust(
|
|
50
|
+
rustAtlaspack: AtlaspackV3,
|
|
51
|
+
): (input: AssetGraphRequestInput) => AssetGraphRequest {
|
|
52
|
+
return (input: AssetGraphRequestInput) => ({
|
|
53
|
+
type: requestTypes.asset_graph_request,
|
|
54
|
+
id: input.name,
|
|
55
|
+
run: async (runInput) => {
|
|
56
|
+
let options = runInput.options;
|
|
57
|
+
let {assetGraphPromise, commitPromise} =
|
|
58
|
+
await rustAtlaspack.buildAssetGraph((eventJson: string) => {
|
|
59
|
+
let event = JSON.parse(eventJson);
|
|
60
|
+
report(event);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
let [serializedAssetGraph, assetGraphError] =
|
|
64
|
+
(await assetGraphPromise) as [SerializedAssetGraphDelta, Error | null];
|
|
65
|
+
|
|
66
|
+
if (assetGraphError) {
|
|
67
|
+
throw new ThrowableDiagnostic({
|
|
68
|
+
diagnostic: assetGraphError,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Don't reuse a previous asset graph result if Rust didn't have one too
|
|
73
|
+
let prevResult = null;
|
|
74
|
+
if (serializedAssetGraph.hadPreviousGraph) {
|
|
75
|
+
prevResult =
|
|
76
|
+
await runInput.api.getPreviousResult<AssetGraphRequestResult>();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
let {assetGraph, changedAssets} = instrument(
|
|
80
|
+
'atlaspack_v3_getAssetGraph',
|
|
81
|
+
() => getAssetGraph(serializedAssetGraph, prevResult?.assetGraph),
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
let changedAssetsPropagation = new Set(changedAssets.keys());
|
|
85
|
+
|
|
86
|
+
let result = {
|
|
87
|
+
assetGraph,
|
|
88
|
+
assetRequests: [],
|
|
89
|
+
assetGroupsWithRemovedParents: new Set<number>(),
|
|
90
|
+
changedAssets,
|
|
91
|
+
changedAssetsPropagation,
|
|
92
|
+
previousSymbolPropagationErrors: undefined,
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
// When v3AssetGraphSyncImprovements is enabled, wrap downstream steps
|
|
96
|
+
// in try/catch and store the result even on error. This prevents Rust/JS
|
|
97
|
+
// divergence when symbol propagation or commit_assets fails.
|
|
98
|
+
let storeResultOnError = getFeatureFlag('v3AssetGraphSyncImprovements');
|
|
99
|
+
|
|
100
|
+
try {
|
|
101
|
+
// Skip symbol propagation for runtime assets - they have pre-computed symbol data
|
|
102
|
+
if (input.skipSymbolProp) {
|
|
103
|
+
logger.verbose({
|
|
104
|
+
origin: '@atlaspack/core',
|
|
105
|
+
message: 'Skipping symbol propagation for runtime asset graph',
|
|
106
|
+
});
|
|
107
|
+
} else {
|
|
108
|
+
let errors = propagateSymbols({
|
|
109
|
+
options,
|
|
110
|
+
assetGraph,
|
|
111
|
+
changedAssetsPropagation,
|
|
112
|
+
assetGroupsWithRemovedParents: new Set(),
|
|
113
|
+
previousErrors: new Map(), //this.previousSymbolPropagationErrors,
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
if (errors.size > 0) {
|
|
117
|
+
// Just throw the first error. Since errors can bubble (e.g. reexporting a reexported symbol also fails),
|
|
118
|
+
// determining which failing export is the root cause is nontrivial (because of circular dependencies).
|
|
119
|
+
throw new ThrowableDiagnostic({
|
|
120
|
+
diagnostic: [...errors.values()][0],
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
await dumpGraphToGraphViz(assetGraph, 'AssetGraphV3');
|
|
126
|
+
|
|
127
|
+
let [_commitResult, commitError] = await commitPromise;
|
|
128
|
+
|
|
129
|
+
if (commitError) {
|
|
130
|
+
throw new ThrowableDiagnostic({
|
|
131
|
+
diagnostic: {
|
|
132
|
+
message:
|
|
133
|
+
'Error committing asset graph in Rust: ' + commitError.message,
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
await runInput.api.storeResult(result);
|
|
139
|
+
runInput.api.invalidateOnBuild();
|
|
140
|
+
} catch (e) {
|
|
141
|
+
if (storeResultOnError) {
|
|
142
|
+
// Store the graph even on error to prevent Rust/JS divergence.
|
|
143
|
+
// The graph from getAssetGraph is structurally correct — only
|
|
144
|
+
// downstream processing (symbols, commit) failed.
|
|
145
|
+
await runInput.api.storeResult(result);
|
|
146
|
+
runInput.api.invalidateOnBuild();
|
|
147
|
+
}
|
|
148
|
+
throw e;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return result;
|
|
152
|
+
},
|
|
153
|
+
input,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export function getAssetGraph(
|
|
158
|
+
serializedGraph: any,
|
|
159
|
+
prevAssetGraph?: AssetGraph,
|
|
160
|
+
): {
|
|
161
|
+
assetGraph: AssetGraph;
|
|
162
|
+
changedAssets: Map<string, Asset>;
|
|
163
|
+
} {
|
|
164
|
+
let graph: AssetGraph;
|
|
165
|
+
|
|
166
|
+
let reuseEdges = false;
|
|
167
|
+
|
|
168
|
+
let clonePrevGraph = getFeatureFlag('v3AssetGraphSyncImprovements');
|
|
169
|
+
|
|
170
|
+
if (prevAssetGraph && serializedGraph.safeToSkipBundling) {
|
|
171
|
+
if (clonePrevGraph) {
|
|
172
|
+
graph = new AssetGraph({
|
|
173
|
+
_contentKeyToNodeId: new Map(prevAssetGraph._contentKeyToNodeId),
|
|
174
|
+
_nodeIdToContentKey: new Map(prevAssetGraph._nodeIdToContentKey),
|
|
175
|
+
nodes: [...prevAssetGraph.nodes],
|
|
176
|
+
rootNodeId: prevAssetGraph.rootNodeId,
|
|
177
|
+
adjacencyList: prevAssetGraph.adjacencyList,
|
|
178
|
+
});
|
|
179
|
+
} else {
|
|
180
|
+
graph = new AssetGraph({
|
|
181
|
+
_contentKeyToNodeId: prevAssetGraph._contentKeyToNodeId,
|
|
182
|
+
_nodeIdToContentKey: prevAssetGraph._nodeIdToContentKey,
|
|
183
|
+
nodes: prevAssetGraph.nodes,
|
|
184
|
+
rootNodeId: prevAssetGraph.rootNodeId,
|
|
185
|
+
adjacencyList: prevAssetGraph.adjacencyList,
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
reuseEdges = true;
|
|
189
|
+
} else if (
|
|
190
|
+
prevAssetGraph &&
|
|
191
|
+
(serializedGraph.updates.length > 0 || serializedGraph.nodes.length > 0)
|
|
192
|
+
) {
|
|
193
|
+
if (clonePrevGraph) {
|
|
194
|
+
graph = new AssetGraph({
|
|
195
|
+
_contentKeyToNodeId: new Map(prevAssetGraph._contentKeyToNodeId),
|
|
196
|
+
_nodeIdToContentKey: new Map(prevAssetGraph._nodeIdToContentKey),
|
|
197
|
+
nodes: [...prevAssetGraph.nodes],
|
|
198
|
+
initialCapacity: serializedGraph.edges.length,
|
|
199
|
+
// Accomodate the root node
|
|
200
|
+
initialNodeCapacity: prevAssetGraph.nodes.length + 1,
|
|
201
|
+
rootNodeId: prevAssetGraph.rootNodeId,
|
|
202
|
+
});
|
|
203
|
+
} else {
|
|
204
|
+
graph = new AssetGraph({
|
|
205
|
+
_contentKeyToNodeId: prevAssetGraph._contentKeyToNodeId,
|
|
206
|
+
_nodeIdToContentKey: prevAssetGraph._nodeIdToContentKey,
|
|
207
|
+
nodes: prevAssetGraph.nodes,
|
|
208
|
+
initialCapacity: serializedGraph.edges.length,
|
|
209
|
+
// Accomodate the root node
|
|
210
|
+
initialNodeCapacity: prevAssetGraph.nodes.length + 1,
|
|
211
|
+
rootNodeId: prevAssetGraph.rootNodeId,
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
graph.safeToIncrementallyBundle = false;
|
|
215
|
+
} else {
|
|
216
|
+
graph = new AssetGraph({
|
|
217
|
+
_contentKeyToNodeId: new Map(),
|
|
218
|
+
_nodeIdToContentKey: new Map(),
|
|
219
|
+
initialCapacity: serializedGraph.edges.length,
|
|
220
|
+
// Accomodate the root node
|
|
221
|
+
initialNodeCapacity: serializedGraph.nodes.length + 1,
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
let rootNodeId = graph.addNodeByContentKey('@@root', {
|
|
225
|
+
id: '@@root',
|
|
226
|
+
type: 'root',
|
|
227
|
+
value: null,
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
graph.setRootNodeId(rootNodeId);
|
|
231
|
+
graph.safeToIncrementallyBundle = false;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
invariant(graph, 'Asset graph not initialized');
|
|
235
|
+
invariant(graph.rootNodeId != null, 'Asset graph has no root node');
|
|
236
|
+
|
|
237
|
+
// @ts-expect-error TS7031
|
|
238
|
+
function mapSymbols({exported, ...symbol}) {
|
|
239
|
+
let jsSymbol = {
|
|
240
|
+
local: symbol.local ?? undefined,
|
|
241
|
+
loc: symbol.loc ?? undefined,
|
|
242
|
+
isWeak: symbol.isWeak,
|
|
243
|
+
meta: {
|
|
244
|
+
isEsm: symbol.isEsmExport,
|
|
245
|
+
isStaticBindingSafe: symbol.isStaticBindingSafe,
|
|
246
|
+
},
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
if (symbol.exported) {
|
|
250
|
+
// @ts-expect-error TS2339
|
|
251
|
+
jsSymbol.exported = symbol.exported;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
return [exported, jsSymbol];
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// See crates/atlaspack_core/src/types/environment.rs
|
|
258
|
+
let changedAssets = new Map();
|
|
259
|
+
let entry = 0;
|
|
260
|
+
|
|
261
|
+
let envs = new Map();
|
|
262
|
+
let getEnvId = (env: Environment) => {
|
|
263
|
+
let envKey = [
|
|
264
|
+
env.context,
|
|
265
|
+
env.engines.atlaspack,
|
|
266
|
+
env.engines.browsers,
|
|
267
|
+
env.engines.electron,
|
|
268
|
+
env.engines.node,
|
|
269
|
+
env.includeNodeModules,
|
|
270
|
+
env.isLibrary,
|
|
271
|
+
env.outputFormat,
|
|
272
|
+
env.shouldScopeHoist,
|
|
273
|
+
env.shouldOptimize,
|
|
274
|
+
env.sourceType,
|
|
275
|
+
].join(':');
|
|
276
|
+
|
|
277
|
+
let envId = envs.get(envKey);
|
|
278
|
+
if (envId == null) {
|
|
279
|
+
envId = getEnvironmentHash(env);
|
|
280
|
+
envs.set(envKey, envId);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
return envId;
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
function describeNode(node: AssetGraphNode): Record<string, unknown> {
|
|
287
|
+
const base = {type: node.type, id: node.id};
|
|
288
|
+
if (node.type === 'asset') {
|
|
289
|
+
return {
|
|
290
|
+
...base,
|
|
291
|
+
filePath: node.value.filePath,
|
|
292
|
+
fileType: node.value.type,
|
|
293
|
+
pipeline: node.value.pipeline,
|
|
294
|
+
};
|
|
295
|
+
} else if (node.type === 'dependency') {
|
|
296
|
+
return {
|
|
297
|
+
...base,
|
|
298
|
+
specifier: node.value.specifier,
|
|
299
|
+
specifierType: node.value.specifierType,
|
|
300
|
+
sourceAssetId: node.value.sourceAssetId,
|
|
301
|
+
sourcePath: node.value.sourcePath,
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
return base;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
function buildDivergenceDiagnostics(
|
|
308
|
+
divergenceType: string,
|
|
309
|
+
newNode: AssetGraphNode,
|
|
310
|
+
existingNode: AssetGraphNode | null | undefined,
|
|
311
|
+
index: number,
|
|
312
|
+
) {
|
|
313
|
+
return {
|
|
314
|
+
contentKey: newNode.id,
|
|
315
|
+
divergenceType,
|
|
316
|
+
newNode: describeNode(newNode),
|
|
317
|
+
existingNode: existingNode ? describeNode(existingNode) : null,
|
|
318
|
+
iterationIndex: index,
|
|
319
|
+
totalSerializedNodes: nodesCount,
|
|
320
|
+
newNodesCount: serializedGraph.nodes.length,
|
|
321
|
+
updatesCount: serializedGraph.updates.length,
|
|
322
|
+
edgesCount: serializedGraph.edges.length,
|
|
323
|
+
hadPreviousGraph: !!prevAssetGraph,
|
|
324
|
+
safeToSkipBundling: serializedGraph.safeToSkipBundling,
|
|
325
|
+
graphNodeCount: graph._contentKeyToNodeId.size,
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
function updateNode(
|
|
330
|
+
newNode: AssetGraphNode,
|
|
331
|
+
isUpdateNode: boolean,
|
|
332
|
+
index: number,
|
|
333
|
+
) {
|
|
334
|
+
let healDivergence = getFeatureFlag('v3AssetGraphSyncImprovements');
|
|
335
|
+
|
|
336
|
+
if (isUpdateNode) {
|
|
337
|
+
let existingNode = graph.getNodeByContentKey(newNode.id);
|
|
338
|
+
|
|
339
|
+
if (healDivergence) {
|
|
340
|
+
if (existingNode) {
|
|
341
|
+
assert(existingNode.type === newNode.type);
|
|
342
|
+
Object.assign(existingNode, newNode);
|
|
343
|
+
} else {
|
|
344
|
+
// Rust sent an update for a node JS doesn't have.
|
|
345
|
+
// This means JS's graph is stale. Add the node as new instead.
|
|
346
|
+
// This handles the "undefined == true" error class.
|
|
347
|
+
let diagnostics = buildDivergenceDiagnostics(
|
|
348
|
+
'update_node_not_found',
|
|
349
|
+
newNode,
|
|
350
|
+
existingNode,
|
|
351
|
+
index,
|
|
352
|
+
);
|
|
353
|
+
logger.warn({
|
|
354
|
+
origin: '@atlaspack/core',
|
|
355
|
+
message:
|
|
356
|
+
`Rust/JS asset graph divergence healed: update node not found, ` +
|
|
357
|
+
`adding as new. contentKey=${newNode.id} type=${newNode.type} iterationIndex=${index}`,
|
|
358
|
+
meta: {
|
|
359
|
+
trackableEvent: 'asset_graph_divergence_healed',
|
|
360
|
+
...diagnostics,
|
|
361
|
+
},
|
|
362
|
+
});
|
|
363
|
+
graph.addNodeByContentKey(newNode.id, newNode);
|
|
364
|
+
}
|
|
365
|
+
} else {
|
|
366
|
+
assert(existingNode && existingNode.type === newNode.type);
|
|
367
|
+
Object.assign(existingNode, newNode);
|
|
368
|
+
}
|
|
369
|
+
} else {
|
|
370
|
+
if (healDivergence) {
|
|
371
|
+
if (graph.hasContentKey(newNode.id)) {
|
|
372
|
+
// Rust sent a "new" node that JS already has.
|
|
373
|
+
// This means JS's graph has nodes that Rust considers new.
|
|
374
|
+
// Treat as an update instead of throwing.
|
|
375
|
+
// This handles the "Graph already has content key" error class.
|
|
376
|
+
let existingNode = graph.getNodeByContentKey(newNode.id);
|
|
377
|
+
let diagnostics = buildDivergenceDiagnostics(
|
|
378
|
+
'new_node_already_exists',
|
|
379
|
+
newNode,
|
|
380
|
+
existingNode,
|
|
381
|
+
index,
|
|
382
|
+
);
|
|
383
|
+
logger.warn({
|
|
384
|
+
origin: '@atlaspack/core',
|
|
385
|
+
message:
|
|
386
|
+
`Rust/JS asset graph divergence healed: new node already exists, ` +
|
|
387
|
+
`treating as update. contentKey=${newNode.id} type=${newNode.type} iterationIndex=${index}`,
|
|
388
|
+
meta: {
|
|
389
|
+
trackableEvent: 'asset_graph_divergence_healed',
|
|
390
|
+
...diagnostics,
|
|
391
|
+
},
|
|
392
|
+
});
|
|
393
|
+
if (existingNode) {
|
|
394
|
+
Object.assign(existingNode, newNode);
|
|
395
|
+
}
|
|
396
|
+
} else {
|
|
397
|
+
graph.addNodeByContentKey(newNode.id, newNode);
|
|
398
|
+
}
|
|
399
|
+
} else {
|
|
400
|
+
try {
|
|
401
|
+
graph.addNodeByContentKey(newNode.id, newNode);
|
|
402
|
+
} catch (e) {
|
|
403
|
+
if (
|
|
404
|
+
e instanceof Error &&
|
|
405
|
+
e.message.includes('already has content key')
|
|
406
|
+
) {
|
|
407
|
+
let existingNode = graph.getNodeByContentKey(newNode.id);
|
|
408
|
+
let diagnostics = buildDivergenceDiagnostics(
|
|
409
|
+
'new_node_already_exists',
|
|
410
|
+
newNode,
|
|
411
|
+
existingNode,
|
|
412
|
+
index,
|
|
413
|
+
);
|
|
414
|
+
|
|
415
|
+
throw new Error(
|
|
416
|
+
`Graph already has content key '${newNode.id}'. Diagnostics: ${JSON.stringify(diagnostics, null, 2)}`,
|
|
417
|
+
);
|
|
418
|
+
}
|
|
419
|
+
throw e;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
let nodeTypeSwitchoverIndex = serializedGraph.nodes.length;
|
|
426
|
+
let nodesCount =
|
|
427
|
+
serializedGraph.nodes.length + serializedGraph.updates.length;
|
|
428
|
+
|
|
429
|
+
for (let index = 0; index < nodesCount; index++) {
|
|
430
|
+
let isUpdateNode = index >= nodeTypeSwitchoverIndex;
|
|
431
|
+
let node = isUpdateNode
|
|
432
|
+
? serializedGraph.updates[index - nodeTypeSwitchoverIndex]
|
|
433
|
+
: serializedGraph.nodes[index];
|
|
434
|
+
|
|
435
|
+
node = JSON.parse(node);
|
|
436
|
+
|
|
437
|
+
if (node.type === 'entry') {
|
|
438
|
+
let id = 'entry:' + ++entry;
|
|
439
|
+
|
|
440
|
+
graph.addNodeByContentKey(id, {
|
|
441
|
+
id: id,
|
|
442
|
+
type: 'root',
|
|
443
|
+
value: null,
|
|
444
|
+
});
|
|
445
|
+
} else if (node.type === 'asset') {
|
|
446
|
+
let asset = node.value;
|
|
447
|
+
let id = asset.id;
|
|
448
|
+
|
|
449
|
+
asset.committed = true;
|
|
450
|
+
asset.contentKey = id;
|
|
451
|
+
asset.env.id = getFeatureFlag('environmentDeduplication')
|
|
452
|
+
? // TODO: Rust can do this and avoid copying a significant amount of data over
|
|
453
|
+
getEnvironmentHash(asset.env)
|
|
454
|
+
: getEnvId(asset.env);
|
|
455
|
+
asset.mapKey = `map:${asset.id}`;
|
|
456
|
+
|
|
457
|
+
asset.env = toEnvironmentRef(asset.env);
|
|
458
|
+
|
|
459
|
+
// This is populated later when we map the edges between assets and dependencies
|
|
460
|
+
asset.dependencies = new Map();
|
|
461
|
+
|
|
462
|
+
// We need to add this property for source map handling, as some assets like runtimes
|
|
463
|
+
// are processed after the Rust transformation and take the v2 code path
|
|
464
|
+
asset.meta.isV3 = true;
|
|
465
|
+
|
|
466
|
+
if (asset.symbols != null) {
|
|
467
|
+
asset.symbols = new Map(asset.symbols.map(mapSymbols));
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
changedAssets.set(id, asset);
|
|
471
|
+
|
|
472
|
+
let assetNode: AssetNode = {
|
|
473
|
+
id,
|
|
474
|
+
type: 'asset',
|
|
475
|
+
usedSymbols: new Set(),
|
|
476
|
+
usedSymbolsDownDirty: true,
|
|
477
|
+
usedSymbolsUpDirty: true,
|
|
478
|
+
value: asset,
|
|
479
|
+
};
|
|
480
|
+
updateNode(assetNode, isUpdateNode, index);
|
|
481
|
+
} else if (node.type === 'dependency') {
|
|
482
|
+
let {dependency, id} = node.value;
|
|
483
|
+
|
|
484
|
+
dependency.id = id;
|
|
485
|
+
dependency.env.id = getFeatureFlag('environmentDeduplication')
|
|
486
|
+
? // TODO: Rust can do this and avoid copying a significant amount of data over
|
|
487
|
+
getEnvironmentHash(dependency.env)
|
|
488
|
+
: getEnvId(dependency.env);
|
|
489
|
+
dependency.env = toEnvironmentRef(dependency.env);
|
|
490
|
+
|
|
491
|
+
if (dependency.symbols != null) {
|
|
492
|
+
dependency.symbols = new Map(dependency.symbols?.map(mapSymbols));
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
let usedSymbolsDown = new Set();
|
|
496
|
+
let usedSymbolsUp = new Map();
|
|
497
|
+
|
|
498
|
+
if (node.used_symbols_up) {
|
|
499
|
+
for (let usedSymbol of node.used_symbols_up) {
|
|
500
|
+
// Transform Rust UsedSymbol { symbol: Symbol, asset: string, resolved_symbol: string }
|
|
501
|
+
// to JS format { symbol: string, asset: string } where symbol is the resolved name
|
|
502
|
+
const exportedName = usedSymbol.symbol.exported;
|
|
503
|
+
usedSymbolsUp.set(exportedName, {
|
|
504
|
+
asset: usedSymbol.asset,
|
|
505
|
+
symbol: usedSymbol.resolved_symbol ?? exportedName,
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
if (dependency.isEntry && dependency.isLibrary) {
|
|
511
|
+
usedSymbolsDown.add('*');
|
|
512
|
+
usedSymbolsUp.set('*', undefined);
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
let depNode: DependencyNode = {
|
|
516
|
+
id,
|
|
517
|
+
type: 'dependency',
|
|
518
|
+
deferred: false,
|
|
519
|
+
excluded: false,
|
|
520
|
+
hasDeferred: node.has_deferred,
|
|
521
|
+
// @ts-expect-error TS2322
|
|
522
|
+
usedSymbolsDown,
|
|
523
|
+
usedSymbolsDownDirty: true,
|
|
524
|
+
usedSymbolsUp,
|
|
525
|
+
usedSymbolsUpDirtyDown: true,
|
|
526
|
+
usedSymbolsUpDirtyUp: true,
|
|
527
|
+
value: dependency,
|
|
528
|
+
};
|
|
529
|
+
|
|
530
|
+
updateNode(depNode, isUpdateNode, index);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
if (!reuseEdges) {
|
|
535
|
+
for (let i = 0; i < serializedGraph.edges.length; i += 2) {
|
|
536
|
+
let from = serializedGraph.edges[i];
|
|
537
|
+
let to = serializedGraph.edges[i + 1];
|
|
538
|
+
let fromNode = graph.getNode(from);
|
|
539
|
+
let toNode = graph.getNode(to);
|
|
540
|
+
|
|
541
|
+
if (fromNode?.type === 'dependency') {
|
|
542
|
+
invariant(toNode?.type === 'asset');
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
if (fromNode?.type === 'asset' && toNode?.type === 'dependency') {
|
|
546
|
+
fromNode.value.dependencies.set(toNode.value.id, toNode.value);
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
graph.addEdge(from, to);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
return {
|
|
554
|
+
assetGraph: graph,
|
|
555
|
+
changedAssets,
|
|
556
|
+
};
|
|
557
|
+
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// @flow strict-local
|
|
2
|
-
|
|
3
1
|
import type {ContentKey} from '@atlaspack/graph';
|
|
4
2
|
import type {Async} from '@atlaspack/types';
|
|
5
3
|
import type {StaticRunOpts} from '../RequestTracker';
|
|
@@ -21,18 +19,18 @@ import {fromProjectPath, fromProjectPathRelative} from '../projectPath';
|
|
|
21
19
|
import {report} from '../ReporterRunner';
|
|
22
20
|
import {requestTypes} from '../RequestTracker';
|
|
23
21
|
import type {DevDepRequestResult} from './DevDepRequest';
|
|
22
|
+
import {toEnvironmentId} from '../EnvironmentManager';
|
|
24
23
|
|
|
25
|
-
type RunInput<TResult> = {
|
|
26
|
-
input: AssetRequestInput
|
|
27
|
-
|
|
28
|
-
|};
|
|
24
|
+
type RunInput<TResult> = {
|
|
25
|
+
input: AssetRequestInput;
|
|
26
|
+
} & StaticRunOpts<TResult>;
|
|
29
27
|
|
|
30
|
-
export type AssetRequest = {
|
|
31
|
-
id: ContentKey
|
|
32
|
-
|
|
33
|
-
run: (RunInput<AssetRequestResult>) => Async<AssetRequestResult
|
|
34
|
-
input: AssetRequestInput
|
|
35
|
-
|
|
28
|
+
export type AssetRequest = {
|
|
29
|
+
id: ContentKey;
|
|
30
|
+
readonly type: typeof requestTypes.asset_request;
|
|
31
|
+
run: (arg1: RunInput<AssetRequestResult>) => Async<AssetRequestResult>;
|
|
32
|
+
input: AssetRequestInput;
|
|
33
|
+
};
|
|
36
34
|
|
|
37
35
|
export default function createAssetRequest(
|
|
38
36
|
input: AssetRequestInput,
|
|
@@ -51,7 +49,7 @@ function getId(input: AssetRequestInput) {
|
|
|
51
49
|
return hashString(
|
|
52
50
|
type +
|
|
53
51
|
fromProjectPathRelative(input.filePath) +
|
|
54
|
-
input.env
|
|
52
|
+
toEnvironmentId(input.env) +
|
|
55
53
|
String(input.isSource) +
|
|
56
54
|
String(input.sideEffects) +
|
|
57
55
|
(input.code ?? '') +
|
|
@@ -62,6 +60,7 @@ function getId(input: AssetRequestInput) {
|
|
|
62
60
|
);
|
|
63
61
|
}
|
|
64
62
|
|
|
63
|
+
// @ts-expect-error TS7031
|
|
65
64
|
async function run({input, api, farm, invalidateReason, options}) {
|
|
66
65
|
report({
|
|
67
66
|
type: 'buildProgress',
|
|
@@ -73,6 +72,7 @@ async function run({input, api, farm, invalidateReason, options}) {
|
|
|
73
72
|
let start = Date.now();
|
|
74
73
|
let {optionsRef, ...rest} = input;
|
|
75
74
|
let {cachePath} = nullthrows(
|
|
75
|
+
// @ts-expect-error TS2347
|
|
76
76
|
await api.runRequest<null, ConfigAndCachePath>(
|
|
77
77
|
createAtlaspackConfigRequest(),
|
|
78
78
|
),
|
|
@@ -82,9 +82,12 @@ async function run({input, api, farm, invalidateReason, options}) {
|
|
|
82
82
|
await Promise.all(
|
|
83
83
|
api
|
|
84
84
|
.getSubRequests()
|
|
85
|
+
// @ts-expect-error TS7006
|
|
85
86
|
.filter((req) => req.requestType === requestTypes.dev_dep_request)
|
|
87
|
+
// @ts-expect-error TS7006
|
|
86
88
|
.map(async (req) => [
|
|
87
89
|
req.id,
|
|
90
|
+
// @ts-expect-error TS2347
|
|
88
91
|
nullthrows(await api.getRequestResult<DevDepRequestResult>(req.id)),
|
|
89
92
|
]),
|
|
90
93
|
),
|
|
@@ -95,21 +98,24 @@ async function run({input, api, farm, invalidateReason, options}) {
|
|
|
95
98
|
invalidateReason,
|
|
96
99
|
devDeps: new Map(
|
|
97
100
|
[...previousDevDepRequests.entries()]
|
|
98
|
-
|
|
99
|
-
.
|
|
101
|
+
// @ts-expect-error TS2769
|
|
102
|
+
.filter(([id]: [any]) => api.canSkipSubrequest(id))
|
|
103
|
+
.map(([, req]: [any, any]) => [
|
|
100
104
|
`${req.specifier}:${fromProjectPathRelative(req.resolveFrom)}`,
|
|
101
105
|
req.hash,
|
|
102
106
|
]),
|
|
103
107
|
),
|
|
104
108
|
invalidDevDeps: await Promise.all(
|
|
105
109
|
[...previousDevDepRequests.entries()]
|
|
106
|
-
|
|
107
|
-
.
|
|
110
|
+
// @ts-expect-error TS2769
|
|
111
|
+
.filter(([id]: [any]) => !api.canSkipSubrequest(id))
|
|
112
|
+
.flatMap(([, req]: [any, any]) => {
|
|
108
113
|
return [
|
|
109
114
|
{
|
|
110
115
|
specifier: req.specifier,
|
|
111
116
|
resolveFrom: req.resolveFrom,
|
|
112
117
|
},
|
|
118
|
+
// @ts-expect-error TS7006
|
|
113
119
|
...(req.additionalInvalidations ?? []).map((i) => ({
|
|
114
120
|
specifier: i.specifier,
|
|
115
121
|
resolveFrom: i.resolveFrom,
|
|
@@ -127,7 +133,7 @@ async function run({input, api, farm, invalidateReason, options}) {
|
|
|
127
133
|
configCachePath: cachePath,
|
|
128
134
|
optionsRef,
|
|
129
135
|
request,
|
|
130
|
-
})
|
|
136
|
+
})) as TransformationResult;
|
|
131
137
|
|
|
132
138
|
let time = Date.now() - start;
|
|
133
139
|
if (assets) {
|