@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
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.SourceMapHashRefRewriteStream = void 0;
|
|
7
|
+
exports.applyReplacementsToSourceMap = applyReplacementsToSourceMap;
|
|
8
|
+
exports.applyReplacementsToVLQMappings = applyReplacementsToVLQMappings;
|
|
9
|
+
exports.computeSourceMapRoot = computeSourceMapRoot;
|
|
6
10
|
exports.default = createWriteBundleRequest;
|
|
7
11
|
var _constants = require("../constants");
|
|
8
12
|
function _nullthrows() {
|
|
@@ -19,6 +23,13 @@ function _path() {
|
|
|
19
23
|
};
|
|
20
24
|
return data;
|
|
21
25
|
}
|
|
26
|
+
function _url() {
|
|
27
|
+
const data = _interopRequireDefault(require("url"));
|
|
28
|
+
_url = function () {
|
|
29
|
+
return data;
|
|
30
|
+
};
|
|
31
|
+
return data;
|
|
32
|
+
}
|
|
22
33
|
var _Bundle = require("../public/Bundle");
|
|
23
34
|
function _utils() {
|
|
24
35
|
const data = require("@atlaspack/utils");
|
|
@@ -45,7 +56,6 @@ function _logger() {
|
|
|
45
56
|
return data;
|
|
46
57
|
}
|
|
47
58
|
var _DevDepRequest = require("./DevDepRequest");
|
|
48
|
-
var _AtlaspackConfig = require("../AtlaspackConfig");
|
|
49
59
|
function _diagnostic() {
|
|
50
60
|
const data = _interopRequireWildcard(require("@atlaspack/diagnostic"));
|
|
51
61
|
_diagnostic = function () {
|
|
@@ -68,11 +78,22 @@ function _featureFlags() {
|
|
|
68
78
|
};
|
|
69
79
|
return data;
|
|
70
80
|
}
|
|
71
|
-
|
|
72
|
-
function
|
|
73
|
-
|
|
81
|
+
var _EnvironmentManager = require("../EnvironmentManager");
|
|
82
|
+
function _sourceMap() {
|
|
83
|
+
const data = require("@atlaspack/source-map");
|
|
84
|
+
_sourceMap = function () {
|
|
85
|
+
return data;
|
|
86
|
+
};
|
|
87
|
+
return data;
|
|
88
|
+
}
|
|
89
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
90
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
74
91
|
const HASH_REF_PREFIX_LEN = _constants.HASH_REF_PREFIX.length;
|
|
75
92
|
const BOUNDARY_LENGTH = _constants.HASH_REF_PREFIX.length + 32 - 1;
|
|
93
|
+
const HASH_REF_PLACEHOLDER_LEN = HASH_REF_PREFIX_LEN + _constants.HASH_REF_HASH_LEN;
|
|
94
|
+
|
|
95
|
+
// The JSON key prefix we scan for in the source map stream.
|
|
96
|
+
const MAPPINGS_KEY_BUF = Buffer.from('"mappings":"');
|
|
76
97
|
/**
|
|
77
98
|
* Writes a bundle to the dist directory, replacing hash references with the final content hashes.
|
|
78
99
|
*/
|
|
@@ -86,6 +107,8 @@ function createWriteBundleRequest(input) {
|
|
|
86
107
|
input
|
|
87
108
|
};
|
|
88
109
|
}
|
|
110
|
+
|
|
111
|
+
// @ts-expect-error TS7031
|
|
89
112
|
async function run({
|
|
90
113
|
input,
|
|
91
114
|
options,
|
|
@@ -121,7 +144,8 @@ async function run({
|
|
|
121
144
|
let cacheKeys = info.cacheKeys;
|
|
122
145
|
let mapKey = cacheKeys.map;
|
|
123
146
|
let fullPath = (0, _projectPath.fromProjectPath)(options.projectRoot, filePath);
|
|
124
|
-
|
|
147
|
+
const env = (0, _EnvironmentManager.fromEnvironmentId)(bundle.env);
|
|
148
|
+
if (mapKey && env.sourceMap && !env.sourceMap.inline) {
|
|
125
149
|
api.invalidateOnFileDelete((0, _projectPath.toProjectPath)(options.projectRoot, fullPath + '.map'));
|
|
126
150
|
}
|
|
127
151
|
let dir = _path().default.dirname(fullPath);
|
|
@@ -141,24 +165,36 @@ async function run({
|
|
|
141
165
|
contentStream = (0, _utils().blobToStream)(await options.cache.getBlob(cacheKeys.content));
|
|
142
166
|
}
|
|
143
167
|
let size = 0;
|
|
144
|
-
contentStream = contentStream.pipe(
|
|
168
|
+
contentStream = contentStream.pipe(
|
|
169
|
+
// @ts-expect-error TS2554
|
|
170
|
+
new (_utils().TapStream)(buf => {
|
|
145
171
|
size += buf.length;
|
|
146
172
|
}));
|
|
147
|
-
let configResult = (0, _nullthrows().default)(
|
|
173
|
+
let configResult = (0, _nullthrows().default)(
|
|
174
|
+
// @ts-expect-error TS2347
|
|
175
|
+
await api.runRequest((0, _AtlaspackConfigRequest.default)()));
|
|
148
176
|
let config = (0, _AtlaspackConfigRequest.getCachedAtlaspackConfig)(configResult, options);
|
|
149
177
|
let {
|
|
150
178
|
devDeps,
|
|
151
179
|
invalidDevDeps
|
|
152
180
|
} = await (0, _DevDepRequest.getDevDepRequests)(api);
|
|
153
181
|
(0, _DevDepRequest.invalidateDevDeps)(invalidDevDeps, options, config);
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
182
|
+
const bundleReplacements = (0, _featureFlags().getFeatureFlag)('fixSourceMapHashRefs') ? [] : undefined;
|
|
183
|
+
await writeFiles(contentStream, info, hashRefToNameHash, options, config, outputFS, filePath, writeOptions, devDeps, api, bundleReplacements);
|
|
184
|
+
const hasSourceMap = await options.cache.has(mapKey);
|
|
185
|
+
if (mapKey && env.sourceMap && !env.sourceMap.inline && hasSourceMap) {
|
|
186
|
+
const mapEntry = await options.cache.getBlob(mapKey);
|
|
187
|
+
let mapStream;
|
|
188
|
+
if ((0, _featureFlags().getFeatureFlag)('fixSourceMapHashRefs') && bundleReplacements && bundleReplacements.length > 0) {
|
|
189
|
+
mapStream = (0, _utils().blobToStream)(mapEntry).pipe(new SourceMapHashRefRewriteStream(bundleReplacements));
|
|
190
|
+
} else {
|
|
191
|
+
mapStream = (0, _utils().blobToStream)(mapEntry);
|
|
192
|
+
}
|
|
193
|
+
await writeFiles(mapStream, info, hashRefToNameHash, options, config, outputFS, (0, _projectPath.toProjectPathUnsafe)((0, _projectPath.fromProjectPathRelative)(filePath) + '.map'), writeOptions, devDeps, api);
|
|
159
194
|
}
|
|
160
195
|
let res = {
|
|
161
196
|
filePath,
|
|
197
|
+
bundleId: bundle.id,
|
|
162
198
|
type: info.type,
|
|
163
199
|
stats: {
|
|
164
200
|
size,
|
|
@@ -168,17 +204,255 @@ async function run({
|
|
|
168
204
|
api.storeResult(res);
|
|
169
205
|
return res;
|
|
170
206
|
}
|
|
171
|
-
|
|
207
|
+
function applyReplacementsToSourceMap(sourceMap, replacements) {
|
|
208
|
+
if (replacements.length === 0) return;
|
|
209
|
+
const sorted = [...replacements].sort((a, b) => a.line - b.line || a.column - b.column);
|
|
210
|
+
for (const r of sorted) {
|
|
211
|
+
const delta = r.newLength - r.originalLength;
|
|
212
|
+
if (delta !== 0) {
|
|
213
|
+
// r.column is in post-replacement coordinates (matching the already-shifted
|
|
214
|
+
// source map state after previous offsetColumns calls). The end of the
|
|
215
|
+
// placeholder in these coordinates is simply r.column + r.originalLength.
|
|
216
|
+
const offsetStartColumn = r.column + r.originalLength;
|
|
217
|
+
const line1Based = r.line + 1;
|
|
218
|
+
if (line1Based >= 1 && offsetStartColumn + delta >= 0) {
|
|
219
|
+
sourceMap.offsetColumns(line1Based, offsetStartColumn, delta);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Applies hash-ref replacement column offsets directly to a VLQ mappings
|
|
227
|
+
* string without deserializing the full source map into a native struct.
|
|
228
|
+
*
|
|
229
|
+
* Each replacement r describes a hash-ref that was substituted in the output
|
|
230
|
+
* file. r.column is in the progressively-shifted post-replacement coordinate
|
|
231
|
+
* space (matching the already-shifted source map state after all previous
|
|
232
|
+
* offsetColumns calls), so thresholds are applied sequentially against the
|
|
233
|
+
* running absCol values exactly as the native offsetColumns implementation does.
|
|
234
|
+
*/
|
|
235
|
+
function applyReplacementsToVLQMappings(mappings, replacements) {
|
|
236
|
+
if (replacements.length === 0) return mappings;
|
|
237
|
+
|
|
238
|
+
// Group replacements by line (0-indexed), sorted by column ascending.
|
|
239
|
+
const byLine = new Map();
|
|
240
|
+
for (const r of replacements) {
|
|
241
|
+
let arr = byLine.get(r.line);
|
|
242
|
+
if (!arr) {
|
|
243
|
+
arr = [];
|
|
244
|
+
byLine.set(r.line, arr);
|
|
245
|
+
}
|
|
246
|
+
arr.push(r);
|
|
247
|
+
}
|
|
248
|
+
for (const arr of byLine.values()) {
|
|
249
|
+
arr.sort((a, b) => a.column - b.column);
|
|
250
|
+
}
|
|
251
|
+
const lines = mappings.split(';');
|
|
252
|
+
const resultLines = [];
|
|
253
|
+
for (let lineIdx = 0; lineIdx < lines.length; lineIdx++) {
|
|
254
|
+
const lineReps = byLine.get(lineIdx);
|
|
255
|
+
if (!lineReps || lineReps.length === 0) {
|
|
256
|
+
resultLines.push(lines[lineIdx]);
|
|
257
|
+
continue;
|
|
258
|
+
}
|
|
259
|
+
const line = lines[lineIdx];
|
|
260
|
+
if (!line) {
|
|
261
|
+
resultLines.push('');
|
|
262
|
+
continue;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// Decode segment column deltas to absolute columns.
|
|
266
|
+
const segments = line.split(',');
|
|
267
|
+
const colVlqEnds = [];
|
|
268
|
+
const absCols = [];
|
|
269
|
+
let absCol = 0;
|
|
270
|
+
for (const seg of segments) {
|
|
271
|
+
const {
|
|
272
|
+
value: colDelta,
|
|
273
|
+
nextPos
|
|
274
|
+
} = (0, _sourceMap().decodeVLQ)(seg, 0);
|
|
275
|
+
absCol += colDelta;
|
|
276
|
+
colVlqEnds.push(nextPos);
|
|
277
|
+
absCols.push(absCol);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// Apply each replacement's column shift sequentially against the
|
|
281
|
+
// current absCol values (which have already been adjusted by previous
|
|
282
|
+
// replacements on this line), mirroring the sequential offsetColumns calls.
|
|
283
|
+
for (const r of lineReps) {
|
|
284
|
+
const delta = r.newLength - r.originalLength;
|
|
285
|
+
if (delta === 0) continue;
|
|
286
|
+
const threshold = r.column + r.originalLength;
|
|
287
|
+
for (let i = 0; i < absCols.length; i++) {
|
|
288
|
+
if (absCols[i] >= threshold) {
|
|
289
|
+
absCols[i] += delta;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// Re-encode with updated absolute columns; only the leading column VLQ
|
|
295
|
+
// field of each segment changes – the tail bytes are sliced unchanged.
|
|
296
|
+
const resultSegments = [];
|
|
297
|
+
let prevAbsCol = 0;
|
|
298
|
+
for (let i = 0; i < segments.length; i++) {
|
|
299
|
+
const newDelta = absCols[i] - prevAbsCol;
|
|
300
|
+
prevAbsCol = absCols[i];
|
|
301
|
+
resultSegments.push((0, _sourceMap().encodeVLQ)(newDelta) + segments[i].slice(colVlqEnds[i]));
|
|
302
|
+
}
|
|
303
|
+
resultLines.push(resultSegments.join(','));
|
|
304
|
+
}
|
|
305
|
+
return resultLines.join(';');
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* A Transform stream that rewrites the "mappings" VLQ field of a source map
|
|
309
|
+
* JSON to account for hash-ref replacements, without ever loading the full
|
|
310
|
+
* JSON object or the native Rust SourceMapInner into memory.
|
|
311
|
+
*
|
|
312
|
+
* Field order in cached source maps (from partialVlqMapToSourceMap / toVLQ):
|
|
313
|
+
* mappings → sources → sourcesContent → names → version → file → sourceRoot
|
|
314
|
+
*
|
|
315
|
+
* "mappings" is the very first field, so we scan only a tiny header before
|
|
316
|
+
* switching to zero-copy passthrough for the bulk sourcesContent bytes.
|
|
317
|
+
*/
|
|
318
|
+
class SourceMapHashRefRewriteStream extends _stream().Transform {
|
|
319
|
+
constructor(replacements) {
|
|
320
|
+
super();
|
|
321
|
+
this.replacements = replacements;
|
|
322
|
+
this.state = 'scanning';
|
|
323
|
+
this.scanBuf = Buffer.alloc(0);
|
|
324
|
+
this.mappingsBufs = [];
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// @ts-expect-error TS7006
|
|
328
|
+
_transform(chunk, _encoding, cb) {
|
|
329
|
+
if (this.state === 'passthrough') {
|
|
330
|
+
this.push(chunk);
|
|
331
|
+
cb();
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
if (this.state === 'scanning') {
|
|
335
|
+
const combined = Buffer.concat([this.scanBuf, chunk]);
|
|
336
|
+
const idx = combined.indexOf(MAPPINGS_KEY_BUF);
|
|
337
|
+
if (idx === -1) {
|
|
338
|
+
// Key not yet found – hold back enough bytes to handle a split key.
|
|
339
|
+
const keepLen = Math.min(combined.length, MAPPINGS_KEY_BUF.length - 1);
|
|
340
|
+
if (combined.length > keepLen) {
|
|
341
|
+
this.push(combined.slice(0, combined.length - keepLen));
|
|
342
|
+
}
|
|
343
|
+
this.scanBuf = combined.slice(combined.length - keepLen);
|
|
344
|
+
cb();
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// Emit everything up to and including the key.
|
|
349
|
+
const keyEnd = idx + MAPPINGS_KEY_BUF.length;
|
|
350
|
+
this.push(combined.slice(0, keyEnd));
|
|
351
|
+
this.scanBuf = Buffer.alloc(0);
|
|
352
|
+
this.state = 'buffering';
|
|
353
|
+
this._bufferingTransform(combined.slice(keyEnd), cb);
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
// state === 'buffering'
|
|
358
|
+
this._bufferingTransform(chunk, cb);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
// @ts-expect-error TS7006
|
|
362
|
+
_bufferingTransform(chunk, cb) {
|
|
363
|
+
// Mappings values contain only base64 chars, ';', and ',' – no escaping –
|
|
364
|
+
// so scanning for the closing '"' (0x22) is safe.
|
|
365
|
+
const closeIdx = chunk.indexOf(0x22);
|
|
366
|
+
if (closeIdx === -1) {
|
|
367
|
+
this.mappingsBufs.push(chunk);
|
|
368
|
+
cb();
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
this.mappingsBufs.push(chunk.slice(0, closeIdx));
|
|
372
|
+
|
|
373
|
+
// VLQ chars are all ASCII (<128), so latin1 round-trips without loss.
|
|
374
|
+
const mappingsStr = Buffer.concat(this.mappingsBufs).toString('latin1');
|
|
375
|
+
const rewritten = applyReplacementsToVLQMappings(mappingsStr, this.replacements);
|
|
376
|
+
this.push(Buffer.from(rewritten, 'latin1'));
|
|
377
|
+
|
|
378
|
+
// Emit the closing '"' and everything remaining in one push.
|
|
379
|
+
this.push(chunk.slice(closeIdx));
|
|
380
|
+
this.state = 'passthrough';
|
|
381
|
+
this.mappingsBufs = [];
|
|
382
|
+
cb();
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
// @ts-expect-error TS7006
|
|
386
|
+
_flush(cb) {
|
|
387
|
+
if (this.state === 'scanning' && this.scanBuf.length > 0) {
|
|
388
|
+
this.push(this.scanBuf);
|
|
389
|
+
} else if (this.state === 'buffering') {
|
|
390
|
+
// Malformed JSON – flush whatever we buffered as-is.
|
|
391
|
+
this.push(Buffer.concat(this.mappingsBufs));
|
|
392
|
+
}
|
|
393
|
+
cb();
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* Computes the sourceRoot for a source map file. This is the relative path from
|
|
399
|
+
* the output directory back to the project root, so that source paths (stored
|
|
400
|
+
* relative to projectRoot) resolve correctly from the .map file location.
|
|
401
|
+
*
|
|
402
|
+
* Returns undefined when sources are inlined (inlineSources), since the browser
|
|
403
|
+
* doesn't need to fetch them and sourceRoot would be unnecessary.
|
|
404
|
+
*
|
|
405
|
+
* This logic must stay in sync with PackagerRunner.generateSourceMap.
|
|
406
|
+
*/
|
|
407
|
+
exports.SourceMapHashRefRewriteStream = SourceMapHashRefRewriteStream;
|
|
408
|
+
function computeSourceMapRoot(bundle, options) {
|
|
409
|
+
let name = (0, _nullthrows().default)(bundle.name);
|
|
410
|
+
let filePath = (0, _projectPath.joinProjectPath)(bundle.target.distDir, name);
|
|
411
|
+
let fullPath = (0, _projectPath.fromProjectPath)(options.projectRoot, filePath);
|
|
412
|
+
let sourceRoot = _path().default.relative(_path().default.dirname(fullPath), options.projectRoot);
|
|
413
|
+
let inlineSources = false;
|
|
414
|
+
const bundleEnv = (0, _EnvironmentManager.fromEnvironmentId)(bundle.env);
|
|
415
|
+
if (bundle.target) {
|
|
416
|
+
const bundleTargetEnv = (0, _EnvironmentManager.fromEnvironmentId)(bundle.target.env);
|
|
417
|
+
if (bundleEnv.sourceMap && bundleEnv.sourceMap.sourceRoot !== undefined) {
|
|
418
|
+
sourceRoot = bundleEnv.sourceMap.sourceRoot;
|
|
419
|
+
} else if (options.serveOptions && bundleTargetEnv.context === 'browser') {
|
|
420
|
+
sourceRoot = '/__parcel_source_root';
|
|
421
|
+
}
|
|
422
|
+
if (bundleEnv.sourceMap && bundleEnv.sourceMap.inlineSources !== undefined) {
|
|
423
|
+
inlineSources = bundleEnv.sourceMap.inlineSources;
|
|
424
|
+
} else if (bundleTargetEnv.context !== 'node') {
|
|
425
|
+
inlineSources = options.mode === 'production';
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
let isInlineMap = bundleEnv.sourceMap && bundleEnv.sourceMap.inline;
|
|
429
|
+
if ((0, _featureFlags().getFeatureFlag)('omitSourcesContentInMemory') && !isInlineMap) {
|
|
430
|
+
if (!(bundleEnv.sourceMap && bundleEnv.sourceMap.inlineSources === false)) {
|
|
431
|
+
inlineSources = true;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
if (inlineSources) {
|
|
435
|
+
return undefined;
|
|
436
|
+
}
|
|
437
|
+
return _url().default.format(_url().default.parse(sourceRoot + '/'));
|
|
438
|
+
}
|
|
439
|
+
async function writeFiles(
|
|
440
|
+
// @ts-expect-error TS2503
|
|
441
|
+
inputStream, info, hashRefToNameHash, options, config, outputFS, filePath, writeOptions, devDeps, api, bundleReplacements) {
|
|
172
442
|
let compressors = await config.getCompressors((0, _projectPath.fromProjectPathRelative)(filePath));
|
|
173
443
|
let fullPath = (0, _projectPath.fromProjectPath)(options.projectRoot, filePath);
|
|
174
|
-
let stream = info.hashReferences.length ? inputStream.pipe(replaceStream(hashRefToNameHash)) : inputStream;
|
|
444
|
+
let stream = info.hashReferences.length ? inputStream.pipe(replaceStream(hashRefToNameHash, bundleReplacements)) : inputStream;
|
|
175
445
|
let promises = [];
|
|
176
446
|
for (let compressor of compressors) {
|
|
177
|
-
promises.push(
|
|
447
|
+
promises.push(
|
|
448
|
+
// @ts-expect-error TS2345
|
|
449
|
+
runCompressor(compressor, cloneStream(stream), options, outputFS, fullPath, writeOptions, devDeps, api));
|
|
178
450
|
}
|
|
179
451
|
await Promise.all(promises);
|
|
180
452
|
}
|
|
181
|
-
async function runCompressor(compressor,
|
|
453
|
+
async function runCompressor(compressor,
|
|
454
|
+
// @ts-expect-error TS2503
|
|
455
|
+
stream, options, outputFS, filePath, writeOptions, devDeps, api) {
|
|
182
456
|
let measurement;
|
|
183
457
|
try {
|
|
184
458
|
measurement = _profiler().tracer.createMeasurement(compressor.name, 'compress', _path().default.relative(options.projectRoot, filePath));
|
|
@@ -195,7 +469,9 @@ async function runCompressor(compressor, stream, options, outputFS, filePath, wr
|
|
|
195
469
|
});
|
|
196
470
|
if (res != null) {
|
|
197
471
|
await new Promise((resolve, reject) => (0, _stream().pipeline)(res.stream, outputFS.createWriteStream(filePath + (res.type != null ? '.' + res.type : ''), writeOptions), err => {
|
|
198
|
-
if (err) reject(err);
|
|
472
|
+
if (err) reject(err);
|
|
473
|
+
// @ts-expect-error TS2794
|
|
474
|
+
else resolve();
|
|
199
475
|
}));
|
|
200
476
|
}
|
|
201
477
|
} catch (err) {
|
|
@@ -214,9 +490,25 @@ async function runCompressor(compressor, stream, options, outputFS, filePath, wr
|
|
|
214
490
|
await (0, _DevDepRequest.runDevDepRequest)(api, devDepRequest);
|
|
215
491
|
}
|
|
216
492
|
}
|
|
217
|
-
function
|
|
493
|
+
function advanceLineColumn(line, column, buf) {
|
|
494
|
+
for (let i = 0; i < buf.length; i++) {
|
|
495
|
+
if (buf[i] === 0x0a) {
|
|
496
|
+
line++;
|
|
497
|
+
column = 0;
|
|
498
|
+
} else {
|
|
499
|
+
column++;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
return {
|
|
503
|
+
line,
|
|
504
|
+
column
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
function replaceStream(hashRefToNameHash, replacements) {
|
|
218
508
|
let boundaryStr = Buffer.alloc(0);
|
|
219
509
|
let replaced = Buffer.alloc(0);
|
|
510
|
+
let outputLine = 0;
|
|
511
|
+
let outputColumn = 0;
|
|
220
512
|
return new (_stream().Transform)({
|
|
221
513
|
transform(chunk, encoding, cb) {
|
|
222
514
|
let str = Buffer.concat([boundaryStr, Buffer.from(chunk)]);
|
|
@@ -234,15 +526,29 @@ function replaceStream(hashRefToNameHash) {
|
|
|
234
526
|
} else {
|
|
235
527
|
let match = str.subarray(matchI, matchI + HASH_REF_PREFIX_LEN + _constants.HASH_REF_HASH_LEN).toString();
|
|
236
528
|
let replacement = Buffer.from(hashRefToNameHash.get(match) ?? match);
|
|
529
|
+
// Copy pre-match content FIRST so position calculation includes it
|
|
237
530
|
replaced.set(str.subarray(lastMatchI, matchI), replacedLength);
|
|
238
531
|
replacedLength += matchI - lastMatchI;
|
|
532
|
+
if (replacements) {
|
|
533
|
+
const pos = advanceLineColumn(outputLine, outputColumn, replaced.subarray(0, replacedLength));
|
|
534
|
+
replacements.push({
|
|
535
|
+
line: pos.line,
|
|
536
|
+
column: pos.column,
|
|
537
|
+
originalLength: HASH_REF_PLACEHOLDER_LEN,
|
|
538
|
+
newLength: replacement.byteLength
|
|
539
|
+
});
|
|
540
|
+
}
|
|
239
541
|
replaced.set(replacement, replacedLength);
|
|
240
542
|
replacedLength += replacement.byteLength;
|
|
241
543
|
lastMatchI = matchI + HASH_REF_PREFIX_LEN + _constants.HASH_REF_HASH_LEN;
|
|
242
544
|
}
|
|
243
545
|
}
|
|
546
|
+
const pushLen = replacedLength - BOUNDARY_LENGTH;
|
|
547
|
+
const pushed = advanceLineColumn(outputLine, outputColumn, replaced.subarray(0, pushLen));
|
|
548
|
+
outputLine = pushed.line;
|
|
549
|
+
outputColumn = pushed.column;
|
|
244
550
|
boundaryStr = replaced.subarray(replacedLength - BOUNDARY_LENGTH, replacedLength);
|
|
245
|
-
let strUpToBoundary = replaced.subarray(0,
|
|
551
|
+
let strUpToBoundary = replaced.subarray(0, pushLen);
|
|
246
552
|
cb(null, strUpToBoundary);
|
|
247
553
|
},
|
|
248
554
|
flush(cb) {
|
|
@@ -250,12 +556,15 @@ function replaceStream(hashRefToNameHash) {
|
|
|
250
556
|
}
|
|
251
557
|
});
|
|
252
558
|
}
|
|
559
|
+
|
|
560
|
+
// @ts-expect-error TS2503
|
|
253
561
|
function cloneStream(readable) {
|
|
254
562
|
let res = new (_stream().Readable)();
|
|
255
|
-
// $FlowFixMe
|
|
256
563
|
res._read = () => {};
|
|
564
|
+
// @ts-expect-error TS7006
|
|
257
565
|
readable.on('data', chunk => res.push(chunk));
|
|
258
566
|
readable.on('end', () => res.push(null));
|
|
567
|
+
// @ts-expect-error TS7006
|
|
259
568
|
readable.on('error', err => res.emit('error', err));
|
|
260
569
|
return res;
|
|
261
570
|
}
|
|
@@ -12,6 +12,8 @@ function _featureFlags() {
|
|
|
12
12
|
return data;
|
|
13
13
|
}
|
|
14
14
|
var _RequestTracker = require("../RequestTracker");
|
|
15
|
+
var _types = require("../types");
|
|
16
|
+
var _ReporterRunner = require("../ReporterRunner");
|
|
15
17
|
var _constants = require("../constants");
|
|
16
18
|
var _projectPath = require("../projectPath");
|
|
17
19
|
function _nullthrows() {
|
|
@@ -30,7 +32,33 @@ function _rust() {
|
|
|
30
32
|
}
|
|
31
33
|
var _PackageRequest = require("./PackageRequest");
|
|
32
34
|
var _WriteBundleRequest = _interopRequireDefault(require("./WriteBundleRequest"));
|
|
33
|
-
function
|
|
35
|
+
function _utils() {
|
|
36
|
+
const data = require("@atlaspack/utils");
|
|
37
|
+
_utils = function () {
|
|
38
|
+
return data;
|
|
39
|
+
};
|
|
40
|
+
return data;
|
|
41
|
+
}
|
|
42
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
43
|
+
/** Length of the hash suffix in output filenames (e.g. .runtime.13dc01ac.js). */
|
|
44
|
+
const NAME_HASH_DISPLAY_LEN = 8;
|
|
45
|
+
|
|
46
|
+
/** Use at most NAME_HASH_DISPLAY_LEN chars for the name hash so filenames stay short. */
|
|
47
|
+
function nameHashForFilename(hash) {
|
|
48
|
+
return hash.length <= NAME_HASH_DISPLAY_LEN ? hash : hash.slice(-NAME_HASH_DISPLAY_LEN);
|
|
49
|
+
}
|
|
50
|
+
function reportPackagingProgress(completeBundles, totalBundles) {
|
|
51
|
+
if (!(0, _featureFlags().getFeatureFlag)('cliProgressReportingImprovements')) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
(0, _ReporterRunner.report)({
|
|
55
|
+
type: 'buildProgress',
|
|
56
|
+
phase: 'packagingAndOptimizing',
|
|
57
|
+
totalBundles,
|
|
58
|
+
completeBundles
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
34
62
|
/**
|
|
35
63
|
* Packages, optimizes, and writes all bundles to the dist directory.
|
|
36
64
|
*/
|
|
@@ -67,15 +95,16 @@ async function run({
|
|
|
67
95
|
const allBundles = bundleGraph.getBundles({
|
|
68
96
|
includeInline: (0, _featureFlags().getFeatureFlag)('inlineBundlesSourceMapFixes')
|
|
69
97
|
});
|
|
70
|
-
const bundles = allBundles.filter(bundle => bundle.bundleBehavior !==
|
|
98
|
+
const bundles = allBundles.filter(bundle => bundle.bundleBehavior !== _types.BundleBehavior.inline && bundle.bundleBehavior !== _types.BundleBehavior.inlineIsolated).filter(bundle => {
|
|
71
99
|
// Do not package and write placeholder bundles to disk. We just
|
|
72
100
|
// need to update the name so other bundles can reference it.
|
|
73
101
|
if (bundle.isPlaceholder) {
|
|
74
|
-
|
|
75
|
-
hashRefToNameHash.set(bundle.hashReference,
|
|
76
|
-
let name = (0, _nullthrows().default)(bundle.name, `Expected ${bundle.type} bundle to have a name`).replace(bundle.hashReference,
|
|
102
|
+
const nameHash = nameHashForFilename(bundle.id);
|
|
103
|
+
hashRefToNameHash.set(bundle.hashReference, nameHash);
|
|
104
|
+
let name = (0, _nullthrows().default)(bundle.name, `Expected ${bundle.type} bundle to have a name`).replace(bundle.hashReference, nameHash);
|
|
77
105
|
res.set(bundle.id, {
|
|
78
106
|
filePath: (0, _projectPath.joinProjectPath)(bundle.target.distDir, name),
|
|
107
|
+
bundleId: bundle.id,
|
|
79
108
|
type: bundle.type,
|
|
80
109
|
// FIXME: this is wrong if the packager changes the type...
|
|
81
110
|
stats: {
|
|
@@ -87,11 +116,14 @@ async function run({
|
|
|
87
116
|
}
|
|
88
117
|
return true;
|
|
89
118
|
});
|
|
119
|
+
let cachedBundles = new Set(bundles.filter(b => api.canSkipSubrequest(bundleGraph.getHash(b))));
|
|
90
120
|
|
|
91
121
|
// Package on the main thread if there is only one bundle to package.
|
|
92
122
|
// This avoids the cost of serializing the bundle graph for single file change builds.
|
|
93
|
-
let useMainThread = bundles.length === 1 || bundles.
|
|
123
|
+
let useMainThread = bundles.length === 1 || bundles.length - cachedBundles.size <= 1;
|
|
94
124
|
try {
|
|
125
|
+
let completeBundles = cachedBundles.size;
|
|
126
|
+
reportPackagingProgress(completeBundles, bundles.length);
|
|
95
127
|
await Promise.all(bundles.map(async bundle => {
|
|
96
128
|
let request = (0, _PackageRequest.createPackageRequest)({
|
|
97
129
|
bundle,
|
|
@@ -101,6 +133,10 @@ async function run({
|
|
|
101
133
|
useMainThread
|
|
102
134
|
});
|
|
103
135
|
let info = await api.runRequest(request);
|
|
136
|
+
if (!cachedBundles.has(bundle)) {
|
|
137
|
+
completeBundles++;
|
|
138
|
+
reportPackagingProgress(completeBundles, bundles.length);
|
|
139
|
+
}
|
|
104
140
|
if (!useMainThread) {
|
|
105
141
|
// Force a refresh of the cache to avoid a race condition
|
|
106
142
|
// between threaded reads and writes that can result in an LMDB cache miss:
|
|
@@ -114,7 +150,7 @@ async function run({
|
|
|
114
150
|
}
|
|
115
151
|
bundleInfoMap[bundle.id] = info;
|
|
116
152
|
if (!info.hashReferences.length) {
|
|
117
|
-
hashRefToNameHash.set(bundle.hashReference, options.shouldContentHash ? info.hash
|
|
153
|
+
hashRefToNameHash.set(bundle.hashReference, nameHashForFilename(options.shouldContentHash ? info.hash : bundle.id));
|
|
118
154
|
let writeBundleRequest = (0, _WriteBundleRequest.default)({
|
|
119
155
|
bundle,
|
|
120
156
|
info,
|
|
@@ -137,8 +173,26 @@ async function run({
|
|
|
137
173
|
}));
|
|
138
174
|
return promise.then(r => res.set(bundle.id, r));
|
|
139
175
|
}));
|
|
140
|
-
|
|
141
|
-
|
|
176
|
+
let result = {
|
|
177
|
+
bundleInfo: res
|
|
178
|
+
};
|
|
179
|
+
if (_utils().debugTools['scope-hoisting-stats']) {
|
|
180
|
+
// Aggregate scope hoisting stats from all bundles
|
|
181
|
+
let aggregatedScopeHoistingStats = {
|
|
182
|
+
totalAssets: 0,
|
|
183
|
+
wrappedAssets: 0
|
|
184
|
+
};
|
|
185
|
+
for (let bundle of bundles) {
|
|
186
|
+
let bundleInfo = bundleInfoMap[bundle.id];
|
|
187
|
+
if (bundleInfo !== null && bundleInfo !== void 0 && bundleInfo.scopeHoistingStats) {
|
|
188
|
+
aggregatedScopeHoistingStats.totalAssets += bundleInfo.scopeHoistingStats.totalAssets;
|
|
189
|
+
aggregatedScopeHoistingStats.wrappedAssets += bundleInfo.scopeHoistingStats.wrappedAssets;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
result.scopeHoistingStats = aggregatedScopeHoistingStats;
|
|
193
|
+
}
|
|
194
|
+
api.storeResult(result);
|
|
195
|
+
return result;
|
|
142
196
|
} finally {
|
|
143
197
|
await dispose();
|
|
144
198
|
}
|
|
@@ -148,7 +202,7 @@ function assignComplexNameHashes(hashRefToNameHash, bundles, bundleInfoMap, opti
|
|
|
148
202
|
if (hashRefToNameHash.get(bundle.hashReference) != null) {
|
|
149
203
|
continue;
|
|
150
204
|
}
|
|
151
|
-
hashRefToNameHash.set(bundle.hashReference, options.shouldContentHash ? (0, _rust().hashString)([...getBundlesIncludedInHash(bundle.id, bundleInfoMap)].map(bundleId => bundleInfoMap[bundleId].hash).join(':'))
|
|
205
|
+
hashRefToNameHash.set(bundle.hashReference, nameHashForFilename(options.shouldContentHash ? (0, _rust().hashString)([...getBundlesIncludedInHash(bundle.id, bundleInfoMap)].map(bundleId => bundleInfoMap[bundleId].hash).join(':')) : bundle.id));
|
|
152
206
|
}
|
|
153
207
|
}
|
|
154
208
|
function getBundlesIncludedInHash(bundleId, bundleInfoMap, included = new Set()) {
|
|
@@ -14,11 +14,11 @@ function _jestDiff() {
|
|
|
14
14
|
};
|
|
15
15
|
return data;
|
|
16
16
|
}
|
|
17
|
-
var _AssetGraph = _interopRequireDefault(require("../AssetGraph"));
|
|
18
17
|
var _projectPath = require("../projectPath");
|
|
19
|
-
function _interopRequireDefault(
|
|
20
|
-
/* eslint-disable no-console */
|
|
21
|
-
//
|
|
18
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
19
|
+
/* eslint-disable no-console */
|
|
20
|
+
// @ts-expect-error missing types
|
|
21
|
+
|
|
22
22
|
function filterNode(node) {
|
|
23
23
|
let clone = (0, _default().default)(node);
|
|
24
24
|
|
|
@@ -43,6 +43,8 @@ function filterNode(node) {
|
|
|
43
43
|
delete clone.value.dependencies;
|
|
44
44
|
return clone;
|
|
45
45
|
}
|
|
46
|
+
|
|
47
|
+
// @ts-expect-error missing return type
|
|
46
48
|
function compactDeep(obj, ignoredPatterns = [], currentPath = '$') {
|
|
47
49
|
if (obj instanceof Map) {
|
|
48
50
|
const copy = {};
|
|
@@ -53,6 +55,7 @@ function compactDeep(obj, ignoredPatterns = [], currentPath = '$') {
|
|
|
53
55
|
});
|
|
54
56
|
return copy;
|
|
55
57
|
} else if (Array.isArray(obj)) {
|
|
58
|
+
// @ts-expect-error implicit any
|
|
56
59
|
return obj.map(v => compactDeep(v, ignoredPatterns, `${currentPath}[]`));
|
|
57
60
|
} else if (typeof obj === 'object') {
|
|
58
61
|
const copy = {};
|
|
@@ -74,17 +77,19 @@ function compactDeep(obj, ignoredPatterns = [], currentPath = '$') {
|
|
|
74
77
|
return obj;
|
|
75
78
|
}
|
|
76
79
|
}
|
|
77
|
-
function assetGraphDiff(jsAssetGraph, rustAssetGraph) {
|
|
80
|
+
function assetGraphDiff(jsAssetGraph, rustAssetGraph, projectRoot) {
|
|
78
81
|
const getNodes = graph => {
|
|
79
82
|
let nodes = {};
|
|
83
|
+
|
|
84
|
+
// @ts-expect-error implicit any
|
|
80
85
|
graph.traverse(nodeId => {
|
|
81
86
|
let node = graph.getNode(nodeId) ?? null;
|
|
82
87
|
if (!node) return;
|
|
83
88
|
if (node.type === 'dependency') {
|
|
84
|
-
let sourcePath = node.value.sourcePath
|
|
85
|
-
nodes[`dep:${
|
|
89
|
+
let sourcePath = node.value.sourcePath ? (0, _projectPath.toProjectPath)(projectRoot, node.value.sourcePath) : (0, _projectPath.toProjectPath)(projectRoot, 'entry');
|
|
90
|
+
nodes[`dep:${sourcePath}:${node.value.specifier}`] = filterNode(node);
|
|
86
91
|
} else if (node.type === 'asset') {
|
|
87
|
-
nodes[`asset:${(0, _projectPath.
|
|
92
|
+
nodes[`asset:${(0, _projectPath.toProjectPath)(projectRoot, node.value.filePath)}`] = filterNode(node);
|
|
88
93
|
}
|
|
89
94
|
});
|
|
90
95
|
return nodes;
|