packtory 0.0.15 → 0.0.17
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/artifacts/artifacts-builder.d.ts +3 -1
- package/artifacts/artifacts-builder.d.ts.map +1 -1
- package/artifacts/artifacts-builder.js +20 -74
- package/artifacts/artifacts-builder.js.map +1 -1
- package/artifacts/content-collection.js +60 -0
- package/artifacts/content-collection.js.map +1 -0
- package/artifacts/folder-writer.js +24 -0
- package/artifacts/folder-writer.js.map +1 -0
- package/bundle-emitter/emitter.d.ts +3 -2
- package/bundle-emitter/emitter.d.ts.map +1 -1
- package/bundle-emitter/emitter.js +10 -8
- package/bundle-emitter/emitter.js.map +1 -1
- package/bundle-emitter/fetch-published-artifacts.d.ts +10 -0
- package/bundle-emitter/fetch-published-artifacts.d.ts.map +1 -0
- package/bundle-emitter/fetch-published-artifacts.js +16 -0
- package/bundle-emitter/fetch-published-artifacts.js.map +1 -0
- package/bundle-emitter/publish-error/auto-mode-error-matching.js +30 -0
- package/bundle-emitter/publish-error/auto-mode-error-matching.js.map +1 -0
- package/bundle-emitter/publish-error/error-shape-helpers.js +10 -0
- package/bundle-emitter/publish-error/error-shape-helpers.js.map +1 -0
- package/bundle-emitter/publish-error/file-mode-error-matching.js +28 -0
- package/bundle-emitter/publish-error/file-mode-error-matching.js.map +1 -0
- package/bundle-emitter/publish-error/publish-error-messages.js +37 -0
- package/bundle-emitter/publish-error/publish-error-messages.js.map +1 -0
- package/bundle-emitter/registry/metadata-auth-retry.js +26 -0
- package/bundle-emitter/registry/metadata-auth-retry.js.map +1 -0
- package/bundle-emitter/registry/oidc-token-exchange.js +83 -0
- package/bundle-emitter/registry/oidc-token-exchange.js.map +1 -0
- package/bundle-emitter/registry/package-metadata-fetcher.d.ts +4 -0
- package/bundle-emitter/registry/package-metadata-fetcher.d.ts.map +1 -0
- package/bundle-emitter/registry/package-metadata-fetcher.js +99 -0
- package/bundle-emitter/registry/package-metadata-fetcher.js.map +1 -0
- package/bundle-emitter/registry/publish-settings-bridge.js +39 -0
- package/bundle-emitter/registry/publish-settings-bridge.js.map +1 -0
- package/bundle-emitter/registry/registry-auth-config.js +82 -0
- package/bundle-emitter/registry/registry-auth-config.js.map +1 -0
- package/bundle-emitter/registry/registry-client.d.ts +10 -0
- package/bundle-emitter/registry/registry-client.d.ts.map +1 -0
- package/bundle-emitter/registry/registry-client.js +38 -0
- package/bundle-emitter/registry/registry-client.js.map +1 -0
- package/bundle-emitter/registry/registry-response-schemas.js +45 -0
- package/bundle-emitter/registry/registry-response-schemas.js.map +1 -0
- package/bundle-emitter/repository-url-normalizer.js +2 -4
- package/bundle-emitter/repository-url-normalizer.js.map +1 -1
- package/checks/rules/duplicate-detection.js +26 -0
- package/checks/rules/duplicate-detection.js.map +1 -0
- package/checks/rules/duplicate-messages.js +26 -0
- package/checks/rules/duplicate-messages.js.map +1 -0
- package/checks/rules/file-ownership.js +16 -0
- package/checks/rules/file-ownership.js.map +1 -0
- package/checks/rules/no-duplicated-files.js +2 -76
- package/checks/rules/no-duplicated-files.js.map +1 -1
- package/checks/rules/required-files.js +2 -1
- package/checks/rules/required-files.js.map +1 -1
- package/checks/rules/set-intersection.js +14 -0
- package/checks/rules/set-intersection.js.map +1 -0
- package/checks/rules/unique-target-paths.js +11 -10
- package/checks/rules/unique-target-paths.js.map +1 -1
- package/common/code-files.js +21 -0
- package/common/code-files.js.map +1 -1
- package/common/max-date.js +6 -0
- package/common/max-date.js.map +1 -0
- package/common/sort-values.js.map +1 -0
- package/common/stable-json.js +42 -0
- package/common/stable-json.js.map +1 -0
- package/common/typed-diff.d.ts +3 -0
- package/common/typed-diff.d.ts.map +1 -0
- package/common/typed-diff.js +5 -0
- package/common/typed-diff.js.map +1 -0
- package/config/config.d.ts +0 -3
- package/config/config.d.ts.map +1 -1
- package/config/cross-package-validation.js +18 -0
- package/config/cross-package-validation.js.map +1 -0
- package/config/dependency-existence-validation.js +20 -0
- package/config/dependency-existence-validation.js.map +1 -0
- package/config/package-config.d.ts +0 -2
- package/config/package-config.d.ts.map +1 -1
- package/config/package-graph-builder.js +15 -0
- package/config/package-graph-builder.js.map +1 -0
- package/config/pre-graph-validation.js +19 -0
- package/config/pre-graph-validation.js.map +1 -0
- package/config/root-config-validation.js +126 -0
- package/config/root-config-validation.js.map +1 -0
- package/config/settings-validation.js +29 -0
- package/config/settings-validation.js.map +1 -0
- package/config/validation.d.ts +2 -2
- package/config/validation.d.ts.map +1 -1
- package/config/validation.js +9 -231
- package/config/validation.js.map +1 -1
- package/dead-code-eliminator/class-purity.js +33 -0
- package/dead-code-eliminator/class-purity.js.map +1 -0
- package/dead-code-eliminator/code-file-analyzer.js +56 -0
- package/dead-code-eliminator/code-file-analyzer.js.map +1 -0
- package/dead-code-eliminator/cross-bundle/bundle-index.js +31 -0
- package/dead-code-eliminator/cross-bundle/bundle-index.js.map +1 -0
- package/dead-code-eliminator/cross-bundle/cross-bundle-seeds.js +4 -111
- package/dead-code-eliminator/cross-bundle/cross-bundle-seeds.js.map +1 -1
- package/dead-code-eliminator/cross-bundle/import-export-walker.js +69 -0
- package/dead-code-eliminator/cross-bundle/import-export-walker.js.map +1 -0
- package/dead-code-eliminator/cross-bundle/seed-store.js +19 -0
- package/dead-code-eliminator/cross-bundle/seed-store.js.map +1 -0
- package/dead-code-eliminator/eliminator.js +3 -83
- package/dead-code-eliminator/eliminator.js.map +1 -1
- package/dead-code-eliminator/expression-unwrapping.js +17 -0
- package/dead-code-eliminator/expression-unwrapping.js.map +1 -0
- package/dead-code-eliminator/imported-expression-origin.js +95 -0
- package/dead-code-eliminator/imported-expression-origin.js.map +1 -0
- package/dead-code-eliminator/load-bundle.js +1 -1
- package/dead-code-eliminator/load-bundle.js.map +1 -1
- package/dead-code-eliminator/pure-expression.js +116 -0
- package/dead-code-eliminator/pure-expression.js.map +1 -0
- package/dead-code-eliminator/reachability/bfs-closure.js +40 -0
- package/dead-code-eliminator/reachability/bfs-closure.js.map +1 -0
- package/dead-code-eliminator/reachability/binding-id.js +33 -0
- package/dead-code-eliminator/reachability/binding-id.js.map +1 -0
- package/dead-code-eliminator/reachability/identifier-target-collector.js +36 -0
- package/dead-code-eliminator/reachability/identifier-target-collector.js.map +1 -0
- package/dead-code-eliminator/reachability/local-seed-gathering.js +24 -0
- package/dead-code-eliminator/reachability/local-seed-gathering.js.map +1 -0
- package/dead-code-eliminator/reachability/reachability.js +19 -130
- package/dead-code-eliminator/reachability/reachability.js.map +1 -1
- package/dead-code-eliminator/side-effect-classifier.js +2 -394
- package/dead-code-eliminator/side-effect-classifier.js.map +1 -1
- package/dead-code-eliminator/source-map-recomposition.js +27 -0
- package/dead-code-eliminator/source-map-recomposition.js.map +1 -0
- package/dead-code-eliminator/statement-classifiers.js +67 -0
- package/dead-code-eliminator/statement-classifiers.js.map +1 -0
- package/dead-code-eliminator/syntax-kind-sets.js +67 -0
- package/dead-code-eliminator/syntax-kind-sets.js.map +1 -0
- package/dead-code-eliminator/transform/declaration-removal.js +34 -0
- package/dead-code-eliminator/transform/declaration-removal.js.map +1 -0
- package/dead-code-eliminator/transform/declaration-remover.js +2 -72
- package/dead-code-eliminator/transform/declaration-remover.js.map +1 -1
- package/dead-code-eliminator/transform/named-declaration-kinds.js +13 -0
- package/dead-code-eliminator/transform/named-declaration-kinds.js.map +1 -0
- package/dead-code-eliminator/transform/survivor-capture.js +33 -0
- package/dead-code-eliminator/transform/survivor-capture.js.map +1 -0
- package/dependency-scanner/dependency-graph.js +46 -28
- package/dependency-scanner/dependency-graph.js.map +1 -1
- package/dependency-scanner/file-host-predicates.js +10 -0
- package/dependency-scanner/file-host-predicates.js.map +1 -0
- package/dependency-scanner/host-method-binding.js +19 -0
- package/dependency-scanner/host-method-binding.js.map +1 -0
- package/dependency-scanner/node-modules-manifest-synthesizer.js +55 -0
- package/dependency-scanner/node-modules-manifest-synthesizer.js.map +1 -0
- package/dependency-scanner/package-owned-asset-file-path.js +21 -0
- package/dependency-scanner/package-owned-asset-file-path.js.map +1 -0
- package/dependency-scanner/scanner.d.ts +1 -1
- package/dependency-scanner/scanner.d.ts.map +1 -1
- package/dependency-scanner/scanner.js +34 -39
- package/dependency-scanner/scanner.js.map +1 -1
- package/dependency-scanner/source-file-references.d.ts +3 -0
- package/dependency-scanner/source-file-references.d.ts.map +1 -0
- package/dependency-scanner/source-file-references.js +106 -7
- package/dependency-scanner/source-file-references.js.map +1 -1
- package/dependency-scanner/typescript-compiler-options.d.ts +3 -0
- package/dependency-scanner/typescript-compiler-options.d.ts.map +1 -0
- package/dependency-scanner/typescript-compiler-options.js +22 -0
- package/dependency-scanner/typescript-compiler-options.js.map +1 -0
- package/dependency-scanner/typescript-file-host.d.ts.map +1 -1
- package/dependency-scanner/typescript-file-host.js +15 -81
- package/dependency-scanner/typescript-file-host.js.map +1 -1
- package/dependency-scanner/typescript-project-analyzer.d.ts +3 -3
- package/dependency-scanner/typescript-project-analyzer.d.ts.map +1 -1
- package/dependency-scanner/typescript-project-analyzer.js +6 -26
- package/dependency-scanner/typescript-project-analyzer.js.map +1 -1
- package/dependency-scanner/virtual-package-json-host.js +45 -0
- package/dependency-scanner/virtual-package-json-host.js.map +1 -0
- package/directed-graph/graph.js +19 -8
- package/directed-graph/graph.js.map +1 -1
- package/file-manager/file-description.d.ts.map +1 -1
- package/file-manager/file-description.js +4 -0
- package/file-manager/file-description.js.map +1 -0
- package/file-manager/file-manager.js +30 -1
- package/file-manager/file-manager.js.map +1 -1
- package/file-manager/permissions.js +5 -4
- package/file-manager/permissions.js.map +1 -1
- package/linker/linked-bundle.d.ts.map +1 -1
- package/linker/linked-bundle.js +6 -0
- package/linker/linked-bundle.js.map +1 -0
- package/linker/linker.d.ts +1 -1
- package/linker/linker.d.ts.map +1 -1
- package/linker/linker.js +2 -1
- package/linker/linker.js.map +1 -1
- package/linker/replacement-lookup.js +41 -0
- package/linker/replacement-lookup.js.map +1 -0
- package/linker/resource-graph.js +2 -1
- package/linker/resource-graph.js.map +1 -1
- package/linker/substitute-bundles.js +4 -42
- package/linker/substitute-bundles.js.map +1 -1
- package/linker/substituted-resource-graph.js +2 -1
- package/linker/substituted-resource-graph.js.map +1 -1
- package/pack-emitter/pack-emitter.d.ts +8 -0
- package/pack-emitter/pack-emitter.d.ts.map +1 -0
- package/pack-emitter/pack-emitter.js +28 -0
- package/pack-emitter/pack-emitter.js.map +1 -0
- package/package-surface/bin-field.js +9 -0
- package/package-surface/bin-field.js.map +1 -0
- package/package-surface/explicit-bin.js +25 -0
- package/package-surface/explicit-bin.js.map +1 -0
- package/package-surface/explicit-exports.js +12 -0
- package/package-surface/explicit-exports.js.map +1 -0
- package/package-surface/explicit-specifier-build.js +28 -0
- package/package-surface/explicit-specifier-build.js.map +1 -0
- package/package-surface/explicit-specifier-resolve.js +17 -0
- package/package-surface/explicit-specifier-resolve.js.map +1 -0
- package/package-surface/export-map.js +10 -0
- package/package-surface/export-map.js.map +1 -0
- package/package-surface/implicit-bin.js +23 -0
- package/package-surface/implicit-bin.js.map +1 -0
- package/package-surface/implicit-exports.js +11 -0
- package/package-surface/implicit-exports.js.map +1 -0
- package/package-surface/implicit-root-exports.js +14 -0
- package/package-surface/implicit-root-exports.js.map +1 -0
- package/package-surface/implicit-specifier-build.js +26 -0
- package/package-surface/implicit-specifier-build.js.map +1 -0
- package/package-surface/implicit-specifier-resolve.js +17 -0
- package/package-surface/implicit-specifier-resolve.js.map +1 -0
- package/package-surface/package-json-export.js +10 -0
- package/package-surface/package-json-export.js.map +1 -0
- package/package-surface/package-shape.js +10 -0
- package/package-surface/package-shape.js.map +1 -0
- package/package-surface/public-module-usage.js +1 -1
- package/package-surface/public-module-usage.js.map +1 -1
- package/package-surface/public-specifiers.js +17 -0
- package/package-surface/public-specifiers.js.map +1 -0
- package/package-surface/root-registry.js +35 -0
- package/package-surface/root-registry.js.map +1 -0
- package/package-surface/specifier-syntax.js +24 -0
- package/package-surface/specifier-syntax.js.map +1 -0
- package/package-surface/substitution-exports.js +67 -0
- package/package-surface/substitution-exports.js.map +1 -0
- package/package.json +25 -12
- package/packages/package-processor.composition.js +54 -25
- package/packages/package-processor.composition.js.map +1 -1
- package/packages/packtory/packtory.entry-point.d.ts +24 -14
- package/packages/packtory/packtory.entry-point.d.ts.map +1 -1
- package/packages/packtory/packtory.entry-point.js +7 -3
- package/packages/packtory/packtory.entry-point.js.map +1 -1
- package/packtory/map-config.d.ts +3 -2
- package/packtory/map-config.d.ts.map +1 -1
- package/packtory/map-config.js +2 -1
- package/packtory/map-config.js.map +1 -1
- package/packtory/options/bundle-dependency-resolution.js +20 -0
- package/packtory/options/bundle-dependency-resolution.js.map +1 -0
- package/packtory/options/dead-code-elimination-resolution.js +11 -0
- package/packtory/options/dead-code-elimination-resolution.js.map +1 -0
- package/packtory/options/prepare-package-options.d.ts +18 -0
- package/packtory/options/prepare-package-options.d.ts.map +1 -0
- package/packtory/options/prepare-package-options.js +46 -0
- package/packtory/options/prepare-package-options.js.map +1 -0
- package/packtory/options/required-value-helpers.js +18 -0
- package/packtory/options/required-value-helpers.js.map +1 -0
- package/packtory/options/setting-resolvers.d.ts +6 -0
- package/packtory/options/setting-resolvers.d.ts.map +1 -0
- package/packtory/options/setting-resolvers.js +42 -0
- package/packtory/options/setting-resolvers.js.map +1 -0
- package/packtory/options/surface-resolution.js +16 -0
- package/packtory/options/surface-resolution.js.map +1 -0
- package/packtory/options/version-trigger.js +31 -0
- package/packtory/options/version-trigger.js.map +1 -0
- package/packtory/package-processor-build.js +2 -1
- package/packtory/package-processor-build.js.map +1 -1
- package/packtory/package-processor-publish.d.ts +5 -0
- package/packtory/package-processor-publish.d.ts.map +1 -1
- package/packtory/package-processor-publish.js +25 -40
- package/packtory/package-processor-publish.js.map +1 -1
- package/packtory/packtory-pack.js +221 -0
- package/packtory/packtory-pack.js.map +1 -0
- package/packtory/packtory-publish.js +3 -51
- package/packtory/packtory-publish.js.map +1 -1
- package/packtory/packtory-release-analysis.js +69 -0
- package/packtory/packtory-release-analysis.js.map +1 -0
- package/packtory/packtory-release-diff.js +48 -0
- package/packtory/packtory-release-diff.js.map +1 -0
- package/packtory/packtory-resolve.js +3 -71
- package/packtory/packtory-resolve.js.map +1 -1
- package/packtory/packtory-results.d.ts +73 -1
- package/packtory/packtory-results.d.ts.map +1 -1
- package/packtory/packtory-results.js +15 -0
- package/packtory/packtory-results.js.map +1 -1
- package/packtory/packtory.d.ts +15 -1
- package/packtory/packtory.d.ts.map +1 -1
- package/packtory/packtory.js +58 -5
- package/packtory/packtory.js.map +1 -1
- package/packtory/publish-failure-mapping.js +7 -0
- package/packtory/publish-failure-mapping.js.map +1 -0
- package/packtory/release-analysis.js +147 -0
- package/packtory/release-analysis.js.map +1 -0
- package/packtory/release-diff-failure-mapping.js +7 -0
- package/packtory/release-diff-failure-mapping.js.map +1 -0
- package/packtory/report-attachment.js +12 -1
- package/packtory/report-attachment.js.map +1 -1
- package/packtory/stages/package-analysis-stage.js +24 -0
- package/packtory/stages/package-analysis-stage.js.map +1 -0
- package/packtory/stages/package-resolution-stage.js +44 -0
- package/packtory/stages/package-resolution-stage.js.map +1 -0
- package/packtory/stages/publish-stage.js +44 -0
- package/packtory/stages/publish-stage.js.map +1 -0
- package/packtory/stages/release-diff-stage.js +84 -0
- package/packtory/stages/release-diff-stage.js.map +1 -0
- package/published-package/published-package.d.ts +39 -0
- package/published-package/published-package.d.ts.map +1 -0
- package/published-package/published-package.js +11 -0
- package/published-package/published-package.js.map +1 -0
- package/readme.md +27 -12
- package/report/aggregator/artifact-entry-merger.js.map +1 -0
- package/report/aggregator/package-report-materialization.js +63 -0
- package/report/aggregator/package-report-materialization.js.map +1 -0
- package/report/aggregator/report-aggregator.js +36 -0
- package/report/aggregator/report-aggregator.js.map +1 -0
- package/report/{report-aggregator.js → aggregator/report-event-handlers.js} +8 -95
- package/report/aggregator/report-event-handlers.js.map +1 -0
- package/report/{report-aggregator.d.ts → aggregator/report-types.d.ts} +2 -2
- package/report/aggregator/report-types.d.ts.map +1 -0
- package/report/aggregator/report-types.js +4 -0
- package/report/aggregator/report-types.js.map +1 -0
- package/report/config-redactor.js.map +1 -1
- package/report/inspectors/inspect-artifact-sizes.js +34 -0
- package/report/inspectors/inspect-artifact-sizes.js.map +1 -0
- package/report/inspectors/inspect-linker-rewrites.js +15 -0
- package/report/inspectors/inspect-linker-rewrites.js.map +1 -0
- package/report/inspectors/inspect-package-json-provenance.js +16 -0
- package/report/inspectors/inspect-package-json-provenance.js.map +1 -0
- package/report/inspectors/inspect-scan-results.js +10 -0
- package/report/inspectors/inspect-scan-results.js.map +1 -0
- package/report/preview/preview-document-diff.d.ts +13 -0
- package/report/preview/preview-document-diff.d.ts.map +1 -0
- package/report/preview/preview-document-diff.js +29 -0
- package/report/preview/preview-document-diff.js.map +1 -0
- package/report/release-diff/file-hunks.js +10 -0
- package/report/release-diff/file-hunks.js.map +1 -0
- package/report/release-diff/file-set-diff.d.ts +49 -0
- package/report/release-diff/file-set-diff.d.ts.map +1 -0
- package/report/release-diff/file-set-diff.js +71 -0
- package/report/release-diff/file-set-diff.js.map +1 -0
- package/report/release-diff/release-version-transition.js +17 -0
- package/report/release-diff/release-version-transition.js.map +1 -0
- package/resource-resolver/bundle-resource-lookup.js +24 -0
- package/resource-resolver/bundle-resource-lookup.js.map +1 -0
- package/resource-resolver/content.js +8 -4
- package/resource-resolver/content.js.map +1 -1
- package/resource-resolver/dependency-resolution-walker.js +25 -0
- package/resource-resolver/dependency-resolution-walker.js.map +1 -0
- package/resource-resolver/resolved-bundle.d.ts +1 -0
- package/resource-resolver/resolved-bundle.d.ts.map +1 -1
- package/resource-resolver/resolved-bundle.js +4 -0
- package/resource-resolver/resolved-bundle.js.map +1 -0
- package/resource-resolver/resource-resolve-options.js.map +1 -1
- package/resource-resolver/resource-resolver.d.ts.map +1 -1
- package/resource-resolver/resource-resolver.js +22 -57
- package/resource-resolver/resource-resolver.js.map +1 -1
- package/sbom/sbom-canonicalizer.js +46 -0
- package/sbom/sbom-canonicalizer.js.map +1 -0
- package/sbom/sbom-file.d.ts +2 -2
- package/sbom/sbom-file.d.ts.map +1 -1
- package/sbom/sbom-file.js +2 -5
- package/sbom/sbom-file.js.map +1 -1
- package/tar/extract-tar.js +11 -8
- package/tar/extract-tar.js.map +1 -1
- package/tar/tarball-builder.d.ts +4 -0
- package/tar/tarball-builder.d.ts.map +1 -1
- package/tar/tarball-builder.js +24 -11
- package/tar/tarball-builder.js.map +1 -1
- package/vendor-materializer/vendor-entry.d.ts +1 -0
- package/vendor-materializer/vendor-entry.d.ts.map +1 -0
- package/vendor-materializer/vendor-entry.js +8 -0
- package/vendor-materializer/vendor-entry.js.map +1 -0
- package/vendor-materializer/vendor-materializer.d.ts +5 -0
- package/vendor-materializer/vendor-materializer.d.ts.map +1 -0
- package/vendor-materializer/vendor-materializer.js +232 -0
- package/vendor-materializer/vendor-materializer.js.map +1 -0
- package/version-manager/dependencies/bundle-dependency-grouping.js +23 -0
- package/version-manager/dependencies/bundle-dependency-grouping.js.map +1 -0
- package/version-manager/dependencies/dependency-groups.js +12 -0
- package/version-manager/dependencies/dependency-groups.js.map +1 -0
- package/version-manager/{versioned-bundle-dependencies.js → dependencies/external-dependency-classification.js} +4 -42
- package/version-manager/dependencies/external-dependency-classification.js.map +1 -0
- package/version-manager/dependencies/versioned-bundle-dependencies.js +9 -0
- package/version-manager/dependencies/versioned-bundle-dependencies.js.map +1 -0
- package/version-manager/imports/hash-import-scanner.js +21 -0
- package/version-manager/imports/hash-import-scanner.js.map +1 -0
- package/version-manager/imports/imports-key-matcher.js +21 -0
- package/version-manager/imports/imports-key-matcher.js.map +1 -0
- package/version-manager/{versioned-bundle-imports.js → imports/versioned-bundle-imports.js} +3 -36
- package/version-manager/imports/versioned-bundle-imports.js.map +1 -0
- package/version-manager/manager.js +1 -1
- package/version-manager/manager.js.map +1 -1
- package/version-manager/manifest/builder.js +3 -5
- package/version-manager/manifest/builder.js.map +1 -1
- package/version-manager/manifest/serialize.js +2 -41
- package/version-manager/manifest/serialize.js.map +1 -1
- package/version-manager/optional-bundle-fields.js +9 -0
- package/version-manager/optional-bundle-fields.js.map +1 -0
- package/version-manager/representative-root.js +30 -0
- package/version-manager/representative-root.js.map +1 -0
- package/version-manager/specifier-classifier.js +14 -11
- package/version-manager/specifier-classifier.js.map +1 -1
- package/version-manager/versioned-bundle.d.ts +7 -23
- package/version-manager/versioned-bundle.d.ts.map +1 -1
- package/version-manager/versioned-bundle.js +7 -40
- package/version-manager/versioned-bundle.js.map +1 -1
- package/zip/zip-builder.d.ts +5 -0
- package/zip/zip-builder.d.ts.map +1 -0
- package/zip/zip-builder.js +80 -0
- package/zip/zip-builder.js.map +1 -0
- package/bundle-emitter/publish-settings-bridge.js +0 -133
- package/bundle-emitter/publish-settings-bridge.js.map +0 -1
- package/bundle-emitter/registry-client.d.ts +0 -9
- package/bundle-emitter/registry-client.d.ts.map +0 -1
- package/bundle-emitter/registry-client.js +0 -265
- package/bundle-emitter/registry-client.js.map +0 -1
- package/package-surface/modules.js +0 -319
- package/package-surface/modules.js.map +0 -1
- package/packtory/prepare-package-options.d.ts +0 -14
- package/packtory/prepare-package-options.d.ts.map +0 -1
- package/packtory/prepare-package-options.js +0 -128
- package/packtory/prepare-package-options.js.map +0 -1
- package/report/artifact-entry-merger.js.map +0 -1
- package/report/inspectors.js +0 -74
- package/report/inspectors.js.map +0 -1
- package/report/report-aggregator.d.ts.map +0 -1
- package/report/report-aggregator.js.map +0 -1
- package/version-manager/manifest/sort-values.js.map +0 -1
- package/version-manager/versioned-bundle-dependencies.js.map +0 -1
- package/version-manager/versioned-bundle-imports.d.ts +0 -4
- package/version-manager/versioned-bundle-imports.d.ts.map +0 -1
- package/version-manager/versioned-bundle-imports.js.map +0 -1
- /package/{version-manager/manifest → common}/sort-values.js +0 -0
- /package/report/{artifact-entry-merger.js → aggregator/artifact-entry-merger.js} +0 -0
package/config/validation.js
CHANGED
|
@@ -1,217 +1,10 @@
|
|
|
1
1
|
import { Result } from 'true-myth';
|
|
2
2
|
import { safeParse } from '@schema-hub/zod-error-formatter';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { getBundledDependencies } from "./config.js";
|
|
3
|
+
import { validateCyclicDependencies, validateDuplicatePackages } from "./cross-package-validation.js";
|
|
4
|
+
import { buildPackageGraph } from "./package-graph-builder.js";
|
|
6
5
|
import { packtoryConfigSchema } from "./packtory-config-schema.js";
|
|
7
6
|
import { packtoryConfigWithoutRegistrySchema } from "./packtory-config-without-registry-schema.js";
|
|
8
|
-
|
|
9
|
-
const graph = createDirectedGraph();
|
|
10
|
-
for (const packageConfig of Object.values(packages)) {
|
|
11
|
-
graph.addNode(packageConfig.name, undefined);
|
|
12
|
-
}
|
|
13
|
-
for (const packageConfig of Object.values(packages)) {
|
|
14
|
-
for (const dependency of getBundledDependencies(packageConfig)) {
|
|
15
|
-
graph.connect({ from: packageConfig.name, to: dependency });
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return graph;
|
|
19
|
-
}
|
|
20
|
-
function validateDependenciesExistForSinglePackage(packageName, allKnownPackageNames, dependencies, isPeer) {
|
|
21
|
-
const prefix = isPeer ? 'Bundle peer' : 'Bundle';
|
|
22
|
-
return dependencies
|
|
23
|
-
.filter((dependency) => {
|
|
24
|
-
return !allKnownPackageNames.includes(dependency);
|
|
25
|
-
})
|
|
26
|
-
.map((dependency) => {
|
|
27
|
-
return `${prefix} dependency "${dependency}" referenced in "${packageName}" does not exist`;
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
function validateDependenciesExist(packageConfigs) {
|
|
31
|
-
const knownPackageNames = Object.keys(packageConfigs);
|
|
32
|
-
return Object.values(packageConfigs).flatMap((packageConfig) => {
|
|
33
|
-
return [
|
|
34
|
-
...validateDependenciesExistForSinglePackage(packageConfig.name, knownPackageNames, packageConfig.bundleDependencies ?? [], false),
|
|
35
|
-
...validateDependenciesExistForSinglePackage(packageConfig.name, knownPackageNames, packageConfig.bundlePeerDependencies ?? [], true)
|
|
36
|
-
];
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
function validateDuplicateRootJavaScriptTargets(packageConfig) {
|
|
40
|
-
const issues = [];
|
|
41
|
-
const rootEntries = Object.entries(packageConfig.roots);
|
|
42
|
-
const jsPaths = new Map();
|
|
43
|
-
for (const [rootId, root] of rootEntries) {
|
|
44
|
-
const previous = jsPaths.get(root.js);
|
|
45
|
-
if (previous === undefined) {
|
|
46
|
-
jsPaths.set(root.js, rootId);
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
issues.push(`Package "${packageConfig.name}" maps both root "${previous}" and "${rootId}" to "${root.js}"`);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return issues;
|
|
53
|
-
}
|
|
54
|
-
function validateImplicitRootConfiguration(packageConfig) {
|
|
55
|
-
const rootIds = Object.keys(packageConfig.roots);
|
|
56
|
-
const issues = [];
|
|
57
|
-
const { defaultModuleRoot } = packageConfig;
|
|
58
|
-
if (rootIds.length > 1 && defaultModuleRoot === undefined) {
|
|
59
|
-
issues.push(`Package "${packageConfig.name}" must define defaultModuleRoot when multiple roots exist`);
|
|
60
|
-
}
|
|
61
|
-
if (defaultModuleRoot !== undefined && packageConfig.roots[defaultModuleRoot] === undefined) {
|
|
62
|
-
issues.push(`Package "${packageConfig.name}" references unknown defaultModuleRoot "${defaultModuleRoot}"`);
|
|
63
|
-
}
|
|
64
|
-
return issues;
|
|
65
|
-
}
|
|
66
|
-
function createExplicitValidationState() {
|
|
67
|
-
return {
|
|
68
|
-
usedRootIds: new Set(),
|
|
69
|
-
publicRootIds: new Set(),
|
|
70
|
-
seenExportKeys: new Set(),
|
|
71
|
-
seenBinNames: new Set(),
|
|
72
|
-
seenPrivateRootIds: new Set()
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
function validateExplicitModules(packageConfig, state) {
|
|
76
|
-
const issues = [];
|
|
77
|
-
for (const entry of packageConfig.packageInterface.modules ?? []) {
|
|
78
|
-
if (packageConfig.roots[entry.root] === undefined) {
|
|
79
|
-
issues.push([
|
|
80
|
-
`Package "${packageConfig.name}" module export "${entry.export}"`,
|
|
81
|
-
`references unknown root "${entry.root}"`
|
|
82
|
-
].join(' '));
|
|
83
|
-
}
|
|
84
|
-
if (state.seenExportKeys.has(entry.export)) {
|
|
85
|
-
issues.push(`Package "${packageConfig.name}" declares duplicate export key "${entry.export}"`);
|
|
86
|
-
}
|
|
87
|
-
state.seenExportKeys.add(entry.export);
|
|
88
|
-
state.usedRootIds.add(entry.root);
|
|
89
|
-
state.publicRootIds.add(entry.root);
|
|
90
|
-
}
|
|
91
|
-
return issues;
|
|
92
|
-
}
|
|
93
|
-
function validateExplicitBins(packageConfig, state) {
|
|
94
|
-
const issues = [];
|
|
95
|
-
for (const entry of packageConfig.packageInterface.bins ?? []) {
|
|
96
|
-
if (packageConfig.roots[entry.root] === undefined) {
|
|
97
|
-
issues.push(`Package "${packageConfig.name}" bin "${entry.name}" references unknown root "${entry.root}"`);
|
|
98
|
-
}
|
|
99
|
-
if (state.seenBinNames.has(entry.name)) {
|
|
100
|
-
issues.push(`Package "${packageConfig.name}" declares duplicate bin name "${entry.name}"`);
|
|
101
|
-
}
|
|
102
|
-
state.seenBinNames.add(entry.name);
|
|
103
|
-
state.usedRootIds.add(entry.root);
|
|
104
|
-
state.publicRootIds.add(entry.root);
|
|
105
|
-
}
|
|
106
|
-
return issues;
|
|
107
|
-
}
|
|
108
|
-
function validateExplicitPrivateRoots(packageConfig, state) {
|
|
109
|
-
return (packageConfig.packageInterface.privateRoots ?? []).flatMap((rootId) => {
|
|
110
|
-
const issues = [];
|
|
111
|
-
if (packageConfig.roots[rootId] === undefined) {
|
|
112
|
-
issues.push(`Package "${packageConfig.name}" private root "${rootId}" references unknown root "${rootId}"`);
|
|
113
|
-
}
|
|
114
|
-
if (state.seenPrivateRootIds.has(rootId)) {
|
|
115
|
-
issues.push(`Package "${packageConfig.name}" declares duplicate private root "${rootId}"`);
|
|
116
|
-
}
|
|
117
|
-
if (state.publicRootIds.has(rootId)) {
|
|
118
|
-
issues.push(`Package "${packageConfig.name}" root "${rootId}" cannot be both public and private`);
|
|
119
|
-
}
|
|
120
|
-
state.seenPrivateRootIds.add(rootId);
|
|
121
|
-
state.usedRootIds.add(rootId);
|
|
122
|
-
return issues;
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
function validateExplicitUnusedRoots(packageConfig, state) {
|
|
126
|
-
return Object.keys(packageConfig.roots).flatMap((rootId) => {
|
|
127
|
-
if (state.usedRootIds.has(rootId)) {
|
|
128
|
-
return [];
|
|
129
|
-
}
|
|
130
|
-
return [`Package "${packageConfig.name}" defines unused root "${rootId}" in explicit mode`];
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
function validateExplicitRootConfiguration(packageConfig) {
|
|
134
|
-
const state = createExplicitValidationState();
|
|
135
|
-
return [
|
|
136
|
-
...validateExplicitModules(packageConfig, state),
|
|
137
|
-
...validateExplicitBins(packageConfig, state),
|
|
138
|
-
...validateExplicitPrivateRoots(packageConfig, state),
|
|
139
|
-
...validateExplicitUnusedRoots(packageConfig, state)
|
|
140
|
-
];
|
|
141
|
-
}
|
|
142
|
-
function buildMutualExclusionIssues(packageName, defaultModuleRoot) {
|
|
143
|
-
if (defaultModuleRoot === undefined) {
|
|
144
|
-
return [];
|
|
145
|
-
}
|
|
146
|
-
return [
|
|
147
|
-
[
|
|
148
|
-
`Package "${packageName}" cannot combine defaultModuleRoot with packageInterface;`,
|
|
149
|
-
'remove defaultModuleRoot in explicit mode'
|
|
150
|
-
].join(' ')
|
|
151
|
-
];
|
|
152
|
-
}
|
|
153
|
-
function validateRootConfiguration(packageConfig) {
|
|
154
|
-
const duplicateRootIssues = validateDuplicateRootJavaScriptTargets(packageConfig);
|
|
155
|
-
if (packageConfig.packageInterface === undefined) {
|
|
156
|
-
return [...duplicateRootIssues, ...validateImplicitRootConfiguration(packageConfig)];
|
|
157
|
-
}
|
|
158
|
-
const packageConfigWithBothFields = packageConfig;
|
|
159
|
-
const mutualExclusionIssues = buildMutualExclusionIssues(packageConfig.name, packageConfigWithBothFields.defaultModuleRoot);
|
|
160
|
-
return [...duplicateRootIssues, ...mutualExclusionIssues, ...validateExplicitRootConfiguration(packageConfig)];
|
|
161
|
-
}
|
|
162
|
-
function packageListToRecord(packages) {
|
|
163
|
-
return indexBy(packages, (packageConfig) => {
|
|
164
|
-
return packageConfig.name;
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
function validateDuplicatePackages(packages) {
|
|
168
|
-
const knownPackageNames = new Set();
|
|
169
|
-
const issues = [];
|
|
170
|
-
packages.forEach((packageConfig) => {
|
|
171
|
-
if (knownPackageNames.has(packageConfig.name)) {
|
|
172
|
-
issues.push(`Duplicate package definition with the name "${packageConfig.name}"`);
|
|
173
|
-
}
|
|
174
|
-
knownPackageNames.add(packageConfig.name);
|
|
175
|
-
});
|
|
176
|
-
return issues;
|
|
177
|
-
}
|
|
178
|
-
function validateCyclicDependencies(packageGraph) {
|
|
179
|
-
const cycles = packageGraph.detectCycles();
|
|
180
|
-
return cycles.map((cycle) => {
|
|
181
|
-
return `Unexpected cyclic dependency path: [${cycle.join('→')}]`;
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
function validatePublishSettingsArePlaced(packtoryConfig) {
|
|
185
|
-
if (packtoryConfig.commonPackageSettings?.publishSettings !== undefined) {
|
|
186
|
-
return [];
|
|
187
|
-
}
|
|
188
|
-
const everyPackageHasIt = packtoryConfig.packages.every((packageConfig) => {
|
|
189
|
-
return packageConfig.publishSettings !== undefined;
|
|
190
|
-
});
|
|
191
|
-
if (everyPackageHasIt) {
|
|
192
|
-
return [];
|
|
193
|
-
}
|
|
194
|
-
return ['publishSettings must be set in commonPackageSettings or in every package'];
|
|
195
|
-
}
|
|
196
|
-
function validatePackageSurfaceRules(packageConfigs) {
|
|
197
|
-
return Object.values(packageConfigs).flatMap(validateRootConfiguration);
|
|
198
|
-
}
|
|
199
|
-
function validateAllowScriptsConsistency(packtoryConfig) {
|
|
200
|
-
const commonAttributes = packtoryConfig.commonPackageSettings?.additionalPackageJsonAttributes;
|
|
201
|
-
const commonPublishSettings = packtoryConfig.commonPackageSettings?.publishSettings;
|
|
202
|
-
return packtoryConfig.packages.flatMap((packageConfig) => {
|
|
203
|
-
const mergedAttributes = { ...commonAttributes, ...packageConfig.additionalPackageJsonAttributes };
|
|
204
|
-
const resolvedPublishSettings = packageConfig.publishSettings ?? commonPublishSettings;
|
|
205
|
-
if (!('scripts' in mergedAttributes)) {
|
|
206
|
-
return [];
|
|
207
|
-
}
|
|
208
|
-
if (resolvedPublishSettings?.allowScripts === true) {
|
|
209
|
-
return [];
|
|
210
|
-
}
|
|
211
|
-
const prefix = `Package "${packageConfig.name}": "scripts" in additionalPackageJsonAttributes`;
|
|
212
|
-
return [`${prefix} requires "publishSettings.allowScripts: true"`];
|
|
213
|
-
});
|
|
214
|
-
}
|
|
7
|
+
import { collectPreGraphIssues, packageListToRecord } from "./pre-graph-validation.js";
|
|
215
8
|
function validatePreGraphGenerationWithSchema(schema, config) {
|
|
216
9
|
const schemaValidationResult = safeParse(schema, config);
|
|
217
10
|
if (!schemaValidationResult.success) {
|
|
@@ -220,19 +13,11 @@ function validatePreGraphGenerationWithSchema(schema, config) {
|
|
|
220
13
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- callers bind the expected config type for this schema
|
|
221
14
|
const packtoryConfig = schemaValidationResult.data;
|
|
222
15
|
const packageConfigs = packageListToRecord(packtoryConfig.packages);
|
|
223
|
-
const preGraphIssues =
|
|
224
|
-
...validatePublishSettingsArePlaced(packtoryConfig),
|
|
225
|
-
...validateAllowScriptsConsistency(packtoryConfig),
|
|
226
|
-
...validateDependenciesExist(packageConfigs),
|
|
227
|
-
...validatePackageSurfaceRules(packageConfigs)
|
|
228
|
-
];
|
|
16
|
+
const preGraphIssues = collectPreGraphIssues(packtoryConfig);
|
|
229
17
|
if (preGraphIssues.length > 0) {
|
|
230
18
|
return Result.err([...validateDuplicatePackages(packtoryConfig.packages), ...preGraphIssues]);
|
|
231
19
|
}
|
|
232
|
-
return Result.ok({
|
|
233
|
-
packtoryConfig,
|
|
234
|
-
packageConfigs
|
|
235
|
-
});
|
|
20
|
+
return Result.ok({ packtoryConfig, packageConfigs });
|
|
236
21
|
}
|
|
237
22
|
function finalizeValidation(result) {
|
|
238
23
|
if (result.isErr) {
|
|
@@ -240,23 +25,16 @@ function finalizeValidation(result) {
|
|
|
240
25
|
}
|
|
241
26
|
const { packageConfigs, packtoryConfig } = result.value;
|
|
242
27
|
const packageGraph = buildPackageGraph(packageConfigs);
|
|
243
|
-
const issues =
|
|
244
|
-
issues.push(...validateCyclicDependencies(packageGraph));
|
|
28
|
+
const issues = [...validateDuplicatePackages(packtoryConfig.packages), ...validateCyclicDependencies(packageGraph)];
|
|
245
29
|
if (issues.length > 0) {
|
|
246
30
|
return Result.err(issues);
|
|
247
31
|
}
|
|
248
|
-
return Result.ok({
|
|
249
|
-
packtoryConfig,
|
|
250
|
-
packageConfigs,
|
|
251
|
-
packageGraph
|
|
252
|
-
});
|
|
32
|
+
return Result.ok({ packtoryConfig, packageConfigs, packageGraph });
|
|
253
33
|
}
|
|
254
34
|
export function validateConfig(config) {
|
|
255
|
-
|
|
256
|
-
return finalizeValidation(result);
|
|
35
|
+
return finalizeValidation(validatePreGraphGenerationWithSchema(packtoryConfigSchema, config));
|
|
257
36
|
}
|
|
258
37
|
export function validateConfigWithoutRegistry(config) {
|
|
259
|
-
|
|
260
|
-
return finalizeValidation(result);
|
|
38
|
+
return finalizeValidation(validatePreGraphGenerationWithSchema(packtoryConfigWithoutRegistrySchema, config));
|
|
261
39
|
}
|
|
262
40
|
//# sourceMappingURL=validation.js.map
|
package/config/validation.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../../../source/config/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC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C,CAAC;AACzD,CAAC;AAED,SAAS,kBAAkB,CACvB,MAAyE;IAEzE,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QACf,OAAO,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;IAED,MAAM,EAAE,cAAc,EAAE,cAAc,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC;IACxD,MAAM,YAAY,GAAG,iBAAiB,CAAC,cAAc,CAAC,CAAC;IAEvD,MAAM,MAAM,GAAG,CAAC,GAAG,yBAAyB,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,GAAG,0BAA0B,CAAC,YAAY,CAAC,CAAC,CAAC;IACpH,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpB,OAAO,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC;IAED,OAAO,MAAM,CAAC,EAAE,CAAC,EAAE,cAAc,EAAE,cAAc,EAAE,YAAY,EAAE,CAAC,CAAC;AACvE,CAAC;AAMD,MAAM,UAAU,cAAc,CAAC,MAAe;IAC1C,OAAO,kBAAkB,CAAC,oCAAoC,CAAiB,oBAAoB,EAAE,MAAM,CAAC,CAAC,CAAC;AAClH,CAAC;AAED,MAAM,UAAU,6BAA6B,CACzC,MAAe;IAEf,OAAO,kBAAkB,CACrB,oCAAoC,CAAgC,mCAAmC,EAAE,MAAM,CAAC,CACnH,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Node as TsMorphNode } from 'ts-morph';
|
|
2
|
+
import { isPureExpression } from "./pure-expression.js";
|
|
3
|
+
function memberHasDecorators(member) {
|
|
4
|
+
if (TsMorphNode.isMethodDeclaration(member) ||
|
|
5
|
+
TsMorphNode.isPropertyDeclaration(member) ||
|
|
6
|
+
TsMorphNode.isGetAccessorDeclaration(member) ||
|
|
7
|
+
TsMorphNode.isSetAccessorDeclaration(member)) {
|
|
8
|
+
return member.getDecorators().length > 0;
|
|
9
|
+
}
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
function memberHasImpureStaticInit(member, settings) {
|
|
13
|
+
if (!TsMorphNode.isPropertyDeclaration(member) || !member.isStatic()) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
const initializer = member.getInitializer();
|
|
17
|
+
return initializer !== undefined && !isPureExpression(initializer, settings);
|
|
18
|
+
}
|
|
19
|
+
function classMemberIsImpure(member, settings) {
|
|
20
|
+
if (TsMorphNode.isClassStaticBlockDeclaration(member)) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
return memberHasDecorators(member) || memberHasImpureStaticInit(member, settings);
|
|
24
|
+
}
|
|
25
|
+
export function hasClassImpurity(classDeclaration, settings) {
|
|
26
|
+
if (classDeclaration.getDecorators().length > 0) {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
return classDeclaration.getMembers().some((member) => {
|
|
30
|
+
return classMemberIsImpure(member, settings);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=class-purity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"class-purity.js","sourceRoot":"","sources":["../../../../source/dead-code-eliminator/class-purity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,WAAW,EAAyB,MAAM,UAAU,CAAC;AAEtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,SAAS,mBAAmB,CAAC,MAAmB;IAC5C,IACI,WAAW,CAAC,mBAAmB,CAAC,MAAM,CAAC;QACvC,WAAW,CAAC,qBAAqB,CAAC,MAAM,CAAC;QACzC,WAAW,CAAC,wBAAwB,CAAC,MAAM,CAAC;QAC5C,WAAW,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAC9C,CAAC;QACC,OAAO,MAAM,CAAC,aAAa,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;IAC7C,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,SAAS,yBAAyB,CAAC,MAAmB,EAAE,QAAiD;IACrG,IAAI,CAAC,WAAW,CAAC,qBAAqB,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC;QACnE,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,MAAM,WAAW,GAAG,MAAM,CAAC,cAAc,EAAE,CAAC;IAC5C,OAAO,WAAW,KAAK,SAAS,IAAI,CAAC,gBAAgB,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;AACjF,CAAC;AAED,SAAS,mBAAmB,CAAC,MAAmB,EAAE,QAAiD;IAC/F,IAAI,WAAW,CAAC,6BAA6B,CAAC,MAAM,CAAC,EAAE,CAAC;QACpD,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,OAAO,mBAAmB,CAAC,MAAM,CAAC,IAAI,yBAAyB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AACtF,CAAC;AAED,MAAM,UAAU,gBAAgB,CAC5B,gBAAkC,EAClC,QAAiD;IAEjD,IAAI,gBAAgB,CAAC,aAAa,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC9C,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,OAAO,gBAAgB,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;QACjD,OAAO,mBAAmB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { createEmptyFileAnalysis } from "./analyzed-bundle.js";
|
|
2
|
+
import { bindingId } from "./reachability/binding-id.js";
|
|
3
|
+
import { classifySideEffects } from "./side-effect-classifier.js";
|
|
4
|
+
import { applyRemovalPlan } from "./transform/declaration-remover.js";
|
|
5
|
+
const noTransforms = [];
|
|
6
|
+
function allBindingNamesFor(loaded) {
|
|
7
|
+
const names = new Set();
|
|
8
|
+
for (const binding of loaded.bindings) {
|
|
9
|
+
names.add(binding.name);
|
|
10
|
+
}
|
|
11
|
+
return names;
|
|
12
|
+
}
|
|
13
|
+
function reachableBindingsFor(loaded, reachable) {
|
|
14
|
+
const { sourceFilePath } = loaded.resource.fileDescription;
|
|
15
|
+
return new Set(loaded.bindings.flatMap((binding) => {
|
|
16
|
+
return reachable.has(bindingId(sourceFilePath, binding.name)) ? [binding.name] : [];
|
|
17
|
+
}));
|
|
18
|
+
}
|
|
19
|
+
function transformSourceFile(sourceFile, surviving) {
|
|
20
|
+
const result = applyRemovalPlan(sourceFile, { survivingNames: surviving });
|
|
21
|
+
return { transformedCode: sourceFile.getFullText(), atoms: result.atoms };
|
|
22
|
+
}
|
|
23
|
+
function analyzeCodeFile(loaded, context) {
|
|
24
|
+
const sideEffectStatements = classifySideEffects(loaded.sourceFile, context.deadCodeElimination);
|
|
25
|
+
const reachableBindings = reachableBindingsFor(loaded, context.reachable);
|
|
26
|
+
const shouldTransform = context.transformationsEnabled && sideEffectStatements.length === 0;
|
|
27
|
+
const survivingBindings = shouldTransform ? reachableBindings : allBindingNamesFor(loaded);
|
|
28
|
+
return {
|
|
29
|
+
analysis: { survivingBindings, sideEffectStatements, sideEffectImports: new Set() },
|
|
30
|
+
reachableBindings,
|
|
31
|
+
shouldTransform
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export function buildAnalyzedResource(loaded, context) {
|
|
35
|
+
if (loaded.sourceFile === undefined) {
|
|
36
|
+
return { resource: { ...loaded.resource, analysis: createEmptyFileAnalysis() }, transforms: noTransforms };
|
|
37
|
+
}
|
|
38
|
+
const { analysis, reachableBindings, shouldTransform } = analyzeCodeFile(loaded, context);
|
|
39
|
+
if (!shouldTransform) {
|
|
40
|
+
return { resource: { ...loaded.resource, analysis }, transforms: noTransforms };
|
|
41
|
+
}
|
|
42
|
+
const originalCode = loaded.resource.fileDescription.content;
|
|
43
|
+
const { transformedCode, atoms } = transformSourceFile(loaded.sourceFile, reachableBindings);
|
|
44
|
+
if (transformedCode === originalCode) {
|
|
45
|
+
return { resource: { ...loaded.resource, analysis }, transforms: noTransforms };
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
resource: {
|
|
49
|
+
...loaded.resource,
|
|
50
|
+
fileDescription: { ...loaded.resource.fileDescription, content: transformedCode },
|
|
51
|
+
analysis
|
|
52
|
+
},
|
|
53
|
+
transforms: [{ originalCode, transformedCode, atoms }]
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=code-file-analyzer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-file-analyzer.js","sourceRoot":"","sources":["../../../../source/dead-code-eliminator/code-file-analyzer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAkD,MAAM,sBAAsB,CAAC;AAE/G,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAqB,MAAM,oCAAoC,CAAC;AAmBzF,MAAM,YAAY,GAA+B,EAAE,CAAC;AAEpD,SAAS,kBAAkB,CAAC,MAA0B;IAClD,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAChC,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;QACpC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,SAAS,oBAAoB,CAAC,MAA0B,EAAE,SAA8B;IACpF,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC;IAC3D,OAAO,IAAI,GAAG,CACV,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAChC,OAAO,SAAS,CA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,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC;IAC/G,CAAC;IACD,MAAM,EAAE,QAAQ,EAAE,iBAAiB,EAAE,eAAe,EAAE,GAAG,eAAe,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1F,IAAI,CAAC,eAAe,EAAE,CAAC;QACnB,OAAO,EAAE,QAAQ,EAAE,EAAE,GAAG,MAAM,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC;IACpF,CAAC;IACD,MAAM,YAAY,GAAG,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,OAAO,CAAC;IAC7D,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,GAAG,mBAAmB,CAAC,MAAM,CAAC,UAAU,EAAE,iBAAiB,CAAC,CAAC;IAC7F,IAAI,eAAe,KAAK,YAAY,EAAE,CAAC;QACnC,OAAO,EAAE,QAAQ,EAAE,EAAE,GAAG,MAAM,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC;IACpF,CAAC;IACD,OAAO;QACH,QAAQ,EAAE;YACN,GAAG,MAAM,CAAC,QAAQ;YAClB,eAAe,EAAE,EAAE,GAAG,MAAM,CAAC,QAAQ,CAAC,eAAe,EAAE,OAAO,EAAE,eAAe,EAAE;YACjF,QAAQ;SACX;QACD,UAAU,EAAE,CAAC,EAAE,YAAY,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC;KACzD,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { resolvePublicModuleSourceFilePath } from "../../package-surface/public-specifiers.js";
|
|
2
|
+
export function indexBundles(inputs) {
|
|
3
|
+
const map = new Map();
|
|
4
|
+
for (const input of inputs) {
|
|
5
|
+
const bindingsByFilePath = new Map(input.fileBindings.map((file) => {
|
|
6
|
+
return [file.sourceFilePath, file];
|
|
7
|
+
}));
|
|
8
|
+
map.set(input.bundle.name, { bundle: input.bundle, bindingsByFilePath });
|
|
9
|
+
}
|
|
10
|
+
return map;
|
|
11
|
+
}
|
|
12
|
+
function tryResolveAgainstBundle(indexedBundle, specifier) {
|
|
13
|
+
const sourceFilePath = resolvePublicModuleSourceFilePath(indexedBundle.bundle, specifier);
|
|
14
|
+
if (sourceFilePath === undefined) {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
return { bundleName: indexedBundle.bundle.name, sourceFilePath, indexedBundle };
|
|
18
|
+
}
|
|
19
|
+
export function resolveCrossBundleTarget(specifier, indexed) {
|
|
20
|
+
if (specifier === undefined) {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
for (const info of indexed.values()) {
|
|
24
|
+
const resolved = tryResolveAgainstBundle(info, specifier);
|
|
25
|
+
if (resolved !== undefined) {
|
|
26
|
+
return resolved;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=bundle-index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle-index.js","sourceRoot":"","sources":["../../../../../source/dead-code-eliminator/cross-bundle/bundle-index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iCAAiC,EAAE,MAAM,4CAA4C,CAAC;AAc/F,MAAM,UAAU,YAAY,CACxB,MAAoG;IAEpG,MAAM,GAAG,GAAG,IAAI,GAAG,EAAyB,CAAC;IAC7C,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QACzB,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAC9B,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;YAC5B,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;QACvC,CAAC,CAAC,CACL,CAAC;QACF,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,kBAAkB,EAAE,CAAC,CAAC;IAC7E,CAAC;IACD,OAAO,GAAG,CAAC;AACf,CAAC;AAED,SAAS,uBAAuB,CAAC,aAA4B,EAAE,SAAiB;IAC5E,MAAM,cAAc,GAAG,iCAAiC,CAAC,aAAa,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAC1F,IAAI,cAAc,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO,SAAS,CAAC;IACrB,CAAC;IACD,OAAO,EAAE,UAAU,EAAE,aAAa,CAAC,MAAM,CAAC,IAAI,EAAE,cAAc,EAAE,aAAa,EAAE,CAAC;AACpF,CAAC;AAED,MAAM,UAAU,wBAAwB,CACpC,SAA6B,EAC7B,OAA2C;IAE3C,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,SAAS,CAAC;IACrB,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;QAClC,MAAM,QAAQ,GAAG,uBAAuB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QAC1D,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YACzB,OAAO,QAAQ,CAAC;QACpB,CAAC;IACL,CAAC;IACD,OAAO,SAAS,CAAC;AACrB,CAAC"}
|
|
@@ -1,116 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
function indexBundles(inputs) {
|
|
5
|
-
const map = new Map();
|
|
6
|
-
for (const input of inputs) {
|
|
7
|
-
const bindingsByFilePath = new Map(input.fileBindings.map((file) => {
|
|
8
|
-
return [file.sourceFilePath, file];
|
|
9
|
-
}));
|
|
10
|
-
map.set(input.bundle.name, { bundle: input.bundle, bindingsByFilePath });
|
|
11
|
-
}
|
|
12
|
-
return map;
|
|
13
|
-
}
|
|
14
|
-
function tryResolveAgainstBundle(indexedBundle, specifier) {
|
|
15
|
-
const sourceFilePath = resolvePublicModuleSourceFilePath(indexedBundle.bundle, specifier);
|
|
16
|
-
if (sourceFilePath === undefined) {
|
|
17
|
-
return undefined;
|
|
18
|
-
}
|
|
19
|
-
return { bundleName: indexedBundle.bundle.name, sourceFilePath, indexedBundle };
|
|
20
|
-
}
|
|
21
|
-
function resolveCrossBundleTarget(specifier, indexed) {
|
|
22
|
-
if (specifier === undefined) {
|
|
23
|
-
return undefined;
|
|
24
|
-
}
|
|
25
|
-
for (const info of indexed.values()) {
|
|
26
|
-
const resolved = tryResolveAgainstBundle(info, specifier);
|
|
27
|
-
if (resolved !== undefined) {
|
|
28
|
-
return resolved;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return undefined;
|
|
32
|
-
}
|
|
33
|
-
function recordSeed(seeds, bundleName, seed) {
|
|
34
|
-
const existing = seeds.get(bundleName) ?? new Set();
|
|
35
|
-
existing.add(seed);
|
|
36
|
-
seeds.set(bundleName, existing);
|
|
37
|
-
}
|
|
38
|
-
function seedAllBindings(seeds, target) {
|
|
39
|
-
const fileBindings = target.indexedBundle.bindingsByFilePath.get(target.sourceFilePath);
|
|
40
|
-
if (fileBindings === undefined) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
for (const binding of fileBindings.bindings) {
|
|
44
|
-
recordSeed(seeds, target.bundleName, bindingId(target.sourceFilePath, binding.name));
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
function localNameOfNamedImport(namedImport) {
|
|
48
|
-
return namedImport.getAliasNode()?.getText() ?? namedImport.getName();
|
|
49
|
-
}
|
|
50
|
-
function isLocalBindingReachable(context, localName) {
|
|
51
|
-
return context.localReachable.has(bindingId(context.sourceFilePath, localName));
|
|
52
|
-
}
|
|
53
|
-
function recordDefaultImportSeed(importDeclaration, target, context) {
|
|
54
|
-
const defaultImport = importDeclaration.getDefaultImport();
|
|
55
|
-
if (defaultImport === undefined) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
if (!isLocalBindingReachable(context, defaultImport.getText())) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
recordSeed(context.seeds, target.bundleName, bindingId(target.sourceFilePath, 'default'));
|
|
62
|
-
}
|
|
63
|
-
function recordNamedImportSeeds(importDeclaration, target, context) {
|
|
64
|
-
for (const namedImport of importDeclaration.getNamedImports()) {
|
|
65
|
-
if (isLocalBindingReachable(context, localNameOfNamedImport(namedImport))) {
|
|
66
|
-
recordSeed(context.seeds, target.bundleName, bindingId(target.sourceFilePath, namedImport.getName()));
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
function processImportDeclaration(importDeclaration, context) {
|
|
71
|
-
const target = resolveCrossBundleTarget(importDeclaration.getModuleSpecifierValue(), context.indexed);
|
|
72
|
-
if (target === undefined) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
const namespaceImport = importDeclaration.getNamespaceImport();
|
|
76
|
-
if (namespaceImport !== undefined) {
|
|
77
|
-
if (isLocalBindingReachable(context, namespaceImport.getText())) {
|
|
78
|
-
seedAllBindings(context.seeds, target);
|
|
79
|
-
}
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
recordDefaultImportSeed(importDeclaration, target, context);
|
|
83
|
-
recordNamedImportSeeds(importDeclaration, target, context);
|
|
84
|
-
}
|
|
85
|
-
function recordNamedReExportSeeds(exportDeclaration, target, seeds) {
|
|
86
|
-
for (const namedExport of exportDeclaration.getNamedExports()) {
|
|
87
|
-
recordSeed(seeds, target.bundleName, bindingId(target.sourceFilePath, namedExport.getName()));
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
function processExportDeclaration(exportDeclaration, context) {
|
|
91
|
-
const target = resolveCrossBundleTarget(exportDeclaration.getModuleSpecifierValue(), context.indexed);
|
|
92
|
-
if (target === undefined) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
if (exportDeclaration.isNamespaceExport()) {
|
|
96
|
-
seedAllBindings(context.seeds, target);
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
recordNamedReExportSeeds(exportDeclaration, target, context.seeds);
|
|
100
|
-
}
|
|
101
|
-
function walkCrossBundleStatements(sourceFile, context) {
|
|
102
|
-
for (const statement of sourceFile.getStatements()) {
|
|
103
|
-
if (TsMorphNode.isImportDeclaration(statement)) {
|
|
104
|
-
processImportDeclaration(statement, context);
|
|
105
|
-
}
|
|
106
|
-
else if (TsMorphNode.isExportDeclaration(statement)) {
|
|
107
|
-
processExportDeclaration(statement, context);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
1
|
+
import { indexBundles } from "./bundle-index.js";
|
|
2
|
+
import { walkCrossBundleStatements } from "./import-export-walker.js";
|
|
3
|
+
import { createSeedStore } from "./seed-store.js";
|
|
111
4
|
export function buildCrossBundleSeeds(inputs) {
|
|
112
5
|
const indexed = indexBundles(inputs);
|
|
113
|
-
const seeds =
|
|
6
|
+
const seeds = createSeedStore();
|
|
114
7
|
for (const input of inputs) {
|
|
115
8
|
for (const sourceFile of input.sourceFiles) {
|
|
116
9
|
walkCrossBundleStatements(sourceFile, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cross-bundle-seeds.js","sourceRoot":"","sources":["../../../../../source/dead-code-eliminator/cross-bundle/cross-bundle-seeds.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cross-bundle-seeds.js","sourceRoot":"","sources":["../../../../../source/dead-code-eliminator/cross-bundle/cross-bundle-seeds.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,eAAe,EAAgB,MAAM,iBAAiB,CAAC;AAShE,MAAM,UAAU,qBAAqB,CAAC,MAAmC;IACrE,MAAM,OAAO,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IACrC,MAAM,KAAK,GAAG,eAAe,EAAE,CAAC;IAChC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QACzB,KAAK,MAAM,UAAU,IAAI,KAAK,CAAC,WAAW,EAAE,CAAC;YACzC,yBAAyB,CAAC,UAAU,EAAE;gBAClC,OAAO;gBACP,KAAK;gBACL,cAAc,EAAE,UAAU,CAAC,WAAW,EAAE;gBACxC,cAAc,EAAE,KAAK,CAAC,cAAc;aACvC,CAAC,CAAC;QACP,CAAC;IACL,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Node as TsMorphNode } from 'ts-morph';
|
|
2
|
+
import { bindingId } from "../reachability/binding-id.js";
|
|
3
|
+
import { resolveCrossBundleTarget } from "./bundle-index.js";
|
|
4
|
+
import { recordSeed, seedAllBindings } from "./seed-store.js";
|
|
5
|
+
function localNameOfNamedImport(namedImport) {
|
|
6
|
+
return namedImport.getAliasNode()?.getText() ?? namedImport.getName();
|
|
7
|
+
}
|
|
8
|
+
function isLocalBindingReachable(context, localName) {
|
|
9
|
+
return context.localReachable.has(bindingId(context.sourceFilePath, localName));
|
|
10
|
+
}
|
|
11
|
+
function recordDefaultImportSeed(importDeclaration, target, context) {
|
|
12
|
+
const defaultImport = importDeclaration.getDefaultImport();
|
|
13
|
+
if (defaultImport === undefined) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (!isLocalBindingReachable(context, defaultImport.getText())) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
recordSeed(context.seeds, target.bundleName, bindingId(target.sourceFilePath, 'default'));
|
|
20
|
+
}
|
|
21
|
+
function recordNamedImportSeeds(importDeclaration, target, context) {
|
|
22
|
+
for (const namedImport of importDeclaration.getNamedImports()) {
|
|
23
|
+
if (isLocalBindingReachable(context, localNameOfNamedImport(namedImport))) {
|
|
24
|
+
recordSeed(context.seeds, target.bundleName, bindingId(target.sourceFilePath, namedImport.getName()));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function processImportDeclaration(importDeclaration, context) {
|
|
29
|
+
const target = resolveCrossBundleTarget(importDeclaration.getModuleSpecifierValue(), context.indexed);
|
|
30
|
+
if (target === undefined) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const namespaceImport = importDeclaration.getNamespaceImport();
|
|
34
|
+
if (namespaceImport !== undefined) {
|
|
35
|
+
if (isLocalBindingReachable(context, namespaceImport.getText())) {
|
|
36
|
+
seedAllBindings(context.seeds, target);
|
|
37
|
+
}
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
recordDefaultImportSeed(importDeclaration, target, context);
|
|
41
|
+
recordNamedImportSeeds(importDeclaration, target, context);
|
|
42
|
+
}
|
|
43
|
+
function recordNamedReExportSeeds(exportDeclaration, target, seeds) {
|
|
44
|
+
for (const namedExport of exportDeclaration.getNamedExports()) {
|
|
45
|
+
recordSeed(seeds, target.bundleName, bindingId(target.sourceFilePath, namedExport.getName()));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function processExportDeclaration(exportDeclaration, context) {
|
|
49
|
+
const target = resolveCrossBundleTarget(exportDeclaration.getModuleSpecifierValue(), context.indexed);
|
|
50
|
+
if (target === undefined) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (exportDeclaration.isNamespaceExport()) {
|
|
54
|
+
seedAllBindings(context.seeds, target);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
recordNamedReExportSeeds(exportDeclaration, target, context.seeds);
|
|
58
|
+
}
|
|
59
|
+
export function walkCrossBundleStatements(sourceFile, context) {
|
|
60
|
+
for (const statement of sourceFile.getStatements()) {
|
|
61
|
+
if (TsMorphNode.isImportDeclaration(statement)) {
|
|
62
|
+
processImportDeclaration(statement, context);
|
|
63
|
+
}
|
|
64
|
+
else if (TsMorphNode.isExportDeclaration(statement)) {
|
|
65
|
+
processExportDeclaration(statement, context);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=import-export-walker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-export-walker.js","sourceRoot":"","sources":["../../../../../source/dead-code-eliminator/cross-bundle/import-export-walker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,WAAW,EAAmE,MAAM,UAAU,CAAC;AAChH,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,wBAAwB,EAA2C,MAAM,mBAAmB,CAAC;AACtG,OAAO,EAAE,UAAU,EAAE,eAAe,EAAuB,MAAM,iBAAiB,CAAC;AASnF,SAAS,sBAAsB,CAAC,WAAqE;IACjG,OAAO,WAAW,CAAC,YAAY,EAAE,EAAE,OAAO,EAAE,IAAI,WAAW,CAAC,OAAO,EAAE,CAAC;AAC1E,CAAC;AAED,SAAS,uBAAuB,CAAC,OAAoB,EAAE,SAAiB;IACpE,OAAO,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC,OAAO,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC,CAAC;AACpF,CAAC;AAED,SAAS,uBAAuB,CAC5B,iBAAoC,EACpC,MAAsB,EACtB,OAAoB;IAEpB,MAAM,aAAa,GAAG,iBAAiB,CAAC,gBAAgB,EAAE,CAAC;IAC3D,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;QAC9B,OAAO;IACX,CAAC;IACD,IAAI,CAAC,uBAAuB,CAAC,OAAO,EAAE,aAAa,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;QAC7D,OAAO;IACX,CAAC;IACD,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC,MAAM,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC,CAAC;AAC9F,CAAC;AAED,SAAS,sBAAsB,CAC3B,iBAAoC,EACpC,MAAsB,EACtB,OAAoB;IAEpB,KAAK,MAAM,WAAW,I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