@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
package/lib/RequestTracker.js
CHANGED
|
@@ -6,9 +6,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.RequestGraph = void 0;
|
|
7
7
|
exports.cleanUpOrphans = cleanUpOrphans;
|
|
8
8
|
exports.default = void 0;
|
|
9
|
+
exports.getBiggestFSEventsInvalidations = getBiggestFSEventsInvalidations;
|
|
9
10
|
exports.getWatcherOptions = getWatcherOptions;
|
|
11
|
+
exports.invalidateRequestGraph = invalidateRequestGraph;
|
|
12
|
+
exports.invalidateRequestGraphFSEvents = invalidateRequestGraphFSEvents;
|
|
10
13
|
exports.readAndDeserializeRequestGraph = readAndDeserializeRequestGraph;
|
|
11
14
|
exports.requestTypes = exports.requestGraphEdgeTypes = void 0;
|
|
15
|
+
exports.runInvalidation = runInvalidation;
|
|
12
16
|
function _assert() {
|
|
13
17
|
const data = _interopRequireWildcard(require("assert"));
|
|
14
18
|
_assert = function () {
|
|
@@ -30,13 +34,6 @@ function _buildCache() {
|
|
|
30
34
|
};
|
|
31
35
|
return data;
|
|
32
36
|
}
|
|
33
|
-
function _cache() {
|
|
34
|
-
const data = require("@atlaspack/cache");
|
|
35
|
-
_cache = function () {
|
|
36
|
-
return data;
|
|
37
|
-
};
|
|
38
|
-
return data;
|
|
39
|
-
}
|
|
40
37
|
function _featureFlags() {
|
|
41
38
|
const data = require("@atlaspack/feature-flags");
|
|
42
39
|
_featureFlags = function () {
|
|
@@ -52,7 +49,7 @@ function _graph() {
|
|
|
52
49
|
return data;
|
|
53
50
|
}
|
|
54
51
|
function _logger() {
|
|
55
|
-
const data =
|
|
52
|
+
const data = _interopRequireDefault(require("@atlaspack/logger"));
|
|
56
53
|
_logger = function () {
|
|
57
54
|
return data;
|
|
58
55
|
};
|
|
@@ -84,9 +81,16 @@ var _projectPath = require("./projectPath");
|
|
|
84
81
|
var _ReporterRunner = require("./ReporterRunner");
|
|
85
82
|
var _ConfigRequest = require("./requests/ConfigRequest");
|
|
86
83
|
var _utils2 = require("./utils");
|
|
87
|
-
function
|
|
88
|
-
|
|
89
|
-
|
|
84
|
+
function _perf_hooks() {
|
|
85
|
+
const data = require("perf_hooks");
|
|
86
|
+
_perf_hooks = function () {
|
|
87
|
+
return data;
|
|
88
|
+
};
|
|
89
|
+
return data;
|
|
90
|
+
}
|
|
91
|
+
var _EnvironmentManager = require("./EnvironmentManager");
|
|
92
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
93
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
90
94
|
const requestGraphEdgeTypes = exports.requestGraphEdgeTypes = {
|
|
91
95
|
subrequest: 2,
|
|
92
96
|
invalidated_by_update: 3,
|
|
@@ -151,7 +155,7 @@ const nodeFromOption = (option, value) => ({
|
|
|
151
155
|
hash: (0, _utils2.hashFromOption)(value)
|
|
152
156
|
});
|
|
153
157
|
const nodeFromConfigKey = (fileName, configKey, contentHash) => ({
|
|
154
|
-
id: `config_key:${(0, _projectPath.fromProjectPathRelative)(fileName)}:${configKey}`,
|
|
158
|
+
id: `config_key:${(0, _projectPath.fromProjectPathRelative)(fileName)}:${JSON.stringify(configKey)}`,
|
|
155
159
|
type: CONFIG_KEY,
|
|
156
160
|
configKey,
|
|
157
161
|
contentHash
|
|
@@ -162,6 +166,8 @@ const keyFromOptionContentKey = contentKey => contentKey.slice('option:'.length)
|
|
|
162
166
|
// This constant is chosen by local profiling the time to serialise n nodes and tuning until an average time of ~50 ms per blob.
|
|
163
167
|
// The goal is to free up the event loop periodically to allow interruption by the user.
|
|
164
168
|
const NODES_PER_BLOB = 2 ** 14;
|
|
169
|
+
|
|
170
|
+
// @ts-expect-error TS2417
|
|
165
171
|
class RequestGraph extends _graph().ContentGraph {
|
|
166
172
|
invalidNodeIds = new Set();
|
|
167
173
|
incompleteNodeIds = new Set();
|
|
@@ -176,10 +182,7 @@ class RequestGraph extends _graph().ContentGraph {
|
|
|
176
182
|
cachedRequestChunks = new Set();
|
|
177
183
|
configKeyNodes = new Map();
|
|
178
184
|
nodesPerBlob = NODES_PER_BLOB;
|
|
179
|
-
|
|
180
|
-
// $FlowFixMe[prop-missing]
|
|
181
185
|
static deserialize(opts) {
|
|
182
|
-
// $FlowFixMe[prop-missing]
|
|
183
186
|
let deserialized = new RequestGraph(opts);
|
|
184
187
|
deserialized.invalidNodeIds = opts.invalidNodeIds;
|
|
185
188
|
deserialized.incompleteNodeIds = opts.incompleteNodeIds;
|
|
@@ -192,8 +195,6 @@ class RequestGraph extends _graph().ContentGraph {
|
|
|
192
195
|
deserialized.configKeyNodes = opts.configKeyNodes;
|
|
193
196
|
return deserialized;
|
|
194
197
|
}
|
|
195
|
-
|
|
196
|
-
// $FlowFixMe[prop-missing]
|
|
197
198
|
serialize() {
|
|
198
199
|
return {
|
|
199
200
|
...super.serialize(),
|
|
@@ -333,6 +334,8 @@ class RequestGraph extends _graph().ContentGraph {
|
|
|
333
334
|
let node = (0, _nullthrows().default)(this.getNode(nodeId));
|
|
334
335
|
(0, _assert().default)(node.type === OPTION);
|
|
335
336
|
const key = keyFromOptionContentKey(node.id);
|
|
337
|
+
|
|
338
|
+
// @ts-expect-error TS7053
|
|
336
339
|
if ((0, _utils2.hashFromOption)(options[key]) !== node.hash) {
|
|
337
340
|
invalidatedKeys.push(key);
|
|
338
341
|
let parentNodes = this.getNodeIdsConnectedTo(nodeId, requestGraphEdgeTypes.invalidated_by_update);
|
|
@@ -371,9 +374,13 @@ class RequestGraph extends _graph().ContentGraph {
|
|
|
371
374
|
}
|
|
372
375
|
invalidateOnFileCreate(requestNodeId, input) {
|
|
373
376
|
let node;
|
|
377
|
+
// @ts-expect-error TS2339
|
|
374
378
|
if (input.glob != null) {
|
|
379
|
+
// @ts-expect-error TS2339
|
|
375
380
|
node = nodeFromGlob(input.glob);
|
|
381
|
+
// @ts-expect-error TS2339
|
|
376
382
|
} else if (input.fileName != null && input.aboveFilePath != null) {
|
|
383
|
+
// @ts-expect-error TS2339
|
|
377
384
|
let aboveFilePath = input.aboveFilePath;
|
|
378
385
|
|
|
379
386
|
// Create nodes and edges for each part of the filename pattern.
|
|
@@ -381,6 +388,7 @@ class RequestGraph extends _graph().ContentGraph {
|
|
|
381
388
|
// This creates a sort of trie structure within the graph that can be
|
|
382
389
|
// quickly matched by following the edges. This is also memory efficient
|
|
383
390
|
// since common sub-paths (e.g. 'node_modules') are deduplicated.
|
|
391
|
+
// @ts-expect-error TS2339
|
|
384
392
|
let parts = input.fileName.split('/').reverse();
|
|
385
393
|
let lastNodeId;
|
|
386
394
|
for (let part of parts) {
|
|
@@ -415,7 +423,9 @@ class RequestGraph extends _graph().ContentGraph {
|
|
|
415
423
|
if (!this.hasEdge(lastNodeId, nodeId, requestGraphEdgeTypes.invalidated_by_create_above)) {
|
|
416
424
|
this.addEdge(lastNodeId, nodeId, requestGraphEdgeTypes.invalidated_by_create_above);
|
|
417
425
|
}
|
|
426
|
+
// @ts-expect-error TS2339
|
|
418
427
|
} else if (input.filePath != null) {
|
|
428
|
+
// @ts-expect-error TS2339
|
|
419
429
|
node = nodeFromFilePath(input.filePath);
|
|
420
430
|
} else {
|
|
421
431
|
throw new Error('Invalid invalidation');
|
|
@@ -434,8 +444,8 @@ class RequestGraph extends _graph().ContentGraph {
|
|
|
434
444
|
this.invalidateOnBuildNodeIds.add(requestNodeId);
|
|
435
445
|
}
|
|
436
446
|
invalidateOnEnvChange(requestNodeId, env, value) {
|
|
437
|
-
|
|
438
|
-
|
|
447
|
+
const envNode = nodeFromEnv(env, value);
|
|
448
|
+
const envNodeId = this.addNode(envNode);
|
|
439
449
|
if (!this.hasEdge(requestNodeId, envNodeId, requestGraphEdgeTypes.invalidated_by_update)) {
|
|
440
450
|
this.addEdge(requestNodeId, envNodeId, requestGraphEdgeTypes.invalidated_by_update);
|
|
441
451
|
}
|
|
@@ -461,6 +471,7 @@ class RequestGraph extends _graph().ContentGraph {
|
|
|
461
471
|
|
|
462
472
|
// For now just handling updates. Could add creates/deletes later if needed.
|
|
463
473
|
let invalidations = this.getNodeIdsConnectedFrom(requestNodeId, requestGraphEdgeTypes.invalidated_by_update);
|
|
474
|
+
// @ts-expect-error TS2322
|
|
464
475
|
return invalidations.map(nodeId => {
|
|
465
476
|
let node = (0, _nullthrows().default)(this.getNode(nodeId));
|
|
466
477
|
switch (node.type) {
|
|
@@ -582,10 +593,12 @@ class RequestGraph extends _graph().ContentGraph {
|
|
|
582
593
|
aboveCache.set(fileNameNodeId, above);
|
|
583
594
|
return above;
|
|
584
595
|
};
|
|
596
|
+
const invalidationsByPath = new Map();
|
|
585
597
|
for (let {
|
|
586
598
|
path: _path,
|
|
587
599
|
type
|
|
588
600
|
} of events) {
|
|
601
|
+
const invalidationsBefore = this.getInvalidNodeCount();
|
|
589
602
|
if (!enableOptimization && process.env.ATLASPACK_DISABLE_CACHE_TIMEOUT !== 'true' && ++count === 256) {
|
|
590
603
|
let duration = Date.now() - startTime;
|
|
591
604
|
predictedTime = duration * (events.length >> 8);
|
|
@@ -622,7 +635,10 @@ class RequestGraph extends _graph().ContentGraph {
|
|
|
622
635
|
this.invalidNodeIds.add(id);
|
|
623
636
|
}
|
|
624
637
|
}
|
|
625
|
-
return
|
|
638
|
+
return {
|
|
639
|
+
didInvalidate: true,
|
|
640
|
+
invalidationsByPath: new Map()
|
|
641
|
+
};
|
|
626
642
|
}
|
|
627
643
|
|
|
628
644
|
// sometimes mac os reports update events as create events.
|
|
@@ -679,10 +695,17 @@ class RequestGraph extends _graph().ContentGraph {
|
|
|
679
695
|
this.removeNode(nodeId, removeOrphans);
|
|
680
696
|
}
|
|
681
697
|
let configKeyNodes = this.configKeyNodes.get(_filePath);
|
|
682
|
-
|
|
698
|
+
|
|
699
|
+
// With granular invalidations we will always run this block,
|
|
700
|
+
// so even if we get a create event (for whatever reason), we will still
|
|
701
|
+
// try to limit invalidations from config key changes through hashing.
|
|
702
|
+
//
|
|
703
|
+
// Currently create events can invalidate a large number of nodes due to
|
|
704
|
+
// "create above" invalidations.
|
|
705
|
+
if (configKeyNodes) {
|
|
683
706
|
for (let nodeId of configKeyNodes) {
|
|
684
707
|
let isInvalid = type === 'delete';
|
|
685
|
-
if (type
|
|
708
|
+
if (type !== 'delete') {
|
|
686
709
|
let node = this.getNode(nodeId);
|
|
687
710
|
(0, _assert().default)(node && node.type === CONFIG_KEY);
|
|
688
711
|
let contentHash = await (0, _ConfigRequest.getConfigKeyContentHash)(_filePath, node.configKey, options);
|
|
@@ -697,6 +720,9 @@ class RequestGraph extends _graph().ContentGraph {
|
|
|
697
720
|
}
|
|
698
721
|
}
|
|
699
722
|
}
|
|
723
|
+
const invalidationsAfter = this.getInvalidNodeCount();
|
|
724
|
+
const invalidationsForEvent = invalidationsAfter - invalidationsBefore;
|
|
725
|
+
invalidationsByPath.set(_path, (invalidationsByPath.get(_path) ?? 0) + invalidationsForEvent);
|
|
700
726
|
}
|
|
701
727
|
if ((0, _featureFlags().getFeatureFlag)('fixQuadraticCacheInvalidation')) {
|
|
702
728
|
cleanUpOrphans(this);
|
|
@@ -714,7 +740,10 @@ class RequestGraph extends _graph().ContentGraph {
|
|
|
714
740
|
numberOfInvalidatedNodes: invalidatedNodes.size
|
|
715
741
|
}
|
|
716
742
|
});
|
|
717
|
-
return
|
|
743
|
+
return {
|
|
744
|
+
didInvalidate,
|
|
745
|
+
invalidationsByPath
|
|
746
|
+
};
|
|
718
747
|
}
|
|
719
748
|
hasCachedRequestChunk(index) {
|
|
720
749
|
return this.cachedRequestChunks.has(index);
|
|
@@ -725,6 +754,13 @@ class RequestGraph extends _graph().ContentGraph {
|
|
|
725
754
|
removeCachedRequestChunkForNode(nodeId) {
|
|
726
755
|
this.cachedRequestChunks.delete(Math.floor(nodeId / this.nodesPerBlob));
|
|
727
756
|
}
|
|
757
|
+
|
|
758
|
+
/**
|
|
759
|
+
* Returns the number of invalidated nodes in the graph.
|
|
760
|
+
*/
|
|
761
|
+
getInvalidNodeCount() {
|
|
762
|
+
return this.invalidNodeIds.size;
|
|
763
|
+
}
|
|
728
764
|
}
|
|
729
765
|
exports.RequestGraph = RequestGraph;
|
|
730
766
|
class RequestTracker {
|
|
@@ -740,11 +776,6 @@ class RequestTracker {
|
|
|
740
776
|
this.options = options;
|
|
741
777
|
this.rustAtlaspack = rustAtlaspack;
|
|
742
778
|
}
|
|
743
|
-
|
|
744
|
-
// TODO: refactor (abortcontroller should be created by RequestTracker)
|
|
745
|
-
setSignal(signal) {
|
|
746
|
-
this.signal = signal;
|
|
747
|
-
}
|
|
748
779
|
startRequest(request) {
|
|
749
780
|
let didPreviouslyExist = this.graph.hasContentKey(request.id);
|
|
750
781
|
let requestNodeId;
|
|
@@ -762,6 +793,7 @@ class RequestTracker {
|
|
|
762
793
|
promise,
|
|
763
794
|
deferred
|
|
764
795
|
} = (0, _utils().makeDeferredWithPromise)();
|
|
796
|
+
// @ts-expect-error TS2345
|
|
765
797
|
this.graph.incompleteNodePromises.set(requestNodeId, promise);
|
|
766
798
|
return {
|
|
767
799
|
requestNodeId,
|
|
@@ -787,15 +819,12 @@ class RequestTracker {
|
|
|
787
819
|
return null;
|
|
788
820
|
}
|
|
789
821
|
if (node.result != undefined) {
|
|
790
|
-
// $FlowFixMe
|
|
791
822
|
let result = node.result;
|
|
792
823
|
return result;
|
|
793
824
|
} else if (node.resultCacheKey != null && ifMatch == null) {
|
|
794
825
|
let key = node.resultCacheKey;
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
}
|
|
798
|
-
let cachedResult = (0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements') ? (0, _nullthrows().default)(await this.options.cache.get(key)) : (0, _buildCache().deserialize)(await this.options.cache.getLargeBlob(key));
|
|
826
|
+
(0, _assert().default)(this.options.cache.hasLargeBlob(key));
|
|
827
|
+
let cachedResult = (0, _buildCache().deserialize)(await this.options.cache.getLargeBlob(key));
|
|
799
828
|
node.result = cachedResult;
|
|
800
829
|
return cachedResult;
|
|
801
830
|
}
|
|
@@ -841,7 +870,7 @@ class RequestTracker {
|
|
|
841
870
|
let requestId = hasKey ? this.graph.getNodeIdByContentKey(request.id) : undefined;
|
|
842
871
|
let hasValidResult = requestId != null && this.hasValidResult(requestId);
|
|
843
872
|
if (!(opts !== null && opts !== void 0 && opts.force) && hasValidResult) {
|
|
844
|
-
//
|
|
873
|
+
// @ts-expect-error TS2322
|
|
845
874
|
return this.getRequestResult(request.id);
|
|
846
875
|
}
|
|
847
876
|
if (requestId != null) {
|
|
@@ -850,7 +879,7 @@ class RequestTracker {
|
|
|
850
879
|
// There is a another instance of this request already running, wait for its completion and reuse its result
|
|
851
880
|
try {
|
|
852
881
|
if (await incompletePromise) {
|
|
853
|
-
//
|
|
882
|
+
// @ts-expect-error TS2322
|
|
854
883
|
return this.getRequestResult(request.id);
|
|
855
884
|
}
|
|
856
885
|
} catch (e) {
|
|
@@ -883,7 +912,6 @@ class RequestTracker {
|
|
|
883
912
|
options: this.options,
|
|
884
913
|
rustAtlaspack: this.rustAtlaspack
|
|
885
914
|
});
|
|
886
|
-
(0, _utils2.assertSignalNotAborted)(this.signal);
|
|
887
915
|
this.completeRequest(requestNodeId);
|
|
888
916
|
deferred.resolve(true);
|
|
889
917
|
return result;
|
|
@@ -921,65 +949,56 @@ class RequestTracker {
|
|
|
921
949
|
}
|
|
922
950
|
createAPI(requestId, previousInvalidations) {
|
|
923
951
|
let subRequestContentKeys = new Set();
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
runRequest: (subRequest, opts) => {
|
|
954
|
-
subRequestContentKeys.add(subRequest.id);
|
|
955
|
-
return this.runRequest(subRequest, opts);
|
|
952
|
+
let api = {
|
|
953
|
+
invalidateOnFileCreate: input => this.graph.invalidateOnFileCreate(requestId, input),
|
|
954
|
+
invalidateOnConfigKeyChange: (filePath, configKey, contentHash) => this.graph.invalidateOnConfigKeyChange(requestId, filePath, configKey, contentHash),
|
|
955
|
+
invalidateOnFileDelete: filePath => this.graph.invalidateOnFileDelete(requestId, filePath),
|
|
956
|
+
invalidateOnFileUpdate: filePath => this.graph.invalidateOnFileUpdate(requestId, filePath),
|
|
957
|
+
invalidateOnStartup: () => this.graph.invalidateOnStartup(requestId),
|
|
958
|
+
invalidateOnBuild: () => this.graph.invalidateOnBuild(requestId),
|
|
959
|
+
invalidateOnEnvChange: env => this.graph.invalidateOnEnvChange(requestId, env, this.options.env[env]),
|
|
960
|
+
invalidateOnOptionChange: option => this.graph.invalidateOnOptionChange(requestId, option,
|
|
961
|
+
// @ts-expect-error TS7053
|
|
962
|
+
this.options[option]),
|
|
963
|
+
getInvalidations: () => previousInvalidations,
|
|
964
|
+
storeResult: (result, cacheKey) => {
|
|
965
|
+
this.storeResult(requestId, result, cacheKey);
|
|
966
|
+
},
|
|
967
|
+
getSubRequests: () => this.graph.getSubRequests(requestId),
|
|
968
|
+
getInvalidSubRequests: () => this.graph.getInvalidSubRequests(requestId),
|
|
969
|
+
getPreviousResult: ifMatch => {
|
|
970
|
+
var _this$graph$getNode;
|
|
971
|
+
let contentKey = (0, _nullthrows().default)((_this$graph$getNode = this.graph.getNode(requestId)) === null || _this$graph$getNode === void 0 ? void 0 : _this$graph$getNode.id);
|
|
972
|
+
return this.getRequestResult(contentKey, ifMatch);
|
|
973
|
+
},
|
|
974
|
+
getRequestResult: (
|
|
975
|
+
// @ts-expect-error TS7006
|
|
976
|
+
id) => this.getRequestResult(id),
|
|
977
|
+
canSkipSubrequest: contentKey => {
|
|
978
|
+
if (this.graph.hasContentKey(contentKey) && this.hasValidResult(this.graph.getNodeIdByContentKey(contentKey))) {
|
|
979
|
+
subRequestContentKeys.add(contentKey);
|
|
980
|
+
return true;
|
|
956
981
|
}
|
|
982
|
+
return false;
|
|
957
983
|
},
|
|
984
|
+
runRequest: (subRequest, opts) => {
|
|
985
|
+
subRequestContentKeys.add(subRequest.id);
|
|
986
|
+
return this.runRequest(subRequest, opts);
|
|
987
|
+
}
|
|
988
|
+
};
|
|
989
|
+
return {
|
|
990
|
+
api,
|
|
958
991
|
subRequestContentKeys
|
|
959
992
|
};
|
|
960
993
|
}
|
|
961
994
|
async writeToCache(signal) {
|
|
962
|
-
const options = this.options;
|
|
963
|
-
async function runCacheImprovements(newPath, oldPath) {
|
|
964
|
-
if ((0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements')) {
|
|
965
|
-
(0, _assert().default)(options.cache instanceof _cache().LMDBLiteCache);
|
|
966
|
-
const result = await newPath(options.cache);
|
|
967
|
-
return result;
|
|
968
|
-
} else {
|
|
969
|
-
const result = await oldPath();
|
|
970
|
-
return result;
|
|
971
|
-
}
|
|
972
|
-
}
|
|
973
995
|
let cacheKey = getCacheKey(this.options);
|
|
974
|
-
let requestGraphKey =
|
|
975
|
-
let snapshotKey =
|
|
996
|
+
let requestGraphKey = `requestGraph-${cacheKey}`;
|
|
997
|
+
let snapshotKey = `snapshot-${cacheKey}`;
|
|
976
998
|
if (this.options.shouldDisableCache) {
|
|
977
999
|
return;
|
|
978
1000
|
}
|
|
979
1001
|
let total = 0;
|
|
980
|
-
await runCacheImprovements(async cache => {
|
|
981
|
-
await cache.getNativeRef().startWriteTransaction();
|
|
982
|
-
}, () => Promise.resolve());
|
|
983
1002
|
try {
|
|
984
1003
|
(0, _ReporterRunner.report)({
|
|
985
1004
|
type: 'cache',
|
|
@@ -987,6 +1006,9 @@ class RequestTracker {
|
|
|
987
1006
|
total,
|
|
988
1007
|
size: this.graph.nodes.length
|
|
989
1008
|
});
|
|
1009
|
+
if ((0, _featureFlags().getFeatureFlag)('environmentDeduplication')) {
|
|
1010
|
+
await (0, _EnvironmentManager.writeEnvironmentsToCache)(this.options.cache);
|
|
1011
|
+
}
|
|
990
1012
|
let serialisedGraph = this.graph.serialize();
|
|
991
1013
|
|
|
992
1014
|
// Delete an existing request graph cache, to prevent invalid states
|
|
@@ -995,16 +1017,9 @@ class RequestTracker {
|
|
|
995
1017
|
if (signal !== null && signal !== void 0 && signal.aborted) {
|
|
996
1018
|
throw new Error('Serialization was aborted');
|
|
997
1019
|
}
|
|
998
|
-
await
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
});
|
|
1002
|
-
return Promise.resolve();
|
|
1003
|
-
}, async () => {
|
|
1004
|
-
await this.options.cache.setLargeBlob(key, (0, _buildCache().serialize)(contents), signal ? {
|
|
1005
|
-
signal: signal
|
|
1006
|
-
} : undefined);
|
|
1007
|
-
});
|
|
1020
|
+
await this.options.cache.setLargeBlob(key, (0, _buildCache().serialize)(contents), signal ? {
|
|
1021
|
+
signal: signal
|
|
1022
|
+
} : undefined);
|
|
1008
1023
|
total += 1;
|
|
1009
1024
|
(0, _ReporterRunner.report)({
|
|
1010
1025
|
type: 'cache',
|
|
@@ -1021,6 +1036,8 @@ class RequestTracker {
|
|
|
1021
1036
|
let cacheableNodes = new Array(serialisedGraph.nodes.length);
|
|
1022
1037
|
for (let i = 0; i < serialisedGraph.nodes.length; i += 1) {
|
|
1023
1038
|
let node = serialisedGraph.nodes[i];
|
|
1039
|
+
|
|
1040
|
+
// @ts-expect-error TS2339
|
|
1024
1041
|
let resultCacheKey = node === null || node === void 0 ? void 0 : node.resultCacheKey;
|
|
1025
1042
|
if ((node === null || node === void 0 ? void 0 : node.type) === REQUEST && resultCacheKey != null && (node === null || node === void 0 ? void 0 : node.result) != null) {
|
|
1026
1043
|
queue.add(() => serialiseAndSet(resultCacheKey, node.result));
|
|
@@ -1057,23 +1074,12 @@ class RequestTracker {
|
|
|
1057
1074
|
nodeCountsPerBlob,
|
|
1058
1075
|
nodes: undefined
|
|
1059
1076
|
});
|
|
1060
|
-
await runCacheImprovements(() => serialiseAndSet(`${cacheKey}/cache_metadata`, {
|
|
1061
|
-
version: _constants.ATLASPACK_VERSION,
|
|
1062
|
-
entries: this.options.entries,
|
|
1063
|
-
mode: this.options.mode,
|
|
1064
|
-
shouldBuildLazily: this.options.shouldBuildLazily,
|
|
1065
|
-
watchBackend: this.options.watchBackend
|
|
1066
|
-
}), () => Promise.resolve());
|
|
1067
1077
|
let opts = getWatcherOptions(this.options);
|
|
1068
1078
|
let snapshotPath = _path2().default.join(this.options.cacheDir, snapshotKey + '.txt');
|
|
1069
1079
|
await this.options.outputFS.writeSnapshot(this.options.watchDir, snapshotPath, opts);
|
|
1070
1080
|
} catch (err) {
|
|
1071
1081
|
// If we have aborted, ignore the error and continue
|
|
1072
1082
|
if (!(signal !== null && signal !== void 0 && signal.aborted)) throw err;
|
|
1073
|
-
} finally {
|
|
1074
|
-
await runCacheImprovements(async cache => {
|
|
1075
|
-
await cache.getNativeRef().commitWriteTransaction();
|
|
1076
|
-
}, () => Promise.resolve());
|
|
1077
1083
|
}
|
|
1078
1084
|
(0, _ReporterRunner.report)({
|
|
1079
1085
|
type: 'cache',
|
|
@@ -1103,7 +1109,8 @@ function getWatcherOptions({
|
|
|
1103
1109
|
watchDir,
|
|
1104
1110
|
watchBackend
|
|
1105
1111
|
}) {
|
|
1106
|
-
const
|
|
1112
|
+
const vcsDirs = ['.git', '.hg'];
|
|
1113
|
+
const uniqueDirs = [...new Set([...watchIgnore, ...vcsDirs, cacheDir])];
|
|
1107
1114
|
const ignore = uniqueDirs.map(dir => _path2().default.resolve(watchDir, dir));
|
|
1108
1115
|
return {
|
|
1109
1116
|
ignore,
|
|
@@ -1111,33 +1118,22 @@ function getWatcherOptions({
|
|
|
1111
1118
|
};
|
|
1112
1119
|
}
|
|
1113
1120
|
function getCacheKey(options) {
|
|
1114
|
-
if ((0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements')) {
|
|
1115
|
-
const hash = (0, _rust().hashString)(`${_constants.ATLASPACK_VERSION}:${JSON.stringify(options.entries)}:${options.mode}:${options.shouldBuildLazily ? 'lazy' : 'eager'}:${options.watchBackend ?? ''}`);
|
|
1116
|
-
return `RequestTracker/${_constants.ATLASPACK_VERSION}/${hash}`;
|
|
1117
|
-
}
|
|
1118
1121
|
return (0, _rust().hashString)(`${_constants.ATLASPACK_VERSION}:${JSON.stringify(options.entries)}:${options.mode}:${options.shouldBuildLazily ? 'lazy' : 'eager'}:${options.watchBackend ?? ''}`);
|
|
1119
1122
|
}
|
|
1120
1123
|
function getRequestGraphNodeKey(index, cacheKey) {
|
|
1121
|
-
if ((0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements')) {
|
|
1122
|
-
return `${cacheKey}/RequestGraph/nodes/${index}`;
|
|
1123
|
-
}
|
|
1124
1124
|
return `requestGraph-nodes-${index}-${cacheKey}`;
|
|
1125
1125
|
}
|
|
1126
1126
|
async function readAndDeserializeRequestGraph(cache, requestGraphKey, cacheKey) {
|
|
1127
1127
|
let bufferLength = 0;
|
|
1128
1128
|
const getAndDeserialize = async key => {
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
return (0, _buildCache().deserialize)(buffer);
|
|
1133
|
-
} else {
|
|
1134
|
-
const buffer = await cache.getLargeBlob(key);
|
|
1135
|
-
bufferLength += Buffer.byteLength(buffer);
|
|
1136
|
-
return (0, _buildCache().deserialize)(buffer);
|
|
1137
|
-
}
|
|
1129
|
+
const buffer = await cache.getLargeBlob(key);
|
|
1130
|
+
bufferLength += Buffer.byteLength(buffer);
|
|
1131
|
+
return (0, _buildCache().deserialize)(buffer);
|
|
1138
1132
|
};
|
|
1139
1133
|
let serializedRequestGraph = await getAndDeserialize(requestGraphKey);
|
|
1140
|
-
let nodePromises = serializedRequestGraph.nodeCountsPerBlob.map(
|
|
1134
|
+
let nodePromises = serializedRequestGraph.nodeCountsPerBlob.map(
|
|
1135
|
+
// @ts-expect-error TS7006
|
|
1136
|
+
async (nodesCount, i) => {
|
|
1141
1137
|
let nodes = await getAndDeserialize(getRequestGraphNodeKey(i, cacheKey));
|
|
1142
1138
|
_assert().default.equal(nodes.length, nodesCount, 'RequestTracker node chunk: invalid node count');
|
|
1143
1139
|
return nodes;
|
|
@@ -1156,9 +1152,9 @@ async function loadRequestGraph(options) {
|
|
|
1156
1152
|
return new RequestGraph();
|
|
1157
1153
|
}
|
|
1158
1154
|
let cacheKey = getCacheKey(options);
|
|
1159
|
-
let requestGraphKey =
|
|
1155
|
+
let requestGraphKey = `requestGraph-${cacheKey}`;
|
|
1160
1156
|
let timeout;
|
|
1161
|
-
const snapshotKey =
|
|
1157
|
+
const snapshotKey = `snapshot-${cacheKey}`;
|
|
1162
1158
|
const snapshotPath = _path2().default.join(options.cacheDir, snapshotKey + '.txt');
|
|
1163
1159
|
const commonMeta = {
|
|
1164
1160
|
cacheKey,
|
|
@@ -1178,7 +1174,10 @@ async function loadRequestGraph(options) {
|
|
|
1178
1174
|
...commonMeta
|
|
1179
1175
|
}
|
|
1180
1176
|
});
|
|
1181
|
-
|
|
1177
|
+
if ((0, _featureFlags().getFeatureFlag)('environmentDeduplication')) {
|
|
1178
|
+
await (0, _EnvironmentManager.loadEnvironmentsFromCache)(options.cache);
|
|
1179
|
+
}
|
|
1180
|
+
const hasRequestGraphInCache = await options.cache.hasLargeBlob(requestGraphKey);
|
|
1182
1181
|
if (hasRequestGraphInCache) {
|
|
1183
1182
|
try {
|
|
1184
1183
|
let {
|
|
@@ -1204,23 +1203,16 @@ async function loadRequestGraph(options) {
|
|
|
1204
1203
|
duration: Date.now() - startTime
|
|
1205
1204
|
}
|
|
1206
1205
|
});
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
});
|
|
1218
|
-
} else {
|
|
1219
|
-
requestGraph.invalidateUnpredictableNodes();
|
|
1220
|
-
requestGraph.invalidateOnBuildNodes();
|
|
1221
|
-
requestGraph.invalidateEnvNodes(options.env);
|
|
1222
|
-
requestGraph.invalidateOptionNodes(options);
|
|
1223
|
-
}
|
|
1206
|
+
const invalidationStats = await invalidateRequestGraph(requestGraph, options, events);
|
|
1207
|
+
_logger().default.verbose({
|
|
1208
|
+
origin: '@atlaspack/core',
|
|
1209
|
+
message: 'Request track loaded from cache',
|
|
1210
|
+
meta: {
|
|
1211
|
+
...commonMeta,
|
|
1212
|
+
trackableEvent: 'request_tracker_cache_key_hit',
|
|
1213
|
+
invalidationStats
|
|
1214
|
+
}
|
|
1215
|
+
});
|
|
1224
1216
|
return requestGraph;
|
|
1225
1217
|
} catch (e) {
|
|
1226
1218
|
// Prevent logging fs events took too long warning
|
|
@@ -1246,6 +1238,20 @@ async function loadRequestGraph(options) {
|
|
|
1246
1238
|
* A wrapper around an invalidation type / method
|
|
1247
1239
|
*/
|
|
1248
1240
|
|
|
1241
|
+
/**
|
|
1242
|
+
* Details about an invalidation.
|
|
1243
|
+
*
|
|
1244
|
+
* If this is a fs events invalidation, this key will contain statistics about invalidations
|
|
1245
|
+
* by path.
|
|
1246
|
+
*
|
|
1247
|
+
* If this is a env or option invalidation, this key will contain the list of changed environment
|
|
1248
|
+
* variables or options.
|
|
1249
|
+
*/
|
|
1250
|
+
|
|
1251
|
+
/**
|
|
1252
|
+
* Number of invalidations for a given file-system event.
|
|
1253
|
+
*/
|
|
1254
|
+
|
|
1249
1255
|
/**
|
|
1250
1256
|
* Information about a certain cache invalidation type.
|
|
1251
1257
|
*/
|
|
@@ -1259,9 +1265,11 @@ async function loadRequestGraph(options) {
|
|
|
1259
1265
|
async function invalidateRequestGraph(requestGraph, options, events) {
|
|
1260
1266
|
const invalidationFns = [{
|
|
1261
1267
|
key: 'unpredictable',
|
|
1268
|
+
// @ts-expect-error TS2322
|
|
1262
1269
|
fn: () => requestGraph.invalidateUnpredictableNodes()
|
|
1263
1270
|
}, {
|
|
1264
1271
|
key: 'onBuild',
|
|
1272
|
+
// @ts-expect-error TS2322
|
|
1265
1273
|
fn: () => requestGraph.invalidateOnBuildNodes()
|
|
1266
1274
|
}, {
|
|
1267
1275
|
key: 'env',
|
|
@@ -1271,9 +1279,7 @@ async function invalidateRequestGraph(requestGraph, options, events) {
|
|
|
1271
1279
|
fn: () => requestGraph.invalidateOptionNodes(options)
|
|
1272
1280
|
}, {
|
|
1273
1281
|
key: 'fsEvents',
|
|
1274
|
-
fn:
|
|
1275
|
-
await requestGraph.respondToFSEvents(options.unstableFileInvalidations || events, options, 10000, true);
|
|
1276
|
-
}
|
|
1282
|
+
fn: () => invalidateRequestGraphFSEvents(requestGraph, options, events)
|
|
1277
1283
|
}];
|
|
1278
1284
|
const invalidations = [];
|
|
1279
1285
|
for (const invalidation of invalidationFns) {
|
|
@@ -1282,27 +1288,45 @@ async function invalidateRequestGraph(requestGraph, options, events) {
|
|
|
1282
1288
|
const invalidatedCount = invalidations.reduce((acc, invalidation) => acc + invalidation.count, 0);
|
|
1283
1289
|
const requestCount = requestGraph.nodes.reduce((acc, node) => acc + ((node === null || node === void 0 ? void 0 : node.type) === REQUEST ? 1 : 0), 0);
|
|
1284
1290
|
const nodeCount = requestGraph.nodes.length;
|
|
1291
|
+
const nodeInvalidationRatio = invalidatedCount / nodeCount;
|
|
1292
|
+
const requestInvalidationRatio = invalidatedCount / requestCount;
|
|
1285
1293
|
return {
|
|
1286
1294
|
invalidations,
|
|
1287
1295
|
nodeCount,
|
|
1288
1296
|
requestCount,
|
|
1289
1297
|
invalidatedCount,
|
|
1290
|
-
nodeInvalidationRatio
|
|
1291
|
-
requestInvalidationRatio
|
|
1298
|
+
nodeInvalidationRatio,
|
|
1299
|
+
requestInvalidationRatio
|
|
1300
|
+
};
|
|
1301
|
+
}
|
|
1302
|
+
/**
|
|
1303
|
+
* Invalidate the request graph based on file-system events.
|
|
1304
|
+
*
|
|
1305
|
+
* Returns statistics about the invalidations.
|
|
1306
|
+
*/
|
|
1307
|
+
async function invalidateRequestGraphFSEvents(requestGraph, options, events) {
|
|
1308
|
+
const {
|
|
1309
|
+
invalidationsByPath
|
|
1310
|
+
} = await requestGraph.respondToFSEvents(options.unstableFileInvalidations || events, options, 10000, true);
|
|
1311
|
+
const biggestInvalidations = getBiggestFSEventsInvalidations(invalidationsByPath);
|
|
1312
|
+
return {
|
|
1313
|
+
biggestInvalidations
|
|
1292
1314
|
};
|
|
1293
1315
|
}
|
|
1294
|
-
|
|
1295
1316
|
/**
|
|
1296
1317
|
* Runs an invalidation function and reports metrics.
|
|
1297
1318
|
*/
|
|
1298
1319
|
async function runInvalidation(requestGraph, invalidationFn) {
|
|
1299
|
-
const
|
|
1320
|
+
const start = _perf_hooks().performance.now();
|
|
1321
|
+
const startInvalidationCount = requestGraph.getInvalidNodeCount();
|
|
1300
1322
|
const result = await invalidationFn.fn();
|
|
1301
|
-
const count = requestGraph.
|
|
1323
|
+
const count = requestGraph.getInvalidNodeCount() - startInvalidationCount;
|
|
1324
|
+
const duration = _perf_hooks().performance.now() - start;
|
|
1302
1325
|
return {
|
|
1303
1326
|
key: invalidationFn.key,
|
|
1304
1327
|
count,
|
|
1305
|
-
|
|
1328
|
+
detail: result ?? null,
|
|
1329
|
+
duration
|
|
1306
1330
|
};
|
|
1307
1331
|
}
|
|
1308
1332
|
function logErrorOnBailout(options, snapshotPath, e) {
|
|
@@ -1344,4 +1368,19 @@ function cleanUpOrphans(graph) {
|
|
|
1344
1368
|
}
|
|
1345
1369
|
});
|
|
1346
1370
|
return removedNodeIds;
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1373
|
+
/**
|
|
1374
|
+
* Returns paths that invalidated the most nodes
|
|
1375
|
+
*/
|
|
1376
|
+
function getBiggestFSEventsInvalidations(invalidationsByPath, limit = 10) {
|
|
1377
|
+
const invalidations = [];
|
|
1378
|
+
for (const [path, count] of invalidationsByPath) {
|
|
1379
|
+
invalidations.push({
|
|
1380
|
+
path,
|
|
1381
|
+
count
|
|
1382
|
+
});
|
|
1383
|
+
}
|
|
1384
|
+
invalidations.sort((a, b) => b.count - a.count);
|
|
1385
|
+
return invalidations.slice(0, limit);
|
|
1347
1386
|
}
|