@atlaspack/core 2.16.2-canary.27 → 2.16.2-canary.270
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 +665 -0
- package/dist/AssetGraph.js +591 -0
- package/dist/Atlaspack.js +658 -0
- package/dist/AtlaspackConfig.js +324 -0
- package/dist/AtlaspackConfig.schema.js +108 -0
- package/dist/BundleGraph.js +1635 -0
- package/dist/CommittedAsset.js +142 -0
- package/dist/Dependency.js +125 -0
- package/dist/Environment.js +132 -0
- package/dist/EnvironmentManager.js +108 -0
- package/dist/IdentifierRegistry.js +38 -0
- package/dist/InternalConfig.js +37 -0
- package/dist/PackagerRunner.js +545 -0
- package/dist/ReporterRunner.js +151 -0
- package/dist/RequestTracker.js +1360 -0
- package/dist/SymbolPropagation.js +620 -0
- package/dist/TargetDescriptor.schema.js +143 -0
- package/dist/Transformation.js +490 -0
- package/dist/UncommittedAsset.js +315 -0
- package/dist/Validation.js +196 -0
- package/dist/applyRuntimes.js +305 -0
- package/dist/assetUtils.js +168 -0
- package/dist/atlaspack-v3/AtlaspackV3.js +70 -0
- package/dist/atlaspack-v3/NapiWorkerPool.js +57 -0
- package/dist/atlaspack-v3/fs.js +52 -0
- package/dist/atlaspack-v3/index.js +25 -0
- package/dist/atlaspack-v3/jsCallable.js +16 -0
- package/dist/atlaspack-v3/worker/compat/asset-symbols.js +190 -0
- package/dist/atlaspack-v3/worker/compat/bitflags.js +94 -0
- package/dist/atlaspack-v3/worker/compat/dependency.js +43 -0
- package/dist/atlaspack-v3/worker/compat/environment.js +57 -0
- package/dist/atlaspack-v3/worker/compat/index.js +25 -0
- package/dist/atlaspack-v3/worker/compat/mutable-asset.js +152 -0
- package/dist/atlaspack-v3/worker/compat/plugin-config.js +76 -0
- package/dist/atlaspack-v3/worker/compat/plugin-logger.js +26 -0
- package/dist/atlaspack-v3/worker/compat/plugin-options.js +122 -0
- package/dist/atlaspack-v3/worker/compat/plugin-tracer.js +10 -0
- package/dist/atlaspack-v3/worker/compat/target.js +14 -0
- package/dist/atlaspack-v3/worker/worker.js +297 -0
- package/dist/constants.js +17 -0
- package/dist/dumpGraphToGraphViz.js +281 -0
- package/dist/index.js +62 -0
- package/dist/loadAtlaspackPlugin.js +128 -0
- package/dist/loadDotEnv.js +41 -0
- package/dist/projectPath.js +83 -0
- package/dist/public/Asset.js +279 -0
- package/dist/public/Bundle.js +224 -0
- package/dist/public/BundleGraph.js +359 -0
- package/dist/public/BundleGroup.js +53 -0
- package/dist/public/Config.js +286 -0
- package/dist/public/Dependency.js +138 -0
- package/dist/public/Environment.js +278 -0
- package/dist/public/MutableBundleGraph.js +277 -0
- package/dist/public/PluginOptions.js +80 -0
- package/dist/public/Symbols.js +248 -0
- package/dist/public/Target.js +69 -0
- package/dist/registerCoreWithSerializer.js +38 -0
- package/dist/requests/AssetGraphRequest.js +429 -0
- package/dist/requests/AssetGraphRequestRust.js +262 -0
- package/dist/requests/AssetRequest.js +130 -0
- package/dist/requests/AtlaspackBuildRequest.js +65 -0
- package/dist/requests/AtlaspackConfigRequest.js +493 -0
- package/dist/requests/BundleGraphRequest.js +445 -0
- package/dist/requests/ConfigRequest.js +222 -0
- package/dist/requests/DevDepRequest.js +204 -0
- package/dist/requests/EntryRequest.js +314 -0
- package/dist/requests/PackageRequest.js +62 -0
- package/dist/requests/PathRequest.js +349 -0
- package/dist/requests/TargetRequest.js +1311 -0
- package/dist/requests/ValidationRequest.js +49 -0
- package/dist/requests/WriteBundleRequest.js +254 -0
- package/dist/requests/WriteBundlesRequest.js +184 -0
- package/dist/requests/asset-graph-diff.js +128 -0
- package/dist/requests/asset-graph-dot.js +131 -0
- package/dist/resolveOptions.js +268 -0
- package/dist/rustWorkerThreadDylibHack.js +19 -0
- package/dist/serializerCore.browser.js +43 -0
- package/dist/summarizeRequest.js +39 -0
- package/dist/types.js +31 -0
- package/dist/utils.js +172 -0
- package/dist/worker.js +123 -0
- package/lib/AssetGraph.js +111 -14
- package/lib/Atlaspack.js +81 -37
- package/lib/AtlaspackConfig.js +15 -3
- package/lib/AtlaspackConfig.schema.js +7 -5
- package/lib/BundleGraph.js +90 -32
- package/lib/CommittedAsset.js +6 -0
- package/lib/Dependency.js +8 -2
- package/lib/Environment.js +15 -8
- package/lib/EnvironmentManager.js +143 -0
- package/lib/IdentifierRegistry.js +1 -3
- package/lib/InternalConfig.js +3 -2
- package/lib/PackagerRunner.js +90 -27
- package/lib/ReporterRunner.js +6 -9
- package/lib/RequestTracker.js +266 -156
- package/lib/SymbolPropagation.js +42 -18
- package/lib/TargetDescriptor.schema.js +7 -1
- package/lib/Transformation.js +26 -10
- package/lib/UncommittedAsset.js +30 -9
- package/lib/Validation.js +18 -2
- package/lib/applyRuntimes.js +9 -1
- package/lib/assetUtils.js +7 -4
- package/lib/atlaspack-v3/AtlaspackV3.js +32 -7
- package/lib/atlaspack-v3/NapiWorkerPool.js +3 -0
- package/lib/atlaspack-v3/fs.js +3 -1
- package/lib/atlaspack-v3/index.js +28 -1
- package/lib/atlaspack-v3/jsCallable.js +0 -2
- package/lib/atlaspack-v3/worker/compat/asset-symbols.js +7 -4
- package/lib/atlaspack-v3/worker/compat/bitflags.js +7 -6
- package/lib/atlaspack-v3/worker/compat/dependency.js +3 -0
- package/lib/atlaspack-v3/worker/compat/environment.js +10 -7
- package/lib/atlaspack-v3/worker/compat/mutable-asset.js +14 -9
- package/lib/atlaspack-v3/worker/compat/plugin-config.js +8 -10
- package/lib/atlaspack-v3/worker/compat/plugin-options.js +1 -0
- package/lib/atlaspack-v3/worker/compat/plugin-tracer.js +3 -0
- package/lib/atlaspack-v3/worker/compat/target.js +2 -0
- package/lib/atlaspack-v3/worker/index.js +3 -0
- package/lib/atlaspack-v3/worker/worker.js +43 -7
- package/lib/constants.js +0 -1
- package/lib/dumpGraphToGraphViz.js +71 -16
- package/lib/index.js +45 -1
- package/lib/loadDotEnv.js +4 -1
- package/lib/projectPath.js +5 -0
- package/lib/public/Asset.js +21 -11
- package/lib/public/Bundle.js +15 -16
- package/lib/public/BundleGraph.js +10 -4
- package/lib/public/BundleGroup.js +4 -5
- package/lib/public/Config.js +118 -17
- package/lib/public/Dependency.js +8 -6
- package/lib/public/Environment.js +12 -7
- package/lib/public/MutableBundleGraph.js +54 -12
- package/lib/public/PluginOptions.js +2 -2
- package/lib/public/Symbols.js +11 -11
- package/lib/public/Target.js +7 -6
- package/lib/registerCoreWithSerializer.js +5 -3
- package/lib/requests/AssetGraphRequest.js +42 -5
- package/lib/requests/AssetGraphRequestRust.js +126 -62
- package/lib/requests/AssetRequest.js +23 -6
- package/lib/requests/AtlaspackBuildRequest.js +10 -4
- package/lib/requests/AtlaspackConfigRequest.js +27 -16
- package/lib/requests/BundleGraphRequest.js +34 -19
- package/lib/requests/ConfigRequest.js +28 -4
- package/lib/requests/DevDepRequest.js +31 -5
- package/lib/requests/EntryRequest.js +2 -0
- package/lib/requests/PackageRequest.js +2 -1
- package/lib/requests/PathRequest.js +24 -3
- package/lib/requests/TargetRequest.js +122 -57
- package/lib/requests/ValidationRequest.js +5 -1
- package/lib/requests/WriteBundleRequest.js +39 -11
- package/lib/requests/WriteBundlesRequest.js +51 -4
- package/lib/requests/asset-graph-diff.js +12 -7
- package/lib/requests/asset-graph-dot.js +1 -7
- package/lib/resolveOptions.js +36 -10
- package/lib/rustWorkerThreadDylibHack.js +0 -1
- package/lib/types/AssetGraph.d.ts +80 -0
- package/lib/types/Atlaspack.d.ts +52 -0
- package/lib/types/AtlaspackConfig.d.ts +65 -0
- package/lib/types/AtlaspackConfig.schema.d.ts +46 -0
- package/lib/types/BundleGraph.d.ts +182 -0
- package/lib/types/CommittedAsset.d.ts +23 -0
- package/lib/types/Dependency.d.ts +44 -0
- package/lib/types/Environment.d.ts +11 -0
- package/lib/types/EnvironmentManager.d.ts +37 -0
- package/lib/types/IdentifierRegistry.d.ts +6 -0
- package/lib/types/InternalConfig.d.ts +24 -0
- package/lib/types/PackagerRunner.d.ts +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 +26 -0
- package/lib/types/atlaspack-v3/NapiWorkerPool.d.ts +12 -0
- package/lib/types/atlaspack-v3/fs.d.ts +12 -0
- package/lib/types/atlaspack-v3/index.d.ts +5 -0
- package/lib/types/atlaspack-v3/jsCallable.d.ts +1 -0
- package/lib/types/atlaspack-v3/worker/compat/asset-symbols.d.ts +51 -0
- package/lib/types/atlaspack-v3/worker/compat/bitflags.d.ts +15 -0
- package/lib/types/atlaspack-v3/worker/compat/dependency.d.ts +25 -0
- package/lib/types/atlaspack-v3/worker/compat/environment.d.ts +27 -0
- package/{src/atlaspack-v3/worker/compat/index.js → lib/types/atlaspack-v3/worker/compat/index.d.ts} +0 -1
- package/lib/types/atlaspack-v3/worker/compat/mutable-asset.d.ts +49 -0
- package/lib/types/atlaspack-v3/worker/compat/plugin-config.d.ts +37 -0
- package/lib/types/atlaspack-v3/worker/compat/plugin-logger.d.ts +9 -0
- package/lib/types/atlaspack-v3/worker/compat/plugin-options.d.ts +22 -0
- package/lib/types/atlaspack-v3/worker/compat/plugin-tracer.d.ts +5 -0
- package/lib/types/atlaspack-v3/worker/compat/target.d.ts +11 -0
- package/lib/types/atlaspack-v3/worker/worker.d.ts +60 -0
- package/lib/types/constants.d.ts +13 -0
- package/lib/types/dumpGraphToGraphViz.d.ts +10 -0
- package/lib/types/index.d.ts +8 -0
- package/lib/types/loadAtlaspackPlugin.d.ts +8 -0
- package/lib/types/loadDotEnv.d.ts +3 -0
- package/lib/types/projectPath.d.ts +19 -0
- package/lib/types/public/Asset.d.ts +74 -0
- package/lib/types/public/Bundle.d.ts +45 -0
- package/lib/types/public/BundleGraph.d.ts +70 -0
- package/lib/types/public/BundleGroup.d.ts +12 -0
- package/lib/types/public/Config.d.ts +75 -0
- package/lib/types/public/Dependency.d.ts +32 -0
- package/lib/types/public/Environment.d.ts +34 -0
- package/lib/types/public/MutableBundleGraph.d.ts +26 -0
- package/lib/types/public/PluginOptions.d.ts +25 -0
- package/lib/types/public/Symbols.d.ts +81 -0
- package/lib/types/public/Target.d.ts +16 -0
- package/lib/types/registerCoreWithSerializer.d.ts +2 -0
- package/lib/types/requests/AssetGraphRequest.d.ts +74 -0
- package/lib/types/requests/AssetGraphRequestRust.d.ts +21 -0
- package/lib/types/requests/AssetRequest.d.ts +16 -0
- package/lib/types/requests/AtlaspackBuildRequest.d.ts +33 -0
- package/lib/types/requests/AtlaspackConfigRequest.d.ts +45 -0
- package/lib/types/requests/BundleGraphRequest.d.ts +28 -0
- package/lib/types/requests/ConfigRequest.d.ts +59 -0
- package/lib/types/requests/DevDepRequest.d.ts +30 -0
- package/lib/types/requests/EntryRequest.d.ts +36 -0
- package/lib/types/requests/PackageRequest.d.ts +27 -0
- package/lib/types/requests/PathRequest.d.ts +48 -0
- package/lib/types/requests/TargetRequest.d.ts +48 -0
- package/lib/types/requests/ValidationRequest.d.ts +20 -0
- package/lib/types/requests/WriteBundleRequest.d.ts +28 -0
- package/lib/types/requests/WriteBundlesRequest.d.ts +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 +493 -0
- package/lib/types/utils.d.ts +23 -0
- package/lib/types/worker.d.ts +44 -0
- package/lib/types.js +8 -1
- package/lib/utils.js +17 -2
- package/lib/worker.js +29 -13
- package/package.json +24 -34
- package/src/{AssetGraph.js → AssetGraph.ts} +156 -52
- package/src/{Atlaspack.js → Atlaspack.ts} +114 -61
- package/src/{AtlaspackConfig.schema.js → AtlaspackConfig.schema.ts} +16 -19
- package/src/{AtlaspackConfig.js → AtlaspackConfig.ts} +78 -54
- package/src/{BundleGraph.js → BundleGraph.ts} +231 -140
- package/src/{CommittedAsset.js → CommittedAsset.ts} +14 -12
- package/src/{Dependency.js → Dependency.ts} +59 -42
- package/src/{Environment.js → Environment.ts} +24 -15
- package/src/EnvironmentManager.ts +154 -0
- package/src/{IdentifierRegistry.js → IdentifierRegistry.ts} +1 -4
- package/src/{InternalConfig.js → InternalConfig.ts} +22 -23
- package/src/{PackagerRunner.js → PackagerRunner.ts} +178 -86
- package/src/{ReporterRunner.js → ReporterRunner.ts} +13 -18
- package/src/{RequestTracker.js → RequestTracker.ts} +572 -357
- package/src/{SymbolPropagation.js → SymbolPropagation.ts} +165 -57
- package/src/{TargetDescriptor.schema.js → TargetDescriptor.schema.ts} +7 -1
- package/src/{Transformation.js → Transformation.ts} +71 -62
- package/src/{UncommittedAsset.js → UncommittedAsset.ts} +57 -36
- package/src/{Validation.js → Validation.ts} +32 -17
- package/src/{applyRuntimes.js → applyRuntimes.ts} +35 -26
- package/src/{assetUtils.js → assetUtils.ts} +47 -35
- package/src/atlaspack-v3/AtlaspackV3.ts +122 -0
- package/src/atlaspack-v3/{NapiWorkerPool.js → NapiWorkerPool.ts} +10 -5
- package/src/atlaspack-v3/{fs.js → fs.ts} +3 -4
- package/src/atlaspack-v3/{index.js → index.ts} +2 -4
- package/src/atlaspack-v3/jsCallable.ts +14 -0
- package/src/atlaspack-v3/worker/compat/{asset-symbols.js → asset-symbols.ts} +40 -30
- package/src/atlaspack-v3/worker/compat/{bitflags.js → bitflags.ts} +9 -10
- package/src/atlaspack-v3/worker/compat/{dependency.js → dependency.ts} +12 -12
- package/src/atlaspack-v3/worker/compat/{environment.js → environment.ts} +13 -9
- package/src/atlaspack-v3/worker/compat/index.ts +9 -0
- package/src/atlaspack-v3/worker/compat/{mutable-asset.js → mutable-asset.ts} +20 -19
- package/src/atlaspack-v3/worker/compat/{plugin-config.js → plugin-config.ts} +27 -26
- package/src/atlaspack-v3/worker/compat/{plugin-logger.js → plugin-logger.ts} +0 -2
- package/src/atlaspack-v3/worker/compat/{plugin-options.js → plugin-options.ts} +4 -5
- package/src/atlaspack-v3/worker/compat/{plugin-tracer.js → plugin-tracer.ts} +2 -2
- package/src/atlaspack-v3/worker/compat/{target.js → target.ts} +3 -4
- package/src/atlaspack-v3/worker/index.js +2 -1
- package/src/atlaspack-v3/worker/{worker.js → worker.ts} +102 -66
- package/src/{constants.js → constants.ts} +0 -3
- package/src/{dumpGraphToGraphViz.js → dumpGraphToGraphViz.ts} +73 -28
- package/src/index.ts +18 -0
- package/src/{loadAtlaspackPlugin.js → loadAtlaspackPlugin.ts} +8 -9
- package/src/{loadDotEnv.js → loadDotEnv.ts} +2 -2
- package/src/{projectPath.js → projectPath.ts} +20 -9
- package/src/public/{Asset.js → Asset.ts} +40 -27
- package/src/public/{Bundle.js → Bundle.ts} +28 -29
- package/src/public/{BundleGraph.js → BundleGraph.ts} +81 -50
- package/src/public/{BundleGroup.js → BundleGroup.ts} +7 -10
- package/src/public/{Config.js → Config.ts} +171 -33
- package/src/public/{Dependency.js → Dependency.ts} +20 -17
- package/src/public/{Environment.js → Environment.ts} +28 -17
- package/src/public/{MutableBundleGraph.js → MutableBundleGraph.ts} +55 -24
- package/src/public/{PluginOptions.js → PluginOptions.ts} +6 -6
- package/src/public/{Symbols.js → Symbols.ts} +75 -36
- package/src/public/{Target.js → Target.ts} +10 -8
- package/src/{registerCoreWithSerializer.js → registerCoreWithSerializer.ts} +9 -7
- package/src/requests/{AssetGraphRequest.js → AssetGraphRequest.ts} +84 -49
- package/src/requests/AssetGraphRequestRust.ts +352 -0
- package/src/requests/{AssetRequest.js → AssetRequest.ts} +24 -18
- package/src/requests/{AtlaspackBuildRequest.js → AtlaspackBuildRequest.ts} +46 -32
- package/src/requests/{AtlaspackConfigRequest.js → AtlaspackConfigRequest.ts} +72 -58
- package/src/requests/{BundleGraphRequest.js → BundleGraphRequest.ts} +71 -58
- package/src/requests/{ConfigRequest.js → ConfigRequest.ts} +71 -50
- package/src/requests/{DevDepRequest.js → DevDepRequest.ts} +60 -35
- package/src/requests/{EntryRequest.js → EntryRequest.ts} +36 -31
- package/src/requests/{PackageRequest.js → PackageRequest.ts} +20 -22
- package/src/requests/{PathRequest.js → PathRequest.ts} +47 -37
- package/src/requests/{TargetRequest.js → TargetRequest.ts} +260 -179
- package/src/requests/{ValidationRequest.js → ValidationRequest.ts} +18 -17
- package/src/requests/{WriteBundleRequest.js → WriteBundleRequest.ts} +77 -49
- package/src/requests/{WriteBundlesRequest.js → WriteBundlesRequest.ts} +109 -37
- package/src/requests/{asset-graph-diff.js → asset-graph-diff.ts} +25 -21
- package/src/requests/{asset-graph-dot.js → asset-graph-dot.ts} +8 -12
- package/src/{resolveOptions.js → resolveOptions.ts} +56 -24
- package/src/{rustWorkerThreadDylibHack.js → rustWorkerThreadDylibHack.ts} +1 -4
- package/src/{serializerCore.browser.js → serializerCore.browser.ts} +2 -3
- package/src/{summarizeRequest.js → summarizeRequest.ts} +17 -5
- package/src/types.ts +647 -0
- package/src/{utils.js → utils.ts} +52 -21
- package/src/{worker.js → worker.ts} +49 -41
- package/test/{AssetGraph.test.js → AssetGraph.test.ts} +37 -8
- package/test/{Atlaspack.test.js → Atlaspack.test.ts} +5 -10
- package/test/{AtlaspackConfig.test.js → AtlaspackConfig.test.ts} +0 -5
- package/test/{AtlaspackConfigRequest.test.js → AtlaspackConfigRequest.test.ts} +75 -15
- package/test/{BundleGraph.test.js → BundleGraph.test.ts} +8 -13
- package/test/{Dependency.test.js → Dependency.test.ts} +2 -3
- package/test/{EntryRequest.test.js → EntryRequest.test.ts} +1 -6
- package/test/Environment.test.ts +153 -0
- package/test/EnvironmentManager.test.ts +188 -0
- package/test/{IdentifierRegistry.test.js → IdentifierRegistry.test.ts} +2 -4
- package/test/{InternalAsset.test.js → InternalAsset.test.ts} +2 -7
- package/test/PackagerRunner.test.ts +0 -0
- package/test/{PublicAsset.test.js → PublicAsset.test.ts} +2 -7
- package/test/{PublicBundle.test.js → PublicBundle.test.ts} +1 -2
- package/test/{PublicDependency.test.js → PublicDependency.test.ts} +0 -2
- package/test/PublicEnvironment.test.ts +49 -0
- package/test/{PublicMutableBundleGraph.test.js → PublicMutableBundleGraph.test.ts} +6 -11
- package/test/{RequestTracker.test.js → RequestTracker.test.ts} +314 -59
- package/test/{SymbolPropagation.test.js → SymbolPropagation.test.ts} +124 -74
- package/test/{TargetRequest.test.js → TargetRequest.test.ts} +66 -92
- package/test/fixtures/config-with-reporters/.parcelrc +7 -0
- package/test/fixtures/custom-targets/package.json +6 -0
- package/test/public/Config.test.ts +104 -0
- package/test/requests/{AssetGraphRequestRust.test.js → AssetGraphRequestRust.test.ts} +164 -134
- package/test/requests/{ConfigRequest.test.js → ConfigRequest.test.ts} +202 -13
- package/test/requests/{DevDepRequest.test.js → DevDepRequest.test.ts} +0 -2
- package/test/{test-utils.js → test-utils.ts} +4 -11
- package/test/{utils.test.js → utils.test.ts} +1 -3
- package/tsconfig.json +57 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/index.d.ts +0 -30
- package/src/atlaspack-v3/AtlaspackV3.js +0 -87
- package/src/atlaspack-v3/jsCallable.js +0 -18
- package/src/index.js +0 -13
- package/src/requests/AssetGraphRequestRust.js +0 -263
- 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
|
@@ -0,0 +1,545 @@
|
|
|
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
|
+
const assert_1 = __importDefault(require("assert"));
|
|
40
|
+
const build_cache_1 = require("@atlaspack/build-cache");
|
|
41
|
+
const utils_1 = require("@atlaspack/utils");
|
|
42
|
+
const logger_1 = require("@atlaspack/logger");
|
|
43
|
+
const diagnostic_1 = __importStar(require("@atlaspack/diagnostic"));
|
|
44
|
+
const stream_1 = require("stream");
|
|
45
|
+
const nullthrows_1 = __importDefault(require("nullthrows"));
|
|
46
|
+
const path_1 = __importDefault(require("path"));
|
|
47
|
+
const url_1 = __importDefault(require("url"));
|
|
48
|
+
const rust_1 = require("@atlaspack/rust");
|
|
49
|
+
const Bundle_1 = require("./public/Bundle");
|
|
50
|
+
const BundleGraph_1 = __importStar(require("./public/BundleGraph"));
|
|
51
|
+
const PluginOptions_1 = __importDefault(require("./public/PluginOptions"));
|
|
52
|
+
const Config_1 = __importDefault(require("./public/Config"));
|
|
53
|
+
const constants_1 = require("./constants");
|
|
54
|
+
const projectPath_1 = require("./projectPath");
|
|
55
|
+
const InternalConfig_1 = require("./InternalConfig");
|
|
56
|
+
const ConfigRequest_1 = require("./requests/ConfigRequest");
|
|
57
|
+
const DevDepRequest_1 = require("./requests/DevDepRequest");
|
|
58
|
+
const assetUtils_1 = require("./assetUtils");
|
|
59
|
+
const utils_2 = require("./utils");
|
|
60
|
+
const DevDepRequest_2 = require("./requests/DevDepRequest");
|
|
61
|
+
const profiler_1 = require("@atlaspack/profiler");
|
|
62
|
+
const EnvironmentManager_1 = require("./EnvironmentManager");
|
|
63
|
+
const feature_flags_1 = require("@atlaspack/feature-flags");
|
|
64
|
+
const BOUNDARY_LENGTH = constants_1.HASH_REF_PREFIX.length + 32 - 1;
|
|
65
|
+
// Packager/optimizer configs are not bundle-specific, so we only need to
|
|
66
|
+
// load them once per build.
|
|
67
|
+
const pluginConfigs = (0, build_cache_1.createBuildCache)();
|
|
68
|
+
class PackagerRunner {
|
|
69
|
+
constructor({ config, options, report, previousDevDeps, previousInvalidations, }) {
|
|
70
|
+
this.config = config;
|
|
71
|
+
this.options = options;
|
|
72
|
+
this.report = report;
|
|
73
|
+
this.previousDevDeps = previousDevDeps;
|
|
74
|
+
this.devDepRequests = new Map();
|
|
75
|
+
this.previousInvalidations = previousInvalidations;
|
|
76
|
+
this.invalidations = new Map();
|
|
77
|
+
this.pluginOptions = new PluginOptions_1.default((0, utils_2.optionsProxy)(this.options, (option) => {
|
|
78
|
+
let invalidation = {
|
|
79
|
+
type: 'option',
|
|
80
|
+
key: option,
|
|
81
|
+
};
|
|
82
|
+
this.invalidations.set((0, assetUtils_1.getInvalidationId)(invalidation), invalidation);
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
85
|
+
async run(bundleGraph, bundle, invalidDevDeps) {
|
|
86
|
+
(0, DevDepRequest_2.invalidateDevDeps)(invalidDevDeps, this.options, this.config);
|
|
87
|
+
let { configs, bundleConfigs } = await this.loadConfigs(bundleGraph, bundle);
|
|
88
|
+
let bundleInfo = (await this.getBundleInfoFromCache(bundleGraph, bundle, configs, bundleConfigs)) ??
|
|
89
|
+
(await this.getBundleInfo(bundle, bundleGraph, configs, bundleConfigs));
|
|
90
|
+
let configRequests = (0, ConfigRequest_1.getConfigRequests)([
|
|
91
|
+
...configs.values(),
|
|
92
|
+
...bundleConfigs.values(),
|
|
93
|
+
]);
|
|
94
|
+
let devDepRequests = (0, DevDepRequest_1.getWorkerDevDepRequests)([
|
|
95
|
+
...this.devDepRequests.values(),
|
|
96
|
+
]);
|
|
97
|
+
return {
|
|
98
|
+
bundleInfo,
|
|
99
|
+
configRequests,
|
|
100
|
+
devDepRequests,
|
|
101
|
+
invalidations: [...this.invalidations.values()],
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
async loadConfigs(bundleGraph, bundle) {
|
|
105
|
+
let configs = new Map();
|
|
106
|
+
let bundleConfigs = new Map();
|
|
107
|
+
await this.loadConfig(bundleGraph, bundle, configs, bundleConfigs);
|
|
108
|
+
for (let inlineBundle of bundleGraph.getInlineBundles(bundle)) {
|
|
109
|
+
await this.loadConfig(bundleGraph, inlineBundle, configs, bundleConfigs);
|
|
110
|
+
}
|
|
111
|
+
return { configs, bundleConfigs };
|
|
112
|
+
}
|
|
113
|
+
async loadConfig(bundleGraph, bundle, configs, bundleConfigs) {
|
|
114
|
+
let name = (0, nullthrows_1.default)(bundle.name);
|
|
115
|
+
let plugin = await this.config.getPackager(name);
|
|
116
|
+
await this.loadPluginConfig(bundleGraph, bundle, plugin, configs, bundleConfigs);
|
|
117
|
+
let optimizers = await this.config.getOptimizers(name, bundle.pipeline);
|
|
118
|
+
for (let optimizer of optimizers) {
|
|
119
|
+
await this.loadPluginConfig(bundleGraph, bundle, optimizer, configs, bundleConfigs);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
async loadPluginConfig(bundleGraph, bundle, plugin, configs, bundleConfigs) {
|
|
123
|
+
if (!configs.has(plugin.name)) {
|
|
124
|
+
// Only load config for a plugin once per build.
|
|
125
|
+
let existing = pluginConfigs.get(plugin.name);
|
|
126
|
+
if (existing != null) {
|
|
127
|
+
// @ts-expect-error TS2345
|
|
128
|
+
configs.set(plugin.name, existing);
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
if (plugin.plugin.loadConfig != null) {
|
|
132
|
+
let config = (0, InternalConfig_1.createConfig)({
|
|
133
|
+
plugin: plugin.name,
|
|
134
|
+
searchPath: (0, projectPath_1.toProjectPathUnsafe)('index'),
|
|
135
|
+
});
|
|
136
|
+
await (0, ConfigRequest_1.loadPluginConfig)(plugin, config, this.options);
|
|
137
|
+
for (let devDep of config.devDeps) {
|
|
138
|
+
let devDepRequest = await (0, DevDepRequest_1.createDevDependency)(devDep, this.previousDevDeps, this.options);
|
|
139
|
+
let key = `${devDep.specifier}:${(0, projectPath_1.fromProjectPath)(this.options.projectRoot, devDep.resolveFrom)}`;
|
|
140
|
+
this.devDepRequests.set(key, devDepRequest);
|
|
141
|
+
}
|
|
142
|
+
pluginConfigs.set(plugin.name, config);
|
|
143
|
+
configs.set(plugin.name, config);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
let loadBundleConfig = plugin.plugin.loadBundleConfig;
|
|
148
|
+
if (!bundleConfigs.has(plugin.name) && loadBundleConfig != null) {
|
|
149
|
+
let config = (0, InternalConfig_1.createConfig)({
|
|
150
|
+
plugin: plugin.name,
|
|
151
|
+
searchPath: (0, projectPath_1.joinProjectPath)(bundle.target.distDir, bundle.name ?? bundle.id),
|
|
152
|
+
});
|
|
153
|
+
config.result = await loadBundleConfig({
|
|
154
|
+
bundle: Bundle_1.NamedBundle.get(bundle, bundleGraph, this.options),
|
|
155
|
+
bundleGraph: new BundleGraph_1.default(bundleGraph, Bundle_1.NamedBundle.get.bind(Bundle_1.NamedBundle), this.options),
|
|
156
|
+
config: new Config_1.default(config, this.options),
|
|
157
|
+
options: new PluginOptions_1.default(this.options),
|
|
158
|
+
logger: new logger_1.PluginLogger({ origin: plugin.name }),
|
|
159
|
+
tracer: new profiler_1.PluginTracer({ origin: plugin.name, category: 'loadConfig' }),
|
|
160
|
+
});
|
|
161
|
+
bundleConfigs.set(plugin.name, config);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
async getBundleInfoFromCache(bundleGraph, bundle, configs, bundleConfigs) {
|
|
165
|
+
if (this.options.shouldDisableCache) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
let cacheKey = await this.getCacheKey(bundle, bundleGraph, configs, bundleConfigs, this.previousInvalidations);
|
|
169
|
+
let infoKey = PackagerRunner.getInfoKey(cacheKey);
|
|
170
|
+
return this.options.cache.get(infoKey);
|
|
171
|
+
}
|
|
172
|
+
async getBundleInfo(bundle, bundleGraph, configs, bundleConfigs) {
|
|
173
|
+
let { type, contents, map, scopeHoistingStats } = await this.getBundleResult(bundle, bundleGraph, configs, bundleConfigs);
|
|
174
|
+
// Recompute cache keys as they may have changed due to dev dependencies.
|
|
175
|
+
let cacheKey = await this.getCacheKey(bundle, bundleGraph, configs, bundleConfigs, [...this.invalidations.values()]);
|
|
176
|
+
let cacheKeys = {
|
|
177
|
+
content: PackagerRunner.getContentKey(cacheKey),
|
|
178
|
+
map: PackagerRunner.getMapKey(cacheKey),
|
|
179
|
+
info: PackagerRunner.getInfoKey(cacheKey),
|
|
180
|
+
};
|
|
181
|
+
let cachedResult = await this.writeToCache(cacheKeys, type, contents, map);
|
|
182
|
+
if (utils_1.debugTools['scope-hoisting-stats']) {
|
|
183
|
+
return { ...cachedResult, scopeHoistingStats };
|
|
184
|
+
}
|
|
185
|
+
return cachedResult;
|
|
186
|
+
}
|
|
187
|
+
async getBundleResult(bundle, bundleGraph, configs, bundleConfigs) {
|
|
188
|
+
let packaged = await this.package(bundle, bundleGraph, configs, bundleConfigs);
|
|
189
|
+
let type = packaged.type ?? bundle.type;
|
|
190
|
+
let res = await this.optimize(bundle, bundleGraph, type, packaged.contents, packaged.map, configs, bundleConfigs);
|
|
191
|
+
let map = res.map != null ? await this.generateSourceMap(bundle, res.map) : null;
|
|
192
|
+
return {
|
|
193
|
+
type: res.type ?? type,
|
|
194
|
+
contents: res.contents,
|
|
195
|
+
map,
|
|
196
|
+
scopeHoistingStats: packaged.scopeHoistingStats,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
getSourceMapReference(bundle, map) {
|
|
200
|
+
if (map &&
|
|
201
|
+
bundle.env.sourceMap &&
|
|
202
|
+
bundle.bundleBehavior !== 'inline' &&
|
|
203
|
+
bundle.bundleBehavior !== 'inlineIsolated') {
|
|
204
|
+
if (bundle.env.sourceMap && bundle.env.sourceMap.inline) {
|
|
205
|
+
return this.generateSourceMap((0, Bundle_1.bundleToInternalBundle)(bundle), map);
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
return path_1.default.basename(bundle.name) + '.map';
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
return null;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
async package(internalBundle, bundleGraph, configs, bundleConfigs) {
|
|
216
|
+
let bundle = Bundle_1.NamedBundle.get(internalBundle, bundleGraph, this.options);
|
|
217
|
+
this.report({
|
|
218
|
+
type: 'buildProgress',
|
|
219
|
+
phase: 'packaging',
|
|
220
|
+
bundle,
|
|
221
|
+
});
|
|
222
|
+
let packager = await this.config.getPackager(bundle.name);
|
|
223
|
+
let { name, resolveFrom, plugin } = packager;
|
|
224
|
+
let measurement;
|
|
225
|
+
try {
|
|
226
|
+
measurement = profiler_1.tracer.createMeasurement(name, 'packaging', bundle.name, {
|
|
227
|
+
type: bundle.type,
|
|
228
|
+
});
|
|
229
|
+
return await plugin.package({
|
|
230
|
+
config: configs.get(name)?.result,
|
|
231
|
+
bundleConfig: bundleConfigs.get(name)?.result,
|
|
232
|
+
bundle,
|
|
233
|
+
bundleGraph: new BundleGraph_1.default(bundleGraph, Bundle_1.NamedBundle.get.bind(Bundle_1.NamedBundle), this.options),
|
|
234
|
+
getSourceMapReference: (map) => {
|
|
235
|
+
return this.getSourceMapReference(bundle, map);
|
|
236
|
+
},
|
|
237
|
+
options: this.pluginOptions,
|
|
238
|
+
logger: new logger_1.PluginLogger({ origin: name }),
|
|
239
|
+
tracer: new profiler_1.PluginTracer({ origin: name, category: 'package' }),
|
|
240
|
+
getInlineBundleContents: async (bundle, bundleGraph) => {
|
|
241
|
+
if (bundle.bundleBehavior !== 'inline' &&
|
|
242
|
+
bundle.bundleBehavior !== 'inlineIsolated') {
|
|
243
|
+
throw new Error('Bundle is not inline and unable to retrieve contents');
|
|
244
|
+
}
|
|
245
|
+
let { contents } = await this.getBundleResult((0, Bundle_1.bundleToInternalBundle)(bundle), (0, BundleGraph_1.bundleGraphToInternalBundleGraph)(bundleGraph), configs, bundleConfigs);
|
|
246
|
+
return { contents };
|
|
247
|
+
},
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
catch (e) {
|
|
251
|
+
throw new diagnostic_1.default({
|
|
252
|
+
diagnostic: (0, diagnostic_1.errorToDiagnostic)(e, {
|
|
253
|
+
origin: name,
|
|
254
|
+
filePath: path_1.default.join(bundle.target.distDir, bundle.name),
|
|
255
|
+
}),
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
finally {
|
|
259
|
+
measurement && measurement.end();
|
|
260
|
+
// Add dev dependency for the packager. This must be done AFTER running it due to
|
|
261
|
+
// the potential for lazy require() that aren't executed until the request runs.
|
|
262
|
+
let devDepRequest = await (0, DevDepRequest_1.createDevDependency)({
|
|
263
|
+
specifier: name,
|
|
264
|
+
resolveFrom,
|
|
265
|
+
}, this.previousDevDeps, this.options);
|
|
266
|
+
this.devDepRequests.set(`${name}:${(0, projectPath_1.fromProjectPathRelative)(resolveFrom)}`, devDepRequest);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
async optimize(internalBundle, internalBundleGraph, type, contents, map, configs, bundleConfigs) {
|
|
270
|
+
let bundle = Bundle_1.NamedBundle.get(internalBundle, internalBundleGraph, this.options);
|
|
271
|
+
let bundleGraph = new BundleGraph_1.default(internalBundleGraph, Bundle_1.NamedBundle.get.bind(Bundle_1.NamedBundle), this.options);
|
|
272
|
+
let optimizers = await this.config.getOptimizers(bundle.name, internalBundle.pipeline);
|
|
273
|
+
if (!optimizers.length) {
|
|
274
|
+
return { type: bundle.type, contents, map };
|
|
275
|
+
}
|
|
276
|
+
this.report({
|
|
277
|
+
type: 'buildProgress',
|
|
278
|
+
phase: 'optimizing',
|
|
279
|
+
bundle,
|
|
280
|
+
});
|
|
281
|
+
let optimized = {
|
|
282
|
+
type,
|
|
283
|
+
contents,
|
|
284
|
+
map,
|
|
285
|
+
};
|
|
286
|
+
for (let optimizer of optimizers) {
|
|
287
|
+
let measurement;
|
|
288
|
+
try {
|
|
289
|
+
measurement = profiler_1.tracer.createMeasurement(optimizer.name, 'optimize', bundle.name);
|
|
290
|
+
let next = await optimizer.plugin.optimize({
|
|
291
|
+
config: configs.get(optimizer.name)?.result,
|
|
292
|
+
bundleConfig: bundleConfigs.get(optimizer.name)?.result,
|
|
293
|
+
bundle,
|
|
294
|
+
bundleGraph,
|
|
295
|
+
contents: optimized.contents,
|
|
296
|
+
map: optimized.map,
|
|
297
|
+
getSourceMapReference: (map) => {
|
|
298
|
+
return this.getSourceMapReference(bundle, map);
|
|
299
|
+
},
|
|
300
|
+
options: this.pluginOptions,
|
|
301
|
+
logger: new logger_1.PluginLogger({ origin: optimizer.name }),
|
|
302
|
+
tracer: new profiler_1.PluginTracer({
|
|
303
|
+
origin: optimizer.name,
|
|
304
|
+
category: 'optimize',
|
|
305
|
+
}),
|
|
306
|
+
});
|
|
307
|
+
optimized.type = next.type ?? optimized.type;
|
|
308
|
+
optimized.contents = next.contents;
|
|
309
|
+
optimized.map = next.map;
|
|
310
|
+
}
|
|
311
|
+
catch (e) {
|
|
312
|
+
throw new diagnostic_1.default({
|
|
313
|
+
diagnostic: (0, diagnostic_1.errorToDiagnostic)(e, {
|
|
314
|
+
origin: optimizer.name,
|
|
315
|
+
filePath: path_1.default.join(bundle.target.distDir, bundle.name),
|
|
316
|
+
}),
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
finally {
|
|
320
|
+
measurement && measurement.end();
|
|
321
|
+
// Add dev dependency for the optimizer. This must be done AFTER running it due to
|
|
322
|
+
// the potential for lazy require() that aren't executed until the request runs.
|
|
323
|
+
let devDepRequest = await (0, DevDepRequest_1.createDevDependency)({
|
|
324
|
+
specifier: optimizer.name,
|
|
325
|
+
resolveFrom: optimizer.resolveFrom,
|
|
326
|
+
}, this.previousDevDeps, this.options);
|
|
327
|
+
this.devDepRequests.set(`${optimizer.name}:${(0, projectPath_1.fromProjectPathRelative)(optimizer.resolveFrom)}`, devDepRequest);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
return optimized;
|
|
331
|
+
}
|
|
332
|
+
async generateSourceMap(bundle, map) {
|
|
333
|
+
// sourceRoot should be a relative path between outDir and rootDir for node.js targets
|
|
334
|
+
let filePath = (0, projectPath_1.joinProjectPath)(bundle.target.distDir, (0, nullthrows_1.default)(bundle.name));
|
|
335
|
+
let fullPath = (0, projectPath_1.fromProjectPath)(this.options.projectRoot, filePath);
|
|
336
|
+
let sourceRoot = path_1.default.relative(path_1.default.dirname(fullPath), this.options.projectRoot);
|
|
337
|
+
let inlineSources = false;
|
|
338
|
+
const bundleEnv = (0, EnvironmentManager_1.fromEnvironmentId)(bundle.env);
|
|
339
|
+
if (bundle.target) {
|
|
340
|
+
const bundleTargetEnv = (0, EnvironmentManager_1.fromEnvironmentId)(bundle.target.env);
|
|
341
|
+
if (bundleEnv.sourceMap && bundleEnv.sourceMap.sourceRoot !== undefined) {
|
|
342
|
+
sourceRoot = bundleEnv.sourceMap.sourceRoot;
|
|
343
|
+
}
|
|
344
|
+
else if (this.options.serveOptions &&
|
|
345
|
+
bundleTargetEnv.context === 'browser') {
|
|
346
|
+
sourceRoot = '/__parcel_source_root';
|
|
347
|
+
}
|
|
348
|
+
if (bundleEnv.sourceMap &&
|
|
349
|
+
bundleEnv.sourceMap.inlineSources !== undefined) {
|
|
350
|
+
inlineSources = bundleEnv.sourceMap.inlineSources;
|
|
351
|
+
}
|
|
352
|
+
else if (bundleTargetEnv.context !== 'node') {
|
|
353
|
+
// inlining should only happen in production for browser targets by default
|
|
354
|
+
inlineSources = this.options.mode === 'production';
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
let mapFilename = fullPath + '.map';
|
|
358
|
+
let isInlineMap = bundleEnv.sourceMap && bundleEnv.sourceMap.inline;
|
|
359
|
+
if ((0, feature_flags_1.getFeatureFlag)('omitSourcesContentInMemory') && !isInlineMap) {
|
|
360
|
+
if (!(bundleEnv.sourceMap && bundleEnv.sourceMap.inlineSources === false)) {
|
|
361
|
+
/*
|
|
362
|
+
We're omitting sourcesContent during transformation to allow GC to run.
|
|
363
|
+
Ensure sources are still inlined into the final source maps written to disk. UNLESS the user explicitly disabled inlineSources.
|
|
364
|
+
*/
|
|
365
|
+
inlineSources = true;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
let stringified = await map.stringify({
|
|
369
|
+
file: path_1.default.basename(mapFilename),
|
|
370
|
+
fs: this.options.inputFS,
|
|
371
|
+
rootDir: this.options.projectRoot,
|
|
372
|
+
sourceRoot: !inlineSources
|
|
373
|
+
? url_1.default.format(url_1.default.parse(sourceRoot + '/'))
|
|
374
|
+
: undefined,
|
|
375
|
+
inlineSources,
|
|
376
|
+
format: isInlineMap ? 'inline' : 'string',
|
|
377
|
+
});
|
|
378
|
+
(0, assert_1.default)(typeof stringified === 'string');
|
|
379
|
+
return stringified;
|
|
380
|
+
}
|
|
381
|
+
async getCacheKey(bundle, bundleGraph, configs, bundleConfigs, invalidations) {
|
|
382
|
+
let configResults = {};
|
|
383
|
+
for (let [pluginName, config] of configs) {
|
|
384
|
+
if (config) {
|
|
385
|
+
configResults[pluginName] = await (0, ConfigRequest_1.getConfigHash)(config, pluginName, this.options);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
let globalInfoResults = {};
|
|
389
|
+
for (let [pluginName, config] of bundleConfigs) {
|
|
390
|
+
if (config) {
|
|
391
|
+
globalInfoResults[pluginName] = await (0, ConfigRequest_1.getConfigHash)(config, pluginName, this.options);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
let devDepHashes = await this.getDevDepHashes(bundle);
|
|
395
|
+
for (let inlineBundle of bundleGraph.getInlineBundles(bundle)) {
|
|
396
|
+
devDepHashes += await this.getDevDepHashes(inlineBundle);
|
|
397
|
+
}
|
|
398
|
+
let invalidationHash = await (0, assetUtils_1.getInvalidationHash)(invalidations, this.options);
|
|
399
|
+
if ((0, feature_flags_1.getFeatureFlag)('cachePerformanceImprovements')) {
|
|
400
|
+
const hash = (0, rust_1.hashString)(constants_1.ATLASPACK_VERSION +
|
|
401
|
+
devDepHashes +
|
|
402
|
+
invalidationHash +
|
|
403
|
+
bundle.target.publicUrl +
|
|
404
|
+
bundleGraph.getHash(bundle) +
|
|
405
|
+
JSON.stringify(configResults) +
|
|
406
|
+
JSON.stringify(globalInfoResults) +
|
|
407
|
+
this.options.mode +
|
|
408
|
+
(this.options.shouldBuildLazily ? 'lazy' : 'eager'));
|
|
409
|
+
return path_1.default.join(bundle.displayName ?? bundle.name ?? bundle.id, hash);
|
|
410
|
+
}
|
|
411
|
+
return (0, rust_1.hashString)(constants_1.ATLASPACK_VERSION +
|
|
412
|
+
devDepHashes +
|
|
413
|
+
invalidationHash +
|
|
414
|
+
bundle.target.publicUrl +
|
|
415
|
+
bundleGraph.getHash(bundle) +
|
|
416
|
+
JSON.stringify(configResults) +
|
|
417
|
+
JSON.stringify(globalInfoResults) +
|
|
418
|
+
this.options.mode +
|
|
419
|
+
(this.options.shouldBuildLazily ? 'lazy' : 'eager'));
|
|
420
|
+
}
|
|
421
|
+
async getDevDepHashes(bundle) {
|
|
422
|
+
let name = (0, nullthrows_1.default)(bundle.name);
|
|
423
|
+
let packager = await this.config.getPackager(name);
|
|
424
|
+
let optimizers = await this.config.getOptimizers(name);
|
|
425
|
+
let key = `${packager.name}:${(0, projectPath_1.fromProjectPathRelative)(packager.resolveFrom)}`;
|
|
426
|
+
let devDepHashes = this.devDepRequests.get(key)?.hash ?? this.previousDevDeps.get(key) ?? '';
|
|
427
|
+
for (let { name, resolveFrom } of optimizers) {
|
|
428
|
+
let key = `${name}:${(0, projectPath_1.fromProjectPathRelative)(resolveFrom)}`;
|
|
429
|
+
devDepHashes +=
|
|
430
|
+
this.devDepRequests.get(key)?.hash ??
|
|
431
|
+
this.previousDevDeps.get(key) ??
|
|
432
|
+
'';
|
|
433
|
+
}
|
|
434
|
+
return devDepHashes;
|
|
435
|
+
}
|
|
436
|
+
async readFromCache(cacheKey) {
|
|
437
|
+
let contentKey = PackagerRunner.getContentKey(cacheKey);
|
|
438
|
+
let mapKey = PackagerRunner.getMapKey(cacheKey);
|
|
439
|
+
let isLargeBlob = await this.options.cache.hasLargeBlob(contentKey);
|
|
440
|
+
let contentExists = (0, feature_flags_1.getFeatureFlag)('cachePerformanceImprovements')
|
|
441
|
+
? isLargeBlob
|
|
442
|
+
: isLargeBlob || (await this.options.cache.has(contentKey));
|
|
443
|
+
if (!contentExists) {
|
|
444
|
+
return null;
|
|
445
|
+
}
|
|
446
|
+
let mapExists = (0, feature_flags_1.getFeatureFlag)('cachePerformanceImprovements')
|
|
447
|
+
? await this.options.cache.hasLargeBlob(mapKey)
|
|
448
|
+
: await this.options.cache.has(mapKey);
|
|
449
|
+
return {
|
|
450
|
+
contents: isLargeBlob
|
|
451
|
+
? this.options.cache.getStream(contentKey)
|
|
452
|
+
: (0, utils_1.blobToStream)(await this.options.cache.getBlob(contentKey)),
|
|
453
|
+
map: mapExists
|
|
454
|
+
? (0, utils_1.blobToStream)((0, feature_flags_1.getFeatureFlag)('cachePerformanceImprovements')
|
|
455
|
+
? await this.options.cache.getLargeBlob(mapKey)
|
|
456
|
+
: await this.options.cache.getBlob(mapKey))
|
|
457
|
+
: null,
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
async writeToCache(cacheKeys, type, contents, map) {
|
|
461
|
+
let size = 0;
|
|
462
|
+
let hash;
|
|
463
|
+
// @ts-expect-error TS2702
|
|
464
|
+
let hashReferences = [];
|
|
465
|
+
let isLargeBlob = (0, feature_flags_1.getFeatureFlag)('cachePerformanceImprovements');
|
|
466
|
+
// TODO: don't replace hash references in binary files??
|
|
467
|
+
if (contents instanceof stream_1.Readable) {
|
|
468
|
+
if (!(0, feature_flags_1.getFeatureFlag)('cachePerformanceImprovements')) {
|
|
469
|
+
isLargeBlob = true;
|
|
470
|
+
}
|
|
471
|
+
let boundaryStr = '';
|
|
472
|
+
let h = new rust_1.Hash();
|
|
473
|
+
await this.options.cache.setStream(cacheKeys.content, (0, utils_1.blobToStream)(contents).pipe(
|
|
474
|
+
// @ts-expect-error TS2554
|
|
475
|
+
new utils_1.TapStream((buf) => {
|
|
476
|
+
let str = boundaryStr + buf.toString();
|
|
477
|
+
hashReferences = hashReferences.concat(str.match(constants_1.HASH_REF_REGEX) ?? []);
|
|
478
|
+
size += buf.length;
|
|
479
|
+
h.writeBuffer(buf);
|
|
480
|
+
boundaryStr = str.slice(str.length - BOUNDARY_LENGTH);
|
|
481
|
+
})));
|
|
482
|
+
hash = h.finish();
|
|
483
|
+
}
|
|
484
|
+
else if (typeof contents === 'string') {
|
|
485
|
+
let buffer = Buffer.from(contents);
|
|
486
|
+
size = buffer.byteLength;
|
|
487
|
+
hash = (0, rust_1.hashBuffer)(buffer);
|
|
488
|
+
hashReferences = contents.match(constants_1.HASH_REF_REGEX) ?? [];
|
|
489
|
+
if ((0, feature_flags_1.getFeatureFlag)('cachePerformanceImprovements')) {
|
|
490
|
+
await this.options.cache.setLargeBlob(cacheKeys.content, buffer);
|
|
491
|
+
}
|
|
492
|
+
else {
|
|
493
|
+
await this.options.cache.setBlob(cacheKeys.content, buffer);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
else {
|
|
497
|
+
size = contents.length;
|
|
498
|
+
hash = (0, rust_1.hashBuffer)(contents);
|
|
499
|
+
hashReferences = contents.toString().match(constants_1.HASH_REF_REGEX) ?? [];
|
|
500
|
+
if ((0, feature_flags_1.getFeatureFlag)('cachePerformanceImprovements')) {
|
|
501
|
+
await this.options.cache.setLargeBlob(cacheKeys.content, contents);
|
|
502
|
+
}
|
|
503
|
+
else {
|
|
504
|
+
await this.options.cache.setBlob(cacheKeys.content, contents);
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
if (map != null) {
|
|
508
|
+
if ((0, feature_flags_1.getFeatureFlag)('cachePerformanceImprovements')) {
|
|
509
|
+
await this.options.cache.setLargeBlob(cacheKeys.map, map);
|
|
510
|
+
}
|
|
511
|
+
else {
|
|
512
|
+
await this.options.cache.setBlob(cacheKeys.map, map);
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
let info = {
|
|
516
|
+
type,
|
|
517
|
+
size,
|
|
518
|
+
hash,
|
|
519
|
+
hashReferences,
|
|
520
|
+
cacheKeys,
|
|
521
|
+
isLargeBlob,
|
|
522
|
+
};
|
|
523
|
+
await this.options.cache.set(cacheKeys.info, info);
|
|
524
|
+
return info;
|
|
525
|
+
}
|
|
526
|
+
static getContentKey(cacheKey) {
|
|
527
|
+
if ((0, feature_flags_1.getFeatureFlag)('cachePerformanceImprovements')) {
|
|
528
|
+
return `PackagerRunner/${constants_1.ATLASPACK_VERSION}/${cacheKey}/content`;
|
|
529
|
+
}
|
|
530
|
+
return (0, rust_1.hashString)(`${cacheKey}:content`);
|
|
531
|
+
}
|
|
532
|
+
static getMapKey(cacheKey) {
|
|
533
|
+
if ((0, feature_flags_1.getFeatureFlag)('cachePerformanceImprovements')) {
|
|
534
|
+
return `PackagerRunner/${constants_1.ATLASPACK_VERSION}/${cacheKey}/map`;
|
|
535
|
+
}
|
|
536
|
+
return (0, rust_1.hashString)(`${cacheKey}:map`);
|
|
537
|
+
}
|
|
538
|
+
static getInfoKey(cacheKey) {
|
|
539
|
+
if ((0, feature_flags_1.getFeatureFlag)('cachePerformanceImprovements')) {
|
|
540
|
+
return `PackagerRunner/${constants_1.ATLASPACK_VERSION}/${cacheKey}/info`;
|
|
541
|
+
}
|
|
542
|
+
return (0, rust_1.hashString)(`${cacheKey}:info`);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
exports.default = PackagerRunner;
|