@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.
Files changed (180) hide show
  1. package/README.md +9 -0
  2. package/dist/bundler-plugins/per-locale-build/index.js +14 -7
  3. package/dist/bundler-plugins/per-locale-build/index.js.map +1 -1
  4. package/dist/bundler-plugins/per-locale-build/vite-environments.test.js +235 -2
  5. package/dist/bundler-plugins/per-locale-build/vite-environments.test.js.map +1 -1
  6. package/dist/bundler-plugins/unplugin.d.ts +4 -1
  7. package/dist/bundler-plugins/unplugin.js +134 -22
  8. package/dist/bundler-plugins/unplugin.js.map +1 -1
  9. package/dist/bundler-plugins/unplugin.test.js +490 -1
  10. package/dist/bundler-plugins/unplugin.test.js.map +1 -1
  11. package/dist/bundler-plugins/vite-error-response.test.d.ts +1 -0
  12. package/dist/bundler-plugins/vite-error-response.test.js +171 -0
  13. package/dist/bundler-plugins/vite-error-response.test.js.map +1 -0
  14. package/dist/bundler-plugins/vite.d.ts +8 -0
  15. package/dist/bundler-plugins/vite.js +14 -4
  16. package/dist/bundler-plugins/vite.js.map +1 -1
  17. package/dist/bundler-plugins/vite.test.js +1 -1
  18. package/dist/bundler-plugins/vite.test.js.map +1 -1
  19. package/dist/cli/commands/compile/command.js +13 -0
  20. package/dist/cli/commands/compile/command.js.map +1 -1
  21. package/dist/cli/commands/compile/command.test.js +87 -3
  22. package/dist/cli/commands/compile/command.test.js.map +1 -1
  23. package/dist/cli/commands/init/command.d.ts +5 -0
  24. package/dist/cli/commands/init/command.js +213 -59
  25. package/dist/cli/commands/init/command.js.map +1 -1
  26. package/dist/cli/commands/init/command.test.d.ts +1 -0
  27. package/dist/cli/commands/init/command.test.js +123 -0
  28. package/dist/cli/commands/init/command.test.js.map +1 -0
  29. package/dist/cli/init-options.d.ts +11 -0
  30. package/dist/cli/init-options.js +2 -0
  31. package/dist/cli/init-options.js.map +1 -0
  32. package/dist/cli/steps/add-inlang-check.js +2 -2
  33. package/dist/cli/steps/add-inlang-check.js.map +1 -1
  34. package/dist/cli/steps/add-message-lint.d.ts +34 -0
  35. package/dist/cli/steps/add-message-lint.js +105 -0
  36. package/dist/cli/steps/add-message-lint.js.map +1 -0
  37. package/dist/cli/steps/add-message-lint.test.d.ts +1 -0
  38. package/dist/cli/steps/add-message-lint.test.js +74 -0
  39. package/dist/cli/steps/add-message-lint.test.js.map +1 -0
  40. package/dist/cli/steps/add-vite-plugin.d.ts +18 -0
  41. package/dist/cli/steps/add-vite-plugin.js +34 -6
  42. package/dist/cli/steps/add-vite-plugin.js.map +1 -1
  43. package/dist/cli/steps/add-vite-plugin.test.js +25 -9
  44. package/dist/cli/steps/add-vite-plugin.test.js.map +1 -1
  45. package/dist/cli/steps/check-for-uncomitted-changes.d.ts +3 -0
  46. package/dist/cli/steps/check-for-uncomitted-changes.js +15 -3
  47. package/dist/cli/steps/check-for-uncomitted-changes.js.map +1 -1
  48. package/dist/cli/steps/detect-bundler.d.ts +1 -0
  49. package/dist/cli/steps/detect-bundler.js +7 -1
  50. package/dist/cli/steps/detect-bundler.js.map +1 -1
  51. package/dist/cli/steps/initialize-inlang-project.d.ts +4 -3
  52. package/dist/cli/steps/initialize-inlang-project.js +60 -157
  53. package/dist/cli/steps/initialize-inlang-project.js.map +1 -1
  54. package/dist/cli/steps/maybe-add-machine-translation.d.ts +4 -0
  55. package/dist/cli/steps/maybe-add-machine-translation.js +11 -6
  56. package/dist/cli/steps/maybe-add-machine-translation.js.map +1 -1
  57. package/dist/cli/steps/maybe-add-sherlock.d.ts +2 -0
  58. package/dist/cli/steps/maybe-add-sherlock.js +12 -6
  59. package/dist/cli/steps/maybe-add-sherlock.js.map +1 -1
  60. package/dist/cli/steps/maybe-add-sherlock.test.d.ts +1 -0
  61. package/dist/cli/steps/maybe-add-sherlock.test.js +44 -0
  62. package/dist/cli/steps/maybe-add-sherlock.test.js.map +1 -0
  63. package/dist/cli/steps/prompt-for-outdir.d.ts +2 -0
  64. package/dist/cli/steps/prompt-for-outdir.js +4 -0
  65. package/dist/cli/steps/prompt-for-outdir.js.map +1 -1
  66. package/dist/cli/steps/update-package-json.js +8 -13
  67. package/dist/cli/steps/update-package-json.js.map +1 -1
  68. package/dist/cli/steps/update-ts-config.d.ts +6 -0
  69. package/dist/cli/steps/update-ts-config.js +27 -4
  70. package/dist/cli/steps/update-ts-config.js.map +1 -1
  71. package/dist/cli/utils.d.ts +2 -0
  72. package/dist/cli/utils.js +6 -0
  73. package/dist/cli/utils.js.map +1 -1
  74. package/dist/cli/utils.test.d.ts +1 -0
  75. package/dist/cli/utils.test.js +16 -0
  76. package/dist/cli/utils.test.js.map +1 -0
  77. package/dist/compiler/compile-annotation.js +6 -1
  78. package/dist/compiler/compile-annotation.js.map +1 -1
  79. package/dist/compiler/compile-bundle.d.ts +4 -0
  80. package/dist/compiler/compile-bundle.js +67 -2
  81. package/dist/compiler/compile-bundle.js.map +1 -1
  82. package/dist/compiler/compile-bundle.test.js +214 -1
  83. package/dist/compiler/compile-bundle.test.js.map +1 -1
  84. package/dist/compiler/compile-lifecycle.test.d.ts +1 -0
  85. package/dist/compiler/compile-lifecycle.test.js +69 -0
  86. package/dist/compiler/compile-lifecycle.test.js.map +1 -0
  87. package/dist/compiler/compile-local-variable.test.js +14 -14
  88. package/dist/compiler/compile-local-variable.test.js.map +1 -1
  89. package/dist/compiler/compile-message.exact-number.test.js +1 -1
  90. package/dist/compiler/compile-message.exact-number.test.js.map +1 -1
  91. package/dist/compiler/compile-message.locals.test.js +1 -1
  92. package/dist/compiler/compile-message.locals.test.js.map +1 -1
  93. package/dist/compiler/compile-message.test.js +2 -2
  94. package/dist/compiler/compile-message.test.js.map +1 -1
  95. package/dist/compiler/compile-pattern.test.js +5 -5
  96. package/dist/compiler/compile-pattern.test.js.map +1 -1
  97. package/dist/compiler/compile-project.js +1 -0
  98. package/dist/compiler/compile-project.js.map +1 -1
  99. package/dist/compiler/compile-project.test.js +94 -1
  100. package/dist/compiler/compile-project.test.js.map +1 -1
  101. package/dist/compiler/compile.js +36 -17
  102. package/dist/compiler/compile.js.map +1 -1
  103. package/dist/compiler/compile.test.js +70 -0
  104. package/dist/compiler/compile.test.js.map +1 -1
  105. package/dist/compiler/compiler-options.d.ts +41 -0
  106. package/dist/compiler/compiler-options.js.map +1 -1
  107. package/dist/compiler/output-structure/message-modules.js +1 -1
  108. package/dist/compiler/output-structure/message-modules.js.map +1 -1
  109. package/dist/compiler/registry.js +71 -13
  110. package/dist/compiler/registry.js.map +1 -1
  111. package/dist/compiler/registry.test.d.ts +1 -0
  112. package/dist/compiler/registry.test.js +291 -0
  113. package/dist/compiler/registry.test.js.map +1 -0
  114. package/dist/compiler/runtime/create-runtime.d.ts +2 -0
  115. package/dist/compiler/runtime/create-runtime.js +9 -0
  116. package/dist/compiler/runtime/create-runtime.js.map +1 -1
  117. package/dist/compiler/runtime/extract-locale-from-cookie.js +8 -1
  118. package/dist/compiler/runtime/extract-locale-from-cookie.js.map +1 -1
  119. package/dist/compiler/runtime/extract-locale-from-cookie.test.js +26 -0
  120. package/dist/compiler/runtime/extract-locale-from-cookie.test.js.map +1 -1
  121. package/dist/compiler/runtime/extract-locale-from-header.js +47 -5
  122. package/dist/compiler/runtime/extract-locale-from-header.js.map +1 -1
  123. package/dist/compiler/runtime/extract-locale-from-header.test.js +58 -0
  124. package/dist/compiler/runtime/extract-locale-from-header.test.js.map +1 -1
  125. package/dist/compiler/runtime/get-locale.js +7 -1
  126. package/dist/compiler/runtime/get-locale.js.map +1 -1
  127. package/dist/compiler/runtime/get-locale.test.js +95 -0
  128. package/dist/compiler/runtime/get-locale.test.js.map +1 -1
  129. package/dist/compiler/runtime/localize-href.d.ts +8 -0
  130. package/dist/compiler/runtime/localize-href.js +60 -0
  131. package/dist/compiler/runtime/localize-href.js.map +1 -1
  132. package/dist/compiler/runtime/localize-href.test.js +227 -1
  133. package/dist/compiler/runtime/localize-href.test.js.map +1 -1
  134. package/dist/compiler/runtime/localize-url.d.ts +8 -4
  135. package/dist/compiler/runtime/localize-url.js +12 -8
  136. package/dist/compiler/runtime/localize-url.js.map +1 -1
  137. package/dist/compiler/runtime/localize-url.test.js +45 -0
  138. package/dist/compiler/runtime/localize-url.test.js.map +1 -1
  139. package/dist/compiler/runtime/set-locale.js +24 -6
  140. package/dist/compiler/runtime/set-locale.js.map +1 -1
  141. package/dist/compiler/runtime/set-locale.test.js +182 -0
  142. package/dist/compiler/runtime/set-locale.test.js.map +1 -1
  143. package/dist/compiler/runtime/type.d.ts +2 -0
  144. package/dist/compiler/runtime/type.js.map +1 -1
  145. package/dist/compiler/runtime/type.test.js +75 -0
  146. package/dist/compiler/runtime/type.test.js.map +1 -1
  147. package/dist/compiler/runtime/variables.d.ts +2 -0
  148. package/dist/compiler/runtime/variables.js +7 -0
  149. package/dist/compiler/runtime/variables.js.map +1 -1
  150. package/dist/compiler/server/middleware.d.ts +8 -2
  151. package/dist/compiler/server/middleware.js +175 -7
  152. package/dist/compiler/server/middleware.js.map +1 -1
  153. package/dist/compiler/server/middleware.test.js +750 -3
  154. package/dist/compiler/server/middleware.test.js.map +1 -1
  155. package/dist/eslint/index.d.ts +4 -0
  156. package/dist/eslint/index.js +8 -0
  157. package/dist/eslint/index.js.map +1 -0
  158. package/dist/eslint/no-dynamic-message-access.d.ts +3 -0
  159. package/dist/eslint/no-dynamic-message-access.js +150 -0
  160. package/dist/eslint/no-dynamic-message-access.js.map +1 -0
  161. package/dist/eslint/no-dynamic-message-access.test.d.ts +1 -0
  162. package/dist/eslint/no-dynamic-message-access.test.js +126 -0
  163. package/dist/eslint/no-dynamic-message-access.test.js.map +1 -0
  164. package/dist/eslint/oxlint.test.d.ts +1 -0
  165. package/dist/eslint/oxlint.test.js +64 -0
  166. package/dist/eslint/oxlint.test.js.map +1 -0
  167. package/dist/services/config/config-schema.d.ts +2 -0
  168. package/dist/services/config/config-schema.js +2 -0
  169. package/dist/services/config/config-schema.js.map +1 -1
  170. package/dist/services/config/load-paraglide-config.test.js +12 -0
  171. package/dist/services/config/load-paraglide-config.test.js.map +1 -1
  172. package/dist/services/env-variables/index.js +1 -1
  173. package/dist/services/env-variables/index.js.map +1 -1
  174. package/dist/services/file-handling/write-output.bench.js +51 -11
  175. package/dist/services/file-handling/write-output.bench.js.map +1 -1
  176. package/dist/services/file-handling/write-output.js +60 -20
  177. package/dist/services/file-handling/write-output.js.map +1 -1
  178. package/dist/services/file-handling/write-output.test.js +175 -0
  179. package/dist/services/file-handling/write-output.test.js.map +1 -1
  180. package/package.json +14 -4
