zod-compiler 1.0.0 → 1.0.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 +108 -78
- package/dist/cli/commands/generate.d.ts +0 -1
- package/dist/cli/commands/generate.d.ts.map +1 -1
- package/dist/cli/commands/generate.js +8 -1
- package/dist/cli/commands/generate.js.map +1 -1
- package/dist/cli/commands/watch.d.ts.map +1 -1
- package/dist/cli/commands/watch.js +4 -1
- package/dist/cli/commands/watch.js.map +1 -1
- package/dist/discovery.d.ts +1 -2
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +1 -1
- package/dist/discovery.js.map +1 -1
- package/dist/loader.d.ts +18 -6
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +91 -38
- package/dist/loader.js.map +1 -1
- package/dist/static-filter.d.ts +7 -0
- package/dist/static-filter.d.ts.map +1 -0
- package/dist/static-filter.js +396 -0
- package/dist/static-filter.js.map +1 -0
- package/dist/unplugin/hoist.d.ts +19 -0
- package/dist/unplugin/hoist.d.ts.map +1 -0
- package/dist/unplugin/hoist.js +648 -0
- package/dist/unplugin/hoist.js.map +1 -0
- package/dist/unplugin/index.d.ts.map +1 -1
- package/dist/unplugin/index.js +38 -4
- package/dist/unplugin/index.js.map +1 -1
- package/dist/unplugin/transform.d.ts.map +1 -1
- package/dist/unplugin/transform.js +36 -12
- package/dist/unplugin/transform.js.map +1 -1
- package/dist/unplugin/types.d.ts +38 -0
- package/dist/unplugin/types.d.ts.map +1 -1
- package/dist/unplugin/types.js.map +1 -1
- package/package.json +10 -10
package/dist/loader.js
CHANGED
|
@@ -8,69 +8,122 @@ function detectRuntime() {
|
|
|
8
8
|
return "deno";
|
|
9
9
|
return "node";
|
|
10
10
|
}
|
|
11
|
+
/** Cache: search dir → tsconfig lookup result (getTsconfig walks the fs otherwise). */
|
|
12
|
+
const tsconfigSearchCache = new Map();
|
|
11
13
|
/** Cache: tsconfig.json absolute path → resolved jiti alias map */
|
|
12
14
|
const aliasCache = new Map();
|
|
13
15
|
/**
|
|
14
16
|
* Resolve tsconfig.json path aliases into the format jiti expects.
|
|
15
|
-
* Returns an empty
|
|
17
|
+
* Returns an empty alias map if no tsconfig.json is found or no paths are configured.
|
|
16
18
|
*
|
|
17
19
|
* tsconfig paths use wildcards: { "@/*": ["./src/*"] }
|
|
18
20
|
* jiti uses prefix matching: { "@": "/absolute/path/to/src" }
|
|
19
21
|
*
|
|
20
22
|
* The trailing "/*" is stripped from both key and value before passing to jiti.
|
|
21
23
|
*/
|
|
22
|
-
function
|
|
23
|
-
const tsconfig = getTsconfig(fromDir);
|
|
24
|
+
function resolveLoaderConfig(fromDir) {
|
|
25
|
+
const tsconfig = getTsconfig(fromDir, "tsconfig.json", tsconfigSearchCache);
|
|
24
26
|
if (!tsconfig)
|
|
25
|
-
return {};
|
|
27
|
+
return { key: "", alias: {} };
|
|
26
28
|
const cached = aliasCache.get(tsconfig.path);
|
|
27
29
|
if (cached)
|
|
28
|
-
return cached;
|
|
29
|
-
const paths = tsconfig.config.compilerOptions?.paths;
|
|
30
|
-
if (!paths || Object.keys(paths).length === 0) {
|
|
31
|
-
const empty = {};
|
|
32
|
-
aliasCache.set(tsconfig.path, empty);
|
|
33
|
-
return empty;
|
|
34
|
-
}
|
|
35
|
-
const tsconfigDir = path.dirname(tsconfig.path);
|
|
36
|
-
const baseUrl = tsconfig.config.compilerOptions?.baseUrl;
|
|
37
|
-
const baseDir = baseUrl ? path.resolve(tsconfigDir, baseUrl) : tsconfigDir;
|
|
30
|
+
return { key: tsconfig.path, alias: cached };
|
|
38
31
|
const alias = {};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
32
|
+
const paths = tsconfig.config.compilerOptions?.paths;
|
|
33
|
+
if (paths && Object.keys(paths).length > 0) {
|
|
34
|
+
const tsconfigDir = path.dirname(tsconfig.path);
|
|
35
|
+
const baseUrl = tsconfig.config.compilerOptions?.baseUrl;
|
|
36
|
+
const baseDir = baseUrl ? path.resolve(tsconfigDir, baseUrl) : tsconfigDir;
|
|
37
|
+
for (const [pattern, targets] of Object.entries(paths)) {
|
|
38
|
+
if (!targets || targets.length === 0)
|
|
39
|
+
continue;
|
|
40
|
+
const target = targets[0];
|
|
41
|
+
if (!target)
|
|
42
|
+
continue;
|
|
43
|
+
// Strip trailing "/*" — jiti uses prefix matching, not glob wildcards
|
|
44
|
+
const key = pattern.endsWith("/*") ? pattern.slice(0, -2) : pattern;
|
|
45
|
+
const val = target.endsWith("/*") ? target.slice(0, -2) : target;
|
|
46
|
+
alias[key] = path.resolve(baseDir, val);
|
|
47
|
+
}
|
|
49
48
|
}
|
|
50
49
|
aliasCache.set(tsconfig.path, alias);
|
|
51
|
-
return alias;
|
|
50
|
+
return { key: tsconfig.path, alias };
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Shared jiti instances, keyed by tsconfig identity (the alias config).
|
|
54
|
+
* Sharing one instance with `moduleCache: true` across the whole build means
|
|
55
|
+
* the module graph behind schema files (zod itself, shared helpers, ...) is
|
|
56
|
+
* executed roughly once per build instead of once per transformed file.
|
|
57
|
+
*/
|
|
58
|
+
const jitiInstances = new Map();
|
|
59
|
+
/**
|
|
60
|
+
* Bumped by invalidateModuleCache(). Bun/Deno use native import, whose module
|
|
61
|
+
* cache cannot be evicted — instead the generation is appended as a query
|
|
62
|
+
* suffix so files re-execute after an invalidation while unchanged builds
|
|
63
|
+
* share a single execution.
|
|
64
|
+
*/
|
|
65
|
+
let cacheGeneration = 0;
|
|
66
|
+
/** Serializes loads so concurrent transforms don't double-execute shared deps. */
|
|
67
|
+
let loadQueue = Promise.resolve();
|
|
68
|
+
const NODE_MODULES_SEGMENT = `${path.sep}node_modules${path.sep}`;
|
|
69
|
+
/**
|
|
70
|
+
* Drop every first-party (non-node_modules) module from the shared loader
|
|
71
|
+
* caches. Called on watch/HMR file changes so the next discovery re-executes
|
|
72
|
+
* changed schema graphs.
|
|
73
|
+
*
|
|
74
|
+
* Eviction is deliberately first-party-wide rather than per-module: jiti's
|
|
75
|
+
* module cache only records importer→dep edges on cache misses, so a precise
|
|
76
|
+
* reverse-dependency walk would miss importers of already-cached modules and
|
|
77
|
+
* serve stale schemas. Evicting all project files (cheap to re-execute) while
|
|
78
|
+
* keeping node_modules (the expensive bulk — zod itself) warm is both correct
|
|
79
|
+
* and fast.
|
|
80
|
+
*/
|
|
81
|
+
export function invalidateModuleCache() {
|
|
82
|
+
cacheGeneration++;
|
|
83
|
+
for (const jiti of jitiInstances.values()) {
|
|
84
|
+
for (const key of Object.keys(jiti.cache)) {
|
|
85
|
+
if (!key.includes(NODE_MODULES_SEGMENT)) {
|
|
86
|
+
delete jiti.cache[key];
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
async function getJiti(absPath) {
|
|
92
|
+
const { key, alias } = resolveLoaderConfig(path.dirname(absPath));
|
|
93
|
+
const existing = jitiInstances.get(key);
|
|
94
|
+
if (existing)
|
|
95
|
+
return existing;
|
|
96
|
+
const { createJiti } = await import("jiti");
|
|
97
|
+
const created = createJiti(pathToFileURL(absPath).href, {
|
|
98
|
+
moduleCache: true,
|
|
99
|
+
alias,
|
|
100
|
+
jsx: true,
|
|
101
|
+
});
|
|
102
|
+
jitiInstances.set(key, created);
|
|
103
|
+
return created;
|
|
52
104
|
}
|
|
53
105
|
/**
|
|
54
106
|
* Dynamically import a source file (.ts or .js).
|
|
55
107
|
* - Bun/Deno: native TypeScript support, direct import
|
|
56
|
-
* - Node.js: uses jiti for reliable TypeScript transpilation
|
|
108
|
+
* - Node.js: uses a shared jiti instance for reliable TypeScript transpilation
|
|
57
109
|
* (handles extensionless imports, enums, path aliases, and all TS syntax)
|
|
110
|
+
*
|
|
111
|
+
* Module executions are cached across calls; use invalidateModuleCache()
|
|
112
|
+
* when source files change (watch/HMR).
|
|
58
113
|
*/
|
|
59
|
-
export async function loadSourceFile(filePath
|
|
114
|
+
export async function loadSourceFile(filePath) {
|
|
60
115
|
const absPath = path.resolve(filePath);
|
|
61
116
|
const runtime = detectRuntime();
|
|
62
|
-
|
|
63
|
-
//
|
|
64
|
-
|
|
117
|
+
// Bun/Deno execute TypeScript natively. .mjs files bypass jiti even on
|
|
118
|
+
// Node (jiti hands them to native import, outside its evictable cache),
|
|
119
|
+
// so the generation suffix is the only way to refresh them.
|
|
120
|
+
if (runtime === "bun" || runtime === "deno" || absPath.endsWith(".mjs")) {
|
|
121
|
+
const suffix = cacheGeneration > 0 ? `?zcGen=${cacheGeneration}` : "";
|
|
65
122
|
return (await import(pathToFileURL(absPath).href + suffix));
|
|
66
123
|
}
|
|
67
|
-
const
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
alias,
|
|
72
|
-
jsx: true,
|
|
73
|
-
});
|
|
74
|
-
return (await jiti.import(absPath));
|
|
124
|
+
const jiti = await getJiti(absPath);
|
|
125
|
+
const load = loadQueue.then(() => jiti.import(absPath));
|
|
126
|
+
loadQueue = load.then(() => undefined, () => undefined);
|
|
127
|
+
return (await load);
|
|
75
128
|
}
|
|
76
129
|
//# 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;AACzC,OAAO,
|
|
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;AACzC,OAAO,EAAc,WAAW,EAAE,MAAM,cAAc,CAAC;AAKvD,SAAS,a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,CAAC,CAAC,CAAC,CAAC,UAAU,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACtE,OAAO,CAAC,MAAM,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,IAAI,GAAG,MAAM,CAAC,CAA4B,CAAC;IACzF,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IACpC,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;IACxD,SAAS,GAAG,IAAI,CAAC,IAAI,CACnB,GAAG,EAAE,CAAC,SAAS,EACf,GAAG,EAAE,CAAC,SAAS,CAChB,CAAC;IACF,OAAO,CAAC,MAAM,IAAI,CAA4B,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check whether a file's exports could include Zod schemas (or compile()
|
|
3
|
+
* results) without executing the file. `filename` selects the TS/JSX
|
|
4
|
+
* transforms; the file does not need to exist on disk.
|
|
5
|
+
*/
|
|
6
|
+
export declare function mayExportSchemas(code: string, filename: string): Promise<boolean>;
|
|
7
|
+
//# sourceMappingURL=static-filter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"static-filter.d.ts","sourceRoot":"","sources":["../src/static-filter.ts"],"names":[],"mappings":"AA2CA;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CA+BvF"}
|
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { pathToFileURL } from "node:url";
|
|
3
|
+
import { parse } from "acorn";
|
|
4
|
+
/** Lazily created jiti instance used only for single-file transpilation. */
|
|
5
|
+
let transformerPromise;
|
|
6
|
+
function getTransformer() {
|
|
7
|
+
transformerPromise ??= import("jiti").then(({ createJiti }) => createJiti(pathToFileURL(path.resolve("__zod-compiler-static-filter__.mjs")).href));
|
|
8
|
+
return transformerPromise;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Check whether a file's exports could include Zod schemas (or compile()
|
|
12
|
+
* results) without executing the file. `filename` selects the TS/JSX
|
|
13
|
+
* transforms; the file does not need to exist on disk.
|
|
14
|
+
*/
|
|
15
|
+
export async function mayExportSchemas(code, filename) {
|
|
16
|
+
let transpiled;
|
|
17
|
+
try {
|
|
18
|
+
const jiti = await getTransformer();
|
|
19
|
+
transpiled = jiti.transform({
|
|
20
|
+
source: code,
|
|
21
|
+
filename,
|
|
22
|
+
ts: /\.[cm]?tsx?$/.test(filename),
|
|
23
|
+
jsx: /\.[cm]?[jt]sx$/.test(filename),
|
|
24
|
+
// async mode keeps top-level await and emits `await jitiImport(...)`
|
|
25
|
+
// instead of failing — statements stay top-level either way.
|
|
26
|
+
async: true,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
// jiti reports parse failures by embedding an error marker in the output
|
|
33
|
+
// instead of throwing. We can't analyze such files — keep them candidates
|
|
34
|
+
// so the real loader surfaces (or tolerates) the failure exactly as before.
|
|
35
|
+
if (transpiled.includes("__JITI_ERROR__"))
|
|
36
|
+
return true;
|
|
37
|
+
let program;
|
|
38
|
+
try {
|
|
39
|
+
// Module mode: the CJS output has no import/export statements, but may
|
|
40
|
+
// contain top-level await (async transform).
|
|
41
|
+
program = parse(transpiled, { ecmaVersion: "latest", sourceType: "module" });
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
return analyzeProgram(program);
|
|
47
|
+
}
|
|
48
|
+
function analyzeProgram(program) {
|
|
49
|
+
// Pass 1: top-level bindings for identifier resolution, plus the set of
|
|
50
|
+
// identifier nodes that are "expected" (declaration ids and exports-chain
|
|
51
|
+
// participants). Pass 2 counts every OTHER reference: a name referenced
|
|
52
|
+
// outside its declaration/export may be mutated after creation
|
|
53
|
+
// (defineProperty, member writes, helper calls), so object/array values
|
|
54
|
+
// it names cannot be proven schema-free.
|
|
55
|
+
const safeDecls = new Set();
|
|
56
|
+
const varInits = new Map();
|
|
57
|
+
const expectedNodes = new Set();
|
|
58
|
+
function recordChainNodes(expr) {
|
|
59
|
+
let node = expr;
|
|
60
|
+
let hasExportTarget = false;
|
|
61
|
+
while (node.type === "AssignmentExpression" && node.operator === "=") {
|
|
62
|
+
if (node.left.type === "Identifier") {
|
|
63
|
+
// Assignment LHS identifiers rebind — they never read the value.
|
|
64
|
+
expectedNodes.add(node.left);
|
|
65
|
+
}
|
|
66
|
+
else if (node.left.type === "MemberExpression" && mentionsExports(node.left)) {
|
|
67
|
+
hasExportTarget = true;
|
|
68
|
+
}
|
|
69
|
+
node = node.right;
|
|
70
|
+
}
|
|
71
|
+
// The bare-identifier value of an export chain (`exports.f = f`) is the
|
|
72
|
+
// export itself; in a plain local chain (`alias = obj`) it is a real
|
|
73
|
+
// aliasing reference and must count toward taint.
|
|
74
|
+
if (hasExportTarget && node.type === "Identifier")
|
|
75
|
+
expectedNodes.add(node);
|
|
76
|
+
}
|
|
77
|
+
for (const stmt of program.body) {
|
|
78
|
+
if (stmt.type === "FunctionDeclaration" || stmt.type === "ClassDeclaration") {
|
|
79
|
+
safeDecls.add(stmt.id.name);
|
|
80
|
+
expectedNodes.add(stmt.id);
|
|
81
|
+
}
|
|
82
|
+
else if (stmt.type === "VariableDeclaration") {
|
|
83
|
+
for (const decl of stmt.declarations) {
|
|
84
|
+
if (decl.id.type === "Identifier") {
|
|
85
|
+
expectedNodes.add(decl.id);
|
|
86
|
+
// The init may be an `exports.X = value` chain — resolution should
|
|
87
|
+
// see the final value expression.
|
|
88
|
+
varInits.set(decl.id.name, decl.init ? unwrapAssignmentChain(decl.init).value : null);
|
|
89
|
+
}
|
|
90
|
+
if (decl.init)
|
|
91
|
+
recordChainNodes(decl.init);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
else if (stmt.type === "ExpressionStatement") {
|
|
95
|
+
recordChainNodes(stmt.expression);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const referencedNames = collectReferencedNames(program, expectedNodes);
|
|
99
|
+
function resolveIdentifier(name, defaultish, seen) {
|
|
100
|
+
if (seen.has(name))
|
|
101
|
+
return "candidate";
|
|
102
|
+
seen.add(name);
|
|
103
|
+
if (safeDecls.has(name))
|
|
104
|
+
return "safe";
|
|
105
|
+
const init = varInits.get(name);
|
|
106
|
+
if (init === undefined || init === null)
|
|
107
|
+
return "candidate";
|
|
108
|
+
return classifyValue(init, defaultish, seen, [name]);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Could this expression evaluate to a Zod schema (an object carrying
|
|
112
|
+
* `_zod.def` or the compile() marker)? `bindingNames` are the local
|
|
113
|
+
* aliases of the value — a mutable container (object/array) is only safe
|
|
114
|
+
* when none of its aliases are referenced elsewhere in the file.
|
|
115
|
+
*/
|
|
116
|
+
function classifyValue(node, defaultish, seen, bindingNames) {
|
|
117
|
+
switch (node.type) {
|
|
118
|
+
case "Literal":
|
|
119
|
+
case "TemplateLiteral":
|
|
120
|
+
case "ArrowFunctionExpression":
|
|
121
|
+
case "FunctionExpression":
|
|
122
|
+
case "ClassExpression":
|
|
123
|
+
case "UnaryExpression":
|
|
124
|
+
case "UpdateExpression":
|
|
125
|
+
case "BinaryExpression":
|
|
126
|
+
return "safe";
|
|
127
|
+
case "ObjectExpression":
|
|
128
|
+
case "ArrayExpression":
|
|
129
|
+
// Discovery unwraps the properties of a default export object (and
|
|
130
|
+
// arrays are objects), so containers are candidates there. Named
|
|
131
|
+
// export containers are never unwrapped — but a container whose
|
|
132
|
+
// alias is referenced elsewhere may be mutated into a schema shape.
|
|
133
|
+
if (defaultish)
|
|
134
|
+
return "candidate";
|
|
135
|
+
return bindingNames.some((n) => referencedNames.has(n)) ? "candidate" : "safe";
|
|
136
|
+
case "Identifier":
|
|
137
|
+
return resolveIdentifier(node.name, defaultish, seen);
|
|
138
|
+
case "ConditionalExpression":
|
|
139
|
+
return classifyValue(node.consequent, defaultish, seen, bindingNames) === "safe" &&
|
|
140
|
+
classifyValue(node.alternate, defaultish, seen, bindingNames) === "safe"
|
|
141
|
+
? "safe"
|
|
142
|
+
: "candidate";
|
|
143
|
+
case "LogicalExpression":
|
|
144
|
+
return classifyValue(node.left, defaultish, seen, bindingNames) === "safe" &&
|
|
145
|
+
classifyValue(node.right, defaultish, seen, bindingNames) === "safe"
|
|
146
|
+
? "safe"
|
|
147
|
+
: "candidate";
|
|
148
|
+
case "SequenceExpression": {
|
|
149
|
+
const last = node.expressions[node.expressions.length - 1];
|
|
150
|
+
return last ? classifyValue(last, defaultish, seen, bindingNames) : "candidate";
|
|
151
|
+
}
|
|
152
|
+
case "AssignmentExpression":
|
|
153
|
+
return classifyValue(unwrapAssignmentChain(node).value, defaultish, seen, bindingNames);
|
|
154
|
+
default:
|
|
155
|
+
// CallExpression, NewExpression, MemberExpression, AwaitExpression, ...
|
|
156
|
+
return "candidate";
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
/** Process one assignment chain: classify the value for each export target. */
|
|
160
|
+
function processAssignment(expr, declaredName) {
|
|
161
|
+
const { targets, value } = unwrapAssignmentChain(expr);
|
|
162
|
+
const bindingNames = declaredName ? [declaredName] : [];
|
|
163
|
+
const exportTargets = [];
|
|
164
|
+
for (const target of targets) {
|
|
165
|
+
const exportTarget = exportTargetOf(target);
|
|
166
|
+
if (exportTarget.kind === "unknown")
|
|
167
|
+
return "candidate";
|
|
168
|
+
if (exportTarget.kind === "local")
|
|
169
|
+
bindingNames.push(exportTarget.name);
|
|
170
|
+
exportTargets.push(exportTarget);
|
|
171
|
+
}
|
|
172
|
+
for (const exportTarget of exportTargets) {
|
|
173
|
+
if (exportTarget.kind === "named") {
|
|
174
|
+
if (classifyValue(value, false, new Set(), bindingNames) === "candidate")
|
|
175
|
+
return "candidate";
|
|
176
|
+
}
|
|
177
|
+
else if (exportTarget.kind === "default") {
|
|
178
|
+
if (classifyValue(value, true, new Set(), bindingNames) === "candidate")
|
|
179
|
+
return "candidate";
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
// Catch-all: the value itself may reference exports in a shape we did
|
|
183
|
+
// not positively classify (e.g. `exports.a = fn(exports.b)`).
|
|
184
|
+
return mentionsExports(value) ? "candidate" : "safe";
|
|
185
|
+
}
|
|
186
|
+
function processVariableDeclaration(stmt) {
|
|
187
|
+
for (const decl of stmt.declarations) {
|
|
188
|
+
if (!decl.init)
|
|
189
|
+
continue;
|
|
190
|
+
if (decl.id.type === "Identifier") {
|
|
191
|
+
if (processAssignment(decl.init, decl.id.name) === "candidate")
|
|
192
|
+
return "candidate";
|
|
193
|
+
}
|
|
194
|
+
else if (mentionsExports(decl.init)) {
|
|
195
|
+
// Destructuring declarators don't export by themselves (babel emits
|
|
196
|
+
// separate `exports.x = x` statements), but be paranoid about any
|
|
197
|
+
// exports reference hiding inside.
|
|
198
|
+
return "candidate";
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return "safe";
|
|
202
|
+
}
|
|
203
|
+
function processStatement(stmt) {
|
|
204
|
+
switch (stmt.type) {
|
|
205
|
+
case "FunctionDeclaration":
|
|
206
|
+
case "ClassDeclaration":
|
|
207
|
+
// Bodies that touch exports (hand-written CJS patterns) are opaque.
|
|
208
|
+
return mentionsExports(stmt) ? "candidate" : "safe";
|
|
209
|
+
case "VariableDeclaration":
|
|
210
|
+
return processVariableDeclaration(stmt);
|
|
211
|
+
case "ExpressionStatement":
|
|
212
|
+
return processExpression(stmt.expression);
|
|
213
|
+
case "EmptyStatement":
|
|
214
|
+
return "safe";
|
|
215
|
+
default:
|
|
216
|
+
// if/try/for/... — babel never emits exports there for ESM input,
|
|
217
|
+
// but hand-written CJS might (`if (x) module.exports = ...`).
|
|
218
|
+
return mentionsExports(stmt) ? "candidate" : "safe";
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
function processExpression(expr) {
|
|
222
|
+
switch (expr.type) {
|
|
223
|
+
case "Literal":
|
|
224
|
+
// Directive prologue ("use strict")
|
|
225
|
+
return "safe";
|
|
226
|
+
case "AssignmentExpression":
|
|
227
|
+
return processAssignment(expr);
|
|
228
|
+
case "SequenceExpression": {
|
|
229
|
+
for (const sub of expr.expressions) {
|
|
230
|
+
if (processExpression(sub) === "candidate")
|
|
231
|
+
return "candidate";
|
|
232
|
+
}
|
|
233
|
+
return "safe";
|
|
234
|
+
}
|
|
235
|
+
case "CallExpression":
|
|
236
|
+
if (isEsModuleMarker(expr))
|
|
237
|
+
return "safe";
|
|
238
|
+
// Other exports-touching calls: re-export getters
|
|
239
|
+
// (Object.defineProperty), `export *` loops, helpers.
|
|
240
|
+
return mentionsExports(expr) ? "candidate" : "safe";
|
|
241
|
+
default:
|
|
242
|
+
return mentionsExports(expr) ? "candidate" : "safe";
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
for (const stmt of program.body) {
|
|
246
|
+
// The CJS output of jiti's transform contains no module declarations,
|
|
247
|
+
// but if one ever appears, treat the file as a candidate.
|
|
248
|
+
if (!isStatement(stmt))
|
|
249
|
+
return true;
|
|
250
|
+
if (processStatement(stmt) === "candidate")
|
|
251
|
+
return true;
|
|
252
|
+
}
|
|
253
|
+
return false;
|
|
254
|
+
}
|
|
255
|
+
function isStatement(node) {
|
|
256
|
+
return !node.type.startsWith("Import") && !node.type.startsWith("Export");
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Unwrap `a = b = c = value` into its assignment targets and final value.
|
|
260
|
+
* Non-assignment expressions return zero targets and themselves as value.
|
|
261
|
+
*/
|
|
262
|
+
function unwrapAssignmentChain(expr) {
|
|
263
|
+
const targets = [];
|
|
264
|
+
let value = expr;
|
|
265
|
+
while (value.type === "AssignmentExpression" && value.operator === "=") {
|
|
266
|
+
targets.push(value.left);
|
|
267
|
+
value = value.right;
|
|
268
|
+
}
|
|
269
|
+
return { targets, value };
|
|
270
|
+
}
|
|
271
|
+
/** Classify an assignment target by what discovery would see. */
|
|
272
|
+
function exportTargetOf(target) {
|
|
273
|
+
if (target.type === "Identifier") {
|
|
274
|
+
if (target.name === "exports" || target.name === "module")
|
|
275
|
+
return { kind: "unknown" };
|
|
276
|
+
return { kind: "local", name: target.name };
|
|
277
|
+
}
|
|
278
|
+
if (target.type !== "MemberExpression") {
|
|
279
|
+
return mentionsExports(target) ? { kind: "unknown" } : { kind: "ignored" };
|
|
280
|
+
}
|
|
281
|
+
const propName = !target.computed && target.property.type === "Identifier"
|
|
282
|
+
? target.property.name
|
|
283
|
+
: target.computed && target.property.type === "Literal"
|
|
284
|
+
? String(target.property.value)
|
|
285
|
+
: null;
|
|
286
|
+
// exports.X = ...
|
|
287
|
+
if (target.object.type === "Identifier" && target.object.name === "exports") {
|
|
288
|
+
if (propName === null)
|
|
289
|
+
return { kind: "unknown" };
|
|
290
|
+
return propName === "default" ? { kind: "default" } : { kind: "named", name: propName };
|
|
291
|
+
}
|
|
292
|
+
// module.exports = ... behaves like a default export after interop:
|
|
293
|
+
// discovery unwraps its properties.
|
|
294
|
+
if (target.object.type === "Identifier" && target.object.name === "module") {
|
|
295
|
+
return propName === "exports" ? { kind: "default" } : { kind: "unknown" };
|
|
296
|
+
}
|
|
297
|
+
// module.exports.X = ...
|
|
298
|
+
if (target.object.type === "MemberExpression" &&
|
|
299
|
+
target.object.object.type === "Identifier" &&
|
|
300
|
+
target.object.object.name === "module" &&
|
|
301
|
+
!target.object.computed &&
|
|
302
|
+
target.object.property.type === "Identifier" &&
|
|
303
|
+
target.object.property.name === "exports") {
|
|
304
|
+
if (propName === null)
|
|
305
|
+
return { kind: "unknown" };
|
|
306
|
+
return propName === "default" ? { kind: "default" } : { kind: "named", name: propName };
|
|
307
|
+
}
|
|
308
|
+
return mentionsExports(target) ? { kind: "unknown" } : { kind: "ignored" };
|
|
309
|
+
}
|
|
310
|
+
/** Object.defineProperty(exports, "__esModule", { value: true }) */
|
|
311
|
+
function isEsModuleMarker(expr) {
|
|
312
|
+
return (expr.type === "CallExpression" &&
|
|
313
|
+
expr.callee.type === "MemberExpression" &&
|
|
314
|
+
expr.callee.object.type === "Identifier" &&
|
|
315
|
+
expr.callee.object.name === "Object" &&
|
|
316
|
+
!expr.callee.computed &&
|
|
317
|
+
expr.callee.property.type === "Identifier" &&
|
|
318
|
+
expr.callee.property.name === "defineProperty" &&
|
|
319
|
+
expr.arguments[0]?.type === "Identifier" &&
|
|
320
|
+
expr.arguments[0].name === "exports" &&
|
|
321
|
+
expr.arguments[1]?.type === "Literal" &&
|
|
322
|
+
expr.arguments[1].value === "__esModule");
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Collect every identifier name used in a reference position, excluding the
|
|
326
|
+
* `expected` nodes (declaration ids and exports-chain participants).
|
|
327
|
+
* Non-reference positions — non-computed member properties, non-computed
|
|
328
|
+
* object/class keys, labels — are skipped. Over-counting (e.g. shadowed
|
|
329
|
+
* names in nested scopes, function params) only makes the filter more
|
|
330
|
+
* conservative, never less safe.
|
|
331
|
+
*/
|
|
332
|
+
function collectReferencedNames(program, expected) {
|
|
333
|
+
const names = new Set();
|
|
334
|
+
const stack = [program];
|
|
335
|
+
while (stack.length > 0) {
|
|
336
|
+
const node = stack.pop();
|
|
337
|
+
if (Array.isArray(node)) {
|
|
338
|
+
for (const item of node)
|
|
339
|
+
stack.push(item);
|
|
340
|
+
continue;
|
|
341
|
+
}
|
|
342
|
+
if (typeof node !== "object" || node === null)
|
|
343
|
+
continue;
|
|
344
|
+
const record = node;
|
|
345
|
+
const type = record["type"];
|
|
346
|
+
if (typeof type !== "string")
|
|
347
|
+
continue;
|
|
348
|
+
if (type === "Identifier") {
|
|
349
|
+
if (!expected.has(node))
|
|
350
|
+
names.add(record["name"]);
|
|
351
|
+
continue;
|
|
352
|
+
}
|
|
353
|
+
for (const [key, value] of Object.entries(record)) {
|
|
354
|
+
if (typeof value !== "object" || value === null)
|
|
355
|
+
continue;
|
|
356
|
+
// Skip non-reference identifier positions.
|
|
357
|
+
if (key === "property" && type === "MemberExpression" && record["computed"] !== true)
|
|
358
|
+
continue;
|
|
359
|
+
if (key === "key" &&
|
|
360
|
+
(type === "Property" || type === "PropertyDefinition" || type === "MethodDefinition") &&
|
|
361
|
+
record["computed"] !== true)
|
|
362
|
+
continue;
|
|
363
|
+
if (key === "label")
|
|
364
|
+
continue;
|
|
365
|
+
stack.push(value);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
return names;
|
|
369
|
+
}
|
|
370
|
+
/** Deep-walk an acorn node for any reference to `exports` or `module`. */
|
|
371
|
+
function mentionsExports(root) {
|
|
372
|
+
const stack = [root];
|
|
373
|
+
while (stack.length > 0) {
|
|
374
|
+
const node = stack.pop();
|
|
375
|
+
if (Array.isArray(node)) {
|
|
376
|
+
for (const item of node)
|
|
377
|
+
stack.push(item);
|
|
378
|
+
continue;
|
|
379
|
+
}
|
|
380
|
+
if (typeof node !== "object" || node === null)
|
|
381
|
+
continue;
|
|
382
|
+
const record = node;
|
|
383
|
+
if (typeof record["type"] === "string") {
|
|
384
|
+
if (record["type"] === "Identifier" &&
|
|
385
|
+
(record["name"] === "exports" || record["name"] === "module")) {
|
|
386
|
+
return true;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
for (const value of Object.values(record)) {
|
|
390
|
+
if (typeof value === "object" && value !== null)
|
|
391
|
+
stack.push(value);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
return false;
|
|
395
|
+
}
|
|
396
|
+
//# sourceMappingURL=static-filter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"static-filter.js","sourceRoot":"","sources":["../src/static-filter.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CA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ACd,CAAC;QACH,CAAC;QACD,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;YAC1C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;gBAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACrE,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
interface ImportBindings {
|
|
2
|
+
/** Every runtime (non-type) imported binding name. */
|
|
3
|
+
all: Set<string>;
|
|
4
|
+
/** Bindings imported from a zod module (usually just `z`). */
|
|
5
|
+
zod: Set<string>;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Collect runtime import bindings with a regex over import statements.
|
|
9
|
+
* Type-only imports and `type` specifiers are excluded — they cannot be
|
|
10
|
+
* referenced at runtime, so excluding them keeps the capture rule sound.
|
|
11
|
+
*/
|
|
12
|
+
export declare function collectImportBindings(code: string): ImportBindings;
|
|
13
|
+
/**
|
|
14
|
+
* Hoist eligible Zod schema expressions to module scope.
|
|
15
|
+
* Returns the rewritten source, or null when nothing was hoisted.
|
|
16
|
+
*/
|
|
17
|
+
export declare function hoistZodSchemas(code: string): string | null;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=hoist.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hoist.d.ts","sourceRoot":"","sources":["../../src/unplugin/hoist.ts"],"names":[],"mappings":"AA8CA,UAAU,cAAc;IACtB,sDAAsD;IACtD,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACjB,8DAA8D;IAC9D,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAClB;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAelE;AAsdD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA+H3D"}
|