@inlang/paraglide-js 2.28.0 → 2.29.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/bundler-plugins/unplugin.d.ts +4 -1
- package/dist/bundler-plugins/unplugin.js +55 -12
- package/dist/bundler-plugins/unplugin.js.map +1 -1
- package/dist/bundler-plugins/unplugin.test.js +156 -0
- package/dist/bundler-plugins/unplugin.test.js.map +1 -1
- package/dist/bundler-plugins/vite-error-response.test.d.ts +1 -0
- package/dist/bundler-plugins/vite-error-response.test.js +171 -0
- package/dist/bundler-plugins/vite-error-response.test.js.map +1 -0
- package/dist/bundler-plugins/vite.d.ts +8 -0
- package/dist/bundler-plugins/vite.js +14 -5
- package/dist/bundler-plugins/vite.js.map +1 -1
- package/dist/compiler/runtime/localize-url.d.ts +8 -4
- package/dist/compiler/runtime/localize-url.js +12 -8
- package/dist/compiler/runtime/localize-url.js.map +1 -1
- package/dist/compiler/runtime/localize-url.test.js +45 -0
- package/dist/compiler/runtime/localize-url.test.js.map +1 -1
- package/dist/compiler/runtime/type.test.js +41 -0
- package/dist/compiler/runtime/type.test.js.map +1 -1
- package/dist/services/env-variables/index.js +1 -1
- package/dist/services/env-variables/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -32,6 +32,9 @@ export type ParaglidePluginOptions = Omit<Partial<CompilerOptions>, "project"> &
|
|
|
32
32
|
*/
|
|
33
33
|
project: string;
|
|
34
34
|
};
|
|
35
|
-
type
|
|
35
|
+
type UnpluginIntegrationOptions = Pick<CompilerOptions, "outputStructure"> & {
|
|
36
|
+
devErrorResponse?: boolean;
|
|
37
|
+
};
|
|
38
|
+
type UnpluginFactoryWithOptions = (userArgs: ParaglidePluginOptions, meta?: Parameters<UnpluginFactory<ParaglidePluginOptions>>[1], defaults?: UnpluginIntegrationOptions) => ReturnType<UnpluginFactory<ParaglidePluginOptions>>;
|
|
36
39
|
export declare const unpluginFactory: UnpluginFactoryWithOptions;
|
|
37
40
|
export {};
|
|
@@ -366,7 +366,10 @@ export const unpluginFactory = (userArgs, _meta, defaults) => {
|
|
|
366
366
|
let hadActiveConfig = false;
|
|
367
367
|
// Watch-rebuild serialization state (see watchChange).
|
|
368
368
|
let compiling = false;
|
|
369
|
+
let isClosed = false;
|
|
370
|
+
let pendingCompilation;
|
|
369
371
|
const pendingWatchPaths = new Set();
|
|
372
|
+
const pendingCompilationCachePaths = new Set();
|
|
370
373
|
// Options from the most recent successful resolution — reused by input
|
|
371
374
|
// events that cannot have changed them.
|
|
372
375
|
let lastOptions;
|
|
@@ -497,6 +500,7 @@ export const unpluginFactory = (userArgs, _meta, defaults) => {
|
|
|
497
500
|
logger.info(`Re-compiling inlang project... File "${relative(process.cwd(), path)}" has changed.`);
|
|
498
501
|
}
|
|
499
502
|
clearReadFiles();
|
|
503
|
+
pendingCompilationCachePaths.add(getPersistentCachePath(args, outputStructure));
|
|
500
504
|
await compileAndUpdateState({
|
|
501
505
|
state,
|
|
502
506
|
compilerOptions: args,
|
|
@@ -527,6 +531,9 @@ export const unpluginFactory = (userArgs, _meta, defaults) => {
|
|
|
527
531
|
name: PLUGIN_NAME,
|
|
528
532
|
enforce: "pre",
|
|
529
533
|
async buildStart() {
|
|
534
|
+
if (isClosed)
|
|
535
|
+
clearParaglideConfigCache({ projectDir: getProjectDir() });
|
|
536
|
+
isClosed = false;
|
|
530
537
|
addWatchFile = this.addWatchFile?.bind(this);
|
|
531
538
|
try {
|
|
532
539
|
const loaded = await loadActiveConfig();
|
|
@@ -571,27 +578,53 @@ export const unpluginFactory = (userArgs, _meta, defaults) => {
|
|
|
571
578
|
clearViteError();
|
|
572
579
|
}
|
|
573
580
|
},
|
|
574
|
-
|
|
581
|
+
watchChange(path) {
|
|
582
|
+
if (isClosed)
|
|
583
|
+
return pendingCompilation;
|
|
575
584
|
// Serialize rebuilds: bundlers may deliver several watchChange
|
|
576
585
|
// events concurrently (webpack fires once per modified file).
|
|
577
586
|
// Every path is queued — a config event must never be starved by
|
|
578
587
|
// later input events.
|
|
579
588
|
pendingWatchPaths.add(nodeNormalizePath(path));
|
|
580
589
|
if (compiling)
|
|
581
|
-
return;
|
|
590
|
+
return pendingCompilation;
|
|
582
591
|
compiling = true;
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
592
|
+
pendingCompilation = (async () => {
|
|
593
|
+
try {
|
|
594
|
+
while (pendingWatchPaths.size > 0) {
|
|
595
|
+
const batch = [...pendingWatchPaths];
|
|
596
|
+
pendingWatchPaths.clear();
|
|
597
|
+
for (const current of batch) {
|
|
598
|
+
await performWatchRecompile(current);
|
|
599
|
+
}
|
|
589
600
|
}
|
|
590
601
|
}
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
602
|
+
finally {
|
|
603
|
+
try {
|
|
604
|
+
if (isClosed) {
|
|
605
|
+
// Inputs can change after compile reads them but before its
|
|
606
|
+
// digest is taken. Once closing starts, watcher events can
|
|
607
|
+
// no longer repair that mismatch, so neither warm nor cold
|
|
608
|
+
// restarts may reuse caches from this queue.
|
|
609
|
+
state.previousInputsDigest = undefined;
|
|
610
|
+
for (const cachePath of pendingCompilationCachePaths) {
|
|
611
|
+
await (userArgs.fs ?? nodeFs).promises.rm(cachePath, {
|
|
612
|
+
force: true,
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
finally {
|
|
618
|
+
pendingCompilationCachePaths.clear();
|
|
619
|
+
compiling = false;
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
})();
|
|
623
|
+
return pendingCompilation;
|
|
624
|
+
},
|
|
625
|
+
closeBundle() {
|
|
626
|
+
isClosed = true;
|
|
627
|
+
return pendingCompilation;
|
|
595
628
|
},
|
|
596
629
|
vite: {
|
|
597
630
|
config: {
|
|
@@ -611,6 +644,16 @@ export const unpluginFactory = (userArgs, _meta, defaults) => {
|
|
|
611
644
|
},
|
|
612
645
|
configureServer(server) {
|
|
613
646
|
viteServer = server;
|
|
647
|
+
if (defaults?.devErrorResponse) {
|
|
648
|
+
server.middlewares.use((_request, response, next) => {
|
|
649
|
+
if (!viteError)
|
|
650
|
+
return next();
|
|
651
|
+
response.statusCode = 500;
|
|
652
|
+
response.setHeader("Content-Type", "text/plain; charset=utf-8");
|
|
653
|
+
response.setHeader("Cache-Control", "no-store");
|
|
654
|
+
response.end(viteError.err.message);
|
|
655
|
+
});
|
|
656
|
+
}
|
|
614
657
|
server.ws.on("connection", (socket) => {
|
|
615
658
|
if (viteError)
|
|
616
659
|
socket.send(JSON.stringify(viteError));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unplugin.js","sourceRoot":"","sources":["../../src/bundler-plugins/unplugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAA0B,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,MAAM,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAEnE,OAAO,EACN,eAAe,EACf,eAAe,EACf,uBAAuB,GACvB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EAAE,iCAAiC,EAAE,MAAM,0CAA0C,CAAC;AAC7F,OAAO,EACN,iBAAiB,EACjB,yBAAyB,EACzB,gBAAgB,EAChB,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB,GAEtB,MAAM,6BAA6B,CAAC;AAGrC,MAAM,WAAW,GAAG,uBAAuB,CAAC;AAsC5C,MAAM,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;A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C;4BACxC,MAAM,EAAE,IAAI,CAAC,MAAM;4BACnB,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,QAAQ;yBACrB,CAAC,CAAC,CAAC;oBACL,MAAM,qBAAqB,CAAC;wBAC3B,KAAK;wBACL,eAAe,EAAE,IAAI;wBACrB,eAAe;wBACf,mBAAmB,EAAE,cAAc;wBACnC,QAAQ,EAAE,SAAS;qBACnB,CAAC,CAAC;oBACH,MAAM,oBAAoB,CAAC,KAAK,EAAE,IAAI,EAAE,eAAe,CAAC,CAAC;oBACzD,MAAM,CAAC,OAAO,CAAC,yBAAyB,eAAe,GAAG,CAAC,CAAC;gBAC7D,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBAChB,KAAK,CAAC,oBAAoB,GAAG,SAAS,CAAC;oBACvC,MAAM,CAAC,IAAI,CAAC,4BAA4B,EAAG,KAAe,CAAC,OAAO,CAAC,CAAC;oBACpE,MAAM,CAAC,IAAI,CAAC,wDAAwD,CAAC,CAAC;oBACtE,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;wBAAE,MAAM,KAAK,CAAC;gBACxD,CAAC;YACF,CAAC,CAAC,CAAC;QACJ,CAAC;KACD,CAAC;AACH,CAAC,CAAC","sourcesContent":["import type { UnpluginFactory } from \"unplugin\";\nimport { compile, type CompilationResult } from \"../compiler/compile.js\";\nimport { dirname, join, relative, resolve } from \"node:path\";\nimport { createHash } from \"node:crypto\";\nimport nodeFs from \"node:fs\";\nimport { Logger } from \"../services/logger/index.js\";\nimport { ENV_VARIABLES } from \"../services/env-variables/index.js\";\nimport type { CompilerOptions } from \"../compiler/compiler-options.js\";\nimport {\n\tcreateTrackedFs,\n\tgetWatchTargets,\n\tisPathWithinDirectories,\n} from \"../services/file-watching/tracked-fs.js\";\nimport { nodeNormalizePath } from \"../utilities/node-normalize-path.js\";\nimport { seedPreviousCompilationFromOutdir } from \"../compiler/seed-previous-compilation.js\";\nimport {\n\tCONFIG_FILE_NAMES,\n\tclearParaglideConfigCache,\n\tisConfigFileName,\n\tloadParaglideConfig,\n\tresolveCompilerOptions,\n\tresolveConfigCandidate,\n\ttype LoadedParaglideConfig,\n} from \"../services/config/index.js\";\nimport type { ErrorPayload, ViteDevServer, WebSocketClient } from \"vite\";\n\nconst PLUGIN_NAME = \"unplugin-paraglide-js\";\n\n/**\n * The options accepted by the paraglide bundler plugins.\n *\n * `project` is required — the path to your inlang project directory, which\n * also hosts the paraglide config file (`<project>/paraglide.config.*`).\n * Relative paths are resolved against the tool's project root (Vite `root`,\n * webpack/rspack `context`, else the process working directory).\n *\n * Every other property is optional: values that are not provided are read\n * from the config file, and anything still missing falls back to the\n * built-in defaults.\n *\n * @example\n * ```ts\n * paraglideVitePlugin({ project: \"./project.inlang\" })\n *\n * // Explicit options win over the config file\n * paraglideVitePlugin({\n * project: \"./project.inlang\",\n * outdir: \"./src/paraglide-custom\",\n * })\n * ```\n */\nexport type ParaglidePluginOptions = Omit<\n\tPartial<CompilerOptions>,\n\t\"project\"\n> & {\n\t/**\n\t * Required — the path to your inlang project directory, which also\n\t * hosts the paraglide config file (`<project>/paraglide.config.*`).\n\t * Relative paths are resolved against the tool's project root (Vite\n\t * `root`, webpack/rspack `context`, else the process working directory).\n\t */\n\tproject: string;\n};\n\nconst logger = new Logger();\n\nconst PERSISTENT_CACHE_VERSION = 1;\n\ntype PersistentCompilationCache = {\n\tversion: typeof PERSISTENT_CACHE_VERSION;\n\tcompilerVersion: string;\n\tinputsDigest: string;\n\treadFiles: string[];\n\toutputHashes: Record<string, string>;\n};\n\nfunction isStringRecord(value: unknown): value is Record<string, string> {\n\treturn (\n\t\ttypeof value === \"object\" &&\n\t\tvalue !== null &&\n\t\t!Array.isArray(value) &&\n\t\tObject.values(value).every((entry) => typeof entry === \"string\")\n\t);\n}\n\n/**\n * Default isServer which differs per bundler.\n */\nlet isServer: string | undefined;\n\ntype PluginState = {\n\t/** Identity of the fs the tracked wrapper was created around. */\n\tbaseFs: typeof nodeFs | undefined;\n\ttrackedFs: typeof nodeFs;\n\treadFiles: Set<string>;\n\tclearReadFiles: () => void;\n\tpreviousCompilation: CompilationResult | undefined;\n\tcompilationError: Error | undefined;\n\t/**\n\t * Digest of the input files and options of the last successful compilation.\n\t *\n\t * `vite build` fires `buildStart` once per environment (client, ssr, ...).\n\t * When the digest of the current inputs matches, `compile()` is skipped\n\t * entirely — project loading and message compilation are expensive even\n\t * when `previousCompilation` dedupes the writes.\n\t *\n\t * https://github.com/opral/paraglide-js/issues/693\n\t */\n\tpreviousInputsDigest: string | undefined;\n\tpreviousProject: string | undefined;\n\tpreviousOutdir: string | undefined;\n};\n\n// Module-scoped so the warm state survives plugin re-instantiation within\n// one process (e.g. a vite config reload), but recreated when a different\n// fs is passed — the tracked wrapper, read set, and cached compilation are\n// only valid for the filesystem they were produced from.\nlet pluginState: PluginState | undefined;\n\nfunction getPluginState(args: Pick<CompilerOptions, \"fs\">): PluginState {\n\tif (pluginState === undefined || pluginState.baseFs !== args.fs) {\n\t\tconst tracked = createTrackedFs({ fs: args.fs });\n\t\tpluginState = {\n\t\t\tbaseFs: args.fs,\n\t\t\ttrackedFs: tracked.fs,\n\t\t\treadFiles: tracked.readFiles,\n\t\t\tclearReadFiles: tracked.clearReadFiles,\n\t\t\tpreviousCompilation: undefined,\n\t\t\tcompilationError: undefined,\n\t\t\tpreviousInputsDigest: undefined,\n\t\t\tpreviousProject: undefined,\n\t\t\tpreviousOutdir: undefined,\n\t\t};\n\t}\n\treturn pluginState;\n}\n\nfunction withoutCleanOutdir(\n\targs: CompilerOptions\n): Omit<CompilerOptions, \"cleanOutdir\"> {\n\tconst { cleanOutdir, ...compileArgs } = args;\n\tvoid cleanOutdir;\n\treturn compileArgs;\n}\n\nfunction getCompilerConfig(\n\targs: CompilerOptions,\n\toutputStructure: NonNullable<CompilerOptions[\"outputStructure\"]>\n) {\n\tconst { fs: _fs, ...serializableArgs } = args;\n\tvoid _fs;\n\treturn {\n\t\t...serializableArgs,\n\t\toutputStructure,\n\t\tisServer,\n\t\tcompilerVersion: ENV_VARIABLES.PARJS_PACKAGE_VERSION,\n\t};\n}\n\n/**\n * Hashes the files (and directory listings) the last compilation read,\n * together with the options that affect the output. Returns `undefined`\n * when the digest can't be computed (no tracked reads yet, an unexpected\n * read error, ...) — `undefined` never matches, so the caller compiles.\n *\n * Directory listings are included so that a message file *added* next to\n * the tracked ones invalidates the digest, not only edits to known files.\n * All components are length-prefixed so distinct input states can't\n * produce the same hash stream.\n *\n * The digest is taken after the compile, by re-reading the inputs. A file\n * edited *during* a compile can therefore be hashed at its new content\n * while the output reflects the old one — accepted: in dev, watchChange\n * recompiles on that edit, and a fresh build process always recompiles.\n */\nasync function computeInputsDigest(\n\tstate: PluginState,\n\targs: CompilerOptions,\n\toutputStructure: NonNullable<CompilerOptions[\"outputStructure\"]>\n): Promise<string | undefined> {\n\tif (state.readFiles.size === 0) {\n\t\treturn undefined;\n\t}\n\tconst targets = getWatchTargets(state.readFiles, { outdir: args.outdir });\n\tif (targets.files.size === 0) {\n\t\treturn undefined;\n\t}\n\tconst fsp = (args.fs ?? nodeFs).promises;\n\tconst hash = createHash(\"sha256\");\n\ttry {\n\t\thash.update(JSON.stringify(getCompilerConfig(args, outputStructure)));\n\t\tfor (const directoryPath of [...targets.directories].sort()) {\n\t\t\tconst entries = await fsp\n\t\t\t\t.readdir(directoryPath)\n\t\t\t\t// tracked reads include probed-but-absent paths (the SDK reads\n\t\t\t\t// optional files and handles ENOENT itself) — a missing entry\n\t\t\t\t// is valid input state, hash it as such\n\t\t\t\t.catch(rethrowUnlessEnoent);\n\t\t\thash.update(`\\0dir:${directoryPath.length}:${directoryPath}:`);\n\t\t\tif (entries === undefined) {\n\t\t\t\thash.update(\"missing\");\n\t\t\t} else {\n\t\t\t\tfor (const entry of [...entries].sort()) {\n\t\t\t\t\thash.update(`${entry.length}:${entry},`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (const filePath of [...targets.files].sort()) {\n\t\t\tconst content = await fsp.readFile(filePath).catch(rethrowUnlessEnoent);\n\t\t\thash.update(`\\0file:${filePath.length}:${filePath}:`);\n\t\t\tif (content === undefined) {\n\t\t\t\thash.update(\"missing\");\n\t\t\t} else {\n\t\t\t\thash.update(`${content.length}:`);\n\t\t\t\thash.update(content);\n\t\t\t}\n\t\t}\n\t} catch {\n\t\treturn undefined;\n\t}\n\treturn hash.digest(\"hex\");\n}\n\nfunction getPersistentCachePath(\n\targs: CompilerOptions,\n\toutputStructure: NonNullable<CompilerOptions[\"outputStructure\"]>\n): string {\n\tconst absoluteOutdir = resolve(process.cwd(), args.outdir);\n\tconst cacheKey = createHash(\"sha256\")\n\t\t.update(\n\t\t\tJSON.stringify({\n\t\t\t\tabsoluteOutdir,\n\t\t\t\tcompilerConfig: getCompilerConfig(args, outputStructure),\n\t\t\t})\n\t\t)\n\t\t.digest(\"hex\")\n\t\t.slice(0, 16);\n\treturn resolve(\n\t\tprocess.cwd(),\n\t\targs.project,\n\t\t\"cache\",\n\t\t\"paraglide-js\",\n\t\t`${cacheKey}.json`\n\t);\n}\n\nasync function readPersistentCache(\n\targs: CompilerOptions,\n\toutputStructure: NonNullable<CompilerOptions[\"outputStructure\"]>\n): Promise<PersistentCompilationCache | undefined> {\n\tconst fsp = (args.fs ?? nodeFs).promises;\n\ttry {\n\t\tconst parsed = JSON.parse(\n\t\t\tawait fsp.readFile(getPersistentCachePath(args, outputStructure), \"utf8\")\n\t\t) as Partial<PersistentCompilationCache>;\n\t\tif (\n\t\t\tparsed.version !== PERSISTENT_CACHE_VERSION ||\n\t\t\tparsed.compilerVersion !== ENV_VARIABLES.PARJS_PACKAGE_VERSION ||\n\t\t\ttypeof parsed.inputsDigest !== \"string\" ||\n\t\t\t!Array.isArray(parsed.readFiles) ||\n\t\t\tparsed.readFiles.some((file) => typeof file !== \"string\") ||\n\t\t\t!isStringRecord(parsed.outputHashes)\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn parsed as PersistentCompilationCache;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nasync function preparePersistentCacheDirectory(\n\targs: CompilerOptions,\n\toutputStructure: NonNullable<CompilerOptions[\"outputStructure\"]>\n): Promise<void> {\n\ttry {\n\t\tawait (args.fs ?? nodeFs).promises.mkdir(\n\t\t\tdirname(getPersistentCachePath(args, outputStructure)),\n\t\t\t{ recursive: true }\n\t\t);\n\t} catch {\n\t\t// The cache is an optimization. Read-only projects must still compile.\n\t}\n}\n\nasync function writePersistentCache(\n\tstate: PluginState,\n\targs: CompilerOptions,\n\toutputStructure: NonNullable<CompilerOptions[\"outputStructure\"]>\n): Promise<void> {\n\tif (\n\t\tstate.previousInputsDigest === undefined ||\n\t\tstate.previousCompilation?.outputHashes === undefined\n\t) {\n\t\treturn;\n\t}\n\tconst cachePath = getPersistentCachePath(args, outputStructure);\n\tconst cache: PersistentCompilationCache = {\n\t\tversion: PERSISTENT_CACHE_VERSION,\n\t\tcompilerVersion: ENV_VARIABLES.PARJS_PACKAGE_VERSION,\n\t\tinputsDigest: state.previousInputsDigest,\n\t\treadFiles: [...state.readFiles].sort(),\n\t\toutputHashes: state.previousCompilation.outputHashes,\n\t};\n\tconst fsp = (args.fs ?? nodeFs).promises;\n\ttry {\n\t\tawait fsp.mkdir(dirname(cachePath), { recursive: true });\n\t\tawait fsp.writeFile(cachePath, JSON.stringify(cache));\n\t} catch {\n\t\t// The cache is an optimization. Read-only projects must still compile.\n\t}\n}\n\nfunction outputHashesMatch(\n\tleft: Record<string, string> | undefined,\n\tright: Record<string, string>\n): boolean {\n\tif (left === undefined) return false;\n\tconst leftEntries = Object.entries(left);\n\tconst rightEntries = Object.entries(right);\n\tif (leftEntries.length !== rightEntries.length) return false;\n\treturn leftEntries.every(([file, hash]) => right[file] === hash);\n}\n\nasync function restorePersistentCache(args: {\n\tstate: PluginState;\n\tcompilerOptions: CompilerOptions;\n\toutputStructure: NonNullable<CompilerOptions[\"outputStructure\"]>;\n}): Promise<boolean> {\n\tconst cached = await readPersistentCache(\n\t\targs.compilerOptions,\n\t\targs.outputStructure\n\t);\n\tif (cached === undefined) return false;\n\n\tconst cachedReadFiles = new Set<string>();\n\tfor (const file of cached.readFiles) {\n\t\tcachedReadFiles.add(file);\n\t}\n\tconst validationState: PluginState = {\n\t\t...args.state,\n\t\treadFiles: cachedReadFiles,\n\t\tclearReadFiles: () => cachedReadFiles.clear(),\n\t};\n\tconst [inputsDigest, previousCompilation] = await Promise.all([\n\t\tcomputeInputsDigest(\n\t\t\tvalidationState,\n\t\t\targs.compilerOptions,\n\t\t\targs.outputStructure\n\t\t),\n\t\tseedPreviousCompilationFromOutdir({\n\t\t\toutdir: args.compilerOptions.outdir,\n\t\t\tfs: args.compilerOptions.fs?.promises,\n\t\t}),\n\t]);\n\tif (\n\t\tinputsDigest !== cached.inputsDigest ||\n\t\t!outputHashesMatch(previousCompilation?.outputHashes, cached.outputHashes)\n\t) {\n\t\treturn false;\n\t}\n\n\targs.state.clearReadFiles();\n\tfor (const file of cachedReadFiles) {\n\t\targs.state.readFiles.add(file);\n\t}\n\targs.state.previousCompilation = previousCompilation;\n\targs.state.previousInputsDigest = inputsDigest;\n\treturn true;\n}\n\nfunction rethrowUnlessEnoent(error: unknown): undefined {\n\tif ((error as NodeJS.ErrnoException)?.code === \"ENOENT\") {\n\t\treturn undefined;\n\t}\n\tthrow error;\n}\n\n// default to locale-modules for development to speed up the dev server\n// https://github.com/opral/inlang-paraglide-js/issues/486\nfunction resolveOutputStructure(\n\toptions: CompilerOptions\n): \"message-modules\" | \"locale-modules\" {\n\tconst isProduction = process.env.NODE_ENV === \"production\";\n\treturn (\n\t\toptions.outputStructure ??\n\t\t(isProduction ? \"message-modules\" : \"locale-modules\")\n\t);\n}\n\nfunction hasUnchangedInputs(args: {\n\tstate: PluginState;\n\tcompilerOptions: CompilerOptions;\n\toutputStructure: \"message-modules\" | \"locale-modules\";\n}): Promise<boolean> {\n\tif (args.state.previousCompilation === undefined) {\n\t\treturn Promise.resolve(false);\n\t}\n\tif (args.state.previousInputsDigest === undefined) {\n\t\treturn Promise.resolve(false);\n\t}\n\treturn computeInputsDigest(\n\t\targs.state,\n\t\targs.compilerOptions,\n\t\targs.outputStructure\n\t).then((currentDigest) => currentDigest === args.state.previousInputsDigest);\n}\n\nfunction maybeInvalidateForOptionsChange(\n\tstate: PluginState,\n\tcompilerOptions: CompilerOptions\n): void {\n\tif (\n\t\tstate.previousProject !== undefined &&\n\t\t(state.previousProject !== compilerOptions.project ||\n\t\t\tstate.previousOutdir !== compilerOptions.outdir)\n\t) {\n\t\tstate.previousCompilation = undefined;\n\t\tstate.previousInputsDigest = undefined;\n\t\tstate.clearReadFiles();\n\t}\n\tstate.previousProject = compilerOptions.project;\n\tstate.previousOutdir = compilerOptions.outdir;\n}\n\n// Compiles and stores the result plus its inputs digest on the plugin\n// state. Callers decide whether to persist the compilation cache.\nasync function compileAndUpdateState(args: {\n\tstate: PluginState;\n\tcompilerOptions: CompilerOptions;\n\toutputStructure: \"message-modules\" | \"locale-modules\";\n\tpreviousCompilation: CompilationResult | undefined;\n\t/**\n\t * The `isServer` expression to bake into the compiled runtime.\n\t * Webpack omits it and relies on the compiler default.\n\t */\n\tisServer: string | undefined;\n}): Promise<void> {\n\targs.state.previousCompilation = await compile({\n\t\tpreviousCompilation: args.previousCompilation,\n\t\toutputStructure: args.outputStructure,\n\t\tisServer: args.isServer,\n\t\t...withoutCleanOutdir(args.compilerOptions),\n\t\tcleanOutdir: false,\n\t\t// after the options spread so a user-provided fs doesn't bypass\n\t\t// the read tracking (trackedFs wraps options.fs when provided)\n\t\tfs: args.state.trackedFs,\n\t});\n\targs.state.previousInputsDigest = await computeInputsDigest(\n\t\targs.state,\n\t\targs.compilerOptions,\n\t\targs.outputStructure\n\t);\n}\n\n/**\n * Runs the compilation with the given, already-resolved options. Shared by\n * buildStart and watch-mode rebuilds.\n */\nasync function runCompilation(args: {\n\tstate: PluginState;\n\tcompilerOptions: CompilerOptions;\n}): Promise<void> {\n\tconst compilerOptions = args.compilerOptions;\n\tconst { state } = args;\n\tconst outputStructure = resolveOutputStructure(compilerOptions);\n\tmaybeInvalidateForOptionsChange(state, compilerOptions);\n\tstate.compilationError = undefined;\n\ttry {\n\t\t// Stabilize project directory listings before the first digest. The\n\t\t// ignored cache directory must not invalidate the cache that creates it.\n\t\tawait preparePersistentCacheDirectory(compilerOptions, outputStructure);\n\t\tif (\n\t\t\tstate.previousCompilation === undefined &&\n\t\t\t(await restorePersistentCache({\n\t\t\t\tstate,\n\t\t\t\tcompilerOptions,\n\t\t\t\toutputStructure,\n\t\t\t}))\n\t\t) {\n\t\t\tlogger.info(\n\t\t\t\t`Compilation skipped — inputs unchanged (${outputStructure})`\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tif (\n\t\t\tawait hasUnchangedInputs({\n\t\t\t\tstate,\n\t\t\t\tcompilerOptions,\n\t\t\t\toutputStructure,\n\t\t\t})\n\t\t) {\n\t\t\tlogger.info(\n\t\t\t\t`Compilation skipped — inputs unchanged (${outputStructure})`\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\t// On a fresh process, seed previousCompilation from on-disk hashes\n\t\t// so the first compile is a no-op when inputs are unchanged. Avoids\n\t\t// racing concurrent readers that wiping outdir would interrupt.\n\t\tconst seededPrevious =\n\t\t\tstate.previousCompilation ??\n\t\t\t(await seedPreviousCompilationFromOutdir({\n\t\t\t\toutdir: compilerOptions.outdir,\n\t\t\t\tfs: compilerOptions.fs?.promises,\n\t\t\t}));\n\t\tawait compileAndUpdateState({\n\t\t\tstate,\n\t\t\tcompilerOptions,\n\t\t\toutputStructure,\n\t\t\tpreviousCompilation: seededPrevious,\n\t\t\tisServer,\n\t\t});\n\t\tawait writePersistentCache(state, compilerOptions, outputStructure);\n\t\tlogger.success(`Compilation complete (${outputStructure})`);\n\t} catch (error) {\n\t\tstate.compilationError =\n\t\t\terror instanceof Error ? error : new Error(String(error));\n\t\tstate.previousInputsDigest = undefined;\n\t\tlogger.error(\"Failed to compile project:\", (error as Error).message);\n\t\tlogger.info(\"Please check your translation files for syntax errors.\");\n\t\tif (process.env.NODE_ENV === \"production\") throw error;\n\t}\n}\n\n// The return type preserves literal option types (`enforce: \"pre\"`, ...)\n// while `project` stays required on the input side.\ntype UnpluginFactoryWithOptions = (\n\tuserArgs: ParaglidePluginOptions,\n\tmeta?: Parameters<UnpluginFactory<ParaglidePluginOptions>>[1],\n\tdefaults?: Pick<CompilerOptions, \"outputStructure\">\n) => ReturnType<UnpluginFactory<ParaglidePluginOptions>>;\n\nexport const unpluginFactory: UnpluginFactoryWithOptions = (\n\tuserArgs,\n\t_meta,\n\tdefaults\n) => {\n\tconst state = getPluginState(userArgs);\n\tconst { readFiles, clearReadFiles } = state;\n\t// Project root as reported by the bundler (vite `root`, webpack/rspack\n\t// `context`). Falls back to the process working directory when the\n\t// bundler doesn't provide one. The config file is resolved inside the\n\t// project directory.\n\tlet discoveryRoot: string | undefined;\n\t// Bound to the hook context in buildStart so that watchChange can\n\t// register additional files.\n\tlet addWatchFile: ((path: string) => void) | undefined;\n\t// A new plugin instance must not be served by config cache entries\n\t// from a previous instance (e.g. vite.config.ts reloads reuse the\n\t// process). Wiping the cache here makes every instance perform one\n\t// fresh load; subsequent loads within the instance stay cached.\n\tclearParaglideConfigCache();\n\n\tfunction safeAddWatchFile(\n\t\tthisArg: { addWatchFile: (path: string) => void } | undefined,\n\t\tpath: string\n\t): void {\n\t\tconst fn = thisArg?.addWatchFile ?? addWatchFile;\n\t\tif (!fn) return;\n\t\tif (watchRegistrationUnsupported) return;\n\t\ttry {\n\t\t\tfn.call(thisArg ?? undefined, path);\n\t\t} catch (error) {\n\t\t\t// Watch-file registration is best-effort: backends differ in what\n\t\t\t// they support (unplugin's esbuild context throws for every call),\n\t\t\t// and watcher resource limits can surface as errors. A failed\n\t\t\t// registration must never fail the build.\n\t\t\twatchRegistrationUnsupported = true;\n\t\t\tlogger.warn(\n\t\t\t\t`Registering additional watch files is not supported by this bundler context — skipping further registrations (${(error as Error)?.message ?? String(error)})`\n\t\t\t);\n\t\t}\n\t}\n\n\t// Whether a config file was present at the last load — drives the\n\t// one-time warning when every config candidate disappears.\n\tlet hadActiveConfig = false;\n\t// Watch-rebuild serialization state (see watchChange).\n\tlet compiling = false;\n\tconst pendingWatchPaths = new Set<string>();\n\t// Options from the most recent successful resolution — reused by input\n\t// events that cannot have changed them.\n\tlet lastOptions: CompilerOptions | undefined;\n\t// Set once a bundler context rejects watch-file registrations (esbuild);\n\t// further registration attempts are skipped to avoid warning floods.\n\tlet watchRegistrationUnsupported = false;\n\tlet viteServer: ViteDevServer | undefined;\n\tlet viteError: ErrorPayload | undefined;\n\tlet configLoadFailed = false;\n\n\tfunction reportViteError(\n\t\terror: unknown,\n\t\tsource: \"config\" | \"compilation\" = \"compilation\"\n\t): void {\n\t\tif (!viteServer || process.env.NODE_ENV === \"production\") return;\n\t\tif (configLoadFailed && source === \"compilation\") return;\n\t\tif (source === \"config\") configLoadFailed = true;\n\t\tconst failure = error instanceof Error ? error : new Error(String(error));\n\t\tviteError = {\n\t\t\ttype: \"error\",\n\t\t\terr: {\n\t\t\t\tmessage: failure.message,\n\t\t\t\tstack: failure.stack ?? \"\",\n\t\t\t\tplugin: PLUGIN_NAME,\n\t\t\t},\n\t\t};\n\t\t// Older Vite versions buffer errors without clients, even after recovery.\n\t\tif (viteServer.ws.clients.size > 0) viteServer.ws.send(viteError);\n\t}\n\n\tfunction clearViteError(): void {\n\t\tif (!viteServer || !viteError || configLoadFailed) return;\n\t\tviteError = undefined;\n\t\t// An invalid config can recover without writing generated files,\n\t\t// leaving no HMR update to dismiss the error overlay.\n\t\tif (viteServer.ws.clients.size > 0) {\n\t\t\tviteServer.ws.send({ type: \"full-reload\" });\n\t\t}\n\t}\n\n\tconst getProjectDir = () =>\n\t\tnodeNormalizePath(\n\t\t\tresolve(discoveryRoot ?? process.cwd(), userArgs.project)\n\t\t);\n\n\tconst resolveOptionsWith = (\n\t\tloaded: LoadedParaglideConfig | undefined\n\t): CompilerOptions => {\n\t\tconst options = resolveCompilerOptions({\n\t\t\tconfig: loaded?.config,\n\t\t\toverrides: userArgs,\n\t\t\troot: discoveryRoot ?? process.cwd(),\n\t\t});\n\t\t// Apply integration defaults after each config load, keeping watched\n\t\t// config values separate from explicit plugin overrides.\n\t\tif (\n\t\t\toptions.outputStructure === undefined &&\n\t\t\tdefaults?.outputStructure !== undefined\n\t\t) {\n\t\t\toptions.outputStructure = defaults.outputStructure;\n\t\t}\n\t\treturn options;\n\t};\n\n\t/**\n\t * Loads the active config, following candidate renames and keeping the\n\t * last known-good configuration while the file is missing or invalid.\n\t * Callers that know the config content changed should clear the cache\n\t * for the project directory first.\n\t */\n\tasync function loadActiveConfig(): Promise<\n\t\tLoadedParaglideConfig | undefined\n\t> {\n\t\tconst dir = getProjectDir();\n\t\tconst winner = await resolveConfigCandidate(dir);\n\t\tif (winner === undefined) {\n\t\t\tif (hadActiveConfig) {\n\t\t\t\thadActiveConfig = false;\n\t\t\t\tlogger.warn(\n\t\t\t\t\t\"Paraglide config file was removed, continuing with default options.\"\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\t\thadActiveConfig = true;\n\t\t// Throws when the file exists but is invalid — callers decide the\n\t\t// policy: watch modes skip and surface the error in development,\n\t\t// build paths fail loudly in production.\n\t\treturn loadParaglideConfig({ projectDir: dir, logger });\n\t}\n\n\t/**\n\t * Rebuild for a single watch event. Config-named events reload the\n\t * config; input events reuse the last known options unless the config\n\t * failed to load.\n\t */\n\tasync function performWatchRecompile(path: string): Promise<void> {\n\t\tconst normalizedPath = nodeNormalizePath(path);\n\t\tconst projectDir = getProjectDir();\n\t\tconst withinProjectDir =\n\t\t\tnormalizedPath === projectDir ||\n\t\t\tnormalizedPath.startsWith(`${projectDir}/`);\n\t\tconst configEvent = withinProjectDir && isConfigFileName(normalizedPath);\n\n\t\tlet args: CompilerOptions;\n\t\tif (!configEvent && lastOptions !== undefined) {\n\t\t\tconst targets = getWatchTargets(readFiles, {\n\t\t\t\toutdir: lastOptions.outdir,\n\t\t\t});\n\t\t\tif (targets.isIgnoredPath(normalizedPath)) return;\n\t\t\tconst shouldCompile =\n\t\t\t\ttargets.files.has(normalizedPath) ||\n\t\t\t\tisPathWithinDirectories(normalizedPath, targets.directories);\n\t\t\tif (!shouldCompile) return;\n\t\t}\n\t\tif (!configEvent && lastOptions !== undefined && !configLoadFailed) {\n\t\t\targs = lastOptions;\n\t\t} else {\n\t\t\tif (configEvent) {\n\t\t\t\tlogger.info(\"Paraglide configuration changed, re-compiling.\");\n\t\t\t\tclearParaglideConfigCache({ projectDir });\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tconst loaded = await loadActiveConfig();\n\t\t\t\targs = resolveOptionsWith(loaded);\n\t\t\t} catch (error) {\n\t\t\t\t// Invalid config: skip the compilation entirely and surface\n\t\t\t\t// the problem. The previously compiled output stays on disk.\n\t\t\t\treportViteError(error, \"config\");\n\t\t\t\tlogger.error((error as Error).message);\n\t\t\t\tlogger.error(\n\t\t\t\t\t\"Skipping compilation because of the invalid paraglide config.\"\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tlastOptions = args;\n\t\t\tconfigLoadFailed = false;\n\t\t}\n\n\t\tmaybeInvalidateForOptionsChange(state, args);\n\t\tconst outputStructure = resolveOutputStructure(args);\n\t\tconst previouslyReadFiles = new Set(readFiles);\n\n\t\ttry {\n\t\t\tif (!configEvent) {\n\t\t\t\tlogger.info(\n\t\t\t\t\t`Re-compiling inlang project... File \"${relative(process.cwd(), path)}\" has changed.`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tclearReadFiles();\n\t\t\tawait compileAndUpdateState({\n\t\t\t\tstate,\n\t\t\t\tcompilerOptions: args,\n\t\t\t\toutputStructure,\n\t\t\t\tpreviousCompilation: state.previousCompilation,\n\t\t\t\tisServer,\n\t\t\t});\n\t\t\tawait writePersistentCache(state, args, outputStructure);\n\t\t\tlogger.success(`Re-compilation complete (${outputStructure})`);\n\t\t\tclearViteError();\n\n\t\t\tconst nextTargets = getWatchTargets(readFiles, { outdir: args.outdir });\n\t\t\tfor (const filePath of nextTargets.files)\n\t\t\t\tsafeAddWatchFile(undefined, filePath);\n\t\t\tfor (const directoryPath of nextTargets.directories)\n\t\t\t\tsafeAddWatchFile(undefined, directoryPath);\n\t\t} catch (e) {\n\t\t\treportViteError(e);\n\t\t\tclearReadFiles();\n\t\t\tfor (const filePath of previouslyReadFiles) readFiles.add(filePath);\n\t\t\tstate.previousCompilation = undefined;\n\t\t\tstate.previousInputsDigest = undefined;\n\t\t\tlogger.warn(\"Failed to re-compile project:\", (e as Error).message);\n\t\t}\n\t}\n\n\treturn {\n\t\tname: PLUGIN_NAME,\n\t\tenforce: \"pre\",\n\t\tasync buildStart() {\n\t\t\taddWatchFile = this.addWatchFile?.bind(this);\n\t\t\ttry {\n\t\t\t\tconst loaded = await loadActiveConfig();\n\t\t\t\tconst args = resolveOptionsWith(loaded);\n\t\t\t\tconfigLoadFailed = false;\n\t\t\t\tlastOptions = args;\n\t\t\t\tawait runCompilation({ state, compilerOptions: args });\n\t\t\t} catch (error) {\n\t\t\t\t// Config errors are converted to last-good options by\n\t\t\t\t// loadActiveConfig; compilation errors are handled inside\n\t\t\t\t// runCompilation. Anything escaping is unexpected — fail the\n\t\t\t\t// build in production, keep serving in development.\n\t\t\t\tif (process.env.NODE_ENV === \"production\") throw error;\n\t\t\t\tlogger.error(\n\t\t\t\t\t\"Failed to prepare paraglide compilation:\",\n\t\t\t\t\t(error as Error).message\n\t\t\t\t);\n\t\t\t\treportViteError(error, \"config\");\n\t\t\t\treturn;\n\t\t\t} finally {\n\t\t\t\tif (lastOptions !== undefined) {\n\t\t\t\t\tconst targets = getWatchTargets(readFiles, {\n\t\t\t\t\t\toutdir: lastOptions.outdir,\n\t\t\t\t\t});\n\t\t\t\t\tfor (const filePath of targets.files)\n\t\t\t\t\t\tsafeAddWatchFile(this, filePath);\n\t\t\t\t\tfor (const directoryPath of targets.directories)\n\t\t\t\t\t\tsafeAddWatchFile(this, directoryPath);\n\t\t\t\t}\n\t\t\t\t// Register every config candidate inside the project directory\n\t\t\t\t// so renames and format switches are reported even by backends\n\t\t\t\t// that only report watched files (webpack's modifiedFiles).\n\t\t\t\tconst projectDir = getProjectDir();\n\t\t\t\tfor (const name of CONFIG_FILE_NAMES) {\n\t\t\t\t\tsafeAddWatchFile(\n\t\t\t\t\t\tthis as unknown as { addWatchFile: (p: string) => void },\n\t\t\t\t\t\tjoin(projectDir, name)\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (state.compilationError) {\n\t\t\t\treportViteError(state.compilationError);\n\t\t\t} else {\n\t\t\t\tclearViteError();\n\t\t\t}\n\t\t},\n\t\tasync watchChange(path) {\n\t\t\t// Serialize rebuilds: bundlers may deliver several watchChange\n\t\t\t// events concurrently (webpack fires once per modified file).\n\t\t\t// Every path is queued — a config event must never be starved by\n\t\t\t// later input events.\n\t\t\tpendingWatchPaths.add(nodeNormalizePath(path));\n\t\t\tif (compiling) return;\n\t\t\tcompiling = true;\n\t\t\ttry {\n\t\t\t\twhile (pendingWatchPaths.size > 0) {\n\t\t\t\t\tconst batch = [...pendingWatchPaths];\n\t\t\t\t\tpendingWatchPaths.clear();\n\t\t\t\t\tfor (const current of batch) {\n\t\t\t\t\t\tawait performWatchRecompile(current);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\tcompiling = false;\n\t\t\t}\n\t\t},\n\t\tvite: {\n\t\t\tconfig: {\n\t\t\t\thandler: () => {\n\t\t\t\t\tisServer = \"import.meta.env?.SSR ?? typeof window === 'undefined'\";\n\t\t\t\t},\n\t\t\t},\n\t\t\tconfigEnvironment: {\n\t\t\t\thandler: () => {\n\t\t\t\t\tisServer = \"import.meta.env?.SSR ?? typeof window === 'undefined'\";\n\t\t\t\t},\n\t\t\t},\n\t\t\tconfigResolved: {\n\t\t\t\thandler: (config: { root?: string }) => {\n\t\t\t\t\tdiscoveryRoot = config.root;\n\t\t\t\t},\n\t\t\t},\n\t\t\tconfigureServer(server) {\n\t\t\t\tviteServer = server;\n\t\t\t\tserver.ws.on(\"connection\", (socket: WebSocketClient[\"socket\"]) => {\n\t\t\t\t\tif (viteError) socket.send(JSON.stringify(viteError));\n\t\t\t\t});\n\t\t\t},\n\t\t},\n\t\twebpack(compiler) {\n\t\t\tdiscoveryRoot = compiler.context;\n\t\t\tcompiler.options.resolve = {\n\t\t\t\t...compiler.options.resolve,\n\t\t\t\tfallback: {\n\t\t\t\t\t...compiler.options.resolve?.fallback,\n\t\t\t\t\t// https://stackoverflow.com/a/72989932\n\t\t\t\t\tasync_hooks: false,\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tcompiler.hooks.beforeRun.tapPromise(PLUGIN_NAME, async () => {\n\t\t\t\tlet args: CompilerOptions;\n\t\t\t\ttry {\n\t\t\t\t\tconst loaded = await loadActiveConfig();\n\t\t\t\t\targs = resolveOptionsWith(loaded);\n\t\t\t\t\tlastOptions = args;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tstate.previousInputsDigest = undefined;\n\t\t\t\t\tstate.previousCompilation = undefined;\n\t\t\t\t\tlogger.error(\n\t\t\t\t\t\t\"Failed to load paraglide config:\",\n\t\t\t\t\t\t(error as Error).message\n\t\t\t\t\t);\n\t\t\t\t\tif (process.env.NODE_ENV === \"production\") throw error;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst outputStructure = resolveOutputStructure(args);\n\t\t\t\tmaybeInvalidateForOptionsChange(state, args);\n\t\t\t\ttry {\n\t\t\t\t\tawait preparePersistentCacheDirectory(args, outputStructure);\n\t\t\t\t\tif (\n\t\t\t\t\t\tstate.previousCompilation === undefined &&\n\t\t\t\t\t\t(await restorePersistentCache({\n\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\tcompilerOptions: args,\n\t\t\t\t\t\t\toutputStructure,\n\t\t\t\t\t\t}))\n\t\t\t\t\t) {\n\t\t\t\t\t\tlogger.info(\n\t\t\t\t\t\t\t`Compilation skipped — inputs unchanged (${outputStructure})`\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\t// Multi-compiler webpack setups (client + server) trigger\n\t\t\t\t\t// beforeRun once per compiler — skip when inputs are unchanged.\n\t\t\t\t\tif (\n\t\t\t\t\t\tawait hasUnchangedInputs({\n\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\tcompilerOptions: args,\n\t\t\t\t\t\t\toutputStructure,\n\t\t\t\t\t\t})\n\t\t\t\t\t) {\n\t\t\t\t\t\tlogger.info(\n\t\t\t\t\t\t\t`Compilation skipped — inputs unchanged (${outputStructure})`\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tconst seededPrevious =\n\t\t\t\t\t\tstate.previousCompilation ??\n\t\t\t\t\t\t(await seedPreviousCompilationFromOutdir({\n\t\t\t\t\t\t\toutdir: args.outdir,\n\t\t\t\t\t\t\tfs: args.fs?.promises,\n\t\t\t\t\t\t}));\n\t\t\t\t\tawait compileAndUpdateState({\n\t\t\t\t\t\tstate,\n\t\t\t\t\t\tcompilerOptions: args,\n\t\t\t\t\t\toutputStructure,\n\t\t\t\t\t\tpreviousCompilation: seededPrevious,\n\t\t\t\t\t\t// webpack has no vite-style SSR expression; rely on the\n\t\t\t\t\t\t// compiler default.\n\t\t\t\t\t\tisServer: undefined,\n\t\t\t\t\t});\n\t\t\t\t\tawait writePersistentCache(state, args, outputStructure);\n\t\t\t\t\tlogger.success(`Compilation complete (${outputStructure})`);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tstate.previousInputsDigest = undefined;\n\t\t\t\t\tlogger.warn(\"Failed to compile project:\", (error as Error).message);\n\t\t\t\t\tlogger.warn(\"Please check your translation files for syntax errors.\");\n\t\t\t\t\tif (process.env.NODE_ENV === \"production\") throw error;\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t\trspack(compiler) {\n\t\t\tdiscoveryRoot = compiler.context;\n\t\t\t// Rspack mirrors webpack's hook API but ships no usable types,\n\t\t\t// so hooks are tapped structurally.\n\t\t\tconst tapRspackBeforeRun = (fn: () => Promise<void>): void => {\n\t\t\t\tconst target = (\n\t\t\t\t\tcompiler as unknown as {\n\t\t\t\t\t\thooks: Record<\n\t\t\t\t\t\t\tstring,\n\t\t\t\t\t\t\t{ tapPromise?: (n: string, fn: () => Promise<void>) => void }\n\t\t\t\t\t\t>;\n\t\t\t\t\t}\n\t\t\t\t).hooks?.beforeRun;\n\t\t\t\ttarget?.tapPromise?.(PLUGIN_NAME, fn);\n\t\t\t};\n\t\t\ttapRspackBeforeRun(async () => {\n\t\t\t\tlet args: CompilerOptions;\n\t\t\t\ttry {\n\t\t\t\t\tconst loaded = await loadActiveConfig();\n\t\t\t\t\targs = resolveOptionsWith(loaded);\n\t\t\t\t\tlastOptions = args;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tstate.previousInputsDigest = undefined;\n\t\t\t\t\tstate.previousCompilation = undefined;\n\t\t\t\t\tlogger.error(\n\t\t\t\t\t\t\"Failed to load paraglide config:\",\n\t\t\t\t\t\t(error as Error).message\n\t\t\t\t\t);\n\t\t\t\t\tif (process.env.NODE_ENV === \"production\") throw error;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst outputStructure = resolveOutputStructure(args);\n\t\t\t\tmaybeInvalidateForOptionsChange(state, args);\n\t\t\t\ttry {\n\t\t\t\t\tawait preparePersistentCacheDirectory(args, outputStructure);\n\t\t\t\t\tif (\n\t\t\t\t\t\tstate.previousCompilation === undefined &&\n\t\t\t\t\t\t(await restorePersistentCache({\n\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\tcompilerOptions: args,\n\t\t\t\t\t\t\toutputStructure,\n\t\t\t\t\t\t}))\n\t\t\t\t\t) {\n\t\t\t\t\t\tlogger.info(\n\t\t\t\t\t\t\t`Compilation skipped — inputs unchanged (${outputStructure})`\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tif (\n\t\t\t\t\t\tawait hasUnchangedInputs({\n\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\tcompilerOptions: args,\n\t\t\t\t\t\t\toutputStructure,\n\t\t\t\t\t\t})\n\t\t\t\t\t) {\n\t\t\t\t\t\tlogger.info(\n\t\t\t\t\t\t\t`Compilation skipped — inputs unchanged (${outputStructure})`\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tconst seededPrevious =\n\t\t\t\t\t\tstate.previousCompilation ??\n\t\t\t\t\t\t(await seedPreviousCompilationFromOutdir({\n\t\t\t\t\t\t\toutdir: args.outdir,\n\t\t\t\t\t\t\tfs: args.fs?.promises,\n\t\t\t\t\t\t}));\n\t\t\t\t\tawait compileAndUpdateState({\n\t\t\t\t\t\tstate,\n\t\t\t\t\t\tcompilerOptions: args,\n\t\t\t\t\t\toutputStructure,\n\t\t\t\t\t\tpreviousCompilation: seededPrevious,\n\t\t\t\t\t\tisServer: undefined,\n\t\t\t\t\t});\n\t\t\t\t\tawait writePersistentCache(state, args, outputStructure);\n\t\t\t\t\tlogger.success(`Compilation complete (${outputStructure})`);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tstate.previousInputsDigest = undefined;\n\t\t\t\t\tlogger.warn(\"Failed to compile project:\", (error as Error).message);\n\t\t\t\t\tlogger.warn(\"Please check your translation files for syntax errors.\");\n\t\t\t\t\tif (process.env.NODE_ENV === \"production\") throw error;\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t};\n};\n"]}
|
|
1
|
+
{"version":3,"file":"unplugin.js","sourceRoot":"","sources":["../../src/bundler-plugins/unplugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAA0B,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAA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AC,yBAAyB,eAAe,GAAG,CAAC,CAAC;gBAC7D,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBAChB,KAAK,CAAC,oBAAoB,GAAG,SAAS,CAAC;oBACvC,MAAM,CAAC,IAAI,CAAC,4BAA4B,EAAG,KAAe,CAAC,OAAO,CAAC,CAAC;oBACpE,MAAM,CAAC,IAAI,CAAC,wDAAwD,CAAC,CAAC;oBACtE,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;wBAAE,MAAM,KAAK,CAAC;gBACxD,CAAC;YACF,CAAC,CAAC,CAAC;QACJ,CAAC;KACD,CAAC;AACH,CAAC,CAAC","sourcesContent":["import type { UnpluginFactory } from \"unplugin\";\nimport { compile, type CompilationResult } from \"../compiler/compile.js\";\nimport { dirname, join, relative, resolve } from \"node:path\";\nimport { createHash } from \"node:crypto\";\nimport nodeFs from \"node:fs\";\nimport { Logger } from \"../services/logger/index.js\";\nimport { ENV_VARIABLES } from \"../services/env-variables/index.js\";\nimport type { CompilerOptions } from \"../compiler/compiler-options.js\";\nimport {\n\tcreateTrackedFs,\n\tgetWatchTargets,\n\tisPathWithinDirectories,\n} from \"../services/file-watching/tracked-fs.js\";\nimport { nodeNormalizePath } from \"../utilities/node-normalize-path.js\";\nimport { seedPreviousCompilationFromOutdir } from \"../compiler/seed-previous-compilation.js\";\nimport {\n\tCONFIG_FILE_NAMES,\n\tclearParaglideConfigCache,\n\tisConfigFileName,\n\tloadParaglideConfig,\n\tresolveCompilerOptions,\n\tresolveConfigCandidate,\n\ttype LoadedParaglideConfig,\n} from \"../services/config/index.js\";\nimport type { ErrorPayload, ViteDevServer, WebSocketClient } from \"vite\";\n\nconst PLUGIN_NAME = \"unplugin-paraglide-js\";\n\n/**\n * The options accepted by the paraglide bundler plugins.\n *\n * `project` is required — the path to your inlang project directory, which\n * also hosts the paraglide config file (`<project>/paraglide.config.*`).\n * Relative paths are resolved against the tool's project root (Vite `root`,\n * webpack/rspack `context`, else the process working directory).\n *\n * Every other property is optional: values that are not provided are read\n * from the config file, and anything still missing falls back to the\n * built-in defaults.\n *\n * @example\n * ```ts\n * paraglideVitePlugin({ project: \"./project.inlang\" })\n *\n * // Explicit options win over the config file\n * paraglideVitePlugin({\n * project: \"./project.inlang\",\n * outdir: \"./src/paraglide-custom\",\n * })\n * ```\n */\nexport type ParaglidePluginOptions = Omit<\n\tPartial<CompilerOptions>,\n\t\"project\"\n> & {\n\t/**\n\t * Required — the path to your inlang project directory, which also\n\t * hosts the paraglide config file (`<project>/paraglide.config.*`).\n\t * Relative paths are resolved against the tool's project root (Vite\n\t * `root`, webpack/rspack `context`, else the process working directory).\n\t */\n\tproject: string;\n};\n\nconst logger = new Logger();\n\nconst PERSISTENT_CACHE_VERSION = 1;\n\ntype PersistentCompilationCache = {\n\tversion: typeof PERSISTENT_CACHE_VERSION;\n\tcompilerVersion: string;\n\tinputsDigest: string;\n\treadFiles: string[];\n\toutputHashes: Record<string, string>;\n};\n\nfunction isStringRecord(value: unknown): value is Record<string, string> {\n\treturn (\n\t\ttypeof value === \"object\" &&\n\t\tvalue !== null &&\n\t\t!Array.isArray(value) &&\n\t\tObject.values(value).every((entry) => typeof entry === \"string\")\n\t);\n}\n\n/**\n * Default isServer which differs per bundler.\n */\nlet isServer: string | undefined;\n\ntype PluginState = {\n\t/** Identity of the fs the tracked wrapper was created around. */\n\tbaseFs: typeof nodeFs | undefined;\n\ttrackedFs: typeof nodeFs;\n\treadFiles: Set<string>;\n\tclearReadFiles: () => void;\n\tpreviousCompilation: CompilationResult | undefined;\n\tcompilationError: Error | undefined;\n\t/**\n\t * Digest of the input files and options of the last successful compilation.\n\t *\n\t * `vite build` fires `buildStart` once per environment (client, ssr, ...).\n\t * When the digest of the current inputs matches, `compile()` is skipped\n\t * entirely — project loading and message compilation are expensive even\n\t * when `previousCompilation` dedupes the writes.\n\t *\n\t * https://github.com/opral/paraglide-js/issues/693\n\t */\n\tpreviousInputsDigest: string | undefined;\n\tpreviousProject: string | undefined;\n\tpreviousOutdir: string | undefined;\n};\n\n// Module-scoped so the warm state survives plugin re-instantiation within\n// one process (e.g. a vite config reload), but recreated when a different\n// fs is passed — the tracked wrapper, read set, and cached compilation are\n// only valid for the filesystem they were produced from.\nlet pluginState: PluginState | undefined;\n\nfunction getPluginState(args: Pick<CompilerOptions, \"fs\">): PluginState {\n\tif (pluginState === undefined || pluginState.baseFs !== args.fs) {\n\t\tconst tracked = createTrackedFs({ fs: args.fs });\n\t\tpluginState = {\n\t\t\tbaseFs: args.fs,\n\t\t\ttrackedFs: tracked.fs,\n\t\t\treadFiles: tracked.readFiles,\n\t\t\tclearReadFiles: tracked.clearReadFiles,\n\t\t\tpreviousCompilation: undefined,\n\t\t\tcompilationError: undefined,\n\t\t\tpreviousInputsDigest: undefined,\n\t\t\tpreviousProject: undefined,\n\t\t\tpreviousOutdir: undefined,\n\t\t};\n\t}\n\treturn pluginState;\n}\n\nfunction withoutCleanOutdir(\n\targs: CompilerOptions\n): Omit<CompilerOptions, \"cleanOutdir\"> {\n\tconst { cleanOutdir, ...compileArgs } = args;\n\tvoid cleanOutdir;\n\treturn compileArgs;\n}\n\nfunction getCompilerConfig(\n\targs: CompilerOptions,\n\toutputStructure: NonNullable<CompilerOptions[\"outputStructure\"]>\n) {\n\tconst { fs: _fs, ...serializableArgs } = args;\n\tvoid _fs;\n\treturn {\n\t\t...serializableArgs,\n\t\toutputStructure,\n\t\tisServer,\n\t\tcompilerVersion: ENV_VARIABLES.PARJS_PACKAGE_VERSION,\n\t};\n}\n\n/**\n * Hashes the files (and directory listings) the last compilation read,\n * together with the options that affect the output. Returns `undefined`\n * when the digest can't be computed (no tracked reads yet, an unexpected\n * read error, ...) — `undefined` never matches, so the caller compiles.\n *\n * Directory listings are included so that a message file *added* next to\n * the tracked ones invalidates the digest, not only edits to known files.\n * All components are length-prefixed so distinct input states can't\n * produce the same hash stream.\n *\n * The digest is taken after the compile, by re-reading the inputs. A file\n * edited *during* a compile can therefore be hashed at its new content\n * while the output reflects the old one — accepted: in dev, watchChange\n * recompiles on that edit, and a fresh build process always recompiles.\n */\nasync function computeInputsDigest(\n\tstate: PluginState,\n\targs: CompilerOptions,\n\toutputStructure: NonNullable<CompilerOptions[\"outputStructure\"]>\n): Promise<string | undefined> {\n\tif (state.readFiles.size === 0) {\n\t\treturn undefined;\n\t}\n\tconst targets = getWatchTargets(state.readFiles, { outdir: args.outdir });\n\tif (targets.files.size === 0) {\n\t\treturn undefined;\n\t}\n\tconst fsp = (args.fs ?? nodeFs).promises;\n\tconst hash = createHash(\"sha256\");\n\ttry {\n\t\thash.update(JSON.stringify(getCompilerConfig(args, outputStructure)));\n\t\tfor (const directoryPath of [...targets.directories].sort()) {\n\t\t\tconst entries = await fsp\n\t\t\t\t.readdir(directoryPath)\n\t\t\t\t// tracked reads include probed-but-absent paths (the SDK reads\n\t\t\t\t// optional files and handles ENOENT itself) — a missing entry\n\t\t\t\t// is valid input state, hash it as such\n\t\t\t\t.catch(rethrowUnlessEnoent);\n\t\t\thash.update(`\\0dir:${directoryPath.length}:${directoryPath}:`);\n\t\t\tif (entries === undefined) {\n\t\t\t\thash.update(\"missing\");\n\t\t\t} else {\n\t\t\t\tfor (const entry of [...entries].sort()) {\n\t\t\t\t\thash.update(`${entry.length}:${entry},`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (const filePath of [...targets.files].sort()) {\n\t\t\tconst content = await fsp.readFile(filePath).catch(rethrowUnlessEnoent);\n\t\t\thash.update(`\\0file:${filePath.length}:${filePath}:`);\n\t\t\tif (content === undefined) {\n\t\t\t\thash.update(\"missing\");\n\t\t\t} else {\n\t\t\t\thash.update(`${content.length}:`);\n\t\t\t\thash.update(content);\n\t\t\t}\n\t\t}\n\t} catch {\n\t\treturn undefined;\n\t}\n\treturn hash.digest(\"hex\");\n}\n\nfunction getPersistentCachePath(\n\targs: CompilerOptions,\n\toutputStructure: NonNullable<CompilerOptions[\"outputStructure\"]>\n): string {\n\tconst absoluteOutdir = resolve(process.cwd(), args.outdir);\n\tconst cacheKey = createHash(\"sha256\")\n\t\t.update(\n\t\t\tJSON.stringify({\n\t\t\t\tabsoluteOutdir,\n\t\t\t\tcompilerConfig: getCompilerConfig(args, outputStructure),\n\t\t\t})\n\t\t)\n\t\t.digest(\"hex\")\n\t\t.slice(0, 16);\n\treturn resolve(\n\t\tprocess.cwd(),\n\t\targs.project,\n\t\t\"cache\",\n\t\t\"paraglide-js\",\n\t\t`${cacheKey}.json`\n\t);\n}\n\nasync function readPersistentCache(\n\targs: CompilerOptions,\n\toutputStructure: NonNullable<CompilerOptions[\"outputStructure\"]>\n): Promise<PersistentCompilationCache | undefined> {\n\tconst fsp = (args.fs ?? nodeFs).promises;\n\ttry {\n\t\tconst parsed = JSON.parse(\n\t\t\tawait fsp.readFile(getPersistentCachePath(args, outputStructure), \"utf8\")\n\t\t) as Partial<PersistentCompilationCache>;\n\t\tif (\n\t\t\tparsed.version !== PERSISTENT_CACHE_VERSION ||\n\t\t\tparsed.compilerVersion !== ENV_VARIABLES.PARJS_PACKAGE_VERSION ||\n\t\t\ttypeof parsed.inputsDigest !== \"string\" ||\n\t\t\t!Array.isArray(parsed.readFiles) ||\n\t\t\tparsed.readFiles.some((file) => typeof file !== \"string\") ||\n\t\t\t!isStringRecord(parsed.outputHashes)\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn parsed as PersistentCompilationCache;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nasync function preparePersistentCacheDirectory(\n\targs: CompilerOptions,\n\toutputStructure: NonNullable<CompilerOptions[\"outputStructure\"]>\n): Promise<void> {\n\ttry {\n\t\tawait (args.fs ?? nodeFs).promises.mkdir(\n\t\t\tdirname(getPersistentCachePath(args, outputStructure)),\n\t\t\t{ recursive: true }\n\t\t);\n\t} catch {\n\t\t// The cache is an optimization. Read-only projects must still compile.\n\t}\n}\n\nasync function writePersistentCache(\n\tstate: PluginState,\n\targs: CompilerOptions,\n\toutputStructure: NonNullable<CompilerOptions[\"outputStructure\"]>\n): Promise<void> {\n\tif (\n\t\tstate.previousInputsDigest === undefined ||\n\t\tstate.previousCompilation?.outputHashes === undefined\n\t) {\n\t\treturn;\n\t}\n\tconst cachePath = getPersistentCachePath(args, outputStructure);\n\tconst cache: PersistentCompilationCache = {\n\t\tversion: PERSISTENT_CACHE_VERSION,\n\t\tcompilerVersion: ENV_VARIABLES.PARJS_PACKAGE_VERSION,\n\t\tinputsDigest: state.previousInputsDigest,\n\t\treadFiles: [...state.readFiles].sort(),\n\t\toutputHashes: state.previousCompilation.outputHashes,\n\t};\n\tconst fsp = (args.fs ?? nodeFs).promises;\n\ttry {\n\t\tawait fsp.mkdir(dirname(cachePath), { recursive: true });\n\t\tawait fsp.writeFile(cachePath, JSON.stringify(cache));\n\t} catch {\n\t\t// The cache is an optimization. Read-only projects must still compile.\n\t}\n}\n\nfunction outputHashesMatch(\n\tleft: Record<string, string> | undefined,\n\tright: Record<string, string>\n): boolean {\n\tif (left === undefined) return false;\n\tconst leftEntries = Object.entries(left);\n\tconst rightEntries = Object.entries(right);\n\tif (leftEntries.length !== rightEntries.length) return false;\n\treturn leftEntries.every(([file, hash]) => right[file] === hash);\n}\n\nasync function restorePersistentCache(args: {\n\tstate: PluginState;\n\tcompilerOptions: CompilerOptions;\n\toutputStructure: NonNullable<CompilerOptions[\"outputStructure\"]>;\n}): Promise<boolean> {\n\tconst cached = await readPersistentCache(\n\t\targs.compilerOptions,\n\t\targs.outputStructure\n\t);\n\tif (cached === undefined) return false;\n\n\tconst cachedReadFiles = new Set<string>();\n\tfor (const file of cached.readFiles) {\n\t\tcachedReadFiles.add(file);\n\t}\n\tconst validationState: PluginState = {\n\t\t...args.state,\n\t\treadFiles: cachedReadFiles,\n\t\tclearReadFiles: () => cachedReadFiles.clear(),\n\t};\n\tconst [inputsDigest, previousCompilation] = await Promise.all([\n\t\tcomputeInputsDigest(\n\t\t\tvalidationState,\n\t\t\targs.compilerOptions,\n\t\t\targs.outputStructure\n\t\t),\n\t\tseedPreviousCompilationFromOutdir({\n\t\t\toutdir: args.compilerOptions.outdir,\n\t\t\tfs: args.compilerOptions.fs?.promises,\n\t\t}),\n\t]);\n\tif (\n\t\tinputsDigest !== cached.inputsDigest ||\n\t\t!outputHashesMatch(previousCompilation?.outputHashes, cached.outputHashes)\n\t) {\n\t\treturn false;\n\t}\n\n\targs.state.clearReadFiles();\n\tfor (const file of cachedReadFiles) {\n\t\targs.state.readFiles.add(file);\n\t}\n\targs.state.previousCompilation = previousCompilation;\n\targs.state.previousInputsDigest = inputsDigest;\n\treturn true;\n}\n\nfunction rethrowUnlessEnoent(error: unknown): undefined {\n\tif ((error as NodeJS.ErrnoException)?.code === \"ENOENT\") {\n\t\treturn undefined;\n\t}\n\tthrow error;\n}\n\n// default to locale-modules for development to speed up the dev server\n// https://github.com/opral/inlang-paraglide-js/issues/486\nfunction resolveOutputStructure(\n\toptions: CompilerOptions\n): \"message-modules\" | \"locale-modules\" {\n\tconst isProduction = process.env.NODE_ENV === \"production\";\n\treturn (\n\t\toptions.outputStructure ??\n\t\t(isProduction ? \"message-modules\" : \"locale-modules\")\n\t);\n}\n\nfunction hasUnchangedInputs(args: {\n\tstate: PluginState;\n\tcompilerOptions: CompilerOptions;\n\toutputStructure: \"message-modules\" | \"locale-modules\";\n}): Promise<boolean> {\n\tif (args.state.previousCompilation === undefined) {\n\t\treturn Promise.resolve(false);\n\t}\n\tif (args.state.previousInputsDigest === undefined) {\n\t\treturn Promise.resolve(false);\n\t}\n\treturn computeInputsDigest(\n\t\targs.state,\n\t\targs.compilerOptions,\n\t\targs.outputStructure\n\t).then((currentDigest) => currentDigest === args.state.previousInputsDigest);\n}\n\nfunction maybeInvalidateForOptionsChange(\n\tstate: PluginState,\n\tcompilerOptions: CompilerOptions\n): void {\n\tif (\n\t\tstate.previousProject !== undefined &&\n\t\t(state.previousProject !== compilerOptions.project ||\n\t\t\tstate.previousOutdir !== compilerOptions.outdir)\n\t) {\n\t\tstate.previousCompilation = undefined;\n\t\tstate.previousInputsDigest = undefined;\n\t\tstate.clearReadFiles();\n\t}\n\tstate.previousProject = compilerOptions.project;\n\tstate.previousOutdir = compilerOptions.outdir;\n}\n\n// Compiles and stores the result plus its inputs digest on the plugin\n// state. Callers decide whether to persist the compilation cache.\nasync function compileAndUpdateState(args: {\n\tstate: PluginState;\n\tcompilerOptions: CompilerOptions;\n\toutputStructure: \"message-modules\" | \"locale-modules\";\n\tpreviousCompilation: CompilationResult | undefined;\n\t/**\n\t * The `isServer` expression to bake into the compiled runtime.\n\t * Webpack omits it and relies on the compiler default.\n\t */\n\tisServer: string | undefined;\n}): Promise<void> {\n\targs.state.previousCompilation = await compile({\n\t\tpreviousCompilation: args.previousCompilation,\n\t\toutputStructure: args.outputStructure,\n\t\tisServer: args.isServer,\n\t\t...withoutCleanOutdir(args.compilerOptions),\n\t\tcleanOutdir: false,\n\t\t// after the options spread so a user-provided fs doesn't bypass\n\t\t// the read tracking (trackedFs wraps options.fs when provided)\n\t\tfs: args.state.trackedFs,\n\t});\n\targs.state.previousInputsDigest = await computeInputsDigest(\n\t\targs.state,\n\t\targs.compilerOptions,\n\t\targs.outputStructure\n\t);\n}\n\n/**\n * Runs the compilation with the given, already-resolved options. Shared by\n * buildStart and watch-mode rebuilds.\n */\nasync function runCompilation(args: {\n\tstate: PluginState;\n\tcompilerOptions: CompilerOptions;\n}): Promise<void> {\n\tconst compilerOptions = args.compilerOptions;\n\tconst { state } = args;\n\tconst outputStructure = resolveOutputStructure(compilerOptions);\n\tmaybeInvalidateForOptionsChange(state, compilerOptions);\n\tstate.compilationError = undefined;\n\ttry {\n\t\t// Stabilize project directory listings before the first digest. The\n\t\t// ignored cache directory must not invalidate the cache that creates it.\n\t\tawait preparePersistentCacheDirectory(compilerOptions, outputStructure);\n\t\tif (\n\t\t\tstate.previousCompilation === undefined &&\n\t\t\t(await restorePersistentCache({\n\t\t\t\tstate,\n\t\t\t\tcompilerOptions,\n\t\t\t\toutputStructure,\n\t\t\t}))\n\t\t) {\n\t\t\tlogger.info(\n\t\t\t\t`Compilation skipped — inputs unchanged (${outputStructure})`\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tif (\n\t\t\tawait hasUnchangedInputs({\n\t\t\t\tstate,\n\t\t\t\tcompilerOptions,\n\t\t\t\toutputStructure,\n\t\t\t})\n\t\t) {\n\t\t\tlogger.info(\n\t\t\t\t`Compilation skipped — inputs unchanged (${outputStructure})`\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\t// On a fresh process, seed previousCompilation from on-disk hashes\n\t\t// so the first compile is a no-op when inputs are unchanged. Avoids\n\t\t// racing concurrent readers that wiping outdir would interrupt.\n\t\tconst seededPrevious =\n\t\t\tstate.previousCompilation ??\n\t\t\t(await seedPreviousCompilationFromOutdir({\n\t\t\t\toutdir: compilerOptions.outdir,\n\t\t\t\tfs: compilerOptions.fs?.promises,\n\t\t\t}));\n\t\tawait compileAndUpdateState({\n\t\t\tstate,\n\t\t\tcompilerOptions,\n\t\t\toutputStructure,\n\t\t\tpreviousCompilation: seededPrevious,\n\t\t\tisServer,\n\t\t});\n\t\tawait writePersistentCache(state, compilerOptions, outputStructure);\n\t\tlogger.success(`Compilation complete (${outputStructure})`);\n\t} catch (error) {\n\t\tstate.compilationError =\n\t\t\terror instanceof Error ? error : new Error(String(error));\n\t\tstate.previousInputsDigest = undefined;\n\t\tlogger.error(\"Failed to compile project:\", (error as Error).message);\n\t\tlogger.info(\"Please check your translation files for syntax errors.\");\n\t\tif (process.env.NODE_ENV === \"production\") throw error;\n\t}\n}\n\n// The return type preserves literal option types (`enforce: \"pre\"`, ...)\n// while `project` stays required on the input side.\ntype UnpluginIntegrationOptions = Pick<CompilerOptions, \"outputStructure\"> & {\n\tdevErrorResponse?: boolean;\n};\n\ntype UnpluginFactoryWithOptions = (\n\tuserArgs: ParaglidePluginOptions,\n\tmeta?: Parameters<UnpluginFactory<ParaglidePluginOptions>>[1],\n\tdefaults?: UnpluginIntegrationOptions\n) => ReturnType<UnpluginFactory<ParaglidePluginOptions>>;\n\nexport const unpluginFactory: UnpluginFactoryWithOptions = (\n\tuserArgs,\n\t_meta,\n\tdefaults\n) => {\n\tconst state = getPluginState(userArgs);\n\tconst { readFiles, clearReadFiles } = state;\n\t// Project root as reported by the bundler (vite `root`, webpack/rspack\n\t// `context`). Falls back to the process working directory when the\n\t// bundler doesn't provide one. The config file is resolved inside the\n\t// project directory.\n\tlet discoveryRoot: string | undefined;\n\t// Bound to the hook context in buildStart so that watchChange can\n\t// register additional files.\n\tlet addWatchFile: ((path: string) => void) | undefined;\n\t// A new plugin instance must not be served by config cache entries\n\t// from a previous instance (e.g. vite.config.ts reloads reuse the\n\t// process). Wiping the cache here makes every instance perform one\n\t// fresh load; subsequent loads within the instance stay cached.\n\tclearParaglideConfigCache();\n\n\tfunction safeAddWatchFile(\n\t\tthisArg: { addWatchFile: (path: string) => void } | undefined,\n\t\tpath: string\n\t): void {\n\t\tconst fn = thisArg?.addWatchFile ?? addWatchFile;\n\t\tif (!fn) return;\n\t\tif (watchRegistrationUnsupported) return;\n\t\ttry {\n\t\t\tfn.call(thisArg ?? undefined, path);\n\t\t} catch (error) {\n\t\t\t// Watch-file registration is best-effort: backends differ in what\n\t\t\t// they support (unplugin's esbuild context throws for every call),\n\t\t\t// and watcher resource limits can surface as errors. A failed\n\t\t\t// registration must never fail the build.\n\t\t\twatchRegistrationUnsupported = true;\n\t\t\tlogger.warn(\n\t\t\t\t`Registering additional watch files is not supported by this bundler context — skipping further registrations (${(error as Error)?.message ?? String(error)})`\n\t\t\t);\n\t\t}\n\t}\n\n\t// Whether a config file was present at the last load — drives the\n\t// one-time warning when every config candidate disappears.\n\tlet hadActiveConfig = false;\n\t// Watch-rebuild serialization state (see watchChange).\n\tlet compiling = false;\n\tlet isClosed = false;\n\tlet pendingCompilation: Promise<void> | undefined;\n\tconst pendingWatchPaths = new Set<string>();\n\tconst pendingCompilationCachePaths = new Set<string>();\n\t// Options from the most recent successful resolution — reused by input\n\t// events that cannot have changed them.\n\tlet lastOptions: CompilerOptions | undefined;\n\t// Set once a bundler context rejects watch-file registrations (esbuild);\n\t// further registration attempts are skipped to avoid warning floods.\n\tlet watchRegistrationUnsupported = false;\n\tlet viteServer: ViteDevServer | undefined;\n\tlet viteError: ErrorPayload | undefined;\n\tlet configLoadFailed = false;\n\n\tfunction reportViteError(\n\t\terror: unknown,\n\t\tsource: \"config\" | \"compilation\" = \"compilation\"\n\t): void {\n\t\tif (!viteServer || process.env.NODE_ENV === \"production\") return;\n\t\tif (configLoadFailed && source === \"compilation\") return;\n\t\tif (source === \"config\") configLoadFailed = true;\n\t\tconst failure = error instanceof Error ? error : new Error(String(error));\n\t\tviteError = {\n\t\t\ttype: \"error\",\n\t\t\terr: {\n\t\t\t\tmessage: failure.message,\n\t\t\t\tstack: failure.stack ?? \"\",\n\t\t\t\tplugin: PLUGIN_NAME,\n\t\t\t},\n\t\t};\n\t\t// Older Vite versions buffer errors without clients, even after recovery.\n\t\tif (viteServer.ws.clients.size > 0) viteServer.ws.send(viteError);\n\t}\n\n\tfunction clearViteError(): void {\n\t\tif (!viteServer || !viteError || configLoadFailed) return;\n\t\tviteError = undefined;\n\t\t// An invalid config can recover without writing generated files,\n\t\t// leaving no HMR update to dismiss the error overlay.\n\t\tif (viteServer.ws.clients.size > 0) {\n\t\t\tviteServer.ws.send({ type: \"full-reload\" });\n\t\t}\n\t}\n\n\tconst getProjectDir = () =>\n\t\tnodeNormalizePath(\n\t\t\tresolve(discoveryRoot ?? process.cwd(), userArgs.project)\n\t\t);\n\n\tconst resolveOptionsWith = (\n\t\tloaded: LoadedParaglideConfig | undefined\n\t): CompilerOptions => {\n\t\tconst options = resolveCompilerOptions({\n\t\t\tconfig: loaded?.config,\n\t\t\toverrides: userArgs,\n\t\t\troot: discoveryRoot ?? process.cwd(),\n\t\t});\n\t\t// Apply integration defaults after each config load, keeping watched\n\t\t// config values separate from explicit plugin overrides.\n\t\tif (\n\t\t\toptions.outputStructure === undefined &&\n\t\t\tdefaults?.outputStructure !== undefined\n\t\t) {\n\t\t\toptions.outputStructure = defaults.outputStructure;\n\t\t}\n\t\treturn options;\n\t};\n\n\t/**\n\t * Loads the active config, following candidate renames and keeping the\n\t * last known-good configuration while the file is missing or invalid.\n\t * Callers that know the config content changed should clear the cache\n\t * for the project directory first.\n\t */\n\tasync function loadActiveConfig(): Promise<\n\t\tLoadedParaglideConfig | undefined\n\t> {\n\t\tconst dir = getProjectDir();\n\t\tconst winner = await resolveConfigCandidate(dir);\n\t\tif (winner === undefined) {\n\t\t\tif (hadActiveConfig) {\n\t\t\t\thadActiveConfig = false;\n\t\t\t\tlogger.warn(\n\t\t\t\t\t\"Paraglide config file was removed, continuing with default options.\"\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\t\thadActiveConfig = true;\n\t\t// Throws when the file exists but is invalid — callers decide the\n\t\t// policy: watch modes skip and surface the error in development,\n\t\t// build paths fail loudly in production.\n\t\treturn loadParaglideConfig({ projectDir: dir, logger });\n\t}\n\n\t/**\n\t * Rebuild for a single watch event. Config-named events reload the\n\t * config; input events reuse the last known options unless the config\n\t * failed to load.\n\t */\n\tasync function performWatchRecompile(path: string): Promise<void> {\n\t\tconst normalizedPath = nodeNormalizePath(path);\n\t\tconst projectDir = getProjectDir();\n\t\tconst withinProjectDir =\n\t\t\tnormalizedPath === projectDir ||\n\t\t\tnormalizedPath.startsWith(`${projectDir}/`);\n\t\tconst configEvent = withinProjectDir && isConfigFileName(normalizedPath);\n\n\t\tlet args: CompilerOptions;\n\t\tif (!configEvent && lastOptions !== undefined) {\n\t\t\tconst targets = getWatchTargets(readFiles, {\n\t\t\t\toutdir: lastOptions.outdir,\n\t\t\t});\n\t\t\tif (targets.isIgnoredPath(normalizedPath)) return;\n\t\t\tconst shouldCompile =\n\t\t\t\ttargets.files.has(normalizedPath) ||\n\t\t\t\tisPathWithinDirectories(normalizedPath, targets.directories);\n\t\t\tif (!shouldCompile) return;\n\t\t}\n\t\tif (!configEvent && lastOptions !== undefined && !configLoadFailed) {\n\t\t\targs = lastOptions;\n\t\t} else {\n\t\t\tif (configEvent) {\n\t\t\t\tlogger.info(\"Paraglide configuration changed, re-compiling.\");\n\t\t\t\tclearParaglideConfigCache({ projectDir });\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tconst loaded = await loadActiveConfig();\n\t\t\t\targs = resolveOptionsWith(loaded);\n\t\t\t} catch (error) {\n\t\t\t\t// Invalid config: skip the compilation entirely and surface\n\t\t\t\t// the problem. The previously compiled output stays on disk.\n\t\t\t\treportViteError(error, \"config\");\n\t\t\t\tlogger.error((error as Error).message);\n\t\t\t\tlogger.error(\n\t\t\t\t\t\"Skipping compilation because of the invalid paraglide config.\"\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tlastOptions = args;\n\t\t\tconfigLoadFailed = false;\n\t\t}\n\n\t\tmaybeInvalidateForOptionsChange(state, args);\n\t\tconst outputStructure = resolveOutputStructure(args);\n\t\tconst previouslyReadFiles = new Set(readFiles);\n\n\t\ttry {\n\t\t\tif (!configEvent) {\n\t\t\t\tlogger.info(\n\t\t\t\t\t`Re-compiling inlang project... File \"${relative(process.cwd(), path)}\" has changed.`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tclearReadFiles();\n\t\t\tpendingCompilationCachePaths.add(\n\t\t\t\tgetPersistentCachePath(args, outputStructure)\n\t\t\t);\n\t\t\tawait compileAndUpdateState({\n\t\t\t\tstate,\n\t\t\t\tcompilerOptions: args,\n\t\t\t\toutputStructure,\n\t\t\t\tpreviousCompilation: state.previousCompilation,\n\t\t\t\tisServer,\n\t\t\t});\n\t\t\tawait writePersistentCache(state, args, outputStructure);\n\t\t\tlogger.success(`Re-compilation complete (${outputStructure})`);\n\t\t\tclearViteError();\n\n\t\t\tconst nextTargets = getWatchTargets(readFiles, { outdir: args.outdir });\n\t\t\tfor (const filePath of nextTargets.files)\n\t\t\t\tsafeAddWatchFile(undefined, filePath);\n\t\t\tfor (const directoryPath of nextTargets.directories)\n\t\t\t\tsafeAddWatchFile(undefined, directoryPath);\n\t\t} catch (e) {\n\t\t\treportViteError(e);\n\t\t\tclearReadFiles();\n\t\t\tfor (const filePath of previouslyReadFiles) readFiles.add(filePath);\n\t\t\tstate.previousCompilation = undefined;\n\t\t\tstate.previousInputsDigest = undefined;\n\t\t\tlogger.warn(\"Failed to re-compile project:\", (e as Error).message);\n\t\t}\n\t}\n\n\treturn {\n\t\tname: PLUGIN_NAME,\n\t\tenforce: \"pre\",\n\t\tasync buildStart() {\n\t\t\tif (isClosed) clearParaglideConfigCache({ projectDir: getProjectDir() });\n\t\t\tisClosed = false;\n\t\t\taddWatchFile = this.addWatchFile?.bind(this);\n\t\t\ttry {\n\t\t\t\tconst loaded = await loadActiveConfig();\n\t\t\t\tconst args = resolveOptionsWith(loaded);\n\t\t\t\tconfigLoadFailed = false;\n\t\t\t\tlastOptions = args;\n\t\t\t\tawait runCompilation({ state, compilerOptions: args });\n\t\t\t} catch (error) {\n\t\t\t\t// Config errors are converted to last-good options by\n\t\t\t\t// loadActiveConfig; compilation errors are handled inside\n\t\t\t\t// runCompilation. Anything escaping is unexpected — fail the\n\t\t\t\t// build in production, keep serving in development.\n\t\t\t\tif (process.env.NODE_ENV === \"production\") throw error;\n\t\t\t\tlogger.error(\n\t\t\t\t\t\"Failed to prepare paraglide compilation:\",\n\t\t\t\t\t(error as Error).message\n\t\t\t\t);\n\t\t\t\treportViteError(error, \"config\");\n\t\t\t\treturn;\n\t\t\t} finally {\n\t\t\t\tif (lastOptions !== undefined) {\n\t\t\t\t\tconst targets = getWatchTargets(readFiles, {\n\t\t\t\t\t\toutdir: lastOptions.outdir,\n\t\t\t\t\t});\n\t\t\t\t\tfor (const filePath of targets.files)\n\t\t\t\t\t\tsafeAddWatchFile(this, filePath);\n\t\t\t\t\tfor (const directoryPath of targets.directories)\n\t\t\t\t\t\tsafeAddWatchFile(this, directoryPath);\n\t\t\t\t}\n\t\t\t\t// Register every config candidate inside the project directory\n\t\t\t\t// so renames and format switches are reported even by backends\n\t\t\t\t// that only report watched files (webpack's modifiedFiles).\n\t\t\t\tconst projectDir = getProjectDir();\n\t\t\t\tfor (const name of CONFIG_FILE_NAMES) {\n\t\t\t\t\tsafeAddWatchFile(\n\t\t\t\t\t\tthis as unknown as { addWatchFile: (p: string) => void },\n\t\t\t\t\t\tjoin(projectDir, name)\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (state.compilationError) {\n\t\t\t\treportViteError(state.compilationError);\n\t\t\t} else {\n\t\t\t\tclearViteError();\n\t\t\t}\n\t\t},\n\t\twatchChange(path) {\n\t\t\tif (isClosed) return pendingCompilation;\n\t\t\t// Serialize rebuilds: bundlers may deliver several watchChange\n\t\t\t// events concurrently (webpack fires once per modified file).\n\t\t\t// Every path is queued — a config event must never be starved by\n\t\t\t// later input events.\n\t\t\tpendingWatchPaths.add(nodeNormalizePath(path));\n\t\t\tif (compiling) return pendingCompilation;\n\t\t\tcompiling = true;\n\t\t\tpendingCompilation = (async () => {\n\t\t\t\ttry {\n\t\t\t\t\twhile (pendingWatchPaths.size > 0) {\n\t\t\t\t\t\tconst batch = [...pendingWatchPaths];\n\t\t\t\t\t\tpendingWatchPaths.clear();\n\t\t\t\t\t\tfor (const current of batch) {\n\t\t\t\t\t\t\tawait performWatchRecompile(current);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} finally {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tif (isClosed) {\n\t\t\t\t\t\t\t// Inputs can change after compile reads them but before its\n\t\t\t\t\t\t\t// digest is taken. Once closing starts, watcher events can\n\t\t\t\t\t\t\t// no longer repair that mismatch, so neither warm nor cold\n\t\t\t\t\t\t\t// restarts may reuse caches from this queue.\n\t\t\t\t\t\t\tstate.previousInputsDigest = undefined;\n\t\t\t\t\t\t\tfor (const cachePath of pendingCompilationCachePaths) {\n\t\t\t\t\t\t\t\tawait (userArgs.fs ?? nodeFs).promises.rm(cachePath, {\n\t\t\t\t\t\t\t\t\tforce: true,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tpendingCompilationCachePaths.clear();\n\t\t\t\t\t\tcompiling = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t})();\n\t\t\treturn pendingCompilation;\n\t\t},\n\t\tcloseBundle() {\n\t\t\tisClosed = true;\n\t\t\treturn pendingCompilation;\n\t\t},\n\t\tvite: {\n\t\t\tconfig: {\n\t\t\t\thandler: () => {\n\t\t\t\t\tisServer = \"import.meta.env?.SSR ?? typeof window === 'undefined'\";\n\t\t\t\t},\n\t\t\t},\n\t\t\tconfigEnvironment: {\n\t\t\t\thandler: () => {\n\t\t\t\t\tisServer = \"import.meta.env?.SSR ?? typeof window === 'undefined'\";\n\t\t\t\t},\n\t\t\t},\n\t\t\tconfigResolved: {\n\t\t\t\thandler: (config: { root?: string }) => {\n\t\t\t\t\tdiscoveryRoot = config.root;\n\t\t\t\t},\n\t\t\t},\n\t\t\tconfigureServer(server) {\n\t\t\t\tviteServer = server;\n\t\t\t\tif (defaults?.devErrorResponse) {\n\t\t\t\t\tserver.middlewares.use((_request, response, next) => {\n\t\t\t\t\t\tif (!viteError) return next();\n\t\t\t\t\t\tresponse.statusCode = 500;\n\t\t\t\t\t\tresponse.setHeader(\"Content-Type\", \"text/plain; charset=utf-8\");\n\t\t\t\t\t\tresponse.setHeader(\"Cache-Control\", \"no-store\");\n\t\t\t\t\t\tresponse.end(viteError.err.message);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tserver.ws.on(\"connection\", (socket: WebSocketClient[\"socket\"]) => {\n\t\t\t\t\tif (viteError) socket.send(JSON.stringify(viteError));\n\t\t\t\t});\n\t\t\t},\n\t\t},\n\t\twebpack(compiler) {\n\t\t\tdiscoveryRoot = compiler.context;\n\t\t\tcompiler.options.resolve = {\n\t\t\t\t...compiler.options.resolve,\n\t\t\t\tfallback: {\n\t\t\t\t\t...compiler.options.resolve?.fallback,\n\t\t\t\t\t// https://stackoverflow.com/a/72989932\n\t\t\t\t\tasync_hooks: false,\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tcompiler.hooks.beforeRun.tapPromise(PLUGIN_NAME, async () => {\n\t\t\t\tlet args: CompilerOptions;\n\t\t\t\ttry {\n\t\t\t\t\tconst loaded = await loadActiveConfig();\n\t\t\t\t\targs = resolveOptionsWith(loaded);\n\t\t\t\t\tlastOptions = args;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tstate.previousInputsDigest = undefined;\n\t\t\t\t\tstate.previousCompilation = undefined;\n\t\t\t\t\tlogger.error(\n\t\t\t\t\t\t\"Failed to load paraglide config:\",\n\t\t\t\t\t\t(error as Error).message\n\t\t\t\t\t);\n\t\t\t\t\tif (process.env.NODE_ENV === \"production\") throw error;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst outputStructure = resolveOutputStructure(args);\n\t\t\t\tmaybeInvalidateForOptionsChange(state, args);\n\t\t\t\ttry {\n\t\t\t\t\tawait preparePersistentCacheDirectory(args, outputStructure);\n\t\t\t\t\tif (\n\t\t\t\t\t\tstate.previousCompilation === undefined &&\n\t\t\t\t\t\t(await restorePersistentCache({\n\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\tcompilerOptions: args,\n\t\t\t\t\t\t\toutputStructure,\n\t\t\t\t\t\t}))\n\t\t\t\t\t) {\n\t\t\t\t\t\tlogger.info(\n\t\t\t\t\t\t\t`Compilation skipped — inputs unchanged (${outputStructure})`\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\t// Multi-compiler webpack setups (client + server) trigger\n\t\t\t\t\t// beforeRun once per compiler — skip when inputs are unchanged.\n\t\t\t\t\tif (\n\t\t\t\t\t\tawait hasUnchangedInputs({\n\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\tcompilerOptions: args,\n\t\t\t\t\t\t\toutputStructure,\n\t\t\t\t\t\t})\n\t\t\t\t\t) {\n\t\t\t\t\t\tlogger.info(\n\t\t\t\t\t\t\t`Compilation skipped — inputs unchanged (${outputStructure})`\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tconst seededPrevious =\n\t\t\t\t\t\tstate.previousCompilation ??\n\t\t\t\t\t\t(await seedPreviousCompilationFromOutdir({\n\t\t\t\t\t\t\toutdir: args.outdir,\n\t\t\t\t\t\t\tfs: args.fs?.promises,\n\t\t\t\t\t\t}));\n\t\t\t\t\tawait compileAndUpdateState({\n\t\t\t\t\t\tstate,\n\t\t\t\t\t\tcompilerOptions: args,\n\t\t\t\t\t\toutputStructure,\n\t\t\t\t\t\tpreviousCompilation: seededPrevious,\n\t\t\t\t\t\t// webpack has no vite-style SSR expression; rely on the\n\t\t\t\t\t\t// compiler default.\n\t\t\t\t\t\tisServer: undefined,\n\t\t\t\t\t});\n\t\t\t\t\tawait writePersistentCache(state, args, outputStructure);\n\t\t\t\t\tlogger.success(`Compilation complete (${outputStructure})`);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tstate.previousInputsDigest = undefined;\n\t\t\t\t\tlogger.warn(\"Failed to compile project:\", (error as Error).message);\n\t\t\t\t\tlogger.warn(\"Please check your translation files for syntax errors.\");\n\t\t\t\t\tif (process.env.NODE_ENV === \"production\") throw error;\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t\trspack(compiler) {\n\t\t\tdiscoveryRoot = compiler.context;\n\t\t\t// Rspack mirrors webpack's hook API but ships no usable types,\n\t\t\t// so hooks are tapped structurally.\n\t\t\tconst tapRspackBeforeRun = (fn: () => Promise<void>): void => {\n\t\t\t\tconst target = (\n\t\t\t\t\tcompiler as unknown as {\n\t\t\t\t\t\thooks: Record<\n\t\t\t\t\t\t\tstring,\n\t\t\t\t\t\t\t{ tapPromise?: (n: string, fn: () => Promise<void>) => void }\n\t\t\t\t\t\t>;\n\t\t\t\t\t}\n\t\t\t\t).hooks?.beforeRun;\n\t\t\t\ttarget?.tapPromise?.(PLUGIN_NAME, fn);\n\t\t\t};\n\t\t\ttapRspackBeforeRun(async () => {\n\t\t\t\tlet args: CompilerOptions;\n\t\t\t\ttry {\n\t\t\t\t\tconst loaded = await loadActiveConfig();\n\t\t\t\t\targs = resolveOptionsWith(loaded);\n\t\t\t\t\tlastOptions = args;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tstate.previousInputsDigest = undefined;\n\t\t\t\t\tstate.previousCompilation = undefined;\n\t\t\t\t\tlogger.error(\n\t\t\t\t\t\t\"Failed to load paraglide config:\",\n\t\t\t\t\t\t(error as Error).message\n\t\t\t\t\t);\n\t\t\t\t\tif (process.env.NODE_ENV === \"production\") throw error;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst outputStructure = resolveOutputStructure(args);\n\t\t\t\tmaybeInvalidateForOptionsChange(state, args);\n\t\t\t\ttry {\n\t\t\t\t\tawait preparePersistentCacheDirectory(args, outputStructure);\n\t\t\t\t\tif (\n\t\t\t\t\t\tstate.previousCompilation === undefined &&\n\t\t\t\t\t\t(await restorePersistentCache({\n\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\tcompilerOptions: args,\n\t\t\t\t\t\t\toutputStructure,\n\t\t\t\t\t\t}))\n\t\t\t\t\t) {\n\t\t\t\t\t\tlogger.info(\n\t\t\t\t\t\t\t`Compilation skipped — inputs unchanged (${outputStructure})`\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tif (\n\t\t\t\t\t\tawait hasUnchangedInputs({\n\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\tcompilerOptions: args,\n\t\t\t\t\t\t\toutputStructure,\n\t\t\t\t\t\t})\n\t\t\t\t\t) {\n\t\t\t\t\t\tlogger.info(\n\t\t\t\t\t\t\t`Compilation skipped — inputs unchanged (${outputStructure})`\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tconst seededPrevious =\n\t\t\t\t\t\tstate.previousCompilation ??\n\t\t\t\t\t\t(await seedPreviousCompilationFromOutdir({\n\t\t\t\t\t\t\toutdir: args.outdir,\n\t\t\t\t\t\t\tfs: args.fs?.promises,\n\t\t\t\t\t\t}));\n\t\t\t\t\tawait compileAndUpdateState({\n\t\t\t\t\t\tstate,\n\t\t\t\t\t\tcompilerOptions: args,\n\t\t\t\t\t\toutputStructure,\n\t\t\t\t\t\tpreviousCompilation: seededPrevious,\n\t\t\t\t\t\tisServer: undefined,\n\t\t\t\t\t});\n\t\t\t\t\tawait writePersistentCache(state, args, outputStructure);\n\t\t\t\t\tlogger.success(`Compilation complete (${outputStructure})`);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tstate.previousInputsDigest = undefined;\n\t\t\t\t\tlogger.warn(\"Failed to compile project:\", (error as Error).message);\n\t\t\t\t\tlogger.warn(\"Please check your translation files for syntax errors.\");\n\t\t\t\t\tif (process.env.NODE_ENV === \"production\") throw error;\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t};\n};\n"]}
|
|
@@ -67,6 +67,66 @@ function setViteRoot(plugin, root) {
|
|
|
67
67
|
configResolved?.handler?.({ root });
|
|
68
68
|
}
|
|
69
69
|
const mockContext = { addWatchFile: () => { } };
|
|
70
|
+
test("closing Vite waits for an in-flight watch compilation", async () => {
|
|
71
|
+
process.env.NODE_ENV = "development";
|
|
72
|
+
const { workspace, projectDir, outdir } = await createProjectFixture();
|
|
73
|
+
let notifyEntered;
|
|
74
|
+
let releaseCompilation;
|
|
75
|
+
const entered = new Promise((resolve) => {
|
|
76
|
+
notifyEntered = resolve;
|
|
77
|
+
});
|
|
78
|
+
const released = new Promise((resolve) => {
|
|
79
|
+
releaseCompilation = resolve;
|
|
80
|
+
});
|
|
81
|
+
let shouldBlock = false;
|
|
82
|
+
vi.doMock("../compiler/compile.js", async (importOriginal) => {
|
|
83
|
+
const original = await importOriginal();
|
|
84
|
+
return {
|
|
85
|
+
...original,
|
|
86
|
+
compile: async (...args) => {
|
|
87
|
+
if (shouldBlock) {
|
|
88
|
+
notifyEntered();
|
|
89
|
+
await released;
|
|
90
|
+
}
|
|
91
|
+
return original.compile(...args);
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
});
|
|
95
|
+
const { createServer } = await import("vite");
|
|
96
|
+
const { paraglideVitePlugin } = await import("./vite.js");
|
|
97
|
+
const server = await createServer({
|
|
98
|
+
root: workspace,
|
|
99
|
+
configFile: false,
|
|
100
|
+
logLevel: "silent",
|
|
101
|
+
plugins: [paraglideVitePlugin({ project: projectDir, outdir })],
|
|
102
|
+
server: { middlewareMode: true, watch: null },
|
|
103
|
+
optimizeDeps: { noDiscovery: true, include: [] },
|
|
104
|
+
});
|
|
105
|
+
let pending;
|
|
106
|
+
try {
|
|
107
|
+
const file = path.join(projectDir, "settings.json");
|
|
108
|
+
const settings = JSON.parse(await realFs.promises.readFile(file, "utf8"));
|
|
109
|
+
await realFs.promises.writeFile(file, JSON.stringify({ ...settings, baseLocale: "de" }));
|
|
110
|
+
shouldBlock = true;
|
|
111
|
+
pending = server.pluginContainer.watchChange(file, { event: "update" });
|
|
112
|
+
await entered;
|
|
113
|
+
let didClose = false;
|
|
114
|
+
const closing = server.close().then(() => {
|
|
115
|
+
didClose = true;
|
|
116
|
+
});
|
|
117
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
118
|
+
expect(didClose).toBe(false);
|
|
119
|
+
releaseCompilation();
|
|
120
|
+
await closing;
|
|
121
|
+
expect(await realFs.promises.readFile(path.join(outdir, "runtime.js"), "utf8")).toContain('baseLocale = "de"');
|
|
122
|
+
}
|
|
123
|
+
finally {
|
|
124
|
+
releaseCompilation();
|
|
125
|
+
await pending;
|
|
126
|
+
await server.close();
|
|
127
|
+
vi.doUnmock("../compiler/compile.js");
|
|
128
|
+
}
|
|
129
|
+
});
|
|
70
130
|
function configureViteServer(plugin) {
|
|
71
131
|
const ws = {
|
|
72
132
|
send: vi.fn(),
|
|
@@ -76,6 +136,102 @@ function configureViteServer(plugin) {
|
|
|
76
136
|
plugin.configureServer?.({ ws });
|
|
77
137
|
return ws;
|
|
78
138
|
}
|
|
139
|
+
test.each(["settings", "config"])("ignores late %s events after close and resumes on buildStart", async (source) => {
|
|
140
|
+
process.env.NODE_ENV = "development";
|
|
141
|
+
const { workspace, projectDir, outdir } = await createProjectFixture();
|
|
142
|
+
const { paraglideVitePlugin } = await import("./vite.js");
|
|
143
|
+
const plugin = paraglideVitePlugin({ project: projectDir, outdir });
|
|
144
|
+
setViteRoot(plugin, workspace);
|
|
145
|
+
await plugin.buildStart.call(mockContext);
|
|
146
|
+
await plugin.closeBundle.call(mockContext);
|
|
147
|
+
const runtime = path.join(outdir, "runtime.js");
|
|
148
|
+
const before = await realFs.promises.readFile(runtime, "utf8");
|
|
149
|
+
const file = path.join(projectDir, source === "settings" ? "settings.json" : "paraglide.config.js");
|
|
150
|
+
if (source === "settings") {
|
|
151
|
+
const settings = JSON.parse(await realFs.promises.readFile(file, "utf8"));
|
|
152
|
+
await realFs.promises.writeFile(file, JSON.stringify({ ...settings, baseLocale: "de" }));
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
await realFs.promises.writeFile(file, 'export default { cookieName: "after-close" };');
|
|
156
|
+
}
|
|
157
|
+
await plugin.watchChange.call(mockContext, file);
|
|
158
|
+
expect(await realFs.promises.readFile(runtime, "utf8")).toBe(before);
|
|
159
|
+
await plugin.buildStart.call(mockContext);
|
|
160
|
+
expect(await realFs.promises.readFile(runtime, "utf8")).toContain(source === "settings" ? 'baseLocale = "de"' : 'cookieName = "after-close"');
|
|
161
|
+
});
|
|
162
|
+
test.each(["same instance", "new instance", "cold restart"].flatMap((restart) => [true, false].map((notifyLateChange) => ({ restart, notifyLateChange }))))("rebuilds after a shutdown input race: $restart, late event=$notifyLateChange", async ({ restart, notifyLateChange }) => {
|
|
163
|
+
process.env.NODE_ENV = "development";
|
|
164
|
+
const { workspace, projectDir, outdir } = await createProjectFixture();
|
|
165
|
+
let notifyCompiled;
|
|
166
|
+
let releaseCompilation;
|
|
167
|
+
const compiled = new Promise((resolve) => {
|
|
168
|
+
notifyCompiled = resolve;
|
|
169
|
+
});
|
|
170
|
+
const released = new Promise((resolve) => {
|
|
171
|
+
releaseCompilation = resolve;
|
|
172
|
+
});
|
|
173
|
+
let shouldBlock = false;
|
|
174
|
+
let compilationCount = 0;
|
|
175
|
+
vi.doMock("../compiler/compile.js", async (importOriginal) => {
|
|
176
|
+
const original = await importOriginal();
|
|
177
|
+
return {
|
|
178
|
+
...original,
|
|
179
|
+
compile: async (...args) => {
|
|
180
|
+
compilationCount++;
|
|
181
|
+
const result = await original.compile(...args);
|
|
182
|
+
if (shouldBlock) {
|
|
183
|
+
// Pause after the input has been consumed, before the plugin
|
|
184
|
+
// re-reads it to compute the cached digest.
|
|
185
|
+
notifyCompiled();
|
|
186
|
+
await released;
|
|
187
|
+
}
|
|
188
|
+
return result;
|
|
189
|
+
},
|
|
190
|
+
};
|
|
191
|
+
});
|
|
192
|
+
let { paraglideVitePlugin } = await import("./vite.js");
|
|
193
|
+
let plugin = paraglideVitePlugin({ project: projectDir, outdir });
|
|
194
|
+
setViteRoot(plugin, workspace);
|
|
195
|
+
let pending;
|
|
196
|
+
try {
|
|
197
|
+
await plugin.buildStart.call(mockContext);
|
|
198
|
+
const file = path.join(projectDir, "settings.json");
|
|
199
|
+
const original = await realFs.promises.readFile(file, "utf8");
|
|
200
|
+
await realFs.promises.writeFile(file, JSON.stringify({ ...JSON.parse(original), baseLocale: "de" }));
|
|
201
|
+
shouldBlock = true;
|
|
202
|
+
pending = plugin.watchChange.call(mockContext, file);
|
|
203
|
+
await compiled;
|
|
204
|
+
const closing = plugin.closeBundle.call(mockContext);
|
|
205
|
+
await realFs.promises.writeFile(file, original);
|
|
206
|
+
const lateChange = notifyLateChange
|
|
207
|
+
? plugin.watchChange.call(mockContext, file)
|
|
208
|
+
: undefined;
|
|
209
|
+
releaseCompilation();
|
|
210
|
+
await Promise.all([pending, closing, lateChange]);
|
|
211
|
+
shouldBlock = false;
|
|
212
|
+
// Shutdown drains the existing work without forcing another compile.
|
|
213
|
+
expect(compilationCount).toBe(2);
|
|
214
|
+
const runtime = path.join(outdir, "runtime.js");
|
|
215
|
+
expect(await realFs.promises.readFile(runtime, "utf8")).toContain('baseLocale = "de"');
|
|
216
|
+
if (restart === "cold restart") {
|
|
217
|
+
// Drop the warm state so only the on-disk cache can be reused.
|
|
218
|
+
vi.resetModules();
|
|
219
|
+
({ paraglideVitePlugin } = await import("./vite.js"));
|
|
220
|
+
}
|
|
221
|
+
if (restart !== "same instance") {
|
|
222
|
+
plugin = paraglideVitePlugin({ project: projectDir, outdir });
|
|
223
|
+
setViteRoot(plugin, workspace);
|
|
224
|
+
}
|
|
225
|
+
await plugin.buildStart.call(mockContext);
|
|
226
|
+
expect(compilationCount).toBe(3);
|
|
227
|
+
expect(await realFs.promises.readFile(runtime, "utf8")).toContain('baseLocale = "en"');
|
|
228
|
+
}
|
|
229
|
+
finally {
|
|
230
|
+
releaseCompilation();
|
|
231
|
+
await pending;
|
|
232
|
+
vi.doUnmock("../compiler/compile.js");
|
|
233
|
+
}
|
|
234
|
+
});
|
|
79
235
|
async function connectViteClient(server) {
|
|
80
236
|
const url = new URL(server.resolvedUrls.local[0]);
|
|
81
237
|
url.protocol = "ws:";
|