@@ -1,6 +1,14 @@
1
1
  import type { Plugin } from "vite";
2
2
  import type { ParaglidePluginOptions } from "./unplugin.js";
3
3
  export type ParaglideVitePluginOptions = ParaglidePluginOptions & {
4
+ /**
5
+ * Respond with HTTP 500 while the development compiler or its config is
6
+ * invalid, instead of serving the last successful output. Error overlays
7
+ * remain enabled. Set this on the Vite plugin, not in paraglide.config.
8
+ *
9
+ * @default false
10
+ */
11
+ devErrorResponse?: boolean;
4
12
  /**
5
13
  * Emit one compiler-specialized client asset tree per project locale.
6
14
  *
@@ -1,15 +1,25 @@
1
1
  import { createVitePlugin } from "unplugin";
2
2
  import { createPerLocaleBuildPlugins } from "./per-locale-build/index.js";
3
3
  import { unpluginFactory } from "./unplugin.js";
4
- const createCompilerVitePlugin = createVitePlugin(unpluginFactory);
4
+ const createCompilerVitePlugin = createVitePlugin(({ devErrorResponse, ...options }, meta) => unpluginFactory(options, meta, { devErrorResponse }));
5
+ const createPerLocaleCompilerVitePlugin = createVitePlugin(({ devErrorResponse, ...options }, meta) => unpluginFactory(options, meta, {
6
+ outputStructure: "locale-modules",
7
+ devErrorResponse,
8
+ }));
5
9
  export function paraglideVitePlugin(options) {
6
- const { experimentalPerLocaleBuild, ...compilerOptions } = options;
10
+ const { experimentalPerLocaleBuild, devErrorResponse, ...compilerOptions } = options;
7
11
  if (!experimentalPerLocaleBuild) {
8
- return createCompilerVitePlugin(compilerOptions);
12
+ return createCompilerVitePlugin({
13
+ ...compilerOptions,
14
+ devErrorResponse,
15
+ });
9
16
  }
10
17
  return createPerLocaleBuildPlugins({
11
18
  compilerOptions,
12
- createCompilerPlugin: (options) => createCompilerVitePlugin(options),
19
+ createCompilerPlugin: (options) => createPerLocaleCompilerVitePlugin({
20
+ ...options,
21
+ devErrorResponse,
22
+ }),
13
23
  });
14
24
  }
15
25
  //# sourceMappingURL=vite.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"vite.js","sourceRoot":"","sources":["../../src/bundler-plugins/vite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAG5C,OAAO,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAiBhD,MAAM,wBAAwB,GAAG,gBAAgB,CAAC,eAAe,CAAC,CAAC;AAEnE,MAAM,UAAU,mBAAmB,CAClC,OAAmC;IAEnC,MAAM,EAAE,0BAA0B,EAAE,GAAG,eAAe,EAAE,GAAG,OAAO,CAAC;IACnE,IAAI,CAAC,0BAA0B,EAAE,CAAC;QACjC,OAAO,wBAAwB,CAAC,eAAe,CAAW,CAAC;IAC5D,CAAC;IAED,OAAO,2BAA2B,CAAC;QAClC,eAAe;QACf,oBAAoB,EAAE,CAAC,OAAO,EAAE,EAAE,CACjC,wBAAwB,CAAC,OAAO,CAAW;KAC5C,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { createVitePlugin } from \"unplugin\";\nimport type { Plugin } from \"vite\";\nimport type { ParaglidePluginOptions } from \"./unplugin.js\";\nimport { createPerLocaleBuildPlugins } from \"./per-locale-build/index.js\";\nimport { unpluginFactory } from \"./unplugin.js\";\n\nexport type ParaglideVitePluginOptions = ParaglidePluginOptions & {\n\t/**\n\t * Emit one compiler-specialized client asset tree per project locale.\n\t *\n\t * Requires Vite 8+. Builds one untouched Rolldown client environment per\n\t * locale and emits `paraglide-vite-locales.json`. Locale changes need to use\n\t * full-document navigation. Framework SSR graph selection requires a public\n\t * framework integration API.\n\t *\n\t * @experimental\n\t * @default false\n\t */\n\texperimentalPerLocaleBuild?: boolean;\n};\n\nconst createCompilerVitePlugin = createVitePlugin(unpluginFactory);\n\nexport function paraglideVitePlugin(\n\toptions: ParaglideVitePluginOptions\n): Plugin | Plugin[] {\n\tconst { experimentalPerLocaleBuild, ...compilerOptions } = options;\n\tif (!experimentalPerLocaleBuild) {\n\t\treturn createCompilerVitePlugin(compilerOptions) as Plugin;\n\t}\n\n\treturn createPerLocaleBuildPlugins({\n\t\tcompilerOptions,\n\t\tcreateCompilerPlugin: (options) =>\n\t\t\tcreateCompilerVitePlugin(options) as Plugin,\n\t});\n}\n"]}
