@atlaspack/core 2.16.2-canary.27 → 2.16.2-canary.270
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 +665 -0
- package/dist/AssetGraph.js +591 -0
- package/dist/Atlaspack.js +658 -0
- package/dist/AtlaspackConfig.js +324 -0
- package/dist/AtlaspackConfig.schema.js +108 -0
- package/dist/BundleGraph.js +1635 -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 +545 -0
- package/dist/ReporterRunner.js +151 -0
- package/dist/RequestTracker.js +1360 -0
- package/dist/SymbolPropagation.js +620 -0
- package/dist/TargetDescriptor.schema.js +143 -0
- package/dist/Transformation.js +490 -0
- package/dist/UncommittedAsset.js +315 -0
- package/dist/Validation.js +196 -0
- package/dist/applyRuntimes.js +305 -0
- package/dist/assetUtils.js +168 -0
- package/dist/atlaspack-v3/AtlaspackV3.js +70 -0
- package/dist/atlaspack-v3/NapiWorkerPool.js +57 -0
- package/dist/atlaspack-v3/fs.js +52 -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 +94 -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 +25 -0
- package/dist/atlaspack-v3/worker/compat/mutable-asset.js +152 -0
- package/dist/atlaspack-v3/worker/compat/plugin-config.js +76 -0
- package/dist/atlaspack-v3/worker/compat/plugin-logger.js +26 -0
- package/dist/atlaspack-v3/worker/compat/plugin-options.js +122 -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/worker.js +297 -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 +359 -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 +429 -0
- package/dist/requests/AssetGraphRequestRust.js +262 -0
- package/dist/requests/AssetRequest.js +130 -0
- package/dist/requests/AtlaspackBuildRequest.js +65 -0
- package/dist/requests/AtlaspackConfigRequest.js +493 -0
- package/dist/requests/BundleGraphRequest.js +445 -0
- package/dist/requests/ConfigRequest.js +222 -0
- package/dist/requests/DevDepRequest.js +204 -0
- package/dist/requests/EntryRequest.js +314 -0
- package/dist/requests/PackageRequest.js +62 -0
- package/dist/requests/PathRequest.js +349 -0
- package/dist/requests/TargetRequest.js +1311 -0
- package/dist/requests/ValidationRequest.js +49 -0
- package/dist/requests/WriteBundleRequest.js +254 -0
- package/dist/requests/WriteBundlesRequest.js +184 -0
- package/dist/requests/asset-graph-diff.js +128 -0
- package/dist/requests/asset-graph-dot.js +131 -0
- package/dist/resolveOptions.js +268 -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 +111 -14
- package/lib/Atlaspack.js +81 -37
- package/lib/AtlaspackConfig.js +15 -3
- package/lib/AtlaspackConfig.schema.js +7 -5
- package/lib/BundleGraph.js +90 -32
- package/lib/CommittedAsset.js +6 -0
- package/lib/Dependency.js +8 -2
- package/lib/Environment.js +15 -8
- package/lib/EnvironmentManager.js +143 -0
- package/lib/IdentifierRegistry.js +1 -3
- package/lib/InternalConfig.js +3 -2
- package/lib/PackagerRunner.js +90 -27
- package/lib/ReporterRunner.js +6 -9
- package/lib/RequestTracker.js +266 -156
- package/lib/SymbolPropagation.js +42 -18
- package/lib/TargetDescriptor.schema.js +7 -1
- package/lib/Transformation.js +26 -10
- package/lib/UncommittedAsset.js +30 -9
- package/lib/Validation.js +18 -2
- package/lib/applyRuntimes.js +9 -1
- package/lib/assetUtils.js +7 -4
- package/lib/atlaspack-v3/AtlaspackV3.js +32 -7
- package/lib/atlaspack-v3/NapiWorkerPool.js +3 -0
- package/lib/atlaspack-v3/fs.js +3 -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 +7 -6
- package/lib/atlaspack-v3/worker/compat/dependency.js +3 -0
- package/lib/atlaspack-v3/worker/compat/environment.js +10 -7
- package/lib/atlaspack-v3/worker/compat/mutable-asset.js +14 -9
- package/lib/atlaspack-v3/worker/compat/plugin-config.js +8 -10
- package/lib/atlaspack-v3/worker/compat/plugin-options.js +1 -0
- 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/worker.js +43 -7
- package/lib/constants.js +0 -1
- package/lib/dumpGraphToGraphViz.js +71 -16
- package/lib/index.js +45 -1
- package/lib/loadDotEnv.js +4 -1
- package/lib/projectPath.js +5 -0
- package/lib/public/Asset.js +21 -11
- package/lib/public/Bundle.js +15 -16
- package/lib/public/BundleGraph.js +10 -4
- package/lib/public/BundleGroup.js +4 -5
- package/lib/public/Config.js +118 -17
- package/lib/public/Dependency.js +8 -6
- package/lib/public/Environment.js +12 -7
- package/lib/public/MutableBundleGraph.js +54 -12
- package/lib/public/PluginOptions.js +2 -2
- package/lib/public/Symbols.js +11 -11
- package/lib/public/Target.js +7 -6
- package/lib/registerCoreWithSerializer.js +5 -3
- package/lib/requests/AssetGraphRequest.js +42 -5
- package/lib/requests/AssetGraphRequestRust.js +126 -62
- package/lib/requests/AssetRequest.js +23 -6
- package/lib/requests/AtlaspackBuildRequest.js +10 -4
- package/lib/requests/AtlaspackConfigRequest.js +27 -16
- package/lib/requests/BundleGraphRequest.js +34 -19
- package/lib/requests/ConfigRequest.js +28 -4
- package/lib/requests/DevDepRequest.js +31 -5
- package/lib/requests/EntryRequest.js +2 -0
- package/lib/requests/PackageRequest.js +2 -1
- package/lib/requests/PathRequest.js +24 -3
- package/lib/requests/TargetRequest.js +122 -57
- package/lib/requests/ValidationRequest.js +5 -1
- package/lib/requests/WriteBundleRequest.js +39 -11
- package/lib/requests/WriteBundlesRequest.js +51 -4
- package/lib/requests/asset-graph-diff.js +12 -7
- package/lib/requests/asset-graph-dot.js +1 -7
- package/lib/resolveOptions.js +36 -10
- package/lib/rustWorkerThreadDylibHack.js +0 -1
- package/lib/types/AssetGraph.d.ts +80 -0
- package/lib/types/Atlaspack.d.ts +52 -0
- package/lib/types/AtlaspackConfig.d.ts +65 -0
- package/lib/types/AtlaspackConfig.schema.d.ts +46 -0
- package/lib/types/BundleGraph.d.ts +182 -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 +24 -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 +26 -0
- package/lib/types/atlaspack-v3/NapiWorkerPool.d.ts +12 -0
- package/lib/types/atlaspack-v3/fs.d.ts +12 -0
- package/lib/types/atlaspack-v3/index.d.ts +5 -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 +15 -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 -1
- package/lib/types/atlaspack-v3/worker/compat/mutable-asset.d.ts +49 -0
- package/lib/types/atlaspack-v3/worker/compat/plugin-config.d.ts +37 -0
- package/lib/types/atlaspack-v3/worker/compat/plugin-logger.d.ts +9 -0
- package/lib/types/atlaspack-v3/worker/compat/plugin-options.d.ts +22 -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/worker.d.ts +60 -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 +70 -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 +74 -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/ConfigRequest.d.ts +59 -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 +28 -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 +493 -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 +17 -2
- package/lib/worker.js +29 -13
- package/package.json +24 -34
- package/src/{AssetGraph.js → AssetGraph.ts} +156 -52
- package/src/{Atlaspack.js → Atlaspack.ts} +114 -61
- package/src/{AtlaspackConfig.schema.js → AtlaspackConfig.schema.ts} +16 -19
- package/src/{AtlaspackConfig.js → AtlaspackConfig.ts} +78 -54
- package/src/{BundleGraph.js → BundleGraph.ts} +231 -140
- package/src/{CommittedAsset.js → CommittedAsset.ts} +14 -12
- 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} +178 -86
- package/src/{ReporterRunner.js → ReporterRunner.ts} +13 -18
- package/src/{RequestTracker.js → RequestTracker.ts} +572 -357
- package/src/{SymbolPropagation.js → SymbolPropagation.ts} +165 -57
- package/src/{TargetDescriptor.schema.js → TargetDescriptor.schema.ts} +7 -1
- package/src/{Transformation.js → Transformation.ts} +71 -62
- package/src/{UncommittedAsset.js → UncommittedAsset.ts} +57 -36
- package/src/{Validation.js → Validation.ts} +32 -17
- package/src/{applyRuntimes.js → applyRuntimes.ts} +35 -26
- package/src/{assetUtils.js → assetUtils.ts} +47 -35
- package/src/atlaspack-v3/AtlaspackV3.ts +122 -0
- package/src/atlaspack-v3/{NapiWorkerPool.js → NapiWorkerPool.ts} +10 -5
- package/src/atlaspack-v3/{fs.js → fs.ts} +3 -4
- package/src/atlaspack-v3/{index.js → index.ts} +2 -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.js → bitflags.ts} +9 -10
- package/src/atlaspack-v3/worker/compat/{dependency.js → dependency.ts} +12 -12
- package/src/atlaspack-v3/worker/compat/{environment.js → environment.ts} +13 -9
- package/src/atlaspack-v3/worker/compat/index.ts +9 -0
- package/src/atlaspack-v3/worker/compat/{mutable-asset.js → mutable-asset.ts} +20 -19
- package/src/atlaspack-v3/worker/compat/{plugin-config.js → plugin-config.ts} +27 -26
- package/src/atlaspack-v3/worker/compat/{plugin-logger.js → plugin-logger.ts} +0 -2
- package/src/atlaspack-v3/worker/compat/{plugin-options.js → plugin-options.ts} +4 -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/{worker.js → worker.ts} +102 -66
- 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} +40 -27
- package/src/public/{Bundle.js → Bundle.ts} +28 -29
- package/src/public/{BundleGraph.js → BundleGraph.ts} +81 -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} +84 -49
- package/src/requests/AssetGraphRequestRust.ts +352 -0
- package/src/requests/{AssetRequest.js → AssetRequest.ts} +24 -18
- package/src/requests/{AtlaspackBuildRequest.js → AtlaspackBuildRequest.ts} +46 -32
- package/src/requests/{AtlaspackConfigRequest.js → AtlaspackConfigRequest.ts} +72 -58
- package/src/requests/{BundleGraphRequest.js → BundleGraphRequest.ts} +71 -58
- package/src/requests/{ConfigRequest.js → ConfigRequest.ts} +71 -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} +20 -22
- package/src/requests/{PathRequest.js → PathRequest.ts} +47 -37
- package/src/requests/{TargetRequest.js → TargetRequest.ts} +260 -179
- package/src/requests/{ValidationRequest.js → ValidationRequest.ts} +18 -17
- package/src/requests/{WriteBundleRequest.js → WriteBundleRequest.ts} +77 -49
- package/src/requests/{WriteBundlesRequest.js → WriteBundlesRequest.ts} +109 -37
- 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} +56 -24
- 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 +647 -0
- package/src/{utils.js → utils.ts} +52 -21
- package/src/{worker.js → worker.ts} +49 -41
- package/test/{AssetGraph.test.js → AssetGraph.test.ts} +37 -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} +75 -15
- 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} +314 -59
- package/test/{SymbolPropagation.test.js → SymbolPropagation.test.ts} +124 -74
- package/test/{TargetRequest.test.js → TargetRequest.test.ts} +66 -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.js → AssetGraphRequestRust.test.ts} +164 -134
- package/test/requests/{ConfigRequest.test.js → ConfigRequest.test.ts} +202 -13
- package/test/requests/{DevDepRequest.test.js → DevDepRequest.test.ts} +0 -2
- package/test/{test-utils.js → test-utils.ts} +4 -11
- package/test/{utils.test.js → utils.test.ts} +1 -3
- package/tsconfig.json +57 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/index.d.ts +0 -30
- package/src/atlaspack-v3/AtlaspackV3.js +0 -87
- package/src/atlaspack-v3/jsCallable.js +0 -18
- package/src/index.js +0 -13
- package/src/requests/AssetGraphRequestRust.js +0 -263
- 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
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// @flow strict-local
|
|
2
|
-
|
|
3
1
|
import type {
|
|
4
2
|
FilePath,
|
|
5
3
|
GenerateOutput,
|
|
@@ -31,7 +29,7 @@ import ThrowableDiagnostic, {
|
|
|
31
29
|
errorToDiagnostic,
|
|
32
30
|
escapeMarkdown,
|
|
33
31
|
md,
|
|
34
|
-
|
|
32
|
+
Diagnostic,
|
|
35
33
|
} from '@atlaspack/diagnostic';
|
|
36
34
|
import {SOURCEMAP_EXTENSIONS} from '@atlaspack/utils';
|
|
37
35
|
|
|
@@ -48,12 +46,13 @@ import UncommittedAsset from './UncommittedAsset';
|
|
|
48
46
|
import {createAsset} from './assetUtils';
|
|
49
47
|
import summarizeRequest from './summarizeRequest';
|
|
50
48
|
import PluginOptions from './public/PluginOptions';
|
|
49
|
+
import {fromEnvironmentId} from './EnvironmentManager';
|
|
51
50
|
import {optionsProxy} from './utils';
|
|
52
51
|
import {createConfig} from './InternalConfig';
|
|
53
52
|
import {
|
|
54
53
|
loadPluginConfig,
|
|
55
54
|
getConfigRequests,
|
|
56
|
-
|
|
55
|
+
ConfigRequest,
|
|
57
56
|
} from './requests/ConfigRequest';
|
|
58
57
|
import {
|
|
59
58
|
createDevDependency,
|
|
@@ -61,7 +60,7 @@ import {
|
|
|
61
60
|
getWorkerDevDepRequests,
|
|
62
61
|
} from './requests/DevDepRequest';
|
|
63
62
|
import {
|
|
64
|
-
|
|
63
|
+
ProjectPath,
|
|
65
64
|
fromProjectPath,
|
|
66
65
|
fromProjectPathRelative,
|
|
67
66
|
toProjectPathUnsafe,
|
|
@@ -70,27 +69,28 @@ import {
|
|
|
70
69
|
import {invalidateOnFileCreateToInternal, createInvalidations} from './utils';
|
|
71
70
|
import invariant from 'assert';
|
|
72
71
|
import {tracer, PluginTracer} from '@atlaspack/profiler';
|
|
72
|
+
import {getFeatureFlag} from '@atlaspack/feature-flags';
|
|
73
73
|
|
|
74
74
|
type GenerateFunc = (input: UncommittedAsset) => Promise<GenerateOutput>;
|
|
75
75
|
|
|
76
76
|
type PostProcessFunc = (
|
|
77
|
-
Array<UncommittedAsset>,
|
|
77
|
+
arg1: Array<UncommittedAsset>,
|
|
78
78
|
) => Promise<Array<UncommittedAsset> | null>;
|
|
79
79
|
|
|
80
|
-
export type TransformationOpts = {
|
|
81
|
-
options: AtlaspackOptions
|
|
82
|
-
config: AtlaspackConfig
|
|
83
|
-
request: TransformationRequest
|
|
84
|
-
workerApi: WorkerApi
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
export type TransformationResult = {
|
|
88
|
-
assets?: Array<AssetValue
|
|
89
|
-
error?: Array<Diagnostic
|
|
90
|
-
configRequests: Array<ConfigRequest
|
|
91
|
-
invalidations: Invalidations
|
|
92
|
-
devDepRequests: Array<DevDepRequest | DevDepRequestRef
|
|
93
|
-
|
|
80
|
+
export type TransformationOpts = {
|
|
81
|
+
options: AtlaspackOptions;
|
|
82
|
+
config: AtlaspackConfig;
|
|
83
|
+
request: TransformationRequest;
|
|
84
|
+
workerApi: WorkerApi;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export type TransformationResult = {
|
|
88
|
+
assets?: Array<AssetValue>;
|
|
89
|
+
error?: Array<Diagnostic>;
|
|
90
|
+
configRequests: Array<ConfigRequest>;
|
|
91
|
+
invalidations: Invalidations;
|
|
92
|
+
devDepRequests: Array<DevDepRequest | DevDepRequestRef>;
|
|
93
|
+
};
|
|
94
94
|
|
|
95
95
|
export default class Transformation {
|
|
96
96
|
request: TransformationRequest;
|
|
@@ -140,7 +140,7 @@ export default class Transformation {
|
|
|
140
140
|
// Load existing sourcemaps, this automatically runs the source contents extraction
|
|
141
141
|
try {
|
|
142
142
|
existing = await asset.loadExistingSourcemap();
|
|
143
|
-
} catch (err) {
|
|
143
|
+
} catch (err: any) {
|
|
144
144
|
logger.verbose([
|
|
145
145
|
{
|
|
146
146
|
origin: '@atlaspack/core',
|
|
@@ -165,7 +165,9 @@ export default class Transformation {
|
|
|
165
165
|
// If no existing sourcemap was found, initialize asset.sourceContent
|
|
166
166
|
// with the original contents. This will be used when the transformer
|
|
167
167
|
// calls setMap to ensure the source content is in the sourcemap.
|
|
168
|
-
|
|
168
|
+
if (!getFeatureFlag('omitSourcesContentInMemory')) {
|
|
169
|
+
asset.sourceContent = await asset.getCode();
|
|
170
|
+
}
|
|
169
171
|
}
|
|
170
172
|
|
|
171
173
|
invalidateDevDeps(
|
|
@@ -175,6 +177,7 @@ export default class Transformation {
|
|
|
175
177
|
);
|
|
176
178
|
|
|
177
179
|
let pipeline = await this.loadPipeline(
|
|
180
|
+
// @ts-expect-error TS2345
|
|
178
181
|
this.request.filePath,
|
|
179
182
|
asset.value.isSource,
|
|
180
183
|
asset.value.pipeline,
|
|
@@ -184,7 +187,7 @@ export default class Transformation {
|
|
|
184
187
|
let results = await this.runPipelines(pipeline, asset);
|
|
185
188
|
await Promise.all(results.map((asset) => asset.commit()));
|
|
186
189
|
assets = results.map((a) => a.value);
|
|
187
|
-
} catch (e) {
|
|
190
|
+
} catch (e: any) {
|
|
188
191
|
error = e;
|
|
189
192
|
}
|
|
190
193
|
|
|
@@ -197,8 +200,8 @@ export default class Transformation {
|
|
|
197
200
|
...this.resolverRunner.devDepRequests.values(),
|
|
198
201
|
]);
|
|
199
202
|
|
|
200
|
-
// $FlowFixMe because of $$raw
|
|
201
203
|
return {
|
|
204
|
+
// @ts-expect-error TS2353
|
|
202
205
|
$$raw: true,
|
|
203
206
|
assets,
|
|
204
207
|
configRequests,
|
|
@@ -224,6 +227,7 @@ export default class Transformation {
|
|
|
224
227
|
size,
|
|
225
228
|
isSource: summarizedIsSource,
|
|
226
229
|
} = await summarizeRequest(this.options.inputFS, {
|
|
230
|
+
// @ts-expect-error TS2322
|
|
227
231
|
filePath: fromProjectPath(this.options.projectRoot, filePath),
|
|
228
232
|
code,
|
|
229
233
|
});
|
|
@@ -234,10 +238,13 @@ export default class Transformation {
|
|
|
234
238
|
return new UncommittedAsset({
|
|
235
239
|
value: createAsset(this.options.projectRoot, {
|
|
236
240
|
code,
|
|
241
|
+
// @ts-expect-error TS2322
|
|
237
242
|
filePath,
|
|
238
243
|
isSource,
|
|
244
|
+
// @ts-expect-error TS2345
|
|
239
245
|
type: path.extname(fromProjectPathRelative(filePath)).slice(1),
|
|
240
246
|
pipeline,
|
|
247
|
+
// @ts-expect-error TS2322
|
|
241
248
|
env,
|
|
242
249
|
query,
|
|
243
250
|
stats: {
|
|
@@ -325,7 +332,7 @@ export default class Transformation {
|
|
|
325
332
|
range,
|
|
326
333
|
},
|
|
327
334
|
);
|
|
328
|
-
} catch (err) {
|
|
335
|
+
} catch (err: any) {
|
|
329
336
|
// ignore
|
|
330
337
|
}
|
|
331
338
|
|
|
@@ -347,8 +354,8 @@ export default class Transformation {
|
|
|
347
354
|
|
|
348
355
|
let initialType = initialAsset.value.type;
|
|
349
356
|
let inputAssets = [initialAsset];
|
|
350
|
-
let resultingAssets = [];
|
|
351
|
-
let finalAssets = [];
|
|
357
|
+
let resultingAssets: Array<UncommittedAsset> = [];
|
|
358
|
+
let finalAssets: Array<UncommittedAsset> = [];
|
|
352
359
|
for (let transformer of pipeline.transformers) {
|
|
353
360
|
resultingAssets = [];
|
|
354
361
|
for (let asset of inputAssets) {
|
|
@@ -399,7 +406,7 @@ export default class Transformation {
|
|
|
399
406
|
),
|
|
400
407
|
);
|
|
401
408
|
}
|
|
402
|
-
} catch (e) {
|
|
409
|
+
} catch (e: any) {
|
|
403
410
|
let diagnostic = errorToDiagnostic(e, {
|
|
404
411
|
origin: transformer.name,
|
|
405
412
|
filePath: fromProjectPath(
|
|
@@ -466,7 +473,7 @@ export default class Transformation {
|
|
|
466
473
|
async loadPipeline(
|
|
467
474
|
filePath: ProjectPath,
|
|
468
475
|
isSource: boolean,
|
|
469
|
-
pipeline
|
|
476
|
+
pipeline?: string | null,
|
|
470
477
|
): Promise<Pipeline> {
|
|
471
478
|
let transformers = await this.atlaspackConfig.getTransformers(
|
|
472
479
|
filePath,
|
|
@@ -502,13 +509,13 @@ export default class Transformation {
|
|
|
502
509
|
newType,
|
|
503
510
|
newPipeline,
|
|
504
511
|
currentPipeline,
|
|
505
|
-
}: {
|
|
506
|
-
filePath: ProjectPath
|
|
507
|
-
isSource: boolean
|
|
508
|
-
newType: string
|
|
509
|
-
newPipeline:
|
|
510
|
-
currentPipeline: Pipeline
|
|
511
|
-
|
|
512
|
+
}: {
|
|
513
|
+
filePath: ProjectPath;
|
|
514
|
+
isSource: boolean;
|
|
515
|
+
newType: string;
|
|
516
|
+
newPipeline: string | null | undefined;
|
|
517
|
+
currentPipeline: Pipeline;
|
|
518
|
+
}): Promise<Pipeline | null | undefined> {
|
|
512
519
|
let filePathRelative = fromProjectPathRelative(filePath);
|
|
513
520
|
let nextFilePath = toProjectPathUnsafe(
|
|
514
521
|
filePathRelative.slice(0, -path.extname(filePathRelative).length) +
|
|
@@ -529,9 +536,9 @@ export default class Transformation {
|
|
|
529
536
|
}
|
|
530
537
|
|
|
531
538
|
async loadTransformerConfig(
|
|
532
|
-
transformer: LoadedPlugin<Transformer<
|
|
539
|
+
transformer: LoadedPlugin<Transformer<unknown>>,
|
|
533
540
|
isSource: boolean,
|
|
534
|
-
): Promise
|
|
541
|
+
): Promise<Config | null | undefined> {
|
|
535
542
|
let loadConfig = transformer.plugin.loadConfig;
|
|
536
543
|
if (!loadConfig) {
|
|
537
544
|
return;
|
|
@@ -540,6 +547,7 @@ export default class Transformation {
|
|
|
540
547
|
let config = createConfig({
|
|
541
548
|
plugin: transformer.name,
|
|
542
549
|
isSource,
|
|
550
|
+
// @ts-expect-error TS2322
|
|
543
551
|
searchPath: this.request.filePath,
|
|
544
552
|
env: this.request.env,
|
|
545
553
|
});
|
|
@@ -556,12 +564,12 @@ export default class Transformation {
|
|
|
556
564
|
async runTransformer(
|
|
557
565
|
pipeline: Pipeline,
|
|
558
566
|
asset: UncommittedAsset,
|
|
559
|
-
transformer: Transformer<
|
|
567
|
+
transformer: Transformer<unknown>,
|
|
560
568
|
transformerName: string,
|
|
561
|
-
preloadedConfig:
|
|
562
|
-
configKeyPath
|
|
569
|
+
preloadedConfig: Config | null | undefined,
|
|
570
|
+
configKeyPath: string | null | undefined,
|
|
563
571
|
atlaspackConfig: AtlaspackConfig,
|
|
564
|
-
): Promise
|
|
572
|
+
): Promise<ReadonlyArray<TransformerResult | UncommittedAsset>> {
|
|
565
573
|
const logger = new PluginLogger({origin: transformerName});
|
|
566
574
|
const tracer = new PluginTracer({
|
|
567
575
|
origin: transformerName,
|
|
@@ -603,6 +611,7 @@ export default class Transformation {
|
|
|
603
611
|
throw new ThrowableDiagnostic({diagnostic: result.diagnostics});
|
|
604
612
|
}
|
|
605
613
|
|
|
614
|
+
// @ts-expect-error TS2322
|
|
606
615
|
return fromProjectPath(
|
|
607
616
|
this.options.projectRoot,
|
|
608
617
|
nullthrows(result.assetGroup).filePath,
|
|
@@ -649,8 +658,8 @@ export default class Transformation {
|
|
|
649
658
|
}
|
|
650
659
|
|
|
651
660
|
// Transform.
|
|
661
|
+
// @ts-expect-error TS2322
|
|
652
662
|
let transfomerResult: Array<TransformerResult | MutableAsset> =
|
|
653
|
-
// $FlowFixMe the returned IMutableAsset really is a MutableAsset
|
|
654
663
|
await transformer.transform({
|
|
655
664
|
asset: new MutableAsset(asset),
|
|
656
665
|
config,
|
|
@@ -712,27 +721,27 @@ export default class Transformation {
|
|
|
712
721
|
}
|
|
713
722
|
}
|
|
714
723
|
|
|
715
|
-
type Pipeline = {
|
|
716
|
-
id: string
|
|
717
|
-
transformers: Array<TransformerWithNameAndConfig
|
|
718
|
-
options: AtlaspackOptions
|
|
719
|
-
pluginOptions: PluginOptions
|
|
720
|
-
workerApi: WorkerApi
|
|
721
|
-
postProcess?: PostProcessFunc
|
|
722
|
-
generate?: GenerateFunc
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
type TransformerWithNameAndConfig = {
|
|
726
|
-
name: PackageName
|
|
727
|
-
plugin: Transformer<
|
|
728
|
-
config:
|
|
729
|
-
configKeyPath?: string
|
|
730
|
-
resolveFrom: ProjectPath
|
|
731
|
-
range?:
|
|
732
|
-
|
|
724
|
+
type Pipeline = {
|
|
725
|
+
id: string;
|
|
726
|
+
transformers: Array<TransformerWithNameAndConfig>;
|
|
727
|
+
options: AtlaspackOptions;
|
|
728
|
+
pluginOptions: PluginOptions;
|
|
729
|
+
workerApi: WorkerApi;
|
|
730
|
+
postProcess?: PostProcessFunc;
|
|
731
|
+
generate?: GenerateFunc;
|
|
732
|
+
};
|
|
733
|
+
|
|
734
|
+
type TransformerWithNameAndConfig = {
|
|
735
|
+
name: PackageName;
|
|
736
|
+
plugin: Transformer<unknown>;
|
|
737
|
+
config: Config | null | undefined;
|
|
738
|
+
configKeyPath?: string;
|
|
739
|
+
resolveFrom: ProjectPath;
|
|
740
|
+
range?: SemverRange | null | undefined;
|
|
741
|
+
};
|
|
733
742
|
|
|
734
743
|
function normalizeAssets(
|
|
735
|
-
options,
|
|
744
|
+
options: AtlaspackOptions,
|
|
736
745
|
results: Array<TransformerResult | MutableAsset>,
|
|
737
746
|
): Array<TransformerResult | UncommittedAsset> {
|
|
738
747
|
return results.map((result) => {
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// @flow strict-local
|
|
2
|
-
|
|
3
1
|
import type {
|
|
4
2
|
AST,
|
|
5
3
|
Blob,
|
|
@@ -30,31 +28,37 @@ import {ATLASPACK_VERSION} from './constants';
|
|
|
30
28
|
import {createAsset, createAssetIdFromOptions} from './assetUtils';
|
|
31
29
|
import {BundleBehaviorNames} from './types';
|
|
32
30
|
import {invalidateOnFileCreateToInternal, createInvalidations} from './utils';
|
|
33
|
-
import {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
|
31
|
+
import {
|
|
32
|
+
ProjectPath,
|
|
33
|
+
fromProjectPath,
|
|
34
|
+
fromProjectPathRelative,
|
|
35
|
+
} from './projectPath';
|
|
36
|
+
import {getFeatureFlag} from '@atlaspack/feature-flags';
|
|
37
|
+
import {fromEnvironmentId} from './EnvironmentManager';
|
|
38
|
+
|
|
39
|
+
type UncommittedAssetOptions = {
|
|
40
|
+
value: Asset;
|
|
41
|
+
options: AtlaspackOptions;
|
|
42
|
+
content?: Blob | null | undefined;
|
|
43
|
+
mapBuffer?: Buffer | null | undefined;
|
|
44
|
+
ast?: AST | null | undefined;
|
|
45
|
+
isASTDirty?: boolean | null | undefined;
|
|
46
|
+
code?: string | null | undefined;
|
|
47
|
+
invalidations?: Invalidations;
|
|
48
|
+
};
|
|
45
49
|
|
|
46
50
|
export default class UncommittedAsset {
|
|
47
51
|
value: Asset;
|
|
48
52
|
options: AtlaspackOptions;
|
|
49
|
-
content:
|
|
50
|
-
mapBuffer:
|
|
51
|
-
sourceContent:
|
|
52
|
-
map:
|
|
53
|
-
ast:
|
|
53
|
+
content: Blob | Promise<Buffer> | null | undefined;
|
|
54
|
+
mapBuffer: Buffer | null | undefined;
|
|
55
|
+
sourceContent: string | null | undefined;
|
|
56
|
+
map: SourceMap | null | undefined;
|
|
57
|
+
ast: AST | null | undefined;
|
|
54
58
|
isASTDirty: boolean;
|
|
55
|
-
code:
|
|
59
|
+
code: string | null | undefined;
|
|
56
60
|
invalidations: Invalidations;
|
|
57
|
-
generate:
|
|
61
|
+
generate: (() => Promise<GenerateOutput>) | null | undefined;
|
|
58
62
|
|
|
59
63
|
constructor({
|
|
60
64
|
value,
|
|
@@ -120,9 +124,10 @@ export default class UncommittedAsset {
|
|
|
120
124
|
this.value.committed = true;
|
|
121
125
|
}
|
|
122
126
|
|
|
123
|
-
async commitContent(
|
|
124
|
-
|
|
125
|
-
|
|
127
|
+
async commitContent(contentKey: string): Promise<{
|
|
128
|
+
size: number;
|
|
129
|
+
hash: string;
|
|
130
|
+
}> {
|
|
126
131
|
let content = await this.content;
|
|
127
132
|
if (content == null) {
|
|
128
133
|
return {size: 0, hash: ''};
|
|
@@ -134,7 +139,8 @@ export default class UncommittedAsset {
|
|
|
134
139
|
await this.options.cache.setStream(
|
|
135
140
|
contentKey,
|
|
136
141
|
content.pipe(
|
|
137
|
-
|
|
142
|
+
// @ts-expect-error TS2554
|
|
143
|
+
new TapStream((buf: Buffer) => {
|
|
138
144
|
hash.writeBuffer(buf);
|
|
139
145
|
size += buf.length;
|
|
140
146
|
}),
|
|
@@ -153,7 +159,9 @@ export default class UncommittedAsset {
|
|
|
153
159
|
size = content.length;
|
|
154
160
|
}
|
|
155
161
|
|
|
162
|
+
// Maybe we should just store this in a file instead of LMDB
|
|
156
163
|
await this.options.cache.setBlob(contentKey, content);
|
|
164
|
+
|
|
157
165
|
return {size, hash};
|
|
158
166
|
}
|
|
159
167
|
|
|
@@ -168,6 +176,7 @@ export default class UncommittedAsset {
|
|
|
168
176
|
if (typeof content === 'string' || content instanceof Buffer) {
|
|
169
177
|
return content.toString();
|
|
170
178
|
} else if (content != null) {
|
|
179
|
+
// @ts-expect-error TS2345
|
|
171
180
|
this.content = bufferStream(content);
|
|
172
181
|
return (await this.content).toString();
|
|
173
182
|
}
|
|
@@ -185,6 +194,7 @@ export default class UncommittedAsset {
|
|
|
185
194
|
return Buffer.from(content);
|
|
186
195
|
}
|
|
187
196
|
|
|
197
|
+
// @ts-expect-error TS2345
|
|
188
198
|
this.content = bufferStream(content);
|
|
189
199
|
return this.content;
|
|
190
200
|
}
|
|
@@ -214,12 +224,15 @@ export default class UncommittedAsset {
|
|
|
214
224
|
this.clearAST();
|
|
215
225
|
}
|
|
216
226
|
|
|
227
|
+
/**
|
|
228
|
+
* @deprecated This has been broken on any cache other than FSCache for a long time.
|
|
229
|
+
*/
|
|
217
230
|
setStream(stream: Readable) {
|
|
218
231
|
this.content = stream;
|
|
219
232
|
this.clearAST();
|
|
220
233
|
}
|
|
221
234
|
|
|
222
|
-
async loadExistingSourcemap(): Promise
|
|
235
|
+
async loadExistingSourcemap(): Promise<SourceMap | null | undefined> {
|
|
223
236
|
if (this.map) {
|
|
224
237
|
return this.map;
|
|
225
238
|
}
|
|
@@ -243,11 +256,11 @@ export default class UncommittedAsset {
|
|
|
243
256
|
return this.map;
|
|
244
257
|
}
|
|
245
258
|
|
|
246
|
-
getMapBuffer(): Promise
|
|
259
|
+
getMapBuffer(): Promise<Buffer | null | undefined> {
|
|
247
260
|
return Promise.resolve(this.mapBuffer);
|
|
248
261
|
}
|
|
249
262
|
|
|
250
|
-
async getMap(): Promise
|
|
263
|
+
async getMap(): Promise<SourceMap | null | undefined> {
|
|
251
264
|
if (this.map == null) {
|
|
252
265
|
let mapBuffer = this.mapBuffer ?? (await this.getMapBuffer());
|
|
253
266
|
if (mapBuffer) {
|
|
@@ -259,14 +272,13 @@ export default class UncommittedAsset {
|
|
|
259
272
|
return this.map;
|
|
260
273
|
}
|
|
261
274
|
|
|
262
|
-
setMap(map
|
|
275
|
+
setMap(map?: SourceMap | null): void {
|
|
263
276
|
// If we have sourceContent available, it means this asset is source code without
|
|
264
277
|
// a previous source map. Ensure that the map set by the transformer has the original
|
|
265
278
|
// source content available.
|
|
266
279
|
if (map != null && this.sourceContent != null) {
|
|
267
280
|
map.setSourceContent(
|
|
268
281
|
fromProjectPath(this.options.projectRoot, this.value.filePath),
|
|
269
|
-
// $FlowFixMe
|
|
270
282
|
this.sourceContent,
|
|
271
283
|
);
|
|
272
284
|
this.sourceContent = null;
|
|
@@ -276,7 +288,7 @@ export default class UncommittedAsset {
|
|
|
276
288
|
this.mapBuffer = this.map?.toBuffer();
|
|
277
289
|
}
|
|
278
290
|
|
|
279
|
-
getAST(): Promise
|
|
291
|
+
getAST(): Promise<AST | null | undefined> {
|
|
280
292
|
return Promise.resolve(this.ast);
|
|
281
293
|
}
|
|
282
294
|
|
|
@@ -296,6 +308,11 @@ export default class UncommittedAsset {
|
|
|
296
308
|
}
|
|
297
309
|
|
|
298
310
|
getCacheKey(key: string): string {
|
|
311
|
+
if (getFeatureFlag('cachePerformanceImprovements')) {
|
|
312
|
+
const filePath = fromProjectPathRelative(this.value.filePath);
|
|
313
|
+
return `Asset/${ATLASPACK_VERSION}/${filePath}/${this.value.id}/${key}`;
|
|
314
|
+
}
|
|
315
|
+
|
|
299
316
|
return hashString(ATLASPACK_VERSION + key + this.value.id);
|
|
300
317
|
}
|
|
301
318
|
|
|
@@ -304,9 +321,13 @@ export default class UncommittedAsset {
|
|
|
304
321
|
let {env, symbols, ...rest} = opts;
|
|
305
322
|
let dep = createDependency(this.options.projectRoot, {
|
|
306
323
|
...rest,
|
|
307
|
-
//
|
|
324
|
+
// @ts-expect-error TS2322
|
|
308
325
|
symbols,
|
|
309
|
-
env: mergeEnvironments(
|
|
326
|
+
env: mergeEnvironments(
|
|
327
|
+
this.options.projectRoot,
|
|
328
|
+
fromEnvironmentId(this.value.env),
|
|
329
|
+
env,
|
|
330
|
+
),
|
|
310
331
|
sourceAssetId: this.value.id,
|
|
311
332
|
sourcePath: fromProjectPath(
|
|
312
333
|
this.options.projectRoot,
|
|
@@ -371,7 +392,7 @@ export default class UncommittedAsset {
|
|
|
371
392
|
isSource: this.value.isSource,
|
|
372
393
|
env: mergeEnvironments(
|
|
373
394
|
this.options.projectRoot,
|
|
374
|
-
this.value.env,
|
|
395
|
+
fromEnvironmentId(this.value.env),
|
|
375
396
|
result.env,
|
|
376
397
|
),
|
|
377
398
|
dependencies:
|
|
@@ -389,7 +410,7 @@ export default class UncommittedAsset {
|
|
|
389
410
|
time: 0,
|
|
390
411
|
size: this.value.stats.size,
|
|
391
412
|
},
|
|
392
|
-
//
|
|
413
|
+
// @ts-expect-error TS2322
|
|
393
414
|
symbols: result.symbols,
|
|
394
415
|
sideEffects: result.sideEffects ?? this.value.sideEffects,
|
|
395
416
|
uniqueKey: result.uniqueKey,
|
|
@@ -420,7 +441,7 @@ export default class UncommittedAsset {
|
|
|
420
441
|
}
|
|
421
442
|
|
|
422
443
|
updateId() {
|
|
423
|
-
//
|
|
444
|
+
// @ts-expect-error TS2345
|
|
424
445
|
this.value.id = createAssetIdFromOptions(this.value);
|
|
425
446
|
}
|
|
426
447
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// @flow strict-local
|
|
2
|
-
|
|
3
1
|
import type {WorkerApi} from '@atlaspack/workers';
|
|
4
2
|
import type {AssetGroup, AtlaspackOptions, ReportFn} from './types';
|
|
5
3
|
import type {Validator, ValidateResult} from '@atlaspack/types';
|
|
@@ -18,29 +16,34 @@ import summarizeRequest from './summarizeRequest';
|
|
|
18
16
|
import {fromProjectPath, fromProjectPathRelative} from './projectPath';
|
|
19
17
|
import {PluginTracer} from '@atlaspack/profiler';
|
|
20
18
|
|
|
21
|
-
export type ValidationOpts = {
|
|
22
|
-
config: AtlaspackConfig
|
|
19
|
+
export type ValidationOpts = {
|
|
20
|
+
config: AtlaspackConfig;
|
|
23
21
|
/**
|
|
24
22
|
* If true, this Validation instance will run all validators that implement the single-threaded "validateAll" method.
|
|
25
23
|
* If falsy, it will run validators that implement the one-asset-at-a-time "validate" method.
|
|
26
24
|
*/
|
|
27
|
-
dedicatedThread?: boolean
|
|
28
|
-
options: AtlaspackOptions
|
|
29
|
-
requests: AssetGroup[]
|
|
30
|
-
report: ReportFn
|
|
31
|
-
workerApi?: WorkerApi
|
|
32
|
-
|
|
25
|
+
dedicatedThread?: boolean;
|
|
26
|
+
options: AtlaspackOptions;
|
|
27
|
+
requests: AssetGroup[];
|
|
28
|
+
report: ReportFn;
|
|
29
|
+
workerApi?: WorkerApi;
|
|
30
|
+
};
|
|
33
31
|
|
|
34
32
|
export default class Validation {
|
|
35
|
-
allAssets: {
|
|
36
|
-
|
|
33
|
+
allAssets: {
|
|
34
|
+
[validatorName: string]: UncommittedAsset[];
|
|
35
|
+
} = {};
|
|
36
|
+
allValidators: {
|
|
37
|
+
[validatorName: string]: Validator;
|
|
38
|
+
} = {};
|
|
37
39
|
dedicatedThread: boolean;
|
|
38
|
-
|
|
40
|
+
// @ts-expect-error TS2564
|
|
41
|
+
impactfulOptions: Partial<AtlaspackOptions>;
|
|
39
42
|
options: AtlaspackOptions;
|
|
40
43
|
atlaspackConfig: AtlaspackConfig;
|
|
41
44
|
report: ReportFn;
|
|
42
45
|
requests: AssetGroup[];
|
|
43
|
-
workerApi:
|
|
46
|
+
workerApi: WorkerApi | null | undefined;
|
|
44
47
|
|
|
45
48
|
constructor({
|
|
46
49
|
config,
|
|
@@ -71,10 +74,12 @@ export default class Validation {
|
|
|
71
74
|
origin: validatorName,
|
|
72
75
|
category: 'validator',
|
|
73
76
|
});
|
|
74
|
-
let validatorResults: Array
|
|
77
|
+
let validatorResults: Array<ValidateResult | null | undefined> = [];
|
|
75
78
|
try {
|
|
76
79
|
// If the plugin supports the single-threading validateAll method, pass all assets to it.
|
|
80
|
+
// @ts-expect-error TS2339
|
|
77
81
|
if (plugin.validateAll && this.dedicatedThread) {
|
|
82
|
+
// @ts-expect-error TS2339
|
|
78
83
|
validatorResults = await plugin.validateAll({
|
|
79
84
|
assets: assets.map((asset) => new Asset(asset)),
|
|
80
85
|
options: pluginOptions,
|
|
@@ -94,12 +99,15 @@ export default class Validation {
|
|
|
94
99
|
}
|
|
95
100
|
|
|
96
101
|
// Otherwise, pass the assets one-at-a-time
|
|
102
|
+
// @ts-expect-error TS2339
|
|
97
103
|
else if (plugin.validate && !this.dedicatedThread) {
|
|
98
104
|
await Promise.all(
|
|
99
105
|
assets.map(async (input) => {
|
|
100
106
|
let config = null;
|
|
101
107
|
let publicAsset = new Asset(input);
|
|
108
|
+
// @ts-expect-error TS2339
|
|
102
109
|
if (plugin.getConfig) {
|
|
110
|
+
// @ts-expect-error TS2339
|
|
103
111
|
config = await plugin.getConfig({
|
|
104
112
|
asset: publicAsset,
|
|
105
113
|
options: pluginOptions,
|
|
@@ -115,6 +123,7 @@ export default class Validation {
|
|
|
115
123
|
});
|
|
116
124
|
}
|
|
117
125
|
|
|
126
|
+
// @ts-expect-error TS2339
|
|
118
127
|
let validatorResult = await plugin.validate({
|
|
119
128
|
asset: publicAsset,
|
|
120
129
|
options: pluginOptions,
|
|
@@ -127,7 +136,7 @@ export default class Validation {
|
|
|
127
136
|
);
|
|
128
137
|
}
|
|
129
138
|
this.handleResults(validatorResults);
|
|
130
|
-
} catch (e) {
|
|
139
|
+
} catch (e: any) {
|
|
131
140
|
throw new ThrowableDiagnostic({
|
|
132
141
|
diagnostic: errorToDiagnostic(e, {
|
|
133
142
|
origin: validatorName,
|
|
@@ -145,12 +154,14 @@ export default class Validation {
|
|
|
145
154
|
this.requests.map(async (request) => {
|
|
146
155
|
this.report({
|
|
147
156
|
type: 'validation',
|
|
157
|
+
// @ts-expect-error TS2322
|
|
148
158
|
filePath: fromProjectPath(this.options.projectRoot, request.filePath),
|
|
149
159
|
});
|
|
150
160
|
|
|
151
161
|
let asset = await this.loadAsset(request);
|
|
152
162
|
|
|
153
163
|
let validators = await this.atlaspackConfig.getValidators(
|
|
164
|
+
// @ts-expect-error TS2345
|
|
154
165
|
request.filePath,
|
|
155
166
|
);
|
|
156
167
|
|
|
@@ -166,7 +177,7 @@ export default class Validation {
|
|
|
166
177
|
);
|
|
167
178
|
}
|
|
168
179
|
|
|
169
|
-
handleResults(validatorResults: Array
|
|
180
|
+
handleResults(validatorResults: Array<ValidateResult | null | undefined>) {
|
|
170
181
|
let warnings: Array<Diagnostic> = [];
|
|
171
182
|
let errors: Array<Diagnostic> = [];
|
|
172
183
|
validatorResults.forEach((result) => {
|
|
@@ -192,6 +203,7 @@ export default class Validation {
|
|
|
192
203
|
let {content, size, isSource} = await summarizeRequest(
|
|
193
204
|
this.options.inputFS,
|
|
194
205
|
{
|
|
206
|
+
// @ts-expect-error TS2322
|
|
195
207
|
filePath: fromProjectPath(this.options.projectRoot, request.filePath),
|
|
196
208
|
},
|
|
197
209
|
);
|
|
@@ -199,10 +211,13 @@ export default class Validation {
|
|
|
199
211
|
return new UncommittedAsset({
|
|
200
212
|
value: createAsset(this.options.projectRoot, {
|
|
201
213
|
code,
|
|
214
|
+
// @ts-expect-error TS2322
|
|
202
215
|
filePath: filePath,
|
|
203
216
|
isSource,
|
|
217
|
+
// @ts-expect-error TS2345
|
|
204
218
|
type: path.extname(fromProjectPathRelative(filePath)).slice(1),
|
|
205
219
|
query,
|
|
220
|
+
// @ts-expect-error TS2322
|
|
206
221
|
env: env,
|
|
207
222
|
stats: {
|
|
208
223
|
time: 0,
|