@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,602 @@
|
|
|
1
|
+
import assert from 'assert';
|
|
2
|
+
import {Readable} from 'stream';
|
|
3
|
+
import SourceMap from '@atlaspack/source-map';
|
|
4
|
+
import {
|
|
5
|
+
applyReplacementsToSourceMap,
|
|
6
|
+
applyReplacementsToVLQMappings,
|
|
7
|
+
SourceMapHashRefRewriteStream,
|
|
8
|
+
type HashRefReplacement,
|
|
9
|
+
} from '../../src/requests/WriteBundleRequest';
|
|
10
|
+
|
|
11
|
+
const HASH_REF = 'HASH_REF_0123456789abcdef'; // 25 chars
|
|
12
|
+
const HASH_REPLACEMENT = 'a1b2c3d4'; // 8 chars
|
|
13
|
+
const HASH_REF_LEN = HASH_REF.length; // 25
|
|
14
|
+
const REPLACEMENT_LEN = HASH_REPLACEMENT.length; // 8
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Build a single-line code string with HASH_REF placeholders at known positions.
|
|
18
|
+
* Returns original code, replaced code, correct replacement coordinates, and
|
|
19
|
+
* identifier position tracking in both coordinate spaces.
|
|
20
|
+
*/
|
|
21
|
+
function buildCodeWithHashRefs(
|
|
22
|
+
segments: Array<{type: 'code'; text: string} | {type: 'hashref'}>,
|
|
23
|
+
) {
|
|
24
|
+
let code = '';
|
|
25
|
+
const hashPositions: Array<{column: number}> = [];
|
|
26
|
+
const identifierPositions = new Map<string, number>();
|
|
27
|
+
|
|
28
|
+
for (const seg of segments) {
|
|
29
|
+
if (seg.type === 'hashref') {
|
|
30
|
+
hashPositions.push({column: code.length});
|
|
31
|
+
code += HASH_REF;
|
|
32
|
+
} else {
|
|
33
|
+
const regex = /[A-Z][A-Z_0-9]{3,}/g;
|
|
34
|
+
let match;
|
|
35
|
+
while ((match = regex.exec(seg.text)) !== null) {
|
|
36
|
+
identifierPositions.set(match[0], code.length + match.index);
|
|
37
|
+
}
|
|
38
|
+
code += seg.text;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Build replaced code and compute CORRECT replacement coordinates
|
|
43
|
+
let replacedCode = '';
|
|
44
|
+
const correctReplacements: HashRefReplacement[] = [];
|
|
45
|
+
let srcIdx = 0;
|
|
46
|
+
for (const hp of hashPositions) {
|
|
47
|
+
replacedCode += code.slice(srcIdx, hp.column);
|
|
48
|
+
correctReplacements.push({
|
|
49
|
+
line: 0,
|
|
50
|
+
column: replacedCode.length,
|
|
51
|
+
originalLength: HASH_REF_LEN,
|
|
52
|
+
newLength: REPLACEMENT_LEN,
|
|
53
|
+
});
|
|
54
|
+
replacedCode += HASH_REPLACEMENT;
|
|
55
|
+
srcIdx = hp.column + HASH_REF_LEN;
|
|
56
|
+
}
|
|
57
|
+
replacedCode += code.slice(srcIdx);
|
|
58
|
+
|
|
59
|
+
// Track where identifiers end up in the replaced code
|
|
60
|
+
const replacedIdentifierPositions = new Map<string, number>();
|
|
61
|
+
for (const [name] of identifierPositions) {
|
|
62
|
+
const idx = replacedCode.indexOf(name);
|
|
63
|
+
if (idx >= 0) replacedIdentifierPositions.set(name, idx);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return {
|
|
67
|
+
originalCode: code,
|
|
68
|
+
replacedCode,
|
|
69
|
+
correctReplacements,
|
|
70
|
+
identifierPositions,
|
|
71
|
+
replacedIdentifierPositions,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Drains a Readable stream into a single Buffer.
|
|
77
|
+
*/
|
|
78
|
+
function streamToBuffer(stream: Readable): Promise<Buffer> {
|
|
79
|
+
return new Promise((resolve, reject) => {
|
|
80
|
+
const chunks: Buffer[] = [];
|
|
81
|
+
stream.on('data', (chunk: Buffer) => chunks.push(chunk));
|
|
82
|
+
stream.on('end', () => resolve(Buffer.concat(chunks)));
|
|
83
|
+
stream.on('error', reject);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Cross-checks applyReplacementsToVLQMappings against the native
|
|
89
|
+
* applyReplacementsToSourceMap by building a SourceMap, running both
|
|
90
|
+
* implementations, and asserting identical VLQ output.
|
|
91
|
+
*/
|
|
92
|
+
function crossCheck(sm: SourceMap, replacements: HashRefReplacement[]): void {
|
|
93
|
+
const vlqBefore = sm.toVLQ().mappings;
|
|
94
|
+
const vlqResult = applyReplacementsToVLQMappings(vlqBefore, replacements);
|
|
95
|
+
applyReplacementsToSourceMap(sm, replacements);
|
|
96
|
+
const nativeResult = sm.toVLQ().mappings;
|
|
97
|
+
assert.strictEqual(
|
|
98
|
+
vlqResult,
|
|
99
|
+
nativeResult,
|
|
100
|
+
`VLQ result differs from native:\n VLQ: ${vlqResult}\n native: ${nativeResult}`,
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
describe('applyReplacementsToSourceMap', () => {
|
|
105
|
+
describe('with correct replacement coordinates', () => {
|
|
106
|
+
it('should correctly adjust a single HASH_REF replacement', () => {
|
|
107
|
+
const {
|
|
108
|
+
correctReplacements,
|
|
109
|
+
identifierPositions,
|
|
110
|
+
replacedIdentifierPositions,
|
|
111
|
+
} = buildCodeWithHashRefs([
|
|
112
|
+
{type: 'hashref'},
|
|
113
|
+
{type: 'code', text: ';var x=SOME_IDENT;'},
|
|
114
|
+
]);
|
|
115
|
+
|
|
116
|
+
const origCol = identifierPositions.get('SOME_IDENT')!;
|
|
117
|
+
const expectedCol = replacedIdentifierPositions.get('SOME_IDENT')!;
|
|
118
|
+
|
|
119
|
+
const sm = new SourceMap('/');
|
|
120
|
+
sm.addIndexedMapping({
|
|
121
|
+
generated: {line: 1, column: origCol},
|
|
122
|
+
original: {line: 10, column: 5},
|
|
123
|
+
source: 'test.js',
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
applyReplacementsToSourceMap(sm, correctReplacements);
|
|
127
|
+
|
|
128
|
+
const mappings = sm.getMap().mappings;
|
|
129
|
+
const mapping = mappings.find(
|
|
130
|
+
(m) => m.original?.line === 10 && m.original?.column === 5,
|
|
131
|
+
);
|
|
132
|
+
assert.ok(mapping, 'Mapping should exist');
|
|
133
|
+
assert.strictEqual(mapping!.generated.column, expectedCol);
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it('should correctly adjust multiple HASH_REF replacements on the same line', () => {
|
|
137
|
+
const {
|
|
138
|
+
correctReplacements,
|
|
139
|
+
identifierPositions,
|
|
140
|
+
replacedIdentifierPositions,
|
|
141
|
+
} = buildCodeWithHashRefs([
|
|
142
|
+
{type: 'hashref'},
|
|
143
|
+
{type: 'code', text: ';var a=IDENT_ALPHA;require("'},
|
|
144
|
+
{type: 'hashref'},
|
|
145
|
+
{type: 'code', text: '");var b=IDENT_BETA;require("'},
|
|
146
|
+
{type: 'hashref'},
|
|
147
|
+
{type: 'code', text: '");var c=IDENT_GAMMA;'},
|
|
148
|
+
]);
|
|
149
|
+
|
|
150
|
+
const sm = new SourceMap('/');
|
|
151
|
+
sm.addIndexedMapping({
|
|
152
|
+
generated: {line: 1, column: identifierPositions.get('IDENT_ALPHA')!},
|
|
153
|
+
original: {line: 10, column: 0},
|
|
154
|
+
source: 'test.js',
|
|
155
|
+
});
|
|
156
|
+
sm.addIndexedMapping({
|
|
157
|
+
generated: {line: 1, column: identifierPositions.get('IDENT_BETA')!},
|
|
158
|
+
original: {line: 20, column: 0},
|
|
159
|
+
source: 'test.js',
|
|
160
|
+
});
|
|
161
|
+
sm.addIndexedMapping({
|
|
162
|
+
generated: {line: 1, column: identifierPositions.get('IDENT_GAMMA')!},
|
|
163
|
+
original: {line: 30, column: 0},
|
|
164
|
+
source: 'test.js',
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
applyReplacementsToSourceMap(sm, correctReplacements);
|
|
168
|
+
|
|
169
|
+
const mappings = sm.getMap().mappings;
|
|
170
|
+
for (const [name, origLine] of [
|
|
171
|
+
['IDENT_ALPHA', 10],
|
|
172
|
+
['IDENT_BETA', 20],
|
|
173
|
+
['IDENT_GAMMA', 30],
|
|
174
|
+
] as const) {
|
|
175
|
+
const mapping = mappings.find((m) => m.original?.line === origLine);
|
|
176
|
+
const expectedCol = replacedIdentifierPositions.get(name)!;
|
|
177
|
+
assert.ok(mapping, `${name} mapping should exist`);
|
|
178
|
+
assert.strictEqual(
|
|
179
|
+
mapping!.generated.column,
|
|
180
|
+
expectedCol,
|
|
181
|
+
`${name}: expected col ${expectedCol}, got ${mapping!.generated.column}`,
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
it('should handle 10 replacements on the same line', () => {
|
|
187
|
+
const segments: Array<{type: 'code'; text: string} | {type: 'hashref'}> =
|
|
188
|
+
[];
|
|
189
|
+
for (let i = 0; i < 10; i++) {
|
|
190
|
+
segments.push({type: 'hashref'});
|
|
191
|
+
segments.push({
|
|
192
|
+
type: 'code',
|
|
193
|
+
text: `;var x${i}=TARGET_${String(i).padStart(2, '0')};require("`,
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
segments.push({type: 'code', text: '");'});
|
|
197
|
+
|
|
198
|
+
const {
|
|
199
|
+
correctReplacements,
|
|
200
|
+
identifierPositions,
|
|
201
|
+
replacedIdentifierPositions,
|
|
202
|
+
} = buildCodeWithHashRefs(segments);
|
|
203
|
+
|
|
204
|
+
const sm = new SourceMap('/');
|
|
205
|
+
for (let i = 0; i < 10; i++) {
|
|
206
|
+
const name = `TARGET_${String(i).padStart(2, '0')}`;
|
|
207
|
+
sm.addIndexedMapping({
|
|
208
|
+
generated: {line: 1, column: identifierPositions.get(name)!},
|
|
209
|
+
original: {line: (i + 1) * 10, column: 0},
|
|
210
|
+
source: 'test.js',
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
applyReplacementsToSourceMap(sm, correctReplacements);
|
|
215
|
+
|
|
216
|
+
const mappings = sm.getMap().mappings;
|
|
217
|
+
for (let i = 0; i < 10; i++) {
|
|
218
|
+
const name = `TARGET_${String(i).padStart(2, '0')}`;
|
|
219
|
+
const mapping = mappings.find((m) => m.original?.line === (i + 1) * 10);
|
|
220
|
+
const expectedCol = replacedIdentifierPositions.get(name)!;
|
|
221
|
+
assert.ok(mapping, `${name} mapping should exist`);
|
|
222
|
+
assert.strictEqual(
|
|
223
|
+
mapping!.generated.column,
|
|
224
|
+
expectedCol,
|
|
225
|
+
`${name}: expected col ${expectedCol}, got ${mapping!.generated.column}`,
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
it('should not affect mappings before the first HASH_REF', () => {
|
|
231
|
+
const {
|
|
232
|
+
correctReplacements,
|
|
233
|
+
identifierPositions,
|
|
234
|
+
replacedIdentifierPositions,
|
|
235
|
+
} = buildCodeWithHashRefs([
|
|
236
|
+
{type: 'code', text: 'var BEFORE_HASH=1;'},
|
|
237
|
+
{type: 'hashref'},
|
|
238
|
+
{type: 'code', text: ';var AFTER_HASH=2;'},
|
|
239
|
+
]);
|
|
240
|
+
|
|
241
|
+
const sm = new SourceMap('/');
|
|
242
|
+
sm.addIndexedMapping({
|
|
243
|
+
generated: {line: 1, column: identifierPositions.get('BEFORE_HASH')!},
|
|
244
|
+
original: {line: 1, column: 0},
|
|
245
|
+
source: 'test.js',
|
|
246
|
+
});
|
|
247
|
+
sm.addIndexedMapping({
|
|
248
|
+
generated: {line: 1, column: identifierPositions.get('AFTER_HASH')!},
|
|
249
|
+
original: {line: 2, column: 0},
|
|
250
|
+
source: 'test.js',
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
applyReplacementsToSourceMap(sm, correctReplacements);
|
|
254
|
+
|
|
255
|
+
const mappings = sm.getMap().mappings;
|
|
256
|
+
const beforeMapping = mappings.find((m) => m.original?.line === 1);
|
|
257
|
+
assert.ok(beforeMapping);
|
|
258
|
+
assert.strictEqual(
|
|
259
|
+
beforeMapping!.generated.column,
|
|
260
|
+
replacedIdentifierPositions.get('BEFORE_HASH'),
|
|
261
|
+
);
|
|
262
|
+
|
|
263
|
+
const afterMapping = mappings.find((m) => m.original?.line === 2);
|
|
264
|
+
assert.ok(afterMapping);
|
|
265
|
+
assert.strictEqual(
|
|
266
|
+
afterMapping!.generated.column,
|
|
267
|
+
replacedIdentifierPositions.get('AFTER_HASH'),
|
|
268
|
+
);
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
describe('applyReplacementsToVLQMappings', () => {
|
|
274
|
+
it('returns the same string for empty replacements', () => {
|
|
275
|
+
const sm = new SourceMap('/');
|
|
276
|
+
sm.addIndexedMapping({
|
|
277
|
+
generated: {line: 1, column: 10},
|
|
278
|
+
original: {line: 1, column: 0},
|
|
279
|
+
source: 'test.js',
|
|
280
|
+
});
|
|
281
|
+
const vlq = sm.toVLQ().mappings;
|
|
282
|
+
assert.strictEqual(applyReplacementsToVLQMappings(vlq, []), vlq);
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
it('returns the same string for a zero-delta replacement', () => {
|
|
286
|
+
const sm = new SourceMap('/');
|
|
287
|
+
sm.addIndexedMapping({
|
|
288
|
+
generated: {line: 1, column: 30},
|
|
289
|
+
original: {line: 1, column: 0},
|
|
290
|
+
source: 'test.js',
|
|
291
|
+
});
|
|
292
|
+
const vlq = sm.toVLQ().mappings;
|
|
293
|
+
const repl: HashRefReplacement[] = [
|
|
294
|
+
{line: 0, column: 0, originalLength: 10, newLength: 10},
|
|
295
|
+
];
|
|
296
|
+
assert.strictEqual(applyReplacementsToVLQMappings(vlq, repl), vlq);
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
it('single replacement agrees with native', () => {
|
|
300
|
+
const {correctReplacements, identifierPositions} = buildCodeWithHashRefs([
|
|
301
|
+
{type: 'hashref'},
|
|
302
|
+
{type: 'code', text: ';var x=SOME_IDENT;'},
|
|
303
|
+
]);
|
|
304
|
+
const sm = new SourceMap('/');
|
|
305
|
+
sm.addIndexedMapping({
|
|
306
|
+
generated: {line: 1, column: identifierPositions.get('SOME_IDENT')!},
|
|
307
|
+
original: {line: 10, column: 5},
|
|
308
|
+
source: 'test.js',
|
|
309
|
+
});
|
|
310
|
+
crossCheck(sm, correctReplacements);
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
it('multiple replacements on the same line agree with native', () => {
|
|
314
|
+
const {correctReplacements, identifierPositions} = buildCodeWithHashRefs([
|
|
315
|
+
{type: 'hashref'},
|
|
316
|
+
{type: 'code', text: ';var a=IDENT_ALPHA;require("'},
|
|
317
|
+
{type: 'hashref'},
|
|
318
|
+
{type: 'code', text: '");var b=IDENT_BETA;require("'},
|
|
319
|
+
{type: 'hashref'},
|
|
320
|
+
{type: 'code', text: '");var c=IDENT_GAMMA;'},
|
|
321
|
+
]);
|
|
322
|
+
const sm = new SourceMap('/');
|
|
323
|
+
for (const [name, origLine] of [
|
|
324
|
+
['IDENT_ALPHA', 10],
|
|
325
|
+
['IDENT_BETA', 20],
|
|
326
|
+
['IDENT_GAMMA', 30],
|
|
327
|
+
] as const) {
|
|
328
|
+
sm.addIndexedMapping({
|
|
329
|
+
generated: {line: 1, column: identifierPositions.get(name)!},
|
|
330
|
+
original: {line: origLine, column: 0},
|
|
331
|
+
source: 'test.js',
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
crossCheck(sm, correctReplacements);
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
it('10 replacements on the same line agree with native', () => {
|
|
338
|
+
const segments: Array<{type: 'code'; text: string} | {type: 'hashref'}> =
|
|
339
|
+
[];
|
|
340
|
+
for (let i = 0; i < 10; i++) {
|
|
341
|
+
segments.push({type: 'hashref'});
|
|
342
|
+
segments.push({
|
|
343
|
+
type: 'code',
|
|
344
|
+
text: `;var x${i}=TARGET_${String(i).padStart(2, '0')};require("`,
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
segments.push({type: 'code', text: '");'});
|
|
348
|
+
|
|
349
|
+
const {correctReplacements, identifierPositions} =
|
|
350
|
+
buildCodeWithHashRefs(segments);
|
|
351
|
+
|
|
352
|
+
const sm = new SourceMap('/');
|
|
353
|
+
for (let i = 0; i < 10; i++) {
|
|
354
|
+
const name = `TARGET_${String(i).padStart(2, '0')}`;
|
|
355
|
+
sm.addIndexedMapping({
|
|
356
|
+
generated: {line: 1, column: identifierPositions.get(name)!},
|
|
357
|
+
original: {line: (i + 1) * 10, column: 0},
|
|
358
|
+
source: 'test.js',
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
crossCheck(sm, correctReplacements);
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
it('mapping before the threshold is unaffected', () => {
|
|
365
|
+
const {correctReplacements, identifierPositions} = buildCodeWithHashRefs([
|
|
366
|
+
{type: 'code', text: 'var BEFORE_HASH=1;'},
|
|
367
|
+
{type: 'hashref'},
|
|
368
|
+
{type: 'code', text: ';var AFTER_HASH=2;'},
|
|
369
|
+
]);
|
|
370
|
+
const sm = new SourceMap('/');
|
|
371
|
+
sm.addIndexedMapping({
|
|
372
|
+
generated: {line: 1, column: identifierPositions.get('BEFORE_HASH')!},
|
|
373
|
+
original: {line: 1, column: 0},
|
|
374
|
+
source: 'test.js',
|
|
375
|
+
});
|
|
376
|
+
sm.addIndexedMapping({
|
|
377
|
+
generated: {line: 1, column: identifierPositions.get('AFTER_HASH')!},
|
|
378
|
+
original: {line: 2, column: 0},
|
|
379
|
+
source: 'test.js',
|
|
380
|
+
});
|
|
381
|
+
crossCheck(sm, correctReplacements);
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
it('mapping on a different line is unaffected', () => {
|
|
385
|
+
const sm = new SourceMap('/');
|
|
386
|
+
// Line 0 (VLQ line index 0): hash ref at col 0, mapping at col 50
|
|
387
|
+
// Line 1 (VLQ line index 1): mapping at col 5 – should be untouched
|
|
388
|
+
sm.addIndexedMapping({
|
|
389
|
+
generated: {line: 1, column: 50},
|
|
390
|
+
original: {line: 10, column: 0},
|
|
391
|
+
source: 'test.js',
|
|
392
|
+
});
|
|
393
|
+
sm.addIndexedMapping({
|
|
394
|
+
generated: {line: 2, column: 5},
|
|
395
|
+
original: {line: 20, column: 0},
|
|
396
|
+
source: 'test.js',
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
const replacements: HashRefReplacement[] = [
|
|
400
|
+
{
|
|
401
|
+
line: 0,
|
|
402
|
+
column: 0,
|
|
403
|
+
originalLength: HASH_REF_LEN,
|
|
404
|
+
newLength: REPLACEMENT_LEN,
|
|
405
|
+
},
|
|
406
|
+
];
|
|
407
|
+
|
|
408
|
+
const vlqBefore = sm.toVLQ().mappings;
|
|
409
|
+
const vlqResult = applyReplacementsToVLQMappings(vlqBefore, replacements);
|
|
410
|
+
applyReplacementsToSourceMap(sm, replacements);
|
|
411
|
+
|
|
412
|
+
// Verify the line-1 mapping is unchanged by checking parsed values
|
|
413
|
+
const mappings = sm.getMap().mappings;
|
|
414
|
+
const line2Mapping = mappings.find((m) => m.original?.line === 20);
|
|
415
|
+
assert.ok(line2Mapping, 'Line 2 mapping should exist');
|
|
416
|
+
assert.strictEqual(line2Mapping!.generated.column, 5);
|
|
417
|
+
|
|
418
|
+
// Also verify VLQ agrees with native
|
|
419
|
+
assert.strictEqual(vlqResult, sm.toVLQ().mappings);
|
|
420
|
+
});
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
describe('SourceMapHashRefRewriteStream', () => {
|
|
424
|
+
async function applyStream(
|
|
425
|
+
json: string,
|
|
426
|
+
replacements: HashRefReplacement[],
|
|
427
|
+
chunkSize?: number,
|
|
428
|
+
): Promise<string> {
|
|
429
|
+
const inputBuf = Buffer.from(json, 'utf8');
|
|
430
|
+
let readable: Readable;
|
|
431
|
+
if (chunkSize != null) {
|
|
432
|
+
readable = new Readable({
|
|
433
|
+
read() {
|
|
434
|
+
let offset = 0;
|
|
435
|
+
while (offset < inputBuf.length) {
|
|
436
|
+
this.push(inputBuf.slice(offset, offset + chunkSize));
|
|
437
|
+
offset += chunkSize;
|
|
438
|
+
}
|
|
439
|
+
this.push(null);
|
|
440
|
+
},
|
|
441
|
+
});
|
|
442
|
+
} else {
|
|
443
|
+
readable = Readable.from([inputBuf]);
|
|
444
|
+
}
|
|
445
|
+
const outBuf = await streamToBuffer(
|
|
446
|
+
readable.pipe(new SourceMapHashRefRewriteStream(replacements)),
|
|
447
|
+
);
|
|
448
|
+
return outBuf.toString('utf8');
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
it('full round-trip: mappings field is correctly rewritten', async () => {
|
|
452
|
+
const {correctReplacements, identifierPositions} = buildCodeWithHashRefs([
|
|
453
|
+
{type: 'hashref'},
|
|
454
|
+
{type: 'code', text: ';var x=SOME_IDENT;'},
|
|
455
|
+
]);
|
|
456
|
+
|
|
457
|
+
const sm = new SourceMap('/');
|
|
458
|
+
sm.addIndexedMapping({
|
|
459
|
+
generated: {line: 1, column: identifierPositions.get('SOME_IDENT')!},
|
|
460
|
+
original: {line: 10, column: 5},
|
|
461
|
+
source: 'test.js',
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
const vlqBefore = sm.toVLQ().mappings;
|
|
465
|
+
const expectedMappings = applyReplacementsToVLQMappings(
|
|
466
|
+
vlqBefore,
|
|
467
|
+
correctReplacements,
|
|
468
|
+
);
|
|
469
|
+
|
|
470
|
+
const mapJson = await sm.stringify({format: 'string'});
|
|
471
|
+
const outputJson = await applyStream(
|
|
472
|
+
mapJson as string,
|
|
473
|
+
correctReplacements,
|
|
474
|
+
);
|
|
475
|
+
const parsed = JSON.parse(outputJson);
|
|
476
|
+
|
|
477
|
+
assert.strictEqual(parsed.mappings, expectedMappings);
|
|
478
|
+
});
|
|
479
|
+
|
|
480
|
+
it('bytes after mappings (sourcesContent) pass through unchanged', async () => {
|
|
481
|
+
const sm = new SourceMap('/');
|
|
482
|
+
sm.addIndexedMapping({
|
|
483
|
+
generated: {line: 1, column: 30},
|
|
484
|
+
original: {line: 5, column: 0},
|
|
485
|
+
source: 'test.js',
|
|
486
|
+
});
|
|
487
|
+
sm.setSourceContent('test.js', 'const x = 1;\nconst y = 2;\n');
|
|
488
|
+
|
|
489
|
+
const replacements: HashRefReplacement[] = [
|
|
490
|
+
{
|
|
491
|
+
line: 0,
|
|
492
|
+
column: 0,
|
|
493
|
+
originalLength: HASH_REF_LEN,
|
|
494
|
+
newLength: REPLACEMENT_LEN,
|
|
495
|
+
},
|
|
496
|
+
];
|
|
497
|
+
|
|
498
|
+
const mapJson = (await sm.stringify({format: 'string'})) as string;
|
|
499
|
+
const outputJson = await applyStream(mapJson, replacements);
|
|
500
|
+
const parsedInput = JSON.parse(mapJson);
|
|
501
|
+
const parsedOutput = JSON.parse(outputJson);
|
|
502
|
+
|
|
503
|
+
// sourcesContent must be byte-for-byte identical
|
|
504
|
+
assert.deepStrictEqual(
|
|
505
|
+
parsedOutput.sourcesContent,
|
|
506
|
+
parsedInput.sourcesContent,
|
|
507
|
+
);
|
|
508
|
+
assert.deepStrictEqual(parsedOutput.sources, parsedInput.sources);
|
|
509
|
+
assert.deepStrictEqual(parsedOutput.names, parsedInput.names);
|
|
510
|
+
});
|
|
511
|
+
|
|
512
|
+
it('handles chunk boundaries mid-key', async () => {
|
|
513
|
+
const {correctReplacements, identifierPositions} = buildCodeWithHashRefs([
|
|
514
|
+
{type: 'hashref'},
|
|
515
|
+
{type: 'code', text: ';var x=SOME_IDENT;'},
|
|
516
|
+
]);
|
|
517
|
+
|
|
518
|
+
const sm = new SourceMap('/');
|
|
519
|
+
sm.addIndexedMapping({
|
|
520
|
+
generated: {line: 1, column: identifierPositions.get('SOME_IDENT')!},
|
|
521
|
+
original: {line: 10, column: 5},
|
|
522
|
+
source: 'test.js',
|
|
523
|
+
});
|
|
524
|
+
|
|
525
|
+
const vlqBefore = sm.toVLQ().mappings;
|
|
526
|
+
const expectedMappings = applyReplacementsToVLQMappings(
|
|
527
|
+
vlqBefore,
|
|
528
|
+
correctReplacements,
|
|
529
|
+
);
|
|
530
|
+
|
|
531
|
+
const mapJson = (await sm.stringify({format: 'string'})) as string;
|
|
532
|
+
|
|
533
|
+
// Test multiple chunk sizes to exercise boundary conditions.
|
|
534
|
+
for (const chunkSize of [1, 3, 7, 11, 13]) {
|
|
535
|
+
const outputJson = await applyStream(
|
|
536
|
+
mapJson,
|
|
537
|
+
correctReplacements,
|
|
538
|
+
chunkSize,
|
|
539
|
+
);
|
|
540
|
+
const parsed = JSON.parse(outputJson);
|
|
541
|
+
assert.strictEqual(
|
|
542
|
+
parsed.mappings,
|
|
543
|
+
expectedMappings,
|
|
544
|
+
`Chunk size ${chunkSize}: mappings mismatch`,
|
|
545
|
+
);
|
|
546
|
+
}
|
|
547
|
+
});
|
|
548
|
+
|
|
549
|
+
it('handles chunk boundaries mid-value', async () => {
|
|
550
|
+
// Use a source map with a longer mappings string to ensure the VLQ value
|
|
551
|
+
// spans multiple chunks for small chunk sizes.
|
|
552
|
+
const sm = new SourceMap('/');
|
|
553
|
+
for (let i = 0; i < 20; i++) {
|
|
554
|
+
sm.addIndexedMapping({
|
|
555
|
+
generated: {line: 1, column: i * 5},
|
|
556
|
+
original: {line: i + 1, column: 0},
|
|
557
|
+
source: 'test.js',
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
const replacements: HashRefReplacement[] = [
|
|
562
|
+
{
|
|
563
|
+
line: 0,
|
|
564
|
+
column: 10,
|
|
565
|
+
originalLength: HASH_REF_LEN,
|
|
566
|
+
newLength: REPLACEMENT_LEN,
|
|
567
|
+
},
|
|
568
|
+
];
|
|
569
|
+
|
|
570
|
+
const vlqBefore = sm.toVLQ().mappings;
|
|
571
|
+
const expectedMappings = applyReplacementsToVLQMappings(
|
|
572
|
+
vlqBefore,
|
|
573
|
+
replacements,
|
|
574
|
+
);
|
|
575
|
+
|
|
576
|
+
const mapJson = (await sm.stringify({format: 'string'})) as string;
|
|
577
|
+
|
|
578
|
+
for (const chunkSize of [1, 5, 8]) {
|
|
579
|
+
const outputJson = await applyStream(mapJson, replacements, chunkSize);
|
|
580
|
+
const parsed = JSON.parse(outputJson);
|
|
581
|
+
assert.strictEqual(
|
|
582
|
+
parsed.mappings,
|
|
583
|
+
expectedMappings,
|
|
584
|
+
`Chunk size ${chunkSize}: mappings mismatch`,
|
|
585
|
+
);
|
|
586
|
+
}
|
|
587
|
+
});
|
|
588
|
+
|
|
589
|
+
it('no-op for empty replacements – output equals input', async () => {
|
|
590
|
+
const sm = new SourceMap('/');
|
|
591
|
+
sm.addIndexedMapping({
|
|
592
|
+
generated: {line: 1, column: 10},
|
|
593
|
+
original: {line: 1, column: 0},
|
|
594
|
+
source: 'test.js',
|
|
595
|
+
});
|
|
596
|
+
|
|
597
|
+
const mapJson = (await sm.stringify({format: 'string'})) as string;
|
|
598
|
+
const outputJson = await applyStream(mapJson, []);
|
|
599
|
+
|
|
600
|
+
assert.strictEqual(outputJson, mapJson);
|
|
601
|
+
});
|
|
602
|
+
});
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import type {Environment, AtlaspackOptions, Target} from '../src/types';
|
|
1
|
+
import type {AtlaspackOptions, Target} from '../src/types';
|
|
4
2
|
|
|
5
3
|
import {DEFAULT_FEATURE_FLAGS} from '@atlaspack/feature-flags';
|
|
6
4
|
import {inputFS, outputFS, cache, cacheDir} from '@atlaspack/test-utils';
|
|
@@ -8,6 +6,7 @@ import {relativePath} from '@atlaspack/utils';
|
|
|
8
6
|
import {NodePackageManager} from '@atlaspack/package-manager';
|
|
9
7
|
import {createEnvironment} from '../src/Environment';
|
|
10
8
|
import {toProjectPath} from '../src/projectPath';
|
|
9
|
+
import type {EnvironmentRef} from '../src/EnvironmentManager';
|
|
11
10
|
|
|
12
11
|
export const DEFAULT_OPTIONS: AtlaspackOptions = {
|
|
13
12
|
cacheDir,
|
|
@@ -51,7 +50,7 @@ export const DEFAULT_OPTIONS: AtlaspackOptions = {
|
|
|
51
50
|
},
|
|
52
51
|
};
|
|
53
52
|
|
|
54
|
-
export const DEFAULT_ENV:
|
|
53
|
+
export const DEFAULT_ENV: EnvironmentRef = createEnvironment({
|
|
55
54
|
context: 'browser',
|
|
56
55
|
engines: {
|
|
57
56
|
browsers: ['> 1%'],
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// @flow strict-local
|
|
2
|
-
|
|
3
1
|
import assert from 'assert';
|
|
4
2
|
import {getPublicId} from '../src/utils';
|
|
5
3
|
|
|
@@ -28,7 +26,7 @@ describe('getPublicId', () => {
|
|
|
28
26
|
|
|
29
27
|
it('uses more characters if there is a collision', () => {
|
|
30
28
|
assert.equal(
|
|
31
|
-
getPublicId(id, (publicId) =>
|
|
29
|
+
getPublicId(id, (publicId: any) =>
|
|
32
30
|
[fullPublicId.slice(0, 5), fullPublicId.slice(0, 6)].includes(publicId),
|
|
33
31
|
),
|
|
34
32
|
fullPublicId.slice(0, 7),
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../../tsconfig.base.json",
|
|
3
|
+
"include": ["./src/", "./package.json"],
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"composite": true
|
|
6
|
+
},
|
|
7
|
+
"references": [
|
|
8
|
+
{
|
|
9
|
+
"path": "../../dev/babel-register/tsconfig.json"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"path": "../../utils/events/tsconfig.json"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"path": "../build-cache/tsconfig.json"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"path": "../cache/tsconfig.json"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"path": "../diagnostic/tsconfig.json"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"path": "../feature-flags/tsconfig.json"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"path": "../fs/tsconfig.json"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"path": "../graph/tsconfig.json"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"path": "../logger/tsconfig.json"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"path": "../package-manager/tsconfig.json"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"path": "../plugin/tsconfig.json"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"path": "../profiler/tsconfig.json"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"path": "../rust/tsconfig.json"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"path": "../types/tsconfig.json"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"path": "../utils/tsconfig.json"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"path": "../workers/tsconfig.json"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"path": "../source-map/tsconfig.json"
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
}
|