@inlang/paraglide-js 2.26.0 → 2.28.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 +11 -1
- package/dist/bundler-plugins/per-locale-build/index.js +14 -7
- package/dist/bundler-plugins/per-locale-build/index.js.map +1 -1
- package/dist/bundler-plugins/per-locale-build/vite-environments.test.js +237 -4
- package/dist/bundler-plugins/per-locale-build/vite-environments.test.js.map +1 -1
- package/dist/bundler-plugins/unplugin.d.ts +1 -1
- package/dist/bundler-plugins/unplugin.js +79 -10
- package/dist/bundler-plugins/unplugin.js.map +1 -1
- package/dist/bundler-plugins/unplugin.test.js +334 -1
- package/dist/bundler-plugins/unplugin.test.js.map +1 -1
- package/dist/bundler-plugins/vite.js +2 -1
- package/dist/bundler-plugins/vite.js.map +1 -1
- package/dist/bundler-plugins/vite.test.js +1 -1
- package/dist/bundler-plugins/vite.test.js.map +1 -1
- package/dist/cli/commands/compile/command.js +13 -0
- package/dist/cli/commands/compile/command.js.map +1 -1
- package/dist/cli/commands/compile/command.test.js +87 -3
- package/dist/cli/commands/compile/command.test.js.map +1 -1
- package/dist/cli/commands/init/command.d.ts +5 -0
- package/dist/cli/commands/init/command.js +216 -44
- package/dist/cli/commands/init/command.js.map +1 -1
- package/dist/cli/commands/init/command.test.d.ts +1 -0
- package/dist/cli/commands/init/command.test.js +123 -0
- package/dist/cli/commands/init/command.test.js.map +1 -0
- package/dist/cli/defaults.js +2 -2
- package/dist/cli/defaults.js.map +1 -1
- package/dist/cli/init-options.d.ts +11 -0
- package/dist/cli/init-options.js +2 -0
- package/dist/cli/init-options.js.map +1 -0
- package/dist/cli/steps/add-inlang-check.d.ts +19 -0
- package/dist/cli/steps/add-inlang-check.js +60 -0
- package/dist/cli/steps/add-inlang-check.js.map +1 -0
- package/dist/cli/steps/add-inlang-check.test.d.ts +1 -0
- package/dist/cli/steps/add-inlang-check.test.js +88 -0
- package/dist/cli/steps/add-inlang-check.test.js.map +1 -0
- package/dist/cli/steps/add-message-lint.d.ts +34 -0
- package/dist/cli/steps/add-message-lint.js +105 -0
- package/dist/cli/steps/add-message-lint.js.map +1 -0
- package/dist/cli/steps/add-message-lint.test.d.ts +1 -0
- package/dist/cli/steps/add-message-lint.test.js +74 -0
- package/dist/cli/steps/add-message-lint.test.js.map +1 -0
- package/dist/cli/steps/add-vite-plugin.d.ts +18 -0
- package/dist/cli/steps/add-vite-plugin.js +34 -6
- package/dist/cli/steps/add-vite-plugin.js.map +1 -1
- package/dist/cli/steps/add-vite-plugin.test.js +25 -9
- package/dist/cli/steps/add-vite-plugin.test.js.map +1 -1
- package/dist/cli/steps/agents-md-suggestion.d.ts +11 -0
- package/dist/cli/steps/agents-md-suggestion.js +19 -0
- package/dist/cli/steps/agents-md-suggestion.js.map +1 -0
- package/dist/cli/steps/agents-md-suggestion.test.d.ts +1 -0
- package/dist/cli/steps/agents-md-suggestion.test.js +36 -0
- package/dist/cli/steps/agents-md-suggestion.test.js.map +1 -0
- package/dist/cli/steps/check-for-uncomitted-changes.d.ts +3 -0
- package/dist/cli/steps/check-for-uncomitted-changes.js +15 -3
- package/dist/cli/steps/check-for-uncomitted-changes.js.map +1 -1
- package/dist/cli/steps/detect-bundler.d.ts +1 -0
- package/dist/cli/steps/detect-bundler.js +7 -1
- package/dist/cli/steps/detect-bundler.js.map +1 -1
- package/dist/cli/steps/initialize-inlang-project.d.ts +4 -3
- package/dist/cli/steps/initialize-inlang-project.js +60 -157
- package/dist/cli/steps/initialize-inlang-project.js.map +1 -1
- package/dist/cli/steps/maybe-add-machine-translation.d.ts +4 -0
- package/dist/cli/steps/maybe-add-machine-translation.js +14 -8
- package/dist/cli/steps/maybe-add-machine-translation.js.map +1 -1
- package/dist/cli/steps/maybe-add-sherlock.d.ts +2 -0
- package/dist/cli/steps/maybe-add-sherlock.js +13 -7
- package/dist/cli/steps/maybe-add-sherlock.js.map +1 -1
- package/dist/cli/steps/maybe-add-sherlock.test.d.ts +1 -0
- package/dist/cli/steps/maybe-add-sherlock.test.js +44 -0
- package/dist/cli/steps/maybe-add-sherlock.test.js.map +1 -0
- package/dist/cli/steps/prompt-for-outdir.d.ts +2 -0
- package/dist/cli/steps/prompt-for-outdir.js +4 -0
- package/dist/cli/steps/prompt-for-outdir.js.map +1 -1
- package/dist/cli/steps/update-package-json.js +8 -13
- package/dist/cli/steps/update-package-json.js.map +1 -1
- package/dist/cli/steps/update-ts-config.d.ts +6 -0
- package/dist/cli/steps/update-ts-config.js +27 -4
- package/dist/cli/steps/update-ts-config.js.map +1 -1
- package/dist/cli/utils.d.ts +11 -0
- package/dist/cli/utils.js +21 -0
- package/dist/cli/utils.js.map +1 -1
- package/dist/cli/utils.test.d.ts +1 -0
- package/dist/cli/utils.test.js +16 -0
- package/dist/cli/utils.test.js.map +1 -0
- package/dist/compiler/compile-annotation.d.ts +48 -1
- package/dist/compiler/compile-annotation.js +243 -10
- package/dist/compiler/compile-annotation.js.map +1 -1
- package/dist/compiler/compile-bundle.d.ts +7 -2
- package/dist/compiler/compile-bundle.js +97 -3
- package/dist/compiler/compile-bundle.js.map +1 -1
- package/dist/compiler/compile-bundle.test.js +232 -19
- package/dist/compiler/compile-bundle.test.js.map +1 -1
- package/dist/compiler/compile-lifecycle.test.d.ts +1 -0
- package/dist/compiler/compile-lifecycle.test.js +69 -0
- package/dist/compiler/compile-lifecycle.test.js.map +1 -0
- package/dist/compiler/compile-local-variable.d.ts +3 -0
- package/dist/compiler/compile-local-variable.js +5 -2
- package/dist/compiler/compile-local-variable.js.map +1 -1
- package/dist/compiler/compile-local-variable.test.js +55 -15
- package/dist/compiler/compile-local-variable.test.js.map +1 -1
- package/dist/compiler/compile-message.d.ts +29 -1
- package/dist/compiler/compile-message.exact-number.test.d.ts +1 -0
- package/dist/compiler/compile-message.exact-number.test.js +786 -0
- package/dist/compiler/compile-message.exact-number.test.js.map +1 -0
- package/dist/compiler/compile-message.js +162 -66
- package/dist/compiler/compile-message.js.map +1 -1
- package/dist/compiler/compile-message.locals.test.d.ts +1 -0
- package/dist/compiler/compile-message.locals.test.js +498 -0
- package/dist/compiler/compile-message.locals.test.js.map +1 -0
- package/dist/compiler/compile-message.test.js +113 -22
- package/dist/compiler/compile-message.test.js.map +1 -1
- package/dist/compiler/compile-pattern.d.ts +5 -0
- package/dist/compiler/compile-pattern.js +6 -18
- package/dist/compiler/compile-pattern.js.map +1 -1
- package/dist/compiler/compile-pattern.test.js +169 -5
- package/dist/compiler/compile-pattern.test.js.map +1 -1
- package/dist/compiler/compile-project.js +5 -1
- package/dist/compiler/compile-project.js.map +1 -1
- package/dist/compiler/compile-project.test.js +1260 -185
- package/dist/compiler/compile-project.test.js.map +1 -1
- package/dist/compiler/compile.js +36 -17
- package/dist/compiler/compile.js.map +1 -1
- package/dist/compiler/compile.test.js +71 -1
- package/dist/compiler/compile.test.js.map +1 -1
- package/dist/compiler/compiler-options.d.ts +41 -0
- package/dist/compiler/compiler-options.js.map +1 -1
- package/dist/compiler/create-readme.d.ts +4 -1
- package/dist/compiler/create-readme.js +33 -125
- package/dist/compiler/create-readme.js.map +1 -1
- package/dist/compiler/emit-ts-declarations.interop.test.js +2 -2
- package/dist/compiler/emit-ts-declarations.interop.test.js.map +1 -1
- package/dist/compiler/emit-ts-declarations.test.js +4 -4
- package/dist/compiler/emit-ts-declarations.test.js.map +1 -1
- package/dist/compiler/index.d.ts +1 -1
- package/dist/compiler/index.js +1 -1
- package/dist/compiler/index.js.map +1 -1
- package/dist/compiler/input-alias.d.ts +21 -0
- package/dist/compiler/input-alias.js +42 -0
- package/dist/compiler/input-alias.js.map +1 -0
- package/dist/compiler/input-alias.test.d.ts +1 -0
- package/dist/compiler/input-alias.test.js +58 -0
- package/dist/compiler/input-alias.test.js.map +1 -0
- package/dist/compiler/message-locals.d.ts +46 -0
- package/dist/compiler/message-locals.js +129 -0
- package/dist/compiler/message-locals.js.map +1 -0
- package/dist/compiler/output-structure/locale-modules.js +7 -1
- package/dist/compiler/output-structure/locale-modules.js.map +1 -1
- package/dist/compiler/output-structure/locale-modules.test.js +35 -0
- package/dist/compiler/output-structure/locale-modules.test.js.map +1 -1
- package/dist/compiler/output-structure/message-modules.js +6 -4
- package/dist/compiler/output-structure/message-modules.js.map +1 -1
- package/dist/compiler/output-structure/message-modules.test.js +35 -0
- package/dist/compiler/output-structure/message-modules.test.js.map +1 -1
- package/dist/compiler/registry.d.ts +12 -0
- package/dist/compiler/registry.js +158 -31
- package/dist/compiler/registry.js.map +1 -1
- package/dist/compiler/registry.test.d.ts +1 -0
- package/dist/compiler/registry.test.js +291 -0
- package/dist/compiler/registry.test.js.map +1 -0
- package/dist/compiler/runtime/create-runtime.d.ts +2 -0
- package/dist/compiler/runtime/create-runtime.js +9 -0
- package/dist/compiler/runtime/create-runtime.js.map +1 -1
- package/dist/compiler/runtime/extract-locale-from-cookie.js +8 -1
- package/dist/compiler/runtime/extract-locale-from-cookie.js.map +1 -1
- package/dist/compiler/runtime/extract-locale-from-cookie.test.js +26 -0
- package/dist/compiler/runtime/extract-locale-from-cookie.test.js.map +1 -1
- package/dist/compiler/runtime/extract-locale-from-header.js +47 -5
- package/dist/compiler/runtime/extract-locale-from-header.js.map +1 -1
- package/dist/compiler/runtime/extract-locale-from-header.test.js +58 -0
- package/dist/compiler/runtime/extract-locale-from-header.test.js.map +1 -1
- package/dist/compiler/runtime/get-locale.js +7 -1
- package/dist/compiler/runtime/get-locale.js.map +1 -1
- package/dist/compiler/runtime/get-locale.test.js +95 -0
- package/dist/compiler/runtime/get-locale.test.js.map +1 -1
- package/dist/compiler/runtime/localize-href.d.ts +8 -0
- package/dist/compiler/runtime/localize-href.js +60 -0
- package/dist/compiler/runtime/localize-href.js.map +1 -1
- package/dist/compiler/runtime/localize-href.test.js +227 -1
- package/dist/compiler/runtime/localize-href.test.js.map +1 -1
- package/dist/compiler/runtime/set-locale.js +24 -6
- package/dist/compiler/runtime/set-locale.js.map +1 -1
- package/dist/compiler/runtime/set-locale.test.js +182 -0
- package/dist/compiler/runtime/set-locale.test.js.map +1 -1
- package/dist/compiler/runtime/type.d.ts +2 -0
- package/dist/compiler/runtime/type.js.map +1 -1
- package/dist/compiler/runtime/type.test.js +34 -0
- package/dist/compiler/runtime/type.test.js.map +1 -1
- package/dist/compiler/runtime/variables.d.ts +2 -0
- package/dist/compiler/runtime/variables.js +7 -0
- package/dist/compiler/runtime/variables.js.map +1 -1
- package/dist/compiler/server/create-server-file.js +24 -0
- package/dist/compiler/server/create-server-file.js.map +1 -1
- package/dist/compiler/server/create-server-file.test.js +8 -2
- package/dist/compiler/server/create-server-file.test.js.map +1 -1
- package/dist/compiler/server/middleware.d.ts +8 -2
- package/dist/compiler/server/middleware.js +204 -11
- package/dist/compiler/server/middleware.js.map +1 -1
- package/dist/compiler/server/middleware.test.js +750 -3
- package/dist/compiler/server/middleware.test.js.map +1 -1
- package/dist/eslint/index.d.ts +4 -0
- package/dist/eslint/index.js +8 -0
- package/dist/eslint/index.js.map +1 -0
- package/dist/eslint/no-dynamic-message-access.d.ts +3 -0
- package/dist/eslint/no-dynamic-message-access.js +150 -0
- package/dist/eslint/no-dynamic-message-access.js.map +1 -0
- package/dist/eslint/no-dynamic-message-access.test.d.ts +1 -0
- package/dist/eslint/no-dynamic-message-access.test.js +126 -0
- package/dist/eslint/no-dynamic-message-access.test.js.map +1 -0
- package/dist/eslint/oxlint.test.d.ts +1 -0
- package/dist/eslint/oxlint.test.js +64 -0
- package/dist/eslint/oxlint.test.js.map +1 -0
- package/dist/services/config/config-schema.d.ts +2 -0
- package/dist/services/config/config-schema.js +2 -0
- package/dist/services/config/config-schema.js.map +1 -1
- package/dist/services/config/load-paraglide-config.test.js +12 -0
- package/dist/services/config/load-paraglide-config.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/dist/services/file-handling/write-output.bench.js +51 -11
- package/dist/services/file-handling/write-output.bench.js.map +1 -1
- package/dist/services/file-handling/write-output.js +60 -20
- package/dist/services/file-handling/write-output.js.map +1 -1
- package/dist/services/file-handling/write-output.test.js +175 -0
- package/dist/services/file-handling/write-output.test.js.map +1 -1
- package/package.json +15 -5
|
@@ -35,6 +35,7 @@ function getPluginState(args) {
|
|
|
35
35
|
readFiles: tracked.readFiles,
|
|
36
36
|
clearReadFiles: tracked.clearReadFiles,
|
|
37
37
|
previousCompilation: undefined,
|
|
38
|
+
compilationError: undefined,
|
|
38
39
|
previousInputsDigest: undefined,
|
|
39
40
|
previousProject: undefined,
|
|
40
41
|
previousOutdir: undefined,
|
|
@@ -276,6 +277,7 @@ async function runCompilation(args) {
|
|
|
276
277
|
const { state } = args;
|
|
277
278
|
const outputStructure = resolveOutputStructure(compilerOptions);
|
|
278
279
|
maybeInvalidateForOptionsChange(state, compilerOptions);
|
|
280
|
+
state.compilationError = undefined;
|
|
279
281
|
try {
|
|
280
282
|
// Stabilize project directory listings before the first digest. The
|
|
281
283
|
// ignored cache directory must not invalidate the cache that creates it.
|
|
@@ -316,6 +318,8 @@ async function runCompilation(args) {
|
|
|
316
318
|
logger.success(`Compilation complete (${outputStructure})`);
|
|
317
319
|
}
|
|
318
320
|
catch (error) {
|
|
321
|
+
state.compilationError =
|
|
322
|
+
error instanceof Error ? error : new Error(String(error));
|
|
319
323
|
state.previousInputsDigest = undefined;
|
|
320
324
|
logger.error("Failed to compile project:", error.message);
|
|
321
325
|
logger.info("Please check your translation files for syntax errors.");
|
|
@@ -323,7 +327,7 @@ async function runCompilation(args) {
|
|
|
323
327
|
throw error;
|
|
324
328
|
}
|
|
325
329
|
}
|
|
326
|
-
export const unpluginFactory = (userArgs) => {
|
|
330
|
+
export const unpluginFactory = (userArgs, _meta, defaults) => {
|
|
327
331
|
const state = getPluginState(userArgs);
|
|
328
332
|
const { readFiles, clearReadFiles } = state;
|
|
329
333
|
// Project root as reported by the bundler (vite `root`, webpack/rspack
|
|
@@ -369,12 +373,54 @@ export const unpluginFactory = (userArgs) => {
|
|
|
369
373
|
// Set once a bundler context rejects watch-file registrations (esbuild);
|
|
370
374
|
// further registration attempts are skipped to avoid warning floods.
|
|
371
375
|
let watchRegistrationUnsupported = false;
|
|
376
|
+
let viteServer;
|
|
377
|
+
let viteError;
|
|
378
|
+
let configLoadFailed = false;
|
|
379
|
+
function reportViteError(error, source = "compilation") {
|
|
380
|
+
if (!viteServer || process.env.NODE_ENV === "production")
|
|
381
|
+
return;
|
|
382
|
+
if (configLoadFailed && source === "compilation")
|
|
383
|
+
return;
|
|
384
|
+
if (source === "config")
|
|
385
|
+
configLoadFailed = true;
|
|
386
|
+
const failure = error instanceof Error ? error : new Error(String(error));
|
|
387
|
+
viteError = {
|
|
388
|
+
type: "error",
|
|
389
|
+
err: {
|
|
390
|
+
message: failure.message,
|
|
391
|
+
stack: failure.stack ?? "",
|
|
392
|
+
plugin: PLUGIN_NAME,
|
|
393
|
+
},
|
|
394
|
+
};
|
|
395
|
+
// Older Vite versions buffer errors without clients, even after recovery.
|
|
396
|
+
if (viteServer.ws.clients.size > 0)
|
|
397
|
+
viteServer.ws.send(viteError);
|
|
398
|
+
}
|
|
399
|
+
function clearViteError() {
|
|
400
|
+
if (!viteServer || !viteError || configLoadFailed)
|
|
401
|
+
return;
|
|
402
|
+
viteError = undefined;
|
|
403
|
+
// An invalid config can recover without writing generated files,
|
|
404
|
+
// leaving no HMR update to dismiss the error overlay.
|
|
405
|
+
if (viteServer.ws.clients.size > 0) {
|
|
406
|
+
viteServer.ws.send({ type: "full-reload" });
|
|
407
|
+
}
|
|
408
|
+
}
|
|
372
409
|
const getProjectDir = () => nodeNormalizePath(resolve(discoveryRoot ?? process.cwd(), userArgs.project));
|
|
373
|
-
const resolveOptionsWith = (loaded) =>
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
410
|
+
const resolveOptionsWith = (loaded) => {
|
|
411
|
+
const options = resolveCompilerOptions({
|
|
412
|
+
config: loaded?.config,
|
|
413
|
+
overrides: userArgs,
|
|
414
|
+
root: discoveryRoot ?? process.cwd(),
|
|
415
|
+
});
|
|
416
|
+
// Apply integration defaults after each config load, keeping watched
|
|
417
|
+
// config values separate from explicit plugin overrides.
|
|
418
|
+
if (options.outputStructure === undefined &&
|
|
419
|
+
defaults?.outputStructure !== undefined) {
|
|
420
|
+
options.outputStructure = defaults.outputStructure;
|
|
421
|
+
}
|
|
422
|
+
return options;
|
|
423
|
+
};
|
|
378
424
|
/**
|
|
379
425
|
* Loads the active config, following candidate renames and keeping the
|
|
380
426
|
* last known-good configuration while the file is missing or invalid.
|
|
@@ -399,8 +445,8 @@ export const unpluginFactory = (userArgs) => {
|
|
|
399
445
|
}
|
|
400
446
|
/**
|
|
401
447
|
* Rebuild for a single watch event. Config-named events reload the
|
|
402
|
-
* config; input events reuse the last known options
|
|
403
|
-
*
|
|
448
|
+
* config; input events reuse the last known options unless the config
|
|
449
|
+
* failed to load.
|
|
404
450
|
*/
|
|
405
451
|
async function performWatchRecompile(path) {
|
|
406
452
|
const normalizedPath = nodeNormalizePath(path);
|
|
@@ -410,8 +456,9 @@ export const unpluginFactory = (userArgs) => {
|
|
|
410
456
|
const configEvent = withinProjectDir && isConfigFileName(normalizedPath);
|
|
411
457
|
let args;
|
|
412
458
|
if (!configEvent && lastOptions !== undefined) {
|
|
413
|
-
|
|
414
|
-
|
|
459
|
+
const targets = getWatchTargets(readFiles, {
|
|
460
|
+
outdir: lastOptions.outdir,
|
|
461
|
+
});
|
|
415
462
|
if (targets.isIgnoredPath(normalizedPath))
|
|
416
463
|
return;
|
|
417
464
|
const shouldCompile = targets.files.has(normalizedPath) ||
|
|
@@ -419,6 +466,9 @@ export const unpluginFactory = (userArgs) => {
|
|
|
419
466
|
if (!shouldCompile)
|
|
420
467
|
return;
|
|
421
468
|
}
|
|
469
|
+
if (!configEvent && lastOptions !== undefined && !configLoadFailed) {
|
|
470
|
+
args = lastOptions;
|
|
471
|
+
}
|
|
422
472
|
else {
|
|
423
473
|
if (configEvent) {
|
|
424
474
|
logger.info("Paraglide configuration changed, re-compiling.");
|
|
@@ -431,11 +481,13 @@ export const unpluginFactory = (userArgs) => {
|
|
|
431
481
|
catch (error) {
|
|
432
482
|
// Invalid config: skip the compilation entirely and surface
|
|
433
483
|
// the problem. The previously compiled output stays on disk.
|
|
484
|
+
reportViteError(error, "config");
|
|
434
485
|
logger.error(error.message);
|
|
435
486
|
logger.error("Skipping compilation because of the invalid paraglide config.");
|
|
436
487
|
return;
|
|
437
488
|
}
|
|
438
489
|
lastOptions = args;
|
|
490
|
+
configLoadFailed = false;
|
|
439
491
|
}
|
|
440
492
|
maybeInvalidateForOptionsChange(state, args);
|
|
441
493
|
const outputStructure = resolveOutputStructure(args);
|
|
@@ -454,6 +506,7 @@ export const unpluginFactory = (userArgs) => {
|
|
|
454
506
|
});
|
|
455
507
|
await writePersistentCache(state, args, outputStructure);
|
|
456
508
|
logger.success(`Re-compilation complete (${outputStructure})`);
|
|
509
|
+
clearViteError();
|
|
457
510
|
const nextTargets = getWatchTargets(readFiles, { outdir: args.outdir });
|
|
458
511
|
for (const filePath of nextTargets.files)
|
|
459
512
|
safeAddWatchFile(undefined, filePath);
|
|
@@ -461,6 +514,7 @@ export const unpluginFactory = (userArgs) => {
|
|
|
461
514
|
safeAddWatchFile(undefined, directoryPath);
|
|
462
515
|
}
|
|
463
516
|
catch (e) {
|
|
517
|
+
reportViteError(e);
|
|
464
518
|
clearReadFiles();
|
|
465
519
|
for (const filePath of previouslyReadFiles)
|
|
466
520
|
readFiles.add(filePath);
|
|
@@ -477,6 +531,7 @@ export const unpluginFactory = (userArgs) => {
|
|
|
477
531
|
try {
|
|
478
532
|
const loaded = await loadActiveConfig();
|
|
479
533
|
const args = resolveOptionsWith(loaded);
|
|
534
|
+
configLoadFailed = false;
|
|
480
535
|
lastOptions = args;
|
|
481
536
|
await runCompilation({ state, compilerOptions: args });
|
|
482
537
|
}
|
|
@@ -488,6 +543,7 @@ export const unpluginFactory = (userArgs) => {
|
|
|
488
543
|
if (process.env.NODE_ENV === "production")
|
|
489
544
|
throw error;
|
|
490
545
|
logger.error("Failed to prepare paraglide compilation:", error.message);
|
|
546
|
+
reportViteError(error, "config");
|
|
491
547
|
return;
|
|
492
548
|
}
|
|
493
549
|
finally {
|
|
@@ -508,6 +564,12 @@ export const unpluginFactory = (userArgs) => {
|
|
|
508
564
|
safeAddWatchFile(this, join(projectDir, name));
|
|
509
565
|
}
|
|
510
566
|
}
|
|
567
|
+
if (state.compilationError) {
|
|
568
|
+
reportViteError(state.compilationError);
|
|
569
|
+
}
|
|
570
|
+
else {
|
|
571
|
+
clearViteError();
|
|
572
|
+
}
|
|
511
573
|
},
|
|
512
574
|
async watchChange(path) {
|
|
513
575
|
// Serialize rebuilds: bundlers may deliver several watchChange
|
|
@@ -547,6 +609,13 @@ export const unpluginFactory = (userArgs) => {
|
|
|
547
609
|
discoveryRoot = config.root;
|
|
548
610
|
},
|
|
549
611
|
},
|
|
612
|
+
configureServer(server) {
|
|
613
|
+
viteServer = server;
|
|
614
|
+
server.ws.on("connection", (socket) => {
|
|
615
|
+
if (viteError)
|
|
616
|
+
socket.send(JSON.stringify(viteError));
|
|
617
|
+
});
|
|
618
|
+
},
|
|
550
619
|
},
|
|
551
620
|
webpack(compiler) {
|
|
552
621
|
discoveryRoot = compiler.context;
|
|
@@ -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,eA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npluginFactory } 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\";\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\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\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\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.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) => ReturnType<UnpluginFactory<ParaglidePluginOptions>>;\n\nexport const unpluginFactory: UnpluginFactoryWithOptions = (userArgs) => {\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\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\tresolveCompilerOptions({\n\t\t\tconfig: loaded?.config,\n\t\t\toverrides: userArgs,\n\t\t\troot: discoveryRoot ?? process.cwd(),\n\t\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 — options cannot\n\t * have changed without a config event.\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\targs = lastOptions;\n\t\t\tconst targets = getWatchTargets(readFiles, { outdir: args.outdir });\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} 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\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}\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\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\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\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\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},\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},\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,O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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"]}
|