zod-aot 0.20.5 → 0.21.0
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 +5 -3
- package/dist/unplugin/index.d.ts.map +1 -1
- package/dist/unplugin/index.js +10 -4
- package/dist/unplugin/index.js.map +1 -1
- package/dist/unplugin/rsbuild.d.ts +3 -0
- package/dist/unplugin/rsbuild.d.ts.map +1 -0
- package/dist/unplugin/rsbuild.js +3 -0
- package/dist/unplugin/rsbuild.js.map +1 -0
- package/package.json +7 -1
package/README.md
CHANGED
|
@@ -150,6 +150,7 @@ npx zod-aot generate src/ --watch
|
|
|
150
150
|
| Rollup | `import zodAot from "zod-aot/rollup"` |
|
|
151
151
|
| Rolldown | `import zodAot from "zod-aot/rolldown"` |
|
|
152
152
|
| rspack | `import zodAot from "zod-aot/rspack"` |
|
|
153
|
+
| rsbuild | `import zodAot from "zod-aot/rsbuild"` |
|
|
153
154
|
| Bun | `import zodAot from "zod-aot/bun"` |
|
|
154
155
|
| Farm | `import zodAot from "zod-aot/farm"` |
|
|
155
156
|
|
|
@@ -180,9 +181,10 @@ wrapper, issue factories like `__zaTS`/`__zaIT`, and well-known regexes for
|
|
|
180
181
|
On bundlers that support virtual modules — **Vite, Rollup, Rolldown, esbuild,
|
|
181
182
|
Farm, Bun** — the plugin imports these helpers from
|
|
182
183
|
`virtual:zod-aot/runtime`, so the bundler emits a single bundle-wide copy
|
|
183
|
-
regardless of how many files reference them. webpack
|
|
184
|
-
|
|
185
|
-
|
|
184
|
+
regardless of how many files reference them. webpack, rspack, and rsbuild
|
|
185
|
+
reject the `virtual:` URI scheme at the resolver layer, so they import the same
|
|
186
|
+
runtime module through a bare-specifier alias (`__zod-aot-runtime__`) instead —
|
|
187
|
+
still a single deduplicated copy per bundle.
|
|
186
188
|
|
|
187
189
|
The result: a 5-file project with 10 schemas all using `z.email()` and
|
|
188
190
|
`z.uuid()` produces a bundle where each shared regex appears exactly **once**.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/unplugin/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/unplugin/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAoCtD,eAAO,MAAM,QAAQ,+EA2DpB,CAAC;AAEF,YAAY,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/unplugin/index.js
CHANGED
|
@@ -5,8 +5,9 @@ import { loadVirtual, RESOLVED_RUNTIME_ID, resolveVirtualId, VIRTUAL_RUNTIME_ID,
|
|
|
5
5
|
/**
|
|
6
6
|
* Frameworks whose resolveId/load hooks receive any import specifier, including
|
|
7
7
|
* `virtual:` URIs and bare specifiers, so lean-mode cross-file dedup works.
|
|
8
|
-
* webpack / rspack reject the `virtual:` URI scheme but accept bare
|
|
9
|
-
* so they use WP_RUNTIME_ID (`__zod-aot-runtime__`) instead of
|
|
8
|
+
* webpack / rspack / rsbuild reject the `virtual:` URI scheme but accept bare
|
|
9
|
+
* specifiers, so they use WP_RUNTIME_ID (`__zod-aot-runtime__`) instead of
|
|
10
|
+
* VIRTUAL_RUNTIME_ID.
|
|
10
11
|
*/
|
|
11
12
|
const VIRTUAL_MODULE_FRAMEWORKS = new Set([
|
|
12
13
|
"vite",
|
|
@@ -17,9 +18,14 @@ const VIRTUAL_MODULE_FRAMEWORKS = new Set([
|
|
|
17
18
|
"bun",
|
|
18
19
|
"rspack",
|
|
19
20
|
"webpack",
|
|
21
|
+
"rsbuild",
|
|
20
22
|
]);
|
|
21
|
-
/**
|
|
22
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Frameworks that need the bare-specifier runtime ID instead of `virtual:`.
|
|
25
|
+
* rsbuild is included because it wraps the rspack plugin internally, inheriting
|
|
26
|
+
* rspack's rejection of the `virtual:` URI scheme.
|
|
27
|
+
*/
|
|
28
|
+
const WP_FRAMEWORKS = new Set(["rspack", "webpack", "rsbuild"]);
|
|
23
29
|
export const unplugin = createUnplugin((options, meta) => {
|
|
24
30
|
const stats = new BuildStatsAccumulator();
|
|
25
31
|
const cache = new Map();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/unplugin/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAA4B,MAAM,UAAU,CAAC;AAEpE,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAErE,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EACL,WAAW,EACX,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,GACd,MAAM,cAAc,CAAC;AAEtB
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/unplugin/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAA4B,MAAM,UAAU,CAAC;AAEpE,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAErE,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EACL,WAAW,EACX,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,GACd,MAAM,cAAc,CAAC;AAEtB;;;;;;GAMG;AACH,MAAM,yBAAyB,GAAG,IAAI,GAAG,CAAC;IACxC,MAAM;IACN,QAAQ;IACR,UAAU;IACV,SAAS;IACT,MAAM;IACN,KAAK;IACL,QAAQ;IACR,SAAS;IACT,SAAS;CACV,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,CAA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O,EAAE,SAAS;gBAC7B,YAAY,EAAE,OAAO,EAAE,YAAY;gBACnC,YAAY,CAAC,CAAC;oBACZ,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;gBACf,CAAC;aACF,CAAC,CAAC;YACH,IAAI,CAAC,MAAM;gBAAE,OAAO;YACpB,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;YACtB,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;QACrC,CAAC;QAED,QAAQ;YACN,IAAI,CAAC,OAAO;gBAAE,OAAO;YACrB,IAAI,KAAK,CAAC,OAAO,KAAK,CAAC;gBAAE,OAAO;YAChC,GAAG,CACD,kBAAkB,KAAK,CAAC,SAAS,IAAI,KAAK,CAAC,OAAO,6BAA6B,KAAK,CAAC,KAAK,UAAU;gBAClG,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,MAAM,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CACvD,CAAC;YACF,KAAK,CAAC,KAAK,EAAE,CAAC;YACd,KAAK,CAAC,KAAK,EAAE,CAAC;QAChB,CAAC;KACF,CAAC;AACJ,CAAC,CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rsbuild.d.ts","sourceRoot":"","sources":["../../src/unplugin/rsbuild.ts"],"names":[],"mappings":";AAEA,wBAAgC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rsbuild.js","sourceRoot":"","sources":["../../src/unplugin/rsbuild.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,eAAe,QAAQ,CAAC,OAAO,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zod-aot",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "Compile Zod schemas into zero-overhead validation functions at build time",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -86,6 +86,12 @@
|
|
|
86
86
|
"source": "./src/unplugin/farm.ts",
|
|
87
87
|
"import": "./dist/unplugin/farm.js",
|
|
88
88
|
"default": "./dist/unplugin/farm.js"
|
|
89
|
+
},
|
|
90
|
+
"./rsbuild": {
|
|
91
|
+
"types": "./dist/unplugin/rsbuild.d.ts",
|
|
92
|
+
"source": "./src/unplugin/rsbuild.ts",
|
|
93
|
+
"import": "./dist/unplugin/rsbuild.js",
|
|
94
|
+
"default": "./dist/unplugin/rsbuild.js"
|
|
89
95
|
}
|
|
90
96
|
},
|
|
91
97
|
"dependencies": {
|