@inlang/paraglide-js 2.27.0 → 2.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- 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 +235 -2
- package/dist/bundler-plugins/per-locale-build/vite-environments.test.js.map +1 -1
- package/dist/bundler-plugins/unplugin.d.ts +4 -1
- package/dist/bundler-plugins/unplugin.js +134 -22
- package/dist/bundler-plugins/unplugin.js.map +1 -1
- package/dist/bundler-plugins/unplugin.test.js +490 -1
- package/dist/bundler-plugins/unplugin.test.js.map +1 -1
- package/dist/bundler-plugins/vite-error-response.test.d.ts +1 -0
- package/dist/bundler-plugins/vite-error-response.test.js +171 -0
- package/dist/bundler-plugins/vite-error-response.test.js.map +1 -0
- package/dist/bundler-plugins/vite.d.ts +8 -0
- package/dist/bundler-plugins/vite.js +14 -4
- 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 +213 -59
- 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/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.js +2 -2
- package/dist/cli/steps/add-inlang-check.js.map +1 -1
- 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/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 +11 -6
- 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 +12 -6
- 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 +2 -0
- package/dist/cli/utils.js +6 -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.js +6 -1
- package/dist/compiler/compile-annotation.js.map +1 -1
- package/dist/compiler/compile-bundle.d.ts +4 -0
- package/dist/compiler/compile-bundle.js +67 -2
- package/dist/compiler/compile-bundle.js.map +1 -1
- package/dist/compiler/compile-bundle.test.js +214 -1
- 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.test.js +14 -14
- package/dist/compiler/compile-local-variable.test.js.map +1 -1
- package/dist/compiler/compile-message.exact-number.test.js +1 -1
- package/dist/compiler/compile-message.exact-number.test.js.map +1 -1
- package/dist/compiler/compile-message.locals.test.js +1 -1
- package/dist/compiler/compile-message.locals.test.js.map +1 -1
- package/dist/compiler/compile-message.test.js +2 -2
- package/dist/compiler/compile-message.test.js.map +1 -1
- package/dist/compiler/compile-pattern.test.js +5 -5
- package/dist/compiler/compile-pattern.test.js.map +1 -1
- package/dist/compiler/compile-project.js +1 -0
- package/dist/compiler/compile-project.js.map +1 -1
- package/dist/compiler/compile-project.test.js +94 -1
- 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 +70 -0
- 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/output-structure/message-modules.js +1 -1
- package/dist/compiler/output-structure/message-modules.js.map +1 -1
- package/dist/compiler/registry.js +71 -13
- 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/localize-url.d.ts +8 -4
- package/dist/compiler/runtime/localize-url.js +12 -8
- package/dist/compiler/runtime/localize-url.js.map +1 -1
- package/dist/compiler/runtime/localize-url.test.js +45 -0
- package/dist/compiler/runtime/localize-url.test.js.map +1 -1
- package/dist/compiler/runtime/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 +75 -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/middleware.d.ts +8 -2
- package/dist/compiler/server/middleware.js +175 -7
- 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 +14 -4
|
@@ -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
|
|
@@ -362,19 +366,64 @@ export const unpluginFactory = (userArgs) => {
|
|
|
362
366
|
let hadActiveConfig = false;
|
|
363
367
|
// Watch-rebuild serialization state (see watchChange).
|
|
364
368
|
let compiling = false;
|
|
369
|
+
let isClosed = false;
|
|
370
|
+
let pendingCompilation;
|
|
365
371
|
const pendingWatchPaths = new Set();
|
|
372
|
+
const pendingCompilationCachePaths = new Set();
|
|
366
373
|
// Options from the most recent successful resolution — reused by input
|
|
367
374
|
// events that cannot have changed them.
|
|
368
375
|
let lastOptions;
|
|
369
376
|
// Set once a bundler context rejects watch-file registrations (esbuild);
|
|
370
377
|
// further registration attempts are skipped to avoid warning floods.
|
|
371
378
|
let watchRegistrationUnsupported = false;
|
|
379
|
+
let viteServer;
|
|
380
|
+
let viteError;
|
|
381
|
+
let configLoadFailed = false;
|
|
382
|
+
function reportViteError(error, source = "compilation") {
|
|
383
|
+
if (!viteServer || process.env.NODE_ENV === "production")
|
|
384
|
+
return;
|
|
385
|
+
if (configLoadFailed && source === "compilation")
|
|
386
|
+
return;
|
|
387
|
+
if (source === "config")
|
|
388
|
+
configLoadFailed = true;
|
|
389
|
+
const failure = error instanceof Error ? error : new Error(String(error));
|
|
390
|
+
viteError = {
|
|
391
|
+
type: "error",
|
|
392
|
+
err: {
|
|
393
|
+
message: failure.message,
|
|
394
|
+
stack: failure.stack ?? "",
|
|
395
|
+
plugin: PLUGIN_NAME,
|
|
396
|
+
},
|
|
397
|
+
};
|
|
398
|
+
// Older Vite versions buffer errors without clients, even after recovery.
|
|
399
|
+
if (viteServer.ws.clients.size > 0)
|
|
400
|
+
viteServer.ws.send(viteError);
|
|
401
|
+
}
|
|
402
|
+
function clearViteError() {
|
|
403
|
+
if (!viteServer || !viteError || configLoadFailed)
|
|
404
|
+
return;
|
|
405
|
+
viteError = undefined;
|
|
406
|
+
// An invalid config can recover without writing generated files,
|
|
407
|
+
// leaving no HMR update to dismiss the error overlay.
|
|
408
|
+
if (viteServer.ws.clients.size > 0) {
|
|
409
|
+
viteServer.ws.send({ type: "full-reload" });
|
|
410
|
+
}
|
|
411
|
+
}
|
|
372
412
|
const getProjectDir = () => nodeNormalizePath(resolve(discoveryRoot ?? process.cwd(), userArgs.project));
|
|
373
|
-
const resolveOptionsWith = (loaded) =>
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
413
|
+
const resolveOptionsWith = (loaded) => {
|
|
414
|
+
const options = resolveCompilerOptions({
|
|
415
|
+
config: loaded?.config,
|
|
416
|
+
overrides: userArgs,
|
|
417
|
+
root: discoveryRoot ?? process.cwd(),
|
|
418
|
+
});
|
|
419
|
+
// Apply integration defaults after each config load, keeping watched
|
|
420
|
+
// config values separate from explicit plugin overrides.
|
|
421
|
+
if (options.outputStructure === undefined &&
|
|
422
|
+
defaults?.outputStructure !== undefined) {
|
|
423
|
+
options.outputStructure = defaults.outputStructure;
|
|
424
|
+
}
|
|
425
|
+
return options;
|
|
426
|
+
};
|
|
378
427
|
/**
|
|
379
428
|
* Loads the active config, following candidate renames and keeping the
|
|
380
429
|
* last known-good configuration while the file is missing or invalid.
|
|
@@ -399,8 +448,8 @@ export const unpluginFactory = (userArgs) => {
|
|
|
399
448
|
}
|
|
400
449
|
/**
|
|
401
450
|
* Rebuild for a single watch event. Config-named events reload the
|
|
402
|
-
* config; input events reuse the last known options
|
|
403
|
-
*
|
|
451
|
+
* config; input events reuse the last known options unless the config
|
|
452
|
+
* failed to load.
|
|
404
453
|
*/
|
|
405
454
|
async function performWatchRecompile(path) {
|
|
406
455
|
const normalizedPath = nodeNormalizePath(path);
|
|
@@ -410,8 +459,9 @@ export const unpluginFactory = (userArgs) => {
|
|
|
410
459
|
const configEvent = withinProjectDir && isConfigFileName(normalizedPath);
|
|
411
460
|
let args;
|
|
412
461
|
if (!configEvent && lastOptions !== undefined) {
|
|
413
|
-
|
|
414
|
-
|
|
462
|
+
const targets = getWatchTargets(readFiles, {
|
|
463
|
+
outdir: lastOptions.outdir,
|
|
464
|
+
});
|
|
415
465
|
if (targets.isIgnoredPath(normalizedPath))
|
|
416
466
|
return;
|
|
417
467
|
const shouldCompile = targets.files.has(normalizedPath) ||
|
|
@@ -419,6 +469,9 @@ export const unpluginFactory = (userArgs) => {
|
|
|
419
469
|
if (!shouldCompile)
|
|
420
470
|
return;
|
|
421
471
|
}
|
|
472
|
+
if (!configEvent && lastOptions !== undefined && !configLoadFailed) {
|
|
473
|
+
args = lastOptions;
|
|
474
|
+
}
|
|
422
475
|
else {
|
|
423
476
|
if (configEvent) {
|
|
424
477
|
logger.info("Paraglide configuration changed, re-compiling.");
|
|
@@ -431,11 +484,13 @@ export const unpluginFactory = (userArgs) => {
|
|
|
431
484
|
catch (error) {
|
|
432
485
|
// Invalid config: skip the compilation entirely and surface
|
|
433
486
|
// the problem. The previously compiled output stays on disk.
|
|
487
|
+
reportViteError(error, "config");
|
|
434
488
|
logger.error(error.message);
|
|
435
489
|
logger.error("Skipping compilation because of the invalid paraglide config.");
|
|
436
490
|
return;
|
|
437
491
|
}
|
|
438
492
|
lastOptions = args;
|
|
493
|
+
configLoadFailed = false;
|
|
439
494
|
}
|
|
440
495
|
maybeInvalidateForOptionsChange(state, args);
|
|
441
496
|
const outputStructure = resolveOutputStructure(args);
|
|
@@ -445,6 +500,7 @@ export const unpluginFactory = (userArgs) => {
|
|
|
445
500
|
logger.info(`Re-compiling inlang project... File "${relative(process.cwd(), path)}" has changed.`);
|
|
446
501
|
}
|
|
447
502
|
clearReadFiles();
|
|
503
|
+
pendingCompilationCachePaths.add(getPersistentCachePath(args, outputStructure));
|
|
448
504
|
await compileAndUpdateState({
|
|
449
505
|
state,
|
|
450
506
|
compilerOptions: args,
|
|
@@ -454,6 +510,7 @@ export const unpluginFactory = (userArgs) => {
|
|
|
454
510
|
});
|
|
455
511
|
await writePersistentCache(state, args, outputStructure);
|
|
456
512
|
logger.success(`Re-compilation complete (${outputStructure})`);
|
|
513
|
+
clearViteError();
|
|
457
514
|
const nextTargets = getWatchTargets(readFiles, { outdir: args.outdir });
|
|
458
515
|
for (const filePath of nextTargets.files)
|
|
459
516
|
safeAddWatchFile(undefined, filePath);
|
|
@@ -461,6 +518,7 @@ export const unpluginFactory = (userArgs) => {
|
|
|
461
518
|
safeAddWatchFile(undefined, directoryPath);
|
|
462
519
|
}
|
|
463
520
|
catch (e) {
|
|
521
|
+
reportViteError(e);
|
|
464
522
|
clearReadFiles();
|
|
465
523
|
for (const filePath of previouslyReadFiles)
|
|
466
524
|
readFiles.add(filePath);
|
|
@@ -473,10 +531,14 @@ export const unpluginFactory = (userArgs) => {
|
|
|
473
531
|
name: PLUGIN_NAME,
|
|
474
532
|
enforce: "pre",
|
|
475
533
|
async buildStart() {
|
|
534
|
+
if (isClosed)
|
|
535
|
+
clearParaglideConfigCache({ projectDir: getProjectDir() });
|
|
536
|
+
isClosed = false;
|
|
476
537
|
addWatchFile = this.addWatchFile?.bind(this);
|
|
477
538
|
try {
|
|
478
539
|
const loaded = await loadActiveConfig();
|
|
479
540
|
const args = resolveOptionsWith(loaded);
|
|
541
|
+
configLoadFailed = false;
|
|
480
542
|
lastOptions = args;
|
|
481
543
|
await runCompilation({ state, compilerOptions: args });
|
|
482
544
|
}
|
|
@@ -488,6 +550,7 @@ export const unpluginFactory = (userArgs) => {
|
|
|
488
550
|
if (process.env.NODE_ENV === "production")
|
|
489
551
|
throw error;
|
|
490
552
|
logger.error("Failed to prepare paraglide compilation:", error.message);
|
|
553
|
+
reportViteError(error, "config");
|
|
491
554
|
return;
|
|
492
555
|
}
|
|
493
556
|
finally {
|
|
@@ -508,28 +571,60 @@ export const unpluginFactory = (userArgs) => {
|
|
|
508
571
|
safeAddWatchFile(this, join(projectDir, name));
|
|
509
572
|
}
|
|
510
573
|
}
|
|
574
|
+
if (state.compilationError) {
|
|
575
|
+
reportViteError(state.compilationError);
|
|
576
|
+
}
|
|
577
|
+
else {
|
|
578
|
+
clearViteError();
|
|
579
|
+
}
|
|
511
580
|
},
|
|
512
|
-
|
|
581
|
+
watchChange(path) {
|
|
582
|
+
if (isClosed)
|
|
583
|
+
return pendingCompilation;
|
|
513
584
|
// Serialize rebuilds: bundlers may deliver several watchChange
|
|
514
585
|
// events concurrently (webpack fires once per modified file).
|
|
515
586
|
// Every path is queued — a config event must never be starved by
|
|
516
587
|
// later input events.
|
|
517
588
|
pendingWatchPaths.add(nodeNormalizePath(path));
|
|
518
589
|
if (compiling)
|
|
519
|
-
return;
|
|
590
|
+
return pendingCompilation;
|
|
520
591
|
compiling = true;
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
592
|
+
pendingCompilation = (async () => {
|
|
593
|
+
try {
|
|
594
|
+
while (pendingWatchPaths.size > 0) {
|
|
595
|
+
const batch = [...pendingWatchPaths];
|
|
596
|
+
pendingWatchPaths.clear();
|
|
597
|
+
for (const current of batch) {
|
|
598
|
+
await performWatchRecompile(current);
|
|
599
|
+
}
|
|
527
600
|
}
|
|
528
601
|
}
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
602
|
+
finally {
|
|
603
|
+
try {
|
|
604
|
+
if (isClosed) {
|
|
605
|
+
// Inputs can change after compile reads them but before its
|
|
606
|
+
// digest is taken. Once closing starts, watcher events can
|
|
607
|
+
// no longer repair that mismatch, so neither warm nor cold
|
|
608
|
+
// restarts may reuse caches from this queue.
|
|
609
|
+
state.previousInputsDigest = undefined;
|
|
610
|
+
for (const cachePath of pendingCompilationCachePaths) {
|
|
611
|
+
await (userArgs.fs ?? nodeFs).promises.rm(cachePath, {
|
|
612
|
+
force: true,
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
finally {
|
|
618
|
+
pendingCompilationCachePaths.clear();
|
|
619
|
+
compiling = false;
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
})();
|
|
623
|
+
return pendingCompilation;
|
|
624
|
+
},
|
|
625
|
+
closeBundle() {
|
|
626
|
+
isClosed = true;
|
|
627
|
+
return pendingCompilation;
|
|
533
628
|
},
|
|
534
629
|
vite: {
|
|
535
630
|
config: {
|
|
@@ -547,6 +642,23 @@ export const unpluginFactory = (userArgs) => {
|
|
|
547
642
|
discoveryRoot = config.root;
|
|
548
643
|
},
|
|
549
644
|
},
|
|
645
|
+
configureServer(server) {
|
|
646
|
+
viteServer = server;
|
|
647
|
+
if (defaults?.devErrorResponse) {
|
|
648
|
+
server.middlewares.use((_request, response, next) => {
|
|
649
|
+
if (!viteError)
|
|
650
|
+
return next();
|
|
651
|
+
response.statusCode = 500;
|
|
652
|
+
response.setHeader("Content-Type", "text/plain; charset=utf-8");
|
|
653
|
+
response.setHeader("Cache-Control", "no-store");
|
|
654
|
+
response.end(viteError.err.message);
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
server.ws.on("connection", (socket) => {
|
|
658
|
+
if (viteError)
|
|
659
|
+
socket.send(JSON.stringify(viteError));
|
|
660
|
+
});
|
|
661
|
+
},
|
|
550
662
|
},
|
|
551
663
|
webpack(compiler) {
|
|
552
664
|
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,eAAe,EACf,eAAe,EACf,uBAAuB,GACvB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EAAE,iCAAiC,EAAE,MAAM,0CAA0C,CAAC;AAC7F,OAAO,EACN,iBAAiB,EACjB,yBAAyB,EACzB,gBAAgB,EAChB,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB,GAEtB,MAAM,6BAA6B,CAAC;AAErC,MAAM,WAAW,GAAG,uBAAuB,CAAC;AAsC5C,MAAM,MAAM,GAAG,IAAI,MAAM,EAAE,C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D,MAAM,cAAc,GACnB,KAAK,CAAC,mBAAmB;wBACzB,CAAC,MAAM,iCAAiC,CAAC;4BACxC,MAAM,EAAE,IAAI,CAAC,MAAM;4BACnB,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,QAAQ;yBACrB,CAAC,CAAC,CAAC;oBACL,MAAM,qBAAqB,CAAC;wBAC3B,KAAK;wBACL,eAAe,EAAE,IAAI;wBACrB,eAAe;wBACf,mBAAmB,EAAE,cAAc;wBACnC,QAAQ,EAAE,SAAS;qBACnB,CAAC,CAAC;oBACH,MAAM,oBAAoB,CAAC,KAAK,EAAE,IAAI,EAAE,eAAe,CAAC,CAAC;oBACzD,MAAM,CAAC,OAAO,CAAC,yBAAyB,eAAe,GAAG,CAAC,CAAC;gBAC7D,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBAChB,KAAK,CAAC,oBAAoB,GAAG,SAAS,CAAC;oBACvC,MAAM,CAAC,IAAI,CAAC,4BAA4B,EAAG,KAAe,CAAC,OAAO,CAAC,CAAC;oBACpE,MAAM,CAAC,IAAI,CAAC,wDAAwD,CAAC,CAAC;oBACtE,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;wBAAE,MAAM,KAAK,CAAC;gBACxD,CAAC;YACF,CAAC,CAAC,CAAC;QACJ,CAAC;KACD,CAAC;AACH,CAAC,CAAC","sourcesContent":["import type { UnpluginFactory } from \"unplugin\";\nimport { compile, type CompilationResult } from \"../compiler/compile.js\";\nimport { dirname, join, relative, resolve } from \"node:path\";\nimport { createHash } from \"node:crypto\";\nimport nodeFs from \"node:fs\";\nimport { Logger } from \"../services/logger/index.js\";\nimport { ENV_VARIABLES } from \"../services/env-variables/index.js\";\nimport type { CompilerOptions } from \"../compiler/compiler-options.js\";\nimport {\n\tcreateTrackedFs,\n\tgetWatchTargets,\n\tisPathWithinDirectories,\n} from \"../services/file-watching/tracked-fs.js\";\nimport { nodeNormalizePath } from \"../utilities/node-normalize-path.js\";\nimport { seedPreviousCompilationFromOutdir } from \"../compiler/seed-previous-compilation.js\";\nimport {\n\tCONFIG_FILE_NAMES,\n\tclearParaglideConfigCache,\n\tisConfigFileName,\n\tloadParaglideConfig,\n\tresolveCompilerOptions,\n\tresolveConfigCandidate,\n\ttype LoadedParaglideConfig,\n} from \"../services/config/index.js\";\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,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,MAAM,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAEnE,OAAO,EACN,eAAe,EACf,eAAe,EACf,uBAAuB,GACvB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EAAE,iCAAiC,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AAC,CAAC;QACJ,CAAC;KACD,CAAC;AACH,CAAC,CAAC","sourcesContent":["import type { UnpluginFactory } from \"unplugin\";\nimport { compile, type CompilationResult } from \"../compiler/compile.js\";\nimport { dirname, join, relative, resolve } from \"node:path\";\nimport { createHash } from \"node:crypto\";\nimport nodeFs from \"node:fs\";\nimport { Logger } from \"../services/logger/index.js\";\nimport { ENV_VARIABLES } from \"../services/env-variables/index.js\";\nimport type { CompilerOptions } from \"../compiler/compiler-options.js\";\nimport {\n\tcreateTrackedFs,\n\tgetWatchTargets,\n\tisPathWithinDirectories,\n} from \"../services/file-watching/tracked-fs.js\";\nimport { nodeNormalizePath } from \"../utilities/node-normalize-path.js\";\nimport { seedPreviousCompilationFromOutdir } from \"../compiler/seed-previous-compilation.js\";\nimport {\n\tCONFIG_FILE_NAMES,\n\tclearParaglideConfigCache,\n\tisConfigFileName,\n\tloadParaglideConfig,\n\tresolveCompilerOptions,\n\tresolveConfigCandidate,\n\ttype LoadedParaglideConfig,\n} from \"../services/config/index.js\";\nimport type { ErrorPayload, ViteDevServer, WebSocketClient } from \"vite\";\n\nconst PLUGIN_NAME = \"unplugin-paraglide-js\";\n\n/**\n * The options accepted by the paraglide bundler plugins.\n *\n * `project` is required — the path to your inlang project directory, which\n * also hosts the paraglide config file (`<project>/paraglide.config.*`).\n * Relative paths are resolved against the tool's project root (Vite `root`,\n * webpack/rspack `context`, else the process working directory).\n *\n * Every other property is optional: values that are not provided are read\n * from the config file, and anything still missing falls back to the\n * built-in defaults.\n *\n * @example\n * ```ts\n * paraglideVitePlugin({ project: \"./project.inlang\" })\n *\n * // Explicit options win over the config file\n * paraglideVitePlugin({\n * project: \"./project.inlang\",\n * outdir: \"./src/paraglide-custom\",\n * })\n * ```\n */\nexport type ParaglidePluginOptions = Omit<\n\tPartial<CompilerOptions>,\n\t\"project\"\n> & {\n\t/**\n\t * Required — the path to your inlang project directory, which also\n\t * hosts the paraglide config file (`<project>/paraglide.config.*`).\n\t * Relative paths are resolved against the tool's project root (Vite\n\t * `root`, webpack/rspack `context`, else the process working directory).\n\t */\n\tproject: string;\n};\n\nconst logger = new Logger();\n\nconst PERSISTENT_CACHE_VERSION = 1;\n\ntype PersistentCompilationCache = {\n\tversion: typeof PERSISTENT_CACHE_VERSION;\n\tcompilerVersion: string;\n\tinputsDigest: string;\n\treadFiles: string[];\n\toutputHashes: Record<string, string>;\n};\n\nfunction isStringRecord(value: unknown): value is Record<string, string> {\n\treturn (\n\t\ttypeof value === \"object\" &&\n\t\tvalue !== null &&\n\t\t!Array.isArray(value) &&\n\t\tObject.values(value).every((entry) => typeof entry === \"string\")\n\t);\n}\n\n/**\n * Default isServer which differs per bundler.\n */\nlet isServer: string | undefined;\n\ntype PluginState = {\n\t/** Identity of the fs the tracked wrapper was created around. */\n\tbaseFs: typeof nodeFs | undefined;\n\ttrackedFs: typeof nodeFs;\n\treadFiles: Set<string>;\n\tclearReadFiles: () => void;\n\tpreviousCompilation: CompilationResult | undefined;\n\tcompilationError: Error | undefined;\n\t/**\n\t * Digest of the input files and options of the last successful compilation.\n\t *\n\t * `vite build` fires `buildStart` once per environment (client, ssr, ...).\n\t * When the digest of the current inputs matches, `compile()` is skipped\n\t * entirely — project loading and message compilation are expensive even\n\t * when `previousCompilation` dedupes the writes.\n\t *\n\t * https://github.com/opral/paraglide-js/issues/693\n\t */\n\tpreviousInputsDigest: string | undefined;\n\tpreviousProject: string | undefined;\n\tpreviousOutdir: string | undefined;\n};\n\n// Module-scoped so the warm state survives plugin re-instantiation within\n// one process (e.g. a vite config reload), but recreated when a different\n// fs is passed — the tracked wrapper, read set, and cached compilation are\n// only valid for the filesystem they were produced from.\nlet pluginState: PluginState | undefined;\n\nfunction getPluginState(args: Pick<CompilerOptions, \"fs\">): PluginState {\n\tif (pluginState === undefined || pluginState.baseFs !== args.fs) {\n\t\tconst tracked = createTrackedFs({ fs: args.fs });\n\t\tpluginState = {\n\t\t\tbaseFs: args.fs,\n\t\t\ttrackedFs: tracked.fs,\n\t\t\treadFiles: tracked.readFiles,\n\t\t\tclearReadFiles: tracked.clearReadFiles,\n\t\t\tpreviousCompilation: undefined,\n\t\t\tcompilationError: undefined,\n\t\t\tpreviousInputsDigest: undefined,\n\t\t\tpreviousProject: undefined,\n\t\t\tpreviousOutdir: undefined,\n\t\t};\n\t}\n\treturn pluginState;\n}\n\nfunction withoutCleanOutdir(\n\targs: CompilerOptions\n): Omit<CompilerOptions, \"cleanOutdir\"> {\n\tconst { cleanOutdir, ...compileArgs } = args;\n\tvoid cleanOutdir;\n\treturn compileArgs;\n}\n\nfunction getCompilerConfig(\n\targs: CompilerOptions,\n\toutputStructure: NonNullable<CompilerOptions[\"outputStructure\"]>\n) {\n\tconst { fs: _fs, ...serializableArgs } = args;\n\tvoid _fs;\n\treturn {\n\t\t...serializableArgs,\n\t\toutputStructure,\n\t\tisServer,\n\t\tcompilerVersion: ENV_VARIABLES.PARJS_PACKAGE_VERSION,\n\t};\n}\n\n/**\n * Hashes the files (and directory listings) the last compilation read,\n * together with the options that affect the output. Returns `undefined`\n * when the digest can't be computed (no tracked reads yet, an unexpected\n * read error, ...) — `undefined` never matches, so the caller compiles.\n *\n * Directory listings are included so that a message file *added* next to\n * the tracked ones invalidates the digest, not only edits to known files.\n * All components are length-prefixed so distinct input states can't\n * produce the same hash stream.\n *\n * The digest is taken after the compile, by re-reading the inputs. A file\n * edited *during* a compile can therefore be hashed at its new content\n * while the output reflects the old one — accepted: in dev, watchChange\n * recompiles on that edit, and a fresh build process always recompiles.\n */\nasync function computeInputsDigest(\n\tstate: PluginState,\n\targs: CompilerOptions,\n\toutputStructure: NonNullable<CompilerOptions[\"outputStructure\"]>\n): Promise<string | undefined> {\n\tif (state.readFiles.size === 0) {\n\t\treturn undefined;\n\t}\n\tconst targets = getWatchTargets(state.readFiles, { outdir: args.outdir });\n\tif (targets.files.size === 0) {\n\t\treturn undefined;\n\t}\n\tconst fsp = (args.fs ?? nodeFs).promises;\n\tconst hash = createHash(\"sha256\");\n\ttry {\n\t\thash.update(JSON.stringify(getCompilerConfig(args, outputStructure)));\n\t\tfor (const directoryPath of [...targets.directories].sort()) {\n\t\t\tconst entries = await fsp\n\t\t\t\t.readdir(directoryPath)\n\t\t\t\t// tracked reads include probed-but-absent paths (the SDK reads\n\t\t\t\t// optional files and handles ENOENT itself) — a missing entry\n\t\t\t\t// is valid input state, hash it as such\n\t\t\t\t.catch(rethrowUnlessEnoent);\n\t\t\thash.update(`\\0dir:${directoryPath.length}:${directoryPath}:`);\n\t\t\tif (entries === undefined) {\n\t\t\t\thash.update(\"missing\");\n\t\t\t} else {\n\t\t\t\tfor (const entry of [...entries].sort()) {\n\t\t\t\t\thash.update(`${entry.length}:${entry},`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (const filePath of [...targets.files].sort()) {\n\t\t\tconst content = await fsp.readFile(filePath).catch(rethrowUnlessEnoent);\n\t\t\thash.update(`\\0file:${filePath.length}:${filePath}:`);\n\t\t\tif (content === undefined) {\n\t\t\t\thash.update(\"missing\");\n\t\t\t} else {\n\t\t\t\thash.update(`${content.length}:`);\n\t\t\t\thash.update(content);\n\t\t\t}\n\t\t}\n\t} catch {\n\t\treturn undefined;\n\t}\n\treturn hash.digest(\"hex\");\n}\n\nfunction getPersistentCachePath(\n\targs: CompilerOptions,\n\toutputStructure: NonNullable<CompilerOptions[\"outputStructure\"]>\n): string {\n\tconst absoluteOutdir = resolve(process.cwd(), args.outdir);\n\tconst cacheKey = createHash(\"sha256\")\n\t\t.update(\n\t\t\tJSON.stringify({\n\t\t\t\tabsoluteOutdir,\n\t\t\t\tcompilerConfig: getCompilerConfig(args, outputStructure),\n\t\t\t})\n\t\t)\n\t\t.digest(\"hex\")\n\t\t.slice(0, 16);\n\treturn resolve(\n\t\tprocess.cwd(),\n\t\targs.project,\n\t\t\"cache\",\n\t\t\"paraglide-js\",\n\t\t`${cacheKey}.json`\n\t);\n}\n\nasync function readPersistentCache(\n\targs: CompilerOptions,\n\toutputStructure: NonNullable<CompilerOptions[\"outputStructure\"]>\n): Promise<PersistentCompilationCache | undefined> {\n\tconst fsp = (args.fs ?? nodeFs).promises;\n\ttry {\n\t\tconst parsed = JSON.parse(\n\t\t\tawait fsp.readFile(getPersistentCachePath(args, outputStructure), \"utf8\")\n\t\t) as Partial<PersistentCompilationCache>;\n\t\tif (\n\t\t\tparsed.version !== PERSISTENT_CACHE_VERSION ||\n\t\t\tparsed.compilerVersion !== ENV_VARIABLES.PARJS_PACKAGE_VERSION ||\n\t\t\ttypeof parsed.inputsDigest !== \"string\" ||\n\t\t\t!Array.isArray(parsed.readFiles) ||\n\t\t\tparsed.readFiles.some((file) => typeof file !== \"string\") ||\n\t\t\t!isStringRecord(parsed.outputHashes)\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn parsed as PersistentCompilationCache;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nasync function preparePersistentCacheDirectory(\n\targs: CompilerOptions,\n\toutputStructure: NonNullable<CompilerOptions[\"outputStructure\"]>\n): Promise<void> {\n\ttry {\n\t\tawait (args.fs ?? nodeFs).promises.mkdir(\n\t\t\tdirname(getPersistentCachePath(args, outputStructure)),\n\t\t\t{ recursive: true }\n\t\t);\n\t} catch {\n\t\t// The cache is an optimization. Read-only projects must still compile.\n\t}\n}\n\nasync function writePersistentCache(\n\tstate: PluginState,\n\targs: CompilerOptions,\n\toutputStructure: NonNullable<CompilerOptions[\"outputStructure\"]>\n): Promise<void> {\n\tif (\n\t\tstate.previousInputsDigest === undefined ||\n\t\tstate.previousCompilation?.outputHashes === undefined\n\t) {\n\t\treturn;\n\t}\n\tconst cachePath = getPersistentCachePath(args, outputStructure);\n\tconst cache: PersistentCompilationCache = {\n\t\tversion: PERSISTENT_CACHE_VERSION,\n\t\tcompilerVersion: ENV_VARIABLES.PARJS_PACKAGE_VERSION,\n\t\tinputsDigest: state.previousInputsDigest,\n\t\treadFiles: [...state.readFiles].sort(),\n\t\toutputHashes: state.previousCompilation.outputHashes,\n\t};\n\tconst fsp = (args.fs ?? nodeFs).promises;\n\ttry {\n\t\tawait fsp.mkdir(dirname(cachePath), { recursive: true });\n\t\tawait fsp.writeFile(cachePath, JSON.stringify(cache));\n\t} catch {\n\t\t// The cache is an optimization. Read-only projects must still compile.\n\t}\n}\n\nfunction outputHashesMatch(\n\tleft: Record<string, string> | undefined,\n\tright: Record<string, string>\n): boolean {\n\tif (left === undefined) return false;\n\tconst leftEntries = Object.entries(left);\n\tconst rightEntries = Object.entries(right);\n\tif (leftEntries.length !== rightEntries.length) return false;\n\treturn leftEntries.every(([file, hash]) => right[file] === hash);\n}\n\nasync function restorePersistentCache(args: {\n\tstate: PluginState;\n\tcompilerOptions: CompilerOptions;\n\toutputStructure: NonNullable<CompilerOptions[\"outputStructure\"]>;\n}): Promise<boolean> {\n\tconst cached = await readPersistentCache(\n\t\targs.compilerOptions,\n\t\targs.outputStructure\n\t);\n\tif (cached === undefined) return false;\n\n\tconst cachedReadFiles = new Set<string>();\n\tfor (const file of cached.readFiles) {\n\t\tcachedReadFiles.add(file);\n\t}\n\tconst validationState: PluginState = {\n\t\t...args.state,\n\t\treadFiles: cachedReadFiles,\n\t\tclearReadFiles: () => cachedReadFiles.clear(),\n\t};\n\tconst [inputsDigest, previousCompilation] = await Promise.all([\n\t\tcomputeInputsDigest(\n\t\t\tvalidationState,\n\t\t\targs.compilerOptions,\n\t\t\targs.outputStructure\n\t\t),\n\t\tseedPreviousCompilationFromOutdir({\n\t\t\toutdir: args.compilerOptions.outdir,\n\t\t\tfs: args.compilerOptions.fs?.promises,\n\t\t}),\n\t]);\n\tif (\n\t\tinputsDigest !== cached.inputsDigest ||\n\t\t!outputHashesMatch(previousCompilation?.outputHashes, cached.outputHashes)\n\t) {\n\t\treturn false;\n\t}\n\n\targs.state.clearReadFiles();\n\tfor (const file of cachedReadFiles) {\n\t\targs.state.readFiles.add(file);\n\t}\n\targs.state.previousCompilation = previousCompilation;\n\targs.state.previousInputsDigest = inputsDigest;\n\treturn true;\n}\n\nfunction rethrowUnlessEnoent(error: unknown): undefined {\n\tif ((error as NodeJS.ErrnoException)?.code === \"ENOENT\") {\n\t\treturn undefined;\n\t}\n\tthrow error;\n}\n\n// default to locale-modules for development to speed up the dev server\n// https://github.com/opral/inlang-paraglide-js/issues/486\nfunction resolveOutputStructure(\n\toptions: CompilerOptions\n): \"message-modules\" | \"locale-modules\" {\n\tconst isProduction = process.env.NODE_ENV === \"production\";\n\treturn (\n\t\toptions.outputStructure ??\n\t\t(isProduction ? \"message-modules\" : \"locale-modules\")\n\t);\n}\n\nfunction hasUnchangedInputs(args: {\n\tstate: PluginState;\n\tcompilerOptions: CompilerOptions;\n\toutputStructure: \"message-modules\" | \"locale-modules\";\n}): Promise<boolean> {\n\tif (args.state.previousCompilation === undefined) {\n\t\treturn Promise.resolve(false);\n\t}\n\tif (args.state.previousInputsDigest === undefined) {\n\t\treturn Promise.resolve(false);\n\t}\n\treturn computeInputsDigest(\n\t\targs.state,\n\t\targs.compilerOptions,\n\t\targs.outputStructure\n\t).then((currentDigest) => currentDigest === args.state.previousInputsDigest);\n}\n\nfunction maybeInvalidateForOptionsChange(\n\tstate: PluginState,\n\tcompilerOptions: CompilerOptions\n): void {\n\tif (\n\t\tstate.previousProject !== undefined &&\n\t\t(state.previousProject !== compilerOptions.project ||\n\t\t\tstate.previousOutdir !== compilerOptions.outdir)\n\t) {\n\t\tstate.previousCompilation = undefined;\n\t\tstate.previousInputsDigest = undefined;\n\t\tstate.clearReadFiles();\n\t}\n\tstate.previousProject = compilerOptions.project;\n\tstate.previousOutdir = compilerOptions.outdir;\n}\n\n// Compiles and stores the result plus its inputs digest on the plugin\n// state. Callers decide whether to persist the compilation cache.\nasync function compileAndUpdateState(args: {\n\tstate: PluginState;\n\tcompilerOptions: CompilerOptions;\n\toutputStructure: \"message-modules\" | \"locale-modules\";\n\tpreviousCompilation: CompilationResult | undefined;\n\t/**\n\t * The `isServer` expression to bake into the compiled runtime.\n\t * Webpack omits it and relies on the compiler default.\n\t */\n\tisServer: string | undefined;\n}): Promise<void> {\n\targs.state.previousCompilation = await compile({\n\t\tpreviousCompilation: args.previousCompilation,\n\t\toutputStructure: args.outputStructure,\n\t\tisServer: args.isServer,\n\t\t...withoutCleanOutdir(args.compilerOptions),\n\t\tcleanOutdir: false,\n\t\t// after the options spread so a user-provided fs doesn't bypass\n\t\t// the read tracking (trackedFs wraps options.fs when provided)\n\t\tfs: args.state.trackedFs,\n\t});\n\targs.state.previousInputsDigest = await computeInputsDigest(\n\t\targs.state,\n\t\targs.compilerOptions,\n\t\targs.outputStructure\n\t);\n}\n\n/**\n * Runs the compilation with the given, already-resolved options. Shared by\n * buildStart and watch-mode rebuilds.\n */\nasync function runCompilation(args: {\n\tstate: PluginState;\n\tcompilerOptions: CompilerOptions;\n}): Promise<void> {\n\tconst compilerOptions = args.compilerOptions;\n\tconst { state } = args;\n\tconst outputStructure = resolveOutputStructure(compilerOptions);\n\tmaybeInvalidateForOptionsChange(state, compilerOptions);\n\tstate.compilationError = undefined;\n\ttry {\n\t\t// Stabilize project directory listings before the first digest. The\n\t\t// ignored cache directory must not invalidate the cache that creates it.\n\t\tawait preparePersistentCacheDirectory(compilerOptions, outputStructure);\n\t\tif (\n\t\t\tstate.previousCompilation === undefined &&\n\t\t\t(await restorePersistentCache({\n\t\t\t\tstate,\n\t\t\t\tcompilerOptions,\n\t\t\t\toutputStructure,\n\t\t\t}))\n\t\t) {\n\t\t\tlogger.info(\n\t\t\t\t`Compilation skipped — inputs unchanged (${outputStructure})`\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tif (\n\t\t\tawait hasUnchangedInputs({\n\t\t\t\tstate,\n\t\t\t\tcompilerOptions,\n\t\t\t\toutputStructure,\n\t\t\t})\n\t\t) {\n\t\t\tlogger.info(\n\t\t\t\t`Compilation skipped — inputs unchanged (${outputStructure})`\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\t// On a fresh process, seed previousCompilation from on-disk hashes\n\t\t// so the first compile is a no-op when inputs are unchanged. Avoids\n\t\t// racing concurrent readers that wiping outdir would interrupt.\n\t\tconst seededPrevious =\n\t\t\tstate.previousCompilation ??\n\t\t\t(await seedPreviousCompilationFromOutdir({\n\t\t\t\toutdir: compilerOptions.outdir,\n\t\t\t\tfs: compilerOptions.fs?.promises,\n\t\t\t}));\n\t\tawait compileAndUpdateState({\n\t\t\tstate,\n\t\t\tcompilerOptions,\n\t\t\toutputStructure,\n\t\t\tpreviousCompilation: seededPrevious,\n\t\t\tisServer,\n\t\t});\n\t\tawait writePersistentCache(state, compilerOptions, outputStructure);\n\t\tlogger.success(`Compilation complete (${outputStructure})`);\n\t} catch (error) {\n\t\tstate.compilationError =\n\t\t\terror instanceof Error ? error : new Error(String(error));\n\t\tstate.previousInputsDigest = undefined;\n\t\tlogger.error(\"Failed to compile project:\", (error as Error).message);\n\t\tlogger.info(\"Please check your translation files for syntax errors.\");\n\t\tif (process.env.NODE_ENV === \"production\") throw error;\n\t}\n}\n\n// The return type preserves literal option types (`enforce: \"pre\"`, ...)\n// while `project` stays required on the input side.\ntype UnpluginIntegrationOptions = Pick<CompilerOptions, \"outputStructure\"> & {\n\tdevErrorResponse?: boolean;\n};\n\ntype UnpluginFactoryWithOptions = (\n\tuserArgs: ParaglidePluginOptions,\n\tmeta?: Parameters<UnpluginFactory<ParaglidePluginOptions>>[1],\n\tdefaults?: UnpluginIntegrationOptions\n) => ReturnType<UnpluginFactory<ParaglidePluginOptions>>;\n\nexport const unpluginFactory: UnpluginFactoryWithOptions = (\n\tuserArgs,\n\t_meta,\n\tdefaults\n) => {\n\tconst state = getPluginState(userArgs);\n\tconst { readFiles, clearReadFiles } = state;\n\t// Project root as reported by the bundler (vite `root`, webpack/rspack\n\t// `context`). Falls back to the process working directory when the\n\t// bundler doesn't provide one. The config file is resolved inside the\n\t// project directory.\n\tlet discoveryRoot: string | undefined;\n\t// Bound to the hook context in buildStart so that watchChange can\n\t// register additional files.\n\tlet addWatchFile: ((path: string) => void) | undefined;\n\t// A new plugin instance must not be served by config cache entries\n\t// from a previous instance (e.g. vite.config.ts reloads reuse the\n\t// process). Wiping the cache here makes every instance perform one\n\t// fresh load; subsequent loads within the instance stay cached.\n\tclearParaglideConfigCache();\n\n\tfunction safeAddWatchFile(\n\t\tthisArg: { addWatchFile: (path: string) => void } | undefined,\n\t\tpath: string\n\t): void {\n\t\tconst fn = thisArg?.addWatchFile ?? addWatchFile;\n\t\tif (!fn) return;\n\t\tif (watchRegistrationUnsupported) return;\n\t\ttry {\n\t\t\tfn.call(thisArg ?? undefined, path);\n\t\t} catch (error) {\n\t\t\t// Watch-file registration is best-effort: backends differ in what\n\t\t\t// they support (unplugin's esbuild context throws for every call),\n\t\t\t// and watcher resource limits can surface as errors. A failed\n\t\t\t// registration must never fail the build.\n\t\t\twatchRegistrationUnsupported = true;\n\t\t\tlogger.warn(\n\t\t\t\t`Registering additional watch files is not supported by this bundler context — skipping further registrations (${(error as Error)?.message ?? String(error)})`\n\t\t\t);\n\t\t}\n\t}\n\n\t// Whether a config file was present at the last load — drives the\n\t// one-time warning when every config candidate disappears.\n\tlet hadActiveConfig = false;\n\t// Watch-rebuild serialization state (see watchChange).\n\tlet compiling = false;\n\tlet isClosed = false;\n\tlet pendingCompilation: Promise<void> | undefined;\n\tconst pendingWatchPaths = new Set<string>();\n\tconst pendingCompilationCachePaths = new Set<string>();\n\t// Options from the most recent successful resolution — reused by input\n\t// events that cannot have changed them.\n\tlet lastOptions: CompilerOptions | undefined;\n\t// Set once a bundler context rejects watch-file registrations (esbuild);\n\t// further registration attempts are skipped to avoid warning floods.\n\tlet watchRegistrationUnsupported = false;\n\tlet viteServer: ViteDevServer | undefined;\n\tlet viteError: ErrorPayload | undefined;\n\tlet configLoadFailed = false;\n\n\tfunction reportViteError(\n\t\terror: unknown,\n\t\tsource: \"config\" | \"compilation\" = \"compilation\"\n\t): void {\n\t\tif (!viteServer || process.env.NODE_ENV === \"production\") return;\n\t\tif (configLoadFailed && source === \"compilation\") return;\n\t\tif (source === \"config\") configLoadFailed = true;\n\t\tconst failure = error instanceof Error ? error : new Error(String(error));\n\t\tviteError = {\n\t\t\ttype: \"error\",\n\t\t\terr: {\n\t\t\t\tmessage: failure.message,\n\t\t\t\tstack: failure.stack ?? \"\",\n\t\t\t\tplugin: PLUGIN_NAME,\n\t\t\t},\n\t\t};\n\t\t// Older Vite versions buffer errors without clients, even after recovery.\n\t\tif (viteServer.ws.clients.size > 0) viteServer.ws.send(viteError);\n\t}\n\n\tfunction clearViteError(): void {\n\t\tif (!viteServer || !viteError || configLoadFailed) return;\n\t\tviteError = undefined;\n\t\t// An invalid config can recover without writing generated files,\n\t\t// leaving no HMR update to dismiss the error overlay.\n\t\tif (viteServer.ws.clients.size > 0) {\n\t\t\tviteServer.ws.send({ type: \"full-reload\" });\n\t\t}\n\t}\n\n\tconst getProjectDir = () =>\n\t\tnodeNormalizePath(\n\t\t\tresolve(discoveryRoot ?? process.cwd(), userArgs.project)\n\t\t);\n\n\tconst resolveOptionsWith = (\n\t\tloaded: LoadedParaglideConfig | undefined\n\t): CompilerOptions => {\n\t\tconst options = resolveCompilerOptions({\n\t\t\tconfig: loaded?.config,\n\t\t\toverrides: userArgs,\n\t\t\troot: discoveryRoot ?? process.cwd(),\n\t\t});\n\t\t// Apply integration defaults after each config load, keeping watched\n\t\t// config values separate from explicit plugin overrides.\n\t\tif (\n\t\t\toptions.outputStructure === undefined &&\n\t\t\tdefaults?.outputStructure !== undefined\n\t\t) {\n\t\t\toptions.outputStructure = defaults.outputStructure;\n\t\t}\n\t\treturn options;\n\t};\n\n\t/**\n\t * Loads the active config, following candidate renames and keeping the\n\t * last known-good configuration while the file is missing or invalid.\n\t * Callers that know the config content changed should clear the cache\n\t * for the project directory first.\n\t */\n\tasync function loadActiveConfig(): Promise<\n\t\tLoadedParaglideConfig | undefined\n\t> {\n\t\tconst dir = getProjectDir();\n\t\tconst winner = await resolveConfigCandidate(dir);\n\t\tif (winner === undefined) {\n\t\t\tif (hadActiveConfig) {\n\t\t\t\thadActiveConfig = false;\n\t\t\t\tlogger.warn(\n\t\t\t\t\t\"Paraglide config file was removed, continuing with default options.\"\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\t\thadActiveConfig = true;\n\t\t// Throws when the file exists but is invalid — callers decide the\n\t\t// policy: watch modes skip and surface the error in development,\n\t\t// build paths fail loudly in production.\n\t\treturn loadParaglideConfig({ projectDir: dir, logger });\n\t}\n\n\t/**\n\t * Rebuild for a single watch event. Config-named events reload the\n\t * config; input events reuse the last known options unless the config\n\t * failed to load.\n\t */\n\tasync function performWatchRecompile(path: string): Promise<void> {\n\t\tconst normalizedPath = nodeNormalizePath(path);\n\t\tconst projectDir = getProjectDir();\n\t\tconst withinProjectDir =\n\t\t\tnormalizedPath === projectDir ||\n\t\t\tnormalizedPath.startsWith(`${projectDir}/`);\n\t\tconst configEvent = withinProjectDir && isConfigFileName(normalizedPath);\n\n\t\tlet args: CompilerOptions;\n\t\tif (!configEvent && lastOptions !== undefined) {\n\t\t\tconst targets = getWatchTargets(readFiles, {\n\t\t\t\toutdir: lastOptions.outdir,\n\t\t\t});\n\t\t\tif (targets.isIgnoredPath(normalizedPath)) return;\n\t\t\tconst shouldCompile =\n\t\t\t\ttargets.files.has(normalizedPath) ||\n\t\t\t\tisPathWithinDirectories(normalizedPath, targets.directories);\n\t\t\tif (!shouldCompile) return;\n\t\t}\n\t\tif (!configEvent && lastOptions !== undefined && !configLoadFailed) {\n\t\t\targs = lastOptions;\n\t\t} else {\n\t\t\tif (configEvent) {\n\t\t\t\tlogger.info(\"Paraglide configuration changed, re-compiling.\");\n\t\t\t\tclearParaglideConfigCache({ projectDir });\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tconst loaded = await loadActiveConfig();\n\t\t\t\targs = resolveOptionsWith(loaded);\n\t\t\t} catch (error) {\n\t\t\t\t// Invalid config: skip the compilation entirely and surface\n\t\t\t\t// the problem. The previously compiled output stays on disk.\n\t\t\t\treportViteError(error, \"config\");\n\t\t\t\tlogger.error((error as Error).message);\n\t\t\t\tlogger.error(\n\t\t\t\t\t\"Skipping compilation because of the invalid paraglide config.\"\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tlastOptions = args;\n\t\t\tconfigLoadFailed = false;\n\t\t}\n\n\t\tmaybeInvalidateForOptionsChange(state, args);\n\t\tconst outputStructure = resolveOutputStructure(args);\n\t\tconst previouslyReadFiles = new Set(readFiles);\n\n\t\ttry {\n\t\t\tif (!configEvent) {\n\t\t\t\tlogger.info(\n\t\t\t\t\t`Re-compiling inlang project... File \"${relative(process.cwd(), path)}\" has changed.`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tclearReadFiles();\n\t\t\tpendingCompilationCachePaths.add(\n\t\t\t\tgetPersistentCachePath(args, outputStructure)\n\t\t\t);\n\t\t\tawait compileAndUpdateState({\n\t\t\t\tstate,\n\t\t\t\tcompilerOptions: args,\n\t\t\t\toutputStructure,\n\t\t\t\tpreviousCompilation: state.previousCompilation,\n\t\t\t\tisServer,\n\t\t\t});\n\t\t\tawait writePersistentCache(state, args, outputStructure);\n\t\t\tlogger.success(`Re-compilation complete (${outputStructure})`);\n\t\t\tclearViteError();\n\n\t\t\tconst nextTargets = getWatchTargets(readFiles, { outdir: args.outdir });\n\t\t\tfor (const filePath of nextTargets.files)\n\t\t\t\tsafeAddWatchFile(undefined, filePath);\n\t\t\tfor (const directoryPath of nextTargets.directories)\n\t\t\t\tsafeAddWatchFile(undefined, directoryPath);\n\t\t} catch (e) {\n\t\t\treportViteError(e);\n\t\t\tclearReadFiles();\n\t\t\tfor (const filePath of previouslyReadFiles) readFiles.add(filePath);\n\t\t\tstate.previousCompilation = undefined;\n\t\t\tstate.previousInputsDigest = undefined;\n\t\t\tlogger.warn(\"Failed to re-compile project:\", (e as Error).message);\n\t\t}\n\t}\n\n\treturn {\n\t\tname: PLUGIN_NAME,\n\t\tenforce: \"pre\",\n\t\tasync buildStart() {\n\t\t\tif (isClosed) clearParaglideConfigCache({ projectDir: getProjectDir() });\n\t\t\tisClosed = false;\n\t\t\taddWatchFile = this.addWatchFile?.bind(this);\n\t\t\ttry {\n\t\t\t\tconst loaded = await loadActiveConfig();\n\t\t\t\tconst args = resolveOptionsWith(loaded);\n\t\t\t\tconfigLoadFailed = false;\n\t\t\t\tlastOptions = args;\n\t\t\t\tawait runCompilation({ state, compilerOptions: args });\n\t\t\t} catch (error) {\n\t\t\t\t// Config errors are converted to last-good options by\n\t\t\t\t// loadActiveConfig; compilation errors are handled inside\n\t\t\t\t// runCompilation. Anything escaping is unexpected — fail the\n\t\t\t\t// build in production, keep serving in development.\n\t\t\t\tif (process.env.NODE_ENV === \"production\") throw error;\n\t\t\t\tlogger.error(\n\t\t\t\t\t\"Failed to prepare paraglide compilation:\",\n\t\t\t\t\t(error as Error).message\n\t\t\t\t);\n\t\t\t\treportViteError(error, \"config\");\n\t\t\t\treturn;\n\t\t\t} finally {\n\t\t\t\tif (lastOptions !== undefined) {\n\t\t\t\t\tconst targets = getWatchTargets(readFiles, {\n\t\t\t\t\t\toutdir: lastOptions.outdir,\n\t\t\t\t\t});\n\t\t\t\t\tfor (const filePath of targets.files)\n\t\t\t\t\t\tsafeAddWatchFile(this, filePath);\n\t\t\t\t\tfor (const directoryPath of targets.directories)\n\t\t\t\t\t\tsafeAddWatchFile(this, directoryPath);\n\t\t\t\t}\n\t\t\t\t// Register every config candidate inside the project directory\n\t\t\t\t// so renames and format switches are reported even by backends\n\t\t\t\t// that only report watched files (webpack's modifiedFiles).\n\t\t\t\tconst projectDir = getProjectDir();\n\t\t\t\tfor (const name of CONFIG_FILE_NAMES) {\n\t\t\t\t\tsafeAddWatchFile(\n\t\t\t\t\t\tthis as unknown as { addWatchFile: (p: string) => void },\n\t\t\t\t\t\tjoin(projectDir, name)\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (state.compilationError) {\n\t\t\t\treportViteError(state.compilationError);\n\t\t\t} else {\n\t\t\t\tclearViteError();\n\t\t\t}\n\t\t},\n\t\twatchChange(path) {\n\t\t\tif (isClosed) return pendingCompilation;\n\t\t\t// Serialize rebuilds: bundlers may deliver several watchChange\n\t\t\t// events concurrently (webpack fires once per modified file).\n\t\t\t// Every path is queued — a config event must never be starved by\n\t\t\t// later input events.\n\t\t\tpendingWatchPaths.add(nodeNormalizePath(path));\n\t\t\tif (compiling) return pendingCompilation;\n\t\t\tcompiling = true;\n\t\t\tpendingCompilation = (async () => {\n\t\t\t\ttry {\n\t\t\t\t\twhile (pendingWatchPaths.size > 0) {\n\t\t\t\t\t\tconst batch = [...pendingWatchPaths];\n\t\t\t\t\t\tpendingWatchPaths.clear();\n\t\t\t\t\t\tfor (const current of batch) {\n\t\t\t\t\t\t\tawait performWatchRecompile(current);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} finally {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tif (isClosed) {\n\t\t\t\t\t\t\t// Inputs can change after compile reads them but before its\n\t\t\t\t\t\t\t// digest is taken. Once closing starts, watcher events can\n\t\t\t\t\t\t\t// no longer repair that mismatch, so neither warm nor cold\n\t\t\t\t\t\t\t// restarts may reuse caches from this queue.\n\t\t\t\t\t\t\tstate.previousInputsDigest = undefined;\n\t\t\t\t\t\t\tfor (const cachePath of pendingCompilationCachePaths) {\n\t\t\t\t\t\t\t\tawait (userArgs.fs ?? nodeFs).promises.rm(cachePath, {\n\t\t\t\t\t\t\t\t\tforce: true,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tpendingCompilationCachePaths.clear();\n\t\t\t\t\t\tcompiling = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t})();\n\t\t\treturn pendingCompilation;\n\t\t},\n\t\tcloseBundle() {\n\t\t\tisClosed = true;\n\t\t\treturn pendingCompilation;\n\t\t},\n\t\tvite: {\n\t\t\tconfig: {\n\t\t\t\thandler: () => {\n\t\t\t\t\tisServer = \"import.meta.env?.SSR ?? typeof window === 'undefined'\";\n\t\t\t\t},\n\t\t\t},\n\t\t\tconfigEnvironment: {\n\t\t\t\thandler: () => {\n\t\t\t\t\tisServer = \"import.meta.env?.SSR ?? typeof window === 'undefined'\";\n\t\t\t\t},\n\t\t\t},\n\t\t\tconfigResolved: {\n\t\t\t\thandler: (config: { root?: string }) => {\n\t\t\t\t\tdiscoveryRoot = config.root;\n\t\t\t\t},\n\t\t\t},\n\t\t\tconfigureServer(server) {\n\t\t\t\tviteServer = server;\n\t\t\t\tif (defaults?.devErrorResponse) {\n\t\t\t\t\tserver.middlewares.use((_request, response, next) => {\n\t\t\t\t\t\tif (!viteError) return next();\n\t\t\t\t\t\tresponse.statusCode = 500;\n\t\t\t\t\t\tresponse.setHeader(\"Content-Type\", \"text/plain; charset=utf-8\");\n\t\t\t\t\t\tresponse.setHeader(\"Cache-Control\", \"no-store\");\n\t\t\t\t\t\tresponse.end(viteError.err.message);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tserver.ws.on(\"connection\", (socket: WebSocketClient[\"socket\"]) => {\n\t\t\t\t\tif (viteError) socket.send(JSON.stringify(viteError));\n\t\t\t\t});\n\t\t\t},\n\t\t},\n\t\twebpack(compiler) {\n\t\t\tdiscoveryRoot = compiler.context;\n\t\t\tcompiler.options.resolve = {\n\t\t\t\t...compiler.options.resolve,\n\t\t\t\tfallback: {\n\t\t\t\t\t...compiler.options.resolve?.fallback,\n\t\t\t\t\t// https://stackoverflow.com/a/72989932\n\t\t\t\t\tasync_hooks: false,\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tcompiler.hooks.beforeRun.tapPromise(PLUGIN_NAME, async () => {\n\t\t\t\tlet args: CompilerOptions;\n\t\t\t\ttry {\n\t\t\t\t\tconst loaded = await loadActiveConfig();\n\t\t\t\t\targs = resolveOptionsWith(loaded);\n\t\t\t\t\tlastOptions = args;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tstate.previousInputsDigest = undefined;\n\t\t\t\t\tstate.previousCompilation = undefined;\n\t\t\t\t\tlogger.error(\n\t\t\t\t\t\t\"Failed to load paraglide config:\",\n\t\t\t\t\t\t(error as Error).message\n\t\t\t\t\t);\n\t\t\t\t\tif (process.env.NODE_ENV === \"production\") throw error;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst outputStructure = resolveOutputStructure(args);\n\t\t\t\tmaybeInvalidateForOptionsChange(state, args);\n\t\t\t\ttry {\n\t\t\t\t\tawait preparePersistentCacheDirectory(args, outputStructure);\n\t\t\t\t\tif (\n\t\t\t\t\t\tstate.previousCompilation === undefined &&\n\t\t\t\t\t\t(await restorePersistentCache({\n\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\tcompilerOptions: args,\n\t\t\t\t\t\t\toutputStructure,\n\t\t\t\t\t\t}))\n\t\t\t\t\t) {\n\t\t\t\t\t\tlogger.info(\n\t\t\t\t\t\t\t`Compilation skipped — inputs unchanged (${outputStructure})`\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\t// Multi-compiler webpack setups (client + server) trigger\n\t\t\t\t\t// beforeRun once per compiler — skip when inputs are unchanged.\n\t\t\t\t\tif (\n\t\t\t\t\t\tawait hasUnchangedInputs({\n\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\tcompilerOptions: args,\n\t\t\t\t\t\t\toutputStructure,\n\t\t\t\t\t\t})\n\t\t\t\t\t) {\n\t\t\t\t\t\tlogger.info(\n\t\t\t\t\t\t\t`Compilation skipped — inputs unchanged (${outputStructure})`\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tconst seededPrevious =\n\t\t\t\t\t\tstate.previousCompilation ??\n\t\t\t\t\t\t(await seedPreviousCompilationFromOutdir({\n\t\t\t\t\t\t\toutdir: args.outdir,\n\t\t\t\t\t\t\tfs: args.fs?.promises,\n\t\t\t\t\t\t}));\n\t\t\t\t\tawait compileAndUpdateState({\n\t\t\t\t\t\tstate,\n\t\t\t\t\t\tcompilerOptions: args,\n\t\t\t\t\t\toutputStructure,\n\t\t\t\t\t\tpreviousCompilation: seededPrevious,\n\t\t\t\t\t\t// webpack has no vite-style SSR expression; rely on the\n\t\t\t\t\t\t// compiler default.\n\t\t\t\t\t\tisServer: undefined,\n\t\t\t\t\t});\n\t\t\t\t\tawait writePersistentCache(state, args, outputStructure);\n\t\t\t\t\tlogger.success(`Compilation complete (${outputStructure})`);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tstate.previousInputsDigest = undefined;\n\t\t\t\t\tlogger.warn(\"Failed to compile project:\", (error as Error).message);\n\t\t\t\t\tlogger.warn(\"Please check your translation files for syntax errors.\");\n\t\t\t\t\tif (process.env.NODE_ENV === \"production\") throw error;\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t\trspack(compiler) {\n\t\t\tdiscoveryRoot = compiler.context;\n\t\t\t// Rspack mirrors webpack's hook API but ships no usable types,\n\t\t\t// so hooks are tapped structurally.\n\t\t\tconst tapRspackBeforeRun = (fn: () => Promise<void>): void => {\n\t\t\t\tconst target = (\n\t\t\t\t\tcompiler as unknown as {\n\t\t\t\t\t\thooks: Record<\n\t\t\t\t\t\t\tstring,\n\t\t\t\t\t\t\t{ tapPromise?: (n: string, fn: () => Promise<void>) => void }\n\t\t\t\t\t\t>;\n\t\t\t\t\t}\n\t\t\t\t).hooks?.beforeRun;\n\t\t\t\ttarget?.tapPromise?.(PLUGIN_NAME, fn);\n\t\t\t};\n\t\t\ttapRspackBeforeRun(async () => {\n\t\t\t\tlet args: CompilerOptions;\n\t\t\t\ttry {\n\t\t\t\t\tconst loaded = await loadActiveConfig();\n\t\t\t\t\targs = resolveOptionsWith(loaded);\n\t\t\t\t\tlastOptions = args;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tstate.previousInputsDigest = undefined;\n\t\t\t\t\tstate.previousCompilation = undefined;\n\t\t\t\t\tlogger.error(\n\t\t\t\t\t\t\"Failed to load paraglide config:\",\n\t\t\t\t\t\t(error as Error).message\n\t\t\t\t\t);\n\t\t\t\t\tif (process.env.NODE_ENV === \"production\") throw error;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst outputStructure = resolveOutputStructure(args);\n\t\t\t\tmaybeInvalidateForOptionsChange(state, args);\n\t\t\t\ttry {\n\t\t\t\t\tawait preparePersistentCacheDirectory(args, outputStructure);\n\t\t\t\t\tif (\n\t\t\t\t\t\tstate.previousCompilation === undefined &&\n\t\t\t\t\t\t(await restorePersistentCache({\n\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\tcompilerOptions: args,\n\t\t\t\t\t\t\toutputStructure,\n\t\t\t\t\t\t}))\n\t\t\t\t\t) {\n\t\t\t\t\t\tlogger.info(\n\t\t\t\t\t\t\t`Compilation skipped — inputs unchanged (${outputStructure})`\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tif (\n\t\t\t\t\t\tawait hasUnchangedInputs({\n\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\tcompilerOptions: args,\n\t\t\t\t\t\t\toutputStructure,\n\t\t\t\t\t\t})\n\t\t\t\t\t) {\n\t\t\t\t\t\tlogger.info(\n\t\t\t\t\t\t\t`Compilation skipped — inputs unchanged (${outputStructure})`\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tconst seededPrevious =\n\t\t\t\t\t\tstate.previousCompilation ??\n\t\t\t\t\t\t(await seedPreviousCompilationFromOutdir({\n\t\t\t\t\t\t\toutdir: args.outdir,\n\t\t\t\t\t\t\tfs: args.fs?.promises,\n\t\t\t\t\t\t}));\n\t\t\t\t\tawait compileAndUpdateState({\n\t\t\t\t\t\tstate,\n\t\t\t\t\t\tcompilerOptions: args,\n\t\t\t\t\t\toutputStructure,\n\t\t\t\t\t\tpreviousCompilation: seededPrevious,\n\t\t\t\t\t\tisServer: undefined,\n\t\t\t\t\t});\n\t\t\t\t\tawait writePersistentCache(state, args, outputStructure);\n\t\t\t\t\tlogger.success(`Compilation complete (${outputStructure})`);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tstate.previousInputsDigest = undefined;\n\t\t\t\t\tlogger.warn(\"Failed to compile project:\", (error as Error).message);\n\t\t\t\t\tlogger.warn(\"Please check your translation files for syntax errors.\");\n\t\t\t\t\tif (process.env.NODE_ENV === \"production\") throw error;\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t};\n};\n"]}
|