@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,142 @@
|
|
|
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
|
+
const stream_1 = require("stream");
|
|
7
|
+
const build_cache_1 = require("@atlaspack/build-cache");
|
|
8
|
+
const utils_1 = require("@atlaspack/utils");
|
|
9
|
+
const source_map_1 = __importDefault(require("@atlaspack/source-map"));
|
|
10
|
+
const assetUtils_1 = require("./assetUtils");
|
|
11
|
+
class CommittedAsset {
|
|
12
|
+
constructor(value, options) {
|
|
13
|
+
this.value = value;
|
|
14
|
+
this.key = this.value.contentKey;
|
|
15
|
+
this.options = options;
|
|
16
|
+
}
|
|
17
|
+
getContent() {
|
|
18
|
+
if (this.content == null) {
|
|
19
|
+
if (this.key != null) {
|
|
20
|
+
if (this.value.isLargeBlob) {
|
|
21
|
+
return this.options.cache.getStream(this.key);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
return this.options.cache.getBlob(this.key);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
else if (this.value.astKey != null) {
|
|
28
|
+
return (0, utils_1.streamFromPromise)((0, assetUtils_1.generateFromAST)(this).then(({ content }) => {
|
|
29
|
+
if (!(content instanceof stream_1.Readable)) {
|
|
30
|
+
this.content = Promise.resolve(content);
|
|
31
|
+
}
|
|
32
|
+
return content;
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
throw new Error('Asset has no content');
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return this.content;
|
|
40
|
+
}
|
|
41
|
+
async getCode() {
|
|
42
|
+
let content;
|
|
43
|
+
if (this.content == null && this.key != null) {
|
|
44
|
+
this.content = this.options.cache.getBlob(this.key);
|
|
45
|
+
content = await this.content;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
content = await this.getContent();
|
|
49
|
+
}
|
|
50
|
+
if (typeof content === 'string' || content instanceof Buffer) {
|
|
51
|
+
return content.toString();
|
|
52
|
+
}
|
|
53
|
+
else if (content != null) {
|
|
54
|
+
// @ts-expect-error TS2345
|
|
55
|
+
this.content = (0, utils_1.bufferStream)(content);
|
|
56
|
+
return (await this.content).toString();
|
|
57
|
+
}
|
|
58
|
+
return '';
|
|
59
|
+
}
|
|
60
|
+
async getBuffer() {
|
|
61
|
+
let content = await this.getContent();
|
|
62
|
+
if (content == null) {
|
|
63
|
+
return Buffer.alloc(0);
|
|
64
|
+
}
|
|
65
|
+
else if (typeof content === 'string' || content instanceof Buffer) {
|
|
66
|
+
return Buffer.from(content);
|
|
67
|
+
}
|
|
68
|
+
// @ts-expect-error TS2345
|
|
69
|
+
this.content = (0, utils_1.bufferStream)(content);
|
|
70
|
+
// @ts-expect-error TS2322
|
|
71
|
+
return this.content;
|
|
72
|
+
}
|
|
73
|
+
getStream() {
|
|
74
|
+
let content = this.getContent();
|
|
75
|
+
return content instanceof Promise
|
|
76
|
+
? (0, utils_1.streamFromPromise)(content)
|
|
77
|
+
: (0, utils_1.blobToStream)(content);
|
|
78
|
+
}
|
|
79
|
+
getMapBuffer() {
|
|
80
|
+
let mapKey = this.value.mapKey;
|
|
81
|
+
if (mapKey != null && this.mapBuffer == null) {
|
|
82
|
+
this.mapBuffer = (async () => {
|
|
83
|
+
try {
|
|
84
|
+
// Handle v3 assets that were processed by the native asset graph code (i.e. not runtime
|
|
85
|
+
// or helper assets)
|
|
86
|
+
if (this.options.featureFlags.atlaspackV3 &&
|
|
87
|
+
this.value.meta.isV3 === true) {
|
|
88
|
+
let buffer = await this.options.cache.getBuffer(mapKey);
|
|
89
|
+
if (!buffer) {
|
|
90
|
+
return buffer;
|
|
91
|
+
}
|
|
92
|
+
// We make the conversion from json to buffer here, since both js packagers lazily
|
|
93
|
+
// instantiate a sourcemap from the map buffer. This ensures we do not have to modify
|
|
94
|
+
// the packagers in any significant way. Additionally, storing the SourceMap objects
|
|
95
|
+
// upfront in these packagers appears to make larger builds more prone to failing.
|
|
96
|
+
let sourceMap = new source_map_1.default(this.options.projectRoot);
|
|
97
|
+
sourceMap.addVLQMap(JSON.parse(buffer.toString()));
|
|
98
|
+
return sourceMap.toBuffer();
|
|
99
|
+
}
|
|
100
|
+
return await this.options.cache.getBlob(mapKey);
|
|
101
|
+
}
|
|
102
|
+
catch (err) {
|
|
103
|
+
if (err.code === 'ENOENT' && this.value.astKey != null) {
|
|
104
|
+
return (await (0, assetUtils_1.generateFromAST)(this)).map?.toBuffer();
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
throw err;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
})();
|
|
111
|
+
}
|
|
112
|
+
// @ts-expect-error TS2322
|
|
113
|
+
return this.mapBuffer ?? Promise.resolve();
|
|
114
|
+
}
|
|
115
|
+
getMap() {
|
|
116
|
+
if (this.map == null) {
|
|
117
|
+
this.map = (async () => {
|
|
118
|
+
let mapBuffer = await this.getMapBuffer();
|
|
119
|
+
if (mapBuffer) {
|
|
120
|
+
// Get sourcemap from flatbuffer
|
|
121
|
+
return new source_map_1.default(this.options.projectRoot, mapBuffer);
|
|
122
|
+
}
|
|
123
|
+
})();
|
|
124
|
+
}
|
|
125
|
+
return this.map;
|
|
126
|
+
}
|
|
127
|
+
getAST() {
|
|
128
|
+
if (this.value.astKey == null) {
|
|
129
|
+
return Promise.resolve(null);
|
|
130
|
+
}
|
|
131
|
+
if (this.ast == null) {
|
|
132
|
+
this.ast = this.options.cache
|
|
133
|
+
.getBlob(this.value.astKey)
|
|
134
|
+
.then((serializedAst) => (0, build_cache_1.deserializeRaw)(serializedAst));
|
|
135
|
+
}
|
|
136
|
+
return this.ast;
|
|
137
|
+
}
|
|
138
|
+
getDependencies() {
|
|
139
|
+
return Array.from(this.value.dependencies.values());
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
exports.default = CommittedAsset;
|
|
@@ -0,0 +1,125 @@
|
|
|
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.createDependencyId = createDependencyId;
|
|
7
|
+
exports.createDependency = createDependency;
|
|
8
|
+
exports.mergeDependencies = mergeDependencies;
|
|
9
|
+
const rust_1 = require("@atlaspack/rust");
|
|
10
|
+
const types_1 = require("./types");
|
|
11
|
+
const utils_1 = require("./utils");
|
|
12
|
+
const projectPath_1 = require("./projectPath");
|
|
13
|
+
const assert_1 = __importDefault(require("assert"));
|
|
14
|
+
const IdentifierRegistry_1 = require("./IdentifierRegistry");
|
|
15
|
+
const EnvironmentManager_1 = require("./EnvironmentManager");
|
|
16
|
+
function createDependencyId({ sourceAssetId, specifier, env, target, pipeline, specifierType, bundleBehavior, priority, packageConditions, }) {
|
|
17
|
+
(0, assert_1.default)(typeof specifierType === 'string');
|
|
18
|
+
(0, assert_1.default)(typeof priority === 'string' || priority == null);
|
|
19
|
+
const params = {
|
|
20
|
+
sourceAssetId,
|
|
21
|
+
specifier,
|
|
22
|
+
environmentId: (0, EnvironmentManager_1.toEnvironmentId)(env),
|
|
23
|
+
target: target != null
|
|
24
|
+
? {
|
|
25
|
+
...target,
|
|
26
|
+
env: (0, EnvironmentManager_1.fromEnvironmentId)(target.env),
|
|
27
|
+
}
|
|
28
|
+
: null,
|
|
29
|
+
pipeline,
|
|
30
|
+
specifierType: types_1.SpecifierType[specifierType],
|
|
31
|
+
bundleBehavior,
|
|
32
|
+
priority: priority ? types_1.Priority[priority] : types_1.Priority.sync,
|
|
33
|
+
packageConditions,
|
|
34
|
+
};
|
|
35
|
+
const id = (0, rust_1.createDependencyId)(params);
|
|
36
|
+
IdentifierRegistry_1.identifierRegistry.addIdentifier('dependency', id, params);
|
|
37
|
+
return id;
|
|
38
|
+
}
|
|
39
|
+
function createDependency(projectRoot, opts) {
|
|
40
|
+
let id = opts.id ||
|
|
41
|
+
createDependencyId({
|
|
42
|
+
bundleBehavior: opts.bundleBehavior,
|
|
43
|
+
env: opts.env,
|
|
44
|
+
packageConditions: opts.packageConditions,
|
|
45
|
+
pipeline: opts.pipeline,
|
|
46
|
+
priority: opts.priority,
|
|
47
|
+
sourceAssetId: opts.sourceAssetId,
|
|
48
|
+
specifier: opts.specifier,
|
|
49
|
+
specifierType: opts.specifierType,
|
|
50
|
+
target: opts.target,
|
|
51
|
+
});
|
|
52
|
+
let dep = {
|
|
53
|
+
id,
|
|
54
|
+
specifier: opts.specifier,
|
|
55
|
+
specifierType: types_1.SpecifierType[opts.specifierType],
|
|
56
|
+
priority: types_1.Priority[opts.priority ?? 'sync'],
|
|
57
|
+
needsStableName: opts.needsStableName ?? false,
|
|
58
|
+
bundleBehavior: opts.bundleBehavior
|
|
59
|
+
? types_1.BundleBehavior[opts.bundleBehavior]
|
|
60
|
+
: null,
|
|
61
|
+
isEntry: opts.isEntry ?? false,
|
|
62
|
+
isOptional: opts.isOptional ?? false,
|
|
63
|
+
loc: (0, utils_1.toInternalSourceLocation)(projectRoot, opts.loc),
|
|
64
|
+
env: opts.env,
|
|
65
|
+
meta: opts.meta || {},
|
|
66
|
+
target: opts.target,
|
|
67
|
+
sourceAssetId: opts.sourceAssetId,
|
|
68
|
+
sourcePath: (0, projectPath_1.toProjectPath)(projectRoot, opts.sourcePath),
|
|
69
|
+
resolveFrom: (0, projectPath_1.toProjectPath)(projectRoot, opts.resolveFrom),
|
|
70
|
+
range: opts.range,
|
|
71
|
+
symbols: opts.symbols &&
|
|
72
|
+
new Map([...opts.symbols].map(([k, v]) => [
|
|
73
|
+
k,
|
|
74
|
+
{
|
|
75
|
+
local: v.local,
|
|
76
|
+
meta: v.meta,
|
|
77
|
+
isWeak: v.isWeak,
|
|
78
|
+
loc: (0, utils_1.toInternalSourceLocation)(projectRoot, v.loc),
|
|
79
|
+
},
|
|
80
|
+
])),
|
|
81
|
+
pipeline: opts.pipeline,
|
|
82
|
+
};
|
|
83
|
+
if (opts.packageConditions) {
|
|
84
|
+
convertConditions(opts.packageConditions, dep);
|
|
85
|
+
}
|
|
86
|
+
return dep;
|
|
87
|
+
}
|
|
88
|
+
function mergeDependencies(a, b) {
|
|
89
|
+
let { meta, symbols, needsStableName, isEntry, isOptional, ...other } = b;
|
|
90
|
+
Object.assign(a, other);
|
|
91
|
+
Object.assign(a.meta, meta);
|
|
92
|
+
if (a.symbols && symbols) {
|
|
93
|
+
for (let [k, v] of symbols) {
|
|
94
|
+
a.symbols.set(k, v);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (needsStableName)
|
|
98
|
+
a.needsStableName = true;
|
|
99
|
+
if (isEntry)
|
|
100
|
+
a.isEntry = true;
|
|
101
|
+
if (!isOptional)
|
|
102
|
+
a.isOptional = false;
|
|
103
|
+
}
|
|
104
|
+
function convertConditions(conditions, dep) {
|
|
105
|
+
// Store common package conditions as bit flags to reduce size.
|
|
106
|
+
// Custom conditions are stored as strings.
|
|
107
|
+
let packageConditions = 0;
|
|
108
|
+
let customConditions = [];
|
|
109
|
+
for (let condition of conditions) {
|
|
110
|
+
// @ts-expect-error TS7053
|
|
111
|
+
if (types_1.ExportsCondition[condition]) {
|
|
112
|
+
// @ts-expect-error TS7053
|
|
113
|
+
packageConditions |= types_1.ExportsCondition[condition];
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
customConditions.push(condition);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (packageConditions) {
|
|
120
|
+
dep.packageConditions = packageConditions;
|
|
121
|
+
}
|
|
122
|
+
if (customConditions.length) {
|
|
123
|
+
dep.customPackageConditions = customConditions;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
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.createEnvironment = createEnvironment;
|
|
7
|
+
exports.mergeEnvironments = mergeEnvironments;
|
|
8
|
+
exports.getEnvironmentHash = getEnvironmentHash;
|
|
9
|
+
const rust_1 = require("@atlaspack/rust");
|
|
10
|
+
const utils_1 = require("./utils");
|
|
11
|
+
const Environment_1 = __importDefault(require("./public/Environment"));
|
|
12
|
+
const Environment_2 = require("./public/Environment");
|
|
13
|
+
const IdentifierRegistry_1 = require("./IdentifierRegistry");
|
|
14
|
+
const EnvironmentManager_1 = require("./EnvironmentManager");
|
|
15
|
+
const DEFAULT_ENGINES = {
|
|
16
|
+
browsers: ['> 0.25%'],
|
|
17
|
+
node: '>= 8.0.0',
|
|
18
|
+
};
|
|
19
|
+
function createEnvironment({ context, engines, includeNodeModules, outputFormat, sourceType = 'module', shouldOptimize = false, isLibrary = false, shouldScopeHoist = false, sourceMap, unstableSingleFileOutput = false, loc, customEnv, } = {
|
|
20
|
+
/*::...null*/
|
|
21
|
+
}) {
|
|
22
|
+
if (context == null) {
|
|
23
|
+
if (engines?.node) {
|
|
24
|
+
context = 'node';
|
|
25
|
+
}
|
|
26
|
+
else if (engines?.browsers) {
|
|
27
|
+
context = 'browser';
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
context = 'browser';
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (engines == null) {
|
|
34
|
+
switch (context) {
|
|
35
|
+
case 'node':
|
|
36
|
+
case 'electron-main':
|
|
37
|
+
engines = {
|
|
38
|
+
node: DEFAULT_ENGINES.node,
|
|
39
|
+
};
|
|
40
|
+
break;
|
|
41
|
+
case 'browser':
|
|
42
|
+
case 'web-worker':
|
|
43
|
+
case 'service-worker':
|
|
44
|
+
case 'tesseract':
|
|
45
|
+
case 'electron-renderer':
|
|
46
|
+
engines = {
|
|
47
|
+
// @ts-expect-error TS2322
|
|
48
|
+
browsers: DEFAULT_ENGINES.browsers,
|
|
49
|
+
};
|
|
50
|
+
break;
|
|
51
|
+
default:
|
|
52
|
+
engines = {};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (includeNodeModules == null) {
|
|
56
|
+
switch (context) {
|
|
57
|
+
case 'node':
|
|
58
|
+
case 'electron-main':
|
|
59
|
+
case 'electron-renderer':
|
|
60
|
+
includeNodeModules = false;
|
|
61
|
+
break;
|
|
62
|
+
case 'browser':
|
|
63
|
+
case 'web-worker':
|
|
64
|
+
case 'service-worker':
|
|
65
|
+
case 'tesseract':
|
|
66
|
+
default:
|
|
67
|
+
includeNodeModules = true;
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (outputFormat == null) {
|
|
72
|
+
switch (context) {
|
|
73
|
+
case 'node':
|
|
74
|
+
case 'electron-main':
|
|
75
|
+
case 'electron-renderer':
|
|
76
|
+
outputFormat = 'commonjs';
|
|
77
|
+
break;
|
|
78
|
+
default:
|
|
79
|
+
outputFormat = 'global';
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
let res = {
|
|
84
|
+
id: '',
|
|
85
|
+
context,
|
|
86
|
+
// @ts-expect-error TS2322
|
|
87
|
+
engines,
|
|
88
|
+
includeNodeModules,
|
|
89
|
+
outputFormat,
|
|
90
|
+
sourceType,
|
|
91
|
+
isLibrary,
|
|
92
|
+
shouldOptimize,
|
|
93
|
+
shouldScopeHoist,
|
|
94
|
+
sourceMap,
|
|
95
|
+
unstableSingleFileOutput,
|
|
96
|
+
loc,
|
|
97
|
+
customEnv,
|
|
98
|
+
};
|
|
99
|
+
res.id = getEnvironmentHash(res);
|
|
100
|
+
return (0, EnvironmentManager_1.toEnvironmentRef)(Object.freeze(res));
|
|
101
|
+
}
|
|
102
|
+
function mergeEnvironments(projectRoot, a, b) {
|
|
103
|
+
// If merging the same object, avoid copying.
|
|
104
|
+
if (a === b || !b) {
|
|
105
|
+
return (0, EnvironmentManager_1.toEnvironmentRef)(a);
|
|
106
|
+
}
|
|
107
|
+
if (b instanceof Environment_1.default) {
|
|
108
|
+
return (0, EnvironmentManager_1.toEnvironmentRef)((0, Environment_2.environmentToInternalEnvironment)(b));
|
|
109
|
+
}
|
|
110
|
+
return createEnvironment({
|
|
111
|
+
...a,
|
|
112
|
+
...b,
|
|
113
|
+
loc: b.loc ? (0, utils_1.toInternalSourceLocation)(projectRoot, b.loc) : a.loc,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
function getEnvironmentHash(env) {
|
|
117
|
+
const data = {
|
|
118
|
+
context: env.context,
|
|
119
|
+
engines: env.engines,
|
|
120
|
+
includeNodeModules: env.includeNodeModules,
|
|
121
|
+
outputFormat: env.outputFormat,
|
|
122
|
+
sourceType: env.sourceType,
|
|
123
|
+
isLibrary: env.isLibrary,
|
|
124
|
+
shouldOptimize: env.shouldOptimize,
|
|
125
|
+
shouldScopeHoist: env.shouldScopeHoist,
|
|
126
|
+
sourceMap: env.sourceMap,
|
|
127
|
+
customEnv: env.customEnv,
|
|
128
|
+
};
|
|
129
|
+
const id = (0, rust_1.createEnvironmentId)(data);
|
|
130
|
+
IdentifierRegistry_1.identifierRegistry.addIdentifier('environment', id, data);
|
|
131
|
+
return id;
|
|
132
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toEnvironmentRef = toEnvironmentRef;
|
|
4
|
+
exports.toEnvironmentId = toEnvironmentId;
|
|
5
|
+
exports.fromEnvironmentId = fromEnvironmentId;
|
|
6
|
+
exports.writeEnvironmentsToCache = writeEnvironmentsToCache;
|
|
7
|
+
exports.loadEnvironmentsFromCache = loadEnvironmentsFromCache;
|
|
8
|
+
const rust_1 = require("@atlaspack/rust");
|
|
9
|
+
const feature_flags_1 = require("@atlaspack/feature-flags");
|
|
10
|
+
const logger_1 = require("@atlaspack/logger");
|
|
11
|
+
const constants_1 = require("./constants");
|
|
12
|
+
const localEnvironmentCache = new Map();
|
|
13
|
+
/**
|
|
14
|
+
* Convert environment to a ref.
|
|
15
|
+
* This is what we should be using to store environments.
|
|
16
|
+
*/
|
|
17
|
+
function toEnvironmentRef(env) {
|
|
18
|
+
if (!(0, feature_flags_1.getFeatureFlag)('environmentDeduplication')) {
|
|
19
|
+
return env;
|
|
20
|
+
}
|
|
21
|
+
const id = toEnvironmentId(env);
|
|
22
|
+
return id;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Convert environment to a string ID
|
|
26
|
+
*/
|
|
27
|
+
function toEnvironmentId(
|
|
28
|
+
/**
|
|
29
|
+
* Redundant type during roll-out
|
|
30
|
+
*/
|
|
31
|
+
env) {
|
|
32
|
+
if (!(0, feature_flags_1.getFeatureFlag)('environmentDeduplication')) {
|
|
33
|
+
return typeof env === 'string' ? env : env.id;
|
|
34
|
+
}
|
|
35
|
+
if (typeof env === 'string') {
|
|
36
|
+
return env;
|
|
37
|
+
}
|
|
38
|
+
(0, rust_1.addEnvironment)(env);
|
|
39
|
+
return env.id;
|
|
40
|
+
}
|
|
41
|
+
function fromEnvironmentId(id) {
|
|
42
|
+
if (!(0, feature_flags_1.getFeatureFlag)('environmentDeduplication')) {
|
|
43
|
+
if (typeof id === 'string') {
|
|
44
|
+
throw new Error('This should never happen when environmentDeduplication feature-flag is off');
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
return id;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (typeof id !== 'string') {
|
|
51
|
+
return id;
|
|
52
|
+
}
|
|
53
|
+
const localEnv = localEnvironmentCache.get(id);
|
|
54
|
+
if (localEnv) {
|
|
55
|
+
return localEnv;
|
|
56
|
+
}
|
|
57
|
+
const env = Object.freeze((0, rust_1.getEnvironment)(id));
|
|
58
|
+
// @ts-expect-error TS2345
|
|
59
|
+
localEnvironmentCache.set(id, env);
|
|
60
|
+
// @ts-expect-error TS2322
|
|
61
|
+
return env;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Writes all environments and their IDs to the cache
|
|
65
|
+
* @param {Cache} cache
|
|
66
|
+
* @returns {Promise<void>}
|
|
67
|
+
*/
|
|
68
|
+
async function writeEnvironmentsToCache(cache) {
|
|
69
|
+
const environments = (0, rust_1.getAllEnvironments)();
|
|
70
|
+
const environmentIds = new Set();
|
|
71
|
+
// Store each environment individually
|
|
72
|
+
for (const env of environments) {
|
|
73
|
+
// @ts-expect-error TS18046
|
|
74
|
+
environmentIds.add(env.id);
|
|
75
|
+
// @ts-expect-error TS18046
|
|
76
|
+
const envKey = `Environment/${constants_1.ATLASPACK_VERSION}/${env.id}`;
|
|
77
|
+
await (0, logger_1.instrument)(`RequestTracker::writeToCache::cache.put(${envKey})`, async () => {
|
|
78
|
+
await cache.set(envKey, env);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
// Store the list of environment IDs
|
|
82
|
+
await (0, logger_1.instrument)(`RequestTracker::writeToCache::cache.put(${`EnvironmentManager/${constants_1.ATLASPACK_VERSION}`})`, async () => {
|
|
83
|
+
await cache.set(`EnvironmentManager/${constants_1.ATLASPACK_VERSION}`, Array.from(environmentIds));
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Loads all environments and their IDs from the cache
|
|
88
|
+
* @param {Cache} cache
|
|
89
|
+
* @returns {Promise<void>}
|
|
90
|
+
*/
|
|
91
|
+
async function loadEnvironmentsFromCache(cache) {
|
|
92
|
+
const cachedEnvIds = await cache.get(`EnvironmentManager/${constants_1.ATLASPACK_VERSION}`);
|
|
93
|
+
if (cachedEnvIds == null) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const environments = [];
|
|
97
|
+
// @ts-expect-error TS2488
|
|
98
|
+
for (const envId of cachedEnvIds) {
|
|
99
|
+
const envKey = `Environment/${constants_1.ATLASPACK_VERSION}/${envId}`;
|
|
100
|
+
const cachedEnv = await cache.get(envKey);
|
|
101
|
+
if (cachedEnv != null) {
|
|
102
|
+
environments.push(cachedEnv);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (environments.length > 0) {
|
|
106
|
+
(0, rust_1.setAllEnvironments)(environments);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
var _IdentifierRegistry_enabled, _IdentifierRegistry_createdDirectory;
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.identifierRegistry = exports.IdentifierRegistry = void 0;
|
|
19
|
+
const fs_1 = __importDefault(require("fs"));
|
|
20
|
+
class IdentifierRegistry {
|
|
21
|
+
constructor(enabled) {
|
|
22
|
+
_IdentifierRegistry_enabled.set(this, void 0);
|
|
23
|
+
_IdentifierRegistry_createdDirectory.set(this, false);
|
|
24
|
+
__classPrivateFieldSet(this, _IdentifierRegistry_enabled, enabled, "f");
|
|
25
|
+
}
|
|
26
|
+
addIdentifier(type, identifier, data) {
|
|
27
|
+
if (__classPrivateFieldGet(this, _IdentifierRegistry_enabled, "f")) {
|
|
28
|
+
if (!__classPrivateFieldGet(this, _IdentifierRegistry_createdDirectory, "f")) {
|
|
29
|
+
fs_1.default.mkdirSync('./.atlaspack', { recursive: true });
|
|
30
|
+
__classPrivateFieldSet(this, _IdentifierRegistry_createdDirectory, true, "f");
|
|
31
|
+
}
|
|
32
|
+
fs_1.default.appendFile('./.atlaspack/atlaspack-identifiers.txt', `${type} ${identifier} ${JSON.stringify(data)}\n`, () => { });
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.IdentifierRegistry = IdentifierRegistry;
|
|
37
|
+
_IdentifierRegistry_enabled = new WeakMap(), _IdentifierRegistry_createdDirectory = new WeakMap();
|
|
38
|
+
exports.identifierRegistry = new IdentifierRegistry(process.env.ATLASPACK_IDENTIFIER_DEBUG === 'true');
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createConfig = createConfig;
|
|
4
|
+
const projectPath_1 = require("./projectPath");
|
|
5
|
+
const Environment_1 = require("./Environment");
|
|
6
|
+
const rust_1 = require("@atlaspack/rust");
|
|
7
|
+
const IdentifierRegistry_1 = require("./IdentifierRegistry");
|
|
8
|
+
const EnvironmentManager_1 = require("./EnvironmentManager");
|
|
9
|
+
function createConfig({ plugin, isSource, searchPath, env, result, invalidateOnFileChange, invalidateOnConfigKeyChange, invalidateOnFileCreate, invalidateOnEnvChange, invalidateOnOptionChange, devDeps, invalidateOnStartup, invalidateOnBuild, }) {
|
|
10
|
+
let environment = env ?? (0, Environment_1.createEnvironment)();
|
|
11
|
+
const configId = (0, rust_1.hashString)(plugin +
|
|
12
|
+
(0, projectPath_1.fromProjectPathRelative)(searchPath) +
|
|
13
|
+
(0, EnvironmentManager_1.toEnvironmentId)(environment) +
|
|
14
|
+
String(isSource));
|
|
15
|
+
IdentifierRegistry_1.identifierRegistry.addIdentifier('config_request', configId, {
|
|
16
|
+
plugin,
|
|
17
|
+
searchPath,
|
|
18
|
+
environmentId: (0, EnvironmentManager_1.toEnvironmentId)(environment),
|
|
19
|
+
isSource,
|
|
20
|
+
});
|
|
21
|
+
return {
|
|
22
|
+
id: configId,
|
|
23
|
+
isSource: isSource ?? false,
|
|
24
|
+
searchPath,
|
|
25
|
+
env: environment,
|
|
26
|
+
result: result ?? null,
|
|
27
|
+
cacheKey: null,
|
|
28
|
+
invalidateOnFileChange: invalidateOnFileChange ?? new Set(),
|
|
29
|
+
invalidateOnConfigKeyChange: invalidateOnConfigKeyChange ?? [],
|
|
30
|
+
invalidateOnFileCreate: invalidateOnFileCreate ?? [],
|
|
31
|
+
invalidateOnEnvChange: invalidateOnEnvChange ?? new Set(),
|
|
32
|
+
invalidateOnOptionChange: invalidateOnOptionChange ?? new Set(),
|
|
33
|
+
devDeps: devDeps ?? [],
|
|
34
|
+
invalidateOnStartup: invalidateOnStartup ?? false,
|
|
35
|
+
invalidateOnBuild: invalidateOnBuild ?? false,
|
|
36
|
+
};
|
|
37
|
+
}
|