@atlaspack/core 2.16.2-canary.37 → 2.16.2-canary.371
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 +941 -0
- package/dist/AssetGraph.js +591 -0
- package/dist/Atlaspack.js +666 -0
- package/dist/AtlaspackConfig.js +324 -0
- package/dist/AtlaspackConfig.schema.js +117 -0
- package/dist/BundleGraph.js +1740 -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 +514 -0
- package/dist/UncommittedAsset.js +315 -0
- package/dist/Validation.js +196 -0
- package/dist/applyRuntimes.js +383 -0
- package/dist/assetUtils.js +169 -0
- package/dist/atlaspack-v3/AtlaspackV3.js +74 -0
- package/dist/atlaspack-v3/NapiWorkerPool.js +81 -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 +98 -0
- package/dist/atlaspack-v3/worker/compat/dependency.js +43 -0
- package/dist/atlaspack-v3/worker/compat/environment.js +57 -0
- package/dist/atlaspack-v3/worker/compat/index.js +25 -0
- package/dist/atlaspack-v3/worker/compat/mutable-asset.js +152 -0
- package/dist/atlaspack-v3/worker/compat/plugin-config.js +64 -0
- package/dist/atlaspack-v3/worker/compat/plugin-logger.js +26 -0
- package/dist/atlaspack-v3/worker/compat/plugin-options.js +137 -0
- package/dist/atlaspack-v3/worker/compat/plugin-tracer.js +10 -0
- package/dist/atlaspack-v3/worker/compat/target.js +14 -0
- package/dist/atlaspack-v3/worker/side-effect-detector.js +243 -0
- package/dist/atlaspack-v3/worker/worker.js +381 -0
- package/dist/constants.js +17 -0
- package/dist/dumpGraphToGraphViz.js +281 -0
- package/dist/index.js +62 -0
- package/dist/loadAtlaspackPlugin.js +128 -0
- package/dist/loadDotEnv.js +41 -0
- package/dist/projectPath.js +83 -0
- package/dist/public/Asset.js +279 -0
- package/dist/public/Bundle.js +224 -0
- package/dist/public/BundleGraph.js +371 -0
- package/dist/public/BundleGroup.js +53 -0
- package/dist/public/Config.js +286 -0
- package/dist/public/Dependency.js +138 -0
- package/dist/public/Environment.js +278 -0
- package/dist/public/MutableBundleGraph.js +277 -0
- package/dist/public/PluginOptions.js +80 -0
- package/dist/public/Symbols.js +248 -0
- package/dist/public/Target.js +69 -0
- package/dist/registerCoreWithSerializer.js +38 -0
- package/dist/requests/AssetGraphRequest.js +439 -0
- package/dist/requests/AssetGraphRequestRust.js +273 -0
- package/dist/requests/AssetRequest.js +130 -0
- package/dist/requests/AtlaspackBuildRequest.js +92 -0
- package/dist/requests/AtlaspackConfigRequest.js +493 -0
- package/dist/requests/BundleGraphRequest.js +447 -0
- package/dist/requests/ConfigRequest.js +246 -0
- package/dist/requests/DevDepRequest.js +204 -0
- package/dist/requests/EntryRequest.js +314 -0
- package/dist/requests/PackageRequest.js +72 -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 +269 -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 +94 -41
- package/lib/AtlaspackConfig.js +15 -3
- package/lib/AtlaspackConfig.schema.js +16 -5
- package/lib/BundleGraph.js +197 -32
- package/lib/CommittedAsset.js +7 -1
- 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 +66 -15
- package/lib/UncommittedAsset.js +33 -12
- package/lib/Validation.js +18 -2
- package/lib/applyRuntimes.js +96 -4
- package/lib/assetUtils.js +15 -5
- package/lib/atlaspack-v3/AtlaspackV3.js +52 -14
- package/lib/atlaspack-v3/NapiWorkerPool.js +28 -1
- 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 +31 -25
- package/lib/atlaspack-v3/worker/compat/dependency.js +4 -1
- package/lib/atlaspack-v3/worker/compat/environment.js +10 -7
- package/lib/atlaspack-v3/worker/compat/mutable-asset.js +15 -10
- package/lib/atlaspack-v3/worker/compat/plugin-config.js +13 -34
- package/lib/atlaspack-v3/worker/compat/plugin-options.js +16 -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/side-effect-detector.js +215 -0
- package/lib/atlaspack-v3/worker/worker.js +199 -71
- 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 +25 -22
- 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 +74 -27
- package/lib/requests/AssetGraphRequestRust.js +140 -64
- package/lib/requests/AssetRequest.js +23 -6
- package/lib/requests/AtlaspackBuildRequest.js +43 -4
- package/lib/requests/AtlaspackConfigRequest.js +27 -16
- package/lib/requests/BundleGraphRequest.js +41 -24
- package/lib/requests/ConfigRequest.js +53 -4
- package/lib/requests/DevDepRequest.js +31 -5
- package/lib/requests/EntryRequest.js +2 -0
- package/lib/requests/PackageRequest.js +16 -2
- 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 +38 -11
- 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 +53 -0
- package/lib/types/BundleGraph.d.ts +184 -0
- package/lib/types/CommittedAsset.d.ts +23 -0
- package/lib/types/Dependency.d.ts +44 -0
- package/lib/types/Environment.d.ts +11 -0
- package/lib/types/EnvironmentManager.d.ts +37 -0
- package/lib/types/IdentifierRegistry.d.ts +6 -0
- package/lib/types/InternalConfig.d.ts +23 -0
- package/lib/types/PackagerRunner.d.ts +85 -0
- package/lib/types/ReporterRunner.d.ts +25 -0
- package/lib/types/RequestTracker.d.ts +385 -0
- package/lib/types/SymbolPropagation.d.ts +11 -0
- package/lib/types/TargetDescriptor.schema.d.ts +5 -0
- package/lib/types/Transformation.d.ts +72 -0
- package/lib/types/UncommittedAsset.d.ts +61 -0
- package/lib/types/Validation.d.ts +37 -0
- package/lib/types/applyRuntimes.d.ts +25 -0
- package/lib/types/assetUtils.d.ts +42 -0
- package/lib/types/atlaspack-v3/AtlaspackV3.d.ts +34 -0
- package/lib/types/atlaspack-v3/NapiWorkerPool.d.ts +13 -0
- package/lib/types/atlaspack-v3/fs.d.ts +12 -0
- package/lib/types/atlaspack-v3/index.d.ts +6 -0
- package/lib/types/atlaspack-v3/jsCallable.d.ts +1 -0
- package/lib/types/atlaspack-v3/worker/compat/asset-symbols.d.ts +51 -0
- package/lib/types/atlaspack-v3/worker/compat/bitflags.d.ts +14 -0
- package/lib/types/atlaspack-v3/worker/compat/dependency.d.ts +25 -0
- package/lib/types/atlaspack-v3/worker/compat/environment.d.ts +27 -0
- package/{src/atlaspack-v3/worker/compat/index.js → lib/types/atlaspack-v3/worker/compat/index.d.ts} +0 -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 +29 -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 +23 -0
- package/lib/types/atlaspack-v3/worker/compat/plugin-tracer.d.ts +5 -0
- package/lib/types/atlaspack-v3/worker/compat/target.d.ts +11 -0
- package/lib/types/atlaspack-v3/worker/side-effect-detector.d.ts +76 -0
- package/lib/types/atlaspack-v3/worker/worker.d.ts +80 -0
- package/lib/types/constants.d.ts +13 -0
- package/lib/types/dumpGraphToGraphViz.d.ts +10 -0
- package/lib/types/index.d.ts +8 -0
- package/lib/types/loadAtlaspackPlugin.d.ts +8 -0
- package/lib/types/loadDotEnv.d.ts +3 -0
- package/lib/types/projectPath.d.ts +19 -0
- package/lib/types/public/Asset.d.ts +74 -0
- package/lib/types/public/Bundle.d.ts +45 -0
- package/lib/types/public/BundleGraph.d.ts +72 -0
- package/lib/types/public/BundleGroup.d.ts +12 -0
- package/lib/types/public/Config.d.ts +75 -0
- package/lib/types/public/Dependency.d.ts +32 -0
- package/lib/types/public/Environment.d.ts +34 -0
- package/lib/types/public/MutableBundleGraph.d.ts +26 -0
- package/lib/types/public/PluginOptions.d.ts +25 -0
- package/lib/types/public/Symbols.d.ts +81 -0
- package/lib/types/public/Target.d.ts +16 -0
- package/lib/types/registerCoreWithSerializer.d.ts +2 -0
- package/lib/types/requests/AssetGraphRequest.d.ts +76 -0
- package/lib/types/requests/AssetGraphRequestRust.d.ts +21 -0
- package/lib/types/requests/AssetRequest.d.ts +16 -0
- package/lib/types/requests/AtlaspackBuildRequest.d.ts +33 -0
- package/lib/types/requests/AtlaspackConfigRequest.d.ts +45 -0
- package/lib/types/requests/BundleGraphRequest.d.ts +28 -0
- package/lib/types/requests/ConfigRequest.d.ts +67 -0
- package/lib/types/requests/DevDepRequest.d.ts +30 -0
- package/lib/types/requests/EntryRequest.d.ts +36 -0
- package/lib/types/requests/PackageRequest.d.ts +27 -0
- package/lib/types/requests/PathRequest.d.ts +48 -0
- package/lib/types/requests/TargetRequest.d.ts +48 -0
- package/lib/types/requests/ValidationRequest.d.ts +20 -0
- package/lib/types/requests/WriteBundleRequest.d.ts +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 +495 -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 +30 -14
- package/package.json +25 -35
- package/src/{AssetGraph.js → AssetGraph.ts} +156 -52
- package/src/{Atlaspack.js → Atlaspack.ts} +134 -67
- package/src/{AtlaspackConfig.schema.js → AtlaspackConfig.schema.ts} +25 -19
- package/src/{AtlaspackConfig.js → AtlaspackConfig.ts} +78 -54
- package/src/{BundleGraph.js → BundleGraph.ts} +383 -140
- package/src/{CommittedAsset.js → CommittedAsset.ts} +15 -13
- package/src/{Dependency.js → Dependency.ts} +59 -42
- package/src/{Environment.js → Environment.ts} +24 -15
- package/src/EnvironmentManager.ts +154 -0
- package/src/{IdentifierRegistry.js → IdentifierRegistry.ts} +1 -4
- package/src/{InternalConfig.js → InternalConfig.ts} +22 -23
- package/src/{PackagerRunner.js → PackagerRunner.ts} +179 -87
- 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} +110 -65
- package/src/{UncommittedAsset.js → UncommittedAsset.ts} +60 -39
- package/src/{Validation.js → Validation.ts} +32 -17
- package/src/{applyRuntimes.js → applyRuntimes.ts} +133 -26
- package/src/{assetUtils.js → assetUtils.ts} +49 -36
- package/src/atlaspack-v3/AtlaspackV3.ts +143 -0
- package/src/atlaspack-v3/NapiWorkerPool.ts +91 -0
- package/src/atlaspack-v3/{fs.js → fs.ts} +3 -4
- package/src/atlaspack-v3/{index.js → index.ts} +3 -4
- package/src/atlaspack-v3/jsCallable.ts +14 -0
- package/src/atlaspack-v3/worker/compat/{asset-symbols.js → asset-symbols.ts} +40 -30
- package/src/atlaspack-v3/worker/compat/bitflags.ts +102 -0
- package/src/atlaspack-v3/worker/compat/{dependency.js → dependency.ts} +13 -13
- package/src/atlaspack-v3/worker/compat/{environment.js → environment.ts} +13 -9
- package/src/atlaspack-v3/worker/compat/index.ts +9 -0
- package/src/atlaspack-v3/worker/compat/{mutable-asset.js → mutable-asset.ts} +21 -20
- package/src/atlaspack-v3/worker/compat/{plugin-config.js → plugin-config.ts} +25 -56
- package/src/atlaspack-v3/worker/compat/{plugin-logger.js → plugin-logger.ts} +0 -2
- package/src/atlaspack-v3/worker/compat/{plugin-options.js → plugin-options.ts} +19 -5
- package/src/atlaspack-v3/worker/compat/{plugin-tracer.js → plugin-tracer.ts} +2 -2
- package/src/atlaspack-v3/worker/compat/{target.js → target.ts} +3 -4
- package/src/atlaspack-v3/worker/index.js +2 -1
- package/src/atlaspack-v3/worker/side-effect-detector.ts +298 -0
- package/src/atlaspack-v3/worker/worker.ts +531 -0
- package/src/{constants.js → constants.ts} +0 -3
- package/src/{dumpGraphToGraphViz.js → dumpGraphToGraphViz.ts} +73 -28
- package/src/index.ts +18 -0
- package/src/{loadAtlaspackPlugin.js → loadAtlaspackPlugin.ts} +8 -9
- package/src/{loadDotEnv.js → loadDotEnv.ts} +2 -2
- package/src/{projectPath.js → projectPath.ts} +20 -9
- package/src/public/{Asset.js → Asset.ts} +41 -28
- package/src/public/{Bundle.js → Bundle.ts} +28 -29
- package/src/public/{BundleGraph.js → BundleGraph.ts} +103 -68
- package/src/public/{BundleGroup.js → BundleGroup.ts} +7 -10
- package/src/public/{Config.js → Config.ts} +171 -33
- package/src/public/{Dependency.js → Dependency.ts} +20 -17
- package/src/public/{Environment.js → Environment.ts} +28 -17
- package/src/public/{MutableBundleGraph.js → MutableBundleGraph.ts} +55 -24
- package/src/public/{PluginOptions.js → PluginOptions.ts} +6 -6
- package/src/public/{Symbols.js → Symbols.ts} +75 -36
- package/src/public/{Target.js → Target.ts} +10 -8
- package/src/{registerCoreWithSerializer.js → registerCoreWithSerializer.ts} +9 -7
- package/src/requests/{AssetGraphRequest.js → AssetGraphRequest.ts} +129 -80
- package/src/requests/AssetGraphRequestRust.ts +364 -0
- package/src/requests/{AssetRequest.js → AssetRequest.ts} +24 -18
- package/src/requests/AtlaspackBuildRequest.ts +163 -0
- package/src/requests/{AtlaspackConfigRequest.js → AtlaspackConfigRequest.ts} +72 -58
- package/src/requests/{BundleGraphRequest.js → BundleGraphRequest.ts} +97 -79
- package/src/requests/{ConfigRequest.js → ConfigRequest.ts} +110 -50
- package/src/requests/{DevDepRequest.js → DevDepRequest.ts} +60 -35
- package/src/requests/{EntryRequest.js → EntryRequest.ts} +36 -31
- package/src/requests/{PackageRequest.js → PackageRequest.ts} +34 -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} +59 -25
- 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 +650 -0
- package/src/{utils.js → utils.ts} +52 -21
- package/src/{worker.js → worker.ts} +50 -42
- package/test/{AssetGraph.test.js → AssetGraph.test.ts} +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} +76 -16
- package/test/{BundleGraph.test.js → BundleGraph.test.ts} +8 -13
- package/test/{Dependency.test.js → Dependency.test.ts} +2 -3
- package/test/{EntryRequest.test.js → EntryRequest.test.ts} +1 -6
- package/test/Environment.test.ts +153 -0
- package/test/EnvironmentManager.test.ts +188 -0
- package/test/{IdentifierRegistry.test.js → IdentifierRegistry.test.ts} +2 -4
- package/test/{InternalAsset.test.js → InternalAsset.test.ts} +2 -7
- package/test/PackagerRunner.test.ts +0 -0
- package/test/{PublicAsset.test.js → PublicAsset.test.ts} +2 -7
- package/test/{PublicBundle.test.js → PublicBundle.test.ts} +1 -2
- package/test/{PublicDependency.test.js → PublicDependency.test.ts} +0 -2
- package/test/PublicEnvironment.test.ts +49 -0
- package/test/{PublicMutableBundleGraph.test.js → PublicMutableBundleGraph.test.ts} +6 -11
- package/test/{RequestTracker.test.js → RequestTracker.test.ts} +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.ts +443 -0
- package/test/requests/{ConfigRequest.test.js → ConfigRequest.test.ts} +202 -13
- package/test/requests/{DevDepRequest.test.js → DevDepRequest.test.ts} +0 -2
- package/test/{test-utils.js → test-utils.ts} +4 -11
- package/test/{utils.test.js → utils.test.ts} +1 -3
- package/tsconfig.json +60 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/index.d.ts +0 -30
- package/src/atlaspack-v3/AtlaspackV3.js +0 -87
- package/src/atlaspack-v3/NapiWorkerPool.js +0 -53
- package/src/atlaspack-v3/jsCallable.js +0 -18
- package/src/atlaspack-v3/worker/compat/bitflags.js +0 -100
- package/src/atlaspack-v3/worker/worker.js +0 -362
- package/src/index.js +0 -13
- package/src/requests/AssetGraphRequestRust.js +0 -263
- package/src/requests/AtlaspackBuildRequest.js +0 -111
- package/src/types.js +0 -600
- package/test/Environment.test.js +0 -119
- package/test/PackagerRunner.test.js +0 -27
- package/test/PublicEnvironment.test.js +0 -27
- package/test/requests/AssetGraphRequestRust.test.js +0 -411
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.AtlaspackWorker = void 0;
|
|
7
|
+
var _sideEffectDetector = require("./side-effect-detector");
|
|
7
8
|
function _assert() {
|
|
8
9
|
const data = _interopRequireDefault(require("assert"));
|
|
9
10
|
_assert = function () {
|
|
@@ -51,33 +52,73 @@ var _compat = require("./compat");
|
|
|
51
52
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
52
53
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
53
54
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
55
|
+
/* eslint-disable import/first */
|
|
56
|
+
|
|
57
|
+
// Install side effect detection patches BEFORE importing any modules that use fs
|
|
58
|
+
const sideEffectDetector = new _sideEffectDetector.SideEffectDetector();
|
|
59
|
+
sideEffectDetector.install();
|
|
60
|
+
|
|
61
|
+
// @ts-expect-error TS2305
|
|
62
|
+
|
|
54
63
|
const CONFIG = Symbol.for('parcel-plugin-config');
|
|
55
64
|
class AtlaspackWorker {
|
|
56
65
|
#resolvers;
|
|
57
66
|
#transformers;
|
|
58
67
|
#fs;
|
|
68
|
+
#packageManager;
|
|
69
|
+
#options;
|
|
70
|
+
#sideEffectDetector;
|
|
59
71
|
constructor() {
|
|
60
72
|
this.#resolvers = new Map();
|
|
61
73
|
this.#transformers = new Map();
|
|
62
74
|
this.#fs = new (_fs().NodeFS)();
|
|
75
|
+
this.#packageManager = new (_packageManager().NodePackageManager)(this.#fs, '/');
|
|
76
|
+
this.#sideEffectDetector = sideEffectDetector; // Use the global detector that was installed before imports
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
clearState() {
|
|
80
|
+
this.#resolvers.clear();
|
|
81
|
+
this.#transformers.clear();
|
|
82
|
+
this.#options = undefined;
|
|
63
83
|
}
|
|
64
84
|
loadPlugin = (0, _jsCallable.jsCallable)(async ({
|
|
65
85
|
kind,
|
|
66
86
|
specifier,
|
|
67
|
-
resolveFrom
|
|
87
|
+
resolveFrom,
|
|
88
|
+
options
|
|
68
89
|
}) => {
|
|
69
|
-
|
|
70
|
-
let
|
|
71
|
-
|
|
72
|
-
|
|
90
|
+
// Use packageManager.require() instead of dynamic import() to support TypeScript plugins
|
|
91
|
+
let resolvedModule = await this.#packageManager.require(specifier, resolveFrom, {
|
|
92
|
+
shouldAutoInstall: false
|
|
93
|
+
});
|
|
73
94
|
let instance = undefined;
|
|
74
|
-
|
|
95
|
+
// Check for CommonJS export (module.exports = new Plugin(...))
|
|
96
|
+
if (resolvedModule[CONFIG]) {
|
|
97
|
+
instance = resolvedModule[CONFIG];
|
|
98
|
+
} else if (resolvedModule.default && resolvedModule.default[CONFIG]) {
|
|
99
|
+
// ESM default export
|
|
75
100
|
instance = resolvedModule.default[CONFIG];
|
|
76
101
|
} else if (resolvedModule.default && resolvedModule.default.default && resolvedModule.default.default[CONFIG]) {
|
|
102
|
+
// Double-wrapped default export
|
|
77
103
|
instance = resolvedModule.default.default[CONFIG];
|
|
78
104
|
} else {
|
|
79
105
|
throw new Error(`Plugin could not be resolved\n\t${kind}\n\t${resolveFrom}\n\t${specifier}`);
|
|
80
106
|
}
|
|
107
|
+
if (this.#options == null) {
|
|
108
|
+
this.#options = {
|
|
109
|
+
...options,
|
|
110
|
+
inputFS: this.#fs,
|
|
111
|
+
outputFS: this.#fs,
|
|
112
|
+
packageManager: this.#packageManager,
|
|
113
|
+
shouldAutoInstall: false
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Set feature flags in the worker process
|
|
118
|
+
let featureFlagsModule = await this.#packageManager.require('@atlaspack/feature-flags', __filename, {
|
|
119
|
+
shouldAutoInstall: false
|
|
120
|
+
});
|
|
121
|
+
featureFlagsModule.setFeatureFlags(options.featureFlags);
|
|
81
122
|
switch (kind) {
|
|
82
123
|
case 'resolver':
|
|
83
124
|
this.#resolvers.set(specifier, {
|
|
@@ -85,55 +126,43 @@ class AtlaspackWorker {
|
|
|
85
126
|
});
|
|
86
127
|
break;
|
|
87
128
|
case 'transformer':
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
break;
|
|
129
|
+
{
|
|
130
|
+
return this.initializeTransformer(instance, specifier);
|
|
131
|
+
}
|
|
92
132
|
}
|
|
93
133
|
});
|
|
94
134
|
runResolverResolve = (0, _jsCallable.jsCallable)(async ({
|
|
95
135
|
key,
|
|
96
136
|
dependency: napiDependency,
|
|
97
137
|
specifier,
|
|
98
|
-
pipeline
|
|
99
|
-
pluginOptions
|
|
138
|
+
pipeline
|
|
100
139
|
}) => {
|
|
101
140
|
const state = this.#resolvers.get(key);
|
|
102
141
|
if (!state) {
|
|
103
142
|
throw new Error(`Resolver not found: ${key}`);
|
|
104
143
|
}
|
|
105
|
-
let packageManager = state.packageManager;
|
|
106
|
-
if (!packageManager) {
|
|
107
|
-
packageManager = new (_packageManager().NodePackageManager)(this.#fs, pluginOptions.projectRoot);
|
|
108
|
-
state.packageManager = packageManager;
|
|
109
|
-
}
|
|
110
144
|
const env = new _compat.Environment(napiDependency.env);
|
|
111
145
|
const dependency = new _compat.Dependency(napiDependency, env);
|
|
112
146
|
const defaultOptions = {
|
|
113
147
|
logger: new _compat.PluginLogger(),
|
|
114
148
|
tracer: new _compat.PluginTracer(),
|
|
115
|
-
options: new _compat.PluginOptions(
|
|
116
|
-
...pluginOptions,
|
|
117
|
-
packageManager,
|
|
118
|
-
shouldAutoInstall: false,
|
|
119
|
-
inputFS: this.#fs,
|
|
120
|
-
outputFS: this.#fs
|
|
121
|
-
})
|
|
149
|
+
options: new _compat.PluginOptions(this.options)
|
|
122
150
|
};
|
|
123
151
|
if (!('config' in state)) {
|
|
124
152
|
var _state$resolver$loadC, _state$resolver;
|
|
153
|
+
// @ts-expect-error TS2345
|
|
125
154
|
state.config = await ((_state$resolver$loadC = (_state$resolver = state.resolver).loadConfig) === null || _state$resolver$loadC === void 0 ? void 0 : _state$resolver$loadC.call(_state$resolver, {
|
|
126
155
|
config: new _compat.PluginConfig({
|
|
127
|
-
env,
|
|
156
|
+
env: napiDependency.env,
|
|
157
|
+
plugin: key,
|
|
128
158
|
isSource: true,
|
|
129
|
-
searchPath:
|
|
130
|
-
|
|
131
|
-
fs: this.#fs,
|
|
132
|
-
packageManager
|
|
133
|
-
}),
|
|
159
|
+
searchPath: 'index'
|
|
160
|
+
}, this.options),
|
|
134
161
|
...defaultOptions
|
|
135
162
|
}));
|
|
136
163
|
}
|
|
164
|
+
|
|
165
|
+
// @ts-expect-error TS2345
|
|
137
166
|
const result = await state.resolver.resolve({
|
|
138
167
|
specifier,
|
|
139
168
|
dependency,
|
|
@@ -149,13 +178,21 @@ class AtlaspackWorker {
|
|
|
149
178
|
}
|
|
150
179
|
};
|
|
151
180
|
}
|
|
181
|
+
if (result.isExcluded) {
|
|
182
|
+
return {
|
|
183
|
+
invalidations: [],
|
|
184
|
+
resolution: {
|
|
185
|
+
type: 'excluded'
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
}
|
|
152
189
|
return {
|
|
153
190
|
invalidations: [],
|
|
154
191
|
resolution: {
|
|
155
192
|
type: 'resolved',
|
|
156
193
|
filePath: result.filePath || '',
|
|
157
194
|
canDefer: result.canDefer || false,
|
|
158
|
-
sideEffects: result.sideEffects
|
|
195
|
+
sideEffects: result.sideEffects ?? true,
|
|
159
196
|
code: result.code || undefined,
|
|
160
197
|
meta: result.meta || undefined,
|
|
161
198
|
pipeline: result.pipeline || undefined,
|
|
@@ -166,52 +203,58 @@ class AtlaspackWorker {
|
|
|
166
203
|
});
|
|
167
204
|
runTransformerTransform = (0, _jsCallable.jsCallable)(async ({
|
|
168
205
|
key,
|
|
169
|
-
env: napiEnv,
|
|
170
|
-
options,
|
|
171
206
|
asset: innerAsset
|
|
172
207
|
}, contents, map) => {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
if (!state) {
|
|
208
|
+
const instance = this.#transformers.get(key);
|
|
209
|
+
if (!instance) {
|
|
176
210
|
throw new Error(`Transformer not found: ${key}`);
|
|
177
211
|
}
|
|
178
|
-
let
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
}
|
|
183
|
-
|
|
212
|
+
let {
|
|
213
|
+
transformer,
|
|
214
|
+
config,
|
|
215
|
+
allowedEnv = new Set()
|
|
216
|
+
} = instance;
|
|
217
|
+
let cacheBailouts = [];
|
|
184
218
|
const resolveFunc = (from, to) => {
|
|
185
219
|
let customRequire = _module().createRequire(from);
|
|
186
220
|
let resolvedPath = customRequire.resolve(to);
|
|
221
|
+
// Tranformer not cacheable due to use of the resolve function
|
|
222
|
+
|
|
223
|
+
cacheBailouts.push(`resolve(${from}, ${to})`);
|
|
187
224
|
return Promise.resolve(resolvedPath);
|
|
188
225
|
};
|
|
189
|
-
const env = new _compat.Environment(
|
|
190
|
-
|
|
226
|
+
const env = new _compat.Environment(innerAsset.env);
|
|
227
|
+
let mutableAsset = new _compat.MutableAsset(innerAsset,
|
|
228
|
+
// @ts-expect-error TS2345
|
|
229
|
+
contents, env, this.#fs, map, this.options.projectRoot);
|
|
230
|
+
const pluginOptions = new _compat.PluginOptions(this.options);
|
|
191
231
|
const defaultOptions = {
|
|
192
232
|
logger: new _compat.PluginLogger(),
|
|
193
233
|
tracer: new _compat.PluginTracer(),
|
|
194
|
-
options:
|
|
195
|
-
...options,
|
|
196
|
-
packageManager,
|
|
197
|
-
shouldAutoInstall: false,
|
|
198
|
-
inputFS: this.#fs,
|
|
199
|
-
outputFS: this.#fs
|
|
200
|
-
})
|
|
234
|
+
options: pluginOptions
|
|
201
235
|
};
|
|
202
|
-
|
|
203
|
-
config
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
236
|
+
if (transformer.loadConfig) {
|
|
237
|
+
if (config != null) {
|
|
238
|
+
throw new Error(`Transformer (${key}) should not implement 'setup' and 'loadConfig'`);
|
|
239
|
+
}
|
|
240
|
+
// @ts-expect-error TS2345
|
|
241
|
+
config = await transformer.loadConfig({
|
|
242
|
+
config: new _compat.PluginConfig({
|
|
243
|
+
plugin: key,
|
|
244
|
+
isSource: innerAsset.isSource,
|
|
245
|
+
searchPath: innerAsset.filePath,
|
|
246
|
+
env
|
|
247
|
+
}, this.options),
|
|
248
|
+
...defaultOptions
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
// Transformer uses the deprecated loadConfig API, so mark as not
|
|
252
|
+
// cachable
|
|
253
|
+
cacheBailouts.push(`Transformer.loadConfig`);
|
|
254
|
+
}
|
|
213
255
|
if (transformer.parse) {
|
|
214
256
|
const ast = await transformer.parse({
|
|
257
|
+
// @ts-expect-error TS2322
|
|
215
258
|
asset: mutableAsset,
|
|
216
259
|
config,
|
|
217
260
|
resolve: resolveFunc,
|
|
@@ -220,18 +263,37 @@ class AtlaspackWorker {
|
|
|
220
263
|
if (ast) {
|
|
221
264
|
mutableAsset.setAST(ast);
|
|
222
265
|
}
|
|
266
|
+
cacheBailouts.push(`Transformer.parse`);
|
|
223
267
|
}
|
|
224
|
-
const result = await
|
|
268
|
+
const [result, sideEffects] = await this.#sideEffectDetector.monitorSideEffects(key, () => transformer.transform({
|
|
269
|
+
// @ts-expect-error TS2322
|
|
225
270
|
asset: mutableAsset,
|
|
226
271
|
config,
|
|
227
272
|
resolve: resolveFunc,
|
|
228
273
|
...defaultOptions
|
|
229
|
-
});
|
|
274
|
+
}));
|
|
275
|
+
if (sideEffects.envUsage.didEnumerate) {
|
|
276
|
+
cacheBailouts.push(`Env access: enumeration of process.env`);
|
|
277
|
+
}
|
|
278
|
+
for (let variable of sideEffects.envUsage.vars) {
|
|
279
|
+
if (variable in allowedEnv) {
|
|
280
|
+
continue;
|
|
281
|
+
}
|
|
282
|
+
cacheBailouts.push(`Env access: ${variable}`);
|
|
283
|
+
}
|
|
284
|
+
for (let {
|
|
285
|
+
method,
|
|
286
|
+
path
|
|
287
|
+
} of sideEffects.fsUsage) {
|
|
288
|
+
cacheBailouts.push(`FS usage: ${method}(${path})`);
|
|
289
|
+
}
|
|
290
|
+
(0, _assert().default)(result.length === 1, '[V3] Unimplemented: Multiple asset return from Node transformer');
|
|
291
|
+
(0, _assert().default)(result[0] === mutableAsset, '[V3] Unimplemented: New asset returned from Node transformer');
|
|
230
292
|
if (transformer.generate) {
|
|
231
293
|
const ast = await mutableAsset.getAST();
|
|
232
294
|
if (ast) {
|
|
233
|
-
// $FlowFixMe "Cannot call `transformer.generate` because undefined [1] is not a function." 🤷♀️
|
|
234
295
|
const output = await transformer.generate({
|
|
296
|
+
// @ts-expect-error TS2322
|
|
235
297
|
asset: mutableAsset,
|
|
236
298
|
ast,
|
|
237
299
|
...defaultOptions
|
|
@@ -241,6 +303,7 @@ class AtlaspackWorker {
|
|
|
241
303
|
} else if (output.content instanceof Buffer) {
|
|
242
304
|
mutableAsset.setBuffer(output.content);
|
|
243
305
|
} else {
|
|
306
|
+
// @ts-expect-error TS2345
|
|
244
307
|
mutableAsset.setStream(output.content);
|
|
245
308
|
}
|
|
246
309
|
if (output.map) {
|
|
@@ -248,8 +311,17 @@ class AtlaspackWorker {
|
|
|
248
311
|
}
|
|
249
312
|
}
|
|
250
313
|
}
|
|
251
|
-
|
|
252
|
-
|
|
314
|
+
let assetBuffer = await mutableAsset.getBuffer();
|
|
315
|
+
|
|
316
|
+
// If the asset has no code, we set the buffer to null, which we can
|
|
317
|
+
// detect in Rust, to avoid passing back an empty buffer, which we can't.
|
|
318
|
+
if (assetBuffer.length === 0) {
|
|
319
|
+
assetBuffer = null;
|
|
320
|
+
}
|
|
321
|
+
if (pluginOptions.used) {
|
|
322
|
+
// Plugin options accessed, so not cachable
|
|
323
|
+
cacheBailouts.push(`Plugin options accessed`);
|
|
324
|
+
}
|
|
253
325
|
return [{
|
|
254
326
|
id: mutableAsset.id,
|
|
255
327
|
bundleBehavior: _compat.bundleBehaviorMap.intoNullable(mutableAsset.bundleBehavior),
|
|
@@ -265,16 +337,72 @@ class AtlaspackWorker {
|
|
|
265
337
|
symbols: mutableAsset.symbols.intoNapi(),
|
|
266
338
|
type: mutableAsset.type,
|
|
267
339
|
uniqueKey: mutableAsset.uniqueKey
|
|
268
|
-
},
|
|
340
|
+
}, assetBuffer,
|
|
269
341
|
// Only send back the map if it has changed
|
|
270
342
|
mutableAsset.isMapDirty ?
|
|
271
|
-
//
|
|
272
|
-
JSON.stringify((await mutableAsset.getMap()).toVLQ()) : ''
|
|
343
|
+
// @ts-expect-error TS2533
|
|
344
|
+
JSON.stringify((await mutableAsset.getMap()).toVLQ()) : '',
|
|
345
|
+
// Limit to first 10 bailouts
|
|
346
|
+
cacheBailouts.slice(0, 10)];
|
|
273
347
|
});
|
|
348
|
+
get options() {
|
|
349
|
+
if (this.#options == null) {
|
|
350
|
+
throw new Error('Plugin options have not been initialized');
|
|
351
|
+
}
|
|
352
|
+
return this.#options;
|
|
353
|
+
}
|
|
354
|
+
async initializeTransformer(instance, specifier) {
|
|
355
|
+
let transformer = instance;
|
|
356
|
+
let setup, config, allowedEnv;
|
|
357
|
+
let packageManager = new (_packageManager().NodePackageManager)(this.#fs, this.options.projectRoot);
|
|
358
|
+
if (transformer.setup) {
|
|
359
|
+
var _setupResult$env;
|
|
360
|
+
let setupResult = await transformer.setup({
|
|
361
|
+
logger: new _compat.PluginLogger(),
|
|
362
|
+
options: new _compat.PluginOptions({
|
|
363
|
+
...this.options,
|
|
364
|
+
shouldAutoInstall: false,
|
|
365
|
+
inputFS: this.#fs,
|
|
366
|
+
outputFS: this.#fs,
|
|
367
|
+
packageManager
|
|
368
|
+
}),
|
|
369
|
+
config: new _compat.PluginConfig({
|
|
370
|
+
plugin: specifier,
|
|
371
|
+
searchPath: 'index',
|
|
372
|
+
// Consider project setup config as source
|
|
373
|
+
isSource: true
|
|
374
|
+
}, this.options)
|
|
375
|
+
});
|
|
376
|
+
config = setupResult === null || setupResult === void 0 ? void 0 : setupResult.config;
|
|
377
|
+
allowedEnv = Object.fromEntries((setupResult === null || setupResult === void 0 || (_setupResult$env = setupResult.env) === null || _setupResult$env === void 0 ? void 0 : _setupResult$env.map(env => [env, process.env[env]])) || []);
|
|
378
|
+
|
|
379
|
+
// Always add the following env vars to the cache key
|
|
380
|
+
allowedEnv['NODE_ENV'] = process.env['NODE_ENV'];
|
|
381
|
+
setup = {
|
|
382
|
+
conditions: setupResult === null || setupResult === void 0 ? void 0 : setupResult.conditions,
|
|
383
|
+
config,
|
|
384
|
+
env: allowedEnv
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
this.#transformers.set(specifier, {
|
|
388
|
+
transformer,
|
|
389
|
+
config,
|
|
390
|
+
packageManager,
|
|
391
|
+
allowedEnv
|
|
392
|
+
});
|
|
393
|
+
return setup;
|
|
394
|
+
}
|
|
274
395
|
}
|
|
275
396
|
|
|
276
397
|
// Create napi worker and send it back to main thread
|
|
277
398
|
exports.AtlaspackWorker = AtlaspackWorker;
|
|
278
399
|
const worker = new AtlaspackWorker();
|
|
279
400
|
const napiWorker = napi().newNodejsWorker(worker);
|
|
280
|
-
_worker_threads().parentPort === null || _worker_threads().parentPort === void 0 || _worker_threads().parentPort.postMessage(napiWorker);
|
|
401
|
+
_worker_threads().parentPort === null || _worker_threads().parentPort === void 0 || _worker_threads().parentPort.postMessage(napiWorker);
|
|
402
|
+
_worker_threads().parentPort === null || _worker_threads().parentPort === void 0 || _worker_threads().parentPort.setMaxListeners(_worker_threads().parentPort.getMaxListeners() + 1);
|
|
403
|
+
_worker_threads().parentPort === null || _worker_threads().parentPort === void 0 || _worker_threads().parentPort.addListener('message', message => {
|
|
404
|
+
if (message === 'clearState') {
|
|
405
|
+
worker.clearState();
|
|
406
|
+
_worker_threads().parentPort === null || _worker_threads().parentPort === void 0 || _worker_threads().parentPort.postMessage('stateCleared');
|
|
407
|
+
}
|
|
408
|
+
});
|
package/lib/constants.js
CHANGED
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.VALID = exports.STARTUP = exports.OPTION_CHANGE = exports.INITIAL_BUILD = exports.HASH_REF_REGEX = exports.HASH_REF_PREFIX = exports.HASH_REF_HASH_LEN = exports.FILE_UPDATE = exports.FILE_DELETE = exports.FILE_CREATE = exports.ERROR = exports.ENV_CHANGE = exports.ATLASPACK_VERSION = void 0;
|
|
7
7
|
var _package = require("../package.json");
|
|
8
|
-
// $FlowFixMe
|
|
9
8
|
const ATLASPACK_VERSION = exports.ATLASPACK_VERSION = _package.version;
|
|
10
9
|
const HASH_REF_PREFIX = exports.HASH_REF_PREFIX = 'HASH_REF_';
|
|
11
10
|
const HASH_REF_HASH_LEN = exports.HASH_REF_HASH_LEN = 16;
|
|
@@ -4,8 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = dumpGraphToGraphViz;
|
|
7
|
-
var _BundleGraph = require("./BundleGraph");
|
|
8
|
-
var _RequestTracker = require("./RequestTracker");
|
|
9
7
|
function _path() {
|
|
10
8
|
const data = _interopRequireDefault(require("path"));
|
|
11
9
|
_path = function () {
|
|
@@ -47,13 +45,13 @@ const TYPE_COLORS = {
|
|
|
47
45
|
};
|
|
48
46
|
async function dumpGraphToGraphViz(graph, name, edgeTypes) {
|
|
49
47
|
var _globalThis$ATLASPACK;
|
|
50
|
-
if (
|
|
48
|
+
if (process.env.ATLASPACK_BUILD_ENV === 'production' && !process.env.ATLASPACK_BUILD_REPL) {
|
|
51
49
|
return;
|
|
52
50
|
}
|
|
53
|
-
let mode = process.env.ATLASPACK_BUILD_REPL ? //
|
|
51
|
+
let mode = process.env.ATLASPACK_BUILD_REPL ? // @ts-expect-error TS7017
|
|
54
52
|
(_globalThis$ATLASPACK = globalThis.ATLASPACK_DUMP_GRAPHVIZ) === null || _globalThis$ATLASPACK === void 0 ? void 0 : _globalThis$ATLASPACK.mode : process.env.ATLASPACK_DUMP_GRAPHVIZ;
|
|
55
53
|
|
|
56
|
-
//
|
|
54
|
+
// @ts-expect-error TS2367
|
|
57
55
|
if (mode == null || mode == false) {
|
|
58
56
|
return;
|
|
59
57
|
}
|
|
@@ -61,38 +59,57 @@ async function dumpGraphToGraphViz(graph, name, edgeTypes) {
|
|
|
61
59
|
let GraphVizGraph = require('graphviz/lib/deps/graph').Graph;
|
|
62
60
|
let g = new GraphVizGraph(null, 'G');
|
|
63
61
|
g.type = 'digraph';
|
|
64
|
-
// $FlowFixMe
|
|
65
62
|
for (let [id, node] of graph.nodes.entries()) {
|
|
66
63
|
if (node == null) continue;
|
|
67
64
|
let n = g.addNode(nodeId(id));
|
|
68
|
-
//
|
|
65
|
+
// @ts-expect-error TS7053
|
|
69
66
|
n.set('color', COLORS[node.type || 'default']);
|
|
70
67
|
n.set('shape', 'box');
|
|
71
68
|
n.set('style', 'filled');
|
|
72
69
|
let label;
|
|
73
70
|
if (typeof node === 'string') {
|
|
74
71
|
label = node;
|
|
72
|
+
// @ts-expect-error TS2339
|
|
75
73
|
} else if (node.assets) {
|
|
74
|
+
// @ts-expect-error TS2339
|
|
76
75
|
label = `(${nodeId(id)}), (assetIds: ${[...node.assets].map(a => {
|
|
77
76
|
let arr = a.filePath.split('/');
|
|
78
77
|
return arr[arr.length - 1];
|
|
79
|
-
})
|
|
78
|
+
})
|
|
79
|
+
// @ts-expect-error TS2339
|
|
80
|
+
.join(', ')}) (sourceBundles: ${[...node.sourceBundles].join(', '
|
|
81
|
+
// @ts-expect-error TS2339
|
|
82
|
+
)}) (bb ${node.bundleBehavior ?? 'none'})`;
|
|
83
|
+
// @ts-expect-error TS2339
|
|
80
84
|
} else if (node.type) {
|
|
85
|
+
// @ts-expect-error TS2339
|
|
81
86
|
label = `[${(0, _graph().fromNodeId)(id)}] ${node.type || 'No Type'}: [${node.id}]: `;
|
|
87
|
+
// @ts-expect-error TS2339
|
|
82
88
|
if (node.type === 'dependency') {
|
|
89
|
+
// @ts-expect-error TS2339
|
|
83
90
|
label += node.value.specifier;
|
|
84
91
|
let parts = [];
|
|
92
|
+
// @ts-expect-error TS2339
|
|
85
93
|
if (node.value.priority !== _types.Priority.sync) {
|
|
86
94
|
var _Object$entries$find;
|
|
87
|
-
parts.push((_Object$entries$find = Object.entries(_types.Priority).find(
|
|
95
|
+
parts.push((_Object$entries$find = Object.entries(_types.Priority).find(
|
|
96
|
+
// @ts-expect-error TS2339
|
|
97
|
+
([, v]) => v === node.value.priority)) === null || _Object$entries$find === void 0 ? void 0 : _Object$entries$find[0]);
|
|
88
98
|
}
|
|
99
|
+
// @ts-expect-error TS2339
|
|
89
100
|
if (node.value.isOptional) parts.push('optional');
|
|
101
|
+
// @ts-expect-error TS2339
|
|
90
102
|
if (node.value.specifierType === _types.SpecifierType.url) parts.push('url');
|
|
103
|
+
// @ts-expect-error TS2339
|
|
91
104
|
if (node.hasDeferred) parts.push('deferred');
|
|
105
|
+
// @ts-expect-error TS2339
|
|
92
106
|
if (node.deferred) parts.push('deferred');
|
|
107
|
+
// @ts-expect-error TS2339
|
|
93
108
|
if (node.excluded) parts.push('excluded');
|
|
94
109
|
if (parts.length) label += ' (' + parts.join(', ') + ')';
|
|
110
|
+
// @ts-expect-error TS2339
|
|
95
111
|
if (node.value.env) label += ` (${getEnvDescription(node.value.env)})`;
|
|
112
|
+
// @ts-expect-error TS2339
|
|
96
113
|
let depSymbols = node.value.symbols;
|
|
97
114
|
if (detailedSymbols) {
|
|
98
115
|
if (depSymbols) {
|
|
@@ -107,11 +124,17 @@ async function dumpGraphToGraphViz(graph, name, edgeTypes) {
|
|
|
107
124
|
if (weakSymbols.length) {
|
|
108
125
|
label += '\\nweakSymbols: ' + weakSymbols.join(',');
|
|
109
126
|
}
|
|
127
|
+
// @ts-expect-error TS2339
|
|
110
128
|
if (node.usedSymbolsUp.size > 0) {
|
|
111
|
-
label += '\\nusedSymbolsUp: ' +
|
|
129
|
+
label += '\\nusedSymbolsUp: ' +
|
|
130
|
+
// @ts-expect-error TS2339
|
|
131
|
+
[...node.usedSymbolsUp].map(([s, sAsset]) => sAsset ? `${s}(${sAsset.asset}.${sAsset.symbol ?? ''})` : sAsset === null ? `${s}(external)` : `${s}(ambiguous)`).join(',');
|
|
112
132
|
}
|
|
133
|
+
// @ts-expect-error TS2339
|
|
113
134
|
if (node.usedSymbolsDown.size > 0) {
|
|
114
|
-
label +=
|
|
135
|
+
label +=
|
|
136
|
+
// @ts-expect-error TS2339
|
|
137
|
+
'\\nusedSymbolsDown: ' + [...node.usedSymbolsDown].join(',');
|
|
115
138
|
}
|
|
116
139
|
// if (node.usedSymbolsDownDirty) label += '\\nusedSymbolsDownDirty';
|
|
117
140
|
// if (node.usedSymbolsUpDirtyDown)
|
|
@@ -121,17 +144,28 @@ async function dumpGraphToGraphViz(graph, name, edgeTypes) {
|
|
|
121
144
|
label += '\\nsymbols: cleared';
|
|
122
145
|
}
|
|
123
146
|
}
|
|
147
|
+
// @ts-expect-error TS2339
|
|
124
148
|
} else if (node.type === 'asset') {
|
|
125
|
-
label +=
|
|
149
|
+
label +=
|
|
150
|
+
// @ts-expect-error TS2339
|
|
151
|
+
_path().default.basename((0, _projectPath.fromProjectPathRelative)(node.value.filePath)) + '#' +
|
|
152
|
+
// @ts-expect-error TS2339
|
|
153
|
+
node.value.type;
|
|
126
154
|
if (detailedSymbols) {
|
|
155
|
+
// @ts-expect-error TS2339
|
|
127
156
|
if (!node.value.symbols) {
|
|
128
157
|
label += '\\nsymbols: cleared';
|
|
158
|
+
// @ts-expect-error TS2339
|
|
129
159
|
} else if (node.value.symbols.size) {
|
|
130
|
-
label += '\\nsymbols: ' +
|
|
160
|
+
label += '\\nsymbols: ' +
|
|
161
|
+
// @ts-expect-error TS2339
|
|
162
|
+
[...node.value.symbols].map(([e, {
|
|
131
163
|
local
|
|
132
164
|
}]) => [e, local]).join(';');
|
|
133
165
|
}
|
|
166
|
+
// @ts-expect-error TS2339
|
|
134
167
|
if (node.usedSymbols.size) {
|
|
168
|
+
// @ts-expect-error TS2339
|
|
135
169
|
label += '\\nusedSymbols: ' + [...node.usedSymbols].join(',');
|
|
136
170
|
}
|
|
137
171
|
// if (node.usedSymbolsDownDirty) label += '\\nusedSymbolsDownDirty';
|
|
@@ -139,21 +173,38 @@ async function dumpGraphToGraphViz(graph, name, edgeTypes) {
|
|
|
139
173
|
} else {
|
|
140
174
|
label += '\\nsymbols: cleared';
|
|
141
175
|
}
|
|
176
|
+
// @ts-expect-error TS2339
|
|
142
177
|
} else if (node.type === 'asset_group') {
|
|
178
|
+
// @ts-expect-error TS2339
|
|
143
179
|
if (node.deferred) label += '(deferred)';
|
|
180
|
+
// @ts-expect-error TS2339
|
|
144
181
|
} else if (node.type === 'file') {
|
|
182
|
+
// @ts-expect-error TS2339
|
|
145
183
|
label += _path().default.basename(node.id);
|
|
184
|
+
// @ts-expect-error TS2339
|
|
146
185
|
} else if (node.type === 'transformer_request') {
|
|
147
|
-
label +=
|
|
186
|
+
label +=
|
|
187
|
+
// @ts-expect-error TS2339
|
|
188
|
+
_path().default.basename(node.value.filePath) +
|
|
189
|
+
// @ts-expect-error TS2339
|
|
190
|
+
` (${getEnvDescription(node.value.env)})`;
|
|
191
|
+
// @ts-expect-error TS2339
|
|
148
192
|
} else if (node.type === 'bundle') {
|
|
149
193
|
let parts = [];
|
|
194
|
+
// @ts-expect-error TS2339
|
|
150
195
|
if (node.value.needsStableName) parts.push('stable name');
|
|
196
|
+
// @ts-expect-error TS2339
|
|
151
197
|
parts.push(node.value.name);
|
|
198
|
+
// @ts-expect-error TS2339
|
|
152
199
|
parts.push('bb:' + (node.value.bundleBehavior ?? 'null'));
|
|
200
|
+
// @ts-expect-error TS2339
|
|
153
201
|
if (node.value.isPlaceholder) parts.push('placeholder');
|
|
154
202
|
if (parts.length) label += ' (' + parts.join(', ') + ')';
|
|
203
|
+
// @ts-expect-error TS2339
|
|
155
204
|
if (node.value.env) label += ` (${getEnvDescription(node.value.env)})`;
|
|
205
|
+
// @ts-expect-error TS2339
|
|
156
206
|
} else if (node.type === 'request') {
|
|
207
|
+
// @ts-expect-error TS2339
|
|
157
208
|
label = node.requestType + ':' + node.id;
|
|
158
209
|
}
|
|
159
210
|
}
|
|
@@ -163,10 +214,13 @@ async function dumpGraphToGraphViz(graph, name, edgeTypes) {
|
|
|
163
214
|
if (edgeTypes) {
|
|
164
215
|
edgeNames = Object.fromEntries(Object.entries(edgeTypes).map(([k, v]) => [v, k]));
|
|
165
216
|
}
|
|
217
|
+
|
|
218
|
+
// @ts-expect-error TS2488
|
|
166
219
|
for (let edge of graph.getAllEdges()) {
|
|
167
220
|
let gEdge = g.addEdge(nodeId(edge.from), nodeId(edge.to));
|
|
168
221
|
let color = null;
|
|
169
222
|
if (edge.type != 1 && edgeNames) {
|
|
223
|
+
// @ts-expect-error TS7053
|
|
170
224
|
color = TYPE_COLORS[edgeNames[edge.type]];
|
|
171
225
|
}
|
|
172
226
|
if (color != null) {
|
|
@@ -175,7 +229,7 @@ async function dumpGraphToGraphViz(graph, name, edgeTypes) {
|
|
|
175
229
|
}
|
|
176
230
|
if (process.env.ATLASPACK_BUILD_REPL) {
|
|
177
231
|
var _globalThis$ATLASPACK2;
|
|
178
|
-
//
|
|
232
|
+
// @ts-expect-error TS7017
|
|
179
233
|
(_globalThis$ATLASPACK2 = globalThis.ATLASPACK_DUMP_GRAPHVIZ) === null || _globalThis$ATLASPACK2 === void 0 || _globalThis$ATLASPACK2.call(globalThis, name, g.to_dot());
|
|
180
234
|
} else {
|
|
181
235
|
const tempy = require('tempy');
|
|
@@ -187,8 +241,9 @@ async function dumpGraphToGraphViz(graph, name, edgeTypes) {
|
|
|
187
241
|
console.log('Dumped', tmp);
|
|
188
242
|
}
|
|
189
243
|
}
|
|
244
|
+
|
|
245
|
+
// @ts-expect-error TS2552
|
|
190
246
|
function nodeId(id) {
|
|
191
|
-
// $FlowFixMe
|
|
192
247
|
return `node${id}`;
|
|
193
248
|
}
|
|
194
249
|
function getEnvDescription(env) {
|