@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,384 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.default = applyRuntimes;
|
|
40
|
+
const path_1 = __importDefault(require("path"));
|
|
41
|
+
const assert_1 = __importDefault(require("assert"));
|
|
42
|
+
const assert_2 = __importDefault(require("assert"));
|
|
43
|
+
const nullthrows_1 = __importDefault(require("nullthrows"));
|
|
44
|
+
const AssetGraph_1 = require("./AssetGraph");
|
|
45
|
+
const BundleGraph_1 = __importDefault(require("./public/BundleGraph"));
|
|
46
|
+
const BundleGraph_2 = __importStar(require("./BundleGraph"));
|
|
47
|
+
const Bundle_1 = require("./public/Bundle");
|
|
48
|
+
const logger_1 = require("@atlaspack/logger");
|
|
49
|
+
const rust_1 = require("@atlaspack/rust");
|
|
50
|
+
const diagnostic_1 = __importStar(require("@atlaspack/diagnostic"));
|
|
51
|
+
const Dependency_1 = require("./public/Dependency");
|
|
52
|
+
const Environment_1 = require("./Environment");
|
|
53
|
+
const AssetGraphRequest_1 = __importDefault(require("./requests/AssetGraphRequest"));
|
|
54
|
+
const DevDepRequest_1 = require("./requests/DevDepRequest");
|
|
55
|
+
const projectPath_1 = require("./projectPath");
|
|
56
|
+
const profiler_1 = require("@atlaspack/profiler");
|
|
57
|
+
const utils_1 = require("@atlaspack/utils");
|
|
58
|
+
const EnvironmentManager_1 = require("./EnvironmentManager");
|
|
59
|
+
const feature_flags_1 = require("@atlaspack/feature-flags");
|
|
60
|
+
function nameRuntimeBundle(bundle, siblingBundle) {
|
|
61
|
+
// We don't run custom namers on runtime bundles as the runtime assumes that they are
|
|
62
|
+
// located at the same nesting level as their owning bundle. Custom naming could
|
|
63
|
+
// be added in future as long as the custom name is validated.
|
|
64
|
+
let { hashReference } = bundle;
|
|
65
|
+
let name = (0, nullthrows_1.default)(siblingBundle.name)
|
|
66
|
+
// Remove the existing hash from standard file patterns
|
|
67
|
+
// e.g. 'main.[hash].js' -> 'main.js' or 'main~[hash].js' -> 'main.js'
|
|
68
|
+
.replace(new RegExp(`[\\.~\\-_]?${siblingBundle.hashReference}`), '')
|
|
69
|
+
// Ensure the file ends with 'runtime.[hash].js'
|
|
70
|
+
.replace(`.${bundle.type}`, `.runtime.${hashReference}.${bundle.type}`);
|
|
71
|
+
bundle.name = name;
|
|
72
|
+
bundle.displayName = name.replace(hashReference, '[hash]');
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The applyRuntimes function is responsible for generating all the runtimes
|
|
76
|
+
* (assets created during the build that don't actually exist on disk) and then
|
|
77
|
+
* linking them into the bundle graph.
|
|
78
|
+
*
|
|
79
|
+
* Introduction of manifest bundles: https://github.com/parcel-bundler/parcel/pull/8837
|
|
80
|
+
* Introduction of reverse topology: https://github.com/parcel-bundler/parcel/pull/8981
|
|
81
|
+
*/
|
|
82
|
+
async function applyRuntimes({ bundleGraph, config, options, pluginOptions, api, optionsRef, previousDevDeps, devDepRequests, configs, }) {
|
|
83
|
+
let runtimes = await config.getRuntimes();
|
|
84
|
+
/**
|
|
85
|
+
* Usually, the assets returned from a runtime will go in the same bundle. It is
|
|
86
|
+
* possible though, for a runtime to return an asset with a `parallel` priority,
|
|
87
|
+
* which allows it to be moved to a separate bundle. In practice, this is
|
|
88
|
+
* usually used to generate application manifest files.
|
|
89
|
+
*
|
|
90
|
+
* When adding a manifest bundle (a whole new separate bundle) during a runtime,
|
|
91
|
+
* it needs to be added to a bundle group which will be potentially referenced
|
|
92
|
+
* by another bundle group. To avoid trying to reference a manifest entry which
|
|
93
|
+
* hasn't been created yet, we process the bundles from the bottom up (topological
|
|
94
|
+
* order), so that children will always be available when parents try to reference
|
|
95
|
+
* them.
|
|
96
|
+
*/
|
|
97
|
+
// @ts-expect-error TS2304
|
|
98
|
+
let bundles = [];
|
|
99
|
+
bundleGraph.traverseBundles({
|
|
100
|
+
// @ts-expect-error TS2304
|
|
101
|
+
exit(bundle) {
|
|
102
|
+
bundles.push(bundle);
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
let connectionMap = new utils_1.DefaultMap(() => []);
|
|
106
|
+
for (let bundle of bundles) {
|
|
107
|
+
for (let runtime of runtimes) {
|
|
108
|
+
let measurement;
|
|
109
|
+
try {
|
|
110
|
+
const namedBundle = Bundle_1.NamedBundle.get(bundle, bundleGraph, options);
|
|
111
|
+
measurement = profiler_1.tracer.createMeasurement(runtime.name, 'applyRuntime', namedBundle.displayName);
|
|
112
|
+
let applied = await runtime.plugin.apply({
|
|
113
|
+
bundle: namedBundle,
|
|
114
|
+
bundleGraph: new BundleGraph_1.default(bundleGraph, Bundle_1.NamedBundle.get.bind(Bundle_1.NamedBundle), options),
|
|
115
|
+
config: configs.get(runtime.name)?.result,
|
|
116
|
+
options: pluginOptions,
|
|
117
|
+
logger: new logger_1.PluginLogger({ origin: runtime.name }),
|
|
118
|
+
tracer: new profiler_1.PluginTracer({
|
|
119
|
+
origin: runtime.name,
|
|
120
|
+
category: 'applyRuntime',
|
|
121
|
+
}),
|
|
122
|
+
});
|
|
123
|
+
if (applied) {
|
|
124
|
+
let runtimeAssets = Array.isArray(applied) ? applied : [applied];
|
|
125
|
+
for (let { code, dependency, filePath, isEntry, env, runtimeAssetRequiringExecutionOnLoad, priority, symbolData, } of runtimeAssets) {
|
|
126
|
+
let sourceName = path_1.default.join(path_1.default.dirname(filePath), `runtime-${(0, rust_1.hashString)(code)}.${bundle.type}`);
|
|
127
|
+
let assetGroup = {
|
|
128
|
+
code,
|
|
129
|
+
runtimeAssetRequiringExecutionOnLoad,
|
|
130
|
+
filePath: (0, projectPath_1.toProjectPath)(options.projectRoot, sourceName),
|
|
131
|
+
env: (0, Environment_1.mergeEnvironments)(options.projectRoot, (0, EnvironmentManager_1.fromEnvironmentId)(bundle.env), env),
|
|
132
|
+
// Runtime assets should be considered source, as they should be
|
|
133
|
+
// e.g. compiled to run in the target environment
|
|
134
|
+
isSource: true,
|
|
135
|
+
symbolData,
|
|
136
|
+
};
|
|
137
|
+
let connectionBundle = bundle;
|
|
138
|
+
/**
|
|
139
|
+
* If a runtime asset is marked with a priority of `parallel` this
|
|
140
|
+
* means we need to create a new bundle for the asset and add it to
|
|
141
|
+
* all the same bundle groups.
|
|
142
|
+
*/
|
|
143
|
+
if (priority === 'parallel' && !bundle.needsStableName) {
|
|
144
|
+
let bundleGroups = bundleGraph.getBundleGroupsContainingBundle(bundle);
|
|
145
|
+
connectionBundle = (0, nullthrows_1.default)(bundleGraph.createBundle({
|
|
146
|
+
type: bundle.type,
|
|
147
|
+
needsStableName: false,
|
|
148
|
+
env: bundle.env,
|
|
149
|
+
target: bundle.target,
|
|
150
|
+
uniqueKey: 'runtime-manifest:' + bundle.id,
|
|
151
|
+
shouldContentHash: options.shouldContentHash,
|
|
152
|
+
}));
|
|
153
|
+
for (let bundleGroup of bundleGroups) {
|
|
154
|
+
bundleGraph.addBundleToBundleGroup(connectionBundle, bundleGroup);
|
|
155
|
+
}
|
|
156
|
+
bundleGraph.createBundleReference(bundle, connectionBundle);
|
|
157
|
+
// Ensure we name the bundle now as all other bundles have already
|
|
158
|
+
// been named as this point.
|
|
159
|
+
nameRuntimeBundle(connectionBundle, bundle);
|
|
160
|
+
}
|
|
161
|
+
// @ts-expect-error TS2345
|
|
162
|
+
connectionMap.get(connectionBundle).push({
|
|
163
|
+
bundle: connectionBundle,
|
|
164
|
+
assetGroup,
|
|
165
|
+
dependency,
|
|
166
|
+
isEntry,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
catch (e) {
|
|
172
|
+
throw new diagnostic_1.default({
|
|
173
|
+
diagnostic: (0, diagnostic_1.errorToDiagnostic)(e, {
|
|
174
|
+
origin: runtime.name,
|
|
175
|
+
}),
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
finally {
|
|
179
|
+
measurement && measurement.end();
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* When merging the connections in to the bundle graph, the topological
|
|
185
|
+
* order can create module not found errors in some situations, often when HMR
|
|
186
|
+
* is enabled. To fix this, we put the connections into DFS order.
|
|
187
|
+
*
|
|
188
|
+
* Note: While DFS order seems to be the most reliable order to process the
|
|
189
|
+
* connections, this is likely due to it being close to the order that the bundles were
|
|
190
|
+
* inserted into the graph. There is a known issue where runtime assets marked
|
|
191
|
+
* as `isEntry` can create scenarios where there is no correct load order that
|
|
192
|
+
* won't error, as the entry runtime assets are added to many bundles in a
|
|
193
|
+
* single bundle group but their dependencies are not.
|
|
194
|
+
*
|
|
195
|
+
* This issue is almost exclusive to HMR scenarios as the two HMR runtime
|
|
196
|
+
* plugins (@atlaspack/runtime-browser-hmr and @atlaspack/runtime-react-refresh)
|
|
197
|
+
* are the only known cases where a runtime asset is marked as `isEntry`.
|
|
198
|
+
*/
|
|
199
|
+
let connections = [];
|
|
200
|
+
bundleGraph.traverseBundles({
|
|
201
|
+
// @ts-expect-error TS2304
|
|
202
|
+
enter(bundle) {
|
|
203
|
+
connections.push(...connectionMap.get(bundle));
|
|
204
|
+
},
|
|
205
|
+
});
|
|
206
|
+
// Add dev deps for runtime plugins AFTER running them, to account for lazy require().
|
|
207
|
+
for (let runtime of runtimes) {
|
|
208
|
+
let devDepRequest = await (0, DevDepRequest_1.createDevDependency)({
|
|
209
|
+
specifier: runtime.name,
|
|
210
|
+
resolveFrom: runtime.resolveFrom,
|
|
211
|
+
}, previousDevDeps, options);
|
|
212
|
+
devDepRequests.set(`${devDepRequest.specifier}:${(0, projectPath_1.fromProjectPathRelative)(devDepRequest.resolveFrom)}`, devDepRequest);
|
|
213
|
+
await (0, DevDepRequest_1.runDevDepRequest)(api, devDepRequest);
|
|
214
|
+
}
|
|
215
|
+
// Create a new AssetGraph from the generated runtime assets which also runs
|
|
216
|
+
// transforms and resolves all dependencies.
|
|
217
|
+
let { assetGraph: runtimesAssetGraph, changedAssets } = await reconcileNewRuntimes(api, connections, optionsRef);
|
|
218
|
+
if ((0, feature_flags_1.getFeatureFlag)('skipRuntimeSymbolProp')) {
|
|
219
|
+
// Apply pre-computed symbol data from runtime assets to skip symbol propagation
|
|
220
|
+
applyRuntimeSymbolData(runtimesAssetGraph, connections);
|
|
221
|
+
}
|
|
222
|
+
// Convert the runtime AssetGraph into a BundleGraph, this includes assigning
|
|
223
|
+
// the assets their public ids
|
|
224
|
+
let runtimesBundleGraph = BundleGraph_2.default.fromAssetGraph(runtimesAssetGraph, options.mode === 'production', bundleGraph._publicIdByAssetId, bundleGraph._assetPublicIds);
|
|
225
|
+
// Merge the runtimes bundle graph into the main bundle graph.
|
|
226
|
+
bundleGraph.merge(runtimesBundleGraph);
|
|
227
|
+
// Add the public id mappings from the runtumes bundlegraph to the main bundle graph
|
|
228
|
+
for (let [assetId, publicId] of runtimesBundleGraph._publicIdByAssetId) {
|
|
229
|
+
bundleGraph._publicIdByAssetId.set(assetId, publicId);
|
|
230
|
+
bundleGraph._assetPublicIds.add(publicId);
|
|
231
|
+
}
|
|
232
|
+
// Connect each of the generated runtime assets to bundles in the main bundle
|
|
233
|
+
// graph. This is like a mini-bundling algorithm for runtime assets.
|
|
234
|
+
for (let { bundle, assetGroup, dependency, isEntry } of connections) {
|
|
235
|
+
let assetGroupNode = (0, AssetGraph_1.nodeFromAssetGroup)(assetGroup);
|
|
236
|
+
let assetGroupAssetNodeIds = runtimesAssetGraph.getNodeIdsConnectedFrom(runtimesAssetGraph.getNodeIdByContentKey(assetGroupNode.id));
|
|
237
|
+
(0, assert_2.default)(assetGroupAssetNodeIds.length === 1);
|
|
238
|
+
let runtimeNodeId = assetGroupAssetNodeIds[0];
|
|
239
|
+
let runtimeNode = (0, nullthrows_1.default)(runtimesAssetGraph.getNode(runtimeNodeId));
|
|
240
|
+
(0, assert_2.default)(runtimeNode.type === 'asset');
|
|
241
|
+
// Find the asset that the runtime asset should be connected from by resolving
|
|
242
|
+
// it's dependency.
|
|
243
|
+
let resolution = dependency &&
|
|
244
|
+
bundleGraph.getResolvedAsset((0, Dependency_1.dependencyToInternalDependency)(dependency), bundle);
|
|
245
|
+
// Walk all the dependencies of the runtime assets and check if they are
|
|
246
|
+
// already reachable from the bundle that the runtime asset is assigned to.
|
|
247
|
+
// If so, we add them to `duplicatedContentKeys` to be skipped when assigning
|
|
248
|
+
// assets to bundles.
|
|
249
|
+
let runtimesBundleGraphRuntimeNodeId = runtimesBundleGraph._graph.getNodeIdByContentKey(runtimeNode.id);
|
|
250
|
+
let duplicatedContentKeys = new Set();
|
|
251
|
+
runtimesBundleGraph._graph.traverse((nodeId, _, actions) => {
|
|
252
|
+
let node = (0, nullthrows_1.default)(runtimesBundleGraph._graph.getNode(nodeId));
|
|
253
|
+
if (node.type !== 'dependency') {
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
let assets = runtimesBundleGraph._graph
|
|
257
|
+
.getNodeIdsConnectedFrom(nodeId)
|
|
258
|
+
.map((assetNodeId) => {
|
|
259
|
+
let assetNode = (0, nullthrows_1.default)(runtimesBundleGraph._graph.getNode(assetNodeId));
|
|
260
|
+
(0, assert_2.default)(assetNode.type === 'asset');
|
|
261
|
+
return assetNode.value;
|
|
262
|
+
});
|
|
263
|
+
for (let asset of assets) {
|
|
264
|
+
if (bundleGraph.isAssetReachableFromBundle(asset, bundle) ||
|
|
265
|
+
resolution?.id === asset.id) {
|
|
266
|
+
duplicatedContentKeys.add(asset.id);
|
|
267
|
+
actions.skipChildren();
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}, runtimesBundleGraphRuntimeNodeId);
|
|
271
|
+
let bundleNodeId = bundleGraph._graph.getNodeIdByContentKey(bundle.id);
|
|
272
|
+
let bundleGraphRuntimeNodeId = bundleGraph._graph.getNodeIdByContentKey(runtimeNode.id); // the node id is not constant between graphs
|
|
273
|
+
// Assign the runtime assets and all of it's depepdencies to the bundle unless
|
|
274
|
+
// we have detected it as already being reachable from this bundle via `duplicatedContentKeys`.
|
|
275
|
+
runtimesBundleGraph._graph.traverse((nodeId, _, actions) => {
|
|
276
|
+
let node = (0, nullthrows_1.default)(runtimesBundleGraph._graph.getNode(nodeId));
|
|
277
|
+
if (node.type === 'asset' || node.type === 'dependency') {
|
|
278
|
+
if (duplicatedContentKeys.has(node.id)) {
|
|
279
|
+
actions.skipChildren();
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
const bundleGraphNodeId = bundleGraph._graph.getNodeIdByContentKey(node.id); // the node id is not constant between graphs
|
|
283
|
+
bundleGraph._graph.addEdge(bundleNodeId, bundleGraphNodeId, BundleGraph_2.bundleGraphEdgeTypes.contains);
|
|
284
|
+
}
|
|
285
|
+
}, runtimesBundleGraphRuntimeNodeId);
|
|
286
|
+
if (isEntry) {
|
|
287
|
+
bundleGraph._graph.addEdge(bundleNodeId, bundleGraphRuntimeNodeId);
|
|
288
|
+
bundle.entryAssetIds.unshift(runtimeNode.id);
|
|
289
|
+
}
|
|
290
|
+
if (dependency == null) {
|
|
291
|
+
// Verify this asset won't become an island
|
|
292
|
+
(0, assert_1.default)(bundleGraph._graph.getNodeIdsConnectedTo(bundleGraphRuntimeNodeId)
|
|
293
|
+
.length > 0, 'Runtime must have an inbound dependency or be an entry');
|
|
294
|
+
}
|
|
295
|
+
else {
|
|
296
|
+
let dependencyNodeId = bundleGraph._graph.getNodeIdByContentKey(dependency.id);
|
|
297
|
+
bundleGraph._graph.addEdge(dependencyNodeId, bundleGraphRuntimeNodeId);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
return changedAssets;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Apply pre-computed symbol data from runtime assets to the asset graph
|
|
304
|
+
* to avoid running symbol propagation on runtime code we control.
|
|
305
|
+
*/
|
|
306
|
+
function applyRuntimeSymbolData(assetGraph, connections) {
|
|
307
|
+
for (let { assetGroup } of connections) {
|
|
308
|
+
let assetGroupNode = (0, AssetGraph_1.nodeFromAssetGroup)(assetGroup);
|
|
309
|
+
let assetGroupAssetNodeIds = assetGraph.getNodeIdsConnectedFrom(assetGraph.getNodeIdByContentKey(assetGroupNode.id));
|
|
310
|
+
if (assetGroupAssetNodeIds.length !== 1) {
|
|
311
|
+
continue;
|
|
312
|
+
}
|
|
313
|
+
let runtimeAssetNodeId = assetGroupAssetNodeIds[0];
|
|
314
|
+
let runtimeAssetNode = assetGraph.getNode(runtimeAssetNodeId);
|
|
315
|
+
if (!runtimeAssetNode || runtimeAssetNode.type !== 'asset') {
|
|
316
|
+
continue;
|
|
317
|
+
}
|
|
318
|
+
let symbolData = assetGroup.symbolData;
|
|
319
|
+
if (!symbolData) {
|
|
320
|
+
// We completely skip symbol propagation for runtime assets, so symbolData
|
|
321
|
+
// is required
|
|
322
|
+
throw new Error('Runtime asset is missing symbol data');
|
|
323
|
+
}
|
|
324
|
+
if (symbolData.symbols) {
|
|
325
|
+
// Convert from SymbolData format to internal Asset.symbols format
|
|
326
|
+
let internalSymbols = new Map();
|
|
327
|
+
for (let [symbol, data] of symbolData.symbols) {
|
|
328
|
+
internalSymbols.set(symbol, {
|
|
329
|
+
local: data.local,
|
|
330
|
+
loc: data.loc || null,
|
|
331
|
+
meta: data.meta,
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
runtimeAssetNode.value.symbols = internalSymbols;
|
|
335
|
+
}
|
|
336
|
+
if (symbolData.dependencies && symbolData.dependencies.length > 0) {
|
|
337
|
+
let outgoingDeps = assetGraph
|
|
338
|
+
.getNodeIdsConnectedFrom(runtimeAssetNodeId)
|
|
339
|
+
.map((id) => assetGraph.getNode(id))
|
|
340
|
+
.filter((node) => node?.type === 'dependency')
|
|
341
|
+
.map((node) => node);
|
|
342
|
+
for (let depSymbolData of symbolData.dependencies) {
|
|
343
|
+
let matchingDep = outgoingDeps.find((depNode) => depNode.value.specifier === depSymbolData.specifier);
|
|
344
|
+
if (matchingDep) {
|
|
345
|
+
if (depSymbolData.symbols) {
|
|
346
|
+
let internalDepSymbols = new Map();
|
|
347
|
+
for (let [symbol, data] of depSymbolData.symbols) {
|
|
348
|
+
internalDepSymbols.set(symbol, {
|
|
349
|
+
local: data.local,
|
|
350
|
+
loc: data.loc || null,
|
|
351
|
+
isWeak: data.isWeak,
|
|
352
|
+
meta: data.meta,
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
matchingDep.value.symbols = internalDepSymbols;
|
|
356
|
+
}
|
|
357
|
+
if (depSymbolData.usedSymbols) {
|
|
358
|
+
matchingDep.usedSymbolsDown = new Set(depSymbolData.usedSymbols);
|
|
359
|
+
// For runtime assets, usedSymbolsUp will be the same as usedSymbolsDown
|
|
360
|
+
// since we know exactly what we're using
|
|
361
|
+
let usedSymbolsUp = new Map();
|
|
362
|
+
for (let symbol of depSymbolData.usedSymbols) {
|
|
363
|
+
// Mark as resolved to external (null) since runtime deps are typically external
|
|
364
|
+
usedSymbolsUp.set(symbol, null);
|
|
365
|
+
}
|
|
366
|
+
matchingDep.usedSymbolsUp = usedSymbolsUp;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
function reconcileNewRuntimes(api, connections, optionsRef) {
|
|
374
|
+
let assetGroups = connections.map((t) => t.assetGroup);
|
|
375
|
+
let request = (0, AssetGraphRequest_1.default)({
|
|
376
|
+
name: 'Runtimes',
|
|
377
|
+
assetGroups,
|
|
378
|
+
optionsRef,
|
|
379
|
+
skipSymbolProp: (0, feature_flags_1.getFeatureFlag)('skipRuntimeSymbolProp') ||
|
|
380
|
+
(0, feature_flags_1.getFeatureFlag)('rustSymbolTracker'),
|
|
381
|
+
});
|
|
382
|
+
// rebuild the graph
|
|
383
|
+
return api.runRequest(request, { force: true });
|
|
384
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createAssetIdFromOptions = createAssetIdFromOptions;
|
|
7
|
+
exports.createAsset = createAsset;
|
|
8
|
+
exports.generateFromAST = generateFromAST;
|
|
9
|
+
exports.getInvalidationId = getInvalidationId;
|
|
10
|
+
exports.getInvalidationHash = getInvalidationHash;
|
|
11
|
+
const stream_1 = require("stream");
|
|
12
|
+
const build_cache_1 = require("@atlaspack/build-cache");
|
|
13
|
+
const logger_1 = require("@atlaspack/logger");
|
|
14
|
+
const nullthrows_1 = __importDefault(require("nullthrows"));
|
|
15
|
+
const loadAtlaspackPlugin_1 = __importDefault(require("./loadAtlaspackPlugin"));
|
|
16
|
+
const Asset_1 = require("./public/Asset");
|
|
17
|
+
const PluginOptions_1 = __importDefault(require("./public/PluginOptions"));
|
|
18
|
+
const utils_1 = require("@atlaspack/utils");
|
|
19
|
+
const utils_2 = require("./utils");
|
|
20
|
+
const projectPath_1 = require("./projectPath");
|
|
21
|
+
const rust_1 = require("@atlaspack/rust");
|
|
22
|
+
const types_1 = require("./types");
|
|
23
|
+
const profiler_1 = require("@atlaspack/profiler");
|
|
24
|
+
const IdentifierRegistry_1 = require("./IdentifierRegistry");
|
|
25
|
+
const EnvironmentManager_1 = require("./EnvironmentManager");
|
|
26
|
+
const source_map_1 = __importDefault(require("@atlaspack/source-map"));
|
|
27
|
+
function createAssetIdFromOptions(options) {
|
|
28
|
+
const data = {
|
|
29
|
+
environmentId: (0, EnvironmentManager_1.toEnvironmentId)(options.env),
|
|
30
|
+
filePath: options.filePath,
|
|
31
|
+
code: options.code,
|
|
32
|
+
pipeline: options.pipeline,
|
|
33
|
+
query: options.query,
|
|
34
|
+
uniqueKey: options.uniqueKey,
|
|
35
|
+
fileType: options.type,
|
|
36
|
+
};
|
|
37
|
+
const id = (0, rust_1.createAssetId)(data);
|
|
38
|
+
IdentifierRegistry_1.identifierRegistry.addIdentifier('asset', id, data);
|
|
39
|
+
return id;
|
|
40
|
+
}
|
|
41
|
+
function createAsset(projectRoot, options) {
|
|
42
|
+
return {
|
|
43
|
+
id: options.id != null ? options.id : createAssetIdFromOptions(options),
|
|
44
|
+
committed: options.committed ?? false,
|
|
45
|
+
filePath: options.filePath,
|
|
46
|
+
query: options.query,
|
|
47
|
+
bundleBehavior: options.bundleBehavior
|
|
48
|
+
? types_1.BundleBehavior[options.bundleBehavior]
|
|
49
|
+
: null,
|
|
50
|
+
isBundleSplittable: options.isBundleSplittable ?? true,
|
|
51
|
+
type: options.type,
|
|
52
|
+
contentKey: options.contentKey,
|
|
53
|
+
mapKey: options.mapKey,
|
|
54
|
+
astKey: options.astKey,
|
|
55
|
+
astGenerator: options.astGenerator,
|
|
56
|
+
dependencies: options.dependencies || new Map(),
|
|
57
|
+
isSource: options.isSource,
|
|
58
|
+
outputHash: options.outputHash,
|
|
59
|
+
pipeline: options.pipeline,
|
|
60
|
+
env: options.env,
|
|
61
|
+
meta: options.meta || {},
|
|
62
|
+
stats: options.stats,
|
|
63
|
+
symbols: options.symbols &&
|
|
64
|
+
new Map([...options.symbols].map(([k, v]) => [
|
|
65
|
+
k,
|
|
66
|
+
{
|
|
67
|
+
local: v.local,
|
|
68
|
+
meta: v.meta,
|
|
69
|
+
loc: (0, utils_2.toInternalSourceLocation)(projectRoot, v.loc),
|
|
70
|
+
},
|
|
71
|
+
])),
|
|
72
|
+
sideEffects: options.sideEffects ?? true,
|
|
73
|
+
uniqueKey: options.uniqueKey,
|
|
74
|
+
plugin: options.plugin,
|
|
75
|
+
configPath: options.configPath,
|
|
76
|
+
configKeyPath: options.configKeyPath,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
const generateResults = new WeakMap();
|
|
80
|
+
function generateFromAST(asset) {
|
|
81
|
+
let output = generateResults.get(asset.value);
|
|
82
|
+
if (output == null) {
|
|
83
|
+
output = _generateFromAST(asset);
|
|
84
|
+
generateResults.set(asset.value, output);
|
|
85
|
+
}
|
|
86
|
+
return output;
|
|
87
|
+
}
|
|
88
|
+
async function _generateFromAST(asset) {
|
|
89
|
+
let ast = await asset.getAST();
|
|
90
|
+
if (ast == null) {
|
|
91
|
+
throw new Error('Asset has no AST');
|
|
92
|
+
}
|
|
93
|
+
let pluginName = (0, nullthrows_1.default)(asset.value.plugin);
|
|
94
|
+
let { plugin } = await (0, loadAtlaspackPlugin_1.default)(pluginName, (0, projectPath_1.fromProjectPath)(asset.options.projectRoot, (0, nullthrows_1.default)(asset.value.configPath)), (0, nullthrows_1.default)(asset.value.configKeyPath), asset.options);
|
|
95
|
+
let generate = plugin.generate?.bind(plugin);
|
|
96
|
+
if (!generate) {
|
|
97
|
+
throw new Error(`${pluginName} does not have a generate method`);
|
|
98
|
+
}
|
|
99
|
+
let { content, map } = await generate({
|
|
100
|
+
asset: new Asset_1.Asset(asset),
|
|
101
|
+
ast,
|
|
102
|
+
options: new PluginOptions_1.default(asset.options),
|
|
103
|
+
logger: new logger_1.PluginLogger({ origin: pluginName }),
|
|
104
|
+
tracer: new profiler_1.PluginTracer({ origin: pluginName, category: 'asset-generate' }),
|
|
105
|
+
});
|
|
106
|
+
let mapBuffer = source_map_1.default.safeToBuffer(map);
|
|
107
|
+
// Store the results in the cache so we can avoid generating again next time
|
|
108
|
+
await Promise.all([
|
|
109
|
+
asset.options.cache.setStream((0, nullthrows_1.default)(asset.value.contentKey), (0, utils_1.blobToStream)(content)),
|
|
110
|
+
mapBuffer != null &&
|
|
111
|
+
asset.options.cache.setBlob((0, nullthrows_1.default)(asset.value.mapKey), mapBuffer),
|
|
112
|
+
]);
|
|
113
|
+
return {
|
|
114
|
+
content: content instanceof stream_1.Readable
|
|
115
|
+
? asset.options.cache.getStream((0, nullthrows_1.default)(asset.value.contentKey))
|
|
116
|
+
: content,
|
|
117
|
+
map,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function getInvalidationId(invalidation) {
|
|
121
|
+
switch (invalidation.type) {
|
|
122
|
+
case 'file':
|
|
123
|
+
return 'file:' + (0, projectPath_1.fromProjectPathRelative)(invalidation.filePath);
|
|
124
|
+
case 'env':
|
|
125
|
+
return 'env:' + invalidation.key;
|
|
126
|
+
case 'option':
|
|
127
|
+
return 'option:' + invalidation.key;
|
|
128
|
+
default:
|
|
129
|
+
// @ts-expect-error TS2339
|
|
130
|
+
throw new Error('Unknown invalidation type: ' + invalidation.type);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
const hashCache = (0, build_cache_1.createBuildCache)();
|
|
134
|
+
async function getInvalidationHash(invalidations, options) {
|
|
135
|
+
if (invalidations.length === 0) {
|
|
136
|
+
return '';
|
|
137
|
+
}
|
|
138
|
+
let sortedInvalidations = invalidations
|
|
139
|
+
.slice()
|
|
140
|
+
.sort((a, b) => (getInvalidationId(a) < getInvalidationId(b) ? -1 : 1));
|
|
141
|
+
let hashes = '';
|
|
142
|
+
for (let invalidation of sortedInvalidations) {
|
|
143
|
+
switch (invalidation.type) {
|
|
144
|
+
case 'file': {
|
|
145
|
+
// Only recompute the hash of this file if we haven't seen it already during this build.
|
|
146
|
+
let fileHash = hashCache.get(invalidation.filePath);
|
|
147
|
+
if (fileHash == null) {
|
|
148
|
+
fileHash = (0, utils_1.hashFile)(options.inputFS, (0, projectPath_1.fromProjectPath)(options.projectRoot, invalidation.filePath));
|
|
149
|
+
hashCache.set(invalidation.filePath, fileHash);
|
|
150
|
+
}
|
|
151
|
+
hashes += await fileHash;
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
case 'env':
|
|
155
|
+
hashes +=
|
|
156
|
+
invalidation.key + ':' + (options.env[invalidation.key] || '');
|
|
157
|
+
break;
|
|
158
|
+
case 'option':
|
|
159
|
+
hashes +=
|
|
160
|
+
// @ts-expect-error TS7053
|
|
161
|
+
invalidation.key + ':' + (0, utils_2.hashFromOption)(options[invalidation.key]);
|
|
162
|
+
break;
|
|
163
|
+
default:
|
|
164
|
+
// @ts-expect-error TS2339
|
|
165
|
+
throw new Error('Unknown invalidation type: ' + invalidation.type);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return (0, rust_1.hashString)(hashes);
|
|
169
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.AtlaspackV3 = void 0;
|
|
7
|
+
const rust_1 = require("@atlaspack/rust");
|
|
8
|
+
const NapiWorkerPool_1 = require("./NapiWorkerPool");
|
|
9
|
+
const diagnostic_1 = __importDefault(require("@atlaspack/diagnostic"));
|
|
10
|
+
class AtlaspackV3 {
|
|
11
|
+
constructor(atlaspack_napi, napiWorkerPool, isDefaultNapiWorkerPool) {
|
|
12
|
+
this._atlaspack_napi = atlaspack_napi;
|
|
13
|
+
this._napiWorkerPool = napiWorkerPool;
|
|
14
|
+
this._isDefaultNapiWorkerPool = isDefaultNapiWorkerPool;
|
|
15
|
+
}
|
|
16
|
+
static async create({ fs, packageManager, threads, lmdb, napiWorkerPool, ...options }) {
|
|
17
|
+
// @ts-expect-error TS2339
|
|
18
|
+
options.logLevel = options.logLevel || 'error';
|
|
19
|
+
// @ts-expect-error TS2339
|
|
20
|
+
options.defaultTargetOptions = options.defaultTargetOptions || {};
|
|
21
|
+
// @ts-expect-error TS2339
|
|
22
|
+
options.defaultTargetOptions.engines =
|
|
23
|
+
// @ts-expect-error TS2339
|
|
24
|
+
options.defaultTargetOptions.engines || {};
|
|
25
|
+
let isDefaultNapiWorkerPool = false;
|
|
26
|
+
if (!napiWorkerPool) {
|
|
27
|
+
napiWorkerPool = new NapiWorkerPool_1.NapiWorkerPool();
|
|
28
|
+
isDefaultNapiWorkerPool = true;
|
|
29
|
+
}
|
|
30
|
+
// @ts-expect-error TS2488
|
|
31
|
+
const [internal, error] = await (0, rust_1.atlaspackNapiCreate)({
|
|
32
|
+
fs,
|
|
33
|
+
packageManager,
|
|
34
|
+
threads,
|
|
35
|
+
options,
|
|
36
|
+
napiWorkerPool,
|
|
37
|
+
}, lmdb);
|
|
38
|
+
if (error !== null) {
|
|
39
|
+
throw new diagnostic_1.default({
|
|
40
|
+
diagnostic: error,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return new AtlaspackV3(internal, napiWorkerPool, isDefaultNapiWorkerPool);
|
|
44
|
+
}
|
|
45
|
+
end() {
|
|
46
|
+
// If the worker pool was provided to us, don't shut it down, it's up to the provider.
|
|
47
|
+
if (this._isDefaultNapiWorkerPool) {
|
|
48
|
+
this._napiWorkerPool.shutdown();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
buildAssetGraph(progressCallback) {
|
|
52
|
+
return (0, rust_1.atlaspackNapiBuildAssetGraph)(this._atlaspack_napi, progressCallback);
|
|
53
|
+
}
|
|
54
|
+
buildBundleGraph(progressCallback) {
|
|
55
|
+
return (0, rust_1.atlaspackNapiBuildBundleGraph)(this._atlaspack_napi, progressCallback);
|
|
56
|
+
}
|
|
57
|
+
build(progressCallback) {
|
|
58
|
+
return (0, rust_1.atlaspackNapiBuild)(this._atlaspack_napi, progressCallback);
|
|
59
|
+
}
|
|
60
|
+
loadBundleGraph(bundleGraph) {
|
|
61
|
+
const { nodesJson, edges, publicIdByAssetId, environmentsJson } = bundleGraph.serializeForNative();
|
|
62
|
+
return (0, rust_1.atlaspackNapiLoadBundleGraph)(this._atlaspack_napi, nodesJson, edges, publicIdByAssetId, environmentsJson);
|
|
63
|
+
}
|
|
64
|
+
updateBundleGraph(bundleGraph, changedAssetIds) {
|
|
65
|
+
const nodesJson = bundleGraph.serializeAssetNodesForNative(changedAssetIds);
|
|
66
|
+
return (0, rust_1.atlaspackNapiUpdateBundleGraph)(this._atlaspack_napi, nodesJson);
|
|
67
|
+
}
|
|
68
|
+
package(bundleId, options) {
|
|
69
|
+
return (0, rust_1.atlaspackNapiPackage)(this._atlaspack_napi, bundleId, options);
|
|
70
|
+
}
|
|
71
|
+
async respondToFsEvents(events) {
|
|
72
|
+
// @ts-expect-error TS2488
|
|
73
|
+
let [needsRebuild, error] = await (0, rust_1.atlaspackNapiRespondToFsEvents)(this._atlaspack_napi, events);
|
|
74
|
+
if (error) {
|
|
75
|
+
throw new Error(error);
|
|
76
|
+
}
|
|
77
|
+
return needsRebuild;
|
|
78
|
+
}
|
|
79
|
+
async completeCacheSession() {
|
|
80
|
+
return (await (0, rust_1.atlaspackNapiCompleteSession)(this._atlaspack_napi));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.AtlaspackV3 = AtlaspackV3;
|