@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 {Diagnostic} from '@atlaspack/diagnostic';
|
|
4
2
|
import type {FileSystem} from '@atlaspack/fs';
|
|
5
3
|
import type {
|
|
@@ -34,7 +32,6 @@ import {createEnvironment} from '../Environment';
|
|
|
34
32
|
import createAtlaspackConfigRequest, {
|
|
35
33
|
getCachedAtlaspackConfig,
|
|
36
34
|
} from './AtlaspackConfigRequest';
|
|
37
|
-
// $FlowFixMe
|
|
38
35
|
import browserslist from 'browserslist';
|
|
39
36
|
import {parse} from '@mischnic/json-sourcemap';
|
|
40
37
|
import invariant from 'assert';
|
|
@@ -49,11 +46,12 @@ import {BROWSER_ENVS} from '../public/Environment';
|
|
|
49
46
|
import {optionsProxy, toInternalSourceLocation} from '../utils';
|
|
50
47
|
import {fromProjectPath, toProjectPath, joinProjectPath} from '../projectPath';
|
|
51
48
|
import {requestTypes} from '../RequestTracker';
|
|
49
|
+
import {fromEnvironmentId} from '../EnvironmentManager';
|
|
50
|
+
import {getFeatureFlag} from '@atlaspack/feature-flags';
|
|
52
51
|
|
|
53
|
-
type RunOpts<TResult> = {
|
|
54
|
-
input: Entry
|
|
55
|
-
|
|
56
|
-
|};
|
|
52
|
+
type RunOpts<TResult> = {
|
|
53
|
+
input: Entry;
|
|
54
|
+
} & StaticRunOpts<TResult>;
|
|
57
55
|
|
|
58
56
|
const DEFAULT_DIST_DIRNAME = 'dist';
|
|
59
57
|
const JS_RE = /\.[mc]?js$/;
|
|
@@ -76,7 +74,7 @@ const COMMON_TARGETS = {
|
|
|
76
74
|
match: /\.d\.ts$/,
|
|
77
75
|
extensions: ['.d.ts'],
|
|
78
76
|
},
|
|
79
|
-
};
|
|
77
|
+
} as const;
|
|
80
78
|
|
|
81
79
|
const DEFAULT_ENGINES = {
|
|
82
80
|
node: 'current',
|
|
@@ -86,14 +84,14 @@ const DEFAULT_ENGINES = {
|
|
|
86
84
|
'last 1 Firefox version',
|
|
87
85
|
'last 1 Edge version',
|
|
88
86
|
],
|
|
89
|
-
};
|
|
87
|
+
} as const;
|
|
90
88
|
|
|
91
|
-
export type TargetRequest = {
|
|
92
|
-
id: string
|
|
93
|
-
|
|
94
|
-
run: (RunOpts<TargetRequestResult>) => Async<TargetRequestResult
|
|
95
|
-
input: Entry
|
|
96
|
-
|
|
89
|
+
export type TargetRequest = {
|
|
90
|
+
id: string;
|
|
91
|
+
readonly type: typeof requestTypes.target_request;
|
|
92
|
+
run: (arg1: RunOpts<TargetRequestResult>) => Async<TargetRequestResult>;
|
|
93
|
+
input: Entry;
|
|
94
|
+
};
|
|
97
95
|
|
|
98
96
|
export type TargetRequestResult = Target[];
|
|
99
97
|
|
|
@@ -122,7 +120,7 @@ export function skipTarget(
|
|
|
122
120
|
: targetName !== exclusiveTarget;
|
|
123
121
|
}
|
|
124
122
|
|
|
125
|
-
async function run({input, api, options}) {
|
|
123
|
+
async function run({input, api, options}: RunOpts<TargetRequestResult>) {
|
|
126
124
|
let targetResolver = new TargetResolver(
|
|
127
125
|
api,
|
|
128
126
|
optionsProxy(options, api.invalidateOnOptionChange),
|
|
@@ -132,6 +130,47 @@ async function run({input, api, options}) {
|
|
|
132
130
|
input.target,
|
|
133
131
|
);
|
|
134
132
|
|
|
133
|
+
// Filter targets based on allowExplicitTargetEntries feature flag
|
|
134
|
+
if (
|
|
135
|
+
getFeatureFlag('allowExplicitTargetEntries') &&
|
|
136
|
+
options.targets &&
|
|
137
|
+
// Only explicit targets are allowed (i.e. an object of targets)
|
|
138
|
+
!Array.isArray(options.targets)
|
|
139
|
+
) {
|
|
140
|
+
// Check if ALL targets have sources - only apply new behavior if they do
|
|
141
|
+
const allTargetsHaveSources = targets.every((t) => t.source);
|
|
142
|
+
if (allTargetsHaveSources) {
|
|
143
|
+
// Get the current entry file path relative to project root
|
|
144
|
+
const currentEntryPath = input.filePath;
|
|
145
|
+
|
|
146
|
+
// Filter targets to only include those whose source matches the current entry
|
|
147
|
+
targets = targets.filter((target) => {
|
|
148
|
+
// Handle both string and array sources
|
|
149
|
+
const sources = Array.isArray(target.source)
|
|
150
|
+
? target.source
|
|
151
|
+
: [target.source];
|
|
152
|
+
|
|
153
|
+
// Check if current entry matches any of the target sources
|
|
154
|
+
return sources.some((source) => {
|
|
155
|
+
const targetSourcePath = toProjectPath(
|
|
156
|
+
options.projectRoot,
|
|
157
|
+
path.resolve(
|
|
158
|
+
fromProjectPath(options.projectRoot, input.packagePath),
|
|
159
|
+
nullthrows(
|
|
160
|
+
source,
|
|
161
|
+
'Source must be not be undefined when specified',
|
|
162
|
+
),
|
|
163
|
+
),
|
|
164
|
+
);
|
|
165
|
+
return targetSourcePath === currentEntryPath;
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
} else {
|
|
169
|
+
// If not all targets have sources, fall back to old behavior (skip targets with sources)
|
|
170
|
+
targets = targets.filter((target) => !target.source);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
135
174
|
assertTargetsAreNotEntries(targets, input, options);
|
|
136
175
|
|
|
137
176
|
let configResult = nullthrows(
|
|
@@ -161,30 +200,30 @@ async function run({input, api, options}) {
|
|
|
161
200
|
return targets;
|
|
162
201
|
}
|
|
163
202
|
|
|
164
|
-
type TargetInfo = {
|
|
165
|
-
output: TargetKeyInfo
|
|
166
|
-
engines: TargetKeyInfo
|
|
167
|
-
context: TargetKeyInfo
|
|
168
|
-
includeNodeModules: TargetKeyInfo
|
|
169
|
-
outputFormat: TargetKeyInfo
|
|
170
|
-
isLibrary: TargetKeyInfo
|
|
171
|
-
shouldOptimize: TargetKeyInfo
|
|
172
|
-
shouldScopeHoist: TargetKeyInfo
|
|
173
|
-
|
|
203
|
+
type TargetInfo = {
|
|
204
|
+
output: TargetKeyInfo;
|
|
205
|
+
engines: TargetKeyInfo;
|
|
206
|
+
context: TargetKeyInfo;
|
|
207
|
+
includeNodeModules: TargetKeyInfo;
|
|
208
|
+
outputFormat: TargetKeyInfo;
|
|
209
|
+
isLibrary: TargetKeyInfo;
|
|
210
|
+
shouldOptimize: TargetKeyInfo;
|
|
211
|
+
shouldScopeHoist: TargetKeyInfo;
|
|
212
|
+
};
|
|
174
213
|
|
|
175
214
|
type TargetKeyInfo =
|
|
176
|
-
| {
|
|
177
|
-
path: string
|
|
178
|
-
type?: 'key' | 'value'
|
|
179
|
-
|
|
180
|
-
| {
|
|
181
|
-
inferred: string
|
|
182
|
-
type?: 'key' | 'value'
|
|
183
|
-
message: string
|
|
184
|
-
|
|
185
|
-
| {
|
|
186
|
-
message: string
|
|
187
|
-
|
|
215
|
+
| {
|
|
216
|
+
path: string;
|
|
217
|
+
type?: 'key' | 'value';
|
|
218
|
+
}
|
|
219
|
+
| {
|
|
220
|
+
inferred: string;
|
|
221
|
+
type?: 'key' | 'value';
|
|
222
|
+
message: string;
|
|
223
|
+
}
|
|
224
|
+
| {
|
|
225
|
+
message: string;
|
|
226
|
+
};
|
|
188
227
|
|
|
189
228
|
export class TargetResolver {
|
|
190
229
|
fs: FileSystem;
|
|
@@ -231,6 +270,7 @@ export class TargetResolver {
|
|
|
231
270
|
|
|
232
271
|
// If an array of strings is passed, it's a filter on the resolved package
|
|
233
272
|
// targets. Load them, and find the matching targets.
|
|
273
|
+
// @ts-expect-error TS2322
|
|
234
274
|
targets = optionTargets
|
|
235
275
|
.map((target) => {
|
|
236
276
|
// null means skipped.
|
|
@@ -249,7 +289,7 @@ export class TargetResolver {
|
|
|
249
289
|
// Otherwise, it's an object map of target descriptors (similar to those
|
|
250
290
|
// in package.json). Adapt them to native targets.
|
|
251
291
|
targets = Object.entries(optionTargets)
|
|
252
|
-
.map(([name, _descriptor]) => {
|
|
292
|
+
.map(([name, _descriptor]: [any, any]) => {
|
|
253
293
|
let {distDir, ...descriptor} = parseDescriptor(
|
|
254
294
|
name,
|
|
255
295
|
_descriptor,
|
|
@@ -314,6 +354,7 @@ export class TargetResolver {
|
|
|
314
354
|
),
|
|
315
355
|
unstableSingleFileOutput:
|
|
316
356
|
descriptor.__unstable_singleFileOutput,
|
|
357
|
+
customEnv: descriptor.env,
|
|
317
358
|
}),
|
|
318
359
|
};
|
|
319
360
|
|
|
@@ -329,8 +370,21 @@ export class TargetResolver {
|
|
|
329
370
|
})
|
|
330
371
|
.filter(
|
|
331
372
|
(target) =>
|
|
373
|
+
(getFeatureFlag('allowExplicitTargetEntries') &&
|
|
374
|
+
this.options.entries.length !== 0) ||
|
|
332
375
|
!skipTarget(target.name, exclusiveTarget, target.source),
|
|
333
376
|
);
|
|
377
|
+
|
|
378
|
+
// Apply allowExplicitTargetEntries filtering logic
|
|
379
|
+
if (getFeatureFlag('allowExplicitTargetEntries')) {
|
|
380
|
+
// Check if ALL targets have sources - only apply new behavior if they do
|
|
381
|
+
const allTargetsHaveSources = targets.every((t) => t.source);
|
|
382
|
+
|
|
383
|
+
if (!allTargetsHaveSources) {
|
|
384
|
+
// If not all targets have sources, fall back to old behavior (skip targets with sources)
|
|
385
|
+
targets = targets.filter((target) => !target.source);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
334
388
|
}
|
|
335
389
|
|
|
336
390
|
let serve = this.options.serveOptions;
|
|
@@ -345,7 +399,7 @@ export class TargetResolver {
|
|
|
345
399
|
},
|
|
346
400
|
});
|
|
347
401
|
}
|
|
348
|
-
if (!BROWSER_ENVS.has(targets[0].env.context)) {
|
|
402
|
+
if (!BROWSER_ENVS.has(fromEnvironmentId(targets[0].env).context)) {
|
|
349
403
|
throw new ThrowableDiagnostic({
|
|
350
404
|
diagnostic: {
|
|
351
405
|
message: `Only browser targets are supported in serve mode`,
|
|
@@ -375,6 +429,7 @@ export class TargetResolver {
|
|
|
375
429
|
env: createEnvironment({
|
|
376
430
|
context: 'browser',
|
|
377
431
|
engines: {
|
|
432
|
+
// @ts-expect-error TS2322
|
|
378
433
|
browsers: DEFAULT_ENGINES.browsers,
|
|
379
434
|
},
|
|
380
435
|
shouldOptimize: this.options.defaultTargetOptions.shouldOptimize,
|
|
@@ -388,6 +443,7 @@ export class TargetResolver {
|
|
|
388
443
|
},
|
|
389
444
|
];
|
|
390
445
|
} else {
|
|
446
|
+
// @ts-expect-error TS2322
|
|
391
447
|
targets = Array.from(packageTargets.values())
|
|
392
448
|
.filter(Boolean)
|
|
393
449
|
.filter((descriptor) => {
|
|
@@ -424,11 +480,11 @@ export class TargetResolver {
|
|
|
424
480
|
|
|
425
481
|
let pkg;
|
|
426
482
|
let pkgContents;
|
|
427
|
-
let pkgFilePath:
|
|
483
|
+
let pkgFilePath: FilePath | null | undefined;
|
|
428
484
|
let pkgDir: FilePath;
|
|
429
485
|
let pkgMap;
|
|
430
486
|
if (conf) {
|
|
431
|
-
pkg =
|
|
487
|
+
pkg = conf.config as PackageJSON;
|
|
432
488
|
let pkgFile = conf.files[0];
|
|
433
489
|
if (pkgFile == null) {
|
|
434
490
|
throw new ThrowableDiagnostic({
|
|
@@ -512,6 +568,7 @@ export class TargetResolver {
|
|
|
512
568
|
};
|
|
513
569
|
|
|
514
570
|
browsersLoc = {
|
|
571
|
+
// @ts-expect-error TS2353
|
|
515
572
|
message: `(defined in ${path.relative(
|
|
516
573
|
process.cwd(),
|
|
517
574
|
browserslistConfig,
|
|
@@ -533,25 +590,28 @@ export class TargetResolver {
|
|
|
533
590
|
let browsers = pkgEngines.browsers;
|
|
534
591
|
|
|
535
592
|
let defaultEngines = this.options.defaultTargetOptions.engines;
|
|
536
|
-
let context = browsers ?? node == null ? 'browser' : 'node';
|
|
593
|
+
let context = (browsers ?? node == null) ? 'browser' : 'node';
|
|
537
594
|
if (context === 'browser' && pkgEngines.browsers == null) {
|
|
538
595
|
pkgEngines = {
|
|
539
596
|
...pkgEngines,
|
|
597
|
+
// @ts-expect-error TS2322
|
|
540
598
|
browsers: defaultEngines?.browsers ?? DEFAULT_ENGINES.browsers,
|
|
541
599
|
};
|
|
600
|
+
// @ts-expect-error TS2353
|
|
542
601
|
browsersLoc = {message: '(default)'};
|
|
543
602
|
} else if (context === 'node' && pkgEngines.node == null) {
|
|
544
603
|
pkgEngines = {
|
|
545
604
|
...pkgEngines,
|
|
546
605
|
node: defaultEngines?.node ?? DEFAULT_ENGINES.node,
|
|
547
606
|
};
|
|
607
|
+
// @ts-expect-error TS2353
|
|
548
608
|
nodeLoc = {message: '(default)'};
|
|
549
609
|
}
|
|
550
610
|
|
|
551
611
|
// If there is a separate `browser` target, or an `engines.node` field but no browser targets, then
|
|
552
612
|
// the `main` and `module` targets refer to node, otherwise browser.
|
|
553
613
|
let mainContext =
|
|
554
|
-
pkg.browser ?? pkgTargets.browser ?? (node != null && browsers == null)
|
|
614
|
+
(pkg.browser ?? pkgTargets.browser ?? (node != null && browsers == null))
|
|
555
615
|
? 'node'
|
|
556
616
|
: 'browser';
|
|
557
617
|
let mainContextLoc: TargetKeyInfo =
|
|
@@ -562,22 +622,22 @@ export class TargetResolver {
|
|
|
562
622
|
type: 'key',
|
|
563
623
|
}
|
|
564
624
|
: pkgTargets.browser
|
|
565
|
-
? {
|
|
566
|
-
inferred: '/targets/browser',
|
|
567
|
-
message: '(because a browser target also exists)',
|
|
568
|
-
type: 'key',
|
|
569
|
-
}
|
|
570
|
-
: node != null && browsers == null
|
|
571
|
-
? nodeLoc.path
|
|
572
625
|
? {
|
|
573
|
-
inferred:
|
|
574
|
-
message: '(because
|
|
626
|
+
inferred: '/targets/browser',
|
|
627
|
+
message: '(because a browser target also exists)',
|
|
575
628
|
type: 'key',
|
|
576
629
|
}
|
|
577
|
-
:
|
|
578
|
-
|
|
630
|
+
: node != null && browsers == null
|
|
631
|
+
? nodeLoc.path
|
|
632
|
+
? {
|
|
633
|
+
inferred: nodeLoc.path,
|
|
634
|
+
message: '(because node engines were defined)',
|
|
635
|
+
type: 'key',
|
|
636
|
+
}
|
|
637
|
+
: nodeLoc
|
|
638
|
+
: {message: '(default)'};
|
|
579
639
|
let moduleContext =
|
|
580
|
-
pkg.browser ?? pkgTargets.browser ? 'browser' : mainContext;
|
|
640
|
+
(pkg.browser ?? pkgTargets.browser) ? 'browser' : mainContext;
|
|
581
641
|
let moduleContextLoc: TargetKeyInfo =
|
|
582
642
|
pkg.browser != null
|
|
583
643
|
? {
|
|
@@ -586,14 +646,17 @@ export class TargetResolver {
|
|
|
586
646
|
type: 'key',
|
|
587
647
|
}
|
|
588
648
|
: pkgTargets.browser
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
649
|
+
? {
|
|
650
|
+
inferred: '/targets/browser',
|
|
651
|
+
message: '(becausea browser target also exists)',
|
|
652
|
+
type: 'key',
|
|
653
|
+
}
|
|
654
|
+
: mainContextLoc;
|
|
595
655
|
|
|
596
|
-
let getEnginesLoc = (
|
|
656
|
+
let getEnginesLoc = (
|
|
657
|
+
targetName: string,
|
|
658
|
+
descriptor: PackageTargetDescriptor,
|
|
659
|
+
): TargetKeyInfo => {
|
|
597
660
|
let enginesLoc = `/targets/${targetName}/engines`;
|
|
598
661
|
switch (context) {
|
|
599
662
|
case 'browser':
|
|
@@ -639,6 +702,7 @@ export class TargetResolver {
|
|
|
639
702
|
_targetDist = pkg[targetName][pkg.name];
|
|
640
703
|
pointer = `/${targetName}/${encodeJSONKeyComponent(pkg.name)}`;
|
|
641
704
|
} else {
|
|
705
|
+
// @ts-expect-error TS7053
|
|
642
706
|
_targetDist = pkg[targetName];
|
|
643
707
|
pointer = `/${targetName}`;
|
|
644
708
|
}
|
|
@@ -652,7 +716,7 @@ export class TargetResolver {
|
|
|
652
716
|
|
|
653
717
|
invariant(pkgMap != null);
|
|
654
718
|
|
|
655
|
-
let _descriptor:
|
|
719
|
+
let _descriptor: unknown = pkgTargets[targetName] ?? {};
|
|
656
720
|
if (typeof targetDist === 'string') {
|
|
657
721
|
distDir = toProjectPath(
|
|
658
722
|
this.options.projectRoot,
|
|
@@ -690,16 +754,16 @@ export class TargetResolver {
|
|
|
690
754
|
|
|
691
755
|
if (
|
|
692
756
|
distEntry != null &&
|
|
757
|
+
// @ts-expect-error TS7053
|
|
693
758
|
!COMMON_TARGETS[targetName].match.test(distEntry)
|
|
694
759
|
) {
|
|
695
760
|
let contents: string =
|
|
696
761
|
typeof pkgContents === 'string'
|
|
697
762
|
? pkgContents
|
|
698
|
-
:
|
|
699
|
-
JSON.stringify(pkgContents, null, '\t');
|
|
700
|
-
// $FlowFixMe
|
|
763
|
+
: JSON.stringify(pkgContents, null, '\t');
|
|
701
764
|
let listFormat = new Intl.ListFormat('en-US', {type: 'disjunction'});
|
|
702
765
|
let extensions = listFormat.format(
|
|
766
|
+
// @ts-expect-error TS7053
|
|
703
767
|
COMMON_TARGETS[targetName].extensions,
|
|
704
768
|
);
|
|
705
769
|
let ext = path.extname(distEntry);
|
|
@@ -734,8 +798,7 @@ export class TargetResolver {
|
|
|
734
798
|
let contents: string =
|
|
735
799
|
typeof pkgContents === 'string'
|
|
736
800
|
? pkgContents
|
|
737
|
-
:
|
|
738
|
-
JSON.stringify(pkgContents, null, '\t');
|
|
801
|
+
: JSON.stringify(pkgContents, null, '\t');
|
|
739
802
|
throw new ThrowableDiagnostic({
|
|
740
803
|
diagnostic: {
|
|
741
804
|
message: md`The "global" output format is not supported in the "${targetName}" target.`,
|
|
@@ -767,6 +830,7 @@ export class TargetResolver {
|
|
|
767
830
|
distEntry,
|
|
768
831
|
descriptor,
|
|
769
832
|
targetName,
|
|
833
|
+
// @ts-expect-error TS2345
|
|
770
834
|
pkg,
|
|
771
835
|
pkgFilePath,
|
|
772
836
|
pkgContents,
|
|
@@ -787,8 +851,7 @@ export class TargetResolver {
|
|
|
787
851
|
let contents: string =
|
|
788
852
|
typeof pkgContents === 'string'
|
|
789
853
|
? pkgContents
|
|
790
|
-
:
|
|
791
|
-
JSON.stringify(pkgContents, null, '\t');
|
|
854
|
+
: JSON.stringify(pkgContents, null, '\t');
|
|
792
855
|
throw new ThrowableDiagnostic({
|
|
793
856
|
diagnostic: {
|
|
794
857
|
// prettier-ignore
|
|
@@ -826,8 +889,7 @@ export class TargetResolver {
|
|
|
826
889
|
let contents: string =
|
|
827
890
|
typeof pkgContents === 'string'
|
|
828
891
|
? pkgContents
|
|
829
|
-
:
|
|
830
|
-
JSON.stringify(pkgContents, null, '\t');
|
|
892
|
+
: JSON.stringify(pkgContents, null, '\t');
|
|
831
893
|
throw new ThrowableDiagnostic({
|
|
832
894
|
diagnostic: {
|
|
833
895
|
message: 'Scope hoisting cannot be disabled for library targets.',
|
|
@@ -859,8 +921,8 @@ export class TargetResolver {
|
|
|
859
921
|
(targetName === 'browser'
|
|
860
922
|
? 'browser'
|
|
861
923
|
: isModule
|
|
862
|
-
|
|
863
|
-
|
|
924
|
+
? moduleContext
|
|
925
|
+
: mainContext);
|
|
864
926
|
|
|
865
927
|
targets.set(targetName, {
|
|
866
928
|
name: targetName,
|
|
@@ -870,6 +932,7 @@ export class TargetResolver {
|
|
|
870
932
|
descriptor.publicUrl ?? this.options.defaultTargetOptions.publicUrl,
|
|
871
933
|
env: createEnvironment({
|
|
872
934
|
engines: descriptor.engines ?? pkgEngines,
|
|
935
|
+
// @ts-expect-error TS2322
|
|
873
936
|
context,
|
|
874
937
|
includeNodeModules: descriptor.includeNodeModules ?? false,
|
|
875
938
|
outputFormat,
|
|
@@ -889,30 +952,30 @@ export class TargetResolver {
|
|
|
889
952
|
context: descriptor.context
|
|
890
953
|
? {path: `/targets/${targetName}/context`}
|
|
891
954
|
: targetName === 'browser'
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
955
|
+
? {
|
|
956
|
+
message: '(inferred from target name)',
|
|
957
|
+
inferred: pointer,
|
|
958
|
+
type: 'key',
|
|
959
|
+
}
|
|
960
|
+
: isModule
|
|
961
|
+
? moduleContextLoc
|
|
962
|
+
: mainContextLoc,
|
|
900
963
|
includeNodeModules: descriptor.includeNodeModules
|
|
901
964
|
? {path: `/targets/${targetName}/includeNodeModules`, type: 'key'}
|
|
902
965
|
: {message: '(default)'},
|
|
903
966
|
outputFormat: descriptor.outputFormat
|
|
904
967
|
? {path: `/targets/${targetName}/outputFormat`}
|
|
905
968
|
: inferredOutputFormatField === '/type'
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
969
|
+
? {
|
|
970
|
+
message: `(inferred from package.json#type)`,
|
|
971
|
+
inferred: inferredOutputFormatField,
|
|
972
|
+
}
|
|
973
|
+
: inferredOutputFormatField != null
|
|
974
|
+
? {
|
|
975
|
+
message: `(inferred from file extension)`,
|
|
976
|
+
inferred: inferredOutputFormatField,
|
|
977
|
+
}
|
|
978
|
+
: {message: '(default)'},
|
|
916
979
|
isLibrary: {message: '(default)'},
|
|
917
980
|
shouldOptimize: descriptor.optimize
|
|
918
981
|
? {path: `/targets/${targetName}/optimize`}
|
|
@@ -922,13 +985,15 @@ export class TargetResolver {
|
|
|
922
985
|
}
|
|
923
986
|
}
|
|
924
987
|
|
|
925
|
-
let customTargets = (Object.keys(pkgTargets)
|
|
988
|
+
let customTargets = (Object.keys(pkgTargets) as Array<string>).filter(
|
|
989
|
+
// @ts-expect-error TS7053
|
|
926
990
|
(targetName) => !COMMON_TARGETS[targetName],
|
|
927
991
|
);
|
|
928
992
|
|
|
929
993
|
// Custom targets
|
|
930
994
|
for (let targetName of customTargets) {
|
|
931
|
-
|
|
995
|
+
// @ts-expect-error TS7053
|
|
996
|
+
let distPath: unknown = pkg[targetName];
|
|
932
997
|
let distDir;
|
|
933
998
|
let distEntry;
|
|
934
999
|
let loc;
|
|
@@ -956,8 +1021,7 @@ export class TargetResolver {
|
|
|
956
1021
|
let contents: string =
|
|
957
1022
|
typeof pkgContents === 'string'
|
|
958
1023
|
? pkgContents
|
|
959
|
-
:
|
|
960
|
-
JSON.stringify(pkgContents, null, '\t');
|
|
1024
|
+
: JSON.stringify(pkgContents, null, '\t');
|
|
961
1025
|
throw new ThrowableDiagnostic({
|
|
962
1026
|
diagnostic: {
|
|
963
1027
|
message: md`Invalid distPath for target "${targetName}"`,
|
|
@@ -1009,6 +1073,7 @@ export class TargetResolver {
|
|
|
1009
1073
|
distEntry,
|
|
1010
1074
|
descriptor,
|
|
1011
1075
|
targetName,
|
|
1076
|
+
// @ts-expect-error TS2345
|
|
1012
1077
|
pkg,
|
|
1013
1078
|
pkgFilePath,
|
|
1014
1079
|
pkgContents,
|
|
@@ -1018,8 +1083,7 @@ export class TargetResolver {
|
|
|
1018
1083
|
let contents: string =
|
|
1019
1084
|
typeof pkgContents === 'string'
|
|
1020
1085
|
? pkgContents
|
|
1021
|
-
:
|
|
1022
|
-
JSON.stringify(pkgContents, null, '\t');
|
|
1086
|
+
: JSON.stringify(pkgContents, null, '\t');
|
|
1023
1087
|
throw new ThrowableDiagnostic({
|
|
1024
1088
|
diagnostic: {
|
|
1025
1089
|
message: 'Scope hoisting cannot be disabled for library targets.',
|
|
@@ -1087,6 +1151,7 @@ export class TargetResolver {
|
|
|
1087
1151
|
shouldScopeHoist:
|
|
1088
1152
|
shouldScopeHoist && descriptor.scopeHoist !== false,
|
|
1089
1153
|
sourceMap: normalizeSourceMap(this.options, descriptor.sourceMap),
|
|
1154
|
+
customEnv: descriptor.env,
|
|
1090
1155
|
}),
|
|
1091
1156
|
loc: toInternalSourceLocation(this.options.projectRoot, loc),
|
|
1092
1157
|
});
|
|
@@ -1103,16 +1168,16 @@ export class TargetResolver {
|
|
|
1103
1168
|
outputFormat: descriptor.outputFormat
|
|
1104
1169
|
? {path: `/targets/${targetName}/outputFormat`}
|
|
1105
1170
|
: inferredOutputFormatField === '/type'
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1171
|
+
? {
|
|
1172
|
+
message: `(inferred from package.json#type)`,
|
|
1173
|
+
inferred: inferredOutputFormatField,
|
|
1174
|
+
}
|
|
1175
|
+
: inferredOutputFormatField != null
|
|
1176
|
+
? {
|
|
1177
|
+
message: `(inferred from file extension)`,
|
|
1178
|
+
inferred: inferredOutputFormatField,
|
|
1179
|
+
}
|
|
1180
|
+
: {message: '(default)'},
|
|
1116
1181
|
isLibrary:
|
|
1117
1182
|
descriptor.isLibrary != null
|
|
1118
1183
|
? {path: `/targets/${targetName}/isLibrary`}
|
|
@@ -1142,6 +1207,7 @@ export class TargetResolver {
|
|
|
1142
1207
|
publicUrl: this.options.defaultTargetOptions.publicUrl,
|
|
1143
1208
|
env: createEnvironment({
|
|
1144
1209
|
engines: pkgEngines,
|
|
1210
|
+
// @ts-expect-error TS2322
|
|
1145
1211
|
context,
|
|
1146
1212
|
outputFormat: this.options.defaultTargetOptions.outputFormat,
|
|
1147
1213
|
isLibrary: this.options.defaultTargetOptions.isLibrary,
|
|
@@ -1163,13 +1229,13 @@ export class TargetResolver {
|
|
|
1163
1229
|
}
|
|
1164
1230
|
|
|
1165
1231
|
inferOutputFormat(
|
|
1166
|
-
distEntry:
|
|
1232
|
+
distEntry: FilePath | null | undefined,
|
|
1167
1233
|
descriptor: PackageTargetDescriptor,
|
|
1168
1234
|
targetName: string,
|
|
1169
1235
|
pkg: PackageJSON,
|
|
1170
|
-
pkgFilePath
|
|
1171
|
-
pkgContents
|
|
1172
|
-
): [
|
|
1236
|
+
pkgFilePath?: FilePath | null,
|
|
1237
|
+
pkgContents?: string | null,
|
|
1238
|
+
): [OutputFormat | null | undefined, string | null | undefined] {
|
|
1173
1239
|
// Infer the outputFormat based on package.json properties.
|
|
1174
1240
|
// If the extension is .mjs it's always a module.
|
|
1175
1241
|
// If the extension is .cjs, it's always commonjs.
|
|
@@ -1201,8 +1267,7 @@ export class TargetResolver {
|
|
|
1201
1267
|
let contents: string =
|
|
1202
1268
|
typeof pkgContents === 'string'
|
|
1203
1269
|
? pkgContents
|
|
1204
|
-
:
|
|
1205
|
-
JSON.stringify(pkgContents, null, '\t');
|
|
1270
|
+
: JSON.stringify(pkgContents, null, '\t');
|
|
1206
1271
|
let expectedExtensions;
|
|
1207
1272
|
switch (descriptor.outputFormat) {
|
|
1208
1273
|
case 'esmodule':
|
|
@@ -1215,7 +1280,6 @@ export class TargetResolver {
|
|
|
1215
1280
|
expectedExtensions = ['.js'];
|
|
1216
1281
|
break;
|
|
1217
1282
|
}
|
|
1218
|
-
// $FlowFixMe
|
|
1219
1283
|
let listFormat = new Intl.ListFormat('en-US', {type: 'disjunction'});
|
|
1220
1284
|
throw new ThrowableDiagnostic({
|
|
1221
1285
|
diagnostic: {
|
|
@@ -1253,14 +1317,15 @@ export class TargetResolver {
|
|
|
1253
1317
|
});
|
|
1254
1318
|
}
|
|
1255
1319
|
|
|
1320
|
+
// @ts-expect-error TS2322
|
|
1256
1321
|
return [inferredOutputFormat, inferredOutputFormatField];
|
|
1257
1322
|
}
|
|
1258
1323
|
}
|
|
1259
1324
|
|
|
1260
1325
|
function parseEngines(
|
|
1261
|
-
engines:
|
|
1262
|
-
pkgPath:
|
|
1263
|
-
pkgContents:
|
|
1326
|
+
engines: unknown,
|
|
1327
|
+
pkgPath: FilePath | null | undefined,
|
|
1328
|
+
pkgContents: string | null | undefined,
|
|
1264
1329
|
prependKey: string,
|
|
1265
1330
|
message: string,
|
|
1266
1331
|
): Engines | typeof undefined {
|
|
@@ -1273,16 +1338,16 @@ function parseEngines(
|
|
|
1273
1338
|
'@atlaspack/core',
|
|
1274
1339
|
message,
|
|
1275
1340
|
);
|
|
1276
|
-
//
|
|
1341
|
+
// @ts-expect-error TS2322
|
|
1277
1342
|
return engines;
|
|
1278
1343
|
}
|
|
1279
1344
|
}
|
|
1280
1345
|
|
|
1281
1346
|
function parseDescriptor(
|
|
1282
1347
|
targetName: string,
|
|
1283
|
-
descriptor:
|
|
1284
|
-
pkgPath
|
|
1285
|
-
pkgContents
|
|
1348
|
+
descriptor: unknown,
|
|
1349
|
+
pkgPath?: FilePath | null,
|
|
1350
|
+
pkgContents?: string | null,
|
|
1286
1351
|
): TargetDescriptor {
|
|
1287
1352
|
validateSchema.diagnostic(
|
|
1288
1353
|
DESCRIPTOR_SCHEMA,
|
|
@@ -1296,15 +1361,15 @@ function parseDescriptor(
|
|
|
1296
1361
|
`Invalid target descriptor for target "${targetName}"`,
|
|
1297
1362
|
);
|
|
1298
1363
|
|
|
1299
|
-
//
|
|
1364
|
+
// @ts-expect-error TS2322
|
|
1300
1365
|
return descriptor;
|
|
1301
1366
|
}
|
|
1302
1367
|
|
|
1303
1368
|
function parsePackageDescriptor(
|
|
1304
1369
|
targetName: string,
|
|
1305
|
-
descriptor:
|
|
1306
|
-
pkgPath
|
|
1307
|
-
pkgContents
|
|
1370
|
+
descriptor: unknown,
|
|
1371
|
+
pkgPath?: FilePath | null,
|
|
1372
|
+
pkgContents?: string | null,
|
|
1308
1373
|
): PackageTargetDescriptor {
|
|
1309
1374
|
validateSchema.diagnostic(
|
|
1310
1375
|
PACKAGE_DESCRIPTOR_SCHEMA,
|
|
@@ -1317,15 +1382,15 @@ function parsePackageDescriptor(
|
|
|
1317
1382
|
'@atlaspack/core',
|
|
1318
1383
|
`Invalid target descriptor for target "${targetName}"`,
|
|
1319
1384
|
);
|
|
1320
|
-
//
|
|
1385
|
+
// @ts-expect-error TS2322
|
|
1321
1386
|
return descriptor;
|
|
1322
1387
|
}
|
|
1323
1388
|
|
|
1324
1389
|
function parseCommonTargetDescriptor(
|
|
1325
1390
|
targetName: string,
|
|
1326
|
-
descriptor:
|
|
1327
|
-
pkgPath
|
|
1328
|
-
pkgContents
|
|
1391
|
+
descriptor: unknown,
|
|
1392
|
+
pkgPath?: FilePath | null,
|
|
1393
|
+
pkgContents?: string | null,
|
|
1329
1394
|
): PackageTargetDescriptor {
|
|
1330
1395
|
validateSchema.diagnostic(
|
|
1331
1396
|
COMMON_TARGET_DESCRIPTOR_SCHEMA,
|
|
@@ -1339,11 +1404,16 @@ function parseCommonTargetDescriptor(
|
|
|
1339
1404
|
`Invalid target descriptor for target "${targetName}"`,
|
|
1340
1405
|
);
|
|
1341
1406
|
|
|
1342
|
-
//
|
|
1407
|
+
// @ts-expect-error TS2322
|
|
1343
1408
|
return descriptor;
|
|
1344
1409
|
}
|
|
1345
1410
|
|
|
1346
|
-
function assertNoDuplicateTargets(
|
|
1411
|
+
function assertNoDuplicateTargets(
|
|
1412
|
+
options: AtlaspackOptions,
|
|
1413
|
+
targets: Map<string, Target | null>,
|
|
1414
|
+
pkgFilePath: FilePath | null | undefined,
|
|
1415
|
+
pkgContents: undefined | string,
|
|
1416
|
+
) {
|
|
1347
1417
|
// Detect duplicate targets by destination path and provide a nice error.
|
|
1348
1418
|
// Without this, an assertion is thrown much later after naming the bundles and finding duplicates.
|
|
1349
1419
|
let targetsByPath: Map<string, Array<string>> = new Map();
|
|
@@ -1404,7 +1474,11 @@ function assertNoDuplicateTargets(options, targets, pkgFilePath, pkgContents) {
|
|
|
1404
1474
|
}
|
|
1405
1475
|
}
|
|
1406
1476
|
|
|
1407
|
-
function normalizeSourceMap(
|
|
1477
|
+
function normalizeSourceMap(
|
|
1478
|
+
options: AtlaspackOptions,
|
|
1479
|
+
// @ts-expect-error TS2304
|
|
1480
|
+
sourceMap: undefined | TargetSourceMapOptions | boolean,
|
|
1481
|
+
) {
|
|
1408
1482
|
if (options.defaultTargetOptions.sourceMaps) {
|
|
1409
1483
|
if (typeof sourceMap === 'boolean') {
|
|
1410
1484
|
return sourceMap ? {} : undefined;
|
|
@@ -1431,7 +1505,8 @@ function assertTargetsAreNotEntries(
|
|
|
1431
1505
|
process.cwd(),
|
|
1432
1506
|
fromProjectPath(options.projectRoot, input.filePath),
|
|
1433
1507
|
);
|
|
1434
|
-
|
|
1508
|
+
// @ts-expect-error TS2304
|
|
1509
|
+
let codeFrames: Array<DiagnosticCodeFrame> = [];
|
|
1435
1510
|
if (loc) {
|
|
1436
1511
|
codeFrames.push({
|
|
1437
1512
|
filePath: fromProjectPath(options.projectRoot, loc.filePath),
|
|
@@ -1464,6 +1539,7 @@ function assertTargetsAreNotEntries(
|
|
|
1464
1539
|
message: `Target "${target.name}" is configured to overwrite entry "${relativeEntry}".`,
|
|
1465
1540
|
codeFrames,
|
|
1466
1541
|
hints: [
|
|
1542
|
+
// @ts-expect-error TS7053
|
|
1467
1543
|
(COMMON_TARGETS[target.name]
|
|
1468
1544
|
? `The "${target.name}" field is an _output_ file path so that your build can be consumed by other tools. `
|
|
1469
1545
|
: '') +
|
|
@@ -1476,7 +1552,12 @@ function assertTargetsAreNotEntries(
|
|
|
1476
1552
|
}
|
|
1477
1553
|
}
|
|
1478
1554
|
|
|
1479
|
-
async function debugResolvedTargets(
|
|
1555
|
+
async function debugResolvedTargets(
|
|
1556
|
+
input: Entry,
|
|
1557
|
+
targets: TargetRequestResult,
|
|
1558
|
+
targetInfo: Map<string, TargetInfo>,
|
|
1559
|
+
options: AtlaspackOptions,
|
|
1560
|
+
) {
|
|
1480
1561
|
for (let target of targets) {
|
|
1481
1562
|
let info = targetInfo.get(target.name);
|
|
1482
1563
|
let loc = target.loc;
|
|
@@ -1491,25 +1572,27 @@ async function debugResolvedTargets(input, targets, targetInfo, options) {
|
|
|
1491
1572
|
|
|
1492
1573
|
// Resolve relevant engines for context.
|
|
1493
1574
|
let engines;
|
|
1494
|
-
|
|
1575
|
+
const env = fromEnvironmentId(target.env);
|
|
1576
|
+
switch (env.context) {
|
|
1495
1577
|
case 'browser':
|
|
1496
1578
|
case 'web-worker':
|
|
1497
1579
|
case 'service-worker':
|
|
1498
1580
|
case 'worklet': {
|
|
1499
|
-
let browsers =
|
|
1581
|
+
let browsers = env.engines.browsers;
|
|
1500
1582
|
engines = Array.isArray(browsers) ? browsers.join(', ') : browsers;
|
|
1501
1583
|
break;
|
|
1502
1584
|
}
|
|
1503
1585
|
case 'node':
|
|
1504
|
-
engines =
|
|
1586
|
+
engines = env.engines.node;
|
|
1505
1587
|
break;
|
|
1506
1588
|
case 'electron-main':
|
|
1507
1589
|
case 'electron-renderer':
|
|
1508
|
-
engines =
|
|
1590
|
+
engines = env.engines.electron;
|
|
1509
1591
|
break;
|
|
1510
1592
|
}
|
|
1511
1593
|
|
|
1512
|
-
|
|
1594
|
+
// @ts-expect-error TS2304
|
|
1595
|
+
let highlights: Array<DiagnosticCodeHighlight> = [];
|
|
1513
1596
|
if (input.loc) {
|
|
1514
1597
|
highlights.push(
|
|
1515
1598
|
convertSourceLocationToHighlight(input.loc, 'entry defined here'),
|
|
@@ -1523,6 +1606,7 @@ async function debugResolvedTargets(input, targets, targetInfo, options) {
|
|
|
1523
1606
|
// Builds up map of code highlights for each defined/inferred path in the package.json.
|
|
1524
1607
|
let jsonHighlights = new Map();
|
|
1525
1608
|
for (let key in info) {
|
|
1609
|
+
// @ts-expect-error TS7053
|
|
1526
1610
|
let keyInfo = info[key];
|
|
1527
1611
|
let path = keyInfo.path || keyInfo.inferred;
|
|
1528
1612
|
if (!path) {
|
|
@@ -1547,29 +1631,29 @@ async function debugResolvedTargets(input, targets, targetInfo, options) {
|
|
|
1547
1631
|
}
|
|
1548
1632
|
|
|
1549
1633
|
if (keyInfo.inferred) {
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
);
|
|
1634
|
+
// @ts-expect-error TS2345
|
|
1635
|
+
highlight.inferred.push(md`${key} to be ${JSON.stringify(env[key])}`);
|
|
1553
1636
|
}
|
|
1554
1637
|
}
|
|
1555
1638
|
|
|
1556
|
-
// $FlowFixMe
|
|
1557
1639
|
let listFormat = new Intl.ListFormat('en-US');
|
|
1558
1640
|
|
|
1559
1641
|
// Generate human friendly messages for each field.
|
|
1560
|
-
let highlightsWithMessages = [...jsonHighlights].map(
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1642
|
+
let highlightsWithMessages = [...jsonHighlights].map(
|
|
1643
|
+
([k, v]: [any, any]) => {
|
|
1644
|
+
let message = v.defined;
|
|
1645
|
+
if (v.inferred.length > 0) {
|
|
1646
|
+
message += (message ? ', ' : '') + 'caused ';
|
|
1647
|
+
message += listFormat.format(v.inferred);
|
|
1648
|
+
}
|
|
1566
1649
|
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1650
|
+
return {
|
|
1651
|
+
key: k,
|
|
1652
|
+
type: v.type,
|
|
1653
|
+
message,
|
|
1654
|
+
};
|
|
1655
|
+
},
|
|
1656
|
+
);
|
|
1573
1657
|
|
|
1574
1658
|
// Get code highlights from JSON paths.
|
|
1575
1659
|
highlights.push(
|
|
@@ -1578,28 +1662,29 @@ async function debugResolvedTargets(input, targets, targetInfo, options) {
|
|
|
1578
1662
|
|
|
1579
1663
|
// Format includeNodeModules to be human readable.
|
|
1580
1664
|
let includeNodeModules;
|
|
1581
|
-
if (typeof
|
|
1582
|
-
includeNodeModules = String(
|
|
1583
|
-
} else if (Array.isArray(
|
|
1665
|
+
if (typeof env.includeNodeModules === 'boolean') {
|
|
1666
|
+
includeNodeModules = String(env.includeNodeModules);
|
|
1667
|
+
} else if (Array.isArray(env.includeNodeModules)) {
|
|
1584
1668
|
includeNodeModules =
|
|
1585
1669
|
'only ' +
|
|
1586
|
-
listFormat.format(
|
|
1587
|
-
target.env.includeNodeModules.map((m) => JSON.stringify(m)),
|
|
1588
|
-
);
|
|
1670
|
+
listFormat.format(env.includeNodeModules.map((m) => JSON.stringify(m)));
|
|
1589
1671
|
} else if (
|
|
1590
|
-
|
|
1591
|
-
typeof
|
|
1672
|
+
env.includeNodeModules &&
|
|
1673
|
+
typeof env.includeNodeModules === 'object'
|
|
1592
1674
|
) {
|
|
1593
1675
|
includeNodeModules =
|
|
1594
1676
|
'all except ' +
|
|
1595
1677
|
listFormat.format(
|
|
1596
|
-
Object.entries(
|
|
1597
|
-
.filter(([, v]) => v === false)
|
|
1598
|
-
|
|
1678
|
+
Object.entries(env.includeNodeModules)
|
|
1679
|
+
.filter(([, v]: [any, any]) => v === false)
|
|
1680
|
+
// @ts-expect-error TS2345
|
|
1681
|
+
.map(([k]: [any]) => JSON.stringify(k)),
|
|
1599
1682
|
);
|
|
1600
1683
|
}
|
|
1601
1684
|
|
|
1602
|
-
let format = (v) =>
|
|
1685
|
+
let format = (v: TargetKeyInfo) =>
|
|
1686
|
+
// @ts-expect-error TS2339
|
|
1687
|
+
v.message != null ? md.italic(v.message) : '';
|
|
1603
1688
|
logger.verbose({
|
|
1604
1689
|
origin: '@atlaspack/core',
|
|
1605
1690
|
message: md`**Target** "${target.name}"
|
|
@@ -1609,20 +1694,16 @@ async function debugResolvedTargets(input, targets, targetInfo, options) {
|
|
|
1609
1694
|
fromProjectPath(options.projectRoot, input.filePath),
|
|
1610
1695
|
)}
|
|
1611
1696
|
**Output**: ${path.relative(process.cwd(), output)}
|
|
1612
|
-
**Format**: ${
|
|
1613
|
-
|
|
1614
|
-
)}
|
|
1615
|
-
**Context**: ${target.env.context} ${format(info.context)}
|
|
1697
|
+
**Format**: ${env.outputFormat} ${format(info.outputFormat)}
|
|
1698
|
+
**Context**: ${env.context} ${format(info.context)}
|
|
1616
1699
|
**Engines**: ${engines || ''} ${format(info.engines)}
|
|
1617
|
-
**Library Mode**: ${String(
|
|
1618
|
-
info.isLibrary,
|
|
1619
|
-
)}
|
|
1700
|
+
**Library Mode**: ${String(env.isLibrary)} ${format(info.isLibrary)}
|
|
1620
1701
|
**Include Node Modules**: ${includeNodeModules} ${format(
|
|
1621
1702
|
info.includeNodeModules,
|
|
1622
1703
|
)}
|
|
1623
|
-
**Optimize**: ${String(
|
|
1624
|
-
|
|
1625
|
-
|
|
1704
|
+
**Optimize**: ${String(env.shouldOptimize)} ${format(
|
|
1705
|
+
info.shouldOptimize,
|
|
1706
|
+
)}`,
|
|
1626
1707
|
codeFrames: target.loc
|
|
1627
1708
|
? [
|
|
1628
1709
|
{
|