@atlaspack/core 2.16.2-canary.5 → 2.16.2-canary.500
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 +1452 -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 +160 -57
- 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 +38 -40
- package/lib/ReporterRunner.js +8 -12
- package/lib/RequestTracker.js +336 -168
- package/lib/SymbolPropagation.js +52 -29
- package/lib/TargetDescriptor.schema.js +10 -1
- package/lib/Transformation.js +68 -19
- package/lib/UncommittedAsset.js +23 -13
- 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 +239 -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 +25 -7
- 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 +60 -27
- 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 +67 -124
- 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 +336 -18
- 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 +35 -10
- 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 +27 -33
- package/src/{AssetGraph.js → AssetGraph.ts} +87 -51
- package/src/{Atlaspack.js → Atlaspack.ts} +203 -73
- 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} +109 -103
- package/src/{ReporterRunner.js → ReporterRunner.ts} +13 -18
- package/src/{RequestTracker.js → RequestTracker.ts} +672 -347
- 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} +50 -39
- 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} +102 -50
- package/src/public/{BundleGroup.js → BundleGroup.ts} +7 -10
- package/src/public/{Config.js → Config.ts} +171 -33
- package/src/public/{Dependency.js → Dependency.ts} +20 -17
- package/src/public/{Environment.js → Environment.ts} +28 -17
- package/src/public/{MutableBundleGraph.js → MutableBundleGraph.ts} +55 -24
- package/src/public/{PluginOptions.js → PluginOptions.ts} +6 -6
- package/src/public/{Symbols.js → Symbols.ts} +75 -36
- package/src/public/{Target.js → Target.ts} +10 -8
- package/src/{registerCoreWithSerializer.js → registerCoreWithSerializer.ts} +9 -7
- package/src/requests/{AssetGraphRequest.js → AssetGraphRequest.ts} +114 -77
- 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} +117 -187
- 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} +55 -23
- 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} +149 -59
- 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} +4 -11
- 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 -362
- 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 -362
- 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
package/dist/worker.js
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.clearWorkerBuildCaches = clearWorkerBuildCaches;
|
|
7
|
+
exports.runTransform = runTransform;
|
|
8
|
+
exports.runValidate = runValidate;
|
|
9
|
+
exports.runPackage = runPackage;
|
|
10
|
+
exports.childInit = childInit;
|
|
11
|
+
exports.invalidateRequireCache = invalidateRequireCache;
|
|
12
|
+
exports.ping = ping;
|
|
13
|
+
const utils_1 = require("@atlaspack/utils");
|
|
14
|
+
const assert_1 = __importDefault(require("assert"));
|
|
15
|
+
const nullthrows_1 = __importDefault(require("nullthrows"));
|
|
16
|
+
const BundleGraph_1 = __importDefault(require("./BundleGraph"));
|
|
17
|
+
const Transformation_1 = __importDefault(require("./Transformation"));
|
|
18
|
+
const ReporterRunner_1 = require("./ReporterRunner");
|
|
19
|
+
const PackagerRunner_1 = __importDefault(require("./PackagerRunner"));
|
|
20
|
+
const Validation_1 = __importDefault(require("./Validation"));
|
|
21
|
+
const AtlaspackConfig_1 = require("./AtlaspackConfig");
|
|
22
|
+
const registerCoreWithSerializer_1 = require("./registerCoreWithSerializer");
|
|
23
|
+
const build_cache_1 = require("@atlaspack/build-cache");
|
|
24
|
+
const source_map_1 = require("@atlaspack/source-map");
|
|
25
|
+
// @ts-expect-error TS2305
|
|
26
|
+
const rust_1 = require("@atlaspack/rust");
|
|
27
|
+
const workers_1 = __importDefault(require("@atlaspack/workers"));
|
|
28
|
+
const feature_flags_1 = require("@atlaspack/feature-flags");
|
|
29
|
+
require("@atlaspack/cache"); // register with serializer
|
|
30
|
+
require("@atlaspack/package-manager");
|
|
31
|
+
require("@atlaspack/fs");
|
|
32
|
+
// /flow-to-ts helpers
|
|
33
|
+
(0, registerCoreWithSerializer_1.registerCoreWithSerializer)();
|
|
34
|
+
// TODO: this should eventually be replaced by an in memory cache layer
|
|
35
|
+
let atlaspackConfigCache = new Map();
|
|
36
|
+
function loadOptions(ref, workerApi) {
|
|
37
|
+
return (0, nullthrows_1.default)(workerApi.getSharedReference(ref));
|
|
38
|
+
}
|
|
39
|
+
async function loadConfig(cachePath, options) {
|
|
40
|
+
let config = atlaspackConfigCache.get(cachePath);
|
|
41
|
+
if (config && config.options === options) {
|
|
42
|
+
return config;
|
|
43
|
+
}
|
|
44
|
+
let processedConfig = (0, nullthrows_1.default)(await options.cache.get(cachePath));
|
|
45
|
+
config = new AtlaspackConfig_1.AtlaspackConfig(processedConfig, options);
|
|
46
|
+
atlaspackConfigCache.set(cachePath, config);
|
|
47
|
+
(0, feature_flags_1.setFeatureFlags)(options.featureFlags);
|
|
48
|
+
return config;
|
|
49
|
+
}
|
|
50
|
+
function clearWorkerBuildCaches() {
|
|
51
|
+
utils_1.loadConfig.clear();
|
|
52
|
+
(0, build_cache_1.clearBuildCaches)();
|
|
53
|
+
}
|
|
54
|
+
async function runTransform(workerApi, opts) {
|
|
55
|
+
let { optionsRef, configCachePath, ...rest } = opts;
|
|
56
|
+
let options = loadOptions(optionsRef, workerApi);
|
|
57
|
+
let config = await loadConfig(configCachePath, options);
|
|
58
|
+
return new Transformation_1.default({
|
|
59
|
+
workerApi,
|
|
60
|
+
options,
|
|
61
|
+
// @ts-expect-error TS2783
|
|
62
|
+
config,
|
|
63
|
+
...rest,
|
|
64
|
+
}).run();
|
|
65
|
+
}
|
|
66
|
+
async function runValidate(workerApi, opts) {
|
|
67
|
+
let { optionsRef, configCachePath, ...rest } = opts;
|
|
68
|
+
let options = loadOptions(optionsRef, workerApi);
|
|
69
|
+
let config = await loadConfig(configCachePath, options);
|
|
70
|
+
return new Validation_1.default({
|
|
71
|
+
workerApi,
|
|
72
|
+
// @ts-expect-error TS2783
|
|
73
|
+
report: ReporterRunner_1.reportWorker.bind(null, workerApi),
|
|
74
|
+
options,
|
|
75
|
+
// @ts-expect-error TS2783
|
|
76
|
+
config,
|
|
77
|
+
...rest,
|
|
78
|
+
}).run();
|
|
79
|
+
}
|
|
80
|
+
async function runPackage(workerApi, { bundle, bundleGraphReference, configCachePath, optionsRef, previousDevDeps, invalidDevDeps, previousInvalidations, }) {
|
|
81
|
+
let bundleGraph = workerApi.getSharedReference(bundleGraphReference);
|
|
82
|
+
(0, assert_1.default)(bundleGraph instanceof BundleGraph_1.default);
|
|
83
|
+
let options = loadOptions(optionsRef, workerApi);
|
|
84
|
+
let atlaspackConfig = await loadConfig(configCachePath, options);
|
|
85
|
+
let runner = new PackagerRunner_1.default({
|
|
86
|
+
config: atlaspackConfig,
|
|
87
|
+
options,
|
|
88
|
+
// @ts-expect-error TS2322
|
|
89
|
+
report: workers_1.default.isWorker() ? ReporterRunner_1.reportWorker.bind(null, workerApi) : ReporterRunner_1.report,
|
|
90
|
+
previousDevDeps,
|
|
91
|
+
previousInvalidations,
|
|
92
|
+
});
|
|
93
|
+
return runner.run(bundleGraph, bundle, invalidDevDeps);
|
|
94
|
+
}
|
|
95
|
+
async function childInit() {
|
|
96
|
+
await source_map_1.init;
|
|
97
|
+
await (0, rust_1.init)?.();
|
|
98
|
+
}
|
|
99
|
+
const PKG_RE = /node_modules[/\\]((?:@[^/\\]+[/\\][^/\\]+)|[^/\\]+)(?!.*[/\\]node_modules[/\\])/;
|
|
100
|
+
function invalidateRequireCache(workerApi, file) {
|
|
101
|
+
if (process.env.ATLASPACK_BUILD_ENV === 'test') {
|
|
102
|
+
// Delete this module and all children in the same node_modules folder
|
|
103
|
+
let module = require.cache[file];
|
|
104
|
+
if (module) {
|
|
105
|
+
delete require.cache[file];
|
|
106
|
+
let pkg = file.match(PKG_RE)?.[1];
|
|
107
|
+
for (let child of module.children) {
|
|
108
|
+
if (pkg === child.id.match(PKG_RE)?.[1]) {
|
|
109
|
+
invalidateRequireCache(workerApi, child.id);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
atlaspackConfigCache.clear();
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
throw new Error('invalidateRequireCache is only for tests');
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* This is used to wait until workers are responding to messages.
|
|
120
|
+
*/
|
|
121
|
+
function ping() {
|
|
122
|
+
return true;
|
|
123
|
+
}
|
package/lib/AssetGraph.js
CHANGED
|
@@ -46,7 +46,15 @@ function _graph() {
|
|
|
46
46
|
}
|
|
47
47
|
var _Dependency = require("./Dependency");
|
|
48
48
|
var _projectPath = require("./projectPath");
|
|
49
|
-
|
|
49
|
+
var _EnvironmentManager = require("./EnvironmentManager");
|
|
50
|
+
function _featureFlags() {
|
|
51
|
+
const data = require("@atlaspack/feature-flags");
|
|
52
|
+
_featureFlags = function () {
|
|
53
|
+
return data;
|
|
54
|
+
};
|
|
55
|
+
return data;
|
|
56
|
+
}
|
|
57
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
50
58
|
function nodeFromDep(dep) {
|
|
51
59
|
return {
|
|
52
60
|
id: dep.id,
|
|
@@ -63,7 +71,11 @@ function nodeFromDep(dep) {
|
|
|
63
71
|
}
|
|
64
72
|
function nodeFromAssetGroup(assetGroup) {
|
|
65
73
|
return {
|
|
66
|
-
id: (0, _rust().hashString)(
|
|
74
|
+
id: (0, _rust().hashString)(
|
|
75
|
+
// @ts-expect-error TS2345
|
|
76
|
+
(0, _projectPath.fromProjectPathRelative)(assetGroup.filePath) +
|
|
77
|
+
// @ts-expect-error TS2345
|
|
78
|
+
(0, _EnvironmentManager.toEnvironmentId)(assetGroup.env) + String(assetGroup.isSource) + String(assetGroup.sideEffects) + (assetGroup.code ?? '') + ':' + (assetGroup.pipeline ?? '') + ':' + (assetGroup.query ?? '')),
|
|
67
79
|
type: 'asset_group',
|
|
68
80
|
value: assetGroup,
|
|
69
81
|
usedSymbolsDownDirty: true
|
|
@@ -93,6 +105,8 @@ function nodeFromEntryFile(entry) {
|
|
|
93
105
|
value: entry
|
|
94
106
|
};
|
|
95
107
|
}
|
|
108
|
+
|
|
109
|
+
// @ts-expect-error TS2417
|
|
96
110
|
class AssetGraph extends _graph().ContentGraph {
|
|
97
111
|
safeToIncrementallyBundle = true;
|
|
98
112
|
constructor(opts) {
|
|
@@ -101,6 +115,7 @@ class AssetGraph extends _graph().ContentGraph {
|
|
|
101
115
|
hash,
|
|
102
116
|
...rest
|
|
103
117
|
} = opts;
|
|
118
|
+
// @ts-expect-error TS2345
|
|
104
119
|
super(rest);
|
|
105
120
|
this.hash = hash;
|
|
106
121
|
} else {
|
|
@@ -114,13 +129,9 @@ class AssetGraph extends _graph().ContentGraph {
|
|
|
114
129
|
this.undeferredDependencies = new Set();
|
|
115
130
|
this.envCache = new Map();
|
|
116
131
|
}
|
|
117
|
-
|
|
118
|
-
// $FlowFixMe[prop-missing]
|
|
119
132
|
static deserialize(opts) {
|
|
120
133
|
return new AssetGraph(opts);
|
|
121
134
|
}
|
|
122
|
-
|
|
123
|
-
// $FlowFixMe[prop-missing]
|
|
124
135
|
serialize() {
|
|
125
136
|
return {
|
|
126
137
|
...super.serialize(),
|
|
@@ -128,18 +139,32 @@ class AssetGraph extends _graph().ContentGraph {
|
|
|
128
139
|
};
|
|
129
140
|
}
|
|
130
141
|
|
|
142
|
+
/**
|
|
143
|
+
* Determine if we can incrementally bundle, which will not require a full bundling pass
|
|
144
|
+
* but just update assets into the bundle graph output.
|
|
145
|
+
*/
|
|
146
|
+
canIncrementallyBundle() {
|
|
147
|
+
return this.safeToIncrementallyBundle;
|
|
148
|
+
}
|
|
149
|
+
|
|
131
150
|
// Deduplicates Environments by making them referentially equal
|
|
132
151
|
normalizeEnvironment(input) {
|
|
152
|
+
if ((0, _featureFlags().getFeatureFlag)('environmentDeduplication')) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// @ts-expect-error TS2345
|
|
133
157
|
let {
|
|
134
158
|
id,
|
|
135
159
|
context
|
|
136
|
-
} = input.env;
|
|
160
|
+
} = (0, _EnvironmentManager.fromEnvironmentId)(input.env);
|
|
137
161
|
let idAndContext = `${id}-${context}`;
|
|
138
162
|
let env = this.envCache.get(idAndContext);
|
|
139
163
|
if (env) {
|
|
140
|
-
input.env = env;
|
|
164
|
+
input.env = (0, _EnvironmentManager.toEnvironmentRef)(env);
|
|
141
165
|
} else {
|
|
142
|
-
|
|
166
|
+
// @ts-expect-error TS2345
|
|
167
|
+
this.envCache.set(idAndContext, (0, _EnvironmentManager.fromEnvironmentId)(input.env));
|
|
143
168
|
}
|
|
144
169
|
}
|
|
145
170
|
setRootConnections({
|
|
@@ -166,8 +191,6 @@ class AssetGraph extends _graph().ContentGraph {
|
|
|
166
191
|
let existing = this.getNodeByContentKey(node.id);
|
|
167
192
|
if (existing != null) {
|
|
168
193
|
(0, _assert().default)(existing.type === node.type);
|
|
169
|
-
// $FlowFixMe[incompatible-type] Checked above
|
|
170
|
-
// $FlowFixMe[prop-missing]
|
|
171
194
|
existing.value = node.value;
|
|
172
195
|
let existingId = this.getNodeIdByContentKey(node.id);
|
|
173
196
|
this.updateNode(existingId, existing);
|
|
@@ -199,13 +222,14 @@ class AssetGraph extends _graph().ContentGraph {
|
|
|
199
222
|
env: target.env,
|
|
200
223
|
isEntry: true,
|
|
201
224
|
needsStableName: true,
|
|
202
|
-
|
|
225
|
+
// @ts-expect-error TS2322
|
|
226
|
+
symbols: (0, _EnvironmentManager.fromEnvironmentId)(target.env).isLibrary ? new Map([['*', {
|
|
203
227
|
local: '*',
|
|
204
228
|
isWeak: true,
|
|
205
229
|
loc: null
|
|
206
230
|
}]]) : undefined
|
|
207
231
|
}));
|
|
208
|
-
if (node.value.env.isLibrary) {
|
|
232
|
+
if ((0, _EnvironmentManager.fromEnvironmentId)(node.value.env).isLibrary) {
|
|
209
233
|
// in library mode, all of the entry's symbols are "used"
|
|
210
234
|
node.usedSymbolsDown.add('*');
|
|
211
235
|
node.usedSymbolsUp.set('*', undefined);
|
|
@@ -285,7 +309,10 @@ class AssetGraph extends _graph().ContentGraph {
|
|
|
285
309
|
if (traversedNode.type === 'asset') {
|
|
286
310
|
let hasDeferred = this.getNodeIdsConnectedFrom(traversedNodeId).some(childNodeId => {
|
|
287
311
|
let childNode = (0, _nullthrows().default)(this.getNode(childNodeId));
|
|
288
|
-
|
|
312
|
+
// @ts-expect-error TS2339
|
|
313
|
+
return childNode.hasDeferred == null ? false :
|
|
314
|
+
// @ts-expect-error TS2339
|
|
315
|
+
childNode.hasDeferred;
|
|
289
316
|
});
|
|
290
317
|
if (!hasDeferred) {
|
|
291
318
|
delete traversedNode.hasDeferred;
|
|
@@ -294,6 +321,7 @@ class AssetGraph extends _graph().ContentGraph {
|
|
|
294
321
|
hasDeferred
|
|
295
322
|
};
|
|
296
323
|
} else if (traversedNode.type === 'asset_group' && nodeId !== traversedNodeId) {
|
|
324
|
+
// @ts-expect-error TS2339
|
|
297
325
|
if (!(ctx !== null && ctx !== void 0 && ctx.hasDeferred)) {
|
|
298
326
|
this.safeToIncrementallyBundle = false;
|
|
299
327
|
delete traversedNode.hasDeferred;
|
|
@@ -348,7 +376,7 @@ class AssetGraph extends _graph().ContentGraph {
|
|
|
348
376
|
if (this.undeferredDependencies.has(d)) {
|
|
349
377
|
return false;
|
|
350
378
|
}
|
|
351
|
-
let depIsDeferrable = d.symbols && !(d.env.isLibrary && d.isEntry) && !d.symbols.has('*') && ![...d.symbols.keys()].some(symbol => {
|
|
379
|
+
let depIsDeferrable = d.symbols && !((0, _EnvironmentManager.fromEnvironmentId)(d.env).isLibrary && d.isEntry) && !d.symbols.has('*') && ![...d.symbols.keys()].some(symbol => {
|
|
352
380
|
var _resolvedAsset$symbol;
|
|
353
381
|
let assetSymbol = (_resolvedAsset$symbol = resolvedAsset.symbols) === null || _resolvedAsset$symbol === void 0 || (_resolvedAsset$symbol = _resolvedAsset$symbol.get(symbol)) === null || _resolvedAsset$symbol === void 0 ? void 0 : _resolvedAsset$symbol.local;
|
|
354
382
|
return assetSymbol != null && symbols.has(assetSymbol);
|
|
@@ -363,6 +391,7 @@ class AssetGraph extends _graph().ContentGraph {
|
|
|
363
391
|
resolveAssetGroup(assetGroup, assets, correspondingRequest) {
|
|
364
392
|
this.normalizeEnvironment(assetGroup);
|
|
365
393
|
let assetGroupNode = nodeFromAssetGroup(assetGroup);
|
|
394
|
+
// @ts-expect-error TS2322
|
|
366
395
|
assetGroupNode = this.getNodeByContentKey(assetGroupNode.id);
|
|
367
396
|
if (!assetGroupNode) {
|
|
368
397
|
return;
|
|
@@ -432,6 +461,15 @@ class AssetGraph extends _graph().ContentGraph {
|
|
|
432
461
|
...depNode.value.meta,
|
|
433
462
|
...existing.value.resolverMeta
|
|
434
463
|
};
|
|
464
|
+
if ((0, _featureFlags().getFeatureFlag)('hmrImprovements')) {
|
|
465
|
+
depNode.value.resolverMeta = existing.value.resolverMeta;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
if ((0, _featureFlags().getFeatureFlag)('hmrImprovements')) {
|
|
469
|
+
if ((existing === null || existing === void 0 ? void 0 : existing.type) === 'dependency' && existing.value.resolverPriority != null) {
|
|
470
|
+
depNode.value.priority = existing.value.resolverPriority;
|
|
471
|
+
depNode.value.resolverPriority = existing.value.resolverPriority;
|
|
472
|
+
}
|
|
435
473
|
}
|
|
436
474
|
let dependentAsset = dependentAssets.find(a => a.uniqueKey === dep.specifier);
|
|
437
475
|
if (dependentAsset) {
|
package/lib/Atlaspack.js
CHANGED
|
@@ -80,7 +80,7 @@ var _PathRequest = _interopRequireDefault(require("./requests/PathRequest"));
|
|
|
80
80
|
var _Environment = require("./Environment");
|
|
81
81
|
var _Dependency = require("./Dependency");
|
|
82
82
|
function _sourceMap() {
|
|
83
|
-
const data = require("@
|
|
83
|
+
const data = require("@atlaspack/source-map");
|
|
84
84
|
_sourceMap = function () {
|
|
85
85
|
return data;
|
|
86
86
|
};
|
|
@@ -118,42 +118,48 @@ function _featureFlags() {
|
|
|
118
118
|
var _atlaspackV = require("./atlaspack-v3");
|
|
119
119
|
var _AssetGraphRequest = _interopRequireDefault(require("./requests/AssetGraphRequest"));
|
|
120
120
|
var _AssetGraphRequestRust = require("./requests/AssetGraphRequestRust");
|
|
121
|
+
var _BundleGraphRequestRust = require("./requests/BundleGraphRequestRust");
|
|
121
122
|
var _rustWorkerThreadDylibHack = require("./rustWorkerThreadDylibHack");
|
|
122
|
-
function
|
|
123
|
-
function
|
|
124
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
123
|
+
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); }
|
|
124
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
125
125
|
// eslint-disable-next-line no-unused-vars
|
|
126
|
+
|
|
126
127
|
(0, _registerCoreWithSerializer.registerCoreWithSerializer)();
|
|
127
128
|
const INTERNAL_TRANSFORM = exports.INTERNAL_TRANSFORM = Symbol('internal_transform');
|
|
128
129
|
const INTERNAL_RESOLVE = exports.INTERNAL_RESOLVE = Symbol('internal_resolve');
|
|
129
|
-
|
|
130
|
+
let WORKER_PATH = exports.WORKER_PATH = _path().default.join(__dirname, 'worker.js');
|
|
131
|
+
if (__filename.endsWith('.ts')) {
|
|
132
|
+
exports.WORKER_PATH = WORKER_PATH = _path().default.join(__dirname, 'worker.ts');
|
|
133
|
+
}
|
|
130
134
|
class Atlaspack {
|
|
131
|
-
|
|
132
|
-
#
|
|
133
|
-
|
|
134
|
-
#
|
|
135
|
-
|
|
136
|
-
#
|
|
137
|
-
#
|
|
138
|
-
|
|
139
|
-
#
|
|
140
|
-
#
|
|
141
|
-
|
|
135
|
+
// @ts-expect-error TS2564
|
|
136
|
+
#requestTracker;
|
|
137
|
+
// @ts-expect-error TS2564
|
|
138
|
+
#config;
|
|
139
|
+
// @ts-expect-error TS2564
|
|
140
|
+
#farm;
|
|
141
|
+
#initialized = false;
|
|
142
|
+
// @ts-expect-error TS2564
|
|
143
|
+
#disposable;
|
|
144
|
+
#initialOptions;
|
|
145
|
+
// @ts-expect-error TS2564
|
|
146
|
+
#reporterRunner;
|
|
147
|
+
#resolvedOptions = null;
|
|
148
|
+
// @ts-expect-error TS2564
|
|
149
|
+
#optionsRef;
|
|
150
|
+
// @ts-expect-error TS2564
|
|
151
|
+
#watchAbortController;
|
|
152
|
+
#watchQueue = new (_utils2().PromiseQueue)({
|
|
142
153
|
maxConcurrent: 1
|
|
143
154
|
});
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|},
|
|
153
|
-
> */;
|
|
154
|
-
#watcherSubscription /*: ?AsyncSubscription*/;
|
|
155
|
-
#watcherCount /*: number*/ = 0;
|
|
156
|
-
#requestedAssetIds /*: Set<string>*/ = new Set();
|
|
155
|
+
// @ts-expect-error TS2564
|
|
156
|
+
#watchEvents;
|
|
157
|
+
#watcherSubscription;
|
|
158
|
+
#watcherCount = 0;
|
|
159
|
+
#requestedAssetIds = new Set();
|
|
160
|
+
|
|
161
|
+
// @ts-expect-error TS2564
|
|
162
|
+
|
|
157
163
|
constructor(options) {
|
|
158
164
|
this.#initialOptions = options;
|
|
159
165
|
}
|
|
@@ -191,7 +197,7 @@ class Atlaspack {
|
|
|
191
197
|
});
|
|
192
198
|
this.#resolvedOptions = resolvedOptions;
|
|
193
199
|
let rustAtlaspack;
|
|
194
|
-
if (resolvedOptions.featureFlags.atlaspackV3) {
|
|
200
|
+
if (resolvedOptions.featureFlags.atlaspackV3 || resolvedOptions.featureFlags.fullNative || resolvedOptions.featureFlags.nativePackager) {
|
|
195
201
|
// eslint-disable-next-line no-unused-vars
|
|
196
202
|
let {
|
|
197
203
|
entries,
|
|
@@ -203,22 +209,32 @@ class Atlaspack {
|
|
|
203
209
|
throw new Error('Atlaspack v3 must be run with lmdb lite cache');
|
|
204
210
|
}
|
|
205
211
|
const lmdb = resolvedOptions.cache.getNativeRef();
|
|
206
|
-
|
|
207
|
-
// $FlowFixMe
|
|
208
212
|
const version = require('../package.json').version;
|
|
209
213
|
await lmdb.put('current_session_version', Buffer.from(version));
|
|
214
|
+
let threads = undefined;
|
|
215
|
+
if (process.env.ATLASPACK_NATIVE_THREADS !== undefined) {
|
|
216
|
+
threads = parseInt(process.env.ATLASPACK_NATIVE_THREADS, 10);
|
|
217
|
+
} else if (process.env.NODE_ENV === 'test') {
|
|
218
|
+
threads = 2;
|
|
219
|
+
}
|
|
210
220
|
rustAtlaspack = await _atlaspackV.AtlaspackV3.create({
|
|
211
221
|
...options,
|
|
222
|
+
// @ts-expect-error TS2353
|
|
212
223
|
corePath: _path().default.join(__dirname, '..'),
|
|
213
|
-
threads
|
|
224
|
+
threads,
|
|
214
225
|
entries: Array.isArray(entries) ? entries : entries == null ? undefined : [entries],
|
|
215
226
|
env: resolvedOptions.env,
|
|
216
227
|
fs: inputFS && new _atlaspackV.FileSystemV3(inputFS),
|
|
217
|
-
// $FlowFixMe ProjectPath is a string
|
|
218
228
|
defaultTargetOptions: resolvedOptions.defaultTargetOptions,
|
|
219
|
-
|
|
229
|
+
serveOptions: resolvedOptions.serveOptions,
|
|
230
|
+
lmdb,
|
|
231
|
+
featureFlags: resolvedOptions.featureFlags
|
|
232
|
+
});
|
|
233
|
+
this.#disposable.add(() => {
|
|
234
|
+
rustAtlaspack.end();
|
|
220
235
|
});
|
|
221
236
|
}
|
|
237
|
+
// @ts-expect-error TS2454
|
|
222
238
|
this.rustAtlaspack = rustAtlaspack;
|
|
223
239
|
let {
|
|
224
240
|
config
|
|
@@ -264,6 +280,7 @@ class Atlaspack {
|
|
|
264
280
|
this.#requestTracker = await _RequestTracker.default.init({
|
|
265
281
|
farm: this.#farm,
|
|
266
282
|
options: resolvedOptions,
|
|
283
|
+
// @ts-expect-error TS2454
|
|
267
284
|
rustAtlaspack
|
|
268
285
|
});
|
|
269
286
|
this.#initialized = true;
|
|
@@ -330,6 +347,8 @@ class Atlaspack {
|
|
|
330
347
|
if (!this.#initialized) {
|
|
331
348
|
await this._init();
|
|
332
349
|
}
|
|
350
|
+
|
|
351
|
+
// @ts-expect-error TS7034
|
|
333
352
|
let watchEventsDisposable;
|
|
334
353
|
if (cb) {
|
|
335
354
|
watchEventsDisposable = this.#watchEvents.addListener(({
|
|
@@ -349,8 +368,11 @@ class Atlaspack {
|
|
|
349
368
|
this.#watchQueue.run();
|
|
350
369
|
}
|
|
351
370
|
this.#watcherCount++;
|
|
371
|
+
|
|
372
|
+
// @ts-expect-error TS7034
|
|
352
373
|
let unsubscribePromise;
|
|
353
374
|
const unsubscribe = async () => {
|
|
375
|
+
// @ts-expect-error TS7005
|
|
354
376
|
if (watchEventsDisposable) {
|
|
355
377
|
watchEventsDisposable.dispose();
|
|
356
378
|
}
|
|
@@ -368,9 +390,12 @@ class Atlaspack {
|
|
|
368
390
|
};
|
|
369
391
|
return {
|
|
370
392
|
unsubscribe() {
|
|
393
|
+
// @ts-expect-error TS7005
|
|
371
394
|
if (unsubscribePromise == null) {
|
|
372
395
|
unsubscribePromise = unsubscribe();
|
|
373
396
|
}
|
|
397
|
+
|
|
398
|
+
// @ts-expect-error TS7005
|
|
374
399
|
return unsubscribePromise;
|
|
375
400
|
}
|
|
376
401
|
};
|
|
@@ -381,41 +406,83 @@ class Atlaspack {
|
|
|
381
406
|
} = {
|
|
382
407
|
/*::...null*/
|
|
383
408
|
}) {
|
|
384
|
-
this.#requestTracker.setSignal(signal);
|
|
385
409
|
let options = (0, _nullthrows().default)(this.#resolvedOptions);
|
|
386
410
|
try {
|
|
411
|
+
var _this$rustAtlaspack;
|
|
387
412
|
if (options.shouldProfile) {
|
|
388
413
|
await this.startProfiling();
|
|
389
414
|
}
|
|
415
|
+
if (options.nativeProfiler) {
|
|
416
|
+
const nativeProfiler = new (_profiler().NativeProfiler)();
|
|
417
|
+
await nativeProfiler.startProfiling(options.nativeProfiler);
|
|
418
|
+
}
|
|
390
419
|
if (options.shouldTrace) {
|
|
391
420
|
_profiler().tracer.enable();
|
|
421
|
+
// We need to ensure the tracer is disabled when Atlaspack is disposed as it is a module level object.
|
|
422
|
+
// While rare (except for tests), if another instance is created later it should not have tracing enabled.
|
|
423
|
+
this.#disposable.add(() => {
|
|
424
|
+
_profiler().tracer.disable();
|
|
425
|
+
});
|
|
392
426
|
}
|
|
393
427
|
await this.#reporterRunner.report({
|
|
394
428
|
type: 'buildStart'
|
|
395
429
|
});
|
|
396
430
|
this.#requestTracker.graph.invalidateOnBuildNodes();
|
|
397
|
-
let
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
431
|
+
let bundleGraph;
|
|
432
|
+
let bundleInfo;
|
|
433
|
+
let changedAssets;
|
|
434
|
+
let assetRequests;
|
|
435
|
+
let scopeHoistingStats;
|
|
436
|
+
if ((0, _featureFlags().getFeatureFlag)('fullNative') && this.rustAtlaspack) {
|
|
437
|
+
let [result, error] = await this.rustAtlaspack.build(eventJson => {
|
|
438
|
+
let event = JSON.parse(eventJson);
|
|
439
|
+
this.#reporterRunner.report(event);
|
|
440
|
+
});
|
|
441
|
+
if (error) {
|
|
442
|
+
throw new (_diagnostic().default)({
|
|
443
|
+
diagnostic: error
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
({
|
|
447
|
+
bundleGraph,
|
|
448
|
+
changedAssets
|
|
449
|
+
} = (0, _BundleGraphRequestRust.getBundleGraph)(result));
|
|
450
|
+
bundleInfo = new Map((result.bundleInfo ?? []).map(info => [info.bundleId, {
|
|
451
|
+
filePath: (0, _projectPath.toProjectPath)(options.projectRoot, info.filePath),
|
|
452
|
+
bundleId: info.bundleId,
|
|
453
|
+
type: info.type,
|
|
454
|
+
stats: {
|
|
455
|
+
size: info.size,
|
|
456
|
+
time: info.time
|
|
457
|
+
}
|
|
458
|
+
}]));
|
|
459
|
+
assetRequests = result.assetRequests ?? [];
|
|
460
|
+
} else {
|
|
461
|
+
let request = (0, _AtlaspackBuildRequest.default)({
|
|
462
|
+
optionsRef: this.#optionsRef,
|
|
463
|
+
requestedAssetIds: this.#requestedAssetIds,
|
|
464
|
+
signal
|
|
465
|
+
});
|
|
466
|
+
({
|
|
467
|
+
bundleGraph,
|
|
468
|
+
bundleInfo,
|
|
469
|
+
changedAssets,
|
|
470
|
+
assetRequests,
|
|
471
|
+
scopeHoistingStats
|
|
472
|
+
} = await this.#requestTracker.runRequest(request, {
|
|
473
|
+
force: true
|
|
474
|
+
}));
|
|
475
|
+
}
|
|
410
476
|
this.#requestedAssetIds.clear();
|
|
411
477
|
await (0, _dumpGraphToGraphViz.default)(
|
|
412
|
-
//
|
|
478
|
+
// @ts-expect-error TS2345
|
|
413
479
|
this.#requestTracker.graph, 'RequestGraph', _RequestTracker.requestGraphEdgeTypes);
|
|
414
480
|
let event = {
|
|
415
481
|
type: 'buildSuccess',
|
|
416
482
|
changedAssets: new Map(Array.from(changedAssets).map(([id, asset]) => [id, (0, _Asset.assetFromValue)(asset, options)])),
|
|
417
483
|
bundleGraph: new _BundleGraph.default(bundleGraph, (bundle, bundleGraph, options) => _Bundle.PackagedBundle.getWithInfo(bundle, bundleGraph, options, bundleInfo.get(bundle.id)), options),
|
|
418
484
|
buildTime: Date.now() - startTime,
|
|
485
|
+
// @ts-expect-error TS7006
|
|
419
486
|
requestBundle: async bundle => {
|
|
420
487
|
let bundleNode = bundleGraph._graph.getNodeByContentKey(bundle.id);
|
|
421
488
|
(0, _assert().default)((bundleNode === null || bundleNode === void 0 ? void 0 : bundleNode.type) === 'bundle', 'Bundle does not exist');
|
|
@@ -427,7 +494,8 @@ class Atlaspack {
|
|
|
427
494
|
bundleGraph: event.bundleGraph,
|
|
428
495
|
buildTime: 0,
|
|
429
496
|
requestBundle: event.requestBundle,
|
|
430
|
-
unstable_requestStats: {}
|
|
497
|
+
unstable_requestStats: {},
|
|
498
|
+
scopeHoistingStats: event.scopeHoistingStats
|
|
431
499
|
};
|
|
432
500
|
}
|
|
433
501
|
for (let assetId of bundleNode.value.entryAssetIds) {
|
|
@@ -441,15 +509,23 @@ class Atlaspack {
|
|
|
441
509
|
}
|
|
442
510
|
let results = await this.#watchQueue.run();
|
|
443
511
|
let result = results.filter(Boolean).pop();
|
|
512
|
+
// @ts-expect-error TS18049
|
|
444
513
|
if (result.type === 'buildFailure') {
|
|
514
|
+
// @ts-expect-error TS18049
|
|
445
515
|
throw new BuildError(result.diagnostics);
|
|
446
516
|
}
|
|
447
517
|
return result;
|
|
448
518
|
},
|
|
449
|
-
unstable_requestStats: this.#requestTracker.flushStats()
|
|
519
|
+
unstable_requestStats: this.#requestTracker.flushStats(),
|
|
520
|
+
nativeCacheStats: await ((_this$rustAtlaspack = this.rustAtlaspack) === null || _this$rustAtlaspack === void 0 ? void 0 : _this$rustAtlaspack.completeCacheSession()),
|
|
521
|
+
scopeHoistingStats
|
|
450
522
|
};
|
|
523
|
+
|
|
524
|
+
// @ts-expect-error TS2345
|
|
451
525
|
await this.#reporterRunner.report(event);
|
|
452
|
-
await this.#requestTracker.runRequest(
|
|
526
|
+
await this.#requestTracker.runRequest(
|
|
527
|
+
// @ts-expect-error TS2345
|
|
528
|
+
(0, _ValidationRequest.default)({
|
|
453
529
|
optionsRef: this.#optionsRef,
|
|
454
530
|
assetRequests
|
|
455
531
|
}), {
|
|
@@ -458,8 +534,11 @@ class Atlaspack {
|
|
|
458
534
|
if (this.#reporterRunner.errors.length) {
|
|
459
535
|
throw this.#reporterRunner.errors;
|
|
460
536
|
}
|
|
537
|
+
|
|
538
|
+
// @ts-expect-error TS2322
|
|
461
539
|
return event;
|
|
462
540
|
} catch (e) {
|
|
541
|
+
var _this$rustAtlaspack2;
|
|
463
542
|
if (e instanceof _utils.BuildAbortError) {
|
|
464
543
|
throw e;
|
|
465
544
|
}
|
|
@@ -467,9 +546,13 @@ class Atlaspack {
|
|
|
467
546
|
let event = {
|
|
468
547
|
type: 'buildFailure',
|
|
469
548
|
diagnostics: Array.isArray(diagnostic) ? diagnostic : [diagnostic],
|
|
470
|
-
unstable_requestStats: this.#requestTracker.flushStats()
|
|
549
|
+
unstable_requestStats: this.#requestTracker.flushStats(),
|
|
550
|
+
nativeCacheStats: await ((_this$rustAtlaspack2 = this.rustAtlaspack) === null || _this$rustAtlaspack2 === void 0 ? void 0 : _this$rustAtlaspack2.completeCacheSession())
|
|
471
551
|
};
|
|
552
|
+
|
|
553
|
+
// @ts-expect-error TS2345
|
|
472
554
|
await this.#reporterRunner.report(event);
|
|
555
|
+
// @ts-expect-error TS2322
|
|
473
556
|
return event;
|
|
474
557
|
} finally {
|
|
475
558
|
if (this.isProfiling) {
|
|
@@ -501,10 +584,12 @@ class Atlaspack {
|
|
|
501
584
|
message: `File watch event emitted with ${events.length} events. Sample event: [${(_events$ = events[0]) === null || _events$ === void 0 ? void 0 : _events$.type}] ${(_events$2 = events[0]) === null || _events$2 === void 0 ? void 0 : _events$2.path}`
|
|
502
585
|
});
|
|
503
586
|
let nativeInvalid = false;
|
|
504
|
-
if (this.rustAtlaspack) {
|
|
587
|
+
if ((0, _featureFlags().getFeatureFlag)('atlaspackV3') && this.rustAtlaspack) {
|
|
505
588
|
nativeInvalid = await this.rustAtlaspack.respondToFsEvents(events);
|
|
506
589
|
}
|
|
507
|
-
let
|
|
590
|
+
let {
|
|
591
|
+
didInvalidate: isInvalid
|
|
592
|
+
} = await this.#requestTracker.respondToFSEvents(events, Number.POSITIVE_INFINITY);
|
|
508
593
|
if ((nativeInvalid || isInvalid) && this.#watchQueue.getNumWaiting() === 0) {
|
|
509
594
|
if (this.#watchAbortController) {
|
|
510
595
|
this.#watchAbortController.abort();
|
|
@@ -580,7 +665,11 @@ class Atlaspack {
|
|
|
580
665
|
requestedAssetIds: this.#requestedAssetIds
|
|
581
666
|
};
|
|
582
667
|
const start = Date.now();
|
|
583
|
-
const result = await this.#requestTracker.runRequest(
|
|
668
|
+
const result = await this.#requestTracker.runRequest((0, _featureFlags().getFeatureFlag)('atlaspackV3') && this.rustAtlaspack != null ?
|
|
669
|
+
// @ts-expect-error TS2345
|
|
670
|
+
(0, _AssetGraphRequestRust.createAssetGraphRequestRust)(this.rustAtlaspack)(input) :
|
|
671
|
+
// @ts-expect-error TS2345
|
|
672
|
+
(0, _AssetGraphRequest.default)(input), {
|
|
584
673
|
force: true
|
|
585
674
|
});
|
|
586
675
|
const duration = Date.now() - start;
|
|
@@ -601,6 +690,19 @@ class Atlaspack {
|
|
|
601
690
|
}
|
|
602
691
|
return result;
|
|
603
692
|
}
|
|
693
|
+
|
|
694
|
+
/**
|
|
695
|
+
* Copy the cache to a new directory and compact it.
|
|
696
|
+
*/
|
|
697
|
+
async unstable_compactCache() {
|
|
698
|
+
await this._init();
|
|
699
|
+
const cache = (0, _nullthrows().default)(this.#resolvedOptions).cache;
|
|
700
|
+
if (cache instanceof _cache().LMDBLiteCache) {
|
|
701
|
+
await cache.compact('parcel-cache-compacted');
|
|
702
|
+
} else {
|
|
703
|
+
throw new Error('Cache is not an LMDBLiteCache');
|
|
704
|
+
}
|
|
705
|
+
}
|
|
604
706
|
async unstable_transform(options) {
|
|
605
707
|
var _options$env;
|
|
606
708
|
if (!this.#initialized) {
|
|
@@ -654,6 +756,7 @@ class Atlaspack {
|
|
|
654
756
|
return null;
|
|
655
757
|
}
|
|
656
758
|
return {
|
|
759
|
+
// @ts-expect-error TS2322
|
|
657
760
|
filePath: (0, _projectPath.fromProjectPath)(projectRoot, res.filePath),
|
|
658
761
|
code: res.code,
|
|
659
762
|
query: res.query,
|