zod-aot 0.7.2 → 0.8.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/dist/loader.d.ts +2 -1
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +18 -19
- package/dist/loader.js.map +1 -1
- package/dist/unplugin/rspack.d.ts +3 -0
- package/dist/unplugin/rspack.d.ts.map +1 -0
- package/dist/unplugin/rspack.js +3 -0
- package/dist/unplugin/rspack.js.map +1 -0
- package/package.json +7 -1
package/dist/loader.d.ts
CHANGED
|
@@ -5,7 +5,8 @@ export interface LoadOptions {
|
|
|
5
5
|
/**
|
|
6
6
|
* Dynamically import a source file (.ts or .js).
|
|
7
7
|
* - Bun/Deno: native TypeScript support, direct import
|
|
8
|
-
* - Node.js
|
|
8
|
+
* - Node.js 22+: native type stripping, direct import
|
|
9
|
+
* - Node.js <22: uses tsx's register API for TypeScript files
|
|
9
10
|
*/
|
|
10
11
|
export declare function loadSourceFile(filePath: string, options?: LoadOptions): Promise<Record<string, unknown>>;
|
|
11
12
|
//# sourceMappingURL=loader.d.ts.map
|
package/dist/loader.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAeA,MAAM,WAAW,WAAW;IAC1B,8FAA8F;IAC9F,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAoBlC"}
|
package/dist/loader.js
CHANGED
|
@@ -7,32 +7,37 @@ function detectRuntime() {
|
|
|
7
7
|
return "deno";
|
|
8
8
|
return "node";
|
|
9
9
|
}
|
|
10
|
+
async function importModule(absPath, suffix) {
|
|
11
|
+
return (await import(pathToFileURL(absPath).href + suffix));
|
|
12
|
+
}
|
|
10
13
|
/**
|
|
11
14
|
* Dynamically import a source file (.ts or .js).
|
|
12
15
|
* - Bun/Deno: native TypeScript support, direct import
|
|
13
|
-
* - Node.js
|
|
16
|
+
* - Node.js 22+: native type stripping, direct import
|
|
17
|
+
* - Node.js <22: uses tsx's register API for TypeScript files
|
|
14
18
|
*/
|
|
15
19
|
export async function loadSourceFile(filePath, options) {
|
|
16
20
|
const absPath = path.resolve(filePath);
|
|
17
21
|
const ext = path.extname(absPath);
|
|
18
22
|
const runtime = detectRuntime();
|
|
19
23
|
const suffix = options?.cacheBust ? `?t=${Date.now()}` : "";
|
|
20
|
-
//
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
// Node.js < 22 needs tsx for TypeScript files.
|
|
25
|
+
// Node.js 22+ has native type stripping; tsx's register hook causes
|
|
26
|
+
// ERR_REQUIRE_CYCLE_MODULE due to stricter CJS/ESM interop cycle enforcement.
|
|
27
|
+
const needsTsx = runtime === "node" &&
|
|
28
|
+
(ext === ".ts" || ext === ".tsx" || ext === ".mts") &&
|
|
29
|
+
parseInt(process.versions.node, 10) < 22;
|
|
30
|
+
const unregister = needsTsx ? await registerTsx(absPath) : undefined;
|
|
31
|
+
try {
|
|
32
|
+
return await importModule(absPath, suffix);
|
|
23
33
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return loadTypeScriptFileWithTsx(absPath, suffix);
|
|
34
|
+
finally {
|
|
35
|
+
unregister?.();
|
|
27
36
|
}
|
|
28
|
-
// Node.js: .js / .mjs — direct import
|
|
29
|
-
return (await import(pathToFileURL(absPath).href + suffix));
|
|
30
37
|
}
|
|
31
|
-
async function
|
|
38
|
+
async function registerTsx(absPath) {
|
|
32
39
|
let tsxModule;
|
|
33
40
|
try {
|
|
34
|
-
// Dynamic import — tsx may or may not be installed
|
|
35
|
-
// Use variable to prevent TypeScript from resolving the module statically
|
|
36
41
|
const tsxSpecifier = "tsx/esm/api";
|
|
37
42
|
tsxModule = (await import(tsxSpecifier));
|
|
38
43
|
}
|
|
@@ -41,12 +46,6 @@ async function loadTypeScriptFileWithTsx(absPath, suffix = "") {
|
|
|
41
46
|
`Install it: npm install -D tsx\n` +
|
|
42
47
|
`File: ${absPath}`);
|
|
43
48
|
}
|
|
44
|
-
|
|
45
|
-
try {
|
|
46
|
-
return (await import(pathToFileURL(absPath).href + suffix));
|
|
47
|
-
}
|
|
48
|
-
finally {
|
|
49
|
-
unregister();
|
|
50
|
-
}
|
|
49
|
+
return tsxModule.register();
|
|
51
50
|
}
|
|
52
51
|
//# sourceMappingURL=loader.js.map
|
package/dist/loader.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAIzC,SAAS,aAAa;IACpB,IAAI,KAAK,IAAI,UAAU;QAAE,OAAO,KAAK,CAAC;IACtC,IAAI,MAAM,IAAI,UAAU;QAAE,OAAO,MAAM,CAAC;IACxC,OAAO,MAAM,CAAC;AAChB,CAAC;AAOD
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAIzC,SAAS,aAAa;IACpB,IAAI,KAAK,IAAI,UAAU;QAAE,OAAO,KAAK,CAAC;IACtC,IAAI,MAAM,IAAI,UAAU;QAAE,OAAO,MAAM,CAAC;IACxC,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,KAAK,UAAU,YAAY,CAAC,OAAe,EAAE,MAAc;IACzD,OAAO,CAAC,MAAM,MAAM,CAAC,aAAa,CAA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kCAAkC;YAClC,SAAS,OAAO,EAAE,CACrB,CAAC;IACJ,CAAC;IACD,OAAO,SAAS,CAAC,QAAQ,EAAE,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rspack.d.ts","sourceRoot":"","sources":["../../src/unplugin/rspack.ts"],"names":[],"mappings":";AAEA,wBAA+B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rspack.js","sourceRoot":"","sources":["../../src/unplugin/rspack.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,eAAe,QAAQ,CAAC,MAAM,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zod-aot",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Compile Zod schemas into zero-overhead validation functions at build time",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -74,6 +74,12 @@
|
|
|
74
74
|
"source": "./src/unplugin/bun.ts",
|
|
75
75
|
"import": "./dist/unplugin/bun.js",
|
|
76
76
|
"default": "./dist/unplugin/bun.js"
|
|
77
|
+
},
|
|
78
|
+
"./rspack": {
|
|
79
|
+
"types": "./dist/unplugin/rspack.d.ts",
|
|
80
|
+
"source": "./src/unplugin/rspack.ts",
|
|
81
|
+
"import": "./dist/unplugin/rspack.js",
|
|
82
|
+
"default": "./dist/unplugin/rspack.js"
|
|
77
83
|
}
|
|
78
84
|
},
|
|
79
85
|
"dependencies": {
|