@scriptc/compiler 0.4.8 → 0.4.9
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/ambient/node-fallback/buffer.d.ts +2 -0
- package/ambient/node-fallback/child_process.d.ts +9 -3
- package/ambient/node-fallback/dns-promises.d.ts +25 -0
- package/ambient/node-fallback/dns.d.ts +29 -0
- package/ambient/node-fallback/test.d.ts +7 -0
- package/ambient/scriptc-node-fallback.d.ts +145 -2
- package/ambient/scriptc-overrides.d.ts +22 -13
- package/dist/backend/build-cache.d.ts +1 -1
- package/dist/backend/build-cache.js +1 -1
- package/dist/backend/build-cache.js.map +1 -1
- package/dist/backend/cache-root.d.ts +7 -0
- package/dist/backend/cache-root.js +27 -0
- package/dist/backend/cache-root.js.map +1 -1
- package/dist/backend/executable-features.js +5 -1
- package/dist/backend/executable-features.js.map +1 -1
- package/dist/backend/link-plan.js +7 -1
- package/dist/backend/link-plan.js.map +1 -1
- package/dist/backend/llvm/bytes-loop-versions.d.ts +12 -1
- package/dist/backend/llvm/bytes-loop-versions.js +107 -30
- package/dist/backend/llvm/bytes-loop-versions.js.map +1 -1
- package/dist/backend/llvm/bytes-loop-versions.test.js +96 -0
- package/dist/backend/llvm/bytes-loop-versions.test.js.map +1 -1
- package/dist/backend/llvm/checked-value-lifetimes.js +1 -0
- package/dist/backend/llvm/checked-value-lifetimes.js.map +1 -1
- package/dist/backend/llvm/classes.d.ts +16 -5
- package/dist/backend/llvm/classes.js +34 -6
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/classes.test.js +21 -2
- package/dist/backend/llvm/classes.test.js.map +1 -1
- package/dist/backend/llvm/common.d.ts +9 -0
- package/dist/backend/llvm/common.js +9 -0
- package/dist/backend/llvm/common.js.map +1 -1
- package/dist/backend/llvm/cpu-dispatch.d.ts +36 -2
- package/dist/backend/llvm/cpu-dispatch.js +96 -2
- package/dist/backend/llvm/cpu-dispatch.js.map +1 -1
- package/dist/backend/llvm/dense-array-access.d.ts +5 -2
- package/dist/backend/llvm/dense-array-access.js +16 -12
- package/dist/backend/llvm/dense-array-access.js.map +1 -1
- package/dist/backend/llvm/dense-array-access.test.js +3 -1
- package/dist/backend/llvm/dense-array-access.test.js.map +1 -1
- package/dist/backend/llvm/dyn.d.ts +24 -0
- package/dist/backend/llvm/dyn.js +117 -3
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emit-function.js +6 -0
- package/dist/backend/llvm/emit-function.js.map +1 -1
- package/dist/backend/llvm/emit-journal.d.ts +1 -0
- package/dist/backend/llvm/emit-journal.js.map +1 -1
- package/dist/backend/llvm/emit-module.js +48 -5
- package/dist/backend/llvm/emit-module.js.map +1 -1
- package/dist/backend/llvm/emit-module.test.js +41 -0
- package/dist/backend/llvm/emit-module.test.js.map +1 -1
- package/dist/backend/llvm/emit-statements.js +11 -0
- package/dist/backend/llvm/emit-statements.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +87 -7
- package/dist/backend/llvm/emitter.js +136 -15
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/expr-async.js +28 -6
- package/dist/backend/llvm/expr-async.js.map +1 -1
- package/dist/backend/llvm/expr-containers.js +19 -5
- package/dist/backend/llvm/expr-containers.js.map +1 -1
- package/dist/backend/llvm/expr-dynamic.js +29 -1
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.js +104 -6
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/expr-records.js +15 -1
- package/dist/backend/llvm/expr-records.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.js +53 -5
- package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
- package/dist/backend/llvm/inline-arrays.js +1 -1
- package/dist/backend/llvm/inline-arrays.js.map +1 -1
- package/dist/backend/llvm/js-ic.js +126 -2
- package/dist/backend/llvm/js-ic.js.map +1 -1
- package/dist/backend/llvm/lanes.d.ts +38 -0
- package/dist/backend/llvm/lanes.js +778 -0
- package/dist/backend/llvm/lanes.js.map +1 -0
- package/dist/backend/llvm/lanes.test.d.ts +1 -0
- package/dist/backend/llvm/lanes.test.js +402 -0
- package/dist/backend/llvm/lanes.test.js.map +1 -0
- package/dist/backend/llvm/lib-dispatch.js +9 -4
- package/dist/backend/llvm/lib-dispatch.js.map +1 -1
- package/dist/backend/llvm/lib-network.js +20 -0
- package/dist/backend/llvm/lib-network.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +27 -0
- package/dist/backend/llvm/lib-shared.js.map +1 -1
- package/dist/backend/llvm/lib-test.js +11 -0
- package/dist/backend/llvm/lib-test.js.map +1 -1
- package/dist/backend/llvm/local-array-reads.js +2 -2
- package/dist/backend/llvm/local-array-reads.js.map +1 -1
- package/dist/backend/llvm/map-number-lookup.js +8 -2
- package/dist/backend/llvm/map-number-lookup.js.map +1 -1
- package/dist/backend/llvm/nullable-unions.js +5 -2
- package/dist/backend/llvm/nullable-unions.js.map +1 -1
- package/dist/backend/llvm/publish.d.ts +3 -0
- package/dist/backend/llvm/publish.js +2 -2
- package/dist/backend/llvm/publish.js.map +1 -1
- package/dist/backend/llvm/reference-writes.js +1 -0
- package/dist/backend/llvm/reference-writes.js.map +1 -1
- package/dist/backend/llvm/region-groups.js +43 -4
- package/dist/backend/llvm/region-groups.js.map +1 -1
- package/dist/backend/llvm/region-groups.test.js +79 -0
- package/dist/backend/llvm/region-groups.test.js.map +1 -1
- package/dist/backend/llvm/runtime-registries.test.js +32 -1
- package/dist/backend/llvm/runtime-registries.test.js.map +1 -1
- package/dist/backend/llvm/shapes.js +10 -1
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/string-reads.d.ts +1 -1
- package/dist/backend/llvm/string-reads.js +1 -1
- package/dist/backend/llvm/string-reads.js.map +1 -1
- package/dist/backend/llvm/unwind-abi.js +24 -2
- package/dist/backend/llvm/unwind-abi.js.map +1 -1
- package/dist/backend/llvm/unwind-abi.test.js +38 -0
- package/dist/backend/llvm/unwind-abi.test.js.map +1 -1
- package/dist/backend/llvm/walkers.d.ts +3 -0
- package/dist/backend/llvm/walkers.js +20 -2
- package/dist/backend/llvm/walkers.js.map +1 -1
- package/dist/backend/native/contracts.d.ts +15 -3
- package/dist/backend/native/executable.js +19 -5
- package/dist/backend/native/executable.js.map +1 -1
- package/dist/backend/native-codegen-core.d.ts +20 -0
- package/dist/backend/native-codegen-core.js +15 -0
- package/dist/backend/native-codegen-core.js.map +1 -1
- package/dist/backend/native-codegen.d.ts +5 -0
- package/dist/backend/native-codegen.js +62 -8
- package/dist/backend/native-codegen.js.map +1 -1
- package/dist/backend/native-codegen.test.js +48 -8
- package/dist/backend/native-codegen.test.js.map +1 -1
- package/dist/backend/native-link-info-core.d.ts +27 -3
- package/dist/backend/native-link-info-core.js.map +1 -1
- package/dist/backend/native-link-info.test.js +17 -1
- package/dist/backend/native-link-info.test.js.map +1 -1
- package/dist/backend/native-toolchain.d.ts +1 -1
- package/dist/backend/native-toolchain.js +1 -1
- package/dist/backend/native-toolchain.js.map +1 -1
- package/dist/backend/native-toolchain.test.js +14 -1
- package/dist/backend/native-toolchain.test.js.map +1 -1
- package/dist/backend/runtime-pack-core.d.ts +9 -3
- package/dist/backend/runtime-pack-core.js +6 -1
- package/dist/backend/runtime-pack-core.js.map +1 -1
- package/dist/backend/runtime-pack.test.js +32 -1
- package/dist/backend/runtime-pack.test.js.map +1 -1
- package/dist/backend/targets.d.ts +9 -1
- package/dist/backend/targets.js +11 -2
- package/dist/backend/targets.js.map +1 -1
- package/dist/backend/targets.test.js +6 -0
- package/dist/backend/targets.test.js.map +1 -1
- package/dist/cli/command.js +15 -1
- package/dist/cli/command.js.map +1 -1
- package/dist/cli/host.d.ts +6 -0
- package/dist/cli/mcp.d.ts +72 -0
- package/dist/cli/mcp.js +601 -0
- package/dist/cli/mcp.js.map +1 -0
- package/dist/cli/mcp.test.d.ts +1 -0
- package/dist/cli/mcp.test.js +380 -0
- package/dist/cli/mcp.test.js.map +1 -0
- package/dist/cli/output-options.d.ts +1 -0
- package/dist/cli/output-options.js +3 -0
- package/dist/cli/output-options.js.map +1 -1
- package/dist/cli/usage.d.ts +51 -1
- package/dist/cli/usage.js +709 -186
- package/dist/cli/usage.js.map +1 -1
- package/dist/compat/fetch-profile.js +9 -4
- package/dist/compat/fetch-profile.js.map +1 -1
- package/dist/compile-types.d.ts +17 -0
- package/dist/coverage/report.d.ts +5 -9
- package/dist/coverage/report.js.map +1 -1
- package/dist/executable/executable-cache.d.ts +17 -3
- package/dist/executable/executable-cache.js +17 -3
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/executable/prepare.js +87 -10
- package/dist/executable/prepare.js.map +1 -1
- package/dist/frontend/analysis.js +3 -2
- package/dist/frontend/analysis.js.map +1 -1
- package/dist/frontend/canon-map.js +13 -8
- package/dist/frontend/canon-map.js.map +1 -1
- package/dist/frontend/decl-projection.d.ts +18 -0
- package/dist/frontend/decl-projection.js +90 -22
- package/dist/frontend/decl-projection.js.map +1 -1
- package/dist/frontend/decl-projection.test.js +47 -1
- package/dist/frontend/decl-projection.test.js.map +1 -1
- package/dist/frontend/default-library.d.ts +10 -0
- package/dist/frontend/default-library.js +43 -0
- package/dist/frontend/default-library.js.map +1 -0
- package/dist/frontend/fork-target.js +54 -9
- package/dist/frontend/fork-target.js.map +1 -1
- package/dist/frontend/fork-target.test.js +82 -0
- package/dist/frontend/fork-target.test.js.map +1 -1
- package/dist/frontend/inferred-js-diagnostics.test.js +73 -0
- package/dist/frontend/inferred-js-diagnostics.test.js.map +1 -1
- package/dist/frontend/lowering/abstract-equality.d.ts +2 -1
- package/dist/frontend/lowering/abstract-equality.js +7 -1
- package/dist/frontend/lowering/abstract-equality.js.map +1 -1
- package/dist/frontend/lowering/array-values.js +2 -2
- package/dist/frontend/lowering/array-values.js.map +1 -1
- package/dist/frontend/lowering/assertion-members.js +52 -2
- package/dist/frontend/lowering/assertion-members.js.map +1 -1
- package/dist/frontend/lowering/builtin-namespaces.d.ts +5 -0
- package/dist/frontend/lowering/builtin-namespaces.js +19 -12
- package/dist/frontend/lowering/builtin-namespaces.js.map +1 -1
- package/dist/frontend/lowering/builtins/callable-aliases.js +42 -6
- package/dist/frontend/lowering/builtins/callable-aliases.js.map +1 -1
- package/dist/frontend/lowering/builtins/child-process.d.ts +12 -11
- package/dist/frontend/lowering/builtins/child-process.js +235 -38
- package/dist/frontend/lowering/builtins/child-process.js.map +1 -1
- package/dist/frontend/lowering/builtins/compression.d.ts +6 -1
- package/dist/frontend/lowering/builtins/compression.js +3 -3
- package/dist/frontend/lowering/builtins/compression.js.map +1 -1
- package/dist/frontend/lowering/builtins/constants.js +2 -2
- package/dist/frontend/lowering/builtins/constants.js.map +1 -1
- package/dist/frontend/lowering/builtins/crypto.d.ts +3 -1
- package/dist/frontend/lowering/builtins/crypto.js +9 -1
- package/dist/frontend/lowering/builtins/crypto.js.map +1 -1
- package/dist/frontend/lowering/builtins/dates.js +26 -6
- package/dist/frontend/lowering/builtins/dates.js.map +1 -1
- package/dist/frontend/lowering/builtins/environment.d.ts +13 -1
- package/dist/frontend/lowering/builtins/environment.js +15 -4
- package/dist/frontend/lowering/builtins/environment.js.map +1 -1
- package/dist/frontend/lowering/builtins/module-bindings.d.ts +33 -0
- package/dist/frontend/lowering/builtins/module-bindings.js +213 -11
- package/dist/frontend/lowering/builtins/module-bindings.js.map +1 -1
- package/dist/frontend/lowering/builtins/module-resolution.d.ts +9 -2
- package/dist/frontend/lowering/builtins/module-resolution.js +187 -19
- package/dist/frontend/lowering/builtins/module-resolution.js.map +1 -1
- package/dist/frontend/lowering/builtins/performance.js +1 -1
- package/dist/frontend/lowering/builtins/performance.js.map +1 -1
- package/dist/frontend/lowering/builtins/process.js +40 -2
- package/dist/frontend/lowering/builtins/process.js.map +1 -1
- package/dist/frontend/lowering/builtins/promises.js +33 -0
- package/dist/frontend/lowering/builtins/promises.js.map +1 -1
- package/dist/frontend/lowering/builtins/readline.d.ts +9 -5
- package/dist/frontend/lowering/builtins/readline.js +184 -75
- package/dist/frontend/lowering/builtins/readline.js.map +1 -1
- package/dist/frontend/lowering/builtins/url.d.ts +4 -0
- package/dist/frontend/lowering/builtins/url.js +6 -0
- package/dist/frontend/lowering/builtins/url.js.map +1 -1
- package/dist/frontend/lowering/call-arguments.js +15 -0
- package/dist/frontend/lowering/call-arguments.js.map +1 -1
- package/dist/frontend/lowering/callable-properties.d.ts +34 -0
- package/dist/frontend/lowering/callable-properties.js +210 -0
- package/dist/frontend/lowering/callable-properties.js.map +1 -0
- package/dist/frontend/lowering/cjs-inline-require.d.ts +16 -0
- package/dist/frontend/lowering/cjs-inline-require.js +105 -0
- package/dist/frontend/lowering/cjs-inline-require.js.map +1 -1
- package/dist/frontend/lowering/cjs-inline-require.test.d.ts +1 -0
- package/dist/frontend/lowering/cjs-inline-require.test.js +61 -0
- package/dist/frontend/lowering/cjs-inline-require.test.js.map +1 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.js +82 -2
- package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
- package/dist/frontend/lowering/class-protocols.d.ts +57 -4
- package/dist/frontend/lowering/class-protocols.js +597 -30
- package/dist/frontend/lowering/class-protocols.js.map +1 -1
- package/dist/frontend/lowering/class-unions.js +2 -2
- package/dist/frontend/lowering/class-unions.js.map +1 -1
- package/dist/frontend/lowering/coercions/function-adapters.d.ts +12 -0
- package/dist/frontend/lowering/coercions/function-adapters.js +62 -0
- package/dist/frontend/lowering/coercions/function-adapters.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural-plans.js +56 -1
- package/dist/frontend/lowering/coercions/structural-plans.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural.js +9 -4
- package/dist/frontend/lowering/coercions/structural.js.map +1 -1
- package/dist/frontend/lowering/collection-ingestion.d.ts +9 -0
- package/dist/frontend/lowering/collection-ingestion.js +115 -41
- package/dist/frontend/lowering/collection-ingestion.js.map +1 -1
- package/dist/frontend/lowering/containers/array-callbacks.js +16 -0
- package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
- package/dist/frontend/lowering/containers/bytes.js +66 -10
- package/dist/frontend/lowering/containers/bytes.js.map +1 -1
- package/dist/frontend/lowering/containers/collection-methods.js +61 -5
- package/dist/frontend/lowering/containers/collection-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/filter-predicates.js +11 -0
- package/dist/frontend/lowering/containers/filter-predicates.js.map +1 -1
- package/dist/frontend/lowering/containers/indexed-objects.d.ts +15 -0
- package/dist/frontend/lowering/containers/indexed-objects.js +213 -30
- package/dist/frontend/lowering/containers/indexed-objects.js.map +1 -1
- package/dist/frontend/lowering/error-name-order.d.ts +16 -0
- package/dist/frontend/lowering/error-name-order.js +61 -0
- package/dist/frontend/lowering/error-name-order.js.map +1 -1
- package/dist/frontend/lowering/expressions/asserted-receiver.d.ts +17 -0
- package/dist/frontend/lowering/expressions/asserted-receiver.js +123 -1
- package/dist/frontend/lowering/expressions/asserted-receiver.js.map +1 -1
- package/dist/frontend/lowering/expressions/binary.js +147 -20
- package/dist/frontend/lowering/expressions/binary.js.map +1 -1
- package/dist/frontend/lowering/expressions/element-access.js +63 -14
- package/dist/frontend/lowering/expressions/element-access.js.map +1 -1
- package/dist/frontend/lowering/expressions/erased-delete.d.ts +59 -0
- package/dist/frontend/lowering/expressions/erased-delete.js +247 -0
- package/dist/frontend/lowering/expressions/erased-delete.js.map +1 -0
- package/dist/frontend/lowering/expressions/hosted-narrowing.d.ts +10 -0
- package/dist/frontend/lowering/expressions/hosted-narrowing.js +48 -1
- package/dist/frontend/lowering/expressions/hosted-narrowing.js.map +1 -1
- package/dist/frontend/lowering/expressions/identifiers.js +20 -0
- package/dist/frontend/lowering/expressions/identifiers.js.map +1 -1
- package/dist/frontend/lowering/expressions/narrowing.d.ts +7 -2
- package/dist/frontend/lowering/expressions/narrowing.js +77 -45
- package/dist/frontend/lowering/expressions/narrowing.js.map +1 -1
- package/dist/frontend/lowering/expressions/object-literals.js +62 -19
- package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/optional-chains.js +19 -0
- package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
- package/dist/frontend/lowering/expressions/property-access.d.ts +7 -7
- package/dist/frontend/lowering/expressions/property-access.js +247 -48
- package/dist/frontend/lowering/expressions/property-access.js.map +1 -1
- package/dist/frontend/lowering/expressions/relational.d.ts +1 -0
- package/dist/frontend/lowering/expressions/relational.js +18 -8
- package/dist/frontend/lowering/expressions/relational.js.map +1 -1
- package/dist/frontend/lowering/expressions/union-fields.js +11 -5
- package/dist/frontend/lowering/expressions/union-fields.js.map +1 -1
- package/dist/frontend/lowering/expressions/updates.js +121 -11
- package/dist/frontend/lowering/expressions/updates.js.map +1 -1
- package/dist/frontend/lowering/function-context.d.ts +10 -0
- package/dist/frontend/lowering/function-context.js +36 -0
- package/dist/frontend/lowering/function-context.js.map +1 -1
- package/dist/frontend/lowering/function-returns.js +8 -8
- package/dist/frontend/lowering/function-returns.js.map +1 -1
- package/dist/frontend/lowering/handle-properties.d.ts +62 -3
- package/dist/frontend/lowering/handle-properties.js +674 -26
- package/dist/frontend/lowering/handle-properties.js.map +1 -1
- package/dist/frontend/lowering/handle-properties.test.js +95 -2
- package/dist/frontend/lowering/handle-properties.test.js.map +1 -1
- package/dist/frontend/lowering/lower-builtin-values.d.ts +12 -0
- package/dist/frontend/lowering/lower-builtin-values.js +44 -0
- package/dist/frontend/lowering/lower-builtin-values.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.js +328 -136
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.js +82 -17
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-event-emitter.js +113 -9
- package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
- package/dist/frontend/lowering/lower-expando.d.ts +13 -21
- package/dist/frontend/lowering/lower-expando.js +90 -126
- package/dist/frontend/lowering/lower-expando.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.js +2 -2
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-functions.js +65 -0
- package/dist/frontend/lowering/lower-functions.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.js +471 -0
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.js +36 -10
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-node-island.js +28 -0
- package/dist/frontend/lowering/lower-node-island.js.map +1 -1
- package/dist/frontend/lowering/lower-server.d.ts +53 -7
- package/dist/frontend/lowering/lower-server.js +213 -42
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stdlib.js +50 -7
- package/dist/frontend/lowering/lower-stdlib.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.d.ts +24 -0
- package/dist/frontend/lowering/lower-stmts.js +463 -220
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-stream.js +2 -2
- package/dist/frontend/lowering/lower-stream.js.map +1 -1
- package/dist/frontend/lowering/lower-test.js +71 -2
- package/dist/frontend/lowering/lower-test.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +81 -10
- package/dist/frontend/lowering/lowerer.js +319 -72
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/new-target.js +10 -2
- package/dist/frontend/lowering/new-target.js.map +1 -1
- package/dist/frontend/lowering/nullish-empty-pattern.js +3 -3
- package/dist/frontend/lowering/nullish-empty-pattern.js.map +1 -1
- package/dist/frontend/lowering/partial-assertions.js +30 -5
- package/dist/frontend/lowering/partial-assertions.js.map +1 -1
- package/dist/frontend/lowering/primitive-throws.js +91 -1
- package/dist/frontend/lowering/primitive-throws.js.map +1 -1
- package/dist/frontend/lowering/primitive-wrappers.d.ts +9 -0
- package/dist/frontend/lowering/primitive-wrappers.js +2 -2
- package/dist/frontend/lowering/primitive-wrappers.js.map +1 -1
- package/dist/frontend/lowering/promise-executor-adapter.js +5 -2
- package/dist/frontend/lowering/promise-executor-adapter.js.map +1 -1
- package/dist/frontend/lowering/record-links.js +7 -2
- package/dist/frontend/lowering/record-links.js.map +1 -1
- package/dist/frontend/lowering/surfaces.d.ts +4 -0
- package/dist/frontend/lowering/surfaces.js +118 -2
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/lowering/surfaces.test.d.ts +1 -0
- package/dist/frontend/lowering/surfaces.test.js +31 -0
- package/dist/frontend/lowering/surfaces.test.js.map +1 -0
- package/dist/frontend/mock-shapes.js +3 -3
- package/dist/frontend/mock-shapes.js.map +1 -1
- package/dist/frontend/npm-static-ladder.d.ts +21 -0
- package/dist/frontend/npm-static-ladder.js +2 -0
- package/dist/frontend/npm-static-ladder.js.map +1 -0
- package/dist/frontend/npm-static-ladder.test.d.ts +1 -0
- package/dist/frontend/npm-static-ladder.test.js +138 -0
- package/dist/frontend/npm-static-ladder.test.js.map +1 -0
- package/dist/frontend/npm-static-status.d.ts +15 -0
- package/dist/frontend/npm-static-status.js +2 -0
- package/dist/frontend/npm-static-status.js.map +1 -0
- package/dist/frontend/package-shims.js +1 -1
- package/dist/frontend/package-shims.js.map +1 -1
- package/dist/frontend/pipeline.d.ts +1 -1
- package/dist/frontend/pipeline.js +222 -25
- package/dist/frontend/pipeline.js.map +1 -1
- package/dist/frontend/program-analysis.d.ts +4 -0
- package/dist/frontend/program-analysis.js +6 -0
- package/dist/frontend/program-analysis.js.map +1 -1
- package/dist/frontend/program.js +258 -32
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/program.test.js +30 -0
- package/dist/frontend/program.test.js.map +1 -1
- package/dist/frontend/resolve.js +29 -5
- package/dist/frontend/resolve.js.map +1 -1
- package/dist/frontend/resolve.test.js +40 -0
- package/dist/frontend/resolve.test.js.map +1 -1
- package/dist/frontend/services.d.ts +8 -0
- package/dist/frontend/services.js +7 -0
- package/dist/frontend/services.js.map +1 -1
- package/dist/frontend/ts7/checker.d.ts +7 -0
- package/dist/frontend/ts7/checker.js +12 -0
- package/dist/frontend/ts7/checker.js.map +1 -1
- package/dist/frontend/ts7/checker.test.js +1 -0
- package/dist/frontend/ts7/checker.test.js.map +1 -1
- package/dist/frontend/ts7/program-host.d.ts +39 -2
- package/dist/frontend/ts7/program-host.js +62 -8
- package/dist/frontend/ts7/program-host.js.map +1 -1
- package/dist/frontend/ts7/program-host.test.js +33 -0
- package/dist/frontend/ts7/program-host.test.js.map +1 -1
- package/dist/frontend/ts7/session-cache.d.ts +5 -1
- package/dist/frontend/ts7/session-cache.js +7 -1
- package/dist/frontend/ts7/session-cache.js.map +1 -1
- package/dist/frontend/ts7/session-cache.test.js +37 -0
- package/dist/frontend/ts7/session-cache.test.js.map +1 -1
- package/dist/frontend/ts7/session.js +19 -1
- package/dist/frontend/ts7/session.js.map +1 -1
- package/dist/frontend/ts7/source-parser.d.ts +17 -2
- package/dist/frontend/ts7/source-parser.js +61 -2
- package/dist/frontend/ts7/source-parser.js.map +1 -1
- package/dist/frontend/ts7/source-parser.test.js +55 -2
- package/dist/frontend/ts7/source-parser.test.js.map +1 -1
- package/dist/frontend/tsc-codes.d.ts +3 -2
- package/dist/frontend/tsc-codes.js +129 -22
- package/dist/frontend/tsc-codes.js.map +1 -1
- package/dist/frontend/type-mapper.d.ts +5 -11
- package/dist/frontend/type-mapper.js +380 -70
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +67 -7
- package/dist/index.js.map +1 -1
- package/dist/ir/builtin-effects.js +29 -0
- package/dist/ir/builtin-effects.js.map +1 -1
- package/dist/ir/builtin-signatures.d.ts +1 -1
- package/dist/ir/builtin-signatures.js +72 -6
- package/dist/ir/builtin-signatures.js.map +1 -1
- package/dist/ir/codec.generated.d.ts +1 -1
- package/dist/ir/codec.generated.js +321 -263
- package/dist/ir/codec.generated.js.map +1 -1
- package/dist/ir/constant-length-clones.d.ts +26 -0
- package/dist/ir/constant-length-clones.js +589 -0
- package/dist/ir/constant-length-clones.js.map +1 -0
- package/dist/ir/constant-length-clones.test.d.ts +1 -0
- package/dist/ir/constant-length-clones.test.js +292 -0
- package/dist/ir/constant-length-clones.test.js.map +1 -0
- package/dist/ir/constant-tables.d.ts +10 -5
- package/dist/ir/constant-tables.js +83 -17
- package/dist/ir/constant-tables.js.map +1 -1
- package/dist/ir/constant-tables.test.js +58 -1
- package/dist/ir/constant-tables.test.js.map +1 -1
- package/dist/ir/fields.generated.js +5 -2
- package/dist/ir/fields.generated.js.map +1 -1
- package/dist/ir/function-references.js +2 -0
- package/dist/ir/function-references.js.map +1 -1
- package/dist/ir/function-references.test.js +13 -0
- package/dist/ir/function-references.test.js.map +1 -1
- package/dist/ir/integer-loops.js +1 -0
- package/dist/ir/integer-loops.js.map +1 -1
- package/dist/ir/integer-loops.test.js +16 -0
- package/dist/ir/integer-loops.test.js.map +1 -1
- package/dist/ir/ir.d.ts +50 -6
- package/dist/ir/ir.js +44 -2
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/ir.test.js +83 -1
- package/dist/ir/ir.test.js.map +1 -1
- package/dist/ir/js-groups.js +5 -1
- package/dist/ir/js-groups.js.map +1 -1
- package/dist/ir/js-ic.d.ts +20 -0
- package/dist/ir/js-ic.js +81 -4
- package/dist/ir/js-ic.js.map +1 -1
- package/dist/ir/js-ic.test.js +8 -1
- package/dist/ir/js-ic.test.js.map +1 -1
- package/dist/ir/lane-plans.d.ts +86 -0
- package/dist/ir/lane-plans.js +589 -0
- package/dist/ir/lane-plans.js.map +1 -0
- package/dist/ir/lane-plans.test.d.ts +1 -0
- package/dist/ir/lane-plans.test.js +549 -0
- package/dist/ir/lane-plans.test.js.map +1 -0
- package/dist/ir/runtime-features.d.ts +68 -10
- package/dist/ir/runtime-features.js +285 -17
- package/dist/ir/runtime-features.js.map +1 -1
- package/dist/ir/runtime-features.test.js +190 -1
- package/dist/ir/runtime-features.test.js.map +1 -1
- package/dist/ir/validate.js +61 -24
- package/dist/ir/validate.js.map +1 -1
- package/dist/native/cache.d.ts +5 -0
- package/dist/native/cache.js +23 -1
- package/dist/native/cache.js.map +1 -1
- package/dist/native/cache.test.js +29 -1
- package/dist/native/cache.test.js.map +1 -1
- package/dist/native/cli.js +4 -2
- package/dist/native/cli.js.map +1 -1
- package/dist/native/compiler.d.ts +11 -3
- package/dist/native/compiler.js +102 -16
- package/dist/native/compiler.js.map +1 -1
- package/dist/native/compiler.test.js +244 -2
- package/dist/native/compiler.test.js.map +1 -1
- package/dist/native/prepare.d.ts +14 -1
- package/dist/native/prepare.js +79 -29
- package/dist/native/prepare.js.map +1 -1
- package/dist/native/sanitizer.test.js +3 -0
- package/dist/native/sanitizer.test.js.map +1 -1
- package/dist/native/unchanged.d.ts +80 -0
- package/dist/native/unchanged.js +301 -0
- package/dist/native/unchanged.js.map +1 -0
- package/dist/native/unchanged.test.d.ts +1 -0
- package/dist/native/unchanged.test.js +249 -0
- package/dist/native/unchanged.test.js.map +1 -0
- package/dist/node-islands/boundary.d.ts +16 -0
- package/dist/node-islands/boundary.js +70 -7
- package/dist/node-islands/boundary.js.map +1 -1
- package/dist/node-islands/boundary.test.js +59 -14
- package/dist/node-islands/boundary.test.js.map +1 -1
- package/dist/node-islands/detect.js +203 -47
- package/dist/node-islands/detect.js.map +1 -1
- package/dist/node-islands/detect.test.js +45 -0
- package/dist/node-islands/detect.test.js.map +1 -1
- package/dist/node-islands/growth.js +4 -16
- package/dist/node-islands/growth.js.map +1 -1
- package/dist/node-islands/modules.d.ts +3 -0
- package/dist/node-islands/modules.js +143 -12
- package/dist/node-islands/modules.js.map +1 -1
- package/dist/node-islands/modules.test.js +125 -0
- package/dist/node-islands/modules.test.js.map +1 -1
- package/dist/node-islands/report.d.ts +1 -1
- package/dist/node-islands/report.js +2 -1
- package/dist/node-islands/report.js.map +1 -1
- package/package.json +20 -20
- package/shims/undici/core/request.ts +7 -1
- package/surface-manifest.json +380 -2
package/dist/frontend/program.js
CHANGED
|
@@ -60,6 +60,7 @@ import { clearWorkspacePackages, isRelativeSpecifier, isWorkspacePackageName, np
|
|
|
60
60
|
import { ADOPTED_OPTIONS, isJsSourceFileName, jsOpinion, jsTscCodeTriage, } from "./tsc-codes.js";
|
|
61
61
|
import { trackedFileExists, trackedReadFile, trackedRealpath } from "./input-tracker.js";
|
|
62
62
|
import { earlyErrorDiagnostics7 } from "./early-errors.js";
|
|
63
|
+
import { isBundledLibraryFile } from "./default-library.js";
|
|
63
64
|
import { forkTargetPaths } from "./fork-target.js";
|
|
64
65
|
import { workerTargetPaths } from "./worker-target.js";
|
|
65
66
|
import { erasedTypeOnlyImport, typeOnlyNamedImport, typeOnlyReachedFiles, } from "./type-only-imports.js";
|
|
@@ -424,7 +425,7 @@ function fallbackModuleRoots7(program, host) {
|
|
|
424
425
|
const path = tsgoPath(name);
|
|
425
426
|
if (held.has(path) || path === ambient || path === overrides)
|
|
426
427
|
continue;
|
|
427
|
-
if (
|
|
428
|
+
if (isBundledLibraryFile(program, name))
|
|
428
429
|
continue;
|
|
429
430
|
for (const file of fallbackModulesNamedIn(host.sourceText(name) ?? ""))
|
|
430
431
|
if (!held.has(file))
|
|
@@ -693,7 +694,18 @@ overlayer) {
|
|
|
693
694
|
: [nodeTypes]),
|
|
694
695
|
];
|
|
695
696
|
const programRoots = [...coreRoots];
|
|
696
|
-
|
|
697
|
+
// One project lineage for the whole load: the root-discovery passes and
|
|
698
|
+
// every rewrite update the same synthesized project, so the session
|
|
699
|
+
// carries every unchanged file's syntax tree into the next program.
|
|
700
|
+
const lineage = {};
|
|
701
|
+
let program;
|
|
702
|
+
try {
|
|
703
|
+
program = host.createProgram([...programRoots, overridesDtsPath()], options, false, lineage);
|
|
704
|
+
}
|
|
705
|
+
catch (error) {
|
|
706
|
+
host.releaseLineage(lineage);
|
|
707
|
+
throw error;
|
|
708
|
+
}
|
|
697
709
|
try {
|
|
698
710
|
for (let pass = 0; pass < 32; pass++) {
|
|
699
711
|
const candidates = [
|
|
@@ -706,10 +718,14 @@ overlayer) {
|
|
|
706
718
|
const extraRoots = candidates.filter((root, index) => !programRoots.includes(root) && candidates.indexOf(root) === index);
|
|
707
719
|
if (extraRoots.length === 0)
|
|
708
720
|
break;
|
|
709
|
-
program.dispose();
|
|
710
721
|
for (const root of extraRoots)
|
|
711
722
|
programRoots.push(root);
|
|
712
|
-
|
|
723
|
+
// Create before disposing: the session retains the unchanged files
|
|
724
|
+
// from the snapshot the new program replaces, and the server's
|
|
725
|
+
// change-tracking baseline for the shared project stays alive.
|
|
726
|
+
const previous = program;
|
|
727
|
+
program = host.createProgram([...programRoots, overridesDtsPath()], options, false, lineage);
|
|
728
|
+
previous.dispose();
|
|
713
729
|
if (pass === 31)
|
|
714
730
|
throw new Error("static program-root discovery did not converge");
|
|
715
731
|
}
|
|
@@ -720,12 +736,13 @@ overlayer) {
|
|
|
720
736
|
// program keeps the identical lib set: the slice would add globals to
|
|
721
737
|
// the checker's world for everyone.
|
|
722
738
|
if (programNamesTemporal7(program)) {
|
|
723
|
-
program.dispose();
|
|
724
739
|
options = {
|
|
725
740
|
...options,
|
|
726
741
|
lib: [...(options.lib ?? []), TEMPORAL_LIB],
|
|
727
742
|
};
|
|
728
|
-
|
|
743
|
+
const previous = program;
|
|
744
|
+
program = host.createProgram([...programRoots, overridesDtsPath()], options, false, lineage);
|
|
745
|
+
previous.dispose();
|
|
729
746
|
}
|
|
730
747
|
// JSX: the program above checks the files as written; the program the
|
|
731
748
|
// lowering compiles holds them with their JSX lowered.
|
|
@@ -744,11 +761,11 @@ overlayer) {
|
|
|
744
761
|
tscWorld = {
|
|
745
762
|
program: original,
|
|
746
763
|
diagnostics,
|
|
747
|
-
projectWorld: errors ? host.createProgram(programRoots, options) : null,
|
|
764
|
+
projectWorld: errors ? host.createProgram(programRoots, options, false, lineage) : null,
|
|
748
765
|
};
|
|
749
766
|
for (const [file, lowered] of jsx.sources)
|
|
750
767
|
host.addVirtualFile(file, lowered.text);
|
|
751
|
-
program = host.createProgram([...programRoots, overridesDtsPath()], options);
|
|
768
|
+
program = host.createProgram([...programRoots, overridesDtsPath()], options, false, lineage);
|
|
752
769
|
}
|
|
753
770
|
else if (projector !== undefined) {
|
|
754
771
|
// The declaration-typed boundary: user files typed from package
|
|
@@ -767,7 +784,7 @@ overlayer) {
|
|
|
767
784
|
host.addVirtualFile(file, text);
|
|
768
785
|
host.addVirtualFile(projection.declFile, projection.declText);
|
|
769
786
|
programRoots.push(projection.declFile);
|
|
770
|
-
program = host.createProgram([...programRoots, overridesDtsPath()], options);
|
|
787
|
+
program = host.createProgram([...programRoots, overridesDtsPath()], options, false, lineage);
|
|
771
788
|
// A rewrite the lowering world disagrees with (new errors) is
|
|
772
789
|
// dropped for that file: the file lowers as it would without it.
|
|
773
790
|
const dropped = [];
|
|
@@ -781,8 +798,10 @@ overlayer) {
|
|
|
781
798
|
}
|
|
782
799
|
}
|
|
783
800
|
if (dropped.length > 0) {
|
|
784
|
-
|
|
785
|
-
|
|
801
|
+
// Create before disposing (see the root-discovery loop).
|
|
802
|
+
const replacement = program;
|
|
803
|
+
program = host.createProgram([...programRoots, overridesDtsPath()], options, false, lineage);
|
|
804
|
+
replacement.dispose();
|
|
786
805
|
for (const file of dropped)
|
|
787
806
|
declBoundaryNotes.push(declBoundaryDroppedDiag(file));
|
|
788
807
|
}
|
|
@@ -834,7 +853,7 @@ overlayer) {
|
|
|
834
853
|
overlayOriginals.set(file, before.getSourceFile(file)?.text ?? null);
|
|
835
854
|
for (const [file, text] of overlay)
|
|
836
855
|
host.addVirtualFile(file, text);
|
|
837
|
-
program = host.createProgram([...programRoots, overridesDtsPath()], options);
|
|
856
|
+
program = host.createProgram([...programRoots, overridesDtsPath()], options, false, lineage);
|
|
838
857
|
if (tscWorld.program !== before)
|
|
839
858
|
before.dispose();
|
|
840
859
|
if (timeShapes)
|
|
@@ -865,7 +884,7 @@ overlayer) {
|
|
|
865
884
|
externalTypeSpecifiersByFile,
|
|
866
885
|
...(tscWorld === undefined ? {} : { jsxSources: jsx.sources }),
|
|
867
886
|
...(tscWorld === undefined ? {} : { tscWorld }),
|
|
868
|
-
projectWorld: () => (projectWorld ??= withFilesAsWritten(host, overlayOriginals, () => host.createProgram(programRoots, options))),
|
|
887
|
+
projectWorld: () => (projectWorld ??= withFilesAsWritten(host, overlayOriginals, () => host.createProgram(programRoots, options, false, lineage))),
|
|
869
888
|
disposeAll: () => {
|
|
870
889
|
try {
|
|
871
890
|
projectWorld?.dispose();
|
|
@@ -873,13 +892,19 @@ overlayer) {
|
|
|
873
892
|
tscWorld?.program.dispose();
|
|
874
893
|
}
|
|
875
894
|
finally {
|
|
876
|
-
|
|
895
|
+
try {
|
|
896
|
+
program.dispose();
|
|
897
|
+
}
|
|
898
|
+
finally {
|
|
899
|
+
host.releaseLineage(lineage);
|
|
900
|
+
}
|
|
877
901
|
}
|
|
878
902
|
},
|
|
879
903
|
};
|
|
880
904
|
}
|
|
881
905
|
catch (error) {
|
|
882
906
|
program.dispose();
|
|
907
|
+
host.releaseLineage(lineage);
|
|
883
908
|
throw error;
|
|
884
909
|
}
|
|
885
910
|
}
|
|
@@ -1265,7 +1290,7 @@ function jsOpinionOf7(p, d, projectCheckJs, syntacticOf) {
|
|
|
1265
1290
|
if (nodeFree)
|
|
1266
1291
|
return opinion;
|
|
1267
1292
|
const node = diagnosticNode7(sf, pos, end);
|
|
1268
|
-
if (opinion.site !== undefined && !opinion.site(node, d))
|
|
1293
|
+
if (opinion.site !== undefined && !opinion.site(node, d, p))
|
|
1269
1294
|
return null;
|
|
1270
1295
|
if (opinion.view === "island" && isStrictCode(node))
|
|
1271
1296
|
return null;
|
|
@@ -2389,14 +2414,19 @@ export function isCreateRequireBinding7(program, callee) {
|
|
|
2389
2414
|
* fence, and the resolve.paths value is a function that throws one when
|
|
2390
2415
|
* called (module-resolution.ts), so the statement's catch clause handles
|
|
2391
2416
|
* them (packages that look for optional native addons).
|
|
2392
|
-
* - "
|
|
2393
|
-
*
|
|
2394
|
-
*
|
|
2395
|
-
*
|
|
2417
|
+
* - "value": in JavaScript source, the loader itself as a value (stored,
|
|
2418
|
+
* passed, returned). It lowers to a run-time require function over the
|
|
2419
|
+
* runtime resolver. A package compiled statically cannot prove those
|
|
2420
|
+
* call sites, so npm-static refuses it (the "escaping" class there).
|
|
2421
|
+
* - "computed": the "runtime" and "value" uses in TypeScript source, and
|
|
2422
|
+
* the "deferred" shapes outside a try block.
|
|
2423
|
+
* - "escaping": writes, optional calls, and other members. */
|
|
2396
2424
|
const COMPUTED_CREATE_REQUIRE_REASON = "its createRequire result is used with a computed specifier in TypeScript, or with spread arguments or resolve.paths outside a try block (static requires need literal specifiers)";
|
|
2397
2425
|
function createRequireUse7(expr) {
|
|
2398
2426
|
const use = createRequireUseShape7(expr);
|
|
2399
|
-
return use === "runtime" && !isJsSourceFile(ts.getSourceFileOfNode(expr))
|
|
2427
|
+
return (use === "runtime" || use === "value") && !isJsSourceFile(ts.getSourceFileOfNode(expr))
|
|
2428
|
+
? "computed"
|
|
2429
|
+
: use;
|
|
2400
2430
|
}
|
|
2401
2431
|
function createRequireUseShape7(expr) {
|
|
2402
2432
|
let use = expr;
|
|
@@ -2430,14 +2460,39 @@ function createRequireUseShape7(expr) {
|
|
|
2430
2460
|
!(member && (args.length === 0 || args.length > 2)))
|
|
2431
2461
|
return "runtime";
|
|
2432
2462
|
}
|
|
2433
|
-
else if (
|
|
2463
|
+
else if (isJsWriteTarget7(use) || isAssignmentTarget7(use)) {
|
|
2464
|
+
// A write through any pattern container (destructuring assignment,
|
|
2465
|
+
// for-in/of head, ++/--): the binding's value changes under the
|
|
2466
|
+
// erased declaration, so the loader has no stable value to lower.
|
|
2434
2467
|
return "escaping";
|
|
2435
2468
|
}
|
|
2469
|
+
else if (!member) {
|
|
2470
|
+
// A member read other than resolve (including any optional chain and
|
|
2471
|
+
// element access) is not the loader itself: the run-time value form
|
|
2472
|
+
// is a function, not a lowered member surface.
|
|
2473
|
+
if ((ts.isPropertyAccessExpression(call) || ts.isElementAccessExpression(call)) &&
|
|
2474
|
+
call.expression === use)
|
|
2475
|
+
return "escaping";
|
|
2476
|
+
// The loader itself as a value (stored, passed, returned). JavaScript
|
|
2477
|
+
// source lowers it to a run-time require function over the runtime
|
|
2478
|
+
// resolver; TypeScript source keeps the refusal (createRequireUse7).
|
|
2479
|
+
return "value";
|
|
2480
|
+
}
|
|
2436
2481
|
else if (!paths) {
|
|
2437
2482
|
return "runtime";
|
|
2438
2483
|
}
|
|
2439
2484
|
return insideTryBlock7(use) ? "deferred" : "computed";
|
|
2440
2485
|
}
|
|
2486
|
+
/** True for the operand of a `typeof` expression (parentheses included).
|
|
2487
|
+
* A type probe reads no value out of the loader: npm-static admits it even
|
|
2488
|
+
* though the loader itself would otherwise be a value use. */
|
|
2489
|
+
function isTypeofOperand7(node) {
|
|
2490
|
+
let current = node;
|
|
2491
|
+
while (ts.isParenthesizedExpression(current.parent))
|
|
2492
|
+
current = current.parent;
|
|
2493
|
+
const parent = current.parent;
|
|
2494
|
+
return ts.isTypeOfExpression(parent) && parent.expression === current;
|
|
2495
|
+
}
|
|
2441
2496
|
function isAssignmentTarget7(node) {
|
|
2442
2497
|
const parent = node.parent;
|
|
2443
2498
|
return (ts.isBinaryExpression(parent) &&
|
|
@@ -2570,6 +2625,7 @@ function stableCreateRequireBindingReason7(program, decl) {
|
|
|
2570
2625
|
const sf = ts.getSourceFileOfNode(decl);
|
|
2571
2626
|
const refs = identifierOccurrences7(sf, decl.name.text);
|
|
2572
2627
|
checker.prefetchSymbolNodesExact(refs);
|
|
2628
|
+
let exported = false;
|
|
2573
2629
|
for (const ref of refs) {
|
|
2574
2630
|
if (ref === decl.name || inTypePosition7(ref))
|
|
2575
2631
|
continue;
|
|
@@ -2580,12 +2636,21 @@ function stableCreateRequireBindingReason7(program, decl) {
|
|
|
2580
2636
|
target = checker.getAliasedSymbol(target);
|
|
2581
2637
|
if (target !== symbol)
|
|
2582
2638
|
continue;
|
|
2639
|
+
if (isExportSpecifierReference7(ref)) {
|
|
2640
|
+
exported = true;
|
|
2641
|
+
continue;
|
|
2642
|
+
}
|
|
2583
2643
|
const use = createRequireUse7(ref);
|
|
2584
2644
|
if (use === "computed")
|
|
2585
2645
|
return COMPUTED_CREATE_REQUIRE_REASON;
|
|
2586
2646
|
if (use === "escaping")
|
|
2587
2647
|
return "its createRequire binding is reassigned or escapes";
|
|
2588
2648
|
}
|
|
2649
|
+
if (exported) {
|
|
2650
|
+
const reason = exportedCreateRequireUseReason7(program, symbol);
|
|
2651
|
+
if (reason !== null)
|
|
2652
|
+
return reason;
|
|
2653
|
+
}
|
|
2589
2654
|
const preceding = stmt.declarationList.declarations.nodes.slice(0, stmt.declarationList.declarations.nodes.indexOf(decl));
|
|
2590
2655
|
if (bindingEarlyUse7(program, sf, sf.statements.nodes.indexOf(stmt), decl, preceding) !== null) {
|
|
2591
2656
|
return "its createRequire binding can be used before initialization";
|
|
@@ -2596,8 +2661,78 @@ function stableCreateRequireBindingReason7(program, decl) {
|
|
|
2596
2661
|
cache.set(decl, reason);
|
|
2597
2662
|
return reason;
|
|
2598
2663
|
}
|
|
2664
|
+
/** True for the identifier in an export list that names a local binding
|
|
2665
|
+
* (`export { x }` or `export { x as y }`). The name is exported, not
|
|
2666
|
+
* read: an importing module resolves the same symbol. */
|
|
2667
|
+
function isExportSpecifierReference7(ref) {
|
|
2668
|
+
const parent = ref.parent;
|
|
2669
|
+
if (!ts.isExportSpecifier(parent))
|
|
2670
|
+
return false;
|
|
2671
|
+
return parent.propertyName === ref || (parent.propertyName === undefined && parent.name === ref);
|
|
2672
|
+
}
|
|
2673
|
+
/** An exported createRequire loader is alias plumbing when every module
|
|
2674
|
+
* that imports the name uses it the way the loader itself may be used (a
|
|
2675
|
+
* supported call or member read). The loader then still names no runtime
|
|
2676
|
+
* value; the call sites resolve against its declaring file. A module that
|
|
2677
|
+
* re-exports the name onward would need the same proof transitively, so
|
|
2678
|
+
* that stays refused. */
|
|
2679
|
+
function exportedCreateRequireUseReason7(program, symbol) {
|
|
2680
|
+
const checker = program.getTypeChecker();
|
|
2681
|
+
for (const sf of program.getSourceFiles()) {
|
|
2682
|
+
if (sf.isDeclarationFile)
|
|
2683
|
+
continue;
|
|
2684
|
+
const locals = [];
|
|
2685
|
+
ts.walkPreorder(sf, (node) => {
|
|
2686
|
+
if (!ts.isImportSpecifier(node))
|
|
2687
|
+
return;
|
|
2688
|
+
const local = checker.getSymbolAtLocation(node.name);
|
|
2689
|
+
if (local === undefined || (local.flags & ts.SymbolFlags.Alias) === 0)
|
|
2690
|
+
return;
|
|
2691
|
+
if (checker.getAliasedSymbol(local) === symbol)
|
|
2692
|
+
locals.push(local);
|
|
2693
|
+
});
|
|
2694
|
+
if (locals.length === 0)
|
|
2695
|
+
continue;
|
|
2696
|
+
let reason = null;
|
|
2697
|
+
ts.walkPreorder(sf, (node) => {
|
|
2698
|
+
if (reason !== null || !ts.isIdentifier(node))
|
|
2699
|
+
return;
|
|
2700
|
+
if (ts.isImportSpecifier(node.parent) && node.parent.name === node)
|
|
2701
|
+
return;
|
|
2702
|
+
if (inTypePosition7(node))
|
|
2703
|
+
return;
|
|
2704
|
+
const local = checker.getSymbolAtLocation(node);
|
|
2705
|
+
if (local === undefined || !locals.includes(local))
|
|
2706
|
+
return;
|
|
2707
|
+
if (isExportSpecifierReference7(node)) {
|
|
2708
|
+
reason = "its createRequire binding is re-exported through another module";
|
|
2709
|
+
return;
|
|
2710
|
+
}
|
|
2711
|
+
const use = createRequireUse7(node);
|
|
2712
|
+
if (use === "computed")
|
|
2713
|
+
reason = COMPUTED_CREATE_REQUIRE_REASON;
|
|
2714
|
+
else if (use === "escaping")
|
|
2715
|
+
reason = "its createRequire binding is reassigned or escapes";
|
|
2716
|
+
});
|
|
2717
|
+
if (reason !== null)
|
|
2718
|
+
return reason;
|
|
2719
|
+
}
|
|
2720
|
+
return null;
|
|
2721
|
+
}
|
|
2599
2722
|
function isCreateRequireBaseCall7(program, expr) {
|
|
2600
2723
|
const init = stripRequireCasts7(expr);
|
|
2724
|
+
// `createRequire ? createRequire(import.meta.url) : undefined`: the
|
|
2725
|
+
// import binding is always a function, so the true arm is the value.
|
|
2726
|
+
// Only that polarity folds: with the arms swapped the binding is
|
|
2727
|
+
// undefined at run time.
|
|
2728
|
+
if (ts.isConditionalExpression(init)) {
|
|
2729
|
+
const cond = stripRequireCasts7(init.condition);
|
|
2730
|
+
const other = stripRequireCasts7(init.whenFalse);
|
|
2731
|
+
return (ts.isIdentifier(cond) &&
|
|
2732
|
+
isCreateRequireImport7(program, cond) &&
|
|
2733
|
+
isUndefinedValue7(other) &&
|
|
2734
|
+
isCreateRequireBaseCall7(program, init.whenTrue));
|
|
2735
|
+
}
|
|
2601
2736
|
if (!ts.isCallExpression(init) ||
|
|
2602
2737
|
init.questionDotToken !== undefined ||
|
|
2603
2738
|
!ts.isIdentifier(init.expression) ||
|
|
@@ -2614,6 +2749,12 @@ function isCreateRequireBaseCall7(program, expr) {
|
|
|
2614
2749
|
base.expression.keywordToken === ts.SyntaxKind.ImportKeyword &&
|
|
2615
2750
|
(base.name.text === "url" || base.name.text === "filename"));
|
|
2616
2751
|
}
|
|
2752
|
+
/** `undefined` in either spelling: the identifier, or `void <expr>`. */
|
|
2753
|
+
function isUndefinedValue7(expr) {
|
|
2754
|
+
if (ts.isIdentifier(expr))
|
|
2755
|
+
return expr.text === "undefined";
|
|
2756
|
+
return ts.isVoidExpression(expr);
|
|
2757
|
+
}
|
|
2617
2758
|
/** Refuse require indirection the lowering cannot erase, while
|
|
2618
2759
|
* admitting literal calls through the same stable/inline shapes as program
|
|
2619
2760
|
* code. Inspect symbols, not names: nested shadows are unrelated bindings. */
|
|
@@ -2639,10 +2780,17 @@ function npmStaticModuleImportReason7(program, stmt) {
|
|
|
2639
2780
|
let reason = null;
|
|
2640
2781
|
const checkUse = (expr) => {
|
|
2641
2782
|
const use = createRequireUse7(expr);
|
|
2783
|
+
// A `typeof` probe observes the loader's type, never its call
|
|
2784
|
+
// sites: the erased binding stands in as a function value, which is
|
|
2785
|
+
// what the probe reads under Node too.
|
|
2642
2786
|
if (use === "computed")
|
|
2643
2787
|
reason = COMPUTED_CREATE_REQUIRE_REASON;
|
|
2644
2788
|
else if (use === "escaping")
|
|
2645
2789
|
reason = "its createRequire result escapes (static requires need literal specifiers)";
|
|
2790
|
+
else if (use === "value" && !isTypeofOperand7(expr))
|
|
2791
|
+
// The loader value form lowers to a run-time require: its call
|
|
2792
|
+
// sites are not the static edges this package compilation needs.
|
|
2793
|
+
reason = "its createRequire result escapes (static requires need literal specifiers)";
|
|
2646
2794
|
};
|
|
2647
2795
|
ts.walkPreorder(sf, (node) => {
|
|
2648
2796
|
if (reason ||
|
|
@@ -2652,16 +2800,45 @@ function npmStaticModuleImportReason7(program, stmt) {
|
|
|
2652
2800
|
checker.getSymbolAtLocation(node) !== imported)
|
|
2653
2801
|
return;
|
|
2654
2802
|
const call = node.parent;
|
|
2655
|
-
if (!ts.isCallExpression(call) ||
|
|
2656
|
-
|
|
2657
|
-
|
|
2803
|
+
if (!ts.isCallExpression(call) || call.expression !== node) {
|
|
2804
|
+
// A truthiness test of the import binding (`createRequire ? …
|
|
2805
|
+
// : undefined`) reads a value whose only possible truth is "the
|
|
2806
|
+
// import is a function", which the erased binding keeps: the
|
|
2807
|
+
// conditional's true arm owns the value.
|
|
2808
|
+
if (ts.isConditionalExpression(call) && call.condition === node) {
|
|
2809
|
+
// As a declaration's initializer the conditional must be the
|
|
2810
|
+
// supported fold; the erased binding has no value otherwise
|
|
2811
|
+
// (the reversed polarity reads `undefined` at run time).
|
|
2812
|
+
const parent = call.parent;
|
|
2813
|
+
if (ts.isVariableDeclaration(parent) &&
|
|
2814
|
+
parent.initializer === call &&
|
|
2815
|
+
!isCreateRequireBaseCall7(program, call)) {
|
|
2816
|
+
reason =
|
|
2817
|
+
"its createRequire conditional initializer is not a supported fold (the supported form is `createRequire ? createRequire(import.meta.url) : undefined`)";
|
|
2818
|
+
}
|
|
2819
|
+
return;
|
|
2820
|
+
}
|
|
2821
|
+
reason =
|
|
2822
|
+
"its createRequire import is used outside a supported call based on the current file";
|
|
2823
|
+
return;
|
|
2824
|
+
}
|
|
2825
|
+
if (!isCreateRequireBaseCall7(program, call)) {
|
|
2826
|
+
// A runtime base (`createRequire(from)`) anchors no build-time
|
|
2827
|
+
// resolution: the static package graph cannot resolve the
|
|
2828
|
+
// loader's call sites.
|
|
2658
2829
|
reason =
|
|
2659
2830
|
"its createRequire import is used outside a supported call based on the current file";
|
|
2660
2831
|
return;
|
|
2661
2832
|
}
|
|
2662
|
-
|
|
2833
|
+
// The supported conditional fold (`createRequire ? createRequire(...)
|
|
2834
|
+
// : undefined`) gives its value to the variable's declaration through
|
|
2835
|
+
// the conditional, not through the call directly.
|
|
2836
|
+
const handle = ts.isConditionalExpression(call.parent) && call.parent.whenTrue === call
|
|
2837
|
+
? call.parent
|
|
2838
|
+
: call;
|
|
2839
|
+
const decl = handle.parent;
|
|
2663
2840
|
if (ts.isVariableDeclaration(decl) &&
|
|
2664
|
-
decl.initializer ===
|
|
2841
|
+
decl.initializer === handle &&
|
|
2665
2842
|
ts.isIdentifier(decl.name)) {
|
|
2666
2843
|
if ((ts.getCombinedModifierFlags(decl) & ts.ModifierFlags.Export) !== 0) {
|
|
2667
2844
|
reason = "its createRequire result escapes through an exported binding";
|
|
@@ -2675,15 +2852,23 @@ function npmStaticModuleImportReason7(program, stmt) {
|
|
|
2675
2852
|
const name = decl.name.text;
|
|
2676
2853
|
checker.prefetchSymbolNodesExact(identifierOccurrences7(sf, name));
|
|
2677
2854
|
ts.walkPreorder(sf, (ref) => {
|
|
2678
|
-
if (ts.isIdentifier(ref)
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2855
|
+
if (!ts.isIdentifier(ref) || ref.text !== name || ref === decl.name)
|
|
2856
|
+
return;
|
|
2857
|
+
if (isExportSpecifierReference7(ref))
|
|
2858
|
+
return;
|
|
2859
|
+
// A shorthand `{ load }` reads the variable through its property
|
|
2860
|
+
// alias (the same resolution the stability proof uses).
|
|
2861
|
+
let target = ts.isShorthandPropertyAssignment(ref.parent)
|
|
2862
|
+
? checker.getShorthandAssignmentValueSymbol(ref.parent)
|
|
2863
|
+
: checker.getSymbolAtLocation(ref);
|
|
2864
|
+
if (target !== undefined && (target.flags & ts.SymbolFlags.Alias) !== 0)
|
|
2865
|
+
target = checker.getAliasedSymbol(target);
|
|
2866
|
+
if (target === sym)
|
|
2682
2867
|
checkUse(ref);
|
|
2683
2868
|
});
|
|
2684
2869
|
}
|
|
2685
2870
|
else {
|
|
2686
|
-
checkUse(
|
|
2871
|
+
checkUse(handle);
|
|
2687
2872
|
}
|
|
2688
2873
|
});
|
|
2689
2874
|
if (reason)
|
|
@@ -4973,6 +5158,15 @@ reportMiss = true) {
|
|
|
4973
5158
|
const resolved = resolveProjectModule(from.fileName, specifier);
|
|
4974
5159
|
if (resolved !== null)
|
|
4975
5160
|
return program.getSourceFile(resolved) ?? null;
|
|
5161
|
+
// A JSON document is data, not a package's module surface: Node reads it in
|
|
5162
|
+
// any module system, and a compiled package requires its own data files
|
|
5163
|
+
// (mime-db's db.json) whether or not the package ships declarations. The
|
|
5164
|
+
// document itself is the dependency.
|
|
5165
|
+
if (specifier.endsWith(".json")) {
|
|
5166
|
+
const json = resolveBareModule(from.fileName, specifier, "js-only", resolutionKind);
|
|
5167
|
+
if (json !== null && json.typesFile.endsWith(".json"))
|
|
5168
|
+
return program.getSourceFile(json.typesFile) ?? null;
|
|
5169
|
+
}
|
|
4976
5170
|
const npm = resolveNpmImport7(from.fileName, specifier, resolutionKind);
|
|
4977
5171
|
return npm && isNpmStaticPackage(npm.packageName)
|
|
4978
5172
|
? npmStaticProgramDep(program, npm.packageName, npm.typesFile, reportMiss)
|
|
@@ -5756,6 +5950,18 @@ function preflightStructure7(load) {
|
|
|
5756
5950
|
// require("util")` — util.types IS util/types).
|
|
5757
5951
|
const builtin = canonicalBuiltinModule(req.spec);
|
|
5758
5952
|
const plainElements = (pattern, module) => pattern.elements.nodes.every((e) => {
|
|
5953
|
+
// `const { a, ...rest } = require("./m")` of a program module:
|
|
5954
|
+
// the named bindings alias the module's exports and `rest`
|
|
5955
|
+
// reads the remaining export names through the same table, so
|
|
5956
|
+
// the whole pattern is alias plumbing (lower-stmts.ts).
|
|
5957
|
+
if (e.dotDotDotToken !== undefined &&
|
|
5958
|
+
e.initializer === undefined &&
|
|
5959
|
+
e.name !== undefined &&
|
|
5960
|
+
ts.isIdentifier(e.name) &&
|
|
5961
|
+
module === null &&
|
|
5962
|
+
builtin === null &&
|
|
5963
|
+
bindingKind !== "createRequire")
|
|
5964
|
+
return true;
|
|
5759
5965
|
if (e.initializer !== undefined || e.dotDotDotToken !== undefined)
|
|
5760
5966
|
return false;
|
|
5761
5967
|
if (e.name !== undefined && ts.isIdentifier(e.name))
|
|
@@ -5966,6 +6172,12 @@ function preflightStructure7(load) {
|
|
|
5966
6172
|
const inlineRequireCycleCalls = new Set();
|
|
5967
6173
|
const state = new Map();
|
|
5968
6174
|
const stack = [];
|
|
6175
|
+
// The stack depth at which each enclosing lazily-loaded subtree began.
|
|
6176
|
+
// The lazy require that entered the subtree lowers to its target's %init
|
|
6177
|
+
// at that call site, so the subtree initializes after its own requirer's
|
|
6178
|
+
// top level, not eagerly: the walk visits it here only to give its
|
|
6179
|
+
// modules a place in the emission order.
|
|
6180
|
+
const lazyBases = [];
|
|
5969
6181
|
const visit = (sf) => {
|
|
5970
6182
|
state.set(sf, "visiting");
|
|
5971
6183
|
stack.push(sf.fileName);
|
|
@@ -5982,6 +6194,17 @@ function preflightStructure7(load) {
|
|
|
5982
6194
|
inlineRequireCycleCalls.add(e.call);
|
|
5983
6195
|
continue;
|
|
5984
6196
|
}
|
|
6197
|
+
// A back edge into a module that was already evaluating when the
|
|
6198
|
+
// enclosing lazily-loaded subtree began is a Node cache hit at run
|
|
6199
|
+
// time: the subtree runs its init at the lazy require's call site,
|
|
6200
|
+
// after that module's requirer's top level completed. The walk's
|
|
6201
|
+
// eager visit of the subtree is only about emission order, so the
|
|
6202
|
+
// edge needs no admission analysis — the same trust the walk gives
|
|
6203
|
+
// a lazy edge whose target is still evaluating (skipped below) and
|
|
6204
|
+
// an inline require() call that closes a cycle.
|
|
6205
|
+
const lazyBase = lazyBases[lazyBases.length - 1];
|
|
6206
|
+
if (lazyBase !== undefined && stack.indexOf(e.dep.fileName) < lazyBase)
|
|
6207
|
+
continue;
|
|
5985
6208
|
// A back-edge: Node answers it from the cache (the module is
|
|
5986
6209
|
// already evaluating) — admitted by the cheap per-edge rule, the
|
|
5987
6210
|
// declaration-only init window rule, or the exact initialization
|
|
@@ -6002,8 +6225,11 @@ function preflightStructure7(load) {
|
|
|
6002
6225
|
// Lazy inline requires run after this module's top level: their
|
|
6003
6226
|
// modules join the order afterwards (cache hits when already loaded).
|
|
6004
6227
|
for (const e of edges.get(sf) ?? []) {
|
|
6005
|
-
if (e.lazy === true && state.get(e.dep) === undefined)
|
|
6228
|
+
if (e.lazy === true && state.get(e.dep) === undefined) {
|
|
6229
|
+
lazyBases.push(stack.length);
|
|
6006
6230
|
visit(e.dep);
|
|
6231
|
+
lazyBases.pop();
|
|
6232
|
+
}
|
|
6007
6233
|
}
|
|
6008
6234
|
};
|
|
6009
6235
|
visit(entry);
|