zod-compiler 1.27.0 → 2.0.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 +95 -53
- package/dist/core/codegen/build-path.d.ts +12 -1
- package/dist/core/codegen/build-path.d.ts.map +1 -1
- package/dist/core/codegen/build-path.js +47 -9
- package/dist/core/codegen/build-path.js.map +1 -1
- package/dist/core/codegen/context.d.ts +31 -16
- package/dist/core/codegen/context.d.ts.map +1 -1
- package/dist/core/codegen/context.js +43 -18
- package/dist/core/codegen/context.js.map +1 -1
- package/dist/core/codegen/emit-issue.d.ts +17 -20
- package/dist/core/codegen/emit-issue.d.ts.map +1 -1
- package/dist/core/codegen/emit-issue.js +13 -13
- package/dist/core/codegen/emit-issue.js.map +1 -1
- package/dist/core/codegen/index.d.ts.map +1 -1
- package/dist/core/codegen/index.js +9 -7
- package/dist/core/codegen/index.js.map +1 -1
- package/dist/core/codegen/issue-decls.d.ts +41 -7
- package/dist/core/codegen/issue-decls.d.ts.map +1 -1
- package/dist/core/codegen/issue-decls.js +49 -9
- package/dist/core/codegen/issue-decls.js.map +1 -1
- package/dist/core/codegen/schemas/array.js +1 -1
- package/dist/core/codegen/schemas/array.js.map +1 -1
- package/dist/core/codegen/schemas/bigint.d.ts.map +1 -1
- package/dist/core/codegen/schemas/bigint.js +15 -4
- package/dist/core/codegen/schemas/bigint.js.map +1 -1
- package/dist/core/codegen/schemas/catch.d.ts.map +1 -1
- package/dist/core/codegen/schemas/catch.js +3 -2
- package/dist/core/codegen/schemas/catch.js.map +1 -1
- package/dist/core/codegen/schemas/discriminated-union.d.ts.map +1 -1
- package/dist/core/codegen/schemas/discriminated-union.js +2 -1
- package/dist/core/codegen/schemas/discriminated-union.js.map +1 -1
- package/dist/core/codegen/schemas/effect.d.ts.map +1 -1
- package/dist/core/codegen/schemas/effect.js +4 -2
- package/dist/core/codegen/schemas/effect.js.map +1 -1
- package/dist/core/codegen/schemas/file.js +2 -8
- package/dist/core/codegen/schemas/file.js.map +1 -1
- package/dist/core/codegen/schemas/number.js +4 -3
- package/dist/core/codegen/schemas/number.js.map +1 -1
- package/dist/core/codegen/schemas/object.d.ts +11 -1
- package/dist/core/codegen/schemas/object.d.ts.map +1 -1
- package/dist/core/codegen/schemas/object.js +58 -14
- package/dist/core/codegen/schemas/object.js.map +1 -1
- package/dist/core/codegen/schemas/readonly.d.ts.map +1 -1
- package/dist/core/codegen/schemas/readonly.js.map +1 -1
- package/dist/core/codegen/schemas/record.d.ts.map +1 -1
- package/dist/core/codegen/schemas/record.js +8 -3
- package/dist/core/codegen/schemas/record.js.map +1 -1
- package/dist/core/codegen/schemas/sizeable.d.ts +49 -3
- package/dist/core/codegen/schemas/sizeable.d.ts.map +1 -1
- package/dist/core/codegen/schemas/sizeable.js +101 -8
- package/dist/core/codegen/schemas/sizeable.js.map +1 -1
- package/dist/core/codegen/schemas/string.d.ts.map +1 -1
- package/dist/core/codegen/schemas/string.js +45 -16
- package/dist/core/codegen/schemas/string.js.map +1 -1
- package/dist/core/codegen/schemas/tuple.d.ts +14 -11
- package/dist/core/codegen/schemas/tuple.d.ts.map +1 -1
- package/dist/core/codegen/schemas/tuple.js +99 -49
- package/dist/core/codegen/schemas/tuple.js.map +1 -1
- package/dist/core/codegen/well-known-regex.d.ts +7 -0
- package/dist/core/codegen/well-known-regex.d.ts.map +1 -1
- package/dist/core/codegen/well-known-regex.js +10 -3
- package/dist/core/codegen/well-known-regex.js.map +1 -1
- package/dist/core/extract/checks.d.ts.map +1 -1
- package/dist/core/extract/checks.js +1 -0
- package/dist/core/extract/checks.js.map +1 -1
- package/dist/core/extract/extractors/intersection.js +21 -6
- package/dist/core/extract/extractors/intersection.js.map +1 -1
- package/dist/core/extract/extractors/object.d.ts.map +1 -1
- package/dist/core/extract/extractors/object.js +25 -9
- package/dist/core/extract/extractors/object.js.map +1 -1
- package/dist/core/extract/extractors/optional.d.ts.map +1 -1
- package/dist/core/extract/extractors/optional.js +1 -28
- package/dist/core/extract/extractors/optional.js.map +1 -1
- package/dist/core/extract/extractors/record.js +9 -3
- package/dist/core/extract/extractors/record.js.map +1 -1
- package/dist/core/extract/extractors/tuple.d.ts.map +1 -1
- package/dist/core/extract/extractors/tuple.js +16 -20
- package/dist/core/extract/extractors/tuple.js.map +1 -1
- package/dist/core/extract/types.d.ts +16 -8
- package/dist/core/extract/types.d.ts.map +1 -1
- package/dist/core/iife.d.ts +2 -1
- package/dist/core/iife.d.ts.map +1 -1
- package/dist/core/iife.js +2 -1
- package/dist/core/iife.js.map +1 -1
- package/dist/core/types.d.ts +70 -21
- package/dist/core/types.d.ts.map +1 -1
- package/dist/jit.d.ts.map +1 -1
- package/dist/jit.js +47 -12
- package/dist/jit.js.map +1 -1
- package/dist/runtime.d.ts +3 -1
- package/dist/runtime.js +12 -10
- package/dist/swc.d.ts +5 -1
- package/dist/swc.d.ts.map +1 -1
- package/dist/swc.js.map +1 -1
- package/dist/turbopack.d.ts +6 -1
- package/dist/turbopack.d.ts.map +1 -1
- package/dist/turbopack.js.map +1 -1
- package/dist/unplugin/disk-cache.d.ts.map +1 -1
- package/dist/unplugin/disk-cache.js +1 -0
- package/dist/unplugin/disk-cache.js.map +1 -1
- package/dist/unplugin/index.d.ts.map +1 -1
- package/dist/unplugin/index.js +56 -9
- package/dist/unplugin/index.js.map +1 -1
- package/dist/unplugin/pool-worker.d.ts +1 -0
- package/dist/unplugin/pool-worker.js +116 -0
- package/dist/unplugin/pool-worker.js.map +1 -0
- package/dist/unplugin/pool.d.ts +162 -0
- package/dist/unplugin/pool.d.ts.map +1 -0
- package/dist/unplugin/pool.js +445 -0
- package/dist/unplugin/pool.js.map +1 -0
- package/dist/unplugin/transform.d.ts +2 -1
- package/dist/unplugin/transform.d.ts.map +1 -1
- package/dist/unplugin/transform.js +1 -1
- package/dist/unplugin/transform.js.map +1 -1
- package/dist/unplugin/types.d.ts +36 -1
- package/dist/unplugin/types.d.ts.map +1 -1
- package/dist/unplugin/types.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/unplugin/index.ts"],"sourcesContent":["import process from \"node:process\";\nimport { createUnplugin, type UnpluginContextMeta } from \"unplugin\";\nimport type { CodegenMode } from \"../core/codegen/context.js\";\nimport { getFirstPartyModulePaths, invalidateModuleCache } from \"../loader.js\";\nimport { collectStaticDeps, resetDepGraphMemo } from \"./dep-graph.js\";\nimport { DiskCache, resetDepValidationMemo } from \"./disk-cache.js\";\nimport {\n log,\n shouldTransform,\n TRANSFORM_ID_FILTER,\n transformCodeFilter,\n type TransformSourceMap,\n transformCodeWithMap,\n} from \"./transform.js\";\nimport type { BuildStats, ZodCompilerPluginOptions } from \"./types.js\";\nimport { BuildStatsAccumulator } from \"./types.js\";\nimport {\n loadVirtual,\n RESOLVED_RUNTIME_ID_FILTER,\n resolveVirtualId,\n RUNTIME_SPECIFIER_FILTER,\n VIRTUAL_RUNTIME_ID,\n WP_RUNTIME_ID,\n} from \"./virtual.js\";\n\n/**\n * Frameworks whose resolveId/load hooks receive any import specifier, including\n * `virtual:` URIs and bare specifiers, so lean-mode cross-file dedup works.\n * webpack / rspack reject the `virtual:` URI scheme but accept bare specifiers,\n * so they use WP_RUNTIME_ID (`__zod-compiler-runtime__`) instead of VIRTUAL_RUNTIME_ID.\n */\nconst VIRTUAL_MODULE_FRAMEWORKS = new Set([\n \"vite\",\n \"rollup\",\n \"rolldown\",\n \"esbuild\",\n \"farm\",\n \"bun\",\n \"rspack\",\n \"webpack\",\n]);\n\n/** Frameworks that need the bare-specifier runtime ID instead of `virtual:`. */\nconst WP_FRAMEWORKS = new Set([\"rspack\", \"webpack\"]);\n\n/** File extensions whose changes can affect a schema module graph. */\nconst SOURCE_LIKE = /\\.([cm]?[jt]sx?|json)$/;\n\n/**\n * esbuild has no hook-filter support of its own: unplugin registers a single\n * `onLoad` covering both the load and transform hooks, and its transform shim\n * reads the file off disk before any JS-side filter runs. `onLoadFilter` is\n * the one filter esbuild itself applies (in Go, before calling into JS), so it\n * carries the union of what either hook can handle — source files for\n * transform, the resolved runtime module for load (derived from the load\n * filter so the two cannot drift; a miss there would leave the lean-mode\n * runtime import unresolved). The hooks' own filters narrow it further.\n */\nconst ESBUILD_LOAD_FILTER = new RegExp(`\\\\.[cm]?[jt]sx?$|${RESOLVED_RUNTIME_ID_FILTER.source}`);\n\nexport const unplugin = createUnplugin(\n (options: ZodCompilerPluginOptions | undefined, meta: UnpluginContextMeta) => {\n const schemasMode = options?.schemas ?? \"auto\";\n const autoDiscover = schemasMode === \"auto\";\n const outputMode = options?.output ?? \"schema\";\n // \"compact\" keeps the Zod schema (its safeParse IS the cold error path) — so\n // it is zod-compatible like \"schema\"; only \"bag\" drops the schema object.\n const zodCompat = outputMode === \"schema\" || outputMode === \"compact\";\n const compact = outputMode === \"compact\";\n const stats = new BuildStatsAccumulator();\n // Transform results keyed by id, validated by content: bundlers re-run\n // transform for the same file (multiple environments, watch rebuilds) —\n // identical content returns the cached result, changed content recomputes.\n const cache = new Map<\n string,\n { code: string; result: string | null; map?: TransformSourceMap | null }\n >();\n const verbose = options?.verbose === true;\n const mode: CodegenMode =\n options?.codegenMode ?? (VIRTUAL_MODULE_FRAMEWORKS.has(meta.framework) ? \"lean\" : \"inline\");\n const runtimeId = WP_FRAMEWORKS.has(meta.framework) ? WP_RUNTIME_ID : VIRTUAL_RUNTIME_ID;\n // Persistent transform-result cache: discovery executes schema files (and\n // their import graphs) in-process, and the in-memory caches die with the\n // process — without a disk cache every test run / build re-pays that cost.\n // Entries self-validate against dep content hashes, so watch invalidation\n // semantics carry across processes.\n const cacheOption = options?.cache ?? true;\n const diskCache =\n cacheOption === false\n ? null\n : new DiskCache(\n DiskCache.resolveDir(cacheOption),\n JSON.stringify({\n mode,\n runtimeId,\n output: outputMode,\n schemas: schemasMode,\n hoist:\n typeof options?.hoist === \"object\"\n ? String(options.hoist.schemaNamePattern ?? \"default\")\n : (options?.hoist ?? true),\n }),\n getFirstPartyModulePaths,\n );\n // Vite only (other bundlers ignore the field): when the plugin runs.\n // The default compiles production builds AND test runs — tests should\n // exercise (and benefit from) the validators that ship — while plain dev\n // servers skip AOT cost and use the Zod fallback. Vitest runs Vite in\n // serve mode but is detectable via the VITEST env var / \"test\" mode.\n const viteApply =\n options?.apply === \"all\"\n ? undefined\n : (options?.apply ??\n ((_config: unknown, env: { command: string; mode: string }) =>\n env.command === \"build\" || env.mode === \"test\" || process.env[\"VITEST\"] !== undefined));\n\n // Hook filters (unplugin object hooks): bundlers that support them\n // natively — Rolldown, Vite, Rollup 4.40+ — reject a module before ever\n // calling into JS, and unplugin applies the same patterns itself\n // everywhere else. The `code` filter is the big one: a file that never\n // mentions zod cannot produce output, so it no longer costs a hook call,\n // a content hash and an import scan per build.\n const codeFilter = transformCodeFilter(options);\n const transformFilter =\n codeFilter === undefined\n ? { id: TRANSFORM_ID_FILTER }\n : { code: codeFilter, id: TRANSFORM_ID_FILTER };\n\n return {\n name: \"zod-compiler\",\n enforce: \"pre\" as const,\n\n vite: viteApply === undefined ? {} : { apply: viteApply },\n\n esbuild: { onLoadFilter: ESBUILD_LOAD_FILTER },\n\n resolveId: {\n filter: { id: RUNTIME_SPECIFIER_FILTER },\n handler(id: string) {\n return resolveVirtualId(id);\n },\n },\n\n load: {\n filter: { id: RESOLVED_RUNTIME_ID_FILTER },\n handler(id: string) {\n return loadVirtual(id);\n },\n },\n\n transform: {\n filter: transformFilter,\n async handler(code: string, id: string) {\n // The filter covers the static half of shouldTransform(); the\n // include/exclude options — picomatch `contains` semantics, which the\n // native filters do not reproduce — are applied here, as is the whole\n // check for hosts that ignore filters.\n if (!shouldTransform(id, options)) return;\n\n const cached = cache.get(id);\n if (cached && cached.code === code) {\n return cached.result === null\n ? undefined\n : { code: cached.result, map: cached.map ?? null };\n }\n if (cached) {\n // Content changed but no watchChange fired (bundlers without the\n // hook): drop stale module executions before re-discovering.\n invalidateModuleCache();\n }\n\n // Disk cache: skip static-filtering, discovery (file execution!) and\n // codegen entirely when a previous process already transformed this\n // exact content and every dep it executed is unchanged.\n const diskKey = diskCache === null ? null : diskCache.key(id, code);\n if (diskCache !== null && diskKey !== null) {\n const entry = diskCache.load(diskKey);\n if (entry !== null) {\n cache.set(id, { code, result: entry.result, map: entry.map ?? null });\n if (entry.stats) {\n stats.add({\n files: 1,\n schemas: entry.stats.schemas,\n optimized: entry.stats.optimized,\n failed: 0,\n });\n }\n if (verbose && entry.result !== null) {\n log(`Using cached transform for ${id}`);\n }\n return entry.result === null\n ? undefined\n : { code: entry.result, map: entry.map ?? null };\n }\n }\n\n let discoveryRan = false;\n let substantialWork = false;\n let uncacheable = false;\n let fileStats: BuildStats | null = null;\n const output = await transformCodeWithMap(code, id, {\n mode,\n runtimeId,\n verbose,\n zodCompat,\n compact,\n autoDiscover,\n hoist: options?.hoist,\n onDiscovery() {\n discoveryRan = true;\n },\n onSubstantialWork() {\n substantialWork = true;\n },\n onUncacheableResult() {\n uncacheable = true;\n },\n onBuildStats(s) {\n stats.add(s);\n fileStats = s;\n },\n });\n const result = output === null ? null : output.code;\n const map = output === null ? null : output.map;\n cache.set(id, { code, result, map });\n\n // Persist when the transform did real work: produced output, ran\n // discovery, or did parse-level work (hoist scan / static filter) —\n // even when that work concluded \"no transform needed\". Null results\n // used to be skipped on the theory that bail-outs are cheaper than a\n // cache probe; that holds for textual bail-outs (still never\n // persisted) but not for the scans: hoist-only mode re-paid a full\n // scan per zod-importing file per run (35.8s/run in a field report)\n // purely to re-derive nulls.\n if (\n diskCache !== null &&\n diskKey !== null &&\n !uncacheable &&\n (result !== null || discoveryRan || substantialWork)\n ) {\n // TS narrows fileStats to null here (assignment happens inside a\n // callback it cannot track) — widen back.\n const s = fileStats as BuildStats | null;\n const entryStats =\n s === null ? undefined : { schemas: s.schemas, optimized: s.optimized };\n if (!discoveryRan) {\n // Discovery-free results (hoist scans, static-filter rejections,\n // hoist-only rewrites) are pure functions of the file content:\n // no deps.\n diskCache.save(diskKey, result, [], entryStats, map);\n } else {\n // Per-file dependency sets: the file's static first-party import\n // graph, so editing an unrelated file no longer invalidates this\n // entry (the global superset recorded the whole project — in\n // large codebases every commit wiped the entire cache). The\n // entry file itself is always a dep: the cache key hashes the\n // content the BUNDLER passed, but discovery executed the file\n // from DISK — recording it guards the (rare) divergence between\n // the two. When the graph cannot be fully analyzed (non-literal\n // dynamic imports, unresolvable relative specifiers), the entry\n // is deferred and flushed in buildEnd against ONE end-of-build\n // executed-modules superset — immediate snapshots gave every\n // entry a distinct point-in-time copy (283 MB in the field).\n const staticDeps = collectStaticDeps(id);\n if (staticDeps.complete) {\n diskCache.save(diskKey, result, [id, ...staticDeps.deps], entryStats, map);\n } else {\n diskCache.saveDeferred(diskKey, result, entryStats, map);\n }\n }\n }\n\n if (!result) return;\n return { code: result, map };\n },\n },\n\n watchChange(id: string) {\n if (!SOURCE_LIKE.test(id)) return;\n if (id.includes(\"node_modules\")) return;\n // The changed file may be a dependency of any schema file, so both\n // the module cache (executions) and the transform result cache are\n // invalidated wholesale. node_modules stay warm in the loader. Disk\n // cache entries self-validate via dep hashes — only the per-process\n // stat memo needs resetting so changed files re-hash. Pending\n // deferred entries predate the change and must not flush against\n // post-change dep hashes.\n invalidateModuleCache();\n resetDepValidationMemo();\n resetDepGraphMemo();\n diskCache?.dropDeferred();\n cache.clear();\n },\n\n buildEnd() {\n // The loader's executed-modules superset is final here — persist the\n // queued incomplete-crawl entries against one shared snapshot.\n diskCache?.flushDeferred();\n if (!verbose) return;\n if (stats.schemas === 0) return;\n log(\n `Build summary: ${stats.optimized}/${stats.schemas} schemas optimized across ${stats.files} file(s)` +\n (stats.failed > 0 ? `, ${stats.failed} failed` : \"\"),\n );\n stats.reset();\n },\n };\n },\n);\n\nexport type { ZodCompilerPluginOptions } from \"./types.js\";\n"],"mappings":";;;;;;;;;;;;;;;AA+BA,MAAM,4CAA4B,IAAI,IAAI;CACxC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;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node:process\";\nimport { createUnplugin, type UnpluginContextMeta } from \"unplugin\";\nimport type { CodegenMode } from \"../core/codegen/context.js\";\nimport { getFirstPartyModulePaths, invalidateModuleCache } from \"../loader.js\";\nimport { collectStaticDeps, resetDepGraphMemo } from \"./dep-graph.js\";\nimport { DiskCache, resetDepValidationMemo } from \"./disk-cache.js\";\nimport {\n poolTransformOptions,\n PoolUnavailableError,\n resolvePoolSize,\n TransformPool,\n} from \"./pool.js\";\nimport {\n log,\n shouldTransform,\n TRANSFORM_ID_FILTER,\n transformCodeFilter,\n type TransformOutput,\n type TransformSourceMap,\n transformCodeWithMap,\n warn,\n} from \"./transform.js\";\nimport type { BuildStats, TransformOptions, ZodCompilerPluginOptions } from \"./types.js\";\nimport { BuildStatsAccumulator } from \"./types.js\";\nimport {\n loadVirtual,\n RESOLVED_RUNTIME_ID_FILTER,\n resolveVirtualId,\n RUNTIME_SPECIFIER_FILTER,\n VIRTUAL_RUNTIME_ID,\n WP_RUNTIME_ID,\n} from \"./virtual.js\";\n\n/**\n * Frameworks whose resolveId/load hooks receive any import specifier, including\n * `virtual:` URIs and bare specifiers, so lean-mode cross-file dedup works.\n * webpack / rspack reject the `virtual:` URI scheme but accept bare specifiers,\n * so they use WP_RUNTIME_ID (`__zod-compiler-runtime__`) instead of VIRTUAL_RUNTIME_ID.\n */\nconst VIRTUAL_MODULE_FRAMEWORKS = new Set([\n \"vite\",\n \"rollup\",\n \"rolldown\",\n \"esbuild\",\n \"farm\",\n \"bun\",\n \"rspack\",\n \"webpack\",\n]);\n\n/** Frameworks that need the bare-specifier runtime ID instead of `virtual:`. */\nconst WP_FRAMEWORKS = new Set([\"rspack\", \"webpack\"]);\n\n/** File extensions whose changes can affect a schema module graph. */\nconst SOURCE_LIKE = /\\.([cm]?[jt]sx?|json)$/;\n\n/**\n * esbuild has no hook-filter support of its own: unplugin registers a single\n * `onLoad` covering both the load and transform hooks, and its transform shim\n * reads the file off disk before any JS-side filter runs. `onLoadFilter` is\n * the one filter esbuild itself applies (in Go, before calling into JS), so it\n * carries the union of what either hook can handle — source files for\n * transform, the resolved runtime module for load (derived from the load\n * filter so the two cannot drift; a miss there would leave the lean-mode\n * runtime import unresolved). The hooks' own filters narrow it further.\n */\nconst ESBUILD_LOAD_FILTER = new RegExp(`\\\\.[cm]?[jt]sx?$|${RESOLVED_RUNTIME_ID_FILTER.source}`);\n\nexport const unplugin = createUnplugin(\n (options: ZodCompilerPluginOptions | undefined, meta: UnpluginContextMeta) => {\n const schemasMode = options?.schemas ?? \"auto\";\n const autoDiscover = schemasMode === \"auto\";\n const outputMode = options?.output ?? \"schema\";\n // \"compact\" keeps the Zod schema (its safeParse IS the cold error path) — so\n // it is zod-compatible like \"schema\"; only \"bag\" drops the schema object.\n const zodCompat = outputMode === \"schema\" || outputMode === \"compact\";\n const compact = outputMode === \"compact\";\n const stats = new BuildStatsAccumulator();\n // Transform results keyed by id, validated by content: bundlers re-run\n // transform for the same file (multiple environments, watch rebuilds) —\n // identical content returns the cached result, changed content recomputes.\n const cache = new Map<\n string,\n { code: string; result: string | null; map?: TransformSourceMap | null }\n >();\n const verbose = options?.verbose === true;\n const mode: CodegenMode =\n options?.codegenMode ?? (VIRTUAL_MODULE_FRAMEWORKS.has(meta.framework) ? \"lean\" : \"inline\");\n const runtimeId = WP_FRAMEWORKS.has(meta.framework) ? WP_RUNTIME_ID : VIRTUAL_RUNTIME_ID;\n // Persistent transform-result cache: discovery executes schema files (and\n // their import graphs) in-process, and the in-memory caches die with the\n // process — without a disk cache every test run / build re-pays that cost.\n // Entries self-validate against dep content hashes, so watch invalidation\n // semantics carry across processes.\n const cacheOption = options?.cache ?? true;\n // Opt-in worker pool. Null when disabled, or when the worker entry cannot\n // be located (the plugin has been bundled into a single file by a\n // consumer) — transforms then run in-process exactly as before.\n const poolSize = resolvePoolSize(options?.parallel);\n const pool = TransformPool.create(poolSize);\n /** Dedupes the in-process-fallback warning to one per build. */\n let warnedPoolFallback = false;\n if (poolSize > 0 && pool === null) {\n warn(\n \"parallel was requested but the transform worker entry could not be located \" +\n \"(is zod-compiler bundled into your build?). Falling back to in-process transforms.\",\n );\n }\n /**\n * Executed-module superset for the disk cache's deferred entries.\n *\n * With a pool, discovery happens in the workers, so this process's own\n * loader has executed nothing and `getFirstPartyModulePaths()` alone would\n * report an empty (or absent) set — silently dropping every deferred\n * entry, which on large graphs is most of them. Both sides are unioned:\n * the workers' reports, plus anything the in-process fallback executed\n * here. A worker that cannot track modules at all (Bun/Deno native import)\n * reports null, and null wins — the cache declines to persist rather than\n * record a set it knows is incomplete.\n */\n const executedModuleSuperset = (): string[] | null => {\n const local = getFirstPartyModulePaths();\n if (pool === null) return local;\n const remote = pool.firstPartyModulePaths();\n if (remote === null) return null;\n if (local === null) return remote;\n return [...new Set([...local, ...remote])];\n };\n const diskCache =\n cacheOption === false\n ? null\n : new DiskCache(\n DiskCache.resolveDir(cacheOption),\n JSON.stringify({\n mode,\n runtimeId,\n output: outputMode,\n schemas: schemasMode,\n hoist:\n typeof options?.hoist === \"object\"\n ? String(options.hoist.schemaNamePattern ?? \"default\")\n : (options?.hoist ?? true),\n }),\n executedModuleSuperset,\n );\n // Vite only (other bundlers ignore the field): when the plugin runs.\n // The default compiles production builds AND test runs — tests should\n // exercise (and benefit from) the validators that ship — while plain dev\n // servers skip AOT cost and use the Zod fallback. Vitest runs Vite in\n // serve mode but is detectable via the VITEST env var / \"test\" mode.\n const viteApply =\n options?.apply === \"all\"\n ? undefined\n : (options?.apply ??\n ((_config: unknown, env: { command: string; mode: string }) =>\n env.command === \"build\" || env.mode === \"test\" || process.env[\"VITEST\"] !== undefined));\n\n // Hook filters (unplugin object hooks): bundlers that support them\n // natively — Rolldown, Vite, Rollup 4.40+ — reject a module before ever\n // calling into JS, and unplugin applies the same patterns itself\n // everywhere else. The `code` filter is the big one: a file that never\n // mentions zod cannot produce output, so it no longer costs a hook call,\n // a content hash and an import scan per build.\n const codeFilter = transformCodeFilter(options);\n const transformFilter =\n codeFilter === undefined\n ? { id: TRANSFORM_ID_FILTER }\n : { code: codeFilter, id: TRANSFORM_ID_FILTER };\n\n return {\n name: \"zod-compiler\",\n enforce: \"pre\" as const,\n\n vite: viteApply === undefined ? {} : { apply: viteApply },\n\n esbuild: { onLoadFilter: ESBUILD_LOAD_FILTER },\n\n resolveId: {\n filter: { id: RUNTIME_SPECIFIER_FILTER },\n handler(id: string) {\n return resolveVirtualId(id);\n },\n },\n\n load: {\n filter: { id: RESOLVED_RUNTIME_ID_FILTER },\n handler(id: string) {\n return loadVirtual(id);\n },\n },\n\n transform: {\n filter: transformFilter,\n async handler(code: string, id: string) {\n // The filter covers the static half of shouldTransform(); the\n // include/exclude options — picomatch `contains` semantics, which the\n // native filters do not reproduce — are applied here, as is the whole\n // check for hosts that ignore filters.\n if (!shouldTransform(id, options)) return;\n\n const cached = cache.get(id);\n if (cached && cached.code === code) {\n return cached.result === null\n ? undefined\n : { code: cached.result, map: cached.map ?? null };\n }\n if (cached) {\n // Content changed but no watchChange fired (bundlers without the\n // hook): drop stale module executions before re-discovering.\n invalidateModuleCache();\n }\n\n // Disk cache: skip static-filtering, discovery (file execution!) and\n // codegen entirely when a previous process already transformed this\n // exact content and every dep it executed is unchanged.\n const diskKey = diskCache === null ? null : diskCache.key(id, code);\n if (diskCache !== null && diskKey !== null) {\n const entry = diskCache.load(diskKey);\n if (entry !== null) {\n cache.set(id, { code, result: entry.result, map: entry.map ?? null });\n if (entry.stats) {\n stats.add({\n files: 1,\n schemas: entry.stats.schemas,\n optimized: entry.stats.optimized,\n failed: 0,\n });\n }\n if (verbose && entry.result !== null) {\n log(`Using cached transform for ${id}`);\n }\n return entry.result === null\n ? undefined\n : { code: entry.result, map: entry.map ?? null };\n }\n }\n\n const transformOptions: TransformOptions = {\n mode,\n runtimeId,\n verbose,\n zodCompat,\n compact,\n autoDiscover,\n hoist: options?.hoist,\n };\n\n let discoveryRan = false;\n let substantialWork = false;\n let uncacheable = false;\n let fileStats: BuildStats | null = null;\n\n const inProcess = async (): Promise<TransformOutput | null> =>\n transformCodeWithMap(code, id, {\n ...transformOptions,\n onDiscovery() {\n discoveryRan = true;\n },\n onSubstantialWork() {\n substantialWork = true;\n },\n onUncacheableResult() {\n uncacheable = true;\n },\n onBuildStats(s) {\n fileStats = s;\n },\n });\n\n let output: TransformOutput | null;\n if (pool === null) {\n output = await inProcess();\n } else {\n try {\n // The worker reports through flags what the in-process path\n // reports through callbacks; everything downstream reads the\n // same four values either way.\n const r = await pool.run(code, id, poolTransformOptions(transformOptions));\n output = r.output;\n discoveryRan = r.discoveryRan;\n substantialWork = r.substantialWork;\n uncacheable = r.uncacheable;\n fileStats = r.stats;\n } catch (error) {\n // A transform's own error propagates — it will fail identically\n // in-process, and retrying would only pay discovery twice. Only\n // a pool fault (a worker that died holding this task) is worth\n // redoing on this thread, so a single unhealthy worker degrades\n // the build's speed rather than breaking it.\n if (!(error instanceof PoolUnavailableError)) throw error;\n // Once per build. A pool that is broken rather than unlucky\n // fails for every remaining file, and a warning per file would\n // bury the build's real output under thousands of copies.\n if (!warnedPoolFallback) {\n warnedPoolFallback = true;\n warn(\n `${error.message} — compiling ${id} in-process instead. ` +\n `Later files take the same path without repeating this warning.`,\n );\n }\n output = await inProcess();\n }\n }\n\n if (fileStats !== null) stats.add(fileStats);\n const result = output === null ? null : output.code;\n const map = output === null ? null : output.map;\n cache.set(id, { code, result, map });\n\n // Persist when the transform did real work: produced output, ran\n // discovery, or did parse-level work (hoist scan / static filter) —\n // even when that work concluded \"no transform needed\". Null results\n // used to be skipped on the theory that bail-outs are cheaper than a\n // cache probe; that holds for textual bail-outs (still never\n // persisted) but not for the scans: hoist-only mode re-paid a full\n // scan per zod-importing file per run (35.8s/run in a field report)\n // purely to re-derive nulls.\n if (\n diskCache !== null &&\n diskKey !== null &&\n !uncacheable &&\n (result !== null || discoveryRan || substantialWork)\n ) {\n // TS narrows fileStats to null here (assignment happens inside a\n // callback it cannot track) — widen back.\n const s = fileStats as BuildStats | null;\n const entryStats =\n s === null ? undefined : { schemas: s.schemas, optimized: s.optimized };\n if (!discoveryRan) {\n // Discovery-free results (hoist scans, static-filter rejections,\n // hoist-only rewrites) are pure functions of the file content:\n // no deps.\n diskCache.save(diskKey, result, [], entryStats, map);\n } else {\n // Per-file dependency sets: the file's static first-party import\n // graph, so editing an unrelated file no longer invalidates this\n // entry (the global superset recorded the whole project — in\n // large codebases every commit wiped the entire cache). The\n // entry file itself is always a dep: the cache key hashes the\n // content the BUNDLER passed, but discovery executed the file\n // from DISK — recording it guards the (rare) divergence between\n // the two. When the graph cannot be fully analyzed (non-literal\n // dynamic imports, unresolvable relative specifiers), the entry\n // is deferred and flushed in buildEnd against ONE end-of-build\n // executed-modules superset — immediate snapshots gave every\n // entry a distinct point-in-time copy (283 MB in the field).\n const staticDeps = collectStaticDeps(id);\n if (staticDeps.complete) {\n diskCache.save(diskKey, result, [id, ...staticDeps.deps], entryStats, map);\n } else {\n diskCache.saveDeferred(diskKey, result, entryStats, map);\n }\n }\n }\n\n if (!result) return;\n return { code: result, map };\n },\n },\n\n watchChange(id: string) {\n if (!SOURCE_LIKE.test(id)) return;\n if (id.includes(\"node_modules\")) return;\n // The changed file may be a dependency of any schema file, so both\n // the module cache (executions) and the transform result cache are\n // invalidated wholesale. node_modules stay warm in the loader. Disk\n // cache entries self-validate via dep hashes — only the per-process\n // stat memo needs resetting so changed files re-hash. Pending\n // deferred entries predate the change and must not flush against\n // post-change dep hashes.\n invalidateModuleCache();\n // Workers hold their own module caches; the broadcast is ordered ahead\n // of every transform posted after this point.\n pool?.invalidate();\n resetDepValidationMemo();\n resetDepGraphMemo();\n diskCache?.dropDeferred();\n cache.clear();\n },\n\n buildEnd() {\n // The loader's executed-modules superset is final here — persist the\n // queued incomplete-crawl entries against one shared snapshot.\n diskCache?.flushDeferred();\n if (!verbose) return;\n if (stats.schemas === 0) return;\n log(\n `Build summary: ${stats.optimized}/${stats.schemas} schemas optimized across ${stats.files} file(s)` +\n (stats.failed > 0 ? `, ${stats.fail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AO,OAAO,OAAO;IAC5C,MAAM,IAAI,IAAI;KAAE;KAAM;KAAQ;IAAI,CAAC;IAUnC,IACE,cAAc,QACd,YAAY,QACZ,CAAC,gBACA,WAAW,QAAQ,gBAAgB,kBACpC;KAGA,MAAM,IAAI;KACV,MAAM,aACJ,MAAM,OAAO,KAAA,IAAY;MAAE,SAAS,EAAE;MAAS,WAAW,EAAE;KAAU;KACxE,IAAI,CAAC,cAIH,UAAU,KAAK,SAAS,QAAQ,CAAC,GAAG,YAAY,GAAG;UAC9C;MAaL,MAAM,aAAa,kBAAkB,EAAE;MACvC,IAAI,WAAW,UACb,UAAU,KAAK,SAAS,QAAQ,CAAC,IAAI,GAAG,WAAW,IAAI,GAAG,YAAY,GAAG;WAEzE,UAAU,aAAa,SAAS,QAAQ,YAAY,GAAG;KAE3D;IACF;IAEA,IAAI,CAAC,QAAQ;IACb,OAAO;KAAE,MAAM;KAAQ;IAAI;GAC7B;EACF;EAEA,YAAY,IAAY;GACtB,IAAI,CAAC,YAAY,KAAK,EAAE,GAAG;GAC3B,IAAI,GAAG,SAAS,cAAc,GAAG;GAQjC,sBAAsB;GAGtB,MAAM,WAAW;GACjB,uBAAuB;GACvB,kBAAkB;GAClB,WAAW,aAAa;GACxB,MAAM,MAAM;EACd;EAEA,WAAW;GAGT,WAAW,cAAc;GACzB,IAAI,CAAC,SAAS;GACd,IAAI,MAAM,YAAY,GAAG;GACzB,IACE,kBAAkB,MAAM,UAAU,GAAG,MAAM,QAAQ,4BAA4B,MAAM,MAAM,aACxF,MAAM,SAAS,IAAI,KAAK,MAAM,OAAO,WAAW,GACrD;GACA,MAAM,MAAM;EACd;CACF;AACF,CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { getFirstPartyModulePaths, invalidateModuleCache } from "../loader.js";
|
|
2
|
+
import { transformCodeWithMap } from "./transform.js";
|
|
3
|
+
import { parentPort } from "node:worker_threads";
|
|
4
|
+
//#region src/unplugin/pool-worker.ts
|
|
5
|
+
/**
|
|
6
|
+
* Worker entry for the transform pool (see ./pool.ts).
|
|
7
|
+
*
|
|
8
|
+
* One transform at a time, on its own module graph. The worker owns a private
|
|
9
|
+
* loader — its own jiti instance, its own zod, its own execution cache — which
|
|
10
|
+
* is what makes running several of these concurrently sound: the serialization
|
|
11
|
+
* inside ../loader.ts exists to stop concurrent transforms from double-
|
|
12
|
+
* executing a SHARED dependency, and nothing is shared across threads.
|
|
13
|
+
*
|
|
14
|
+
* The protocol deliberately carries no callbacks. In-process, the transform
|
|
15
|
+
* reports progress through `onDiscovery`/`onSubstantialWork`/
|
|
16
|
+
* `onUncacheableResult`/`onBuildStats`, all of which the disk cache reads to
|
|
17
|
+
* decide whether and how to persist. Functions do not survive structured
|
|
18
|
+
* cloning, so they are collapsed here into flags on a single reply — the main
|
|
19
|
+
* thread reconstructs exactly the decisions it would have made.
|
|
20
|
+
*/
|
|
21
|
+
const port = parentPort;
|
|
22
|
+
if (port === null) throw new Error("zod-compiler pool worker was started outside a worker thread");
|
|
23
|
+
/**
|
|
24
|
+
* Paths already reported to the pool. The executed-module list grows into the
|
|
25
|
+
* thousands on a real project and the main thread only needs the union, so
|
|
26
|
+
* each reply carries the delta since the last one rather than the whole set.
|
|
27
|
+
*/
|
|
28
|
+
let reported = /* @__PURE__ */ new Set();
|
|
29
|
+
/**
|
|
30
|
+
* Modules executed since the previous report, or null when this runtime cannot
|
|
31
|
+
* track them at all (Bun/Deno use native import, whose cache cannot be
|
|
32
|
+
* enumerated or evicted). Null propagates: the pool stops offering a superset
|
|
33
|
+
* and the disk cache declines to persist deferred entries, which is what the
|
|
34
|
+
* in-process path already does on those runtimes.
|
|
35
|
+
*/
|
|
36
|
+
function moduleDelta() {
|
|
37
|
+
const all = getFirstPartyModulePaths();
|
|
38
|
+
if (all === null) return null;
|
|
39
|
+
const delta = [];
|
|
40
|
+
for (const p of all) if (!reported.has(p)) {
|
|
41
|
+
reported.add(p);
|
|
42
|
+
delta.push(p);
|
|
43
|
+
}
|
|
44
|
+
return delta;
|
|
45
|
+
}
|
|
46
|
+
async function handleTransform(request) {
|
|
47
|
+
let discoveryRan = false;
|
|
48
|
+
let substantialWork = false;
|
|
49
|
+
let uncacheable = false;
|
|
50
|
+
let stats = null;
|
|
51
|
+
try {
|
|
52
|
+
const result = {
|
|
53
|
+
output: await transformCodeWithMap(request.code, request.id, {
|
|
54
|
+
...request.options,
|
|
55
|
+
onDiscovery() {
|
|
56
|
+
discoveryRan = true;
|
|
57
|
+
},
|
|
58
|
+
onSubstantialWork() {
|
|
59
|
+
substantialWork = true;
|
|
60
|
+
},
|
|
61
|
+
onUncacheableResult() {
|
|
62
|
+
uncacheable = true;
|
|
63
|
+
},
|
|
64
|
+
onBuildStats(s) {
|
|
65
|
+
stats = s;
|
|
66
|
+
}
|
|
67
|
+
}),
|
|
68
|
+
discoveryRan,
|
|
69
|
+
substantialWork,
|
|
70
|
+
uncacheable,
|
|
71
|
+
stats,
|
|
72
|
+
newModulePaths: moduleDelta()
|
|
73
|
+
};
|
|
74
|
+
return {
|
|
75
|
+
type: "result",
|
|
76
|
+
seq: request.seq,
|
|
77
|
+
result
|
|
78
|
+
};
|
|
79
|
+
} catch (error) {
|
|
80
|
+
const e = error instanceof Error ? error : new Error(String(error));
|
|
81
|
+
return {
|
|
82
|
+
type: "error",
|
|
83
|
+
seq: request.seq,
|
|
84
|
+
name: e.name,
|
|
85
|
+
message: e.message,
|
|
86
|
+
stack: e.stack
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
port.on("message", (request) => {
|
|
91
|
+
if (request.type === "invalidate") {
|
|
92
|
+
invalidateModuleCache();
|
|
93
|
+
reported = /* @__PURE__ */ new Set();
|
|
94
|
+
port.postMessage({
|
|
95
|
+
type: "invalidated",
|
|
96
|
+
seq: request.seq
|
|
97
|
+
});
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
handleTransform(request).then((response) => {
|
|
101
|
+
port.postMessage(response);
|
|
102
|
+
}, (error) => {
|
|
103
|
+
const e = error instanceof Error ? error : new Error(String(error));
|
|
104
|
+
port.postMessage({
|
|
105
|
+
type: "error",
|
|
106
|
+
seq: request.seq,
|
|
107
|
+
name: e.name,
|
|
108
|
+
message: e.message,
|
|
109
|
+
stack: e.stack
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
//#endregion
|
|
114
|
+
export {};
|
|
115
|
+
|
|
116
|
+
//# sourceMappingURL=pool-worker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pool-worker.js","names":[],"sources":["../../src/unplugin/pool-worker.ts"],"sourcesContent":["/**\n * Worker entry for the transform pool (see ./pool.ts).\n *\n * One transform at a time, on its own module graph. The worker owns a private\n * loader — its own jiti instance, its own zod, its own execution cache — which\n * is what makes running several of these concurrently sound: the serialization\n * inside ../loader.ts exists to stop concurrent transforms from double-\n * executing a SHARED dependency, and nothing is shared across threads.\n *\n * The protocol deliberately carries no callbacks. In-process, the transform\n * reports progress through `onDiscovery`/`onSubstantialWork`/\n * `onUncacheableResult`/`onBuildStats`, all of which the disk cache reads to\n * decide whether and how to persist. Functions do not survive structured\n * cloning, so they are collapsed here into flags on a single reply — the main\n * thread reconstructs exactly the decisions it would have made.\n */\n\nimport { parentPort } from \"node:worker_threads\";\nimport { getFirstPartyModulePaths, invalidateModuleCache } from \"../loader.js\";\nimport type { PoolRequest, PoolResponse, PoolTransformResult } from \"./pool.js\";\nimport { transformCodeWithMap } from \"./transform.js\";\nimport type { BuildStats } from \"./types.js\";\n\nconst port = parentPort;\nif (port === null) {\n throw new Error(\"zod-compiler pool worker was started outside a worker thread\");\n}\n\n/**\n * Paths already reported to the pool. The executed-module list grows into the\n * thousands on a real project and the main thread only needs the union, so\n * each reply carries the delta since the last one rather than the whole set.\n */\nlet reported = new Set<string>();\n\n/**\n * Modules executed since the previous report, or null when this runtime cannot\n * track them at all (Bun/Deno use native import, whose cache cannot be\n * enumerated or evicted). Null propagates: the pool stops offering a superset\n * and the disk cache declines to persist deferred entries, which is what the\n * in-process path already does on those runtimes.\n */\nfunction moduleDelta(): string[] | null {\n const all = getFirstPartyModulePaths();\n if (all === null) return null;\n const delta: string[] = [];\n for (const p of all) {\n if (!reported.has(p)) {\n reported.add(p);\n delta.push(p);\n }\n }\n return delta;\n}\n\nasync function handleTransform(\n request: Extract<PoolRequest, { type: \"transform\" }>,\n): Promise<PoolResponse> {\n let discoveryRan = false;\n let substantialWork = false;\n let uncacheable = false;\n let stats: BuildStats | null = null;\n\n try {\n const output = await transformCodeWithMap(request.code, request.id, {\n ...request.options,\n onDiscovery() {\n discoveryRan = true;\n },\n onSubstantialWork() {\n substantialWork = true;\n },\n onUncacheableResult() {\n uncacheable = true;\n },\n onBuildStats(s) {\n stats = s;\n },\n });\n const result: PoolTransformResult = {\n output,\n discoveryRan,\n substantialWork,\n uncacheable,\n // TS cannot see the assignment inside the callback above.\n stats: stats as BuildStats | null,\n newModulePaths: moduleDelta(),\n };\n return { type: \"result\", seq: request.seq, result };\n } catch (error) {\n // The transform's own failures — a schema file that will not load in\n // `schemas: \"explicit\"` mode — must reach the bundler with their original\n // message, so they are forwarded rather than swallowed. The pool rebuilds\n // the Error on the other side; only these three fields survive cloning.\n const e = error instanceof Error ? error : new Error(String(error));\n return { type: \"error\", seq: request.seq, name: e.name, message: e.message, stack: e.stack };\n }\n}\n\nport.on(\"message\", (request: PoolRequest) => {\n if (request.type === \"invalidate\") {\n invalidateModuleCache();\n // The loader just dropped every first-party module, so the next discovery\n // re-executes and must re-report them: a delta against the pre-change set\n // would report nothing and the pool's union would keep paths whose entries\n // are gone. Harmless for cache soundness (a superset only over-\n // invalidates) but it would grow without bound across a long watch session.\n reported = new Set<string>();\n port.postMessage({ type: \"invalidated\", seq: request.seq } satisfies PoolResponse);\n return;\n }\n\n void handleTransform(request).then(\n (response) => {\n port.postMessage(response);\n },\n (error: unknown) => {\n // handleTransform catches its own failures; this is the last resort for\n // a fault in the reply path itself (an output that will not clone).\n const e = error instanceof Error ? error : new Error(String(error));\n port.postMessage({\n type: \"error\",\n seq: request.seq,\n name: e.name,\n message: e.message,\n stack: e.stack,\n } satisfies PoolResponse);\n },\n );\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuBA,MAAM,OAAO;AACb,IAAI,SAAS,MACX,MAAM,IAAI,MAAM,8DAA8D;;;;;;AAQhF,IAAI,2BAAW,IAAI,IAAY;;;;;;;;AAS/B,SAAS,cAA+B;CACtC,MAAM,MAAM,yBAAyB;CACrC,IAAI,QAAQ,MAAM,OAAO;CACzB,MAAM,QAAkB,CAAC;CACzB,KAAK,MAAM,KAAK,KACd,IAAI,CAAC,SAAS,IAAI,CAAC,GAAG;EACpB,SAAS,IAAI,CAAC;EACd,MAAM,KAAK,CAAC;CACd;CAEF,OAAO;AACT;AAEA,eAAe,gBACb,SACuB;CACvB,IAAI,eAAe;CACnB,IAAI,kBAAkB;CACtB,IAAI,cAAc;CAClB,IAAI,QAA2B;CAE/B,IAAI;EAgBF,MAAM,SAA8B;GAClC,QAAA,MAhBmB,qBAAqB,QAAQ,MAAM,QAAQ,IAAI;IAClE,GAAG,QAAQ;IACX,cAAc;KACZ,eAAe;IACjB;IACA,oBAAoB;KAClB,kBAAkB;IACpB;IACA,sBAAsB;KACpB,cAAc;IAChB;IACA,aAAa,GAAG;KACd,QAAQ;IACV;GACF,CAAC;GAGC;GACA;GACA;GAEO;GACP,gBAAgB,YAAY;EAC9B;EACA,OAAO;GAAE,MAAM;GAAU,KAAK,QAAQ;GAAK;EAAO;CACpD,SAAS,OAAO;EAKd,MAAM,IAAI,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;EAClE,OAAO;GAAE,MAAM;GAAS,KAAK,QAAQ;GAAK,MAAM,EAAE;GAAM,SAAS,EAAE;GAAS,OAAO,EAAE;EAAM;CAC7F;AACF;AAEA,KAAK,GAAG,YAAY,YAAyB;CAC3C,IAAI,QAAQ,SAAS,cAAc;EACjC,sBAAsB;EAMtB,2BAAW,IAAI,IAAY;EAC3B,KAAK,YAAY;GAAE,MAAM;GAAe,KAAK,QAAQ;EAAI,CAAwB;EACjF;CACF;CAEA,gBAAqB,OAAO,CAAC,CAAC,MAC3B,aAAa;EACZ,KAAK,YAAY,QAAQ;CAC3B,IACC,UAAmB;EAGlB,MAAM,IAAI,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;EAClE,KAAK,YAAY;GACf,MAAM;GACN,KAAK,QAAQ;GACb,MAAM,EAAE;GACR,SAAS,EAAE;GACX,OAAO,EAAE;EACX,CAAwB;CAC1B,CACF;AACF,CAAC"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { CodegenMode } from "../core/codegen/context.js";
|
|
2
|
+
import { HoistOptions } from "./hoist.js";
|
|
3
|
+
import { BuildStats, TransformOptions } from "./types.js";
|
|
4
|
+
import { TransformSourceMap } from "./transform.js";
|
|
5
|
+
//#region src/unplugin/pool.d.ts
|
|
6
|
+
/** The subset of TransformOptions that survives structured cloning. */
|
|
7
|
+
interface PoolTransformOptions {
|
|
8
|
+
mode: CodegenMode;
|
|
9
|
+
runtimeId?: string | undefined;
|
|
10
|
+
zodCompat?: boolean | undefined;
|
|
11
|
+
compact?: boolean | undefined;
|
|
12
|
+
verbose?: boolean | undefined;
|
|
13
|
+
autoDiscover?: boolean | undefined;
|
|
14
|
+
hoist?: boolean | HoistOptions | undefined;
|
|
15
|
+
}
|
|
16
|
+
/** Main → worker. */
|
|
17
|
+
type PoolRequest = {
|
|
18
|
+
type: "transform";
|
|
19
|
+
seq: number;
|
|
20
|
+
code: string;
|
|
21
|
+
id: string;
|
|
22
|
+
options: PoolTransformOptions;
|
|
23
|
+
} | {
|
|
24
|
+
type: "invalidate";
|
|
25
|
+
seq: number;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* What a worker observed while transforming one file: the output plus the
|
|
29
|
+
* signals the main thread's disk-cache bookkeeping needs, which arrive as
|
|
30
|
+
* callbacks in the in-process path and cannot cross a thread boundary.
|
|
31
|
+
*/
|
|
32
|
+
interface PoolTransformResult {
|
|
33
|
+
output: {
|
|
34
|
+
code: string;
|
|
35
|
+
map: TransformSourceMap | null;
|
|
36
|
+
} | null;
|
|
37
|
+
discoveryRan: boolean;
|
|
38
|
+
substantialWork: boolean;
|
|
39
|
+
uncacheable: boolean;
|
|
40
|
+
stats: BuildStats | null;
|
|
41
|
+
/**
|
|
42
|
+
* First-party modules this worker executed since its last report, or `null`
|
|
43
|
+
* when the worker cannot track them (Bun/Deno native import).
|
|
44
|
+
*/
|
|
45
|
+
newModulePaths: string[] | null;
|
|
46
|
+
}
|
|
47
|
+
/** Worker → main. */
|
|
48
|
+
type PoolResponse = {
|
|
49
|
+
type: "result";
|
|
50
|
+
seq: number;
|
|
51
|
+
result: PoolTransformResult;
|
|
52
|
+
} | {
|
|
53
|
+
type: "error";
|
|
54
|
+
seq: number;
|
|
55
|
+
name: string;
|
|
56
|
+
message: string;
|
|
57
|
+
stack?: string | undefined;
|
|
58
|
+
} | {
|
|
59
|
+
type: "invalidated";
|
|
60
|
+
seq: number;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Raised when the pool itself failed — a worker that would not spawn, or one
|
|
64
|
+
* that died mid-task (OOM is the realistic case; each worker holds a full
|
|
65
|
+
* module graph). Distinct from a transform's own error, which is rethrown with
|
|
66
|
+
* its original identity, because the caller's response differs: an
|
|
67
|
+
* infrastructure failure is worth retrying on the bundler thread, a schema
|
|
68
|
+
* that cannot compile is not.
|
|
69
|
+
*/
|
|
70
|
+
declare class PoolUnavailableError extends Error {
|
|
71
|
+
constructor(message: string, options?: {
|
|
72
|
+
cause?: unknown;
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Resolve `parallel` to a worker count. `false`/`undefined` disable the pool.
|
|
77
|
+
*
|
|
78
|
+
* `true` leaves one core for the bundler itself — it is still parsing,
|
|
79
|
+
* resolving and generating chunks while transforms run — and then caps at
|
|
80
|
+
* {@link MAX_AUTO_WORKERS}.
|
|
81
|
+
*/
|
|
82
|
+
declare function resolvePoolSize(parallel: boolean | number | undefined): number;
|
|
83
|
+
/** Strip the callbacks from TransformOptions; what remains is cloneable. */
|
|
84
|
+
declare function poolTransformOptions(options: TransformOptions): PoolTransformOptions;
|
|
85
|
+
/** Terminate every live transform pool. */
|
|
86
|
+
declare function disposeAllPools(): Promise<void>;
|
|
87
|
+
/**
|
|
88
|
+
* A lazily grown pool of transform workers.
|
|
89
|
+
*
|
|
90
|
+
* Not a general-purpose executor: it knows the transform protocol, and it
|
|
91
|
+
* knows that a broadcast invalidation has to be ordered ahead of every
|
|
92
|
+
* subsequent transform on every worker (per-worker message delivery is FIFO,
|
|
93
|
+
* so posting the broadcast before any later task is sufficient — and the only
|
|
94
|
+
* ordering guarantee available, since a worker mid-transform cannot be
|
|
95
|
+
* interrupted).
|
|
96
|
+
*/
|
|
97
|
+
declare class TransformPool {
|
|
98
|
+
private readonly size;
|
|
99
|
+
private readonly entry;
|
|
100
|
+
private readonly workers;
|
|
101
|
+
private readonly queue;
|
|
102
|
+
/** In-flight requests by seq, so a worker exit can reject exactly its own. */
|
|
103
|
+
private readonly inflight;
|
|
104
|
+
private readonly executedModules;
|
|
105
|
+
/** A worker reported it cannot track executed modules — the union is unusable. */
|
|
106
|
+
private moduleTrackingUnavailable;
|
|
107
|
+
private seq;
|
|
108
|
+
private disposed;
|
|
109
|
+
/** Worker deaths since the last successful result; trips MAX_CONSECUTIVE_FAILURES. */
|
|
110
|
+
private consecutiveFailures;
|
|
111
|
+
/** Set once the breaker trips: every later run() rejects without spawning. */
|
|
112
|
+
private brokenPool;
|
|
113
|
+
private constructor();
|
|
114
|
+
/**
|
|
115
|
+
* Build a pool of `size` workers, or return null when workers are
|
|
116
|
+
* unavailable in this installation (the entry could not be located). Callers
|
|
117
|
+
* treat null as "run in-process".
|
|
118
|
+
*/
|
|
119
|
+
static create(size: number): TransformPool | null;
|
|
120
|
+
/** Transform one file on a worker. Rejects with the transform's own error, or PoolUnavailableError. */
|
|
121
|
+
run(code: string, id: string, options: PoolTransformOptions): Promise<PoolTransformResult>;
|
|
122
|
+
/**
|
|
123
|
+
* Drop every worker's executed-module cache, so the next discovery re-runs
|
|
124
|
+
* changed schema graphs. Mirrors the loader's invalidateModuleCache() for
|
|
125
|
+
* the in-process path; called from watchChange.
|
|
126
|
+
*
|
|
127
|
+
* Fire-and-forget: the broadcast is posted to every live worker before any
|
|
128
|
+
* later transform can be, and per-worker FIFO delivery does the rest. A
|
|
129
|
+
* transform ALREADY executing in a worker keeps its pre-change module cache
|
|
130
|
+
* — the same window the in-process path has, where invalidation lands
|
|
131
|
+
* between awaits — and the main thread's own result cache is cleared
|
|
132
|
+
* alongside, so the file is recomputed either way.
|
|
133
|
+
*/
|
|
134
|
+
invalidate(): void;
|
|
135
|
+
/**
|
|
136
|
+
* Union of the first-party modules every worker has executed, or null when
|
|
137
|
+
* any worker cannot track them. Synchronous, because DiskCache.flushDeferred
|
|
138
|
+
* runs from `buildEnd` and from a process 'exit' hook, where only
|
|
139
|
+
* synchronous work is allowed — which is why workers push deltas rather than
|
|
140
|
+
* answering a query.
|
|
141
|
+
*/
|
|
142
|
+
firstPartyModulePaths(): string[] | null;
|
|
143
|
+
/** Terminate every worker. Pending and queued tasks reject. */
|
|
144
|
+
dispose(): Promise<void>;
|
|
145
|
+
/** Hand a task to an idle worker, grow the pool, or queue it. */
|
|
146
|
+
private dispatch;
|
|
147
|
+
private send;
|
|
148
|
+
private spawn;
|
|
149
|
+
private onMessage;
|
|
150
|
+
/**
|
|
151
|
+
* A worker died — OOM while holding a large module graph is the realistic
|
|
152
|
+
* cause. Its task fails with PoolUnavailableError so the caller can retry
|
|
153
|
+
* in-process, and the worker is dropped from the pool; the next dispatch
|
|
154
|
+
* spawns a replacement.
|
|
155
|
+
*/
|
|
156
|
+
private onWorkerGone;
|
|
157
|
+
private drain;
|
|
158
|
+
private recordModulePaths;
|
|
159
|
+
}
|
|
160
|
+
//#endregion
|
|
161
|
+
export { PoolRequest, PoolResponse, PoolTransformOptions, PoolTransformResult, PoolUnavailableError, TransformPool, disposeAllPools, poolTransformOptions, resolvePoolSize };
|
|
162
|
+
//# sourceMappingURL=pool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pool.d.ts","names":[],"sources":["../../src/unplugin/pool.ts"],"mappings":";;;;;;UA8GiB;EACf,MAAM;EACN;EACA;EACA;EACA;EACA;EACA,kBAAkB;;;KAIR;EACN;EAAmB;EAAa;EAAc;EAAY,SAAS;;EACnE;EAAoB;;;;;;;UAOT;EACf;IAAU;IAAc,KAAK;;EAC7B;EACA;EACA;EACA,OAAO;;;;;EAKP;;;KAIU;EACN;EAAgB;EAAa,QAAQ;;EACrC;EAAe;EAAa;EAAc;EAAiB;;EAC3D;EAAqB;;;;;;;;;;cAUd,6BAA6B;EAC5B,YAAA,iBAAiB;IAAY;;;;;;;;;;iBAa3B,gBAAgB;;iBAUhB,qBAAqB,SAAS,mBAAmB;;iBA4F3C,mBAAmB;;;;;;;;;;;cA0B5B;mBACM;mBACA;mBACA;mBACA;;mBAEA;mBACA;;UAET;UACA;UACA;;UAEA;;UAEA;UAED;;;;;;SAUA,OAAO,eAAe;;EAU7B,IAAI,cAAc,YAAY,SAAS,uBAAuB,QAAQ;;;;;;;;;;;;;EA6BtE;;;;;;;;EAgBA;;EAUM,WAAW;;UAYT;UA0BA;UAUA;UAwBA;;;;;;;UAmCA;UAwBA;UA2BA"}
|