packtory 0.0.95 → 0.0.97
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 +28 -0
- package/artifacts/artifacts-builder.d.ts.map +1 -0
- package/artifacts/artifacts-builder.js +37 -4
- package/artifacts/artifacts-builder.js.map +1 -1
- package/artifacts/content-collection.js +59 -2
- package/artifacts/content-collection.js.map +1 -1
- package/artifacts/folder-writer.js +25 -2
- package/artifacts/folder-writer.js.map +1 -1
- package/bundle-emitter/emitter.d.ts +8 -0
- package/bundle-emitter/emitter.d.ts.map +1 -1
- package/bundle-emitter/emitter.js +137 -6
- package/bundle-emitter/emitter.js.map +1 -1
- package/bundle-emitter/extract-package-tarball.js +13 -2
- package/bundle-emitter/extract-package-tarball.js.map +1 -1
- package/bundle-emitter/fetch-published-artifacts.d.ts +2 -0
- package/bundle-emitter/fetch-published-artifacts.d.ts.map +1 -1
- package/bundle-emitter/fetch-published-artifacts.js +19 -2
- package/bundle-emitter/fetch-published-artifacts.js.map +1 -1
- package/bundle-emitter/publication-outcome.d.ts +3 -0
- package/bundle-emitter/publication-outcome.d.ts.map +1 -1
- package/bundle-emitter/publication-outcome.js +5 -0
- package/bundle-emitter/publication-outcome.js.map +1 -1
- package/bundle-emitter/publish-error/auto-mode-error-matching.js +28 -2
- package/bundle-emitter/publish-error/auto-mode-error-matching.js.map +1 -1
- package/bundle-emitter/publish-error/error-shape-helpers.js +9 -0
- package/bundle-emitter/publish-error/error-shape-helpers.js.map +1 -1
- package/bundle-emitter/publish-error/file-mode-error-matching.js +33 -2
- package/bundle-emitter/publish-error/file-mode-error-matching.js.map +1 -1
- package/bundle-emitter/publish-error/publish-error-messages.js +24 -0
- package/bundle-emitter/publish-error/publish-error-messages.js.map +1 -1
- package/bundle-emitter/registry/metadata-auth-retry.js +24 -1
- package/bundle-emitter/registry/metadata-auth-retry.js.map +1 -1
- package/bundle-emitter/registry/oidc-token-exchange.js +68 -3
- package/bundle-emitter/registry/oidc-token-exchange.js.map +1 -1
- package/bundle-emitter/registry/package-metadata-fetcher.d.ts +14 -0
- package/bundle-emitter/registry/package-metadata-fetcher.d.ts.map +1 -1
- package/bundle-emitter/registry/package-metadata-fetcher.js +210 -7
- package/bundle-emitter/registry/package-metadata-fetcher.js.map +1 -1
- package/bundle-emitter/registry/publish-settings-bridge.js +34 -3
- package/bundle-emitter/registry/publish-settings-bridge.js.map +1 -1
- package/bundle-emitter/registry/registry-auth-config.d.ts +17 -0
- package/bundle-emitter/registry/registry-auth-config.d.ts.map +1 -0
- package/bundle-emitter/registry/registry-auth-config.js +106 -0
- package/bundle-emitter/registry/registry-auth-config.js.map +1 -1
- package/bundle-emitter/registry/registry-client.d.ts +13 -1
- package/bundle-emitter/registry/registry-client.d.ts.map +1 -1
- package/bundle-emitter/registry/registry-client.js +74 -4
- package/bundle-emitter/registry/registry-client.js.map +1 -1
- package/bundle-emitter/registry/registry-package-path.js +3 -0
- package/bundle-emitter/registry/registry-package-path.js.map +1 -1
- package/bundle-emitter/registry/registry-response-schemas.js +50 -2
- package/bundle-emitter/registry/registry-response-schemas.js.map +1 -1
- package/bundle-emitter/registry/tarball-integrity.d.ts +1 -0
- package/bundle-emitter/registry/tarball-integrity.d.ts.map +1 -1
- package/bundle-emitter/registry/tarball-integrity.js +31 -1
- package/bundle-emitter/registry/tarball-integrity.js.map +1 -1
- package/bundle-emitter/registry/validate-tarball-host.js +26 -1
- package/bundle-emitter/registry/validate-tarball-host.js.map +1 -1
- package/bundle-emitter/release-artifact-canonicalizer.js +31 -5
- package/bundle-emitter/release-artifact-canonicalizer.js.map +1 -1
- package/checks/check-runner.d.ts +18 -0
- package/checks/check-runner.d.ts.map +1 -0
- package/checks/check-runner.js +8 -0
- package/checks/check-runner.js.map +1 -1
- package/checks/rule.d.ts +42 -0
- package/checks/rule.d.ts.map +1 -0
- package/checks/rule.js +12 -2
- package/checks/rule.js.map +1 -1
- package/checks/rules/duplicate-detection.js +23 -1
- package/checks/rules/duplicate-detection.js.map +1 -1
- package/checks/rules/duplicate-messages.js +22 -0
- package/checks/rules/duplicate-messages.js.map +1 -1
- package/checks/rules/file-ownership.js +15 -0
- package/checks/rules/file-ownership.js.map +1 -1
- package/checks/rules/max-bundle-size.d.ts +13 -0
- package/checks/rules/max-bundle-size.d.ts.map +1 -0
- package/checks/rules/max-bundle-size.js +55 -1
- package/checks/rules/max-bundle-size.js.map +1 -1
- package/checks/rules/no-dev-dependency-imports.d.ts +11 -0
- package/checks/rules/no-dev-dependency-imports.d.ts.map +1 -0
- package/checks/rules/no-dev-dependency-imports.js +51 -1
- package/checks/rules/no-dev-dependency-imports.js.map +1 -1
- package/checks/rules/no-duplicated-files.d.ts +11 -0
- package/checks/rules/no-duplicated-files.d.ts.map +1 -0
- package/checks/rules/no-duplicated-files.js +53 -3
- package/checks/rules/no-duplicated-files.js.map +1 -1
- package/checks/rules/no-side-effects.d.ts +15 -0
- package/checks/rules/no-side-effects.d.ts.map +1 -0
- package/checks/rules/no-side-effects.js +50 -1
- package/checks/rules/no-side-effects.js.map +1 -1
- package/checks/rules/no-unexposed-executables.d.ts +8 -0
- package/checks/rules/no-unexposed-executables.d.ts.map +1 -0
- package/checks/rules/no-unexposed-executables.js +43 -2
- package/checks/rules/no-unexposed-executables.js.map +1 -1
- package/checks/rules/no-unused-bundle-dependencies.d.ts +8 -0
- package/checks/rules/no-unused-bundle-dependencies.d.ts.map +1 -0
- package/checks/rules/no-unused-bundle-dependencies.js +30 -2
- package/checks/rules/no-unused-bundle-dependencies.js.map +1 -1
- package/checks/rules/registry.d.ts +23 -0
- package/checks/rules/registry.d.ts.map +1 -0
- package/checks/rules/registry.js +22 -9
- package/checks/rules/registry.js.map +1 -1
- package/checks/rules/required-files.d.ts +15 -0
- package/checks/rules/required-files.d.ts.map +1 -0
- package/checks/rules/required-files.js +41 -3
- package/checks/rules/required-files.js.map +1 -1
- package/checks/rules/type-script-declaration-integrity.d.ts +9 -0
- package/checks/rules/type-script-declaration-integrity.d.ts.map +1 -0
- package/checks/rules/type-script-declaration-integrity.js +81 -3
- package/checks/rules/type-script-declaration-integrity.js.map +1 -1
- package/checks/rules/type-script-declaration-paths.js +55 -1
- package/checks/rules/type-script-declaration-paths.js.map +1 -1
- package/checks/rules/type-script-declaration-project.d.ts +29 -0
- package/checks/rules/type-script-declaration-project.d.ts.map +1 -0
- package/checks/rules/type-script-declaration-project.js +202 -3
- package/checks/rules/type-script-declaration-project.js.map +1 -1
- package/checks/rules/type-script-declaration-reachability.js +38 -2
- package/checks/rules/type-script-declaration-reachability.js.map +1 -1
- package/checks/rules/type-script-declaration-roots.js +29 -0
- package/checks/rules/type-script-declaration-roots.js.map +1 -1
- package/checks/rules/type-script-integrity.d.ts +24 -0
- package/checks/rules/type-script-integrity.d.ts.map +1 -0
- package/checks/rules/type-script-integrity.js +72 -2
- package/checks/rules/type-script-integrity.js.map +1 -1
- package/checks/rules/type-script-package-resolution.d.ts +29 -0
- package/checks/rules/type-script-package-resolution.d.ts.map +1 -0
- package/checks/rules/type-script-package-resolution.js +42 -1
- package/checks/rules/type-script-package-resolution.js.map +1 -1
- package/checks/rules/type-script-resolution-summary.js +53 -0
- package/checks/rules/type-script-resolution-summary.js.map +1 -1
- package/checks/rules/unique-target-paths.d.ts +8 -0
- package/checks/rules/unique-target-paths.d.ts.map +1 -0
- package/checks/rules/unique-target-paths.js +34 -2
- package/checks/rules/unique-target-paths.js.map +1 -1
- package/common/bundled-dependency-groups.js +27 -0
- package/common/bundled-dependency-groups.js.map +1 -1
- package/common/code-files.js +28 -0
- package/common/code-files.js.map +1 -1
- package/common/declaration-companion-paths.js +24 -0
- package/common/declaration-companion-paths.js.map +1 -1
- package/common/package-name-map.js +7 -0
- package/common/package-name-map.js.map +1 -1
- package/common/stable-json.js +42 -2
- package/common/stable-json.js.map +1 -1
- package/common/worklist.js +22 -0
- package/common/worklist.js.map +1 -1
- package/config/additional-files.d.ts +1 -1
- package/config/additional-files.js +6 -2
- package/config/additional-files.js.map +1 -1
- package/config/additional-package-json-attributes-schema.js +6 -2
- package/config/additional-package-json-attributes-schema.js.map +1 -1
- package/config/automatic-versioning-settings.js +6 -2
- package/config/automatic-versioning-settings.js.map +1 -1
- package/config/changelog-settings.d.ts +44 -0
- package/config/changelog-settings.d.ts.map +1 -1
- package/config/changelog-settings.js +120 -3
- package/config/changelog-settings.js.map +1 -1
- package/config/common-package-settings-schemas.js +19 -3
- package/config/common-package-settings-schemas.js.map +1 -1
- package/config/config.d.ts +6 -1
- package/config/config.d.ts.map +1 -1
- package/config/config.js +3 -1
- package/config/config.js.map +1 -1
- package/config/cross-package-validation.js +17 -0
- package/config/cross-package-validation.js.map +1 -1
- package/config/dead-code-elimination-settings.d.ts +1 -0
- package/config/dead-code-elimination-settings.d.ts.map +1 -1
- package/config/dead-code-elimination-settings.js +36 -2
- package/config/dead-code-elimination-settings.js.map +1 -1
- package/config/dependency-existence-validation.js +19 -1
- package/config/dependency-existence-validation.js.map +1 -1
- package/config/dependency-policy.js +5 -2
- package/config/dependency-policy.js.map +1 -1
- package/config/main-package-json-schema.js +13 -2
- package/config/main-package-json-schema.js.map +1 -1
- package/config/manual-versioning-settings.d.ts +12 -0
- package/config/manual-versioning-settings.d.ts.map +1 -1
- package/config/manual-versioning-settings.js +29 -2
- package/config/manual-versioning-settings.js.map +1 -1
- package/config/optional-package-settings-schema.js +16 -7
- package/config/optional-package-settings-schema.js.map +1 -1
- package/config/package-config.d.ts +4 -0
- package/config/package-config.d.ts.map +1 -1
- package/config/package-config.js +2 -1
- package/config/package-config.js.map +1 -1
- package/config/package-graph-builder.js +14 -2
- package/config/package-graph-builder.js.map +1 -1
- package/config/package-interface.js +25 -2
- package/config/package-interface.js.map +1 -1
- package/config/package-json.d.ts +2 -0
- package/config/package-json.d.ts.map +1 -1
- package/config/package-json.js +16 -0
- package/config/package-json.js.map +1 -1
- package/config/packtory-config-schema.d.ts +12 -12
- package/config/packtory-config-without-registry-schema.js +6 -0
- package/config/packtory-config-without-registry-schema.js.map +1 -1
- package/config/per-package-settings-schema.js +22 -6
- package/config/per-package-settings-schema.js.map +1 -1
- package/config/pre-graph-validation.js +20 -5
- package/config/pre-graph-validation.js.map +1 -1
- package/config/publish-settings.d.ts +3 -0
- package/config/publish-settings.d.ts.map +1 -1
- package/config/publish-settings.js +25 -3
- package/config/publish-settings.js.map +1 -1
- package/config/publish-settings.report.js +17 -1
- package/config/publish-settings.report.js.map +1 -1
- package/config/registry-settings.d.ts +41 -0
- package/config/registry-settings.d.ts.map +1 -1
- package/config/registry-settings.js +40 -2
- package/config/registry-settings.js.map +1 -1
- package/config/registry-settings.report.js +46 -0
- package/config/registry-settings.report.js.map +1 -1
- package/config/root-config-validation.js +141 -0
- package/config/root-config-validation.js.map +1 -1
- package/config/root.js +6 -2
- package/config/root.js.map +1 -1
- package/config/sbom-settings.js +4 -1
- package/config/sbom-settings.js.map +1 -1
- package/config/settings-validation.js +28 -0
- package/config/settings-validation.js.map +1 -1
- package/config/validation.d.ts.map +1 -1
- package/config/validation.js +35 -1
- package/config/validation.js.map +1 -1
- package/config/versioning-settings.d.ts +18 -1
- package/config/versioning-settings.d.ts.map +1 -1
- package/config/versioning-settings.js +10 -3
- package/config/versioning-settings.js.map +1 -1
- package/dead-code-eliminator/analyzed-bundle.d.ts +11 -0
- package/dead-code-eliminator/analyzed-bundle.d.ts.map +1 -1
- package/dead-code-eliminator/analyzed-bundle.js +7 -0
- package/dead-code-eliminator/analyzed-bundle.js.map +1 -1
- package/dead-code-eliminator/bundle-analysis.js +38 -5
- package/dead-code-eliminator/bundle-analysis.js.map +1 -1
- package/dead-code-eliminator/class-purity.js +48 -2
- package/dead-code-eliminator/class-purity.js.map +1 -1
- package/dead-code-eliminator/code-file-analyzer.js +68 -4
- package/dead-code-eliminator/code-file-analyzer.js.map +1 -1
- package/dead-code-eliminator/cross-bundle/bundle-index.js +10 -1
- package/dead-code-eliminator/cross-bundle/bundle-index.js.map +1 -1
- package/dead-code-eliminator/cross-bundle/cross-bundle-seeds.js +22 -3
- package/dead-code-eliminator/cross-bundle/cross-bundle-seeds.js.map +1 -1
- package/dead-code-eliminator/cross-bundle/import-export-walker.js +164 -4
- package/dead-code-eliminator/cross-bundle/import-export-walker.js.map +1 -1
- package/dead-code-eliminator/cross-bundle/seed-store.js +10 -0
- package/dead-code-eliminator/cross-bundle/seed-store.js.map +1 -1
- package/dead-code-eliminator/dependency-metadata.js +172 -3
- package/dead-code-eliminator/dependency-metadata.js.map +1 -1
- package/dead-code-eliminator/elimination-emitter.js +52 -0
- package/dead-code-eliminator/elimination-emitter.js.map +1 -1
- package/dead-code-eliminator/eliminator.js +22 -4
- package/dead-code-eliminator/eliminator.js.map +1 -1
- package/dead-code-eliminator/expression-unwrapping.js +16 -1
- package/dead-code-eliminator/expression-unwrapping.js.map +1 -1
- package/dead-code-eliminator/imported-expression-origin.js +101 -2
- package/dead-code-eliminator/imported-expression-origin.js.map +1 -1
- package/dead-code-eliminator/liveness/asset-side-effects.js +9 -1
- package/dead-code-eliminator/liveness/asset-side-effects.js.map +1 -1
- package/dead-code-eliminator/liveness/boolean-facts.js +98 -2
- package/dead-code-eliminator/liveness/boolean-facts.js.map +1 -1
- package/dead-code-eliminator/liveness/external-module-resolution.js +172 -2
- package/dead-code-eliminator/liveness/external-module-resolution.js.map +1 -1
- package/dead-code-eliminator/liveness/external-purity-summary.js +294 -3
- package/dead-code-eliminator/liveness/external-purity-summary.js.map +1 -1
- package/dead-code-eliminator/liveness/external-purity.js +39 -3
- package/dead-code-eliminator/liveness/external-purity.js.map +1 -1
- package/dead-code-eliminator/liveness/module-analysis.js +27 -2
- package/dead-code-eliminator/liveness/module-analysis.js.map +1 -1
- package/dead-code-eliminator/liveness/resource-retention.js +91 -1
- package/dead-code-eliminator/liveness/resource-retention.js.map +1 -1
- package/dead-code-eliminator/liveness/runtime-code.js +15 -1
- package/dead-code-eliminator/liveness/runtime-code.js.map +1 -1
- package/dead-code-eliminator/load-bundle.js +86 -5
- package/dead-code-eliminator/load-bundle.js.map +1 -1
- package/dead-code-eliminator/pure-expression.js +178 -5
- package/dead-code-eliminator/pure-expression.js.map +1 -1
- package/dead-code-eliminator/reachability/bfs-closure.js +53 -0
- package/dead-code-eliminator/reachability/bfs-closure.js.map +1 -1
- package/dead-code-eliminator/reachability/binding-extractor.js +100 -2
- package/dead-code-eliminator/reachability/binding-extractor.js.map +1 -1
- package/dead-code-eliminator/reachability/binding-id.js +106 -1
- package/dead-code-eliminator/reachability/binding-id.js.map +1 -1
- package/dead-code-eliminator/reachability/identifier-target-collector.js +96 -2
- package/dead-code-eliminator/reachability/identifier-target-collector.js.map +1 -1
- package/dead-code-eliminator/reachability/impure-statements.js +11 -2
- package/dead-code-eliminator/reachability/impure-statements.js.map +1 -1
- package/dead-code-eliminator/reachability/local-seed-gathering.js +91 -4
- package/dead-code-eliminator/reachability/local-seed-gathering.js.map +1 -1
- package/dead-code-eliminator/reachability/reachability.js +65 -4
- package/dead-code-eliminator/reachability/reachability.js.map +1 -1
- package/dead-code-eliminator/side-effect-classifier.js +39 -4
- package/dead-code-eliminator/side-effect-classifier.js.map +1 -1
- package/dead-code-eliminator/side-effects-field.js +23 -1
- package/dead-code-eliminator/side-effects-field.js.map +1 -1
- package/dead-code-eliminator/source-map-recomposition.js +29 -2
- package/dead-code-eliminator/source-map-recomposition.js.map +1 -1
- package/dead-code-eliminator/statement-classifiers.js +94 -4
- package/dead-code-eliminator/statement-classifiers.js.map +1 -1
- package/dead-code-eliminator/syntax-kind-sets.js +16 -0
- package/dead-code-eliminator/syntax-kind-sets.js.map +1 -1
- package/dead-code-eliminator/transform/atom-translator.d.ts +8 -0
- package/dead-code-eliminator/transform/atom-translator.d.ts.map +1 -1
- package/dead-code-eliminator/transform/atom-translator.js +57 -2
- package/dead-code-eliminator/transform/atom-translator.js.map +1 -1
- package/dead-code-eliminator/transform/declaration-removal.js +183 -5
- package/dead-code-eliminator/transform/declaration-removal.js.map +1 -1
- package/dead-code-eliminator/transform/declaration-remover.js +17 -2
- package/dead-code-eliminator/transform/declaration-remover.js.map +1 -1
- package/dead-code-eliminator/transform/line-index.d.ts +7 -0
- package/dead-code-eliminator/transform/line-index.d.ts.map +1 -1
- package/dead-code-eliminator/transform/line-index.js +20 -0
- package/dead-code-eliminator/transform/line-index.js.map +1 -1
- package/dead-code-eliminator/transform/named-declaration-kinds.js +3 -0
- package/dead-code-eliminator/transform/named-declaration-kinds.js.map +1 -1
- package/dead-code-eliminator/transform/source-map-composer.js +84 -3
- package/dead-code-eliminator/transform/source-map-composer.js.map +1 -1
- package/dead-code-eliminator/variable-declaration-bindings.js +25 -1
- package/dead-code-eliminator/variable-declaration-bindings.js.map +1 -1
- package/dependency-scanner/dependency-graph.d.ts +41 -0
- package/dependency-scanner/dependency-graph.d.ts.map +1 -0
- package/dependency-scanner/dependency-graph.js +77 -3
- package/dependency-scanner/dependency-graph.js.map +1 -1
- package/dependency-scanner/external-dependencies.d.ts +10 -1
- package/dependency-scanner/external-dependencies.d.ts.map +1 -1
- package/dependency-scanner/external-dependencies.js +55 -1
- package/dependency-scanner/external-dependencies.js.map +1 -1
- package/dependency-scanner/file-host-predicates.js +9 -0
- package/dependency-scanner/file-host-predicates.js.map +1 -1
- package/dependency-scanner/host-method-binding.js +18 -0
- package/dependency-scanner/host-method-binding.js.map +1 -1
- package/dependency-scanner/injected-dynamic-imports.js +232 -1
- package/dependency-scanner/injected-dynamic-imports.js.map +1 -1
- package/dependency-scanner/node-modules-manifest-synthesizer.js +52 -4
- package/dependency-scanner/node-modules-manifest-synthesizer.js.map +1 -1
- package/dependency-scanner/package-owned-asset-file-path.js +9 -1
- package/dependency-scanner/package-owned-asset-file-path.js.map +1 -1
- package/dependency-scanner/scanner.d.ts +20 -0
- package/dependency-scanner/scanner.d.ts.map +1 -0
- package/dependency-scanner/scanner.js +109 -4
- package/dependency-scanner/scanner.js.map +1 -1
- package/dependency-scanner/source-file-references.d.ts +37 -0
- package/dependency-scanner/source-file-references.d.ts.map +1 -0
- package/dependency-scanner/source-file-references.js +181 -6
- package/dependency-scanner/source-file-references.js.map +1 -1
- package/dependency-scanner/source-map-file-locator.d.ts +10 -0
- package/dependency-scanner/source-map-file-locator.d.ts.map +1 -0
- package/dependency-scanner/source-map-file-locator.js +66 -2
- package/dependency-scanner/source-map-file-locator.js.map +1 -1
- package/dependency-scanner/typescript-compiler-options.d.ts +8 -0
- package/dependency-scanner/typescript-compiler-options.d.ts.map +1 -0
- package/dependency-scanner/typescript-compiler-options.js +21 -1
- package/dependency-scanner/typescript-compiler-options.js.map +1 -1
- package/dependency-scanner/typescript-file-host.d.ts +12 -0
- package/dependency-scanner/typescript-file-host.d.ts.map +1 -0
- package/dependency-scanner/typescript-file-host.js +49 -5
- package/dependency-scanner/typescript-file-host.js.map +1 -1
- package/dependency-scanner/typescript-project-analyzer.d.ts +19 -0
- package/dependency-scanner/typescript-project-analyzer.d.ts.map +1 -0
- package/dependency-scanner/typescript-project-analyzer.js +35 -3
- package/dependency-scanner/typescript-project-analyzer.js.map +1 -1
- package/dependency-scanner/virtual-package-json-host.js +45 -4
- package/dependency-scanner/virtual-package-json-host.js.map +1 -1
- package/directed-graph/graph.d.ts +1 -0
- package/directed-graph/graph.d.ts.map +1 -1
- package/directed-graph/graph.js +240 -1
- package/directed-graph/graph.js.map +1 -1
- package/file-manager/compare.js +23 -2
- package/file-manager/compare.js.map +1 -1
- package/file-manager/equal.js +5 -0
- package/file-manager/equal.js.map +1 -1
- package/file-manager/file-description.d.ts +2 -1
- package/file-manager/file-description.d.ts.map +1 -1
- package/file-manager/file-description.js +3 -0
- package/file-manager/file-description.js.map +1 -1
- package/file-manager/file-manager.d.ts +1 -1
- package/file-manager/file-manager.d.ts.map +1 -1
- package/file-manager/file-manager.js +4 -4
- package/file-manager/file-manager.js.map +1 -1
- package/file-manager/permissions.js +28 -1
- package/file-manager/permissions.js.map +1 -1
- package/git/current-git-head.d.ts +12 -0
- package/git/current-git-head.d.ts.map +1 -0
- package/git/current-git-head.js +24 -0
- package/git/current-git-head.js.map +1 -1
- package/git/git-command.js +49 -1
- package/git/git-command.js.map +1 -1
- package/linker/linked-bundle.d.ts +19 -2
- package/linker/linked-bundle.d.ts.map +1 -1
- package/linker/linked-bundle.js +5 -0
- package/linker/linked-bundle.js.map +1 -1
- package/linker/linker.d.ts +13 -0
- package/linker/linker.d.ts.map +1 -0
- package/linker/linker.js +51 -5
- package/linker/linker.js.map +1 -1
- package/linker/replacement-lookup.js +297 -8
- package/linker/replacement-lookup.js.map +1 -1
- package/linker/resource-graph.js +65 -2
- package/linker/resource-graph.js.map +1 -1
- package/linker/source-modifier/import-paths.js +76 -3
- package/linker/source-modifier/import-paths.js.map +1 -1
- package/linker/substitute-bundles.js +166 -3
- package/linker/substitute-bundles.js.map +1 -1
- package/linker/substituted-resource-graph.js +111 -2
- package/linker/substituted-resource-graph.js.map +1 -1
- package/npm-oidc-id-token-resolver.js +82 -0
- package/npm-oidc-id-token-resolver.js.map +1 -1
- package/pack-emitter/pack-emitter.d.ts +20 -0
- package/pack-emitter/pack-emitter.d.ts.map +1 -1
- package/pack-emitter/pack-emitter.js +27 -0
- package/pack-emitter/pack-emitter.js.map +1 -1
- package/package-surface/bin-field.js +8 -2
- package/package-surface/bin-field.js.map +1 -1
- package/package-surface/explicit-bin.js +24 -2
- package/package-surface/explicit-bin.js.map +1 -1
- package/package-surface/explicit-exports.js +26 -3
- package/package-surface/explicit-exports.js.map +1 -1
- package/package-surface/export-map.js +9 -2
- package/package-surface/export-map.js.map +1 -1
- package/package-surface/implicit-bin.js +25 -1
- package/package-surface/implicit-bin.js.map +1 -1
- package/package-surface/implicit-exports.js +10 -3
- package/package-surface/implicit-exports.js.map +1 -1
- package/package-surface/implicit-root-exports.js +13 -2
- package/package-surface/implicit-root-exports.js.map +1 -1
- package/package-surface/package-json-export.js +9 -0
- package/package-surface/package-json-export.js.map +1 -1
- package/package-surface/package-shape.js +10 -1
- package/package-surface/package-shape.js.map +1 -1
- package/package-surface/package-surface-index.js +165 -3
- package/package-surface/package-surface-index.js.map +1 -1
- package/package-surface/public-module-usage.js +46 -3
- package/package-surface/public-module-usage.js.map +1 -1
- package/package-surface/public-specifiers.js +7 -1
- package/package-surface/public-specifiers.js.map +1 -1
- package/package-surface/root-registry.js +26 -0
- package/package-surface/root-registry.js.map +1 -1
- package/package-surface/specifier-syntax.js +4 -0
- package/package-surface/specifier-syntax.js.map +1 -1
- package/package-surface/substitution-exports.js +101 -3
- package/package-surface/substitution-exports.js.map +1 -1
- package/package-surface/surface.d.ts +2 -0
- package/package-surface/surface.d.ts.map +1 -1
- package/package-surface/surface.js +12 -0
- package/package-surface/surface.js.map +1 -1
- package/package.json +1 -1
- package/packages/package-processor.composition.d.ts +22 -0
- package/packages/package-processor.composition.d.ts.map +1 -1
- package/packages/package-processor.composition.js +161 -34
- package/packages/package-processor.composition.js.map +1 -1
- package/packtory/changelog-source-attribution.js +16 -16
- package/packtory/changelog-source-attribution.js.map +1 -1
- package/packtory/map-config.d.ts +11 -1
- package/packtory/map-config.d.ts.map +1 -1
- package/packtory/map-config.js +35 -4
- package/packtory/map-config.js.map +1 -1
- package/packtory/normalize-paths.js +25 -1
- package/packtory/normalize-paths.js.map +1 -1
- package/packtory/options/bundle-dependency-resolution.js +17 -1
- package/packtory/options/bundle-dependency-resolution.js.map +1 -1
- package/packtory/options/dead-code-elimination-resolution.js +10 -1
- package/packtory/options/dead-code-elimination-resolution.js.map +1 -1
- package/packtory/options/prepare-package-options.d.ts +13 -1
- package/packtory/options/prepare-package-options.d.ts.map +1 -1
- package/packtory/options/prepare-package-options.js +46 -5
- package/packtory/options/prepare-package-options.js.map +1 -1
- package/packtory/options/required-value-helpers.js +17 -0
- package/packtory/options/required-value-helpers.js.map +1 -1
- package/packtory/options/setting-resolvers.d.ts +17 -1
- package/packtory/options/setting-resolvers.d.ts.map +1 -1
- package/packtory/options/setting-resolvers.js +47 -3
- package/packtory/options/setting-resolvers.js.map +1 -1
- package/packtory/options/surface-resolution.js +15 -2
- package/packtory/options/surface-resolution.js.map +1 -1
- package/packtory/options/version-provider-context.js +24 -2
- package/packtory/options/version-provider-context.js.map +1 -1
- package/packtory/options/version-trigger.js +39 -2
- package/packtory/options/version-trigger.js.map +1 -1
- package/packtory/pack-output-preflight.js +60 -3
- package/packtory/pack-output-preflight.js.map +1 -1
- package/packtory/package-processor-build.js +97 -3
- package/packtory/package-processor-build.js.map +1 -1
- package/packtory/package-processor-publish-result.d.ts +3 -0
- package/packtory/package-processor-publish-result.d.ts.map +1 -1
- package/packtory/package-processor-publish.d.ts +2 -0
- package/packtory/package-processor-publish.d.ts.map +1 -1
- package/packtory/package-processor-publish.js +297 -6
- package/packtory/package-processor-publish.js.map +1 -1
- package/packtory/package-processor.d.ts +34 -0
- package/packtory/package-processor.d.ts.map +1 -1
- package/packtory/package-processor.js +10 -2
- package/packtory/package-processor.js.map +1 -1
- package/packtory/packtory-pack.js +298 -10
- package/packtory/packtory-pack.js.map +1 -1
- package/packtory/packtory-package-dependencies.js +116 -3
- package/packtory/packtory-package-dependencies.js.map +1 -1
- package/packtory/packtory-package-inspection.js +26 -5
- package/packtory/packtory-package-inspection.js.map +1 -1
- package/packtory/packtory-package-side-effects.js +64 -3
- package/packtory/packtory-package-side-effects.js.map +1 -1
- package/packtory/packtory-package-tree.js +43 -4
- package/packtory/packtory-package-tree.js.map +1 -1
- package/packtory/packtory-publish.js +17 -4
- package/packtory/packtory-publish.js.map +1 -1
- package/packtory/packtory-release-analysis.js +64 -6
- package/packtory/packtory-release-analysis.js.map +1 -1
- package/packtory/packtory-release-diff.js +48 -5
- package/packtory/packtory-release-diff.js.map +1 -1
- package/packtory/packtory-release-plan.js +87 -6
- package/packtory/packtory-release-plan.js.map +1 -1
- package/packtory/packtory-resolve.js +16 -5
- package/packtory/packtory-resolve.js.map +1 -1
- package/packtory/packtory.d.ts +28 -1
- package/packtory/packtory.d.ts.map +1 -1
- package/packtory/packtory.js +242 -13
- package/packtory/packtory.js.map +1 -1
- package/packtory/publish-failure-mapping.js +6 -0
- package/packtory/publish-failure-mapping.js.map +1 -1
- package/packtory/publish-target-preflight.js +25 -3
- package/packtory/publish-target-preflight.js.map +1 -1
- package/packtory/published-release-state.d.ts +19 -0
- package/packtory/published-release-state.d.ts.map +1 -1
- package/packtory/published-release-state.js +11 -0
- package/packtory/published-release-state.js.map +1 -1
- package/packtory/release-analysis.js +153 -5
- package/packtory/release-analysis.js.map +1 -1
- package/packtory/release-diff-failure-mapping.js +6 -0
- package/packtory/release-diff-failure-mapping.js.map +1 -1
- package/packtory/release-plan.js +135 -7
- package/packtory/release-plan.js.map +1 -1
- package/packtory/report-attachment.js +35 -2
- package/packtory/report-attachment.js.map +1 -1
- package/packtory/resolved-package.d.ts +11 -0
- package/packtory/resolved-package.d.ts.map +1 -1
- package/packtory/resolved-package.js +97 -3
- package/packtory/resolved-package.js.map +1 -1
- package/packtory/scheduler.d.ts +47 -0
- package/packtory/scheduler.d.ts.map +1 -1
- package/packtory/scheduler.js +99 -1
- package/packtory/scheduler.js.map +1 -1
- package/packtory/stages/package-analysis-stage.js +50 -2
- package/packtory/stages/package-analysis-stage.js.map +1 -1
- package/packtory/stages/package-resolution-stage.js +80 -5
- package/packtory/stages/package-resolution-stage.js.map +1 -1
- package/packtory/stages/publish-stage.js +125 -4
- package/packtory/stages/publish-stage.js.map +1 -1
- package/packtory/stages/release-diff-stage.js +84 -5
- package/packtory/stages/release-diff-stage.js.map +1 -1
- package/progress/progress-broadcaster.d.ts +1 -0
- package/progress/progress-broadcaster.d.ts.map +1 -1
- package/progress/progress-broadcaster.js +45 -0
- package/progress/progress-broadcaster.js.map +1 -1
- package/published-package/published-package.d.ts +2 -0
- package/published-package/published-package.d.ts.map +1 -1
- package/published-package/published-package.js +12 -1
- package/published-package/published-package.js.map +1 -1
- package/report/aggregator/artifact-entry-merger.js +20 -0
- package/report/aggregator/artifact-entry-merger.js.map +1 -1
- package/report/aggregator/package-report-materialization.js +75 -2
- package/report/aggregator/package-report-materialization.js.map +1 -1
- package/report/aggregator/report-aggregator.js +37 -2
- package/report/aggregator/report-aggregator.js.map +1 -1
- package/report/aggregator/report-event-handlers.js +141 -2
- package/report/aggregator/report-event-handlers.js.map +1 -1
- package/report/aggregator/report-types.d.ts +21 -0
- package/report/aggregator/report-types.d.ts.map +1 -1
- package/report/aggregator/report-types.js +3 -0
- package/report/aggregator/report-types.js.map +1 -1
- package/report/config-redactor.js +29 -3
- package/report/config-redactor.js.map +1 -1
- package/report/decorators.js +85 -0
- package/report/decorators.js.map +1 -1
- package/report/inspectors/inspect-artifact-sizes.js +34 -1
- package/report/inspectors/inspect-artifact-sizes.js.map +1 -1
- package/report/inspectors/inspect-linker-rewrites.js +14 -1
- package/report/inspectors/inspect-linker-rewrites.js.map +1 -1
- package/report/inspectors/inspect-package-json-provenance.js +15 -0
- package/report/inspectors/inspect-package-json-provenance.js.map +1 -1
- package/report/inspectors/inspect-scan-results.js +15 -0
- package/report/inspectors/inspect-scan-results.js.map +1 -1
- package/report/release-diff/release-version-transition.js +18 -0
- package/report/release-diff/release-version-transition.js.map +1 -1
- package/resource-resolver/bundle-resource-lookup.js +25 -0
- package/resource-resolver/bundle-resource-lookup.js.map +1 -1
- package/resource-resolver/content.js +136 -3
- package/resource-resolver/content.js.map +1 -1
- package/resource-resolver/dependency-resolution-walker.js +73 -2
- package/resource-resolver/dependency-resolution-walker.js.map +1 -1
- package/resource-resolver/resolved-bundle.d.ts +54 -0
- package/resource-resolver/resolved-bundle.d.ts.map +1 -1
- package/resource-resolver/resolved-bundle.js +3 -0
- package/resource-resolver/resolved-bundle.js.map +1 -1
- package/resource-resolver/resource-resolve-options.d.ts +5 -0
- package/resource-resolver/resource-resolve-options.d.ts.map +1 -1
- package/resource-resolver/resource-resolve-options.js +13 -1
- package/resource-resolver/resource-resolve-options.js.map +1 -1
- package/resource-resolver/resource-resolver.d.ts +15 -0
- package/resource-resolver/resource-resolver.d.ts.map +1 -0
- package/resource-resolver/resource-resolver.js +128 -5
- package/resource-resolver/resource-resolver.js.map +1 -1
- package/sbom/extract-license.js +11 -1
- package/sbom/extract-license.js.map +1 -1
- package/sbom/license-resolver.d.ts +14 -0
- package/sbom/license-resolver.d.ts.map +1 -0
- package/sbom/license-resolver.js +23 -2
- package/sbom/license-resolver.js.map +1 -1
- package/sbom/sbom-builder.js +57 -2
- package/sbom/sbom-builder.js.map +1 -1
- package/sbom/sbom-canonicalizer.js +45 -3
- package/sbom/sbom-canonicalizer.js.map +1 -1
- package/sbom/sbom-file.d.ts +10 -0
- package/sbom/sbom-file.d.ts.map +1 -1
- package/sbom/sbom-file.js +54 -5
- package/sbom/sbom-file.js.map +1 -1
- package/sbom/sbom-serializer.d.ts +8 -0
- package/sbom/sbom-serializer.d.ts.map +1 -0
- package/sbom/sbom-serializer.js +14 -1
- package/sbom/sbom-serializer.js.map +1 -1
- package/sbom/tool-version.js +49 -1
- package/sbom/tool-version.js.map +1 -1
- package/sbom.cdx.json +5 -5
- package/tar/extract-tar.js +83 -3
- package/tar/extract-tar.js.map +1 -1
- package/tar/gzipped-pack.js +20 -0
- package/tar/gzipped-pack.js.map +1 -1
- package/tar/tarball-builder.d.ts +14 -0
- package/tar/tarball-builder.d.ts.map +1 -0
- package/tar/tarball-builder.js +44 -4
- package/tar/tarball-builder.js.map +1 -1
- package/vendor-materializer/vendor-entry.d.ts +12 -0
- package/vendor-materializer/vendor-entry.d.ts.map +1 -0
- package/vendor-materializer/vendor-entry.js +20 -1
- package/vendor-materializer/vendor-entry.js.map +1 -1
- package/vendor-materializer/vendor-materializer.d.ts +55 -0
- package/vendor-materializer/vendor-materializer.d.ts.map +1 -0
- package/vendor-materializer/vendor-materializer.js +240 -8
- package/vendor-materializer/vendor-materializer.js.map +1 -1
- package/version-manager/dependencies/bundle-dependency-grouping.js +32 -2
- package/version-manager/dependencies/bundle-dependency-grouping.js.map +1 -1
- package/version-manager/dependencies/dependency-groups.js +11 -1
- package/version-manager/dependencies/dependency-groups.js.map +1 -1
- package/version-manager/dependencies/external-dependency-classification.js +82 -3
- package/version-manager/dependencies/external-dependency-classification.js.map +1 -1
- package/version-manager/dependencies/versioned-bundle-dependencies.js +8 -3
- package/version-manager/dependencies/versioned-bundle-dependencies.js.map +1 -1
- package/version-manager/imports/hash-import-scanner.js +20 -2
- package/version-manager/imports/hash-import-scanner.js.map +1 -1
- package/version-manager/imports/imports-key-matcher.js +22 -0
- package/version-manager/imports/imports-key-matcher.js.map +1 -1
- package/version-manager/imports/versioned-bundle-imports.js +44 -2
- package/version-manager/imports/versioned-bundle-imports.js.map +1 -1
- package/version-manager/manager.d.ts +5 -0
- package/version-manager/manager.d.ts.map +1 -1
- package/version-manager/manager.js +46 -6
- package/version-manager/manager.js.map +1 -1
- package/version-manager/manifest/builder.js +51 -1
- package/version-manager/manifest/builder.js.map +1 -1
- package/version-manager/manifest/serialize.js +8 -1
- package/version-manager/manifest/serialize.js.map +1 -1
- package/version-manager/optional-bundle-fields.js +5 -1
- package/version-manager/optional-bundle-fields.js.map +1 -1
- package/version-manager/representative-root.js +9 -1
- package/version-manager/representative-root.js.map +1 -1
- package/version-manager/specifier-classifier.js +42 -2
- package/version-manager/specifier-classifier.js.map +1 -1
- package/version-manager/specifier-errors.js +58 -0
- package/version-manager/specifier-errors.js.map +1 -1
- package/version-manager/versioned-bundle.d.ts +3 -1
- package/version-manager/versioned-bundle.d.ts.map +1 -1
- package/version-manager/versioned-bundle.js +31 -6
- package/version-manager/versioned-bundle.js.map +1 -1
- package/zip/zip-builder.d.ts +22 -0
- package/zip/zip-builder.d.ts.map +1 -0
- package/zip/zip-builder.js +81 -2
- package/zip/zip-builder.js.map +1 -1
|
@@ -1,2 +1,107 @@
|
|
|
1
|
-
import "../../common/declaration-companion-paths.js";
|
|
1
|
+
import { declarationCompanionCandidates } from "../../common/declaration-companion-paths.js";
|
|
2
|
+
export function bindingId(filePath, name) {
|
|
3
|
+
return `${filePath}::${name}`;
|
|
4
|
+
}
|
|
5
|
+
function bindingIdsByFile(files) {
|
|
6
|
+
const result = new Map();
|
|
7
|
+
for (const file of files) {
|
|
8
|
+
result.set(file.targetFilePath, new Map(file.bindings.map(function (binding) {
|
|
9
|
+
return [binding.name, bindingId(file.targetFilePath, binding.name)];
|
|
10
|
+
})));
|
|
11
|
+
}
|
|
12
|
+
return result;
|
|
13
|
+
}
|
|
14
|
+
function companionBindingId(binding, file, idsByFile) {
|
|
15
|
+
for (const [targetFilePath, bindingIds] of idsByFile) {
|
|
16
|
+
if (declarationCompanionCandidates(targetFilePath).includes(file.targetFilePath)) {
|
|
17
|
+
return bindingIds.get(binding.name);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
function declarationBindingIds(binding, file, idsByFile) {
|
|
23
|
+
const companionId = companionBindingId(binding, file, idsByFile);
|
|
24
|
+
return [
|
|
25
|
+
bindingId(file.targetFilePath, binding.name),
|
|
26
|
+
...companionId === undefined ? [] : [companionId]
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
function inputFilePathFromDeclaration(declarationNode) {
|
|
30
|
+
const node = declarationNode;
|
|
31
|
+
return node.getSourceFile?.().getFilePath();
|
|
32
|
+
}
|
|
33
|
+
function bindingIdsForFile(file, idsByFile) {
|
|
34
|
+
const idsByName = new Map();
|
|
35
|
+
const idsByNode = [];
|
|
36
|
+
for (const binding of file.bindings) {
|
|
37
|
+
const bindingIds = declarationBindingIds(binding, file, idsByFile);
|
|
38
|
+
idsByNode.push([binding.declarationNode, bindingIds]);
|
|
39
|
+
idsByName.set(binding.name, bindingIds);
|
|
40
|
+
}
|
|
41
|
+
return { idsByName, idsByNode };
|
|
42
|
+
}
|
|
43
|
+
function parsedDeclarationInputFilePaths(file) {
|
|
44
|
+
return file.bindings.flatMap(function (binding) {
|
|
45
|
+
const declarationInputFilePath = inputFilePathFromDeclaration(binding.declarationNode);
|
|
46
|
+
return declarationInputFilePath === undefined ? [] : [declarationInputFilePath];
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
function parsedPathsForTarget(file) {
|
|
50
|
+
return [
|
|
51
|
+
file.parsedInputFilePath,
|
|
52
|
+
...parsedDeclarationInputFilePaths(file)
|
|
53
|
+
];
|
|
54
|
+
}
|
|
55
|
+
export function buildDeclarationNodeIndex(files) {
|
|
56
|
+
const index = {
|
|
57
|
+
idsByNode: new Map(),
|
|
58
|
+
idsByFileAndName: new Map(),
|
|
59
|
+
idsByTargetFileAndName: new Map(),
|
|
60
|
+
moduleReferencesByTargetFilePath: new Map(),
|
|
61
|
+
targetFilePathByInputFilePath: new Map()
|
|
62
|
+
};
|
|
63
|
+
const idsByFile = bindingIdsByFile(files);
|
|
64
|
+
function addFilePathEntries(file, idsByName) {
|
|
65
|
+
index.idsByFileAndName.set(file.inputFilePath, idsByName);
|
|
66
|
+
index.idsByFileAndName.set(file.parsedInputFilePath, idsByName);
|
|
67
|
+
index.idsByFileAndName.set(file.targetFilePath, idsByName);
|
|
68
|
+
index.idsByTargetFileAndName.set(file.targetFilePath, idsByName);
|
|
69
|
+
index.moduleReferencesByTargetFilePath.set(file.targetFilePath, file.moduleReferences);
|
|
70
|
+
for (const parsedPath of parsedPathsForTarget(file)) {
|
|
71
|
+
index.idsByFileAndName.set(parsedPath, idsByName);
|
|
72
|
+
index.targetFilePathByInputFilePath.set(parsedPath, file.targetFilePath);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function addFileDeclarationIds(file) {
|
|
76
|
+
const { idsByName, idsByNode: nodeIds } = bindingIdsForFile(file, idsByFile);
|
|
77
|
+
for (const [node, bindingIds] of nodeIds) {
|
|
78
|
+
index.idsByNode.set(node, bindingIds);
|
|
79
|
+
}
|
|
80
|
+
addFilePathEntries(file, idsByName);
|
|
81
|
+
}
|
|
82
|
+
for (const file of files) {
|
|
83
|
+
addFileDeclarationIds(file);
|
|
84
|
+
}
|
|
85
|
+
return index;
|
|
86
|
+
}
|
|
87
|
+
export function buildBindingsByFile(files) {
|
|
88
|
+
const map = new Map();
|
|
89
|
+
for (const file of files) {
|
|
90
|
+
const ids = new Set();
|
|
91
|
+
for (const binding of file.bindings) {
|
|
92
|
+
ids.add(bindingId(file.targetFilePath, binding.name));
|
|
93
|
+
}
|
|
94
|
+
map.set(file.targetFilePath, ids);
|
|
95
|
+
}
|
|
96
|
+
return map;
|
|
97
|
+
}
|
|
98
|
+
export function buildNodeById(files) {
|
|
99
|
+
const map = new Map();
|
|
100
|
+
for (const file of files) {
|
|
101
|
+
for (const binding of file.bindings) {
|
|
102
|
+
map.set(bindingId(file.targetFilePath, binding.name), binding.referenceNode);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return map;
|
|
106
|
+
}
|
|
2
107
|
//# sourceMappingURL=binding-id.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binding-id.js","sourceRoot":"","sources":["../../../../../source/dead-code-eliminator/reachability/binding-id.ts"],"names":[],"mappings":"AACA,
|
|
1
|
+
{"version":3,"file":"binding-id.js","sourceRoot":"","sources":["../../../../../source/dead-code-eliminator/reachability/binding-id.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,8BAA8B,EAAE,MAAM,6CAA6C,CAAC;AA2B7F,MAAM,UAAU,SAAS,CAAC,QAAgB,EAAE,IAAY;IACpD,OAAO,GAAG,QAAQ,KAAK,IAAI,EAAE,CAAC;AAClC,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAgC;IACtD,MAAM,MAAM,GAAG,IAAI,GAAG,EAA4B,CAAC;IACnD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,MAAM,CAAC,GAAG,CACN,IAAI,CAAC,cAAc,EACnB,IAAI,GAAG,CACH,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,OAAO;YAC/B,OAAO,CAAE,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,IAAI,CAAC,CAAE,CAAC;QAC1E,CA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CAAC,SAAS,CAAC,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QAC1D,CAAC;QACD,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC;IACtC,CAAC;IACD,OAAO,GAAG,CAAC;AACf,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,KAAgC;IAC1D,MAAM,GAAG,GAAG,IAAI,GAAG,EAAuB,CAAC;IAC3C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClC,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;QACjF,CAAC;IACL,CAAC;IACD,OAAO,GAAG,CAAC;AACf,CAAC"}
|
|
@@ -1,3 +1,97 @@
|
|
|
1
|
-
import '
|
|
2
|
-
|
|
1
|
+
import { Node as TsMorphNode, SyntaxKind } from 'ts-morph';
|
|
2
|
+
function declarationName(declaration) {
|
|
3
|
+
return declaration.getSymbolOrThrow().getName();
|
|
4
|
+
}
|
|
5
|
+
function declarationPathTargets(declaration, declarationIndex) {
|
|
6
|
+
const name = declarationName(declaration);
|
|
7
|
+
return declarationIndex.idsByFileAndName.get(declaration.getSourceFile().getFilePath())?.get(name) ?? [];
|
|
8
|
+
}
|
|
9
|
+
function importerTargetFilePath(importDeclaration, declarationIndex) {
|
|
10
|
+
const inputFilePath = importDeclaration.getSourceFile().getFilePath();
|
|
11
|
+
return declarationIndex.targetFilePathByInputFilePath.get(inputFilePath);
|
|
12
|
+
}
|
|
13
|
+
function isRelativeImport(importDeclaration) {
|
|
14
|
+
return importDeclaration.getModuleSpecifierValue().startsWith('.');
|
|
15
|
+
}
|
|
16
|
+
function resolvedImportReference(importDeclaration, declarationIndex) {
|
|
17
|
+
const importerPath = importerTargetFilePath(importDeclaration, declarationIndex);
|
|
18
|
+
if (importerPath === undefined) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
const specifier = importDeclaration.getModuleSpecifierValue();
|
|
22
|
+
return declarationIndex.moduleReferencesByTargetFilePath.get(importerPath)?.find(function (reference) {
|
|
23
|
+
return reference.emittedSpecifier === specifier;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
function missingReferenceError(importDeclaration, importerPath) {
|
|
27
|
+
return new Error(`Missing resolved module reference for "${importDeclaration.getModuleSpecifierValue()}" in "${importerPath}"`);
|
|
28
|
+
}
|
|
29
|
+
function relativeImportTargetPath(importDeclaration, declarationIndex) {
|
|
30
|
+
const importerPath = importerTargetFilePath(importDeclaration, declarationIndex);
|
|
31
|
+
const reference = resolvedImportReference(importDeclaration, declarationIndex);
|
|
32
|
+
if (reference === undefined) {
|
|
33
|
+
if (importerPath !== undefined) {
|
|
34
|
+
throw missingReferenceError(importDeclaration, importerPath);
|
|
35
|
+
}
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
return reference.type === 'local-code' ? reference.targetFilePath : undefined;
|
|
39
|
+
}
|
|
40
|
+
function targetsByFileAndName(idsByFileAndName, filePath, name) {
|
|
41
|
+
return filePath === undefined ? [] : idsByFileAndName.get(filePath)?.get(name) ?? [];
|
|
42
|
+
}
|
|
43
|
+
function relativeImportSpecifierTargets(declaration, declarationIndex) {
|
|
44
|
+
const importDeclaration = declaration.getFirstAncestorByKindOrThrow(SyntaxKind.ImportDeclaration);
|
|
45
|
+
if (!isRelativeImport(importDeclaration)) {
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
48
|
+
return targetsByFileAndName(declarationIndex.idsByTargetFileAndName, relativeImportTargetPath(importDeclaration, declarationIndex), declaration.getName());
|
|
49
|
+
}
|
|
50
|
+
function importSpecifierTargets(declaration, declarationIndex) {
|
|
51
|
+
if (!TsMorphNode.isImportSpecifier(declaration)) {
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
return relativeImportSpecifierTargets(declaration, declarationIndex);
|
|
55
|
+
}
|
|
56
|
+
function declarationTargets(declarations, declarationIndex) {
|
|
57
|
+
return declarations.flatMap(function (declaration) {
|
|
58
|
+
return [
|
|
59
|
+
...declarationIndex.idsByNode.get(declaration) ?? [],
|
|
60
|
+
...declarationPathTargets(declaration, declarationIndex),
|
|
61
|
+
...importSpecifierTargets(declaration, declarationIndex)
|
|
62
|
+
];
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
function symbolTargets(symbol, declarationIndex) {
|
|
66
|
+
const aliased = symbol.getAliasedSymbol();
|
|
67
|
+
return [
|
|
68
|
+
...declarationTargets(symbol.getDeclarations(), declarationIndex),
|
|
69
|
+
...aliased === undefined ? [] : declarationTargets(aliased.getDeclarations(), declarationIndex)
|
|
70
|
+
];
|
|
71
|
+
}
|
|
72
|
+
function shorthandPropertyTargets(rootNode, declarationIndex) {
|
|
73
|
+
const targets = [];
|
|
74
|
+
for (const shorthand of rootNode.getDescendantsOfKind(SyntaxKind.ShorthandPropertyAssignment)) {
|
|
75
|
+
const valueSymbol = shorthand.getValueSymbol();
|
|
76
|
+
if (valueSymbol !== undefined) {
|
|
77
|
+
targets.push(...symbolTargets(valueSymbol, declarationIndex));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return targets;
|
|
81
|
+
}
|
|
82
|
+
export function collectIdentifierTargets(rootNode, declarationIndex) {
|
|
83
|
+
const targets = new Set();
|
|
84
|
+
for (const identifier of rootNode.getDescendantsOfKind(SyntaxKind.Identifier)) {
|
|
85
|
+
const symbol = identifier.getSymbol();
|
|
86
|
+
if (symbol !== undefined) {
|
|
87
|
+
for (const target of symbolTargets(symbol, declarationIndex)) {
|
|
88
|
+
targets.add(target);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
for (const target of shorthandPropertyTargets(rootNode, declarationIndex)) {
|
|
93
|
+
targets.add(target);
|
|
94
|
+
}
|
|
95
|
+
return targets;
|
|
96
|
+
}
|
|
3
97
|
//# sourceMappingURL=identifier-target-collector.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identifier-target-collector.js","sourceRoot":"","sources":["../../../../../source/dead-code-eliminator/reachability/identifier-target-collector.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"identifier-target-collector.js","sourceRoot":"","sources":["../../../../../source/dead-code-eliminator/reachability/identifier-target-collector.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,IAAI,IAAI,WAAW,EACnB,UAAU,EAKb,MAAM,UAAU,CAAC;AAalB,SAAS,eAAe,CAAC,WAAwB;IAC7C,OAAO,WAAW,CAAC,gBAAgB,EAAE,CAAC,OAAO,EAAE,CAAC;AACpD,CAAC;AAED,SAAS,sBAAsB,CAC3B,WAAwB,EACxB,gBAAsC;IAEtC,MAAM,IAAI,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC;IAC1C,OAAO,gBAAgB,CAAC,gBAAgB,CAAC,GAAG,CAAC,WAAW,CAAC,aAAa,EAAE,CAAC,WAAW,EAAE,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;AAC7G,CAAC;AAED,SAAS,sBAAsB,CAC3B,iBAAoC,EACpC,gBAAsC;IAEtC,MAAM,aAAa,GAAG,iBAAiB,CAAC,aAAa,EAAE,CAAC,WAAW,EAAE,CAAC;IACtE,OAAO,gBAAgB,CAAC,6BAA6B,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;AAC7E,CAAC;AAED,SAAS,gBAAgB,CAAC,iBAAoC;IAC1D,OAAO,iBAAiB,CAAC,uBAAuB,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AACvE,CAAC;AAED,SAAS,uBAAuB,CAC5B,iBAAoC,EACpC,gBAAsC;IAEtC,MAAM,YAAY,GAAG,sBAAsB,CAAC,iBAAiB,EAAE,gBAAgB,CAAC,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+
import { classifySideEffects } from "../side-effect-classifier.js";
|
|
3
|
+
export function collectImpureStatements(sourceFile, deadCodeElimination) {
|
|
4
|
+
const impureLines = new Set();
|
|
5
|
+
for (const statement of classifySideEffects(sourceFile, deadCodeElimination)) {
|
|
6
|
+
impureLines.add(statement.line);
|
|
7
|
+
}
|
|
8
|
+
return sourceFile.getStatements().filter(function (statement) {
|
|
9
|
+
return impureLines.has(statement.getStartLineNumber()) && !TsMorphNode.isImportDeclaration(statement);
|
|
10
|
+
});
|
|
11
|
+
}
|
|
3
12
|
//# sourceMappingURL=impure-statements.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"impure-statements.js","sourceRoot":"","sources":["../../../../../source/dead-code-eliminator/reachability/impure-statements.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"impure-statements.js","sourceRoot":"","sources":["../../../../../source/dead-code-eliminator/reachability/impure-statements.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,WAAW,EAAmC,MAAM,UAAU,CAAC;AAEhF,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAEnE,MAAM,UAAU,uBAAuB,CACnC,UAAgC,EAChC,mBAA4D;IAE5D,MAAM,WAAW,GAAG,IAAI,GAAG,EAAU,CAAC;IACtC,KAAK,MAAM,SAAS,IAAI,mBAAmB,CAAC,UAAU,EAAE,mBAAmB,CAAC,EAAE,CAAC;QAC3E,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;IACD,OAAO,UAAU,CAAC,aAAa,EAAE,CAAC,MAAM,CAAC,UAAU,SAAS;QACxD,OAAO,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,kBAAkB,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC;IAC1G,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1,5 +1,92 @@
|
|
|
1
|
-
import 'ts-morph';
|
|
2
|
-
import "./binding-id.js";
|
|
3
|
-
import "./identifier-target-collector.js";
|
|
4
|
-
import "./impure-statements.js";
|
|
1
|
+
import { Node as TsMorphNode } from 'ts-morph';
|
|
2
|
+
import { bindingId } from "./binding-id.js";
|
|
3
|
+
import { collectIdentifierTargets } from "./identifier-target-collector.js";
|
|
4
|
+
import { collectImpureStatements } from "./impure-statements.js";
|
|
5
|
+
function statementSeeds(file, statements, declarationIndex, reason) {
|
|
6
|
+
return statements.flatMap(function (statement) {
|
|
7
|
+
return Array.from(collectIdentifierTargets(statement, declarationIndex), function (seed) {
|
|
8
|
+
return {
|
|
9
|
+
bindingId: seed,
|
|
10
|
+
inputFilePath: file.inputFilePath,
|
|
11
|
+
line: statement.getStartLineNumber(),
|
|
12
|
+
reason
|
|
13
|
+
};
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
function entryPointExportDeclarationSeeds(file, declarationIndex) {
|
|
18
|
+
return file.sourceFile.getStatements().flatMap(function (statement) {
|
|
19
|
+
return TsMorphNode.isExportDeclaration(statement)
|
|
20
|
+
? statementSeeds(file, [statement], declarationIndex, 'entry-export-declaration')
|
|
21
|
+
: [];
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
function bindingLine(binding, trace) {
|
|
25
|
+
if (trace === undefined) {
|
|
26
|
+
return 0;
|
|
27
|
+
}
|
|
28
|
+
return binding.statement.getStartLineNumber();
|
|
29
|
+
}
|
|
30
|
+
function exportedBindingSeeds(file, isEntry, trace) {
|
|
31
|
+
if (!isEntry) {
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
return file.bindings.flatMap(function (binding) {
|
|
35
|
+
return binding.isExported
|
|
36
|
+
? [
|
|
37
|
+
{
|
|
38
|
+
bindingId: bindingId(file.targetFilePath, binding.name),
|
|
39
|
+
inputFilePath: file.inputFilePath,
|
|
40
|
+
line: bindingLine(binding, trace),
|
|
41
|
+
reason: 'entry-export'
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
: [];
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function seedsForFile(file, isEntry, context) {
|
|
48
|
+
const impureStatements = collectImpureStatements(file.sourceFile, context.deadCodeElimination);
|
|
49
|
+
return [
|
|
50
|
+
...exportedBindingSeeds(file, isEntry, context.trace),
|
|
51
|
+
...isEntry ? entryPointExportDeclarationSeeds(file, context.declarationIndex) : [],
|
|
52
|
+
...statementSeeds(file, impureStatements, context.declarationIndex, 'impure-statement')
|
|
53
|
+
];
|
|
54
|
+
}
|
|
55
|
+
function addSeed(input) {
|
|
56
|
+
const { bundleName, seed, seeds, trace } = input;
|
|
57
|
+
const alreadyAdded = seeds.has(seed.bindingId);
|
|
58
|
+
const nextSeeds = new Set(seeds);
|
|
59
|
+
nextSeeds.add(seed.bindingId);
|
|
60
|
+
if (!alreadyAdded && trace !== undefined) {
|
|
61
|
+
trace.collector.record({
|
|
62
|
+
type: 'local-seed-added',
|
|
63
|
+
bundleName,
|
|
64
|
+
bindingId: seed.bindingId,
|
|
65
|
+
inputFilePath: seed.inputFilePath,
|
|
66
|
+
line: seed.line,
|
|
67
|
+
reason: seed.reason
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return nextSeeds;
|
|
71
|
+
}
|
|
72
|
+
export function gatherLocalSeeds(input) {
|
|
73
|
+
let seeds = new Set();
|
|
74
|
+
for (const file of input.files) {
|
|
75
|
+
const isEntry = input.entryPointFilePaths.has(file.targetFilePath);
|
|
76
|
+
const fileSeeds = seedsForFile(file, isEntry, {
|
|
77
|
+
declarationIndex: input.declarationIndex,
|
|
78
|
+
deadCodeElimination: input.deadCodeElimination,
|
|
79
|
+
trace: input.trace
|
|
80
|
+
});
|
|
81
|
+
for (const seed of fileSeeds) {
|
|
82
|
+
seeds = addSeed({
|
|
83
|
+
seeds,
|
|
84
|
+
seed,
|
|
85
|
+
bundleName: input.bundleName,
|
|
86
|
+
trace: input.trace
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return seeds;
|
|
91
|
+
}
|
|
5
92
|
//# sourceMappingURL=local-seed-gathering.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-seed-gathering.js","sourceRoot":"","sources":["../../../../../source/dead-code-eliminator/reachability/local-seed-gathering.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"local-seed-gathering.js","sourceRoot":"","sources":["../../../../../source/dead-code-eliminator/reachability/local-seed-gathering.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,WAAW,EAAmC,MAAM,UAAU,CAAC;AAGhF,OAAO,EAAE,SAAS,EAAuB,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,wBAAwB,EAA6B,MAAM,kCAAkC,CAAC;AACvG,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AA4BjE,SAAS,cAAc,CACnB,IAAkB,EAClB,UAAgC,EAChC,gBAAsC,EACtC,MAAuB;IAEvB,OAAO,UAAU,CAAC,OAAO,CAAC,UAAU,SAAS;QACzC,OAAO,KAAK,CAAC,IAAI,CAAC,wBAAwB,CAAC,SAAS,EAAE,gBAAgB,CAAC,EAAE,UAAU,IAAI;YACnF,OAAO;gBACH,SAAS,EAAE,IAAI;gBACf,aAAa,EAAE,IAAI,CAAC,aAAa;gBACjC,IAAI,EAAE,SAAS,CAAC,kBAAkB,EAAE;gBACpC,MAAM;aACT,CAAC;QACN,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC;AAED,SAAS,gCAAgC,CACrC,IAAkB,EAClB,gBAAsC;IAEtC,OAAO,IAAI,CAAC,UAAU,CAAC,aAAa,EAAE,CAAC,OAAO,CAAC,UAAU,SAAS;QAC9D,OAAO,WAAW,CAAC,mBAAmB,CAAC,SAAS,CAAC;YAC7C,CAAC,CAAC,cAAc,CAAC,IAAI,EAAE,CAAE,SAAS,CAAE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,KAAK;gBACL,IAAI;gBACJ,UAAU,EAAE,KAAK,CAAC,UAAU;gBAC5B,KAAK,EAAE,KAAK,CAAC,KAAK;aACrB,CAAC,CAAC;QACP,CAAC;IACL,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC"}
|
|
@@ -1,5 +1,66 @@
|
|
|
1
|
-
import "./bfs-closure.js";
|
|
2
|
-
import "./binding-id.js";
|
|
3
|
-
import "./identifier-target-collector.js";
|
|
4
|
-
import "./local-seed-gathering.js";
|
|
1
|
+
import { bfsClosure } from "./bfs-closure.js";
|
|
2
|
+
import { buildBindingsByFile, buildDeclarationNodeIndex, buildNodeById } from "./binding-id.js";
|
|
3
|
+
import { collectIdentifierTargets } from "./identifier-target-collector.js";
|
|
4
|
+
import { gatherLocalSeeds } from "./local-seed-gathering.js";
|
|
5
|
+
const emptyStringSet = new Set();
|
|
6
|
+
const defaultDependencies = {
|
|
7
|
+
visitedHas(visited, value) {
|
|
8
|
+
return visited.has(value);
|
|
9
|
+
},
|
|
10
|
+
neighborAdded: undefined
|
|
11
|
+
};
|
|
12
|
+
function tracedDependencies(input, dependencies) {
|
|
13
|
+
return {
|
|
14
|
+
visitedHas: dependencies.visitedHas,
|
|
15
|
+
neighborAdded(fromBindingId, toBindingId) {
|
|
16
|
+
if (dependencies.neighborAdded !== undefined) {
|
|
17
|
+
dependencies.neighborAdded(fromBindingId, toBindingId);
|
|
18
|
+
}
|
|
19
|
+
if (input.trace !== undefined) {
|
|
20
|
+
input.trace.collector.record({
|
|
21
|
+
type: 'edge-added',
|
|
22
|
+
bundleName: input.bundleName,
|
|
23
|
+
fromBindingId,
|
|
24
|
+
toBindingId,
|
|
25
|
+
reason: 'identifier-reference'
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export function buildReachabilityIndex(input, dependencies = {}) {
|
|
32
|
+
const resolvedDependencies = tracedDependencies(input, { ...defaultDependencies, ...dependencies });
|
|
33
|
+
const declarationIndex = buildDeclarationNodeIndex(input.files);
|
|
34
|
+
const nodeById = buildNodeById(input.files);
|
|
35
|
+
const maximumNodeCount = nodeById.size;
|
|
36
|
+
const expand = function (id) {
|
|
37
|
+
const node = nodeById.get(id);
|
|
38
|
+
return node === undefined ? emptyStringSet : collectIdentifierTargets(node, declarationIndex);
|
|
39
|
+
};
|
|
40
|
+
const localSeeds = gatherLocalSeeds({
|
|
41
|
+
files: input.files,
|
|
42
|
+
entryPointFilePaths: input.entryPointFilePaths,
|
|
43
|
+
declarationIndex,
|
|
44
|
+
deadCodeElimination: input.deadCodeElimination,
|
|
45
|
+
bundleName: input.bundleName,
|
|
46
|
+
trace: input.trace
|
|
47
|
+
});
|
|
48
|
+
const localReachable = bfsClosure(localSeeds, expand, emptyStringSet, {
|
|
49
|
+
maximumNodeCount,
|
|
50
|
+
dependencies: resolvedDependencies
|
|
51
|
+
});
|
|
52
|
+
return {
|
|
53
|
+
localReachable,
|
|
54
|
+
bindingIdsByFile: buildBindingsByFile(input.files),
|
|
55
|
+
expandWith(externalSeeds) {
|
|
56
|
+
if (externalSeeds === undefined || externalSeeds.size === 0) {
|
|
57
|
+
return localReachable;
|
|
58
|
+
}
|
|
59
|
+
return bfsClosure(externalSeeds, expand, localReachable, {
|
|
60
|
+
maximumNodeCount,
|
|
61
|
+
dependencies: resolvedDependencies
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
5
66
|
//# sourceMappingURL=reachability.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reachability.js","sourceRoot":"","sources":["../../../../../source/dead-code-eliminator/reachability/reachability.ts"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"reachability.js","sourceRoot":"","sources":["../../../../../source/dead-code-eliminator/reachability/reachability.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAA+B,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAE,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|
+
import { Node as TsMorphNode } from 'ts-morph';
|
|
2
|
+
import { booleanValue, factsAfterStatement } from "./liveness/boolean-facts.js";
|
|
3
|
+
import { statementClassifierFor } from "./statement-classifiers.js";
|
|
4
|
+
import { describeControlFlowStatementKind, pureDeclarationKinds } from "./syntax-kind-sets.js";
|
|
5
|
+
function isStaticallyUnreachableIfStatement(statement, facts) {
|
|
6
|
+
return TsMorphNode.isIfStatement(statement) &&
|
|
7
|
+
statement.getElseStatement() === undefined &&
|
|
8
|
+
booleanValue(statement.getExpression(), facts) === false;
|
|
9
|
+
}
|
|
10
|
+
function classifyResidualStatement(statement, settings) {
|
|
11
|
+
const kind = statement.getKind();
|
|
12
|
+
const controlFlowKind = describeControlFlowStatementKind(kind);
|
|
13
|
+
if (controlFlowKind !== undefined) {
|
|
14
|
+
return controlFlowKind;
|
|
15
|
+
}
|
|
16
|
+
const classifier = statementClassifierFor(kind);
|
|
17
|
+
if (classifier !== undefined) {
|
|
18
|
+
return classifier(statement, settings);
|
|
19
|
+
}
|
|
20
|
+
return 'unknown statement';
|
|
21
|
+
}
|
|
22
|
+
function classifyTopLevelStatement(statement, settings, facts) {
|
|
23
|
+
if (pureDeclarationKinds.has(statement.getKind()) || isStaticallyUnreachableIfStatement(statement, facts)) {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
return classifyResidualStatement(statement, settings);
|
|
27
|
+
}
|
|
28
|
+
export function classifySideEffects(sourceFile, settings) {
|
|
29
|
+
const results = [];
|
|
30
|
+
let facts = new Map();
|
|
31
|
+
for (const statement of sourceFile.getStatements()) {
|
|
32
|
+
const kind = classifyTopLevelStatement(statement, settings, facts);
|
|
33
|
+
if (kind !== undefined) {
|
|
34
|
+
results.push({ line: statement.getStartLineNumber(), kind });
|
|
35
|
+
}
|
|
36
|
+
facts = factsAfterStatement(statement, facts);
|
|
37
|
+
}
|
|
38
|
+
return results;
|
|
39
|
+
}
|
|
5
40
|
//# sourceMappingURL=side-effect-classifier.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"side-effect-classifier.js","sourceRoot":"","sources":["../../../../source/dead-code-eliminator/side-effect-classifier.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"side-effect-classifier.js","sourceRoot":"","sources":["../../../../source/dead-code-eliminator/side-effect-classifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,WAAW,EAAmC,MAAM,UAAU,CAAC;AAGhF,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAqB,MAAM,6BAA6B,CAAC;AACnG,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,gCAAgC,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE/F,SAAS,kCAAkC,CAAC,SAAoB,EAAE,KAAmB;IACjF,OAAO,WAAW,CAAC,aAAa,CAAC,SAAS,CAAC;QACvC,SAAS,CAAC,gBAAgB,EAAE,KAAK,SAAS;QAC1C,YAAY,CAAC,SAAS,CAAC,aAAa,EAAE,EAAE,KAAK,CAAC,KAAK,KAAK,CAAC;AACjE,CAAC;AAED,SAAS,yBAAyB,CAC9B,SAAoB,EACpB,QAAiD;IAEjD,MAAM,IAAI,GAAG,SAAS,CAAC,OAAO,EAAE,CAAC;IACjC,MAAM,eAAe,GAAG,gCAAgC,CAAC,IAAI,CAAC,CAAC;IAC/D,IAAI,eAAe,KAAK,SAAS,EAAE,CAAC;QAChC,OAAO,eAAe,CAAC;IAC3B,CAAC;IACD,MAAM,UAAU,GAAG,sBAAsB,CAAC,IAAI,CAAC,CAAC;IAChD,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO,UAAU,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC3C,CAAC;IACD,OAAO,mBAAmB,CAAC;AAC/B,CAAC;AAED,SAAS,yBAAyB,CAC9B,SAAoB,EACpB,QAAiD,EACjD,KAAmB;IAEnB,IAAI,oBAAoB,CAAC,GAAG,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,IAAI,kCAAkC,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC;QACxG,OAAO,SAAS,CAAC;IACrB,CAAC;IACD,OAAO,yBAAyB,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;AAC1D,CAAC;AAED,MAAM,UAAU,mBAAmB,CAC/B,UAAgC,EAChC,QAAsC;IAEtC,MAAM,OAAO,GAA0B,EAAE,CAAC;IAC1C,IAAI,KAAK,GAAiB,IAAI,GAAG,EAAE,CAAC;IACpC,KAAK,MAAM,SAAS,IAAI,UAAU,CAAC,aAAa,EAAE,EAAE,CAAC;QACjD,MAAM,IAAI,GAAG,yBAAyB,CAAC,SAAS,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;QACnE,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACrB,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,kBAAkB,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;QACjE,CAAC;QACD,KAAK,GAAG,mBAAmB,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,OAAO,CAAC;AACnB,CAAC"}
|
|
@@ -1,2 +1,24 @@
|
|
|
1
|
-
import "./liveness/runtime-code.js";
|
|
1
|
+
import { isRuntimeCodeTargetPath } from "./liveness/runtime-code.js";
|
|
2
|
+
function fileHasSideEffects(resource) {
|
|
3
|
+
return resource.analysis.sideEffectStatements.length > 0;
|
|
4
|
+
}
|
|
5
|
+
export function computeSideEffectsField(contents) {
|
|
6
|
+
const codeFiles = contents.filter(function (resource) {
|
|
7
|
+
return isRuntimeCodeTargetPath(resource.fileDescription.targetFilePath);
|
|
8
|
+
});
|
|
9
|
+
const impureFiles = codeFiles.filter(fileHasSideEffects);
|
|
10
|
+
if (impureFiles.length === 0) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
if (impureFiles.length === codeFiles.length) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
return impureFiles
|
|
17
|
+
.map(function (resource) {
|
|
18
|
+
return `./${resource.fileDescription.targetFilePath}`;
|
|
19
|
+
})
|
|
20
|
+
.toSorted(function (left, right) {
|
|
21
|
+
return left.localeCompare(right);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
2
24
|
//# sourceMappingURL=side-effects-field.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"side-effects-field.js","sourceRoot":"","sources":["../../../../source/dead-code-eliminator/side-effects-field.ts"],"names":[],"mappings":"AACA,
|
|
1
|
+
{"version":3,"file":"side-effects-field.js","sourceRoot":"","sources":["../../../../source/dead-code-eliminator/side-effects-field.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAErE,SAAS,kBAAkB,CAAC,QAAgC;IACxD,OAAO,QAAQ,CAAC,QAAQ,CAAC,oBAAoB,CAAC,MAAM,GAAG,CAAC,CAAC;AAC7D,CAAC;AAED,MAAM,UAAU,uBAAuB,CACnC,QAA2C;IAE3C,MAAM,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC,UAAU,QAAQ;QAChD,OAAO,uBAAuB,CAAC,QAAQ,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC;IAC5E,CAAC,CAAC,CAAC;IACH,MAAM,WAAW,GAAG,SAAS,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;IACzD,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,IAAI,WAAW,CAAC,MAAM,KAAK,SAAS,CAAC,MAAM,EAAE,CAAC;QAC1C,OAAO,SAAS,CAAC;IACrB,CAAC;IACD,OAAO,WAAW;SACb,GAAG,CAAC,UAAU,QAAQ;QACnB,OAAO,KAAK,QAAQ,CAAC,eAAe,CAAC,cAAc,EAAE,CAAC;IAC1D,CAAC,CAAC;SACD,QAAQ,CAAC,UAAU,IAAI,EAAE,KAAK;QAC3B,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -1,3 +1,30 @@
|
|
|
1
|
-
import "./transform/atom-translator.js";
|
|
2
|
-
import "./transform/source-map-composer.js";
|
|
1
|
+
import { toSourceMapTransform } from "./transform/atom-translator.js";
|
|
2
|
+
import { recomposeSourceMap } from "./transform/source-map-composer.js";
|
|
3
|
+
export function buildMapPathTransformIndex(outputs, sourceMapTransformsByTargetPath = new Map()) {
|
|
4
|
+
const transformsByMapPath = new Map();
|
|
5
|
+
for (const [targetPath, transforms] of sourceMapTransformsByTargetPath) {
|
|
6
|
+
transformsByMapPath.set(`${targetPath}.map`, transforms);
|
|
7
|
+
}
|
|
8
|
+
for (const output of outputs) {
|
|
9
|
+
const mapPath = `${output.resource.fileDescription.targetFilePath}.map`;
|
|
10
|
+
for (const transform of output.transforms) {
|
|
11
|
+
const current = transformsByMapPath.get(mapPath) ?? [];
|
|
12
|
+
transformsByMapPath.set(mapPath, [...current, toSourceMapTransform(transform.textTransform)]);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return transformsByMapPath;
|
|
16
|
+
}
|
|
17
|
+
export function recomposePairedSourceMaps(contents, transformsByMapPath) {
|
|
18
|
+
return contents.map(function (resource) {
|
|
19
|
+
const sourceMapTransforms = transformsByMapPath.get(resource.fileDescription.targetFilePath);
|
|
20
|
+
if (sourceMapTransforms === undefined) {
|
|
21
|
+
return resource;
|
|
22
|
+
}
|
|
23
|
+
const recomposed = recomposeSourceMap(resource.fileDescription.content, sourceMapTransforms);
|
|
24
|
+
return {
|
|
25
|
+
...resource,
|
|
26
|
+
fileDescription: { ...resource.fileDescription, content: recomposed }
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
}
|
|
3
30
|
//# sourceMappingURL=source-map-recomposition.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source-map-recomposition.js","sourceRoot":"","sources":["../../../../source/dead-code-eliminator/source-map-recomposition.ts"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"source-map-recomposition.js","sourceRoot":"","sources":["../../../../source/dead-code-eliminator/source-map-recomposition.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAA2B,MAAM,gCAAgC,CAAC;AAC/F,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAExE,MAAM,UAAU,0BAA0B,CACtC,OAA0C,EAC1C,kCAAsF,IAAI,GAAG,EAAE;IAE/F,MAAM,mBAAmB,GAAG,IAAI,GAAG,EAAyC,CAAC;IAC7E,KAAK,MAAM,CAAE,UAAU,EAAE,UAAU,CAAE,IAAI,+BAA+B,EAAE,CAAC;QACvE,mBAAmB,CAAC,GAAG,CAAC,GAAG,UAAU,MAAM,EAAE,UAAU,CAAC,CAAC;IAC7D,CAAC;IAED,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC3B,MAAM,OAAO,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,cAAc,MAAM,CAAC;QACxE,KAAK,MAAM,SAAS,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;YACxC,MAAM,OAAO,GAAG,mBAAmB,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YACvD,mBAAmB,CAAC,GAAG,CAAC,OAAO,EAAE,CAAE,GAAG,OAAO,EAAE,oBAAoB,CAAC,SAAS,CAAC,aAAa,CAAC,CAAE,CAAC,CAAC;QACpG,CAAC;IACL,CAAC;IAED,OAAO,mBAAmB,CAAC;AAC/B,CAAC;AAED,MAAM,UAAU,yBAAyB,CACrC,QAA2C,EAC3C,mBAAuE;IAEvE,OAAO,QAAQ,CAAC,GAAG,CAAC,UAAU,QAAQ;QAClC,MAAM,mBAAmB,GAAG,mBAAmB,CAA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