zod-aot 0.9.1 → 0.9.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/dist/loader.d.ts +2 -2
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +10 -31
- package/dist/loader.js.map +1 -1
- package/package.json +2 -7
package/dist/loader.d.ts
CHANGED
|
@@ -5,8 +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
|
|
9
|
-
*
|
|
8
|
+
* - Node.js: uses jiti for reliable TypeScript transpilation
|
|
9
|
+
* (handles extensionless imports, enums, and all TS syntax)
|
|
10
10
|
*/
|
|
11
11
|
export declare function loadSourceFile(filePath: string, options?: LoadOptions): Promise<Record<string, unknown>>;
|
|
12
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":"AAWA,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,CAelC"}
|
package/dist/loader.js
CHANGED
|
@@ -7,45 +7,24 @@ 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
|
-
}
|
|
13
10
|
/**
|
|
14
11
|
* Dynamically import a source file (.ts or .js).
|
|
15
12
|
* - Bun/Deno: native TypeScript support, direct import
|
|
16
|
-
* - Node.js
|
|
17
|
-
*
|
|
13
|
+
* - Node.js: uses jiti for reliable TypeScript transpilation
|
|
14
|
+
* (handles extensionless imports, enums, and all TS syntax)
|
|
18
15
|
*/
|
|
19
16
|
export async function loadSourceFile(filePath, options) {
|
|
20
17
|
const absPath = path.resolve(filePath);
|
|
21
|
-
const ext = path.extname(absPath);
|
|
22
18
|
const runtime = detectRuntime();
|
|
23
19
|
const suffix = options?.cacheBust ? `?t=${Date.now()}` : "";
|
|
24
|
-
//
|
|
25
|
-
|
|
26
|
-
|
|
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);
|
|
33
|
-
}
|
|
34
|
-
finally {
|
|
35
|
-
unregister?.();
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
async function registerTsx(absPath) {
|
|
39
|
-
let tsxModule;
|
|
40
|
-
try {
|
|
41
|
-
const tsxSpecifier = "tsx/esm/api";
|
|
42
|
-
tsxModule = (await import(tsxSpecifier));
|
|
43
|
-
}
|
|
44
|
-
catch {
|
|
45
|
-
throw new Error(`Cannot load TypeScript file without tsx.\n` +
|
|
46
|
-
`Install it: npm install -D tsx\n` +
|
|
47
|
-
`File: ${absPath}`);
|
|
20
|
+
// Bun and Deno handle TypeScript natively
|
|
21
|
+
if (runtime === "bun" || runtime === "deno") {
|
|
22
|
+
return (await import(pathToFileURL(absPath).href + suffix));
|
|
48
23
|
}
|
|
49
|
-
|
|
24
|
+
const { createJiti } = await import("jiti");
|
|
25
|
+
const jiti = createJiti(pathToFileURL(absPath).href, {
|
|
26
|
+
moduleCache: !options?.cacheBust,
|
|
27
|
+
});
|
|
28
|
+
return (await jiti.import(absPath));
|
|
50
29
|
}
|
|
51
30
|
//# 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;
|
|
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;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,QAAgB,EAChB,OAAqB;IAErB,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACvC,MAAM,OAAO,GAAG,aAAa,EAAE,CAAC;IAChC,MAAM,MAAM,GAAG,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAE5D,0CAA0C;IAC1C,IAAI,OAAO,KAAK,KAAK,IAAI,OAAO,KAAK,MAAM,EAAE,CAAC;QAC5C,OAAO,CAAC,MAAM,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,IAAI,GAAG,MAAM,CAAC,CAA4B,CAAC;IACzF,CAAC;IAED,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5C,MAAM,IAAI,GAAG,UAAU,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE;QACnD,WAAW,EAAE,CAAC,OAAO,EAAE,SAAS;KACjC,CAAC,CAAC;IACH,OAAO,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAA4B,CAAC;AACjE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zod-aot",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"description": "Compile Zod schemas into zero-overhead validation functions at build time",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -83,17 +83,12 @@
|
|
|
83
83
|
}
|
|
84
84
|
},
|
|
85
85
|
"dependencies": {
|
|
86
|
+
"jiti": "^2.6.1",
|
|
86
87
|
"unplugin": "^3.0.0"
|
|
87
88
|
},
|
|
88
89
|
"peerDependencies": {
|
|
89
|
-
"tsx": "^4.0.0",
|
|
90
90
|
"zod": "^4.0.0"
|
|
91
91
|
},
|
|
92
|
-
"peerDependenciesMeta": {
|
|
93
|
-
"tsx": {
|
|
94
|
-
"optional": true
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
92
|
"devDependencies": {
|
|
98
93
|
"@types/node": "^25.5.0",
|
|
99
94
|
"tsx": "^4.21.0",
|