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,4 +1,173 @@
|
|
|
1
|
-
import
|
|
2
|
-
import "
|
|
3
|
-
|
|
1
|
+
import { getModuleReferenceLiterals } from "../dependency-scanner/source-file-references.js";
|
|
2
|
+
import { isCodeTargetPath } from "./liveness/runtime-code.js";
|
|
3
|
+
function hasPackageName(reference) {
|
|
4
|
+
return Object.hasOwn(reference, 'packageName');
|
|
5
|
+
}
|
|
6
|
+
function isLocalDependencyReference(reference) {
|
|
7
|
+
return Object.hasOwn(reference, 'targetFilePath') && !hasPackageName(reference);
|
|
8
|
+
}
|
|
9
|
+
const isPackageDependencyReference = hasPackageName;
|
|
10
|
+
function survivingSpecifiersFor(resource, sourceFilesByPath) {
|
|
11
|
+
const sourceFile = sourceFilesByPath.get(resource.fileDescription.targetFilePath);
|
|
12
|
+
if (sourceFile === undefined) {
|
|
13
|
+
return new Set();
|
|
14
|
+
}
|
|
15
|
+
return new Set(getModuleReferenceLiterals(sourceFile).map(function (literal) {
|
|
16
|
+
return literal.getLiteralValue();
|
|
17
|
+
}));
|
|
18
|
+
}
|
|
19
|
+
function survivingLocalTargets(resource, sourceFilesByPath) {
|
|
20
|
+
const specifiers = survivingSpecifiersFor(resource, sourceFilesByPath);
|
|
21
|
+
return new Set(resource.moduleReferences.flatMap(function (reference) {
|
|
22
|
+
return isLocalDependencyReference(reference) && specifiers.has(reference.emittedSpecifier)
|
|
23
|
+
? [reference.targetFilePath]
|
|
24
|
+
: [];
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
function recomputeDirectDependencies(resource, sourceFilesByPath) {
|
|
28
|
+
if (!isCodeTargetPath(resource.fileDescription.targetFilePath)) {
|
|
29
|
+
return resource;
|
|
30
|
+
}
|
|
31
|
+
const survivingPaths = survivingLocalTargets(resource, sourceFilesByPath);
|
|
32
|
+
return {
|
|
33
|
+
...resource,
|
|
34
|
+
directDependencies: new Set(Array.from(resource.directDependencies).filter(function (dependency) {
|
|
35
|
+
return survivingPaths.has(dependency) || dependency.endsWith('.map');
|
|
36
|
+
}))
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function referencedPackagesByPath(contents, sourceFilesByPath) {
|
|
40
|
+
return new Map(contents.map(function (resource) {
|
|
41
|
+
const specifiers = survivingSpecifiersFor(resource, sourceFilesByPath);
|
|
42
|
+
const packagesByName = new Map();
|
|
43
|
+
const survivingReferences = resource
|
|
44
|
+
.moduleReferences
|
|
45
|
+
.filter(isPackageDependencyReference)
|
|
46
|
+
.filter(function (reference) {
|
|
47
|
+
return specifiers.has(reference.emittedSpecifier);
|
|
48
|
+
});
|
|
49
|
+
for (const reference of survivingReferences) {
|
|
50
|
+
const existing = packagesByName.get(reference.packageName) ?? [];
|
|
51
|
+
packagesByName.set(reference.packageName, new Set([...existing, reference.emittedSpecifier]));
|
|
52
|
+
}
|
|
53
|
+
return [resource.fileDescription.targetFilePath, packagesByName];
|
|
54
|
+
}));
|
|
55
|
+
}
|
|
56
|
+
function legacyDependencyReference(dependency, targetFilePath) {
|
|
57
|
+
return {
|
|
58
|
+
targetFilePath,
|
|
59
|
+
sourceSpecifier: dependency.name,
|
|
60
|
+
emittedSpecifier: dependency.name
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function legacyDependencyReferences(dependency) {
|
|
64
|
+
const [targetFilePath, ...rest] = dependency.referencedFrom;
|
|
65
|
+
return [
|
|
66
|
+
legacyDependencyReference(dependency, targetFilePath),
|
|
67
|
+
...rest.map(function (filePath) {
|
|
68
|
+
return legacyDependencyReference(dependency, filePath);
|
|
69
|
+
})
|
|
70
|
+
];
|
|
71
|
+
}
|
|
72
|
+
function dependencyReferences(dependency) {
|
|
73
|
+
return dependency.references ?? legacyDependencyReferences(dependency);
|
|
74
|
+
}
|
|
75
|
+
function isSameDependencyReference(left, right) {
|
|
76
|
+
return left.targetFilePath === right.targetFilePath &&
|
|
77
|
+
left.sourceSpecifier === right.sourceSpecifier &&
|
|
78
|
+
left.emittedSpecifier === right.emittedSpecifier;
|
|
79
|
+
}
|
|
80
|
+
function uniqueDependencyReferences(references) {
|
|
81
|
+
const [firstReference, ...rest] = references;
|
|
82
|
+
const unique = [firstReference];
|
|
83
|
+
for (const reference of rest) {
|
|
84
|
+
const isNewReference = unique.every(function (value) {
|
|
85
|
+
return !isSameDependencyReference(value, reference);
|
|
86
|
+
});
|
|
87
|
+
if (isNewReference) {
|
|
88
|
+
unique.push(reference);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return unique;
|
|
92
|
+
}
|
|
93
|
+
function mergeDependencyTargetPaths(dependency, reference) {
|
|
94
|
+
const sourcePaths = new Set([...dependency.referencedFrom, reference.targetFilePath]);
|
|
95
|
+
sourcePaths.delete(dependency.referencedFrom[0]);
|
|
96
|
+
return [dependency.referencedFrom[0], ...sourcePaths];
|
|
97
|
+
}
|
|
98
|
+
function mergeDependencyReferences(dependency, reference) {
|
|
99
|
+
const [firstReference, ...rest] = dependencyReferences(dependency);
|
|
100
|
+
return uniqueDependencyReferences([firstReference, ...rest, reference]);
|
|
101
|
+
}
|
|
102
|
+
function addReference(dependencies, dependencyName, reference) {
|
|
103
|
+
const dependency = dependencies.get(dependencyName);
|
|
104
|
+
if (dependency === undefined) {
|
|
105
|
+
dependencies.set(dependencyName, {
|
|
106
|
+
name: dependencyName,
|
|
107
|
+
referencedFrom: [reference.targetFilePath],
|
|
108
|
+
references: [reference]
|
|
109
|
+
});
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
dependencies.set(dependencyName, {
|
|
113
|
+
name: dependencyName,
|
|
114
|
+
referencedFrom: mergeDependencyTargetPaths(dependency, reference),
|
|
115
|
+
references: mergeDependencyReferences(dependency, reference)
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
function shouldPreserveDependencyReference(dependency, reference, packagesByPath, preservedReferencePaths) {
|
|
119
|
+
if (preservedReferencePaths.has(reference.targetFilePath)) {
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
const emittedSpecifiers = packagesByPath.get(reference.targetFilePath)?.get(dependency.name);
|
|
123
|
+
if (emittedSpecifiers === undefined) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
return dependency.references === undefined ||
|
|
127
|
+
emittedSpecifiers.has(reference.emittedSpecifier);
|
|
128
|
+
}
|
|
129
|
+
function recomputeDependencies(dependencies, packagesByPath, preservedReferencePaths) {
|
|
130
|
+
const recomputed = new Map();
|
|
131
|
+
for (const dependency of dependencies.values()) {
|
|
132
|
+
for (const reference of dependencyReferences(dependency)) {
|
|
133
|
+
if (shouldPreserveDependencyReference(dependency, reference, packagesByPath, preservedReferencePaths)) {
|
|
134
|
+
addReference(recomputed, dependency.name, reference);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return recomputed;
|
|
139
|
+
}
|
|
140
|
+
function declarationTargetPaths(contents) {
|
|
141
|
+
const paths = new Set();
|
|
142
|
+
for (const resource of contents) {
|
|
143
|
+
if (resource.fileDescription.targetFilePath.endsWith('.d.ts')) {
|
|
144
|
+
paths.add(resource.fileDescription.targetFilePath);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return paths;
|
|
148
|
+
}
|
|
149
|
+
function filterSubstitutedSourcePaths(substitutedInputFilePathsByPackageName, linkedBundleDependencies) {
|
|
150
|
+
return new Map(Array.from(substitutedInputFilePathsByPackageName).filter(function ([packageName]) {
|
|
151
|
+
return linkedBundleDependencies.has(packageName);
|
|
152
|
+
}));
|
|
153
|
+
}
|
|
154
|
+
export function indexSourceFiles(loaded) {
|
|
155
|
+
return new Map(loaded.fileBindings.map(function (binding) {
|
|
156
|
+
return [binding.targetFilePath, binding.sourceFile];
|
|
157
|
+
}));
|
|
158
|
+
}
|
|
159
|
+
export function recomputeDependencyMetadata(bundle, contents, sourceFileIndex) {
|
|
160
|
+
const recomputedContents = contents.map(function (resource) {
|
|
161
|
+
return recomputeDirectDependencies(resource, sourceFileIndex);
|
|
162
|
+
});
|
|
163
|
+
const packagesByPath = referencedPackagesByPath(recomputedContents, sourceFileIndex);
|
|
164
|
+
const preservedReferencePaths = declarationTargetPaths(recomputedContents);
|
|
165
|
+
const linkedBundleDependencies = recomputeDependencies(bundle.linkedBundleDependencies, packagesByPath, preservedReferencePaths);
|
|
166
|
+
return {
|
|
167
|
+
contents: recomputedContents,
|
|
168
|
+
externalDependencies: recomputeDependencies(bundle.externalDependencies, packagesByPath, preservedReferencePaths),
|
|
169
|
+
linkedBundleDependencies,
|
|
170
|
+
substitutedInputFilePathsByPackageName: filterSubstitutedSourcePaths(bundle.substitutedInputFilePathsByPackageName, linkedBundleDependencies)
|
|
171
|
+
};
|
|
172
|
+
}
|
|
4
173
|
//# sourceMappingURL=dependency-metadata.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependency-metadata.js","sourceRoot":"","sources":["../../../../source/dead-code-eliminator/dependency-metadata.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"dependency-metadata.js","sourceRoot":"","sources":["../../../../source/dead-code-eliminator/dependency-metadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,iDAAiD,CAAC;AAI7F,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AA6C9D,SAAS,cAAc,CAAC,SAAkC;IACtD,OAAO,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;AACnD,CAAC;AAED,SAAS,0BAA0B,CAAC,SAAkC;IAClE,OAAO,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,gBAAgB,CAAC,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;AACpF,CAAC;AAED,MAAM,4BAA4B,GAAG,cAAc,CAAC;AAEpD,SAAS,sBAAsB,CAC3B,QAAgC,EAChC,iBAAmC;IAEnC,MAAM,UAAU,GAAG,iBAAiB,CAAC,GAAG,CAAC,QAAQ,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC;IAClF,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO,IAAI,GAAG,EAAU,CAAC;IAC7B,CAAC;IACD,OAAO,IAAI,GAAG,CACV,0BAA0B,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,UAAU,OAAO;QACxD,OAAO,OAAO,CAAC,eAAe,EAAE,CAA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AAsB,EACtB,QAA2C,EAC3C,eAAiC;IAEjC,MAAM,kBAAkB,GAAG,QAAQ,CAAC,GAAG,CAAC,UAAU,QAAQ;QACtD,OAAO,2BAA2B,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;IACH,MAAM,cAAc,GAAG,wBAAwB,CAAC,kBAAkB,EAAE,eAAe,CAAC,CAAC;IACrF,MAAM,uBAAuB,GAAG,sBAAsB,CAAC,kBAAkB,CAAC,CAAC;IAC3E,MAAM,wBAAwB,GAAG,qBAAqB,CAClD,MAAM,CAAC,wBAAwB,EAC/B,cAAc,EACd,uBAAuB,CAC1B,CAAC;IACF,OAAO;QACH,QAAQ,EAAE,kBAAkB;QAC5B,oBAAoB,EAAE,qBAAqB,CACvC,MAAM,CAAC,oBAAoB,EAC3B,cAAc,EACd,uBAAuB,CAC1B;QACD,wBAAwB;QACxB,sCAAsC,EAAE,4BAA4B,CAChE,MAAM,CAAC,sCAAsC,EAC7C,wBAAwB,CAC3B;KACJ,CAAC;AACN,CAAC"}
|
|
@@ -1 +1,53 @@
|
|
|
1
|
+
function buildFileDecisions(original, analyzed) {
|
|
2
|
+
const analyzedBySourcePath = new Map(analyzed.contents.map(function (entry) {
|
|
3
|
+
return [entry.fileDescription.inputFilePath, entry];
|
|
4
|
+
}));
|
|
5
|
+
return original.contents.map(function (entry) {
|
|
6
|
+
const emitted = analyzedBySourcePath.get(entry.fileDescription.inputFilePath);
|
|
7
|
+
const sourceBytes = Buffer.byteLength(entry.fileDescription.content);
|
|
8
|
+
if (emitted === undefined) {
|
|
9
|
+
return {
|
|
10
|
+
path: entry.fileDescription.inputFilePath,
|
|
11
|
+
decision: 'eliminated',
|
|
12
|
+
reason: 'not-emitted-after-analysis',
|
|
13
|
+
sourceBytes
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
const outputBytes = Buffer.byteLength(emitted.fileDescription.content);
|
|
17
|
+
if (entry.fileDescription.content !== emitted.fileDescription.content) {
|
|
18
|
+
return {
|
|
19
|
+
path: entry.fileDescription.inputFilePath,
|
|
20
|
+
decision: 'transformed',
|
|
21
|
+
reason: 'rewritten-after-analysis',
|
|
22
|
+
sourceBytes,
|
|
23
|
+
outputBytes
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
path: entry.fileDescription.inputFilePath,
|
|
28
|
+
decision: 'kept',
|
|
29
|
+
reason: 'reachable',
|
|
30
|
+
sourceBytes
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
export function maybeEmitElimination(broadcaster, originalBundles, analyzed) {
|
|
35
|
+
if (!broadcaster.hasSubscribers('eliminationCompleted')) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
broadcaster.emit('eliminationCompleted', {
|
|
39
|
+
perBundle: analyzed.map(function (bundle, index) {
|
|
40
|
+
const originalBundle = originalBundles[index];
|
|
41
|
+
if (originalBundle === undefined) {
|
|
42
|
+
throw new Error(`Original bundle missing for analyzed bundle "${bundle.name}"`);
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
packageName: bundle.name,
|
|
46
|
+
files: buildFileDecisions(originalBundle, bundle),
|
|
47
|
+
droppedSymbols: [],
|
|
48
|
+
seeds: []
|
|
49
|
+
};
|
|
50
|
+
})
|
|
51
|
+
});
|
|
52
|
+
}
|
|
1
53
|
//# sourceMappingURL=elimination-emitter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"elimination-emitter.js","sourceRoot":"","sources":["../../../../source/dead-code-eliminator/elimination-emitter.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"elimination-emitter.js","sourceRoot":"","sources":["../../../../source/dead-code-eliminator/elimination-emitter.ts"],"names":[],"mappings":"AAIA,SAAS,kBAAkB,CAAC,QAAsB,EAAE,QAAwB;IACxE,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAChC,QAAQ,CAAC,QAAQ,CAAC,G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,CAAC,IAAI,CAAC,sBAAsB,EAAE;QACrC,SAAS,EAAE,QAAQ,CAAC,GAAG,CAAC,UAAU,MAAM,EAAE,KAAK;YAC3C,MAAM,cAAc,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;YAC9C,IAAI,cAAc,KAAK,SAAS,EAAE,CAAC;gBAC/B,MAAM,IAAI,KAAK,CAAC,gDAAgD,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC;YACpF,CAAC;YACD,OAAO;gBACH,WAAW,EAAE,MAAM,CAAC,IAAI;gBACxB,KAAK,EAAE,kBAAkB,CAAC,cAAc,EAAE,MAAM,CAAC;gBACjD,cAAc,EAAE,EAAE;gBAClB,KAAK,EAAE,EAAE;aACZ,CAAC;QACN,CAAC,CAAC;KACL,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1,5 +1,23 @@
|
|
|
1
|
-
import "./bundle-analysis.js";
|
|
2
|
-
import "./cross-bundle/cross-bundle-seeds.js";
|
|
3
|
-
import "./elimination-emitter.js";
|
|
4
|
-
import "./load-bundle.js";
|
|
1
|
+
import { analyzeBundleWithSeeds, crossBundleInputFrom } from "./bundle-analysis.js";
|
|
2
|
+
import { buildCrossBundleSeeds } from "./cross-bundle/cross-bundle-seeds.js";
|
|
3
|
+
import { maybeEmitElimination } from "./elimination-emitter.js";
|
|
4
|
+
import { loadBundle } from "./load-bundle.js";
|
|
5
|
+
export function createDeadCodeEliminator(dependencies) {
|
|
6
|
+
const { createProject, progressBroadcaster, trace } = dependencies;
|
|
7
|
+
return {
|
|
8
|
+
async eliminate(inputs) {
|
|
9
|
+
const loadedBundles = inputs.map(function (input) {
|
|
10
|
+
return loadBundle(createProject, input, trace);
|
|
11
|
+
});
|
|
12
|
+
const seedMap = buildCrossBundleSeeds(loadedBundles.map(crossBundleInputFrom), trace);
|
|
13
|
+
const analyzed = loadedBundles.map(function (loaded) {
|
|
14
|
+
return analyzeBundleWithSeeds(loaded, seedMap.get(loaded.input.bundle.name), trace);
|
|
15
|
+
});
|
|
16
|
+
maybeEmitElimination(progressBroadcaster, inputs.map(function (input) {
|
|
17
|
+
return input.bundle;
|
|
18
|
+
}), analyzed);
|
|
19
|
+
return analyzed;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
5
23
|
//# sourceMappingURL=eliminator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eliminator.js","sourceRoot":"","sources":["../../../../source/dead-code-eliminator/eliminator.ts"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"eliminator.js","sourceRoot":"","sources":["../../../../source/dead-code-eliminator/eliminator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACpF,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,UAAU,EAAsB,MAAM,kBAAkB,CAAC;AASlE,MAAM,UAAU,wBAAwB,CAAC,YAA4C;IACjF,MAAM,EAAE,aAAa,EAAE,mBAAmB,EAAE,KAAK,EAAE,GAAG,YAAY,CAAC;IACnE,OAAO;QACH,KAAK,CAAC,SAAS,CAAC,MAAM;YAClB,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,KAAK;gBAC5C,OAAO,UAAU,CAAC,aAAa,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;YACnD,CAAC,CAAC,CAAC;YACH,MAAM,OAAO,GAAG,qBAAqB,CAAC,aAAa,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE,KAAK,CAAC,CAAC;YACtF,MAAM,QAAQ,GAAG,aAAa,CAAC,GAAG,CAAC,UAAU,MAAM;gBAC/C,OAAO,sBAAsB,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC;YACxF,CAAC,CAAC,CAAC;YACH,oBAAoB,CAChB,mBAAmB,EACnB,MAAM,CAAC,GAAG,CAAC,UAAU,KAAK;gBACtB,OAAO,KAAK,CAAC,MAAM,CAAC;YACxB,CAAC,CAAC,EACF,QAAQ,CACX,CAAC;YACF,OAAO,QAAQ,CAAC;QACpB,CAAC;KACJ,CAAC;AACN,CAAC"}
|
|
@@ -1,2 +1,17 @@
|
|
|
1
|
-
import 'ts-morph';
|
|
1
|
+
import { Node as TsMorphNode } from 'ts-morph';
|
|
2
|
+
function nextUnwrappedExpression(expression) {
|
|
3
|
+
if (TsMorphNode.isAsExpression(expression) || TsMorphNode.isSatisfiesExpression(expression)) {
|
|
4
|
+
return expression.getExpression();
|
|
5
|
+
}
|
|
6
|
+
if (TsMorphNode.isParenthesizedExpression(expression) ||
|
|
7
|
+
TsMorphNode.isTypeAssertion(expression) ||
|
|
8
|
+
TsMorphNode.isNonNullExpression(expression)) {
|
|
9
|
+
return expression.getExpression();
|
|
10
|
+
}
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
export function unwrapExpression(expression) {
|
|
14
|
+
const nextExpression = nextUnwrappedExpression(expression);
|
|
15
|
+
return nextExpression === undefined ? expression : unwrapExpression(nextExpression);
|
|
16
|
+
}
|
|
2
17
|
//# sourceMappingURL=expression-unwrapping.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expression-unwrapping.js","sourceRoot":"","sources":["../../../../source/dead-code-eliminator/expression-unwrapping.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"expression-unwrapping.js","sourceRoot":"","sources":["../../../../source/dead-code-eliminator/expression-unwrapping.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,WAAW,EAAmB,MAAM,UAAU,CAAC;AAEhE,SAAS,uBAAuB,CAAC,UAAkC;IAC/D,IAAI,WAAW,CAAC,cAAc,CAAC,UAAU,CAAC,IAAI,WAAW,CAAC,qBAAqB,CAAC,UAAU,CAAC,EAAE,CAAC;QAC1F,OAAO,UAAU,CAAC,aAAa,EAAE,CAAC;IACtC,CAAC;IACD,IACI,WAAW,CAAC,yBAAyB,CAAC,UAAU,CAAC;QACjD,WAAW,CAAC,eAAe,CAAC,UAAU,CAAC;QACvC,WAAW,CAAC,mBAAmB,CAAC,UAAU,CAAC,EAC7C,CAAC;QACC,OAAO,UAAU,CAAC,aAAa,EAAE,CAAC;IACtC,CAAC;IACD,OAAO,SAAS,CAAC;AACrB,CAAC;AAID,MAAM,UAAU,gBAAgB,CAAC,UAAkC;IAC/D,MAAM,cAAc,GAAG,uBAAuB,CAAC,UAAU,CAAC,CAAC;IAC3D,OAAO,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAC;AACxF,CAAC"}
|
|
@@ -1,4 +1,103 @@
|
|
|
1
|
-
import 'ts-morph';
|
|
2
|
-
import "./expression-unwrapping.js";
|
|
1
|
+
import { Node as TsMorphNode, SyntaxKind } from 'ts-morph';
|
|
2
|
+
import { unwrapExpression } from "./expression-unwrapping.js";
|
|
3
|
+
function importedOriginForDeclaration(declaration) {
|
|
4
|
+
if (TsMorphNode.isImportSpecifier(declaration)) {
|
|
5
|
+
return {
|
|
6
|
+
from: declaration.getImportDeclaration().getModuleSpecifierValue(),
|
|
7
|
+
path: [declaration.getName()]
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
if (TsMorphNode.isNamespaceImport(declaration)) {
|
|
11
|
+
const importDeclaration = declaration.getFirstAncestorByKindOrThrow(SyntaxKind.ImportDeclaration);
|
|
12
|
+
return {
|
|
13
|
+
from: importDeclaration.getModuleSpecifierValue(),
|
|
14
|
+
path: []
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
if (TsMorphNode.isImportClause(declaration)) {
|
|
18
|
+
const importDeclaration = declaration.getFirstAncestorByKindOrThrow(SyntaxKind.ImportDeclaration);
|
|
19
|
+
return {
|
|
20
|
+
from: importDeclaration.getModuleSpecifierValue(),
|
|
21
|
+
path: ['default']
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
function importedOriginForIdentifier(identifier) {
|
|
27
|
+
const symbol = identifier.getSymbol();
|
|
28
|
+
if (symbol === undefined) {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
for (const declaration of symbol.getDeclarations()) {
|
|
32
|
+
const origin = importedOriginForDeclaration(declaration);
|
|
33
|
+
if (origin !== undefined) {
|
|
34
|
+
return origin;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
function originMatchesTrustedImport(origin, trustedImport) {
|
|
40
|
+
if (trustedImport.from !== origin.from) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
if (trustedImport.imports === undefined) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
const [pathHead = trustedImport.from] = origin.path;
|
|
47
|
+
return pathHead !== trustedImport.from && trustedImport.imports.includes(pathHead);
|
|
48
|
+
}
|
|
49
|
+
function expressionOriginIsTrusted(origin, settings) {
|
|
50
|
+
const pureImports = settings?.pureImports;
|
|
51
|
+
if (origin === undefined || pureImports === undefined) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
return pureImports.some(function (trustedImport) {
|
|
55
|
+
return originMatchesTrustedImport(origin, trustedImport);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
function arePureCallArguments(callArguments, recurse) {
|
|
59
|
+
return callArguments.every(function (argument) {
|
|
60
|
+
if (TsMorphNode.isSpreadElement(argument)) {
|
|
61
|
+
return recurse(argument.getExpression());
|
|
62
|
+
}
|
|
63
|
+
return TsMorphNode.isExpression(argument) && recurse(argument);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
function appendPropertyAccess(base, propertyName) {
|
|
67
|
+
return base === undefined ? undefined : { from: base.from, path: [...base.path, propertyName] };
|
|
68
|
+
}
|
|
69
|
+
function originOfTrustedCall(callee, callArguments, recurse, settings) {
|
|
70
|
+
if (!expressionOriginIsTrusted(callee, settings)) {
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
return arePureCallArguments(callArguments, recurse) ? callee : undefined;
|
|
74
|
+
}
|
|
75
|
+
export function resolveImportedExpressionPath(expression) {
|
|
76
|
+
const identifier = unwrapExpression(expression).asKind(SyntaxKind.Identifier);
|
|
77
|
+
return identifier === undefined ? undefined : importedOriginForIdentifier(identifier);
|
|
78
|
+
}
|
|
79
|
+
function propertyAccessOrigin(expression, recurse, settings, resolveOrigin) {
|
|
80
|
+
if (!TsMorphNode.isPropertyAccessExpression(expression)) {
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
const base = resolveOrigin(expression.getExpression(), recurse, settings);
|
|
84
|
+
return appendPropertyAccess(base, expression.getName());
|
|
85
|
+
}
|
|
86
|
+
function trustedCallOrigin(expression, recurse, settings, resolveOrigin) {
|
|
87
|
+
if (!TsMorphNode.isCallExpression(expression)) {
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
const callee = resolveOrigin(expression.getExpression(), recurse, settings);
|
|
91
|
+
return originOfTrustedCall(callee, expression.getArguments(), recurse, settings);
|
|
92
|
+
}
|
|
93
|
+
export function resolveImportedExpressionOrigin(expression, recurse, settings) {
|
|
94
|
+
const unwrapped = unwrapExpression(expression);
|
|
95
|
+
const directOrigin = resolveImportedExpressionPath(unwrapped);
|
|
96
|
+
if (directOrigin !== undefined) {
|
|
97
|
+
return directOrigin;
|
|
98
|
+
}
|
|
99
|
+
return propertyAccessOrigin(unwrapped, recurse, settings, resolveImportedExpressionOrigin) ??
|
|
100
|
+
trustedCallOrigin(unwrapped, recurse, settings, resolveImportedExpressionOrigin);
|
|
101
|
+
}
|
|
3
102
|
export { arePureCallArguments };
|
|
4
103
|
//# sourceMappingURL=imported-expression-origin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imported-expression-origin.js","sourceRoot":"","sources":["../../../../source/dead-code-eliminator/imported-expression-origin.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"imported-expression-origin.js","sourceRoot":"","sources":["../../../../source/dead-code-eliminator/imported-expression-origin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,WAAW,EAAE,UAAU,EAAoC,MAAM,UAAU,CAAC;AAE7F,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAoB9D,SAAS,4BAA4B,CAAC,WAAwB;IAC1D,IAAI,WAAW,CAAC,iBAAiB,CAAC,WAAW,CAAC,EAAE,CAAC;QAC7C,OAAO;YACH,IAAI,EAAE,WAAW,CAAC,oBAAoB,EAAE,CAAC,uBAAuB,EAAE;YAClE,IAAI,EAAE,CAAE,WAAW,CAAC,OAAO,EAAE,CAAE;SAClC,CAAC;IACN,CAAC;IAED,IAAI,WAAW,CAAC,iBAAiB,CAAC,WAAW,CAAC,EAAE,CAAC;QAC7C,MAAM,iBAAiB,GAAG,WAAW,CAAC,6BAA6B,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC;QAClG,OAAO;YACH,IAAI,EAAE,iBAAiB,CAAC,uBAAuB,EAAE;YACjD,IAAI,EAAE,EAAE;SACX,CAAC;IACN,CAAC;IAED,IAAI,WAAW,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,CAAC;QAC1C,MAAM,iBAAiB,GAAG,WAAW,CAAC,6BAA6B,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC;QAClG,OAAO;YACH,IAAI,EAAE,iBAAiB,CAAC,uBAAuB,EAAE;YACjD,IAAI,EAAE,CAAE,SAAS,CAAE;SACtB,CAAC;IACN,CAAC;IAED,OAAO,SAAS,CAAC;AACrB,CAAC;AAED,SAAS,2BAA2B,CAAC,UAAsB;IACv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,SAAS,CAAC;IACrB,CAAC;IACD,MAAM,IAAI,GAAG,aAAa,CAAC,UAAU,CAAC,aAAa,EAAE,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC1E,OAAO,oBAAoB,CAAC,IAAI,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC;AAC5D,CAAC;AAED,SAAS,iBAAiB,CACtB,UAAsB,EACtB,OAAgC,EAChC,QAAiD,EACjD,aAA+C;IAE/C,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,UAAU,CAAC,EAAE,CAAC;QAC5C,OAAO,SAAS,CAAC;IACrB,CAAC;IACD,MAAM,MAAM,GAAG,aAAa,CAAC,UAAU,CAAC,aAAa,EAAE,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC5E,OAAO,mBAAmB,CAAC,MAAM,EAAE,UAAU,CAAC,YAAY,EAAE,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;AACrF,CAAC;AAED,MAAM,UAAU,+BAA+B,CAC3C,UAAsB,EACtB,OAAgC,EAChC,QAAiD;IAEjD,MAAM,SAAS,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;IAC/C,MAAM,YAAY,GAAG,6BAA6B,CAAC,SAAS,CAAC,CAAC;IAC9D,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;QAC7B,OAAO,YAAY,CAAC;IACxB,CAAC;IACD,OAAO,oBAAoB,CAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,+BAA+B,CAAC;QACtF,iBAAiB,CAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,+BAA+B,CAAC,CAAC;AACzF,CAAC;AAED,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
|
|
@@ -1,2 +1,10 @@
|
|
|
1
|
-
import 'node:path';
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
const sideEffectAssetExtensions = new Set(['.css', '.less', '.sass', '.scss']);
|
|
3
|
+
export function sideEffectAssetImportKind(specifier) {
|
|
4
|
+
const extension = path.extname(specifier);
|
|
5
|
+
if (!sideEffectAssetExtensions.has(extension)) {
|
|
6
|
+
return undefined;
|
|
7
|
+
}
|
|
8
|
+
return `${extension.slice(1)} import`;
|
|
9
|
+
}
|
|
2
10
|
//# sourceMappingURL=asset-side-effects.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asset-side-effects.js","sourceRoot":"","sources":["../../../../../source/dead-code-eliminator/liveness/asset-side-effects.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"asset-side-effects.js","sourceRoot":"","sources":["../../../../../source/dead-code-eliminator/liveness/asset-side-effects.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,yBAAyB,GAAG,IAAI,GAAG,CAAC,CAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAE,CAAC,CAAC;AAEjF,MAAM,UAAU,yBAAyB,CAAC,SAAiB;IACvD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC1C,IAAI,CAAC,yBAAyB,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;QAC5C,OAAO,SAAS,CAAC;IACrB,CAAC;IACD,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AAC1C,CAAC"}
|
|
@@ -1,3 +1,99 @@
|
|
|
1
|
-
import 'ts-morph';
|
|
2
|
-
import "../expression-unwrapping.js";
|
|
1
|
+
import { Node as TsMorphNode, SyntaxKind, VariableDeclarationKind } from 'ts-morph';
|
|
2
|
+
import { unwrapExpression } from "../expression-unwrapping.js";
|
|
3
|
+
function andOperator(left, right) {
|
|
4
|
+
return left && right;
|
|
5
|
+
}
|
|
6
|
+
function orOperator(left, right) {
|
|
7
|
+
return left || right;
|
|
8
|
+
}
|
|
9
|
+
function equalOperator(left, right) {
|
|
10
|
+
return left === right;
|
|
11
|
+
}
|
|
12
|
+
function notEqualOperator(left, right) {
|
|
13
|
+
return left !== right;
|
|
14
|
+
}
|
|
15
|
+
function literalBooleanValue(expression) {
|
|
16
|
+
if (expression.getKind() === SyntaxKind.TrueKeyword) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
return expression.getKind() === SyntaxKind.FalseKeyword ? false : undefined;
|
|
20
|
+
}
|
|
21
|
+
function logicalBooleanOperatorValue(kind, left, right) {
|
|
22
|
+
if (kind === SyntaxKind.AmpersandAmpersandToken) {
|
|
23
|
+
return andOperator(left, right);
|
|
24
|
+
}
|
|
25
|
+
if (kind === SyntaxKind.BarBarToken) {
|
|
26
|
+
return orOperator(left, right);
|
|
27
|
+
}
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
function equalityBooleanOperatorValue(kind, left, right) {
|
|
31
|
+
if (kind === SyntaxKind.EqualsEqualsEqualsToken) {
|
|
32
|
+
return equalOperator(left, right);
|
|
33
|
+
}
|
|
34
|
+
if (kind === SyntaxKind.ExclamationEqualsEqualsToken) {
|
|
35
|
+
return notEqualOperator(left, right);
|
|
36
|
+
}
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
function binaryBooleanOperatorValue(kind, left, right) {
|
|
40
|
+
return logicalBooleanOperatorValue(kind, left, right) ?? equalityBooleanOperatorValue(kind, left, right);
|
|
41
|
+
}
|
|
42
|
+
function identifierBooleanValue(expression, facts) {
|
|
43
|
+
return TsMorphNode.isIdentifier(expression) ? facts.get(expression.getText()) : undefined;
|
|
44
|
+
}
|
|
45
|
+
function binaryBooleanValue(expression, facts, evaluate) {
|
|
46
|
+
if (!TsMorphNode.isBinaryExpression(expression)) {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
const binary = expression.asKindOrThrow(SyntaxKind.BinaryExpression);
|
|
50
|
+
const left = evaluate(binary.getLeft(), facts);
|
|
51
|
+
const right = evaluate(binary.getRight(), facts);
|
|
52
|
+
if (left === undefined || right === undefined) {
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
return binaryBooleanOperatorValue(binary.getOperatorToken().getKind(), left, right);
|
|
56
|
+
}
|
|
57
|
+
function prefixBooleanValue(expression, facts, evaluate) {
|
|
58
|
+
if (!TsMorphNode.isPrefixUnaryExpression(expression)) {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
const operand = evaluate(expression.getOperand(), facts);
|
|
62
|
+
return operand !== undefined && expression.getOperatorToken() === SyntaxKind.ExclamationToken
|
|
63
|
+
? !operand
|
|
64
|
+
: undefined;
|
|
65
|
+
}
|
|
66
|
+
export function booleanValue(expression, facts) {
|
|
67
|
+
const unwrapped = unwrapExpression(expression);
|
|
68
|
+
return literalBooleanValue(unwrapped) ??
|
|
69
|
+
identifierBooleanValue(unwrapped, facts) ??
|
|
70
|
+
prefixBooleanValue(unwrapped, facts, booleanValue) ??
|
|
71
|
+
binaryBooleanValue(unwrapped, facts, booleanValue);
|
|
72
|
+
}
|
|
73
|
+
function collectBooleanFact(declaration, facts) {
|
|
74
|
+
const nameNode = declaration.getNameNode();
|
|
75
|
+
const initializer = declaration.getInitializer();
|
|
76
|
+
if (initializer === undefined || !TsMorphNode.isIdentifier(nameNode)) {
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
const value = booleanValue(initializer, facts);
|
|
80
|
+
return value === undefined ? undefined : [nameNode.getText(), value];
|
|
81
|
+
}
|
|
82
|
+
function collectConstBooleanFacts(statement, facts) {
|
|
83
|
+
if (statement.getDeclarationKind() !== VariableDeclarationKind.Const) {
|
|
84
|
+
return facts;
|
|
85
|
+
}
|
|
86
|
+
const nextFacts = new Map(facts);
|
|
87
|
+
for (const declaration of statement.getDeclarations()) {
|
|
88
|
+
const fact = collectBooleanFact(declaration, nextFacts);
|
|
89
|
+
if (fact !== undefined) {
|
|
90
|
+
const [name, value] = fact;
|
|
91
|
+
nextFacts.set(name, value);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return nextFacts;
|
|
95
|
+
}
|
|
96
|
+
export function factsAfterStatement(statement, facts) {
|
|
97
|
+
return TsMorphNode.isVariableStatement(statement) ? collectConstBooleanFacts(statement, facts) : facts;
|
|
98
|
+
}
|
|
3
99
|
//# sourceMappingURL=boolean-facts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boolean-facts.js","sourceRoot":"","sources":["../../../../../source/dead-code-eliminator/liveness/boolean-facts.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"boolean-facts.js","sourceRoot":"","sources":["../../../../../source/dead-code-eliminator/liveness/boolean-facts.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,IAAI,IAAI,WAAW,EACnB,UAAU,EACV,uBAAuB,EAK1B,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAM/D,SAAS,WAAW,CAAC,IAAa,EAAE,KAAc;IAC9C,OAAO,IAAI,IAAI,KAAK,CAAC;AACzB,CAAC;AAED,SAAS,UAAU,CAAC,IAAa,EAAE,KAAc;IAC7C,OAAO,IAAI,IAAI,KAAK,CAAC;AACzB,CAAC;AAED,SAAS,aAAa,CAAC,IAAa,EAAE,KAAc;IAChD,OAAO,IAAI,KAAK,KAAK,CAAC;AAC1B,CAAC;AAED,SAAS,gBAAgB,CAAC,IAAa,EAAE,KAAc;IACnD,OAAO,IAAI,KAAK,KAAK,CAAC;AAC1B,CAAC;AAED,SAAS,mBAAmB,CAAC,UAAsB;IAC/C,IAAI,UAAU,CAAC,OAAO,EAAE,KAAK,UAAU,CAAC,WAAW,EAAE,CAAC;QAClD,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,OAAO,UAAU,CAAC,OAAO,EAAE,KAAK,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AAChF,CAAC;AAED,SAAS,2BAA2B,CAAC,IA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