zod-compiler 1.23.0 → 1.23.2
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/README.md +9 -6
- package/dist/cli/commands/check.d.ts +10 -7
- package/dist/cli/commands/check.d.ts.map +1 -1
- package/dist/cli/commands/check.js +125 -148
- package/dist/cli/commands/check.js.map +1 -1
- package/dist/cli/commands/generate.d.ts +22 -19
- package/dist/cli/commands/generate.d.ts.map +1 -1
- package/dist/cli/commands/generate.js +102 -133
- package/dist/cli/commands/generate.js.map +1 -1
- package/dist/cli/commands/watch.d.ts +17 -15
- package/dist/cli/commands/watch.d.ts.map +1 -1
- package/dist/cli/commands/watch.js +126 -154
- package/dist/cli/commands/watch.js.map +1 -1
- package/dist/cli/emitter.d.ts +19 -16
- package/dist/cli/emitter.d.ts.map +1 -1
- package/dist/cli/emitter.js +55 -71
- package/dist/cli/emitter.js.map +1 -1
- package/dist/cli/errors.d.ts +4 -1
- package/dist/cli/errors.d.ts.map +1 -1
- package/dist/cli/errors.js +6 -2
- package/dist/cli/errors.js.map +1 -1
- package/dist/cli/index.d.ts +1 -3
- package/dist/cli/index.js +147 -160
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/logger.d.ts +18 -15
- package/dist/cli/logger.d.ts.map +1 -1
- package/dist/cli/logger.js +38 -37
- package/dist/cli/logger.js.map +1 -1
- package/dist/core/codegen/build-path.d.ts +7 -41
- package/dist/core/codegen/build-path.d.ts.map +1 -1
- package/dist/core/codegen/build-path.js +481 -570
- package/dist/core/codegen/build-path.js.map +1 -1
- package/dist/core/codegen/context.d.ts +256 -253
- package/dist/core/codegen/context.d.ts.map +1 -1
- package/dist/core/codegen/context.js +363 -437
- package/dist/core/codegen/context.js.map +1 -1
- package/dist/core/codegen/dedupe.d.ts +22 -56
- package/dist/core/codegen/dedupe.d.ts.map +1 -1
- package/dist/core/codegen/dedupe.js +150 -242
- package/dist/core/codegen/dedupe.js.map +1 -1
- package/dist/core/codegen/emit-issue.d.ts +44 -68
- package/dist/core/codegen/emit-issue.d.ts.map +1 -1
- package/dist/core/codegen/emit-issue.js +76 -108
- package/dist/core/codegen/emit-issue.js.map +1 -1
- package/dist/core/codegen/emit.d.ts +4 -1
- package/dist/core/codegen/emit.d.ts.map +1 -1
- package/dist/core/codegen/emit.js +16 -13
- package/dist/core/codegen/emit.js.map +1 -1
- package/dist/core/codegen/fast-path.d.ts +7 -12
- package/dist/core/codegen/fast-path.d.ts.map +1 -1
- package/dist/core/codegen/fast-path.js +116 -145
- package/dist/core/codegen/fast-path.js.map +1 -1
- package/dist/core/codegen/fast-size.d.ts +12 -26
- package/dist/core/codegen/fast-size.d.ts.map +1 -1
- package/dist/core/codegen/fast-size.js +169 -244
- package/dist/core/codegen/fast-size.js.map +1 -1
- package/dist/core/codegen/index.d.ts +25 -23
- package/dist/core/codegen/index.d.ts.map +1 -1
- package/dist/core/codegen/index.js +239 -405
- package/dist/core/codegen/index.js.map +1 -1
- package/dist/core/codegen/issue-decls.d.ts +15 -12
- package/dist/core/codegen/issue-decls.d.ts.map +1 -1
- package/dist/core/codegen/issue-decls.js +131 -162
- package/dist/core/codegen/issue-decls.js.map +1 -1
- package/dist/core/codegen/regex-unroll.d.ts +4 -1
- package/dist/core/codegen/regex-unroll.d.ts.map +1 -1
- package/dist/core/codegen/regex-unroll.js +173 -197
- package/dist/core/codegen/regex-unroll.js.map +1 -1
- package/dist/core/codegen/schemas/any.d.ts +7 -4
- package/dist/core/codegen/schemas/any.d.ts.map +1 -1
- package/dist/core/codegen/schemas/any.js +8 -4
- package/dist/core/codegen/schemas/any.js.map +1 -1
- package/dist/core/codegen/schemas/array.d.ts +8 -5
- package/dist/core/codegen/schemas/array.d.ts.map +1 -1
- package/dist/core/codegen/schemas/array.js +77 -95
- package/dist/core/codegen/schemas/array.js.map +1 -1
- package/dist/core/codegen/schemas/bigint.d.ts +7 -4
- package/dist/core/codegen/schemas/bigint.d.ts.map +1 -1
- package/dist/core/codegen/schemas/bigint.js +44 -56
- package/dist/core/codegen/schemas/bigint.js.map +1 -1
- package/dist/core/codegen/schemas/boolean.d.ts +7 -4
- package/dist/core/codegen/schemas/boolean.d.ts.map +1 -1
- package/dist/core/codegen/schemas/boolean.js +12 -11
- package/dist/core/codegen/schemas/boolean.js.map +1 -1
- package/dist/core/codegen/schemas/catch.d.ts +8 -5
- package/dist/core/codegen/schemas/catch.d.ts.map +1 -1
- package/dist/core/codegen/schemas/catch.js +23 -23
- package/dist/core/codegen/schemas/catch.js.map +1 -1
- package/dist/core/codegen/schemas/date.d.ts +7 -4
- package/dist/core/codegen/schemas/date.d.ts.map +1 -1
- package/dist/core/codegen/schemas/date.js +49 -68
- package/dist/core/codegen/schemas/date.js.map +1 -1
- package/dist/core/codegen/schemas/default.d.ts +9 -6
- package/dist/core/codegen/schemas/default.d.ts.map +1 -1
- package/dist/core/codegen/schemas/default.js +29 -27
- package/dist/core/codegen/schemas/default.js.map +1 -1
- package/dist/core/codegen/schemas/discriminated-union.d.ts +12 -10
- package/dist/core/codegen/schemas/discriminated-union.d.ts.map +1 -1
- package/dist/core/codegen/schemas/discriminated-union.js +153 -178
- package/dist/core/codegen/schemas/discriminated-union.js.map +1 -1
- package/dist/core/codegen/schemas/effect.d.ts +9 -6
- package/dist/core/codegen/schemas/effect.d.ts.map +1 -1
- package/dist/core/codegen/schemas/effect.js +54 -67
- package/dist/core/codegen/schemas/effect.js.map +1 -1
- package/dist/core/codegen/schemas/enum.d.ts +7 -4
- package/dist/core/codegen/schemas/enum.d.ts.map +1 -1
- package/dist/core/codegen/schemas/enum.js +15 -21
- package/dist/core/codegen/schemas/enum.js.map +1 -1
- package/dist/core/codegen/schemas/fallback.d.ts +6 -3
- package/dist/core/codegen/schemas/fallback.d.ts.map +1 -1
- package/dist/core/codegen/schemas/fallback.js +14 -13
- package/dist/core/codegen/schemas/fallback.js.map +1 -1
- package/dist/core/codegen/schemas/file.d.ts +7 -4
- package/dist/core/codegen/schemas/file.d.ts.map +1 -1
- package/dist/core/codegen/schemas/file.js +51 -57
- package/dist/core/codegen/schemas/file.js.map +1 -1
- package/dist/core/codegen/schemas/intersection.d.ts +8 -5
- package/dist/core/codegen/schemas/intersection.d.ts.map +1 -1
- package/dist/core/codegen/schemas/intersection.js +16 -13
- package/dist/core/codegen/schemas/intersection.js.map +1 -1
- package/dist/core/codegen/schemas/literal.d.ts +7 -4
- package/dist/core/codegen/schemas/literal.d.ts.map +1 -1
- package/dist/core/codegen/schemas/literal.js +20 -23
- package/dist/core/codegen/schemas/literal.js.map +1 -1
- package/dist/core/codegen/schemas/map.d.ts +8 -5
- package/dist/core/codegen/schemas/map.d.ts.map +1 -1
- package/dist/core/codegen/schemas/map.js +61 -67
- package/dist/core/codegen/schemas/map.js.map +1 -1
- package/dist/core/codegen/schemas/nan.d.ts +7 -4
- package/dist/core/codegen/schemas/nan.d.ts.map +1 -1
- package/dist/core/codegen/schemas/nan.js +8 -4
- package/dist/core/codegen/schemas/nan.js.map +1 -1
- package/dist/core/codegen/schemas/never.d.ts +7 -4
- package/dist/core/codegen/schemas/never.d.ts.map +1 -1
- package/dist/core/codegen/schemas/never.js +8 -4
- package/dist/core/codegen/schemas/never.js.map +1 -1
- package/dist/core/codegen/schemas/null.d.ts +7 -4
- package/dist/core/codegen/schemas/null.d.ts.map +1 -1
- package/dist/core/codegen/schemas/null.js +8 -4
- package/dist/core/codegen/schemas/null.js.map +1 -1
- package/dist/core/codegen/schemas/nullable.d.ts +8 -5
- package/dist/core/codegen/schemas/nullable.d.ts.map +1 -1
- package/dist/core/codegen/schemas/nullable.js +8 -5
- package/dist/core/codegen/schemas/nullable.js.map +1 -1
- package/dist/core/codegen/schemas/number.d.ts +7 -4
- package/dist/core/codegen/schemas/number.d.ts.map +1 -1
- package/dist/core/codegen/schemas/number.js +120 -176
- package/dist/core/codegen/schemas/number.js.map +1 -1
- package/dist/core/codegen/schemas/object.d.ts +8 -5
- package/dist/core/codegen/schemas/object.d.ts.map +1 -1
- package/dist/core/codegen/schemas/object.js +144 -231
- package/dist/core/codegen/schemas/object.js.map +1 -1
- package/dist/core/codegen/schemas/optional.d.ts +9 -6
- package/dist/core/codegen/schemas/optional.d.ts.map +1 -1
- package/dist/core/codegen/schemas/optional.js +23 -31
- package/dist/core/codegen/schemas/optional.js.map +1 -1
- package/dist/core/codegen/schemas/pipe.d.ts +8 -5
- package/dist/core/codegen/schemas/pipe.d.ts.map +1 -1
- package/dist/core/codegen/schemas/pipe.js +20 -27
- package/dist/core/codegen/schemas/pipe.js.map +1 -1
- package/dist/core/codegen/schemas/readonly.d.ts +8 -5
- package/dist/core/codegen/schemas/readonly.d.ts.map +1 -1
- package/dist/core/codegen/schemas/readonly.js +8 -5
- package/dist/core/codegen/schemas/readonly.js.map +1 -1
- package/dist/core/codegen/schemas/record.d.ts +8 -5
- package/dist/core/codegen/schemas/record.d.ts.map +1 -1
- package/dist/core/codegen/schemas/record.js +52 -65
- package/dist/core/codegen/schemas/record.js.map +1 -1
- package/dist/core/codegen/schemas/recursive-ref.d.ts +9 -6
- package/dist/core/codegen/schemas/recursive-ref.d.ts.map +1 -1
- package/dist/core/codegen/schemas/recursive-ref.js +44 -44
- package/dist/core/codegen/schemas/recursive-ref.js.map +1 -1
- package/dist/core/codegen/schemas/set.d.ts +8 -5
- package/dist/core/codegen/schemas/set.d.ts.map +1 -1
- package/dist/core/codegen/schemas/set.js +61 -73
- package/dist/core/codegen/schemas/set.js.map +1 -1
- package/dist/core/codegen/schemas/string-bool.d.ts +6 -3
- package/dist/core/codegen/schemas/string-bool.d.ts.map +1 -1
- package/dist/core/codegen/schemas/string-bool.js +22 -23
- package/dist/core/codegen/schemas/string-bool.js.map +1 -1
- package/dist/core/codegen/schemas/string.d.ts +8 -5
- package/dist/core/codegen/schemas/string.d.ts.map +1 -1
- package/dist/core/codegen/schemas/string.js +168 -207
- package/dist/core/codegen/schemas/string.js.map +1 -1
- package/dist/core/codegen/schemas/symbol.d.ts +7 -4
- package/dist/core/codegen/schemas/symbol.d.ts.map +1 -1
- package/dist/core/codegen/schemas/symbol.js +8 -4
- package/dist/core/codegen/schemas/symbol.js.map +1 -1
- package/dist/core/codegen/schemas/template-literal.d.ts +7 -4
- package/dist/core/codegen/schemas/template-literal.d.ts.map +1 -1
- package/dist/core/codegen/schemas/template-literal.js +12 -13
- package/dist/core/codegen/schemas/template-literal.js.map +1 -1
- package/dist/core/codegen/schemas/tuple.d.ts +8 -5
- package/dist/core/codegen/schemas/tuple.d.ts.map +1 -1
- package/dist/core/codegen/schemas/tuple.js +84 -94
- package/dist/core/codegen/schemas/tuple.js.map +1 -1
- package/dist/core/codegen/schemas/undefined.d.ts +7 -4
- package/dist/core/codegen/schemas/undefined.d.ts.map +1 -1
- package/dist/core/codegen/schemas/undefined.js +8 -4
- package/dist/core/codegen/schemas/undefined.js.map +1 -1
- package/dist/core/codegen/schemas/union.d.ts +8 -5
- package/dist/core/codegen/schemas/union.d.ts.map +1 -1
- package/dist/core/codegen/schemas/union.js +49 -69
- package/dist/core/codegen/schemas/union.js.map +1 -1
- package/dist/core/codegen/schemas/unknown.d.ts +7 -4
- package/dist/core/codegen/schemas/unknown.d.ts.map +1 -1
- package/dist/core/codegen/schemas/unknown.js +8 -4
- package/dist/core/codegen/schemas/unknown.js.map +1 -1
- package/dist/core/codegen/schemas/void.d.ts +7 -4
- package/dist/core/codegen/schemas/void.d.ts.map +1 -1
- package/dist/core/codegen/schemas/void.js +8 -4
- package/dist/core/codegen/schemas/void.js.map +1 -1
- package/dist/core/codegen/slow-path.d.ts +7 -4
- package/dist/core/codegen/slow-path.d.ts.map +1 -1
- package/dist/core/codegen/slow-path.js +71 -96
- package/dist/core/codegen/slow-path.js.map +1 -1
- package/dist/core/codegen/well-known-regex.d.ts +22 -19
- package/dist/core/codegen/well-known-regex.d.ts.map +1 -1
- package/dist/core/codegen/well-known-regex.js +127 -96
- package/dist/core/codegen/well-known-regex.js.map +1 -1
- package/dist/core/compile.d.ts +7 -4
- package/dist/core/compile.d.ts.map +1 -1
- package/dist/core/compile.js +48 -48
- package/dist/core/compile.js.map +1 -1
- package/dist/core/diagnostic.d.ts +38 -39
- package/dist/core/diagnostic.d.ts.map +1 -1
- package/dist/core/diagnostic.js +140 -164
- package/dist/core/diagnostic.js.map +1 -1
- package/dist/core/extract/checks.d.ts +18 -15
- package/dist/core/extract/checks.d.ts.map +1 -1
- package/dist/core/extract/checks.js +318 -311
- package/dist/core/extract/checks.js.map +1 -1
- package/dist/core/extract/effects.d.ts +13 -10
- package/dist/core/extract/effects.d.ts.map +1 -1
- package/dist/core/extract/effects.js +153 -222
- package/dist/core/extract/effects.js.map +1 -1
- package/dist/core/extract/extractors/any.d.ts +5 -2
- package/dist/core/extract/extractors/any.d.ts.map +1 -1
- package/dist/core/extract/extractors/any.js +5 -1
- package/dist/core/extract/extractors/any.js.map +1 -1
- package/dist/core/extract/extractors/array.d.ts +6 -3
- package/dist/core/extract/extractors/array.d.ts.map +1 -1
- package/dist/core/extract/extractors/array.js +25 -20
- package/dist/core/extract/extractors/array.js.map +1 -1
- package/dist/core/extract/extractors/bigint.d.ts +6 -3
- package/dist/core/extract/extractors/bigint.d.ts.map +1 -1
- package/dist/core/extract/extractors/bigint.js +66 -64
- package/dist/core/extract/extractors/bigint.js.map +1 -1
- package/dist/core/extract/extractors/boolean.d.ts +5 -2
- package/dist/core/extract/extractors/boolean.d.ts.map +1 -1
- package/dist/core/extract/extractors/boolean.js +7 -3
- package/dist/core/extract/extractors/boolean.js.map +1 -1
- package/dist/core/extract/extractors/catch.d.ts +6 -3
- package/dist/core/extract/extractors/catch.d.ts.map +1 -1
- package/dist/core/extract/extractors/catch.js +26 -17
- package/dist/core/extract/extractors/catch.js.map +1 -1
- package/dist/core/extract/extractors/date.d.ts +6 -3
- package/dist/core/extract/extractors/date.d.ts.map +1 -1
- package/dist/core/extract/extractors/date.js +42 -46
- package/dist/core/extract/extractors/date.js.map +1 -1
- package/dist/core/extract/extractors/default.d.ts +6 -3
- package/dist/core/extract/extractors/default.d.ts.map +1 -1
- package/dist/core/extract/extractors/default.js +20 -14
- package/dist/core/extract/extractors/default.js.map +1 -1
- package/dist/core/extract/extractors/enum.d.ts +5 -2
- package/dist/core/extract/extractors/enum.d.ts.map +1 -1
- package/dist/core/extract/extractors/enum.js +12 -13
- package/dist/core/extract/extractors/enum.js.map +1 -1
- package/dist/core/extract/extractors/file.d.ts +6 -3
- package/dist/core/extract/extractors/file.d.ts.map +1 -1
- package/dist/core/extract/extractors/file.js +34 -28
- package/dist/core/extract/extractors/file.js.map +1 -1
- package/dist/core/extract/extractors/intersection.d.ts +5 -2
- package/dist/core/extract/extractors/intersection.d.ts.map +1 -1
- package/dist/core/extract/extractors/intersection.js +13 -11
- package/dist/core/extract/extractors/intersection.js.map +1 -1
- package/dist/core/extract/extractors/lazy.d.ts +6 -3
- package/dist/core/extract/extractors/lazy.d.ts.map +1 -1
- package/dist/core/extract/extractors/lazy.js +21 -30
- package/dist/core/extract/extractors/lazy.js.map +1 -1
- package/dist/core/extract/extractors/literal.d.ts +5 -2
- package/dist/core/extract/extractors/literal.d.ts.map +1 -1
- package/dist/core/extract/extractors/literal.js +8 -1
- package/dist/core/extract/extractors/literal.js.map +1 -1
- package/dist/core/extract/extractors/map.d.ts +6 -3
- package/dist/core/extract/extractors/map.d.ts.map +1 -1
- package/dist/core/extract/extractors/map.js +10 -4
- package/dist/core/extract/extractors/map.js.map +1 -1
- package/dist/core/extract/extractors/nan.d.ts +5 -2
- package/dist/core/extract/extractors/nan.d.ts.map +1 -1
- package/dist/core/extract/extractors/nan.js +5 -1
- package/dist/core/extract/extractors/nan.js.map +1 -1
- package/dist/core/extract/extractors/never.d.ts +5 -2
- package/dist/core/extract/extractors/never.d.ts.map +1 -1
- package/dist/core/extract/extractors/never.js +5 -1
- package/dist/core/extract/extractors/never.js.map +1 -1
- package/dist/core/extract/extractors/null.d.ts +5 -2
- package/dist/core/extract/extractors/null.d.ts.map +1 -1
- package/dist/core/extract/extractors/null.js +5 -1
- package/dist/core/extract/extractors/null.js.map +1 -1
- package/dist/core/extract/extractors/nullable.d.ts +5 -2
- package/dist/core/extract/extractors/nullable.d.ts.map +1 -1
- package/dist/core/extract/extractors/nullable.js +7 -3
- package/dist/core/extract/extractors/nullable.js.map +1 -1
- package/dist/core/extract/extractors/number.d.ts +6 -3
- package/dist/core/extract/extractors/number.d.ts.map +1 -1
- package/dist/core/extract/extractors/number.js +35 -35
- package/dist/core/extract/extractors/number.js.map +1 -1
- package/dist/core/extract/extractors/object.d.ts +6 -3
- package/dist/core/extract/extractors/object.d.ts.map +1 -1
- package/dist/core/extract/extractors/object.js +49 -76
- package/dist/core/extract/extractors/object.js.map +1 -1
- package/dist/core/extract/extractors/optional.d.ts +5 -2
- package/dist/core/extract/extractors/optional.d.ts.map +1 -1
- package/dist/core/extract/extractors/optional.js +10 -12
- package/dist/core/extract/extractors/optional.js.map +1 -1
- package/dist/core/extract/extractors/pipe.d.ts +6 -3
- package/dist/core/extract/extractors/pipe.d.ts.map +1 -1
- package/dist/core/extract/extractors/pipe.js +40 -41
- package/dist/core/extract/extractors/pipe.js.map +1 -1
- package/dist/core/extract/extractors/readonly.d.ts +5 -2
- package/dist/core/extract/extractors/readonly.d.ts.map +1 -1
- package/dist/core/extract/extractors/readonly.js +10 -6
- package/dist/core/extract/extractors/readonly.js.map +1 -1
- package/dist/core/extract/extractors/record.d.ts +6 -3
- package/dist/core/extract/extractors/record.d.ts.map +1 -1
- package/dist/core/extract/extractors/record.js +24 -35
- package/dist/core/extract/extractors/record.js.map +1 -1
- package/dist/core/extract/extractors/set.d.ts +6 -3
- package/dist/core/extract/extractors/set.d.ts.map +1 -1
- package/dist/core/extract/extractors/set.js +36 -30
- package/dist/core/extract/extractors/set.js.map +1 -1
- package/dist/core/extract/extractors/string-bool.d.ts +7 -4
- package/dist/core/extract/extractors/string-bool.d.ts.map +1 -1
- package/dist/core/extract/extractors/string-bool.js +66 -84
- package/dist/core/extract/extractors/string-bool.js.map +1 -1
- package/dist/core/extract/extractors/string.d.ts +6 -3
- package/dist/core/extract/extractors/string.d.ts.map +1 -1
- package/dist/core/extract/extractors/string.js +34 -37
- package/dist/core/extract/extractors/string.js.map +1 -1
- package/dist/core/extract/extractors/symbol.d.ts +5 -2
- package/dist/core/extract/extractors/symbol.d.ts.map +1 -1
- package/dist/core/extract/extractors/symbol.js +5 -1
- package/dist/core/extract/extractors/symbol.js.map +1 -1
- package/dist/core/extract/extractors/template-literal.d.ts +6 -3
- package/dist/core/extract/extractors/template-literal.d.ts.map +1 -1
- package/dist/core/extract/extractors/template-literal.js +11 -6
- package/dist/core/extract/extractors/template-literal.js.map +1 -1
- package/dist/core/extract/extractors/tuple.d.ts +6 -3
- package/dist/core/extract/extractors/tuple.d.ts.map +1 -1
- package/dist/core/extract/extractors/tuple.js +10 -4
- package/dist/core/extract/extractors/tuple.js.map +1 -1
- package/dist/core/extract/extractors/undefined.d.ts +5 -2
- package/dist/core/extract/extractors/undefined.d.ts.map +1 -1
- package/dist/core/extract/extractors/undefined.js +5 -1
- package/dist/core/extract/extractors/undefined.js.map +1 -1
- package/dist/core/extract/extractors/union.d.ts +6 -3
- package/dist/core/extract/extractors/union.d.ts.map +1 -1
- package/dist/core/extract/extractors/union.js +38 -64
- package/dist/core/extract/extractors/union.js.map +1 -1
- package/dist/core/extract/extractors/unknown.d.ts +5 -2
- package/dist/core/extract/extractors/unknown.d.ts.map +1 -1
- package/dist/core/extract/extractors/unknown.js +5 -1
- package/dist/core/extract/extractors/unknown.js.map +1 -1
- package/dist/core/extract/extractors/void.d.ts +5 -2
- package/dist/core/extract/extractors/void.d.ts.map +1 -1
- package/dist/core/extract/extractors/void.js +5 -1
- package/dist/core/extract/extractors/void.js.map +1 -1
- package/dist/core/extract/fallback.d.ts +6 -3
- package/dist/core/extract/fallback.d.ts.map +1 -1
- package/dist/core/extract/fallback.js +21 -7
- package/dist/core/extract/fallback.js.map +1 -1
- package/dist/core/extract/index.d.ts +6 -4
- package/dist/core/extract/index.d.ts.map +1 -1
- package/dist/core/extract/index.js +15 -15
- package/dist/core/extract/index.js.map +1 -1
- package/dist/core/extract/registry.d.ts +39 -36
- package/dist/core/extract/registry.d.ts.map +1 -1
- package/dist/core/extract/registry.js +96 -123
- package/dist/core/extract/registry.js.map +1 -1
- package/dist/core/extract/types.d.ts +124 -120
- package/dist/core/extract/types.d.ts.map +1 -1
- package/dist/core/extract/types.js +0 -1
- package/dist/core/iife.d.ts +14 -15
- package/dist/core/iife.d.ts.map +1 -1
- package/dist/core/iife.js +182 -206
- package/dist/core/iife.js.map +1 -1
- package/dist/core/pipeline.d.ts +33 -30
- package/dist/core/pipeline.d.ts.map +1 -1
- package/dist/core/pipeline.js +67 -74
- package/dist/core/pipeline.js.map +1 -1
- package/dist/core/types.d.ts +430 -427
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js +0 -5
- package/dist/discovery.d.ts +8 -5
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +31 -32
- package/dist/discovery.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -2
- package/dist/jit.d.ts +15 -42
- package/dist/jit.d.ts.map +1 -1
- package/dist/jit.js +187 -216
- package/dist/jit.js.map +1 -1
- package/dist/loader.d.ts +14 -11
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +226 -258
- package/dist/loader.js.map +1 -1
- package/dist/static-filter.d.ts +4 -1
- package/dist/static-filter.d.ts.map +1 -1
- package/dist/static-filter.js +240 -367
- package/dist/static-filter.js.map +1 -1
- package/dist/swc.d.ts +38 -35
- package/dist/swc.d.ts.map +1 -1
- package/dist/swc.js +83 -76
- package/dist/swc.js.map +1 -1
- package/dist/unplugin/bun.d.ts +5 -2
- package/dist/unplugin/bun.d.ts.map +1 -1
- package/dist/unplugin/bun.js +5 -1
- package/dist/unplugin/bun.js.map +1 -1
- package/dist/unplugin/dep-graph.d.ts +10 -7
- package/dist/unplugin/dep-graph.d.ts.map +1 -1
- package/dist/unplugin/dep-graph.js +216 -252
- package/dist/unplugin/dep-graph.js.map +1 -1
- package/dist/unplugin/disk-cache.d.ts +121 -92
- package/dist/unplugin/disk-cache.d.ts.map +1 -1
- package/dist/unplugin/disk-cache.js +425 -444
- package/dist/unplugin/disk-cache.js.map +1 -1
- package/dist/unplugin/edits.d.ts +15 -12
- package/dist/unplugin/edits.d.ts.map +1 -1
- package/dist/unplugin/edits.js +24 -37
- package/dist/unplugin/edits.js.map +1 -1
- package/dist/unplugin/esbuild.d.ts +5 -2
- package/dist/unplugin/esbuild.d.ts.map +1 -1
- package/dist/unplugin/esbuild.js +5 -1
- package/dist/unplugin/esbuild.js.map +1 -1
- package/dist/unplugin/farm.d.ts +5 -2
- package/dist/unplugin/farm.d.ts.map +1 -1
- package/dist/unplugin/farm.js +5 -1
- package/dist/unplugin/farm.js.map +1 -1
- package/dist/unplugin/hoist-compile.d.ts +14 -42
- package/dist/unplugin/hoist-compile.d.ts.map +1 -1
- package/dist/unplugin/hoist-compile.js +67 -112
- package/dist/unplugin/hoist-compile.js.map +1 -1
- package/dist/unplugin/hoist.d.ts +56 -54
- package/dist/unplugin/hoist.d.ts.map +1 -1
- package/dist/unplugin/hoist.js +945 -1170
- package/dist/unplugin/hoist.js.map +1 -1
- package/dist/unplugin/index.d.ts +5 -3
- package/dist/unplugin/index.d.ts.map +1 -1
- package/dist/unplugin/index.js +175 -250
- package/dist/unplugin/index.js.map +1 -1
- package/dist/unplugin/rolldown.d.ts +5 -2
- package/dist/unplugin/rolldown.d.ts.map +1 -1
- package/dist/unplugin/rolldown.js +5 -1
- package/dist/unplugin/rolldown.js.map +1 -1
- package/dist/unplugin/rollup.d.ts +5 -2
- package/dist/unplugin/rollup.d.ts.map +1 -1
- package/dist/unplugin/rollup.js +5 -1
- package/dist/unplugin/rollup.js.map +1 -1
- package/dist/unplugin/rsbuild.d.ts +6 -3
- package/dist/unplugin/rsbuild.d.ts.map +1 -1
- package/dist/unplugin/rsbuild.js +15 -11
- package/dist/unplugin/rsbuild.js.map +1 -1
- package/dist/unplugin/rspack.d.ts +5 -2
- package/dist/unplugin/rspack.d.ts.map +1 -1
- package/dist/unplugin/rspack.js +5 -1
- package/dist/unplugin/rspack.js.map +1 -1
- package/dist/unplugin/transform.d.ts +30 -27
- package/dist/unplugin/transform.d.ts.map +1 -1
- package/dist/unplugin/transform.js +433 -620
- package/dist/unplugin/transform.js.map +1 -1
- package/dist/unplugin/types.d.ts +189 -184
- package/dist/unplugin/types.d.ts.map +1 -1
- package/dist/unplugin/types.js +22 -18
- package/dist/unplugin/types.js.map +1 -1
- package/dist/unplugin/virtual.d.ts +11 -8
- package/dist/unplugin/virtual.d.ts.map +1 -1
- package/dist/unplugin/virtual.js +65 -83
- package/dist/unplugin/virtual.js.map +1 -1
- package/dist/unplugin/vite.d.ts +5 -2
- package/dist/unplugin/vite.d.ts.map +1 -1
- package/dist/unplugin/vite.js +5 -1
- package/dist/unplugin/vite.js.map +1 -1
- package/dist/unplugin/webpack.d.ts +5 -2
- package/dist/unplugin/webpack.d.ts.map +1 -1
- package/dist/unplugin/webpack.js +5 -1
- package/dist/unplugin/webpack.js.map +1 -1
- package/package.json +23 -14
- package/dist/cli/index.d.ts.map +0 -1
- package/dist/core/extract/types.js.map +0 -1
- package/dist/core/types.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
|
@@ -1,289 +1,253 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Static per-file dependency graphs for disk-cache invalidation.
|
|
3
|
-
*
|
|
4
|
-
* The disk cache used to record `getFirstPartyModulePaths()` — the superset
|
|
5
|
-
* of EVERY first-party module the loader had executed so far — as each
|
|
6
|
-
* entry's dependency set. Supersets never serve stale results, but in a
|
|
7
|
-
* large codebase every entry ends up recording the whole project (~1,900
|
|
8
|
-
* deps, ~400KB JSON per entry in the field report), so ANY commit
|
|
9
|
-
* invalidates essentially the entire cache and CI re-pays full discovery
|
|
10
|
-
* every run.
|
|
11
|
-
*
|
|
12
|
-
* This module computes the file's ACTUAL import graph statically: scan
|
|
13
|
-
* import/export/require specifiers, resolve them (relative paths with
|
|
14
|
-
* extension probing, tsconfig path aliases via the loader's config, bare
|
|
15
|
-
* specifiers through node resolution), and BFS across first-party files.
|
|
16
|
-
* No file is executed. Type-only imports are included (over-approximation
|
|
17
|
-
* only over-invalidates).
|
|
18
|
-
*
|
|
19
|
-
* Soundness rule: when anything cannot be analyzed — a non-literal dynamic
|
|
20
|
-
* import, an unresolvable relative specifier — the crawl reports
|
|
21
|
-
* `complete: false` and the caller falls back to the superset. A static
|
|
22
|
-
* crawl may only replace the superset when it provably covers everything
|
|
23
|
-
* the file can load.
|
|
24
|
-
*
|
|
25
|
-
* Cost discipline (this runs serialized on the bundler's main process, once
|
|
26
|
-
* per discovery file, over closures that reach thousands of files):
|
|
27
|
-
* - every existence probe uses `statSync(p, { throwIfNoEntry: false })` —
|
|
28
|
-
* a thrown ENOENT pays V8 error-plus-stack construction, and a cold crawl
|
|
29
|
-
* issues these probes by the million (the dominant cost in field samples);
|
|
30
|
-
* - resolution is memoized at every level: realpath per path, createRequire
|
|
31
|
-
* per directory, resolved specifier per (directory, specifier), and the
|
|
32
|
-
* full edge list per file (mtime-validated) — repeat crawls over the
|
|
33
|
-
* shared core graph are Map lookups plus one cheap stat per file;
|
|
34
|
-
* - the BFS aborts the moment the graph becomes unanalyzable: the caller
|
|
35
|
-
* discards an incomplete result for the superset anyway, so finishing the
|
|
36
|
-
* crawl would be pure waste (and incomplete is the COMMON outcome on
|
|
37
|
-
* large graphs — one dynamic import anywhere poisons the whole closure).
|
|
38
|
-
*/
|
|
39
|
-
import * as fs from "node:fs";
|
|
40
|
-
import { createRequire } from "node:module";
|
|
41
|
-
import * as path from "node:path";
|
|
42
1
|
import { resolveTsconfigPathCandidates } from "../loader.js";
|
|
43
|
-
|
|
44
|
-
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import * as path$1 from "node:path";
|
|
4
|
+
import * as fs$1 from "node:fs";
|
|
5
|
+
//#region src/unplugin/dep-graph.ts
|
|
6
|
+
/**
|
|
7
|
+
* Static per-file dependency graphs for disk-cache invalidation.
|
|
8
|
+
*
|
|
9
|
+
* The disk cache used to record `getFirstPartyModulePaths()` — the superset
|
|
10
|
+
* of EVERY first-party module the loader had executed so far — as each
|
|
11
|
+
* entry's dependency set. Supersets never serve stale results, but in a
|
|
12
|
+
* large codebase every entry ends up recording the whole project (~1,900
|
|
13
|
+
* deps, ~400KB JSON per entry in the field report), so ANY commit
|
|
14
|
+
* invalidates essentially the entire cache and CI re-pays full discovery
|
|
15
|
+
* every run.
|
|
16
|
+
*
|
|
17
|
+
* This module computes the file's ACTUAL import graph statically: scan
|
|
18
|
+
* import/export/require specifiers, resolve them (relative paths with
|
|
19
|
+
* extension probing, tsconfig path aliases via the loader's config, bare
|
|
20
|
+
* specifiers through node resolution), and BFS across first-party files.
|
|
21
|
+
* No file is executed. Type-only imports are included (over-approximation
|
|
22
|
+
* only over-invalidates).
|
|
23
|
+
*
|
|
24
|
+
* Soundness rule: when anything cannot be analyzed — a non-literal dynamic
|
|
25
|
+
* import, an unresolvable relative specifier — the crawl reports
|
|
26
|
+
* `complete: false` and the caller falls back to the superset. A static
|
|
27
|
+
* crawl may only replace the superset when it provably covers everything
|
|
28
|
+
* the file can load.
|
|
29
|
+
*
|
|
30
|
+
* Cost discipline (this runs serialized on the bundler's main process, once
|
|
31
|
+
* per discovery file, over closures that reach thousands of files):
|
|
32
|
+
* - every existence probe uses `statSync(p, { throwIfNoEntry: false })` —
|
|
33
|
+
* a thrown ENOENT pays V8 error-plus-stack construction, and a cold crawl
|
|
34
|
+
* issues these probes by the million (the dominant cost in field samples);
|
|
35
|
+
* - resolution is memoized at every level: realpath per path, createRequire
|
|
36
|
+
* per directory, resolved specifier per (directory, specifier), and the
|
|
37
|
+
* full edge list per file (mtime-validated) — repeat crawls over the
|
|
38
|
+
* shared core graph are Map lookups plus one cheap stat per file;
|
|
39
|
+
* - the BFS aborts the moment the graph becomes unanalyzable: the caller
|
|
40
|
+
* discards an incomplete result for the superset anyway, so finishing the
|
|
41
|
+
* crawl would be pure waste (and incomplete is the COMMON outcome on
|
|
42
|
+
* large graphs — one dynamic import anywhere poisons the whole closure).
|
|
43
|
+
*/
|
|
44
|
+
const SOURCE_EXTENSIONS = [
|
|
45
|
+
".ts",
|
|
46
|
+
".tsx",
|
|
47
|
+
".mts",
|
|
48
|
+
".cts",
|
|
49
|
+
".js",
|
|
50
|
+
".jsx",
|
|
51
|
+
".mjs",
|
|
52
|
+
".cjs"
|
|
53
|
+
];
|
|
54
|
+
const NODE_MODULES_SEGMENT = `${path$1.sep}node_modules${path$1.sep}`;
|
|
45
55
|
/** Specifier schemes that never resolve to project files. */
|
|
46
|
-
// oxlint-disable-next-line no-control-regex -- rollup-convention virtual module ids begin with NUL
|
|
47
56
|
const SKIP_SPECIFIER = /^(?:node:|data:|virtual:|\u0000)/;
|
|
48
57
|
/** Runaway guard — graphs larger than this fall back to the superset. */
|
|
49
|
-
const MAX_FILES =
|
|
50
|
-
const INCOMPLETE = {
|
|
58
|
+
const MAX_FILES = 1e4;
|
|
59
|
+
const INCOMPLETE = {
|
|
60
|
+
deps: [],
|
|
61
|
+
complete: false
|
|
62
|
+
};
|
|
51
63
|
/**
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
64
|
+
* Resolution-failure sentinel. A unique symbol rather than a string literal:
|
|
65
|
+
* `"incomplete" | string` collapses to `string`, so the type system could
|
|
66
|
+
* not distinguish a resolved path from the failure marker.
|
|
67
|
+
*/
|
|
56
68
|
const UNRESOLVED = Symbol("unresolved");
|
|
57
69
|
/**
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const nodeMemo = new Map();
|
|
66
|
-
const resolveMemo = new Map();
|
|
67
|
-
const realpathMemo = new Map();
|
|
68
|
-
const requireMemo = new Map();
|
|
70
|
+
* Per-process memos. The file node memo is revalidated by mtime on every
|
|
71
|
+
* visit; the resolution memos (specifier, realpath, require) depend on the
|
|
72
|
+
* filesystem layout rather than file contents and are only dropped by
|
|
73
|
+
* resetDepGraphMemo() — the same wholesale invalidation watch mode already
|
|
74
|
+
* applies to the module cache (a memoized resolution can only go stale when
|
|
75
|
+
* files appear/move, which fires watchChange).
|
|
76
|
+
*/
|
|
77
|
+
const nodeMemo = /* @__PURE__ */ new Map();
|
|
78
|
+
const resolveMemo = /* @__PURE__ */ new Map();
|
|
79
|
+
const realpathMemo = /* @__PURE__ */ new Map();
|
|
80
|
+
const requireMemo = /* @__PURE__ */ new Map();
|
|
69
81
|
/** Reset the per-process dep-graph memos (watch-mode file changes). */
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
82
|
+
function resetDepGraphMemo() {
|
|
83
|
+
nodeMemo.clear();
|
|
84
|
+
resolveMemo.clear();
|
|
85
|
+
realpathMemo.clear();
|
|
86
|
+
requireMemo.clear();
|
|
75
87
|
}
|
|
76
88
|
const STATIC_SPECIFIER = /(?:\bfrom\s*|\bimport\s+|\bimport\s*\(\s*|\brequire\s*\(\s*)["']([^"'\n]+)["']/g;
|
|
77
|
-
// No /g flag: `.test()` on a global regex resumes from lastIndex of the
|
|
78
|
-
// PREVIOUS file's match, silently missing dynamic imports (a missed
|
|
79
|
-
// detection records a falsely-complete dep set — stale cache).
|
|
80
89
|
const DYNAMIC_CALL = /\b(?:import|require)\s*\(\s*(?!["'])[^)\s]/;
|
|
81
90
|
/** statSync that reports ENOENT as undefined instead of an exception. */
|
|
82
91
|
function tryStat(p) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
// treat as absent.
|
|
89
|
-
return undefined;
|
|
90
|
-
}
|
|
92
|
+
try {
|
|
93
|
+
return fs$1.statSync(p, { throwIfNoEntry: false });
|
|
94
|
+
} catch {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
91
97
|
}
|
|
92
98
|
function tryFile(p) {
|
|
93
|
-
|
|
99
|
+
return tryStat(p)?.isFile() ? p : null;
|
|
94
100
|
}
|
|
95
101
|
/** Probe a path (possibly extensionless) to an existing file. */
|
|
96
102
|
function probeFile(base) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
if (hit)
|
|
115
|
-
return hit;
|
|
116
|
-
}
|
|
117
|
-
for (const ext of SOURCE_EXTENSIONS) {
|
|
118
|
-
const hit = tryFile(path.join(base, `index${ext}`));
|
|
119
|
-
if (hit)
|
|
120
|
-
return hit;
|
|
121
|
-
}
|
|
122
|
-
// Extensionless path that exists exactly (e.g. ./bin/cli).
|
|
123
|
-
return hasExtension ? null : tryFile(base);
|
|
103
|
+
const hasExtension = path$1.extname(base) !== "";
|
|
104
|
+
if (hasExtension) {
|
|
105
|
+
if (tryFile(base)) return base;
|
|
106
|
+
if (/\.[cm]?js$/.test(base)) {
|
|
107
|
+
const hit = tryFile(base.replace(/\.([cm]?)js$/, ".$1ts")) ?? tryFile(base.replace(/\.[cm]?js$/, ".tsx"));
|
|
108
|
+
if (hit) return hit;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
for (const ext of SOURCE_EXTENSIONS) {
|
|
112
|
+
const hit = tryFile(base + ext);
|
|
113
|
+
if (hit) return hit;
|
|
114
|
+
}
|
|
115
|
+
for (const ext of SOURCE_EXTENSIONS) {
|
|
116
|
+
const hit = tryFile(path$1.join(base, `index${ext}`));
|
|
117
|
+
if (hit) return hit;
|
|
118
|
+
}
|
|
119
|
+
return hasExtension ? null : tryFile(base);
|
|
124
120
|
}
|
|
125
121
|
function realpathOf(p) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
return real;
|
|
122
|
+
let real = realpathMemo.get(p);
|
|
123
|
+
if (real === void 0) {
|
|
124
|
+
try {
|
|
125
|
+
real = fs$1.realpathSync(p);
|
|
126
|
+
} catch {
|
|
127
|
+
real = p;
|
|
128
|
+
}
|
|
129
|
+
realpathMemo.set(p, real);
|
|
130
|
+
}
|
|
131
|
+
return real;
|
|
137
132
|
}
|
|
138
133
|
function firstPartyOrNull(resolved) {
|
|
139
|
-
|
|
140
|
-
|
|
134
|
+
const real = realpathOf(resolved);
|
|
135
|
+
return real.includes(NODE_MODULES_SEGMENT) ? null : real;
|
|
141
136
|
}
|
|
142
137
|
/** Node resolution is a function of the importing DIRECTORY, not the file. */
|
|
143
138
|
function requireFor(dir) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
139
|
+
let req = requireMemo.get(dir);
|
|
140
|
+
if (req === void 0) {
|
|
141
|
+
req = createRequire(path$1.join(dir, "__zod_compiler_resolve__.js"));
|
|
142
|
+
requireMemo.set(dir, req);
|
|
143
|
+
}
|
|
144
|
+
return req;
|
|
150
145
|
}
|
|
151
146
|
/**
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
147
|
+
* Resolve one specifier from a directory. Returns:
|
|
148
|
+
* - an absolute path (first-party file to record + crawl)
|
|
149
|
+
* - null when the dep is intentionally out of scope (node_modules, builtins)
|
|
150
|
+
* - UNRESOLVED when resolution failed and the graph cannot be trusted
|
|
151
|
+
*/
|
|
157
152
|
function resolveSpecifier(rawSpec, fromDir) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
resolveMemo.set(memoKey, result);
|
|
166
|
-
return result;
|
|
153
|
+
if (SKIP_SPECIFIER.test(rawSpec)) return null;
|
|
154
|
+
const memoKey = `${fromDir}\0${rawSpec}`;
|
|
155
|
+
const memoized = resolveMemo.get(memoKey);
|
|
156
|
+
if (memoized !== void 0) return memoized;
|
|
157
|
+
const result = resolveSpecifierUncached(rawSpec, fromDir);
|
|
158
|
+
resolveMemo.set(memoKey, result);
|
|
159
|
+
return result;
|
|
167
160
|
}
|
|
168
161
|
function resolveSpecifierUncached(rawSpec, fromDir) {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
// specifier (npm packages, `#` imports) and only mean "try baseDir
|
|
190
|
-
// first" — a miss falls through to node resolution below.
|
|
191
|
-
if (authoritative)
|
|
192
|
-
return UNRESOLVED;
|
|
193
|
-
// Bare specifier (package) or package.json "imports" (#...): node
|
|
194
|
-
// resolution from the importing directory. node_modules results are out of
|
|
195
|
-
// scope (zod's version is part of the cache key); symlinked workspace
|
|
196
|
-
// packages realpath outside node_modules and are crawled as first-party.
|
|
197
|
-
try {
|
|
198
|
-
const resolved = requireFor(fromDir).resolve(spec);
|
|
199
|
-
if (!path.isAbsolute(resolved))
|
|
200
|
-
return null; // node builtin
|
|
201
|
-
return firstPartyOrNull(resolved);
|
|
202
|
-
}
|
|
203
|
-
catch {
|
|
204
|
-
// Unresolvable from Node's algorithm. jiti may still resolve it (e.g.
|
|
205
|
-
// ESM-only packages without CJS entries) — the file itself stays a dep
|
|
206
|
-
// through the entry, but its subtree is unknown for bare packages.
|
|
207
|
-
// Treat unresolvable BARE specifiers as out-of-scope third-party
|
|
208
|
-
// (caught by the zod-version/plugin key when relevant) only when they
|
|
209
|
-
// cannot be project files; '#' subpath imports stay strict.
|
|
210
|
-
return spec.startsWith("#") ? UNRESOLVED : null;
|
|
211
|
-
}
|
|
162
|
+
const q = rawSpec.indexOf("?");
|
|
163
|
+
const spec = q === -1 ? rawSpec : rawSpec.slice(0, q);
|
|
164
|
+
if (spec === "") return null;
|
|
165
|
+
if (spec.startsWith("./") || spec.startsWith("../")) {
|
|
166
|
+
const hit = probeFile(path$1.resolve(fromDir, spec));
|
|
167
|
+
return hit === null ? UNRESOLVED : firstPartyOrNull(hit);
|
|
168
|
+
}
|
|
169
|
+
const { candidates, authoritative } = resolveTsconfigPathCandidates(fromDir, spec);
|
|
170
|
+
for (const candidate of candidates) {
|
|
171
|
+
const hit = probeFile(candidate);
|
|
172
|
+
if (hit !== null) return firstPartyOrNull(hit);
|
|
173
|
+
}
|
|
174
|
+
if (authoritative) return UNRESOLVED;
|
|
175
|
+
try {
|
|
176
|
+
const resolved = requireFor(fromDir).resolve(spec);
|
|
177
|
+
if (!path$1.isAbsolute(resolved)) return null;
|
|
178
|
+
return firstPartyOrNull(resolved);
|
|
179
|
+
} catch {
|
|
180
|
+
return spec.startsWith("#") ? UNRESOLVED : null;
|
|
181
|
+
}
|
|
212
182
|
}
|
|
213
183
|
/**
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
184
|
+
* Scan + resolve one file into its edge list. Memoized by mtime, so the
|
|
185
|
+
* shared core graph is read and resolved once per process — each entry's
|
|
186
|
+
* closure walk after that is one cheap stat plus Map lookups per file.
|
|
187
|
+
* Returns null for unreadable files.
|
|
188
|
+
*/
|
|
219
189
|
function fileNode(filePath) {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
}
|
|
256
|
-
const node = { mtimeMs: stat.mtimeMs, edges, incomplete };
|
|
257
|
-
nodeMemo.set(filePath, node);
|
|
258
|
-
return node;
|
|
190
|
+
const stat = tryStat(filePath);
|
|
191
|
+
if (stat === void 0 || !stat.isFile()) {
|
|
192
|
+
nodeMemo.set(filePath, null);
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
const memo = nodeMemo.get(filePath);
|
|
196
|
+
if (memo !== void 0 && memo !== null && memo.mtimeMs === stat.mtimeMs) return memo;
|
|
197
|
+
let source;
|
|
198
|
+
try {
|
|
199
|
+
source = fs$1.readFileSync(filePath, "utf8");
|
|
200
|
+
} catch {
|
|
201
|
+
nodeMemo.set(filePath, null);
|
|
202
|
+
return null;
|
|
203
|
+
}
|
|
204
|
+
let incomplete = DYNAMIC_CALL.test(source);
|
|
205
|
+
const edges = [];
|
|
206
|
+
const seen = /* @__PURE__ */ new Set();
|
|
207
|
+
const dir = path$1.dirname(filePath);
|
|
208
|
+
for (const m of source.matchAll(STATIC_SPECIFIER)) {
|
|
209
|
+
const spec = m[1];
|
|
210
|
+
if (!spec) continue;
|
|
211
|
+
const resolved = resolveSpecifier(spec, dir);
|
|
212
|
+
if (resolved === UNRESOLVED) incomplete = true;
|
|
213
|
+
else if (resolved !== null && !seen.has(resolved)) {
|
|
214
|
+
seen.add(resolved);
|
|
215
|
+
edges.push(resolved);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
const node = {
|
|
219
|
+
mtimeMs: stat.mtimeMs,
|
|
220
|
+
edges,
|
|
221
|
+
incomplete
|
|
222
|
+
};
|
|
223
|
+
nodeMemo.set(filePath, node);
|
|
224
|
+
return node;
|
|
259
225
|
}
|
|
260
226
|
/**
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
visited.delete(entry);
|
|
287
|
-
return { deps: [...visited], complete: true };
|
|
227
|
+
* Compute the static first-party dependency closure of `entryFile`.
|
|
228
|
+
* The entry itself is excluded (its content is part of the cache key).
|
|
229
|
+
*/
|
|
230
|
+
function collectStaticDeps(entryFile) {
|
|
231
|
+
const entry = firstPartyOrNull(path$1.resolve(entryFile));
|
|
232
|
+
if (entry === null) return INCOMPLETE;
|
|
233
|
+
const visited = /* @__PURE__ */ new Set([entry]);
|
|
234
|
+
const queue = [entry];
|
|
235
|
+
while (queue.length > 0) {
|
|
236
|
+
if (visited.size > MAX_FILES) return INCOMPLETE;
|
|
237
|
+
const node = fileNode(queue.pop());
|
|
238
|
+
if (node === null || node.incomplete) return INCOMPLETE;
|
|
239
|
+
for (const dep of node.edges) if (!visited.has(dep)) {
|
|
240
|
+
visited.add(dep);
|
|
241
|
+
queue.push(dep);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
visited.delete(entry);
|
|
245
|
+
return {
|
|
246
|
+
deps: [...visited],
|
|
247
|
+
complete: true
|
|
248
|
+
};
|
|
288
249
|
}
|
|
250
|
+
//#endregion
|
|
251
|
+
export { collectStaticDeps, resetDepGraphMemo };
|
|
252
|
+
|
|
289
253
|
//# sourceMappingURL=dep-graph.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
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AAC,GAAG,OAAO,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAChD,CAAC"}
|
|
1
|
+
{"version":3,"file":"dep-graph.js","names":["path","fs"],"sources":["../../src/unplugin/dep-graph.ts"],"sourcesContent":["/**\n * Static per-file dependency graphs for disk-cache invalidation.\n *\n * The disk cache used to record `getFirstPartyModulePaths()` — the superset\n * of EVERY first-party module the loader had executed so far — as each\n * entry's dependency set. Supersets never serve stale results, but in a\n * large codebase every entry ends up recording the whole project (~1,900\n * deps, ~400KB JSON per entry in the field report), so ANY commit\n * invalidates essentially the entire cache and CI re-pays full discovery\n * every run.\n *\n * This module computes the file's ACTUAL import graph statically: scan\n * import/export/require specifiers, resolve them (relative paths with\n * extension probing, tsconfig path aliases via the loader's config, bare\n * specifiers through node resolution), and BFS across first-party files.\n * No file is executed. Type-only imports are included (over-approximation\n * only over-invalidates).\n *\n * Soundness rule: when anything cannot be analyzed — a non-literal dynamic\n * import, an unresolvable relative specifier — the crawl reports\n * `complete: false` and the caller falls back to the superset. A static\n * crawl may only replace the superset when it provably covers everything\n * the file can load.\n *\n * Cost discipline (this runs serialized on the bundler's main process, once\n * per discovery file, over closures that reach thousands of files):\n * - every existence probe uses `statSync(p, { throwIfNoEntry: false })` —\n * a thrown ENOENT pays V8 error-plus-stack construction, and a cold crawl\n * issues these probes by the million (the dominant cost in field samples);\n * - resolution is memoized at every level: realpath per path, createRequire\n * per directory, resolved specifier per (directory, specifier), and the\n * full edge list per file (mtime-validated) — repeat crawls over the\n * shared core graph are Map lookups plus one cheap stat per file;\n * - the BFS aborts the moment the graph becomes unanalyzable: the caller\n * discards an incomplete result for the superset anyway, so finishing the\n * crawl would be pure waste (and incomplete is the COMMON outcome on\n * large graphs — one dynamic import anywhere poisons the whole closure).\n */\n\nimport * as fs from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport * as path from \"node:path\";\nimport { resolveTsconfigPathCandidates } from \"../loader.js\";\n\nexport interface StaticDeps {\n /** Absolute real paths of first-party files reachable from the entry. */\n deps: string[];\n /** False when the graph could not be fully analyzed — use the superset. */\n complete: boolean;\n}\n\nconst SOURCE_EXTENSIONS = [\".ts\", \".tsx\", \".mts\", \".cts\", \".js\", \".jsx\", \".mjs\", \".cjs\"];\nconst NODE_MODULES_SEGMENT = `${path.sep}node_modules${path.sep}`;\n/** Specifier schemes that never resolve to project files. */\n// oxlint-disable-next-line no-control-regex -- rollup-convention virtual module ids begin with NUL\nconst SKIP_SPECIFIER = /^(?:node:|data:|virtual:|\\u0000)/;\n/** Runaway guard — graphs larger than this fall back to the superset. */\nconst MAX_FILES = 10_000;\n\nconst INCOMPLETE: StaticDeps = { deps: [], complete: false };\n\n/**\n * Resolution-failure sentinel. A unique symbol rather than a string literal:\n * `\"incomplete\" | string` collapses to `string`, so the type system could\n * not distinguish a resolved path from the failure marker.\n */\nconst UNRESOLVED = Symbol(\"unresolved\");\n\ninterface FileNode {\n mtimeMs: number;\n /** Resolved first-party imports (absolute real paths), deduped. */\n edges: string[];\n /** Non-literal dynamic import/require or unresolvable specifier. */\n incomplete: boolean;\n}\n\n/**\n * Per-process memos. The file node memo is revalidated by mtime on every\n * visit; the resolution memos (specifier, realpath, require) depend on the\n * filesystem layout rather than file contents and are only dropped by\n * resetDepGraphMemo() — the same wholesale invalidation watch mode already\n * applies to the module cache (a memoized resolution can only go stale when\n * files appear/move, which fires watchChange).\n */\nconst nodeMemo = new Map<string, FileNode | null>();\nconst resolveMemo = new Map<string, string | null | typeof UNRESOLVED>();\nconst realpathMemo = new Map<string, string>();\nconst requireMemo = new Map<string, ReturnType<typeof createRequire>>();\n\n/** Reset the per-process dep-graph memos (watch-mode file changes). */\nexport function resetDepGraphMemo(): void {\n nodeMemo.clear();\n resolveMemo.clear();\n realpathMemo.clear();\n requireMemo.clear();\n}\n\nconst STATIC_SPECIFIER =\n /(?:\\bfrom\\s*|\\bimport\\s+|\\bimport\\s*\\(\\s*|\\brequire\\s*\\(\\s*)[\"']([^\"'\\n]+)[\"']/g;\n// No /g flag: `.test()` on a global regex resumes from lastIndex of the\n// PREVIOUS file's match, silently missing dynamic imports (a missed\n// detection records a falsely-complete dep set — stale cache).\nconst DYNAMIC_CALL = /\\b(?:import|require)\\s*\\(\\s*(?![\"'])[^)\\s]/;\n\n/** statSync that reports ENOENT as undefined instead of an exception. */\nfunction tryStat(p: string): fs.Stats | undefined {\n try {\n return fs.statSync(p, { throwIfNoEntry: false });\n } catch {\n // Non-ENOENT errors (ENOTDIR from probing `file.ts/index.ts`, EACCES):\n // treat as absent.\n return undefined;\n }\n}\n\nfunction tryFile(p: string): string | null {\n return tryStat(p)?.isFile() ? p : null;\n}\n\n/** Probe a path (possibly extensionless) to an existing file. */\nfunction probeFile(base: string): string | null {\n const hasExtension = path.extname(base) !== \"\";\n if (hasExtension) {\n if (tryFile(base)) return base;\n // Extensioned path that doesn't exist as-is: TS source referenced with a\n // .js specifier (nodenext style). Probe the extension-family swap before\n // the append/index probes — in nodenext codebases this is the common hit\n // and skips ~16 dead probes per import.\n if (/\\.[cm]?js$/.test(base)) {\n const hit =\n tryFile(base.replace(/\\.([cm]?)js$/, \".$1ts\")) ??\n tryFile(base.replace(/\\.[cm]?js$/, \".tsx\"));\n if (hit) return hit;\n }\n }\n for (const ext of SOURCE_EXTENSIONS) {\n const hit = tryFile(base + ext);\n if (hit) return hit;\n }\n for (const ext of SOURCE_EXTENSIONS) {\n const hit = tryFile(path.join(base, `index${ext}`));\n if (hit) return hit;\n }\n // Extensionless path that exists exactly (e.g. ./bin/cli).\n return hasExtension ? null : tryFile(base);\n}\n\nfunction realpathOf(p: string): string {\n let real = realpathMemo.get(p);\n if (real === undefined) {\n try {\n real = fs.realpathSync(p);\n } catch {\n real = p; // keep the unresolved path\n }\n realpathMemo.set(p, real);\n }\n return real;\n}\n\nfunction firstPartyOrNull(resolved: string): string | null {\n const real = realpathOf(resolved);\n return real.includes(NODE_MODULES_SEGMENT) ? null : real;\n}\n\n/** Node resolution is a function of the importing DIRECTORY, not the file. */\nfunction requireFor(dir: string): ReturnType<typeof createRequire> {\n let req = requireMemo.get(dir);\n if (req === undefined) {\n req = createRequire(path.join(dir, \"__zod_compiler_resolve__.js\"));\n requireMemo.set(dir, req);\n }\n return req;\n}\n\n/**\n * Resolve one specifier from a directory. Returns:\n * - an absolute path (first-party file to record + crawl)\n * - null when the dep is intentionally out of scope (node_modules, builtins)\n * - UNRESOLVED when resolution failed and the graph cannot be trusted\n */\nfunction resolveSpecifier(rawSpec: string, fromDir: string): string | null | typeof UNRESOLVED {\n if (SKIP_SPECIFIER.test(rawSpec)) return null;\n const memoKey = `${fromDir}\\0${rawSpec}`;\n const memoized = resolveMemo.get(memoKey);\n if (memoized !== undefined) return memoized;\n const result = resolveSpecifierUncached(rawSpec, fromDir);\n resolveMemo.set(memoKey, result);\n return result;\n}\n\nfunction resolveSpecifierUncached(\n rawSpec: string,\n fromDir: string,\n): string | null | typeof UNRESOLVED {\n // Vite-style resource queries (./logo.svg?url, ./shader.glsl?raw) resolve\n // to the underlying file.\n const q = rawSpec.indexOf(\"?\");\n const spec = q === -1 ? rawSpec : rawSpec.slice(0, q);\n if (spec === \"\") return null;\n\n if (spec.startsWith(\"./\") || spec.startsWith(\"../\")) {\n const hit = probeFile(path.resolve(fromDir, spec));\n return hit === null ? UNRESOLVED : firstPartyOrNull(hit);\n }\n\n const { candidates, authoritative } = resolveTsconfigPathCandidates(fromDir, spec);\n for (const candidate of candidates) {\n const hit = probeFile(candidate);\n if (hit !== null) {\n return firstPartyOrNull(hit);\n }\n }\n // An authoritative miss (explicit `paths` pattern matched, or the paths\n // config is present but uninterpretable) means the import cannot be\n // trusted. Implicit baseUrl candidates are proposed for EVERY bare\n // specifier (npm packages, `#` imports) and only mean \"try baseDir\n // first\" — a miss falls through to node resolution below.\n if (authoritative) return UNRESOLVED;\n\n // Bare specifier (package) or package.json \"imports\" (#...): node\n // resolution from the importing directory. node_modules results are out of\n // scope (zod's version is part of the cache key); symlinked workspace\n // packages realpath outside node_modules and are crawled as first-party.\n try {\n const resolved = requireFor(fromDir).resolve(spec);\n if (!path.isAbsolute(resolved)) return null; // node builtin\n return firstPartyOrNull(resolved);\n } catch {\n // Unresolvable from Node's algorithm. jiti may still resolve it (e.g.\n // ESM-only packages without CJS entries) — the file itself stays a dep\n // through the entry, but its subtree is unknown for bare packages.\n // Treat unresolvable BARE specifiers as out-of-scope third-party\n // (caught by the zod-version/plugin key when relevant) only when they\n // cannot be project files; '#' subpath imports stay strict.\n return spec.startsWith(\"#\") ? UNRESOLVED : null;\n }\n}\n\n/**\n * Scan + resolve one file into its edge list. Memoized by mtime, so the\n * shared core graph is read and resolved once per process — each entry's\n * closure walk after that is one cheap stat plus Map lookups per file.\n * Returns null for unreadable files.\n */\nfunction fileNode(filePath: string): FileNode | null {\n const stat = tryStat(filePath);\n if (stat === undefined || !stat.isFile()) {\n nodeMemo.set(filePath, null);\n return null;\n }\n const memo = nodeMemo.get(filePath);\n if (memo !== undefined && memo !== null && memo.mtimeMs === stat.mtimeMs) return memo;\n\n let source: string;\n try {\n source = fs.readFileSync(filePath, \"utf8\");\n } catch {\n nodeMemo.set(filePath, null);\n return null;\n }\n // String/comment contents can false-positive both patterns; extra\n // specifiers only add deps (safe), a false `incomplete` only falls back\n // to the superset (safe).\n let incomplete = DYNAMIC_CALL.test(source);\n const edges: string[] = [];\n const seen = new Set<string>();\n const dir = path.dirname(filePath);\n for (const m of source.matchAll(STATIC_SPECIFIER)) {\n const spec = m[1];\n if (!spec) continue;\n const resolved = resolveSpecifier(spec, dir);\n if (resolved === UNRESOLVED) {\n incomplete = true;\n } else if (resolved !== null && !seen.has(resolved)) {\n seen.add(resolved);\n edges.push(resolved);\n }\n }\n const node: FileNode = { mtimeMs: stat.mtimeMs, edges, incomplete };\n nodeMemo.set(filePath, node);\n return node;\n}\n\n/**\n * Compute the static first-party dependency closure of `entryFile`.\n * The entry itself is excluded (its content is part of the cache key).\n */\nexport function collectStaticDeps(entryFile: string): StaticDeps {\n const entry = firstPartyOrNull(path.resolve(entryFile));\n if (entry === null) return INCOMPLETE;\n\n const visited = new Set<string>([entry]);\n const queue: string[] = [entry];\n\n while (queue.length > 0) {\n if (visited.size > MAX_FILES) return INCOMPLETE;\n const file = queue.pop() as string;\n const node = fileNode(file);\n // Any unanalyzable node poisons the whole closure; the caller falls back\n // to the superset, so abort instead of crawling to exhaustion.\n if (node === null || node.incomplete) return INCOMPLETE;\n for (const dep of node.edges) {\n if (!visited.has(dep)) {\n visited.add(dep);\n queue.push(dep);\n }\n }\n }\n\n visited.delete(entry);\n return { deps: [...visited], complete: true };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,MAAM,oBAAoB;CAAC;CAAO;CAAQ;CAAQ;CAAQ;CAAO;CAAQ;CAAQ;AAAM;AACvF,MAAM,uBAAuB,GAAGA,OAAK,IAAI,cAAcA,OAAK;;AAG5D,MAAM,iBAAiB;;AAEvB,MAAM,YAAY;AAElB,MAAM,aAAyB;CAAE,MAAM,CAAC;CAAG,UAAU;AAAM;;;;;;AAO3D,MAAM,aAAa,OAAO,YAAY;;;;;;;;;AAkBtC,MAAM,2BAAW,IAAI,IAA6B;AAClD,MAAM,8BAAc,IAAI,IAA+C;AACvE,MAAM,+BAAe,IAAI,IAAoB;AAC7C,MAAM,8BAAc,IAAI,IAA8C;;AAGtE,SAAgB,oBAA0B;CACxC,SAAS,MAAM;CACf,YAAY,MAAM;CAClB,aAAa,MAAM;CACnB,YAAY,MAAM;AACpB;AAEA,MAAM,mBACJ;AAIF,MAAM,eAAe;;AAGrB,SAAS,QAAQ,GAAiC;CAChD,IAAI;EACF,OAAOC,KAAG,SAAS,GAAG,EAAE,gBAAgB,MAAM,CAAC;CACjD,QAAQ;EAGN;CACF;AACF;AAEA,SAAS,QAAQ,GAA0B;CACzC,OAAO,QAAQ,CAAC,CAAC,EAAE,OAAO,IAAI,IAAI;AACpC;;AAGA,SAAS,UAAU,MAA6B;CAC9C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