1
+ {"version":3,"file":"vite.js","sourceRoot":"","sources":["../../src/bundler-plugins/vite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAG5C,OAAO,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AA8BhD,MAAM,wBAAwB,GAAG,gBAAgB,CAChD,CAAC,EAAE,gBAAgB,EAAE,GAAG,OAAO,EAAE,EAAE,IAAI,EAAE,EAAE,CAC1C,eAAe,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,gBAAgB,EAAE,CAAC,CACrD,CAAC;AACF,MAAM,iCAAiC,GACtC,gBAAgB,CACf,CAAC,EAAE,gBAAgB,EAAE,GAAG,OAAO,EAAE,EAAE,IAAI,EAAE,EAAE,CAC1C,eAAe,CAAC,OAAO,EAAE,IAAI,EAAE;IAC9B,eAAe,EAAE,gBAAgB;IACjC,gBAAgB;CAChB,CAAC,CACH,CAAC;AAEH,MAAM,UAAU,mBAAmB,CAClC,OAAmC;IAEnC,MAAM,EAAE,0BAA0B,EAAE,gBAAgB,EAAE,GAAG,eAAe,EAAE,GACzE,OAAO,CAAC;IACT,IAAI,CAAC,0BAA0B,EAAE,CAAC;QACjC,OAAO,wBAAwB,CAAC;YAC/B,GAAG,eAAe;YAClB,gBAAgB;SAChB,CAAW,CAAC;IACd,CAAC;IAED,OAAO,2BAA2B,CAAC;QAClC,eAAe;QACf,oBAAoB,EAAE,CAAC,OAAO,EAAE,EAAE,CACjC,iCAAiC,CAAC;YACjC,GAAG,OAAO;YACV,gBAAgB;SAChB,CAAW;KACb,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { createVitePlugin } from \"unplugin\";\nimport type { Plugin } from \"vite\";\nimport type { ParaglidePluginOptions } from \"./unplugin.js\";\nimport { createPerLocaleBuildPlugins } from \"./per-locale-build/index.js\";\nimport { unpluginFactory } from \"./unplugin.js\";\n\nexport type ParaglideVitePluginOptions = ParaglidePluginOptions & {\n\t/**\n\t * Respond with HTTP 500 while the development compiler or its config is\n\t * invalid, instead of serving the last successful output. Error overlays\n\t * remain enabled. Set this on the Vite plugin, not in paraglide.config.\n\t *\n\t * @default false\n\t */\n\tdevErrorResponse?: boolean;\n\t/**\n\t * Emit one compiler-specialized client asset tree per project locale.\n\t *\n\t * Requires Vite 8+. Builds one untouched Rolldown client environment per\n\t * locale and emits `paraglide-vite-locales.json`. Locale changes need to use\n\t * full-document navigation. Framework SSR graph selection requires a public\n\t * framework integration API.\n\t *\n\t * @experimental\n\t * @default false\n\t */\n\texperimentalPerLocaleBuild?: boolean;\n};\n\ntype CompilerVitePluginOptions = Omit<\n\tParaglideVitePluginOptions,\n\t\"experimentalPerLocaleBuild\"\n>;\n\nconst createCompilerVitePlugin = createVitePlugin<CompilerVitePluginOptions>(\n\t({ devErrorResponse, ...options }, meta) =>\n\t\tunpluginFactory(options, meta, { devErrorResponse })\n);\nconst createPerLocaleCompilerVitePlugin =\n\tcreateVitePlugin<CompilerVitePluginOptions>(\n\t\t({ devErrorResponse, ...options }, meta) =>\n\t\t\tunpluginFactory(options, meta, {\n\t\t\t\toutputStructure: \"locale-modules\",\n\t\t\t\tdevErrorResponse,\n\t\t\t})\n\t);\n\nexport function paraglideVitePlugin(\n\toptions: ParaglideVitePluginOptions\n): Plugin | Plugin[] {\n\tconst { experimentalPerLocaleBuild, devErrorResponse, ...compilerOptions } =\n\t\toptions;\n\tif (!experimentalPerLocaleBuild) {\n\t\treturn createCompilerVitePlugin({\n\t\t\t...compilerOptions,\n\t\t\tdevErrorResponse,\n\t\t}) as Plugin;\n\t}\n\n\treturn createPerLocaleBuildPlugins({\n\t\tcompilerOptions,\n\t\tcreateCompilerPlugin: (options) =>\n\t\t\tcreatePerLocaleCompilerVitePlugin({\n\t\t\t\t...options,\n\t\t\t\tdevErrorResponse,\n\t\t\t}) as Plugin,\n\t});\n}\n"]}
@@ -58,7 +58,7 @@ test("experimentalPerLocaleBuild rejects conflicting compiler options", () => {
58
58
  ...common,
59
59
  experimentalPerLocaleBuild: true,
60
60
  outputStructure: "message-modules",
61
- })).toThrow('requires outputStructure: "locale-modules"');
61
+ })).not.toThrow();
62
62
  expect(() => paraglideVitePlugin({
63
63
  ...common,
64
64
  experimentalPerLocaleBuild: true,
@@ -1 +1 @@
1
- {"version":3,"file":"vite.test.js","sourceRoot":"","sources":["../../src/bundler-plugins/vite.test.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,mBAAmB,EACnB,UAAU,EACV,sBAAsB,GACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,oCAAoC,EAAE,MAAM,iCAAiC,CAAC;AACvF,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAEhD,IAAI,CAAC,2GAA2G,EAAE,KAAK,IAAI,EAAE;IAC5H,MAAM,OAAO,GAAG,MAAM,mBAAmB,CAAC;QACzC,IAAI,EAAE,MAAM,UAAU,CAAC;YACtB,QAAQ,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAA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GAAG,MAAM;QACT,0BAA0B,EAAE,IAAI;QAChC,eAAe,EAAE;YAChB;gBACC,KAAK,EAAE,iBAAiB;gBACxB,OAAO,EAAE,IAAI;aACb;SACD;KACD,CAAC,CACF,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;AACjB,CAAC,CAAC,CAAC","sourcesContent":["import {\n\tloadProjectInMemory,\n\tnewProject,\n\tsaveProjectToDirectory,\n} from \"@inlang/sdk\";\nimport { memfs } from \"memfs\";\nimport { expect, test } from \"vitest\";\nimport { perLocaleBuildStaticLocaleExpression } from \"../compiler/per-locale-build.js\";\nimport { paraglideVitePlugin } from \"./vite.js\";\n\ntest(\"experimentalPerLocaleBuild generates locale source modules and installs the Vite environment orchestrator\", async () => {\n\tconst project = await loadProjectInMemory({\n\t\tblob: await newProject({\n\t\t\tsettings: { baseLocale: \"en\", locales: [\"en\", \"de\"] },\n\t\t}),\n\t});\n\tconst fs = memfs().fs as unknown as typeof import(\"node:fs\");\n\tawait saveProjectToDirectory({\n\t\tproject,\n\t\tpath: \"/project.inlang\",\n\t\tfs: fs.promises,\n\t});\n\n\tconst plugins = paraglideVitePlugin({\n\t\tproject: \"/project.inlang\",\n\t\toutdir: \"/src/paraglide\",\n\t\tfs,\n\t\texperimentalPerLocaleBuild: true,\n\t\tstrategy: [\"preferredLanguage\", \"baseLocale\"],\n\t\tadditionalFiles: { \"custom.js\": \"export const custom = true;\\n\" },\n\t});\n\tif (!Array.isArray(plugins)) {\n\t\tthrow new Error(\"Expected multiple Vite plugins\");\n\t}\n\texpect(plugins.map((plugin) => plugin.name)).toEqual([\n\t\t\"paraglide-config-discovery-root\",\n\t\t\"unplugin-paraglide-js\",\n\t\t\"paraglide-vite-locale-environments\",\n\t]);\n\n\tconst compiler = plugins[1]!;\n\tif (typeof compiler.buildStart !== \"function\") {\n\t\tthrow new Error(\"Expected the compiler buildStart hook\");\n\t}\n\tawait compiler.buildStart.call({ addWatchFile() {} } as never, {} as never);\n\n\texpect(\n\t\tawait fs.promises.readFile(\"/src/paraglide/messages/en.js\", \"utf8\")\n\t).toBeDefined();\n\texpect(\n\t\tawait fs.promises.readFile(\"/src/paraglide/messages/de.js\", \"utf8\")\n\t).toBeDefined();\n\texpect(\n\t\tawait fs.promises.readFile(\"/src/paraglide/runtime.js\", \"utf8\")\n\t).toContain(perLocaleBuildStaticLocaleExpression);\n\texpect(\n\t\tawait fs.promises.readFile(\"/src/paraglide/custom.js\", \"utf8\")\n\t).toContain(\"export const custom = true;\");\n\tawait expect(\n\t\tfs.promises.readFile(\"/src/paraglide/tanstack-start.server.js\", \"utf8\")\n\t).rejects.toThrow();\n});\n\ntest(\"experimentalPerLocaleBuild rejects conflicting compiler options\", () => {\n\tconst common = { project: \"/project.inlang\", outdir: \"/src/paraglide\" };\n\texpect(() =>\n\t\tparaglideVitePlugin({\n\t\t\t...common,\n\t\t\texperimentalPerLocaleBuild: true,\n\t\t\texperimentalStaticLocale: '\"de\"',\n\t\t})\n\t).toThrow(\"cannot be combined with experimentalStaticLocale\");\n\texpect(() =>\n\t\tparaglideVitePlugin({\n\t\t\t...common,\n\t\t\texperimentalPerLocaleBuild: true,\n\t\t\texperimentalMiddlewareLocaleSplitting: true,\n\t\t})\n\t).toThrow(\"cannot be combined with experimentalMiddlewareLocaleSplitting\");\n\texpect(() =>\n\t\tparaglideVitePlugin({\n\t\t\t...common,\n\t\t\texperimentalPerLocaleBuild: true,\n\t\t\toutputStructure: \"message-modules\",\n\t\t})\n\t).toThrow('requires outputStructure: \"locale-modules\"');\n\texpect(() =>\n\t\tparaglideVitePlugin({\n\t\t\t...common,\n\t\t\texperimentalPerLocaleBuild: true,\n\t\t\trouteStrategies: [\n\t\t\t\t{\n\t\t\t\t\tmatch: \"/api/:path(.*)?\",\n\t\t\t\t\texclude: true,\n\t\t\t\t},\n\t\t\t],\n\t\t})\n\t).not.toThrow();\n});\n"]}
1
+ {"version":3,"file":"vite.test.js","sourceRoot":"","sources":["../../src/bundler-plugins/vite.test.ts"],"names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I;QAChC,wBAAwB,EAAE,MAAM;KAChC,CAAC,CACF,CAAC,OAAO,CAAC,kDAAkD,CAAC,CAAC;IAC9D,MAAM,CAAC,GAAG,EAAE,CACX,mBAAmB,CAAC;QACnB,GAAG,MAAM;QACT,0BAA0B,EAAE,IAAI;QAChC,qCAAqC,EAAE,IAAI;KAC3C,CAAC,CACF,CAAC,OAAO,CAAC,+DAA+D,CAAC,CAAC;IAC3E,MAAM,CAAC,GAAG,EAAE,CACX,mBAAmB,CAAC;QACnB,GAAG,MAAM;QACT,0BAA0B,EAAE,IAAI;QAChC,eAAe,EAAE,iBAAiB;KAClC,CAAC,CACF,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;IAChB,MAAM,CAAC,GAAG,EAAE,CACX,mBAAmB,CAAC;QACnB,GAAG,MAAM;QACT,0BAA0B,EAAE,IAAI;QAChC,eAAe,EAAE;YAChB;gBACC,KAAK,EAAE,iBAAiB;gBACxB,OAAO,EAAE,IAAI;aACb;SACD;KACD,CAAC,CACF,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;AACjB,CAAC,CAAC,CAAC","sourcesContent":["import {\n\tloadProjectInMemory,\n\tnewProject,\n\tsaveProjectToDirectory,\n} from \"@inlang/sdk\";\nimport { memfs } from \"memfs\";\nimport { expect, test } from \"vitest\";\nimport { perLocaleBuildStaticLocaleExpression } from \"../compiler/per-locale-build.js\";\nimport { paraglideVitePlugin } from \"./vite.js\";\n\ntest(\"experimentalPerLocaleBuild generates locale source modules and installs the Vite environment orchestrator\", async () => {\n\tconst project = await loadProjectInMemory({\n\t\tblob: await newProject({\n\t\t\tsettings: { baseLocale: \"en\", locales: [\"en\", \"de\"] },\n\t\t}),\n\t});\n\tconst fs = memfs().fs as unknown as typeof import(\"node:fs\");\n\tawait saveProjectToDirectory({\n\t\tproject,\n\t\tpath: \"/project.inlang\",\n\t\tfs: fs.promises,\n\t});\n\n\tconst plugins = paraglideVitePlugin({\n\t\tproject: \"/project.inlang\",\n\t\toutdir: \"/src/paraglide\",\n\t\tfs,\n\t\texperimentalPerLocaleBuild: true,\n\t\tstrategy: [\"preferredLanguage\", \"baseLocale\"],\n\t\tadditionalFiles: { \"custom.js\": \"export const custom = true;\\n\" },\n\t});\n\tif (!Array.isArray(plugins)) {\n\t\tthrow new Error(\"Expected multiple Vite plugins\");\n\t}\n\texpect(plugins.map((plugin) => plugin.name)).toEqual([\n\t\t\"paraglide-config-discovery-root\",\n\t\t\"unplugin-paraglide-js\",\n\t\t\"paraglide-vite-locale-environments\",\n\t]);\n\n\tconst compiler = plugins[1]!;\n\tif (typeof compiler.buildStart !== \"function\") {\n\t\tthrow new Error(\"Expected the compiler buildStart hook\");\n\t}\n\tawait compiler.buildStart.call({ addWatchFile() {} } as never, {} as never);\n\n\texpect(\n\t\tawait fs.promises.readFile(\"/src/paraglide/messages/en.js\", \"utf8\")\n\t).toBeDefined();\n\texpect(\n\t\tawait fs.promises.readFile(\"/src/paraglide/messages/de.js\", \"utf8\")\n\t).toBeDefined();\n\texpect(\n\t\tawait fs.promises.readFile(\"/src/paraglide/runtime.js\", \"utf8\")\n\t).toContain(perLocaleBuildStaticLocaleExpression);\n\texpect(\n\t\tawait fs.promises.readFile(\"/src/paraglide/custom.js\", \"utf8\")\n\t).toContain(\"export const custom = true;\");\n\tawait expect(\n\t\tfs.promises.readFile(\"/src/paraglide/tanstack-start.server.js\", \"utf8\")\n\t).rejects.toThrow();\n});\n\ntest(\"experimentalPerLocaleBuild rejects conflicting compiler options\", () => {\n\tconst common = { project: \"/project.inlang\", outdir: \"/src/paraglide\" };\n\texpect(() =>\n\t\tparaglideVitePlugin({\n\t\t\t...common,\n\t\t\texperimentalPerLocaleBuild: true,\n\t\t\texperimentalStaticLocale: '\"de\"',\n\t\t})\n\t).toThrow(\"cannot be combined with experimentalStaticLocale\");\n\texpect(() =>\n\t\tparaglideVitePlugin({\n\t\t\t...common,\n\t\t\texperimentalPerLocaleBuild: true,\n\t\t\texperimentalMiddlewareLocaleSplitting: true,\n\t\t})\n\t).toThrow(\"cannot be combined with experimentalMiddlewareLocaleSplitting\");\n\texpect(() =>\n\t\tparaglideVitePlugin({\n\t\t\t...common,\n\t\t\texperimentalPerLocaleBuild: true,\n\t\t\toutputStructure: \"message-modules\",\n\t\t})\n\t).not.toThrow();\n\texpect(() =>\n\t\tparaglideVitePlugin({\n\t\t\t...common,\n\t\t\texperimentalPerLocaleBuild: true,\n\t\t\trouteStrategies: [\n\t\t\t\t{\n\t\t\t\t\tmatch: \"/api/:path(.*)?\",\n\t\t\t\t\texclude: true,\n\t\t\t\t},\n\t\t\t],\n\t\t})\n\t).not.toThrow();\n});\n"]}
@@ -142,6 +142,7 @@ export const compileCommand = new Command()
142
142
  let compileTimer;
143
143
  let compileInProgress = false;
144
144
  let compileRequested = false;
145
+ let watching = true;
145
146
  // Set by the project-directory watcher when a config-named file
146
147
  // changes — survives debounced coalescing with unrelated events.
147
148
  let configChangedSinceLastBuild = false;
@@ -177,6 +178,8 @@ export const compileCommand = new Command()
177
178
  }
178
179
  };
179
180
  const updateWatchers = (files) => {
181
+ if (!watching)
182
+ return;
180
183
  const { files: nextFiles, directories: nextDirectories, isIgnoredPath, } = getWatchTargets(files, { outdir: compileOptions.outdir });
181
184
  for (const [filePath, watcher] of fileWatchers) {
182
185
  if (!nextFiles.has(filePath)) {
@@ -251,6 +254,8 @@ export const compileCommand = new Command()
251
254
  }
252
255
  };
253
256
  const runCompile = async (changedPath) => {
257
+ if (!watching)
258
+ return;
254
259
  if (compileInProgress) {
255
260
  compileRequested = true;
256
261
  return;
@@ -320,6 +325,8 @@ export const compileCommand = new Command()
320
325
  }
321
326
  };
322
327
  const scheduleCompile = (changedPath) => {
328
+ if (!watching)
329
+ return;
323
330
  if (compileTimer) {
324
331
  clearTimeout(compileTimer);
325
332
  }
@@ -328,6 +335,12 @@ export const compileCommand = new Command()
328
335
  }, 100);
329
336
  };
330
337
  const closeWatchers = () => {
338
+ watching = false;
339
+ compileRequested = false;
340
+ if (compileTimer) {
341
+ clearTimeout(compileTimer);
342
+ compileTimer = undefined;
343
+ }
331
344
  for (const watcher of fileWatchers.values()) {
332
345
  watcher.close();
333
346
  }
@@ -1 +1 @@
1
- {"version":3,"file":"command.js","sourceRoot":"","sources":["../../../../src/cli/commands/compile/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAC3D,OAAO,EACN,cAAc,EACd,oBAAoB,GACpB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,OAAO,EAA0B,MAAM,8BAA8B,CAAC;AAC/E,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,iCAAiC,EAAE,MAAM,gDAAgD,CAAC;AACnG,OAAO,EACN,eAAe,EACf,eAAe,GACf,MAAM,+CAA+C,CAAC;AACvD,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAC7B,OAAO,EACN,yBAAyB,EACzB,gBAAgB,EAChB,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB,EACtB,kBAAkB,GAGlB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAK9E,MAAM,YAAY,GAAG,CAAC,KAAc,EAAU,EAAE,CAC/C,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAExD,MAAM,oBAAoB,GAAG,CAAC,KAAa,EAAmB,EAAE;IAC/D,IAAI,KAAK,KAAK,iBAAiB,IAAI,KAAK,KAAK,gBAAgB,EAAE,CAAC;QAC/D,OAAO,KAAK,CAAC;IACd,CAAC;I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AEF,MAAM,aAAa,GAAG,GAAG,EAAE;QAC1B,KAAK,MAAM,OAAO,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC;YAC7C,OAAO,CAAC,KAAK,EAAE,CAAC;QACjB,CAAC;QACD,KAAK,MAAM,OAAO,IAAI,iBAAiB,CAAC,MAAM,EAAE,EAAE,CAAC;YAClD,OAAO,CAAC,KAAK,EAAE,CAAC;QACjB,CAAC;QACD,YAAY,CAAC,KAAK,EAAE,CAAC;QACrB,iBAAiB,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC,CAAC;IAEF,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;QACzB,aAAa,EAAE,CAAC;QAChB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACjB,CAAC,CAAC,CAAC;IAEH,MAAM,UAAU,EAAE,CAAC;IACnB,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;AACxC,CAAC,CACD,CAAC","sourcesContent":["import { Command, InvalidArgumentError } from \"commander\";\nimport fs from \"node:fs\";\nimport { resolve, relative } from \"node:path\";\nimport { Logger } from \"../../../services/logger/index.js\";\nimport {\n\tDEFAULT_OUTDIR,\n\tDEFAULT_PROJECT_PATH,\n} from \"../../../services/config/defaults.js\";\nimport { compile, type CompilationResult } from \"../../../compiler/compile.js\";\nimport { defaultCompilerOptions } from \"../../../compiler/compiler-options.js\";\nimport { seedPreviousCompilationFromOutdir } from \"../../../compiler/seed-previous-compilation.js\";\nimport {\n\tcreateTrackedFs,\n\tgetWatchTargets,\n} from \"../../../services/file-watching/tracked-fs.js\";\nimport * as v from \"valibot\";\nimport {\n\tclearParaglideConfigCache,\n\tisConfigFileName,\n\tloadParaglideConfig,\n\tresolveCompilerOptions,\n\tresolveConfigCandidate,\n\tstrategyNameSchema,\n\ttype LoadedParaglideConfig,\n\ttype ParaglideConfig,\n} from \"../../../services/config/index.js\";\nimport { nodeNormalizePath } from \"../../../utilities/node-normalize-path.js\";\nimport type { CompilerOptions } from \"../../../compiler/compiler-options.js\";\n\ntype OutputStructure = NonNullable<CompilerOptions[\"outputStructure\"]>;\n\nconst errorMessage = (error: unknown): string =>\n\terror instanceof Error ? error.message : String(error);\n\nconst parseOutputStructure = (value: string): OutputStructure => {\n\tif (value === \"message-modules\" || value === \"locale-modules\") {\n\t\treturn value;\n\t}\n\tthrow new InvalidArgumentError(\n\t\t`Invalid output structure \"${value}\". Expected \"message-modules\" or \"locale-modules\".`\n\t);\n};\n\nexport const compileCommand = new Command()\n\t.name(\"compile\")\n\t.summary(\"Compiles inlang Paraglide-JS\")\n\t.option(\n\t\t\"--project <path>\",\n\t\t`The path to the inlang project. Example: \"./project.inlang\". Defaults to \"${DEFAULT_PROJECT_PATH}\".`\n\t)\n\t.option(\n\t\t\"--outdir <path>\",\n\t\t`The path to the output directory. Example: \"./src/paraglide\". Defaults to \"${DEFAULT_OUTDIR}\".`\n\t)\n\t.option(\n\t\t\"--strategy <items...>\",\n\t\t[\n\t\t\t\"The strategy to be used.\",\n\t\t\t\"\",\n\t\t\t\"Example: --strategy cookie globalVariable baseLocale\",\n\t\t\t\"Read more on https://paraglidejs.com/strategy\",\n\t\t].join(\"\\n\")\n\t)\n\t.requiredOption(\"--silent\", \"Only log errors to the console\", false)\n\t.option(\n\t\t\"--emit-ts-declarations\",\n\t\t`Emit .d.ts files for the generated output (requires the typescript package) (default: ${defaultCompilerOptions.emitTsDeclarations})`\n\t)\n\t.option(\n\t\t\"--no-emit-ts-declarations\",\n\t\t\"Do not emit .d.ts files for the generated output\"\n\t)\n\t.option(\n\t\t\"--emit-git-ignore\",\n\t\t`Emit a .gitignore in the output directory (default: ${defaultCompilerOptions.emitGitIgnore})`\n\t)\n\t.option(\n\t\t\"--no-emit-git-ignore\",\n\t\t\"Do not emit a .gitignore in the output directory\"\n\t)\n\t.option(\n\t\t\"--emit-prettier-ignore\",\n\t\t`Emit a .prettierignore in the output directory (default: ${defaultCompilerOptions.emitPrettierIgnore})`\n\t)\n\t.option(\n\t\t\"--no-emit-prettier-ignore\",\n\t\t\"Do not emit a .prettierignore in the output directory\"\n\t)\n\t.option(\n\t\t\"--emit-readme\",\n\t\t`Emit a README.md in the output directory (helps LLMs understand the generated code) (default: ${defaultCompilerOptions.emitReadme})`\n\t)\n\t.option(\"--no-emit-readme\", \"Do not emit README.md in the output directory\")\n\t.option(\n\t\t\"--is-server <expression>\",\n\t\t[\n\t\t\t\"JavaScript expression for runtime `isServer` (enables server/client tree-shaking).\",\n\t\t\t\"Quote if the expression contains spaces, e.g. --is-server 'typeof window === \\\"undefined\\\"'.\",\n\t\t\t\"Vite SSR example: --is-server 'import.meta.env.SSR'\",\n\t\t].join(\" \")\n\t)\n\t.option(\n\t\t\"--clean-outdir\",\n\t\t\"Remove files in the output directory that are not generated by this compile\",\n\t\tdefaultCompilerOptions.cleanOutdir\n\t)\n\t.option(\n\t\t\"--no-clean-outdir\",\n\t\t\"Preserve files in the output directory that are not generated by this compile\"\n\t)\n\t.option(\n\t\t\"--experimental-static-locale <expression>\",\n\t\t[\n\t\t\t\"JavaScript expression for a compile-time locale constant (experimental).\",\n\t\t\t\"For a literal locale, include the JavaScript quotes, e.g. --experimental-static-locale '\\\"de\\\"'.\",\n\t\t].join(\" \")\n\t)\n\t.option(\n\t\t\"--disable-async-local-storage\",\n\t\t\"Use the synchronous request-locale fallback instead of AsyncLocalStorage\",\n\t\tdefaultCompilerOptions.disableAsyncLocalStorage\n\t)\n\t.option(\n\t\t\"--output-structure <structure>\",\n\t\t[\n\t\t\t`The output structure for compiled messages. Either \"message-modules\" or \"locale-modules\" (default: \"${defaultCompilerOptions.outputStructure}\").`,\n\t\t\t\"\",\n\t\t\t'\"message-modules\" gives each message its own module (better tree-shaking).',\n\t\t\t'\"locale-modules\" bundles messages per locale (fewer files, better for large projects in dev).',\n\t\t].join(\"\\n\"),\n\t\tparseOutputStructure\n\t)\n\t.option(\"--watch\", \"Watch project files and recompile on change\", false)\n\t.action(\n\t\tasync (options: {\n\t\t\tsilent: boolean;\n\t\t\tproject?: string;\n\t\t\toutdir?: string;\n\t\t\tstrategy?: string[];\n\t\t\temitTsDeclarations?: boolean;\n\t\t\temitGitIgnore?: boolean;\n\t\t\temitPrettierIgnore?: boolean;\n\t\t\temitReadme?: boolean;\n\t\t\tisServer?: string;\n\t\t\tcleanOutdir?: CompilerOptions[\"cleanOutdir\"];\n\t\t\texperimentalStaticLocale?: CompilerOptions[\"experimentalStaticLocale\"];\n\t\t\tdisableAsyncLocalStorage?: CompilerOptions[\"disableAsyncLocalStorage\"];\n\t\t\toutputStructure?: OutputStructure;\n\t\t\twatch?: boolean;\n\t\t}) => {\n\t\t\tconst logger = new Logger({ silent: options.silent, prefix: true });\n\n\t\t\tconst projectDir = nodeNormalizePath(\n\t\t\t\tresolve(process.cwd(), options.project ?? DEFAULT_PROJECT_PATH)\n\t\t\t);\n\n\t\t\tconst loadConfig = () => loadParaglideConfig({ projectDir, logger });\n\n\t\t\tlet projectOverride = options.project;\n\t\t\tif (projectOverride === undefined) {\n\t\t\t\tprojectOverride = DEFAULT_PROJECT_PATH;\n\t\t\t\tlogger.info(\n\t\t\t\t\t`--project was not provided, using \"${DEFAULT_PROJECT_PATH}\".`\n\t\t\t\t);\n\t\t\t}\n\n\n\t\t\tconst buildCompileOptions = () => {\n\t\t\t\tlet validatedStrategy: ParaglideConfig[\"strategy\"] | undefined;\n\t\t\t\tif (options.strategy !== undefined) {\n\t\t\t\t\tconst parsed = v.safeParse(\n\t\t\t\t\t\tv.array(strategyNameSchema),\n\t\t\t\t\t\toptions.strategy\n\t\t\t\t\t);\n\t\t\t\t\tif (!parsed.success) {\n\t\t\t\t\t\tconst details = parsed.issues\n\t\t\t\t\t\t\t.map((i) => `\"${v.getDotPath(i) ?? \"(root)\"}\": ${i.message}`)\n\t\t\t\t\t\t\t.join(\", \");\n\t\t\t\t\t\tthrow new Error(`Invalid --strategy: ${details}`);\n\t\t\t\t\t}\n\t\t\t\t\tvalidatedStrategy = parsed.output;\n\t\t\t\t}\n\t\t\t\tlet outdirOverride: string | undefined = options.outdir;\n\t\t\t\tif (\n\t\t\t\t\toutdirOverride === undefined &&\n\t\t\t\t\tloadedConfig?.config.outdir === undefined\n\t\t\t\t) {\n\t\t\t\t\toutdirOverride = DEFAULT_OUTDIR;\n\t\t\t\t}\n\t\t\t\treturn resolveCompilerOptions({\n\t\t\t\t\tconfig: loadedConfig?.config,\n\t\t\t\t\toverrides: {\n\t\t\t\t\t\tproject: projectOverride,\n\t\t\t\t\t\toutdir: outdirOverride,\n\t\t\t\t\t\tstrategy: validatedStrategy,\n\t\t\t\t\t\temitTsDeclarations: options.emitTsDeclarations,\n\t\t\t\t\t\temitGitIgnore: options.emitGitIgnore,\n\t\t\t\t\t\temitPrettierIgnore: options.emitPrettierIgnore,\n\t\t\t\t\t\temitReadme: options.emitReadme,\n\t\t\t\t\t\tisServer: options.isServer,\n\t\t\t\t\t\tcleanOutdir: options.cleanOutdir,\n\t\t\t\t\t\texperimentalStaticLocale: options.experimentalStaticLocale,\n\t\t\t\t\t\tdisableAsyncLocalStorage: options.disableAsyncLocalStorage,\n\t\t\t\t\t\t// The CLI always uses message-modules unless told otherwise\n\t\t\t\t\t\t// (plugins apply their own development default).\n\t\t\t\t\t\toutputStructure:\n\t\t\t\t\t\t\toptions.outputStructure ?? defaultCompilerOptions.outputStructure,\n\t\t\t\t\t},\n\t\t\t\t\troot: process.cwd(),\n\t\t\t\t});\n\t\t\t};\n\n\t\t\tlet loadedConfig: LoadedParaglideConfig | undefined;\n\t\t\tlet compileOptions: CompilerOptions;\n\n\t\t\ttry {\n\t\t\t\tloadedConfig = await loadConfig();\n\t\t\t\tcompileOptions = buildCompileOptions();\n\t\t\t} catch (error) {\n\t\t\t\tlogger.error(errorMessage(error));\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\n\t\t\tif (!options.watch) {\n\t\t\t\tlogger.info(`Compiling inlang project ...`);\n\n\t\t\t\ttry {\n\t\t\t\t\tconst previousCompilation = compileOptions.cleanOutdir\n\t\t\t\t\t\t? await seedPreviousCompilationFromOutdir({\n\t\t\t\t\t\t\t\toutdir: compileOptions.outdir,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t: undefined;\n\n\t\t\t\t\tawait compile({\n\t\t\t\t\t\t...compileOptions,\n\t\t\t\t\t\tpreviousCompilation,\n\t\t\t\t\t\tcleanOutdir: false,\n\t\t\t\t\t});\n\t\t\t\t} catch (e) {\n\t\t\t\t\tlogger.error(\"Error while compiling inlang project.\");\n\t\t\t\t\tlogger.error(e);\n\t\t\t\t\tprocess.exit(1);\n\t\t\t\t}\n\n\t\t\t\tlogger.success(`Successfully compiled inlang project.`);\n\n\t\t\t\tprocess.exit(0);\n\t\t\t}\n\n\t\t\tconst { fs: trackedFs, readFiles, clearReadFiles } = createTrackedFs();\n\t\t\tconst fileWatchers = new Map<string, fs.FSWatcher>();\n\t\t\tconst directoryWatchers = new Map<string, fs.FSWatcher>();\n\t\t\tlet previousCompilation: CompilationResult | undefined;\n\t\t\tlet compileTimer: NodeJS.Timeout | undefined;\n\t\t\tlet compileInProgress = false;\n\t\t\tlet compileRequested = false;\n\t\t\t// Set by the project-directory watcher when a config-named file\n\t\t\t// changes — survives debounced coalescing with unrelated events.\n\t\t\tlet configChangedSinceLastBuild = false;\n\n\t\t\t/**\n\t\t\t * Reacts to a config-named event in the project directory:\n\t\t\t * rescans the candidate winner and reloads. A missing config\n\t\t\t * falls back to the built-in defaults; an invalid one fails the\n\t\t\t * reload (caller skips the compilation).\n\t\t\t */\n\t\t\tconst refreshConfig = async (): Promise<boolean> => {\n\t\t\t\tconst winner = await resolveConfigCandidate(projectDir);\n\t\t\t\tif (winner === undefined) {\n\t\t\t\t\tif (loadedConfig !== undefined) {\n\t\t\t\t\t\tlogger.warn(\n\t\t\t\t\t\t\t\"Paraglide config file was removed, compiling with default options.\"\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tloadedConfig = undefined;\n\t\t\t\t\tcompileOptions = buildCompileOptions();\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tclearParaglideConfigCache({ projectDir });\n\t\t\t\t\tconst nextLoadedConfig = await loadConfig();\n\t\t\t\t\tif (nextLoadedConfig === undefined) return true; // raced deletion\n\t\t\t\t\tloadedConfig = nextLoadedConfig;\n\t\t\t\t\tcompileOptions = buildCompileOptions();\n\t\t\t\t\treturn true;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tlogger.error(errorMessage(error));\n\t\t\t\t\tlogger.error(\n\t\t\t\t\t\t\"Skipping compilation because of the invalid paraglide config.\"\n\t\t\t\t\t);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst updateWatchers = (files: Set<string>) => {\n\t\t\t\tconst {\n\t\t\t\t\tfiles: nextFiles,\n\t\t\t\t\tdirectories: nextDirectories,\n\t\t\t\t\tisIgnoredPath,\n\t\t\t\t} = getWatchTargets(files, { outdir: compileOptions.outdir });\n\n\t\t\t\tfor (const [filePath, watcher] of fileWatchers) {\n\t\t\t\t\tif (!nextFiles.has(filePath)) {\n\t\t\t\t\t\twatcher.close();\n\t\t\t\t\t\tfileWatchers.delete(filePath);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// The project directory is always watched: it hosts the config\n\t\t\t\t// file, and its other contents (settings.json, messages/) are\n\t\t\t\t// compile inputs anyway.\n\t\t\t\tnextDirectories.add(projectDir);\n\n\t\t\t\tfor (const [directoryPath, watcher] of directoryWatchers) {\n\t\t\t\t\tif (!nextDirectories.has(directoryPath)) {\n\t\t\t\t\t\twatcher.close();\n\t\t\t\t\t\tdirectoryWatchers.delete(directoryPath);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst attachWatcherErrorHandler = (\n\t\t\t\t\twatcher: fs.FSWatcher,\n\t\t\t\t\ttargetPath: string,\n\t\t\t\t\ttargetType: \"file\" | \"directory\"\n\t\t\t\t) => {\n\t\t\t\t\twatcher.on(\"error\", (error) => {\n\t\t\t\t\t\tlogger.warn(\n\t\t\t\t\t\t\t`Watch ${targetType} error for ${targetPath}: ${errorMessage(error)}`\n\t\t\t\t\t\t);\n\t\t\t\t\t});\n\t\t\t\t};\n\n\t\t\t\tfor (const filePath of nextFiles) {\n\t\t\t\t\tif (fileWatchers.has(filePath)) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst watcher = fs.watch(filePath, () => {\n\t\t\t\t\t\t\tscheduleCompile(filePath);\n\t\t\t\t\t\t});\n\t\t\t\t\t\tattachWatcherErrorHandler(watcher, filePath, \"file\");\n\t\t\t\t\t\tfileWatchers.set(filePath, watcher);\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tlogger.warn(`Failed to watch file: ${filePath}`);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tfor (const directoryPath of nextDirectories) {\n\t\t\t\t\tif (directoryWatchers.has(directoryPath)) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst watcher = fs.watch(directoryPath, (eventType, filename) => {\n\t\t\t\t\t\t\tconst isProjectDir = directoryPath === projectDir;\n\n\t\t\t\t\t\t\tif (!filename) {\n\t\t\t\t\t\t\t\tif (isProjectDir) {\n\t\t\t\t\t\t\t\t\tconfigChangedSinceLastBuild = true;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tscheduleCompile(directoryPath);\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst changedPath = resolve(directoryPath, filename.toString());\n\t\t\t\t\t\t\tif (isIgnoredPath(changedPath)) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// Config-named events must not be lost to debounce\n\t\t\t\t\t\t\t// coalescing with unrelated files. Ordinary files are\n\t\t\t\t\t\t\t// still scheduled: new inputs can appear directly in\n\t\t\t\t\t\t\t// the project directory (e.g. a locale file matching\n\t\t\t\t\t\t\t// ./messages/{locale}.json patterns rooted there).\n\t\t\t\t\t\t\tif (isProjectDir && isConfigFileName(changedPath)) {\n\t\t\t\t\t\t\t\tconfigChangedSinceLastBuild = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tscheduleCompile(changedPath);\n\t\t\t\t\t\t});\n\t\t\t\t\t\tattachWatcherErrorHandler(watcher, directoryPath, \"directory\");\n\t\t\t\t\t\tdirectoryWatchers.set(directoryPath, watcher);\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tlogger.warn(`Failed to watch directory: ${directoryPath}`);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst runCompile = async (changedPath?: string) => {\n\t\t\t\tif (compileInProgress) {\n\t\t\t\t\tcompileRequested = true;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tcompileInProgress = true;\n\t\t\t\tconst previouslyReadFiles = new Set(readFiles);\n\t\t\t\tclearReadFiles();\n\n\t\t\t\tif (configChangedSinceLastBuild) {\n\t\t\t\t\tconfigChangedSinceLastBuild = false;\n\t\t\t\t\tconst succeeded = await refreshConfig();\n\t\t\t\t\tif (!succeeded) {\n\t\t\t\t\t\t// Invalid config: skip this compilation entirely — the\n\t\t\t\t\t\t// previously compiled output stays on disk untouched.\n\t\t\t\t\t\tcompileInProgress = false;\n\t\t\t\t\t\tupdateWatchers(new Set(readFiles));\n\t\t\t\t\t\tif (compileRequested) {\n\t\t\t\t\t\t\tcompileRequested = false;\n\t\t\t\t\t\t\trunCompile();\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}\n\n\t\t\t\tif (changedPath) {\n\t\t\t\t\tlogger.info(\n\t\t\t\t\t\t`Re-compiling inlang project... File \"${relative(process.cwd(), changedPath)}\" has changed.`\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tlogger.info(\"Compiling inlang project ...\");\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tconst seededPrevious =\n\t\t\t\t\t\tpreviousCompilation ??\n\t\t\t\t\t\t(compileOptions.cleanOutdir\n\t\t\t\t\t\t\t? await seedPreviousCompilationFromOutdir({\n\t\t\t\t\t\t\t\t\toutdir: compileOptions.outdir,\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t: undefined);\n\n\t\t\t\t\tpreviousCompilation = await compile({\n\t\t\t\t\t\t...compileOptions,\n\t\t\t\t\t\tfs: trackedFs,\n\t\t\t\t\t\tpreviousCompilation: seededPrevious,\n\t\t\t\t\t\tcleanOutdir: false,\n\t\t\t\t\t});\n\n\t\t\t\t\tif (changedPath) {\n\t\t\t\t\t\tlogger.success(\"Re-compilation complete.\");\n\t\t\t\t\t} else {\n\t\t\t\t\t\tlogger.success(\"Successfully compiled inlang project.\");\n\t\t\t\t\t}\n\t\t\t\t} catch (e) {\n\t\t\t\t\tif (previouslyReadFiles.size > 0) {\n\t\t\t\t\t\tclearReadFiles();\n\t\t\t\t\t\tfor (const filePath of previouslyReadFiles) {\n\t\t\t\t\t\t\treadFiles.add(filePath);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tpreviousCompilation = undefined;\n\t\t\t\t\tlogger.error(\"Error while compiling inlang project.\");\n\t\t\t\t\tlogger.error(e);\n\t\t\t\t} finally {\n\t\t\t\t\tupdateWatchers(new Set(readFiles));\n\t\t\t\t\tcompileInProgress = false;\n\t\t\t\t\tif (compileRequested) {\n\t\t\t\t\t\tcompileRequested = false;\n\t\t\t\t\t\trunCompile();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst scheduleCompile = (changedPath?: string) => {\n\t\t\t\tif (compileTimer) {\n\t\t\t\t\tclearTimeout(compileTimer);\n\t\t\t\t}\n\t\t\t\tcompileTimer = setTimeout(() => {\n\t\t\t\t\trunCompile(changedPath);\n\t\t\t\t}, 100);\n\t\t\t};\n\n\t\t\tconst closeWatchers = () => {\n\t\t\t\tfor (const watcher of fileWatchers.values()) {\n\t\t\t\t\twatcher.close();\n\t\t\t\t}\n\t\t\t\tfor (const watcher of directoryWatchers.values()) {\n\t\t\t\t\twatcher.close();\n\t\t\t\t}\n\t\t\t\tfileWatchers.clear();\n\t\t\t\tdirectoryWatchers.clear();\n\t\t\t};\n\n\t\t\tprocess.on(\"SIGINT\", () => {\n\t\t\t\tcloseWatchers();\n\t\t\t\tprocess.exit(0);\n\t\t\t});\n\n\t\t\tawait runCompile();\n\t\t\tlogger.info(\"Watching for changes...\");\n\t\t}\n\t);\n"]}
1
+ {"version":3,"file":"command.js","sourceRoot":"","sources":["../../../../src/cli/commands/compile/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAC3D,OAAO,EACN,cAAc,EACd,oBAAoB,GACpB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,OAAO,EAA0B,MAAM,8BAA8B,CAAC;AAC/E,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,iCAAiC,EAAE,MAAM,gDAAgD,CAAC;AACnG,OAAO,EACN,eAAe,EACf,eAAe,GACf,MAAM,+CAA+C,CAAC;AACvD,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAC7B,OAAO,EACN,yBAAyB,EACzB,gBAAgB,EAChB,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB,EACtB,kBAAkB,GAGlB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAK9E,MAA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C,CACD,CAAC","sourcesContent":["import { Command, InvalidArgumentError } from \"commander\";\nimport fs from \"node:fs\";\nimport { resolve, relative } from \"node:path\";\nimport { Logger } from \"../../../services/logger/index.js\";\nimport {\n\tDEFAULT_OUTDIR,\n\tDEFAULT_PROJECT_PATH,\n} from \"../../../services/config/defaults.js\";\nimport { compile, type CompilationResult } from \"../../../compiler/compile.js\";\nimport { defaultCompilerOptions } from \"../../../compiler/compiler-options.js\";\nimport { seedPreviousCompilationFromOutdir } from \"../../../compiler/seed-previous-compilation.js\";\nimport {\n\tcreateTrackedFs,\n\tgetWatchTargets,\n} from \"../../../services/file-watching/tracked-fs.js\";\nimport * as v from \"valibot\";\nimport {\n\tclearParaglideConfigCache,\n\tisConfigFileName,\n\tloadParaglideConfig,\n\tresolveCompilerOptions,\n\tresolveConfigCandidate,\n\tstrategyNameSchema,\n\ttype LoadedParaglideConfig,\n\ttype ParaglideConfig,\n} from \"../../../services/config/index.js\";\nimport { nodeNormalizePath } from \"../../../utilities/node-normalize-path.js\";\nimport type { CompilerOptions } from \"../../../compiler/compiler-options.js\";\n\ntype OutputStructure = NonNullable<CompilerOptions[\"outputStructure\"]>;\n\nconst errorMessage = (error: unknown): string =>\n\terror instanceof Error ? error.message : String(error);\n\nconst parseOutputStructure = (value: string): OutputStructure => {\n\tif (value === \"message-modules\" || value === \"locale-modules\") {\n\t\treturn value;\n\t}\n\tthrow new InvalidArgumentError(\n\t\t`Invalid output structure \"${value}\". Expected \"message-modules\" or \"locale-modules\".`\n\t);\n};\n\nexport const compileCommand = new Command()\n\t.name(\"compile\")\n\t.summary(\"Compiles inlang Paraglide-JS\")\n\t.option(\n\t\t\"--project <path>\",\n\t\t`The path to the inlang project. Example: \"./project.inlang\". Defaults to \"${DEFAULT_PROJECT_PATH}\".`\n\t)\n\t.option(\n\t\t\"--outdir <path>\",\n\t\t`The path to the output directory. Example: \"./src/paraglide\". Defaults to \"${DEFAULT_OUTDIR}\".`\n\t)\n\t.option(\n\t\t\"--strategy <items...>\",\n\t\t[\n\t\t\t\"The strategy to be used.\",\n\t\t\t\"\",\n\t\t\t\"Example: --strategy cookie globalVariable baseLocale\",\n\t\t\t\"Read more on https://paraglidejs.com/strategy\",\n\t\t].join(\"\\n\")\n\t)\n\t.requiredOption(\"--silent\", \"Only log errors to the console\", false)\n\t.option(\n\t\t\"--emit-ts-declarations\",\n\t\t`Emit .d.ts files for the generated output (requires the typescript package) (default: ${defaultCompilerOptions.emitTsDeclarations})`\n\t)\n\t.option(\n\t\t\"--no-emit-ts-declarations\",\n\t\t\"Do not emit .d.ts files for the generated output\"\n\t)\n\t.option(\n\t\t\"--emit-git-ignore\",\n\t\t`Emit a .gitignore in the output directory (default: ${defaultCompilerOptions.emitGitIgnore})`\n\t)\n\t.option(\n\t\t\"--no-emit-git-ignore\",\n\t\t\"Do not emit a .gitignore in the output directory\"\n\t)\n\t.option(\n\t\t\"--emit-prettier-ignore\",\n\t\t`Emit a .prettierignore in the output directory (default: ${defaultCompilerOptions.emitPrettierIgnore})`\n\t)\n\t.option(\n\t\t\"--no-emit-prettier-ignore\",\n\t\t\"Do not emit a .prettierignore in the output directory\"\n\t)\n\t.option(\n\t\t\"--emit-readme\",\n\t\t`Emit a README.md in the output directory (helps LLMs understand the generated code) (default: ${defaultCompilerOptions.emitReadme})`\n\t)\n\t.option(\"--no-emit-readme\", \"Do not emit README.md in the output directory\")\n\t.option(\n\t\t\"--is-server <expression>\",\n\t\t[\n\t\t\t\"JavaScript expression for runtime `isServer` (enables server/client tree-shaking).\",\n\t\t\t\"Quote if the expression contains spaces, e.g. --is-server 'typeof window === \\\"undefined\\\"'.\",\n\t\t\t\"Vite SSR example: --is-server 'import.meta.env.SSR'\",\n\t\t].join(\" \")\n\t)\n\t.option(\n\t\t\"--clean-outdir\",\n\t\t\"Remove files in the output directory that are not generated by this compile\",\n\t\tdefaultCompilerOptions.cleanOutdir\n\t)\n\t.option(\n\t\t\"--no-clean-outdir\",\n\t\t\"Preserve files in the output directory that are not generated by this compile\"\n\t)\n\t.option(\n\t\t\"--experimental-static-locale <expression>\",\n\t\t[\n\t\t\t\"JavaScript expression for a compile-time locale constant (experimental).\",\n\t\t\t\"For a literal locale, include the JavaScript quotes, e.g. --experimental-static-locale '\\\"de\\\"'.\",\n\t\t].join(\" \")\n\t)\n\t.option(\n\t\t\"--disable-async-local-storage\",\n\t\t\"Use the synchronous request-locale fallback instead of AsyncLocalStorage\",\n\t\tdefaultCompilerOptions.disableAsyncLocalStorage\n\t)\n\t.option(\n\t\t\"--output-structure <structure>\",\n\t\t[\n\t\t\t`The output structure for compiled messages. Either \"message-modules\" or \"locale-modules\" (default: \"${defaultCompilerOptions.outputStructure}\").`,\n\t\t\t\"\",\n\t\t\t'\"message-modules\" gives each message its own module (better tree-shaking).',\n\t\t\t'\"locale-modules\" bundles messages per locale (fewer files, better for large projects in dev).',\n\t\t].join(\"\\n\"),\n\t\tparseOutputStructure\n\t)\n\t.option(\"--watch\", \"Watch project files and recompile on change\", false)\n\t.action(\n\t\tasync (options: {\n\t\t\tsilent: boolean;\n\t\t\tproject?: string;\n\t\t\toutdir?: string;\n\t\t\tstrategy?: string[];\n\t\t\temitTsDeclarations?: boolean;\n\t\t\temitGitIgnore?: boolean;\n\t\t\temitPrettierIgnore?: boolean;\n\t\t\temitReadme?: boolean;\n\t\t\tisServer?: string;\n\t\t\tcleanOutdir?: CompilerOptions[\"cleanOutdir\"];\n\t\t\texperimentalStaticLocale?: CompilerOptions[\"experimentalStaticLocale\"];\n\t\t\tdisableAsyncLocalStorage?: CompilerOptions[\"disableAsyncLocalStorage\"];\n\t\t\toutputStructure?: OutputStructure;\n\t\t\twatch?: boolean;\n\t\t}) => {\n\t\t\tconst logger = new Logger({ silent: options.silent, prefix: true });\n\n\t\t\tconst projectDir = nodeNormalizePath(\n\t\t\t\tresolve(process.cwd(), options.project ?? DEFAULT_PROJECT_PATH)\n\t\t\t);\n\n\t\t\tconst loadConfig = () => loadParaglideConfig({ projectDir, logger });\n\n\t\t\tlet projectOverride = options.project;\n\t\t\tif (projectOverride === undefined) {\n\t\t\t\tprojectOverride = DEFAULT_PROJECT_PATH;\n\t\t\t\tlogger.info(\n\t\t\t\t\t`--project was not provided, using \"${DEFAULT_PROJECT_PATH}\".`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst buildCompileOptions = () => {\n\t\t\t\tlet validatedStrategy: ParaglideConfig[\"strategy\"] | undefined;\n\t\t\t\tif (options.strategy !== undefined) {\n\t\t\t\t\tconst parsed = v.safeParse(\n\t\t\t\t\t\tv.array(strategyNameSchema),\n\t\t\t\t\t\toptions.strategy\n\t\t\t\t\t);\n\t\t\t\t\tif (!parsed.success) {\n\t\t\t\t\t\tconst details = parsed.issues\n\t\t\t\t\t\t\t.map((i) => `\"${v.getDotPath(i) ?? \"(root)\"}\": ${i.message}`)\n\t\t\t\t\t\t\t.join(\", \");\n\t\t\t\t\t\tthrow new Error(`Invalid --strategy: ${details}`);\n\t\t\t\t\t}\n\t\t\t\t\tvalidatedStrategy = parsed.output;\n\t\t\t\t}\n\t\t\t\tlet outdirOverride: string | undefined = options.outdir;\n\t\t\t\tif (\n\t\t\t\t\toutdirOverride === undefined &&\n\t\t\t\t\tloadedConfig?.config.outdir === undefined\n\t\t\t\t) {\n\t\t\t\t\toutdirOverride = DEFAULT_OUTDIR;\n\t\t\t\t}\n\t\t\t\treturn resolveCompilerOptions({\n\t\t\t\t\tconfig: loadedConfig?.config,\n\t\t\t\t\toverrides: {\n\t\t\t\t\t\tproject: projectOverride,\n\t\t\t\t\t\toutdir: outdirOverride,\n\t\t\t\t\t\tstrategy: validatedStrategy,\n\t\t\t\t\t\temitTsDeclarations: options.emitTsDeclarations,\n\t\t\t\t\t\temitGitIgnore: options.emitGitIgnore,\n\t\t\t\t\t\temitPrettierIgnore: options.emitPrettierIgnore,\n\t\t\t\t\t\temitReadme: options.emitReadme,\n\t\t\t\t\t\tisServer: options.isServer,\n\t\t\t\t\t\tcleanOutdir: options.cleanOutdir,\n\t\t\t\t\t\texperimentalStaticLocale: options.experimentalStaticLocale,\n\t\t\t\t\t\tdisableAsyncLocalStorage: options.disableAsyncLocalStorage,\n\t\t\t\t\t\t// The CLI always uses message-modules unless told otherwise\n\t\t\t\t\t\t// (plugins apply their own development default).\n\t\t\t\t\t\toutputStructure:\n\t\t\t\t\t\t\toptions.outputStructure ?? defaultCompilerOptions.outputStructure,\n\t\t\t\t\t},\n\t\t\t\t\troot: process.cwd(),\n\t\t\t\t});\n\t\t\t};\n\n\t\t\tlet loadedConfig: LoadedParaglideConfig | undefined;\n\t\t\tlet compileOptions: CompilerOptions;\n\n\t\t\ttry {\n\t\t\t\tloadedConfig = await loadConfig();\n\t\t\t\tcompileOptions = buildCompileOptions();\n\t\t\t} catch (error) {\n\t\t\t\tlogger.error(errorMessage(error));\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\n\t\t\tif (!options.watch) {\n\t\t\t\tlogger.info(`Compiling inlang project ...`);\n\n\t\t\t\ttry {\n\t\t\t\t\tconst previousCompilation = compileOptions.cleanOutdir\n\t\t\t\t\t\t? await seedPreviousCompilationFromOutdir({\n\t\t\t\t\t\t\t\toutdir: compileOptions.outdir,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t: undefined;\n\n\t\t\t\t\tawait compile({\n\t\t\t\t\t\t...compileOptions,\n\t\t\t\t\t\tpreviousCompilation,\n\t\t\t\t\t\tcleanOutdir: false,\n\t\t\t\t\t});\n\t\t\t\t} catch (e) {\n\t\t\t\t\tlogger.error(\"Error while compiling inlang project.\");\n\t\t\t\t\tlogger.error(e);\n\t\t\t\t\tprocess.exit(1);\n\t\t\t\t}\n\n\t\t\t\tlogger.success(`Successfully compiled inlang project.`);\n\n\t\t\t\tprocess.exit(0);\n\t\t\t}\n\n\t\t\tconst { fs: trackedFs, readFiles, clearReadFiles } = createTrackedFs();\n\t\t\tconst fileWatchers = new Map<string, fs.FSWatcher>();\n\t\t\tconst directoryWatchers = new Map<string, fs.FSWatcher>();\n\t\t\tlet previousCompilation: CompilationResult | undefined;\n\t\t\tlet compileTimer: NodeJS.Timeout | undefined;\n\t\t\tlet compileInProgress = false;\n\t\t\tlet compileRequested = false;\n\t\t\tlet watching = true;\n\t\t\t// Set by the project-directory watcher when a config-named file\n\t\t\t// changes — survives debounced coalescing with unrelated events.\n\t\t\tlet configChangedSinceLastBuild = false;\n\n\t\t\t/**\n\t\t\t * Reacts to a config-named event in the project directory:\n\t\t\t * rescans the candidate winner and reloads. A missing config\n\t\t\t * falls back to the built-in defaults; an invalid one fails the\n\t\t\t * reload (caller skips the compilation).\n\t\t\t */\n\t\t\tconst refreshConfig = async (): Promise<boolean> => {\n\t\t\t\tconst winner = await resolveConfigCandidate(projectDir);\n\t\t\t\tif (winner === undefined) {\n\t\t\t\t\tif (loadedConfig !== undefined) {\n\t\t\t\t\t\tlogger.warn(\n\t\t\t\t\t\t\t\"Paraglide config file was removed, compiling with default options.\"\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tloadedConfig = undefined;\n\t\t\t\t\tcompileOptions = buildCompileOptions();\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tclearParaglideConfigCache({ projectDir });\n\t\t\t\t\tconst nextLoadedConfig = await loadConfig();\n\t\t\t\t\tif (nextLoadedConfig === undefined) return true; // raced deletion\n\t\t\t\t\tloadedConfig = nextLoadedConfig;\n\t\t\t\t\tcompileOptions = buildCompileOptions();\n\t\t\t\t\treturn true;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tlogger.error(errorMessage(error));\n\t\t\t\t\tlogger.error(\n\t\t\t\t\t\t\"Skipping compilation because of the invalid paraglide config.\"\n\t\t\t\t\t);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst updateWatchers = (files: Set<string>) => {\n\t\t\t\tif (!watching) return;\n\t\t\t\tconst {\n\t\t\t\t\tfiles: nextFiles,\n\t\t\t\t\tdirectories: nextDirectories,\n\t\t\t\t\tisIgnoredPath,\n\t\t\t\t} = getWatchTargets(files, { outdir: compileOptions.outdir });\n\n\t\t\t\tfor (const [filePath, watcher] of fileWatchers) {\n\t\t\t\t\tif (!nextFiles.has(filePath)) {\n\t\t\t\t\t\twatcher.close();\n\t\t\t\t\t\tfileWatchers.delete(filePath);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// The project directory is always watched: it hosts the config\n\t\t\t\t// file, and its other contents (settings.json, messages/) are\n\t\t\t\t// compile inputs anyway.\n\t\t\t\tnextDirectories.add(projectDir);\n\n\t\t\t\tfor (const [directoryPath, watcher] of directoryWatchers) {\n\t\t\t\t\tif (!nextDirectories.has(directoryPath)) {\n\t\t\t\t\t\twatcher.close();\n\t\t\t\t\t\tdirectoryWatchers.delete(directoryPath);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst attachWatcherErrorHandler = (\n\t\t\t\t\twatcher: fs.FSWatcher,\n\t\t\t\t\ttargetPath: string,\n\t\t\t\t\ttargetType: \"file\" | \"directory\"\n\t\t\t\t) => {\n\t\t\t\t\twatcher.on(\"error\", (error) => {\n\t\t\t\t\t\tlogger.warn(\n\t\t\t\t\t\t\t`Watch ${targetType} error for ${targetPath}: ${errorMessage(error)}`\n\t\t\t\t\t\t);\n\t\t\t\t\t});\n\t\t\t\t};\n\n\t\t\t\tfor (const filePath of nextFiles) {\n\t\t\t\t\tif (fileWatchers.has(filePath)) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst watcher = fs.watch(filePath, () => {\n\t\t\t\t\t\t\tscheduleCompile(filePath);\n\t\t\t\t\t\t});\n\t\t\t\t\t\tattachWatcherErrorHandler(watcher, filePath, \"file\");\n\t\t\t\t\t\tfileWatchers.set(filePath, watcher);\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tlogger.warn(`Failed to watch file: ${filePath}`);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tfor (const directoryPath of nextDirectories) {\n\t\t\t\t\tif (directoryWatchers.has(directoryPath)) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst watcher = fs.watch(directoryPath, (eventType, filename) => {\n\t\t\t\t\t\t\tconst isProjectDir = directoryPath === projectDir;\n\n\t\t\t\t\t\t\tif (!filename) {\n\t\t\t\t\t\t\t\tif (isProjectDir) {\n\t\t\t\t\t\t\t\t\tconfigChangedSinceLastBuild = true;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tscheduleCompile(directoryPath);\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst changedPath = resolve(directoryPath, filename.toString());\n\t\t\t\t\t\t\tif (isIgnoredPath(changedPath)) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// Config-named events must not be lost to debounce\n\t\t\t\t\t\t\t// coalescing with unrelated files. Ordinary files are\n\t\t\t\t\t\t\t// still scheduled: new inputs can appear directly in\n\t\t\t\t\t\t\t// the project directory (e.g. a locale file matching\n\t\t\t\t\t\t\t// ./messages/{locale}.json patterns rooted there).\n\t\t\t\t\t\t\tif (isProjectDir && isConfigFileName(changedPath)) {\n\t\t\t\t\t\t\t\tconfigChangedSinceLastBuild = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tscheduleCompile(changedPath);\n\t\t\t\t\t\t});\n\t\t\t\t\t\tattachWatcherErrorHandler(watcher, directoryPath, \"directory\");\n\t\t\t\t\t\tdirectoryWatchers.set(directoryPath, watcher);\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tlogger.warn(`Failed to watch directory: ${directoryPath}`);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst runCompile = async (changedPath?: string) => {\n\t\t\t\tif (!watching) return;\n\t\t\t\tif (compileInProgress) {\n\t\t\t\t\tcompileRequested = true;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tcompileInProgress = true;\n\t\t\t\tconst previouslyReadFiles = new Set(readFiles);\n\t\t\t\tclearReadFiles();\n\n\t\t\t\tif (configChangedSinceLastBuild) {\n\t\t\t\t\tconfigChangedSinceLastBuild = false;\n\t\t\t\t\tconst succeeded = await refreshConfig();\n\t\t\t\t\tif (!succeeded) {\n\t\t\t\t\t\t// Invalid config: skip this compilation entirely — the\n\t\t\t\t\t\t// previously compiled output stays on disk untouched.\n\t\t\t\t\t\tcompileInProgress = false;\n\t\t\t\t\t\tupdateWatchers(new Set(readFiles));\n\t\t\t\t\t\tif (compileRequested) {\n\t\t\t\t\t\t\tcompileRequested = false;\n\t\t\t\t\t\t\trunCompile();\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}\n\n\t\t\t\tif (changedPath) {\n\t\t\t\t\tlogger.info(\n\t\t\t\t\t\t`Re-compiling inlang project... File \"${relative(process.cwd(), changedPath)}\" has changed.`\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tlogger.info(\"Compiling inlang project ...\");\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tconst seededPrevious =\n\t\t\t\t\t\tpreviousCompilation ??\n\t\t\t\t\t\t(compileOptions.cleanOutdir\n\t\t\t\t\t\t\t? await seedPreviousCompilationFromOutdir({\n\t\t\t\t\t\t\t\t\toutdir: compileOptions.outdir,\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t: undefined);\n\n\t\t\t\t\tpreviousCompilation = await compile({\n\t\t\t\t\t\t...compileOptions,\n\t\t\t\t\t\tfs: trackedFs,\n\t\t\t\t\t\tpreviousCompilation: seededPrevious,\n\t\t\t\t\t\tcleanOutdir: false,\n\t\t\t\t\t});\n\n\t\t\t\t\tif (changedPath) {\n\t\t\t\t\t\tlogger.success(\"Re-compilation complete.\");\n\t\t\t\t\t} else {\n\t\t\t\t\t\tlogger.success(\"Successfully compiled inlang project.\");\n\t\t\t\t\t}\n\t\t\t\t} catch (e) {\n\t\t\t\t\tif (previouslyReadFiles.size > 0) {\n\t\t\t\t\t\tclearReadFiles();\n\t\t\t\t\t\tfor (const filePath of previouslyReadFiles) {\n\t\t\t\t\t\t\treadFiles.add(filePath);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tpreviousCompilation = undefined;\n\t\t\t\t\tlogger.error(\"Error while compiling inlang project.\");\n\t\t\t\t\tlogger.error(e);\n\t\t\t\t} finally {\n\t\t\t\t\tupdateWatchers(new Set(readFiles));\n\t\t\t\t\tcompileInProgress = false;\n\t\t\t\t\tif (compileRequested) {\n\t\t\t\t\t\tcompileRequested = false;\n\t\t\t\t\t\trunCompile();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst scheduleCompile = (changedPath?: string) => {\n\t\t\t\tif (!watching) return;\n\t\t\t\tif (compileTimer) {\n\t\t\t\t\tclearTimeout(compileTimer);\n\t\t\t\t}\n\t\t\t\tcompileTimer = setTimeout(() => {\n\t\t\t\t\trunCompile(changedPath);\n\t\t\t\t}, 100);\n\t\t\t};\n\n\t\t\tconst closeWatchers = () => {\n\t\t\t\twatching = false;\n\t\t\t\tcompileRequested = false;\n\t\t\t\tif (compileTimer) {\n\t\t\t\t\tclearTimeout(compileTimer);\n\t\t\t\t\tcompileTimer = undefined;\n\t\t\t\t}\n\t\t\t\tfor (const watcher of fileWatchers.values()) {\n\t\t\t\t\twatcher.close();\n\t\t\t\t}\n\t\t\t\tfor (const watcher of directoryWatchers.values()) {\n\t\t\t\t\twatcher.close();\n\t\t\t\t}\n\t\t\t\tfileWatchers.clear();\n\t\t\t\tdirectoryWatchers.clear();\n\t\t\t};\n\n\t\t\tprocess.on(\"SIGINT\", () => {\n\t\t\t\tcloseWatchers();\n\t\t\t\tprocess.exit(0);\n\t\t\t});\n\n\t\t\tawait runCompile();\n\t\t\tlogger.info(\"Watching for changes...\");\n\t\t}\n\t);\n"]}
@@ -1,23 +1,71 @@
1
1
  import { mkdtemp, rm, writeFile, mkdir } from "node:fs/promises";
2
2
  import * as nodeFs from "node:fs/promises";
3
+ import fs from "node:fs";
4
+ import { EventEmitter } from "node:events";
3
5
  import { tmpdir } from "node:os";
4
6
  import consola from "consola";
5
7
  import path, { resolve } from "node:path";
6
8
  import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
7
9
  let testDirectories = [];
8
10
  let initialSigintListeners = [];
11
+ let watchers = new Map();
12
+ // Test CLI event handling with real config files and controlled watch delivery.
13
+ // fs.watch does not guarantee event timing, filenames, or one event per write.
14
+ class TestWatcher extends EventEmitter {
15
+ onClose;
16
+ constructor(onClose) {
17
+ super();
18
+ this.onClose = onClose;
19
+ }
20
+ close() {
21
+ this.onClose();
22
+ this.removeAllListeners();
23
+ }
24
+ ref() {
25
+ return this;
26
+ }
27
+ unref() {
28
+ return this;
29
+ }
30
+ }
31
+ function notifyChange(directory, filename, event = "change") {
32
+ const current = watchers.get(path.resolve(directory));
33
+ expect(current?.size).toBeGreaterThan(0);
34
+ for (const watcher of current ?? [])
35
+ watcher.emit("change", event, filename);
36
+ }
9
37
  beforeEach(() => {
10
38
  vi.resetModules();
11
39
  testDirectories = [];
12
40
  initialSigintListeners = process.listeners("SIGINT");
41
+ watchers = new Map();
42
+ vi.spyOn(fs, "watch").mockImplementation((filename, options, listener) => {
43
+ const target = path.resolve(String(filename));
44
+ const current = watchers.get(target) ?? new Set();
45
+ watchers.set(target, current);
46
+ const watcher = new TestWatcher(() => current.delete(watcher));
47
+ const callback = typeof options === "function" ? options : listener;
48
+ if (callback)
49
+ watcher.on("change", callback);
50
+ current.add(watcher);
51
+ return watcher;
52
+ });
13
53
  });
14
54
  afterEach(async () => {
15
- vi.restoreAllMocks();
55
+ // Stop each CLI instance before deleting fixtures or restoring its mocks.
56
+ vi.spyOn(process, "exit").mockImplementation(() => undefined);
16
57
  for (const listener of process.listeners("SIGINT")) {
17
58
  if (!initialSigintListeners.includes(listener)) {
59
+ listener("SIGINT");
18
60
  process.removeListener("SIGINT", listener);
19
61
  }
20
62
  }
63
+ for (const current of watchers.values()) {
64
+ for (const watcher of current)
65
+ watcher.close();
66
+ }
67
+ vi.useRealTimers();
68
+ vi.restoreAllMocks();
21
69
  for (const directory of testDirectories) {
22
70
  await rm(directory, { recursive: true, force: true });
23
71
  }
@@ -279,6 +327,7 @@ describe("config file integration", () => {
279
327
  expect(compileMock).toHaveBeenCalledTimes(1);
280
328
  expect(compileMock.mock.calls[0][0].outdir).toBe(outdir);
281
329
  await rm(configPath);
330
+ notifyChange(projectDir, "paraglide.config.ts", "rename");
282
331
  const deadline = Date.now() + 10_000;
283
332
  while (compileMock.mock.calls.length < 2 && Date.now() < deadline) {
284
333
  await new Promise((r) => setTimeout(r, 50));
@@ -291,6 +340,7 @@ describe("config file integration", () => {
291
340
  }
292
341
  // Recreating the config with a different outdir is picked up again.
293
342
  await writeConfig(projectDir, path.join(workspace, "recreated"));
343
+ notifyChange(projectDir, "paraglide.config.ts", "rename");
294
344
  const recreateDeadline = Date.now() + 10_000;
295
345
  while (Date.now() < recreateDeadline &&
296
346
  !compileMock.mock.calls.some((c) => String(c[0].outdir).endsWith("recreated"))) {
@@ -313,6 +363,7 @@ describe("config file integration", () => {
313
363
  await compileCommand.parseAsync(["--project", projectDir, "--watch", "--silent"], { from: "user" });
314
364
  expect(compileMock).toHaveBeenCalledTimes(1);
315
365
  await writeFile(path.join(projectDir, "es.json"), "{}");
366
+ notifyChange(projectDir, "es.json", "rename");
316
367
  const deadline = Date.now() + 10_000;
317
368
  while (compileMock.mock.calls.length < 2 && Date.now() < deadline) {
318
369
  await new Promise((r) => setTimeout(r, 50));
@@ -336,6 +387,8 @@ describe("config file integration", () => {
336
387
  // Format switch: delete .ts, add .js.
337
388
  await rm(tsPath);
338
389
  await writeFile(jsPath, ["export default {", ` outdir: ${JSON.stringify(outdirB)},`, "}"].join("\n"));
390
+ notifyChange(projectDir, "paraglide.config.ts", "rename");
391
+ notifyChange(projectDir, "paraglide.config.js", "rename");
339
392
  const deadline = Date.now() + 10_000;
340
393
  while (Date.now() < deadline &&
341
394
  !compileMock.mock.calls.some((c) => c[0].outdir === outdirB)) {
@@ -369,17 +422,48 @@ describe("config file integration", () => {
369
422
  expect(compileModule.compile).toHaveBeenCalledTimes(1);
370
423
  expect(loadCount).toBe(1);
371
424
  await writeFile(path.join(projectDir, "README.md"), "hello");
372
- await new Promise((r) => setTimeout(r, 1_000));
425
+ notifyChange(projectDir, "README.md");
426
+ await vi.waitFor(() => expect(compileModule.compile).toHaveBeenCalledTimes(2));
373
427
  await writeFile(path.join(projectDir, "notes.txt"), "world");
374
- await new Promise((r) => setTimeout(r, 1_500));
428
+ notifyChange(projectDir, "notes.txt");
429
+ await vi.waitFor(() => expect(compileModule.compile).toHaveBeenCalledTimes(3));
375
430
  expect(compileModule.compile.mock.calls.length).toBeGreaterThanOrEqual(3);
376
431
  expect(loadCount).toBe(1);
432
+ // A missing filename is ambiguous and must conservatively refresh config.
433
+ notifyChange(projectDir, null);
434
+ await vi.waitFor(() => expect(compileModule.compile).toHaveBeenCalledTimes(4));
435
+ expect(loadCount).toBe(2);
377
436
  }
378
437
  finally {
379
438
  vi.doUnmock("../../../services/config/index.js");
380
439
  }
381
440
  });
382
441
  });
442
+ test("watch shutdown cancels queued rebuilds and ignores late events", async () => {
443
+ const { workspace, projectDir } = await createWorkspace();
444
+ await writeConfig(projectDir, path.join(workspace, "output"));
445
+ const compileMock = vi.fn().mockResolvedValue({ outputHashes: {} });
446
+ vi.doMock("../../../compiler/compile.js", () => ({ compile: compileMock }));
447
+ const { compileCommand } = await import("./command.js");
448
+ await compileCommand.parseAsync(["--project", projectDir, "--watch", "--silent", "--no-clean-outdir"], { from: "user" });
449
+ const watcher = [...watchers.get(path.resolve(projectDir))][0];
450
+ const lateEvent = watcher.listeners("change")[0];
451
+ vi.useFakeTimers();
452
+ notifyChange(projectDir, "notes.txt");
453
+ const exit = vi
454
+ .spyOn(process, "exit")
455
+ .mockImplementation(() => undefined);
456
+ const stop = process
457
+ .listeners("SIGINT")
458
+ .find((listener) => !initialSigintListeners.includes(listener));
459
+ expect(stop).toBeDefined();
460
+ stop("SIGINT");
461
+ lateEvent("change", "notes.txt");
462
+ await vi.advanceTimersByTimeAsync(500);
463
+ expect(exit).toHaveBeenCalledWith(0);
464
+ expect(compileMock).toHaveBeenCalledTimes(1);
465
+ expect([...watchers.values()].every((current) => current.size === 0)).toBe(true);
466
+ });
383
467
  test("compile --watch forwards the newly exposed compiler options (#757)", async () => {
384
468
  const testDirectory = await mkdtemp(path.join(tmpdir(), "paraglide-cli-"));
385
469
  testDirectories.push(testDirectory);