@sebbro/paraglide-lite 0.1.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 (715) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +67 -0
  3. package/bin/run.js +4 -0
  4. package/dist/bundler-plugins/esbuild.d.ts +1 -0
  5. package/dist/bundler-plugins/esbuild.d.ts.map +1 -0
  6. package/dist/bundler-plugins/esbuild.js +4 -0
  7. package/dist/bundler-plugins/esbuild.js.map +1 -0
  8. package/dist/bundler-plugins/index.d.ts +6 -0
  9. package/dist/bundler-plugins/index.d.ts.map +1 -0
  10. package/dist/bundler-plugins/index.js +7 -0
  11. package/dist/bundler-plugins/index.js.map +1 -0
  12. package/dist/bundler-plugins/lazy-modules/scan-message-keys.d.ts +19 -0
  13. package/dist/bundler-plugins/lazy-modules/scan-message-keys.d.ts.map +1 -0
  14. package/dist/bundler-plugins/lazy-modules/scan-message-keys.js +85 -0
  15. package/dist/bundler-plugins/lazy-modules/scan-message-keys.js.map +1 -0
  16. package/dist/bundler-plugins/lazy-modules/scan-message-keys.test.d.ts +2 -0
  17. package/dist/bundler-plugins/lazy-modules/scan-message-keys.test.d.ts.map +1 -0
  18. package/dist/bundler-plugins/lazy-modules/scan-message-keys.test.js +53 -0
  19. package/dist/bundler-plugins/lazy-modules/scan-message-keys.test.js.map +1 -0
  20. package/dist/bundler-plugins/lazy-modules/ssr.d.ts +31 -0
  21. package/dist/bundler-plugins/lazy-modules/ssr.d.ts.map +1 -0
  22. package/dist/bundler-plugins/lazy-modules/ssr.js +42 -0
  23. package/dist/bundler-plugins/lazy-modules/ssr.js.map +1 -0
  24. package/dist/bundler-plugins/lazy-modules/ssr.test.d.ts +2 -0
  25. package/dist/bundler-plugins/lazy-modules/ssr.test.d.ts.map +1 -0
  26. package/dist/bundler-plugins/lazy-modules/ssr.test.js +48 -0
  27. package/dist/bundler-plugins/lazy-modules/ssr.test.js.map +1 -0
  28. package/dist/bundler-plugins/lazy-modules/virtual-ids.d.ts +7 -0
  29. package/dist/bundler-plugins/lazy-modules/virtual-ids.d.ts.map +1 -0
  30. package/dist/bundler-plugins/lazy-modules/virtual-ids.js +30 -0
  31. package/dist/bundler-plugins/lazy-modules/virtual-ids.js.map +1 -0
  32. package/dist/bundler-plugins/lazy-modules/virtual.d.ts +86 -0
  33. package/dist/bundler-plugins/lazy-modules/virtual.d.ts.map +1 -0
  34. package/dist/bundler-plugins/lazy-modules/virtual.js +2 -0
  35. package/dist/bundler-plugins/lazy-modules/virtual.js.map +1 -0
  36. package/dist/bundler-plugins/lazy-modules/vite-plugin.d.ts +18 -0
  37. package/dist/bundler-plugins/lazy-modules/vite-plugin.d.ts.map +1 -0
  38. package/dist/bundler-plugins/lazy-modules/vite-plugin.js +328 -0
  39. package/dist/bundler-plugins/lazy-modules/vite-plugin.js.map +1 -0
  40. package/dist/bundler-plugins/lazy-modules/vite-plugin.test.d.ts +2 -0
  41. package/dist/bundler-plugins/lazy-modules/vite-plugin.test.d.ts.map +1 -0
  42. package/dist/bundler-plugins/lazy-modules/vite-plugin.test.js +45 -0
  43. package/dist/bundler-plugins/lazy-modules/vite-plugin.test.js.map +1 -0
  44. package/dist/bundler-plugins/per-locale-build/constants.d.ts +2 -0
  45. package/dist/bundler-plugins/per-locale-build/constants.d.ts.map +1 -0
  46. package/dist/bundler-plugins/per-locale-build/constants.js +3 -0
  47. package/dist/bundler-plugins/per-locale-build/constants.js.map +1 -0
  48. package/dist/bundler-plugins/per-locale-build/index.d.ts +6 -0
  49. package/dist/bundler-plugins/per-locale-build/index.d.ts.map +1 -0
  50. package/dist/bundler-plugins/per-locale-build/index.js +43 -0
  51. package/dist/bundler-plugins/per-locale-build/index.js.map +1 -0
  52. package/dist/bundler-plugins/per-locale-build/locale-id.d.ts +8 -0
  53. package/dist/bundler-plugins/per-locale-build/locale-id.d.ts.map +1 -0
  54. package/dist/bundler-plugins/per-locale-build/locale-id.js +13 -0
  55. package/dist/bundler-plugins/per-locale-build/locale-id.js.map +1 -0
  56. package/dist/bundler-plugins/per-locale-build/types.d.ts +4 -0
  57. package/dist/bundler-plugins/per-locale-build/types.d.ts.map +1 -0
  58. package/dist/bundler-plugins/per-locale-build/types.js +2 -0
  59. package/dist/bundler-plugins/per-locale-build/types.js.map +1 -0
  60. package/dist/bundler-plugins/per-locale-build/vite-environments.d.ts +51 -0
  61. package/dist/bundler-plugins/per-locale-build/vite-environments.d.ts.map +1 -0
  62. package/dist/bundler-plugins/per-locale-build/vite-environments.js +250 -0
  63. package/dist/bundler-plugins/per-locale-build/vite-environments.js.map +1 -0
  64. package/dist/bundler-plugins/per-locale-build/vite-environments.test.d.ts +1 -0
  65. package/dist/bundler-plugins/per-locale-build/vite-environments.test.d.ts.map +1 -0
  66. package/dist/bundler-plugins/per-locale-build/vite-environments.test.js +250 -0
  67. package/dist/bundler-plugins/per-locale-build/vite-environments.test.js.map +1 -0
  68. package/dist/bundler-plugins/plugin-core.d.ts +74 -0
  69. package/dist/bundler-plugins/plugin-core.d.ts.map +1 -0
  70. package/dist/bundler-plugins/plugin-core.js +292 -0
  71. package/dist/bundler-plugins/plugin-core.js.map +1 -0
  72. package/dist/bundler-plugins/rolldown.d.ts +10 -0
  73. package/dist/bundler-plugins/rolldown.d.ts.map +1 -0
  74. package/dist/bundler-plugins/rolldown.js +36 -0
  75. package/dist/bundler-plugins/rolldown.js.map +1 -0
  76. package/dist/bundler-plugins/rolldown.test.d.ts +1 -0
  77. package/dist/bundler-plugins/rolldown.test.d.ts.map +1 -0
  78. package/dist/bundler-plugins/rolldown.test.js +72 -0
  79. package/dist/bundler-plugins/rolldown.test.js.map +1 -0
  80. package/dist/bundler-plugins/rollup.d.ts +1 -0
  81. package/dist/bundler-plugins/rollup.d.ts.map +1 -0
  82. package/dist/bundler-plugins/rollup.js +4 -0
  83. package/dist/bundler-plugins/rollup.js.map +1 -0
  84. package/dist/bundler-plugins/rspack.d.ts +1 -0
  85. package/dist/bundler-plugins/rspack.d.ts.map +1 -0
  86. package/dist/bundler-plugins/rspack.js +4 -0
  87. package/dist/bundler-plugins/rspack.js.map +1 -0
  88. package/dist/bundler-plugins/unplugin.d.ts +3 -0
  89. package/dist/bundler-plugins/unplugin.d.ts.map +1 -0
  90. package/dist/bundler-plugins/unplugin.js +62 -0
  91. package/dist/bundler-plugins/unplugin.js.map +1 -0
  92. package/dist/bundler-plugins/unplugin.test.d.ts +1 -0
  93. package/dist/bundler-plugins/unplugin.test.d.ts.map +1 -0
  94. package/dist/bundler-plugins/unplugin.test.js +256 -0
  95. package/dist/bundler-plugins/unplugin.test.js.map +1 -0
  96. package/dist/bundler-plugins/virtual-modules.test.d.ts +1 -0
  97. package/dist/bundler-plugins/virtual-modules.test.d.ts.map +1 -0
  98. package/dist/bundler-plugins/virtual-modules.test.js +77 -0
  99. package/dist/bundler-plugins/virtual-modules.test.js.map +1 -0
  100. package/dist/bundler-plugins/vite.d.ts +17 -0
  101. package/dist/bundler-plugins/vite.d.ts.map +1 -0
  102. package/dist/bundler-plugins/vite.js +15 -0
  103. package/dist/bundler-plugins/vite.js.map +1 -0
  104. package/dist/bundler-plugins/vite.test.d.ts +1 -0
  105. package/dist/bundler-plugins/vite.test.d.ts.map +1 -0
  106. package/dist/bundler-plugins/vite.test.js +61 -0
  107. package/dist/bundler-plugins/vite.test.js.map +1 -0
  108. package/dist/bundler-plugins/webpack.d.ts +1 -0
  109. package/dist/bundler-plugins/webpack.d.ts.map +1 -0
  110. package/dist/bundler-plugins/webpack.js +4 -0
  111. package/dist/bundler-plugins/webpack.js.map +1 -0
  112. package/dist/cli/commands/compile/command.d.ts +2 -0
  113. package/dist/cli/commands/compile/command.d.ts.map +1 -0
  114. package/dist/cli/commands/compile/command.js +225 -0
  115. package/dist/cli/commands/compile/command.js.map +1 -0
  116. package/dist/cli/commands/compile/command.test.d.ts +1 -0
  117. package/dist/cli/commands/compile/command.test.d.ts.map +1 -0
  118. package/dist/cli/commands/compile/command.test.js +69 -0
  119. package/dist/cli/commands/compile/command.test.js.map +1 -0
  120. package/dist/cli/commands/init/command.d.ts +2 -0
  121. package/dist/cli/commands/init/command.d.ts.map +1 -0
  122. package/dist/cli/commands/init/command.js +90 -0
  123. package/dist/cli/commands/init/command.js.map +1 -0
  124. package/dist/cli/defaults.d.ts +11 -0
  125. package/dist/cli/defaults.d.ts.map +1 -0
  126. package/dist/cli/defaults.js +13 -0
  127. package/dist/cli/defaults.js.map +1 -0
  128. package/dist/cli/index.d.ts +2 -0
  129. package/dist/cli/index.d.ts.map +1 -0
  130. package/dist/cli/index.js +11 -0
  131. package/dist/cli/index.js.map +1 -0
  132. package/dist/cli/steps/add-vite-plugin.d.ts +31 -0
  133. package/dist/cli/steps/add-vite-plugin.d.ts.map +1 -0
  134. package/dist/cli/steps/add-vite-plugin.js +65 -0
  135. package/dist/cli/steps/add-vite-plugin.js.map +1 -0
  136. package/dist/cli/steps/add-vite-plugin.test.d.ts +1 -0
  137. package/dist/cli/steps/add-vite-plugin.test.d.ts.map +1 -0
  138. package/dist/cli/steps/add-vite-plugin.test.js +74 -0
  139. package/dist/cli/steps/add-vite-plugin.test.js.map +1 -0
  140. package/dist/cli/steps/check-for-uncomitted-changes.d.ts +5 -0
  141. package/dist/cli/steps/check-for-uncomitted-changes.d.ts.map +1 -0
  142. package/dist/cli/steps/check-for-uncomitted-changes.js +37 -0
  143. package/dist/cli/steps/check-for-uncomitted-changes.js.map +1 -0
  144. package/dist/cli/steps/detect-bundler.d.ts +10 -0
  145. package/dist/cli/steps/detect-bundler.d.ts.map +1 -0
  146. package/dist/cli/steps/detect-bundler.js +22 -0
  147. package/dist/cli/steps/detect-bundler.js.map +1 -0
  148. package/dist/cli/steps/detect-bundler.test.d.ts +1 -0
  149. package/dist/cli/steps/detect-bundler.test.d.ts.map +1 -0
  150. package/dist/cli/steps/detect-bundler.test.js +29 -0
  151. package/dist/cli/steps/detect-bundler.test.js.map +1 -0
  152. package/dist/cli/steps/initialize-messages.d.ts +11 -0
  153. package/dist/cli/steps/initialize-messages.d.ts.map +1 -0
  154. package/dist/cli/steps/initialize-messages.js +31 -0
  155. package/dist/cli/steps/initialize-messages.js.map +1 -0
  156. package/dist/cli/steps/prompt-for-outdir.d.ts +8 -0
  157. package/dist/cli/steps/prompt-for-outdir.d.ts.map +1 -0
  158. package/dist/cli/steps/prompt-for-outdir.js +19 -0
  159. package/dist/cli/steps/prompt-for-outdir.js.map +1 -0
  160. package/dist/cli/steps/update-package-json.d.ts +11 -0
  161. package/dist/cli/steps/update-package-json.d.ts.map +1 -0
  162. package/dist/cli/steps/update-package-json.js +34 -0
  163. package/dist/cli/steps/update-package-json.js.map +1 -0
  164. package/dist/cli/steps/update-ts-config.d.ts +26 -0
  165. package/dist/cli/steps/update-ts-config.d.ts.map +1 -0
  166. package/dist/cli/steps/update-ts-config.js +270 -0
  167. package/dist/cli/steps/update-ts-config.js.map +1 -0
  168. package/dist/cli/steps/update-ts-config.test.d.ts +1 -0
  169. package/dist/cli/steps/update-ts-config.test.d.ts.map +1 -0
  170. package/dist/cli/steps/update-ts-config.test.js +60 -0
  171. package/dist/cli/steps/update-ts-config.test.js.map +1 -0
  172. package/dist/cli/utils.d.ts +36 -0
  173. package/dist/cli/utils.d.ts.map +1 -0
  174. package/dist/cli/utils.js +20 -0
  175. package/dist/cli/utils.js.map +1 -0
  176. package/dist/compiler/assert-url-pattern-available.d.ts +7 -0
  177. package/dist/compiler/assert-url-pattern-available.d.ts.map +1 -0
  178. package/dist/compiler/assert-url-pattern-available.js +17 -0
  179. package/dist/compiler/assert-url-pattern-available.js.map +1 -0
  180. package/dist/compiler/compile-annotation.d.ts +12 -0
  181. package/dist/compiler/compile-annotation.d.ts.map +1 -0
  182. package/dist/compiler/compile-annotation.js +136 -0
  183. package/dist/compiler/compile-annotation.js.map +1 -0
  184. package/dist/compiler/compile-bundle.d.ts +28 -0
  185. package/dist/compiler/compile-bundle.d.ts.map +1 -0
  186. package/dist/compiler/compile-bundle.js +431 -0
  187. package/dist/compiler/compile-bundle.js.map +1 -0
  188. package/dist/compiler/compile-bundle.test.d.ts +1 -0
  189. package/dist/compiler/compile-bundle.test.d.ts.map +1 -0
  190. package/dist/compiler/compile-bundle.test.js +399 -0
  191. package/dist/compiler/compile-bundle.test.js.map +1 -0
  192. package/dist/compiler/compile-local-variable.d.ts +16 -0
  193. package/dist/compiler/compile-local-variable.d.ts.map +1 -0
  194. package/dist/compiler/compile-local-variable.js +28 -0
  195. package/dist/compiler/compile-local-variable.js.map +1 -0
  196. package/dist/compiler/compile-local-variable.test.d.ts +1 -0
  197. package/dist/compiler/compile-local-variable.test.d.ts.map +1 -0
  198. package/dist/compiler/compile-local-variable.test.js +359 -0
  199. package/dist/compiler/compile-local-variable.test.js.map +1 -0
  200. package/dist/compiler/compile-message.d.ts +8 -0
  201. package/dist/compiler/compile-message.d.ts.map +1 -0
  202. package/dist/compiler/compile-message.js +174 -0
  203. package/dist/compiler/compile-message.js.map +1 -0
  204. package/dist/compiler/compile-message.test.d.ts +1 -0
  205. package/dist/compiler/compile-message.test.d.ts.map +1 -0
  206. package/dist/compiler/compile-message.test.js +1060 -0
  207. package/dist/compiler/compile-message.test.js.map +1 -0
  208. package/dist/compiler/compile-pattern.d.ts +29 -0
  209. package/dist/compiler/compile-pattern.d.ts.map +1 -0
  210. package/dist/compiler/compile-pattern.js +143 -0
  211. package/dist/compiler/compile-pattern.js.map +1 -0
  212. package/dist/compiler/compile-pattern.test.d.ts +1 -0
  213. package/dist/compiler/compile-pattern.test.d.ts.map +1 -0
  214. package/dist/compiler/compile-pattern.test.js +255 -0
  215. package/dist/compiler/compile-pattern.test.js.map +1 -0
  216. package/dist/compiler/compile-project.d.ts +21 -0
  217. package/dist/compiler/compile-project.d.ts.map +1 -0
  218. package/dist/compiler/compile-project.js +147 -0
  219. package/dist/compiler/compile-project.js.map +1 -0
  220. package/dist/compiler/compile-project.test.d.ts +1 -0
  221. package/dist/compiler/compile-project.test.d.ts.map +1 -0
  222. package/dist/compiler/compile-project.test.js +1709 -0
  223. package/dist/compiler/compile-project.test.js.map +1 -0
  224. package/dist/compiler/compile.bench.d.ts +1 -0
  225. package/dist/compiler/compile.bench.d.ts.map +1 -0
  226. package/dist/compiler/compile.bench.js +89 -0
  227. package/dist/compiler/compile.bench.js.map +1 -0
  228. package/dist/compiler/compile.d.ts +24 -0
  229. package/dist/compiler/compile.d.ts.map +1 -0
  230. package/dist/compiler/compile.js +106 -0
  231. package/dist/compiler/compile.js.map +1 -0
  232. package/dist/compiler/compile.test.d.ts +1 -0
  233. package/dist/compiler/compile.test.d.ts.map +1 -0
  234. package/dist/compiler/compile.test.js +66 -0
  235. package/dist/compiler/compile.test.js.map +1 -0
  236. package/dist/compiler/compiler-options.d.ts +466 -0
  237. package/dist/compiler/compiler-options.d.ts.map +1 -0
  238. package/dist/compiler/compiler-options.js +22 -0
  239. package/dist/compiler/compiler-options.js.map +1 -0
  240. package/dist/compiler/create-paraglide.d.ts +21 -0
  241. package/dist/compiler/create-paraglide.d.ts.map +1 -0
  242. package/dist/compiler/create-paraglide.js +69 -0
  243. package/dist/compiler/create-paraglide.js.map +1 -0
  244. package/dist/compiler/create-paraglide.test.d.ts +1 -0
  245. package/dist/compiler/create-paraglide.test.d.ts.map +1 -0
  246. package/dist/compiler/create-paraglide.test.js +55 -0
  247. package/dist/compiler/create-paraglide.test.js.map +1 -0
  248. package/dist/compiler/create-readme.d.ts +9 -0
  249. package/dist/compiler/create-readme.d.ts.map +1 -0
  250. package/dist/compiler/create-readme.js +127 -0
  251. package/dist/compiler/create-readme.js.map +1 -0
  252. package/dist/compiler/emit-files.d.ts +15 -0
  253. package/dist/compiler/emit-files.d.ts.map +1 -0
  254. package/dist/compiler/emit-files.js +58 -0
  255. package/dist/compiler/emit-files.js.map +1 -0
  256. package/dist/compiler/emit-files.test.d.ts +1 -0
  257. package/dist/compiler/emit-files.test.d.ts.map +1 -0
  258. package/dist/compiler/emit-files.test.js +43 -0
  259. package/dist/compiler/emit-files.test.js.map +1 -0
  260. package/dist/compiler/emit-ts-declarations.d.ts +11 -0
  261. package/dist/compiler/emit-ts-declarations.d.ts.map +1 -0
  262. package/dist/compiler/emit-ts-declarations.interop.test.d.ts +1 -0
  263. package/dist/compiler/emit-ts-declarations.interop.test.d.ts.map +1 -0
  264. package/dist/compiler/emit-ts-declarations.interop.test.js +33 -0
  265. package/dist/compiler/emit-ts-declarations.interop.test.js.map +1 -0
  266. package/dist/compiler/emit-ts-declarations.js +353 -0
  267. package/dist/compiler/emit-ts-declarations.js.map +1 -0
  268. package/dist/compiler/emit-ts-declarations.test.d.ts +1 -0
  269. package/dist/compiler/emit-ts-declarations.test.d.ts.map +1 -0
  270. package/dist/compiler/emit-ts-declarations.test.js +161 -0
  271. package/dist/compiler/emit-ts-declarations.test.js.map +1 -0
  272. package/dist/compiler/index.d.ts +13 -0
  273. package/dist/compiler/index.d.ts.map +1 -0
  274. package/dist/compiler/index.js +11 -0
  275. package/dist/compiler/index.js.map +1 -0
  276. package/dist/compiler/jsdoc-types.d.ts +21 -0
  277. package/dist/compiler/jsdoc-types.d.ts.map +1 -0
  278. package/dist/compiler/jsdoc-types.js +59 -0
  279. package/dist/compiler/jsdoc-types.js.map +1 -0
  280. package/dist/compiler/jsdoc-types.test.d.ts +1 -0
  281. package/dist/compiler/jsdoc-types.test.d.ts.map +1 -0
  282. package/dist/compiler/jsdoc-types.test.js +100 -0
  283. package/dist/compiler/jsdoc-types.test.js.map +1 -0
  284. package/dist/compiler/lazy-modules/compile-cache.d.ts +37 -0
  285. package/dist/compiler/lazy-modules/compile-cache.d.ts.map +1 -0
  286. package/dist/compiler/lazy-modules/compile-cache.js +34 -0
  287. package/dist/compiler/lazy-modules/compile-cache.js.map +1 -0
  288. package/dist/compiler/lazy-modules/compile-project.lazy.test.d.ts +2 -0
  289. package/dist/compiler/lazy-modules/compile-project.lazy.test.d.ts.map +1 -0
  290. package/dist/compiler/lazy-modules/compile-project.lazy.test.js +65 -0
  291. package/dist/compiler/lazy-modules/compile-project.lazy.test.js.map +1 -0
  292. package/dist/compiler/lazy-modules/create-loader.d.ts +18 -0
  293. package/dist/compiler/lazy-modules/create-loader.d.ts.map +1 -0
  294. package/dist/compiler/lazy-modules/create-loader.js +182 -0
  295. package/dist/compiler/lazy-modules/create-loader.js.map +1 -0
  296. package/dist/compiler/lazy-modules/create-loader.test.d.ts +2 -0
  297. package/dist/compiler/lazy-modules/create-loader.test.d.ts.map +1 -0
  298. package/dist/compiler/lazy-modules/create-loader.test.js +82 -0
  299. package/dist/compiler/lazy-modules/create-loader.test.js.map +1 -0
  300. package/dist/compiler/lazy-modules/manifest.d.ts +32 -0
  301. package/dist/compiler/lazy-modules/manifest.d.ts.map +1 -0
  302. package/dist/compiler/lazy-modules/manifest.js +11 -0
  303. package/dist/compiler/lazy-modules/manifest.js.map +1 -0
  304. package/dist/compiler/match-literals.d.ts +2 -0
  305. package/dist/compiler/match-literals.d.ts.map +1 -0
  306. package/dist/compiler/match-literals.js +42 -0
  307. package/dist/compiler/match-literals.js.map +1 -0
  308. package/dist/compiler/output-structure/lazy-modules.d.ts +27 -0
  309. package/dist/compiler/output-structure/lazy-modules.d.ts.map +1 -0
  310. package/dist/compiler/output-structure/lazy-modules.js +157 -0
  311. package/dist/compiler/output-structure/lazy-modules.js.map +1 -0
  312. package/dist/compiler/output-structure/lazy-modules.test.d.ts +2 -0
  313. package/dist/compiler/output-structure/lazy-modules.test.d.ts.map +1 -0
  314. package/dist/compiler/output-structure/lazy-modules.test.js +128 -0
  315. package/dist/compiler/output-structure/lazy-modules.test.js.map +1 -0
  316. package/dist/compiler/output-structure/locale-modules.d.ts +4 -0
  317. package/dist/compiler/output-structure/locale-modules.d.ts.map +1 -0
  318. package/dist/compiler/output-structure/locale-modules.js +81 -0
  319. package/dist/compiler/output-structure/locale-modules.js.map +1 -0
  320. package/dist/compiler/output-structure/locale-modules.test.d.ts +1 -0
  321. package/dist/compiler/output-structure/locale-modules.test.d.ts.map +1 -0
  322. package/dist/compiler/output-structure/locale-modules.test.js +163 -0
  323. package/dist/compiler/output-structure/locale-modules.test.js.map +1 -0
  324. package/dist/compiler/output-structure/message-modules.d.ts +4 -0
  325. package/dist/compiler/output-structure/message-modules.d.ts.map +1 -0
  326. package/dist/compiler/output-structure/message-modules.js +100 -0
  327. package/dist/compiler/output-structure/message-modules.js.map +1 -0
  328. package/dist/compiler/output-structure/message-modules.test.d.ts +1 -0
  329. package/dist/compiler/output-structure/message-modules.test.d.ts.map +1 -0
  330. package/dist/compiler/output-structure/message-modules.test.js +148 -0
  331. package/dist/compiler/output-structure/message-modules.test.js.map +1 -0
  332. package/dist/compiler/per-locale-build.d.ts +2 -0
  333. package/dist/compiler/per-locale-build.d.ts.map +1 -0
  334. package/dist/compiler/per-locale-build.js +3 -0
  335. package/dist/compiler/per-locale-build.js.map +1 -0
  336. package/dist/compiler/registry.d.ts +13 -0
  337. package/dist/compiler/registry.d.ts.map +1 -0
  338. package/dist/compiler/registry.js +60 -0
  339. package/dist/compiler/registry.js.map +1 -0
  340. package/dist/compiler/resolve-tsc-js-path.d.ts +9 -0
  341. package/dist/compiler/resolve-tsc-js-path.d.ts.map +1 -0
  342. package/dist/compiler/resolve-tsc-js-path.js +23 -0
  343. package/dist/compiler/resolve-tsc-js-path.js.map +1 -0
  344. package/dist/compiler/runtime/check-locale.d.ts +31 -0
  345. package/dist/compiler/runtime/check-locale.d.ts.map +1 -0
  346. package/dist/compiler/runtime/check-locale.js +51 -0
  347. package/dist/compiler/runtime/check-locale.js.map +1 -0
  348. package/dist/compiler/runtime/check-locale.test.d.ts +1 -0
  349. package/dist/compiler/runtime/check-locale.test.d.ts.map +1 -0
  350. package/dist/compiler/runtime/check-locale.test.js +84 -0
  351. package/dist/compiler/runtime/check-locale.test.js.map +1 -0
  352. package/dist/compiler/runtime/create-runtime.d.ts +35 -0
  353. package/dist/compiler/runtime/create-runtime.d.ts.map +1 -0
  354. package/dist/compiler/runtime/create-runtime.js +196 -0
  355. package/dist/compiler/runtime/create-runtime.js.map +1 -0
  356. package/dist/compiler/runtime/extract-locale-from-cookie.d.ts +13 -0
  357. package/dist/compiler/runtime/extract-locale-from-cookie.d.ts.map +1 -0
  358. package/dist/compiler/runtime/extract-locale-from-cookie.js +43 -0
  359. package/dist/compiler/runtime/extract-locale-from-cookie.js.map +1 -0
  360. package/dist/compiler/runtime/extract-locale-from-cookie.test.d.ts +1 -0
  361. package/dist/compiler/runtime/extract-locale-from-cookie.test.d.ts.map +1 -0
  362. package/dist/compiler/runtime/extract-locale-from-cookie.test.js +149 -0
  363. package/dist/compiler/runtime/extract-locale-from-cookie.test.js.map +1 -0
  364. package/dist/compiler/runtime/extract-locale-from-header.d.ts +13 -0
  365. package/dist/compiler/runtime/extract-locale-from-header.d.ts.map +1 -0
  366. package/dist/compiler/runtime/extract-locale-from-header.js +45 -0
  367. package/dist/compiler/runtime/extract-locale-from-header.js.map +1 -0
  368. package/dist/compiler/runtime/extract-locale-from-header.test.d.ts +1 -0
  369. package/dist/compiler/runtime/extract-locale-from-header.test.d.ts.map +1 -0
  370. package/dist/compiler/runtime/extract-locale-from-header.test.js +55 -0
  371. package/dist/compiler/runtime/extract-locale-from-header.test.js.map +1 -0
  372. package/dist/compiler/runtime/extract-locale-from-navigator.d.ts +12 -0
  373. package/dist/compiler/runtime/extract-locale-from-navigator.d.ts.map +1 -0
  374. package/dist/compiler/runtime/extract-locale-from-navigator.js +33 -0
  375. package/dist/compiler/runtime/extract-locale-from-navigator.js.map +1 -0
  376. package/dist/compiler/runtime/extract-locale-from-navigator.test.d.ts +1 -0
  377. package/dist/compiler/runtime/extract-locale-from-navigator.test.d.ts.map +1 -0
  378. package/dist/compiler/runtime/extract-locale-from-navigator.test.js +45 -0
  379. package/dist/compiler/runtime/extract-locale-from-navigator.test.js.map +1 -0
  380. package/dist/compiler/runtime/extract-locale-from-request-async.d.ts +34 -0
  381. package/dist/compiler/runtime/extract-locale-from-request-async.d.ts.map +1 -0
  382. package/dist/compiler/runtime/extract-locale-from-request-async.js +70 -0
  383. package/dist/compiler/runtime/extract-locale-from-request-async.js.map +1 -0
  384. package/dist/compiler/runtime/extract-locale-from-request-async.test.d.ts +1 -0
  385. package/dist/compiler/runtime/extract-locale-from-request-async.test.d.ts.map +1 -0
  386. package/dist/compiler/runtime/extract-locale-from-request-async.test.js +119 -0
  387. package/dist/compiler/runtime/extract-locale-from-request-async.test.js.map +1 -0
  388. package/dist/compiler/runtime/extract-locale-from-request.d.ts +41 -0
  389. package/dist/compiler/runtime/extract-locale-from-request.d.ts.map +1 -0
  390. package/dist/compiler/runtime/extract-locale-from-request.js +96 -0
  391. package/dist/compiler/runtime/extract-locale-from-request.js.map +1 -0
  392. package/dist/compiler/runtime/extract-locale-from-request.test.d.ts +1 -0
  393. package/dist/compiler/runtime/extract-locale-from-request.test.d.ts.map +1 -0
  394. package/dist/compiler/runtime/extract-locale-from-request.test.js +351 -0
  395. package/dist/compiler/runtime/extract-locale-from-request.test.js.map +1 -0
  396. package/dist/compiler/runtime/extract-locale-from-url.d.ts +11 -0
  397. package/dist/compiler/runtime/extract-locale-from-url.d.ts.map +1 -0
  398. package/dist/compiler/runtime/extract-locale-from-url.js +68 -0
  399. package/dist/compiler/runtime/extract-locale-from-url.js.map +1 -0
  400. package/dist/compiler/runtime/extract-locale-from-url.test.d.ts +1 -0
  401. package/dist/compiler/runtime/extract-locale-from-url.test.d.ts.map +1 -0
  402. package/dist/compiler/runtime/extract-locale-from-url.test.js +127 -0
  403. package/dist/compiler/runtime/extract-locale-from-url.test.js.map +1 -0
  404. package/dist/compiler/runtime/generate-static-localized-urls.d.ts +44 -0
  405. package/dist/compiler/runtime/generate-static-localized-urls.d.ts.map +1 -0
  406. package/dist/compiler/runtime/generate-static-localized-urls.js +133 -0
  407. package/dist/compiler/runtime/generate-static-localized-urls.js.map +1 -0
  408. package/dist/compiler/runtime/generate-static-localized-urls.test.d.ts +1 -0
  409. package/dist/compiler/runtime/generate-static-localized-urls.test.d.ts.map +1 -0
  410. package/dist/compiler/runtime/generate-static-localized-urls.test.js +159 -0
  411. package/dist/compiler/runtime/generate-static-localized-urls.test.js.map +1 -0
  412. package/dist/compiler/runtime/get-locale.d.ts +42 -0
  413. package/dist/compiler/runtime/get-locale.d.ts.map +1 -0
  414. package/dist/compiler/runtime/get-locale.js +158 -0
  415. package/dist/compiler/runtime/get-locale.js.map +1 -0
  416. package/dist/compiler/runtime/get-locale.test.d.ts +1 -0
  417. package/dist/compiler/runtime/get-locale.test.d.ts.map +1 -0
  418. package/dist/compiler/runtime/get-locale.test.js +295 -0
  419. package/dist/compiler/runtime/get-locale.test.js.map +1 -0
  420. package/dist/compiler/runtime/get-text-direction.d.ts +15 -0
  421. package/dist/compiler/runtime/get-text-direction.d.ts.map +1 -0
  422. package/dist/compiler/runtime/get-text-direction.js +46 -0
  423. package/dist/compiler/runtime/get-text-direction.js.map +1 -0
  424. package/dist/compiler/runtime/get-text-direction.test.d.ts +1 -0
  425. package/dist/compiler/runtime/get-text-direction.test.d.ts.map +1 -0
  426. package/dist/compiler/runtime/get-text-direction.test.js +40 -0
  427. package/dist/compiler/runtime/get-text-direction.test.js.map +1 -0
  428. package/dist/compiler/runtime/get-url-origin.d.ts +19 -0
  429. package/dist/compiler/runtime/get-url-origin.d.ts.map +1 -0
  430. package/dist/compiler/runtime/get-url-origin.js +31 -0
  431. package/dist/compiler/runtime/get-url-origin.js.map +1 -0
  432. package/dist/compiler/runtime/get-url-origin.test.d.ts +1 -0
  433. package/dist/compiler/runtime/get-url-origin.test.d.ts.map +1 -0
  434. package/dist/compiler/runtime/get-url-origin.test.js +18 -0
  435. package/dist/compiler/runtime/get-url-origin.test.js.map +1 -0
  436. package/dist/compiler/runtime/host-routing.d.ts +28 -0
  437. package/dist/compiler/runtime/host-routing.d.ts.map +1 -0
  438. package/dist/compiler/runtime/host-routing.js +79 -0
  439. package/dist/compiler/runtime/host-routing.js.map +1 -0
  440. package/dist/compiler/runtime/host-routing.test.d.ts +1 -0
  441. package/dist/compiler/runtime/host-routing.test.d.ts.map +1 -0
  442. package/dist/compiler/runtime/host-routing.test.js +128 -0
  443. package/dist/compiler/runtime/host-routing.test.js.map +1 -0
  444. package/dist/compiler/runtime/localize-href.d.ts +84 -0
  445. package/dist/compiler/runtime/localize-href.d.ts.map +1 -0
  446. package/dist/compiler/runtime/localize-href.js +115 -0
  447. package/dist/compiler/runtime/localize-href.js.map +1 -0
  448. package/dist/compiler/runtime/localize-href.test.d.ts +1 -0
  449. package/dist/compiler/runtime/localize-href.test.d.ts.map +1 -0
  450. package/dist/compiler/runtime/localize-href.test.js +139 -0
  451. package/dist/compiler/runtime/localize-href.test.js.map +1 -0
  452. package/dist/compiler/runtime/localize-url.d.ts +95 -0
  453. package/dist/compiler/runtime/localize-url.d.ts.map +1 -0
  454. package/dist/compiler/runtime/localize-url.js +327 -0
  455. package/dist/compiler/runtime/localize-url.js.map +1 -0
  456. package/dist/compiler/runtime/localize-url.test.d.ts +1 -0
  457. package/dist/compiler/runtime/localize-url.test.d.ts.map +1 -0
  458. package/dist/compiler/runtime/localize-url.test.js +533 -0
  459. package/dist/compiler/runtime/localize-url.test.js.map +1 -0
  460. package/dist/compiler/runtime/route-strategy.d.ts +32 -0
  461. package/dist/compiler/runtime/route-strategy.d.ts.map +1 -0
  462. package/dist/compiler/runtime/route-strategy.js +72 -0
  463. package/dist/compiler/runtime/route-strategy.js.map +1 -0
  464. package/dist/compiler/runtime/set-locale.d.ts +46 -0
  465. package/dist/compiler/runtime/set-locale.d.ts.map +1 -0
  466. package/dist/compiler/runtime/set-locale.js +172 -0
  467. package/dist/compiler/runtime/set-locale.js.map +1 -0
  468. package/dist/compiler/runtime/set-locale.test.d.ts +1 -0
  469. package/dist/compiler/runtime/set-locale.test.d.ts.map +1 -0
  470. package/dist/compiler/runtime/set-locale.test.js +555 -0
  471. package/dist/compiler/runtime/set-locale.test.js.map +1 -0
  472. package/dist/compiler/runtime/should-redirect.d.ts +100 -0
  473. package/dist/compiler/runtime/should-redirect.d.ts.map +1 -0
  474. package/dist/compiler/runtime/should-redirect.js +155 -0
  475. package/dist/compiler/runtime/should-redirect.js.map +1 -0
  476. package/dist/compiler/runtime/should-redirect.test.d.ts +1 -0
  477. package/dist/compiler/runtime/should-redirect.test.d.ts.map +1 -0
  478. package/dist/compiler/runtime/should-redirect.test.js +270 -0
  479. package/dist/compiler/runtime/should-redirect.test.js.map +1 -0
  480. package/dist/compiler/runtime/strategy.d.ts +63 -0
  481. package/dist/compiler/runtime/strategy.d.ts.map +1 -0
  482. package/dist/compiler/runtime/strategy.js +65 -0
  483. package/dist/compiler/runtime/strategy.js.map +1 -0
  484. package/dist/compiler/runtime/strategy.test.d.ts +1 -0
  485. package/dist/compiler/runtime/strategy.test.d.ts.map +1 -0
  486. package/dist/compiler/runtime/strategy.test.js +90 -0
  487. package/dist/compiler/runtime/strategy.test.js.map +1 -0
  488. package/dist/compiler/runtime/track-message-call.d.ts +5 -0
  489. package/dist/compiler/runtime/track-message-call.d.ts.map +1 -0
  490. package/dist/compiler/runtime/track-message-call.js +14 -0
  491. package/dist/compiler/runtime/track-message-call.js.map +1 -0
  492. package/dist/compiler/runtime/track-message-call.test.d.ts +1 -0
  493. package/dist/compiler/runtime/track-message-call.test.d.ts.map +1 -0
  494. package/dist/compiler/runtime/track-message-call.test.js +22 -0
  495. package/dist/compiler/runtime/track-message-call.test.js.map +1 -0
  496. package/dist/compiler/runtime/type-definitions.d.ts +197 -0
  497. package/dist/compiler/runtime/type-definitions.d.ts.map +1 -0
  498. package/dist/compiler/runtime/type-definitions.js +150 -0
  499. package/dist/compiler/runtime/type-definitions.js.map +1 -0
  500. package/dist/compiler/runtime/type.d.ts +47 -0
  501. package/dist/compiler/runtime/type.d.ts.map +1 -0
  502. package/dist/compiler/runtime/type.js +2 -0
  503. package/dist/compiler/runtime/type.js.map +1 -0
  504. package/dist/compiler/runtime/type.test.d.ts +1 -0
  505. package/dist/compiler/runtime/type.test.d.ts.map +1 -0
  506. package/dist/compiler/runtime/type.test.js +153 -0
  507. package/dist/compiler/runtime/type.test.js.map +1 -0
  508. package/dist/compiler/runtime/url-pattern.d.ts +12 -0
  509. package/dist/compiler/runtime/url-pattern.d.ts.map +1 -0
  510. package/dist/compiler/runtime/url-pattern.js +35 -0
  511. package/dist/compiler/runtime/url-pattern.js.map +1 -0
  512. package/dist/compiler/runtime/variables.d.ts +128 -0
  513. package/dist/compiler/runtime/variables.d.ts.map +1 -0
  514. package/dist/compiler/runtime/variables.js +111 -0
  515. package/dist/compiler/runtime/variables.js.map +1 -0
  516. package/dist/compiler/safe-module-id.d.ts +7 -0
  517. package/dist/compiler/safe-module-id.d.ts.map +1 -0
  518. package/dist/compiler/safe-module-id.js +78 -0
  519. package/dist/compiler/safe-module-id.js.map +1 -0
  520. package/dist/compiler/safe-module-id.test.d.ts +1 -0
  521. package/dist/compiler/safe-module-id.test.d.ts.map +1 -0
  522. package/dist/compiler/safe-module-id.test.js +36 -0
  523. package/dist/compiler/safe-module-id.test.js.map +1 -0
  524. package/dist/compiler/seed-previous-compilation.d.ts +7 -0
  525. package/dist/compiler/seed-previous-compilation.d.ts.map +1 -0
  526. package/dist/compiler/seed-previous-compilation.js +9 -0
  527. package/dist/compiler/seed-previous-compilation.js.map +1 -0
  528. package/dist/compiler/server/create-server-file.d.ts +12 -0
  529. package/dist/compiler/server/create-server-file.d.ts.map +1 -0
  530. package/dist/compiler/server/create-server-file.js +91 -0
  531. package/dist/compiler/server/create-server-file.js.map +1 -0
  532. package/dist/compiler/server/create-server-file.test.d.ts +1 -0
  533. package/dist/compiler/server/create-server-file.test.d.ts.map +1 -0
  534. package/dist/compiler/server/create-server-file.test.js +48 -0
  535. package/dist/compiler/server/create-server-file.test.js.map +1 -0
  536. package/dist/compiler/server/middleware.d.ts +98 -0
  537. package/dist/compiler/server/middleware.d.ts.map +1 -0
  538. package/dist/compiler/server/middleware.js +278 -0
  539. package/dist/compiler/server/middleware.js.map +1 -0
  540. package/dist/compiler/server/middleware.test.d.ts +1 -0
  541. package/dist/compiler/server/middleware.test.d.ts.map +1 -0
  542. package/dist/compiler/server/middleware.test.js +1001 -0
  543. package/dist/compiler/server/middleware.test.js.map +1 -0
  544. package/dist/compiler/server/type.d.ts +6 -0
  545. package/dist/compiler/server/type.d.ts.map +1 -0
  546. package/dist/compiler/server/type.js +2 -0
  547. package/dist/compiler/server/type.js.map +1 -0
  548. package/dist/compiler/test-helpers.d.ts +30 -0
  549. package/dist/compiler/test-helpers.d.ts.map +1 -0
  550. package/dist/compiler/test-helpers.js +50 -0
  551. package/dist/compiler/test-helpers.js.map +1 -0
  552. package/dist/compiler/types.d.ts +7 -0
  553. package/dist/compiler/types.d.ts.map +1 -0
  554. package/dist/compiler/types.js +2 -0
  555. package/dist/compiler/types.js.map +1 -0
  556. package/dist/compiler/variable-access.d.ts +3 -0
  557. package/dist/compiler/variable-access.d.ts.map +1 -0
  558. package/dist/compiler/variable-access.js +15 -0
  559. package/dist/compiler/variable-access.js.map +1 -0
  560. package/dist/index.d.ts +2 -0
  561. package/dist/index.d.ts.map +1 -0
  562. package/dist/index.js +3 -0
  563. package/dist/index.js.map +1 -0
  564. package/dist/messages/ast.d.ts +102 -0
  565. package/dist/messages/ast.d.ts.map +1 -0
  566. package/dist/messages/ast.js +8 -0
  567. package/dist/messages/ast.js.map +1 -0
  568. package/dist/messages/create-bundle-nested.d.ts +16 -0
  569. package/dist/messages/create-bundle-nested.d.ts.map +1 -0
  570. package/dist/messages/create-bundle-nested.js +22 -0
  571. package/dist/messages/create-bundle-nested.js.map +1 -0
  572. package/dist/messages/index.d.ts +5 -0
  573. package/dist/messages/index.d.ts.map +1 -0
  574. package/dist/messages/index.js +5 -0
  575. package/dist/messages/index.js.map +1 -0
  576. package/dist/messages/load-messages.d.ts +19 -0
  577. package/dist/messages/load-messages.d.ts.map +1 -0
  578. package/dist/messages/load-messages.js +49 -0
  579. package/dist/messages/load-messages.js.map +1 -0
  580. package/dist/messages/message-format/flatten.d.ts +9 -0
  581. package/dist/messages/message-format/flatten.d.ts.map +1 -0
  582. package/dist/messages/message-format/flatten.js +32 -0
  583. package/dist/messages/message-format/flatten.js.map +1 -0
  584. package/dist/messages/message-format/import-files.d.ts +32 -0
  585. package/dist/messages/message-format/import-files.d.ts.map +1 -0
  586. package/dist/messages/message-format/import-files.js +53 -0
  587. package/dist/messages/message-format/import-files.js.map +1 -0
  588. package/dist/messages/message-format/import-files.test.d.ts +1 -0
  589. package/dist/messages/message-format/import-files.test.d.ts.map +1 -0
  590. package/dist/messages/message-format/import-files.test.js +145 -0
  591. package/dist/messages/message-format/import-files.test.js.map +1 -0
  592. package/dist/messages/message-format/index.d.ts +6 -0
  593. package/dist/messages/message-format/index.d.ts.map +1 -0
  594. package/dist/messages/message-format/index.js +7 -0
  595. package/dist/messages/message-format/index.js.map +1 -0
  596. package/dist/messages/message-format/parse-bundle.d.ts +31 -0
  597. package/dist/messages/message-format/parse-bundle.d.ts.map +1 -0
  598. package/dist/messages/message-format/parse-bundle.js +169 -0
  599. package/dist/messages/message-format/parse-bundle.js.map +1 -0
  600. package/dist/messages/message-format/parse-declaration.d.ts +2 -0
  601. package/dist/messages/message-format/parse-declaration.d.ts.map +1 -0
  602. package/dist/messages/message-format/parse-declaration.js +56 -0
  603. package/dist/messages/message-format/parse-declaration.js.map +1 -0
  604. package/dist/messages/message-format/parse-markup.d.ts +4 -0
  605. package/dist/messages/message-format/parse-markup.d.ts.map +1 -0
  606. package/dist/messages/message-format/parse-markup.js +167 -0
  607. package/dist/messages/message-format/parse-markup.js.map +1 -0
  608. package/dist/messages/message-format/parse-matches.d.ts +5 -0
  609. package/dist/messages/message-format/parse-matches.d.ts.map +1 -0
  610. package/dist/messages/message-format/parse-matches.js +31 -0
  611. package/dist/messages/message-format/parse-matches.js.map +1 -0
  612. package/dist/messages/message-format/parse-pattern.d.ts +5 -0
  613. package/dist/messages/message-format/parse-pattern.d.ts.map +1 -0
  614. package/dist/messages/message-format/parse-pattern.js +120 -0
  615. package/dist/messages/message-format/parse-pattern.js.map +1 -0
  616. package/dist/messages/message-format/unique.d.ts +2 -0
  617. package/dist/messages/message-format/unique.d.ts.map +1 -0
  618. package/dist/messages/message-format/unique.js +5 -0
  619. package/dist/messages/message-format/unique.js.map +1 -0
  620. package/dist/messages/nest-bundles.d.ts +19 -0
  621. package/dist/messages/nest-bundles.d.ts.map +1 -0
  622. package/dist/messages/nest-bundles.js +49 -0
  623. package/dist/messages/nest-bundles.js.map +1 -0
  624. package/dist/services/account/index.d.ts +14 -0
  625. package/dist/services/account/index.d.ts.map +1 -0
  626. package/dist/services/account/index.js +43 -0
  627. package/dist/services/account/index.js.map +1 -0
  628. package/dist/services/account/types.d.ts +4 -0
  629. package/dist/services/account/types.d.ts.map +1 -0
  630. package/dist/services/account/types.js +2 -0
  631. package/dist/services/account/types.js.map +1 -0
  632. package/dist/services/codegen/escape.d.ts +9 -0
  633. package/dist/services/codegen/escape.d.ts.map +1 -0
  634. package/dist/services/codegen/escape.js +19 -0
  635. package/dist/services/codegen/escape.js.map +1 -0
  636. package/dist/services/codegen/quotes.d.ts +4 -0
  637. package/dist/services/codegen/quotes.d.ts.map +1 -0
  638. package/dist/services/codegen/quotes.js +5 -0
  639. package/dist/services/codegen/quotes.js.map +1 -0
  640. package/dist/services/env-variables/create-index-file.d.ts +9 -0
  641. package/dist/services/env-variables/create-index-file.d.ts.map +1 -0
  642. package/dist/services/env-variables/create-index-file.js +28 -0
  643. package/dist/services/env-variables/create-index-file.js.map +1 -0
  644. package/dist/services/env-variables/index.d.ts +3 -0
  645. package/dist/services/env-variables/index.d.ts.map +1 -0
  646. package/dist/services/env-variables/index.js +4 -0
  647. package/dist/services/env-variables/index.js.map +1 -0
  648. package/dist/services/environment/package.d.ts +9 -0
  649. package/dist/services/environment/package.d.ts.map +1 -0
  650. package/dist/services/environment/package.js +31 -0
  651. package/dist/services/environment/package.js.map +1 -0
  652. package/dist/services/environment/package.test.d.ts +1 -0
  653. package/dist/services/environment/package.test.d.ts.map +1 -0
  654. package/dist/services/environment/package.test.js +21 -0
  655. package/dist/services/environment/package.test.js.map +1 -0
  656. package/dist/services/error-handling.d.ts +12 -0
  657. package/dist/services/error-handling.d.ts.map +1 -0
  658. package/dist/services/error-handling.js +27 -0
  659. package/dist/services/error-handling.js.map +1 -0
  660. package/dist/services/error-handling.test.d.ts +1 -0
  661. package/dist/services/error-handling.test.d.ts.map +1 -0
  662. package/dist/services/error-handling.test.js +10 -0
  663. package/dist/services/error-handling.test.js.map +1 -0
  664. package/dist/services/file-handling/content-hash.d.ts +9 -0
  665. package/dist/services/file-handling/content-hash.js +19 -0
  666. package/dist/services/file-handling/content-hash.js.map +1 -0
  667. package/dist/services/file-handling/exists.d.ts +7 -0
  668. package/dist/services/file-handling/exists.d.ts.map +1 -0
  669. package/dist/services/file-handling/exists.js +24 -0
  670. package/dist/services/file-handling/exists.js.map +1 -0
  671. package/dist/services/file-handling/exists.test.d.ts +1 -0
  672. package/dist/services/file-handling/exists.test.d.ts.map +1 -0
  673. package/dist/services/file-handling/exists.test.js +27 -0
  674. package/dist/services/file-handling/exists.test.js.map +1 -0
  675. package/dist/services/file-handling/types.d.ts +4 -0
  676. package/dist/services/file-handling/types.d.ts.map +1 -0
  677. package/dist/services/file-handling/types.js +2 -0
  678. package/dist/services/file-handling/types.js.map +1 -0
  679. package/dist/services/file-handling/write-output.d.ts +21 -0
  680. package/dist/services/file-handling/write-output.d.ts.map +1 -0
  681. package/dist/services/file-handling/write-output.js +157 -0
  682. package/dist/services/file-handling/write-output.js.map +1 -0
  683. package/dist/services/file-handling/write-output.test.d.ts +1 -0
  684. package/dist/services/file-handling/write-output.test.d.ts.map +1 -0
  685. package/dist/services/file-handling/write-output.test.js +217 -0
  686. package/dist/services/file-handling/write-output.test.js.map +1 -0
  687. package/dist/services/file-watching/tracked-fs.d.ts +25 -0
  688. package/dist/services/file-watching/tracked-fs.d.ts.map +1 -0
  689. package/dist/services/file-watching/tracked-fs.js +94 -0
  690. package/dist/services/file-watching/tracked-fs.js.map +1 -0
  691. package/dist/services/file-watching/tracked-fs.test.d.ts +1 -0
  692. package/dist/services/file-watching/tracked-fs.test.d.ts.map +1 -0
  693. package/dist/services/file-watching/tracked-fs.test.js +87 -0
  694. package/dist/services/file-watching/tracked-fs.test.js.map +1 -0
  695. package/dist/services/logger/index.d.ts +17 -0
  696. package/dist/services/logger/index.d.ts.map +1 -0
  697. package/dist/services/logger/index.js +58 -0
  698. package/dist/services/logger/index.js.map +1 -0
  699. package/dist/services/lookup.d.ts +14 -0
  700. package/dist/services/lookup.d.ts.map +1 -0
  701. package/dist/services/lookup.js +24 -0
  702. package/dist/services/lookup.js.map +1 -0
  703. package/dist/urlpattern-polyfill/index.d.ts +2 -0
  704. package/dist/urlpattern-polyfill/index.d.ts.map +1 -0
  705. package/dist/urlpattern-polyfill/index.js +2 -0
  706. package/dist/urlpattern-polyfill/index.js.map +1 -0
  707. package/dist/utilities/detect-json-formatting.d.ts +10 -0
  708. package/dist/utilities/detect-json-formatting.d.ts.map +1 -0
  709. package/dist/utilities/detect-json-formatting.js +80 -0
  710. package/dist/utilities/detect-json-formatting.js.map +1 -0
  711. package/dist/utilities/node-normalize-path.d.ts +1 -0
  712. package/dist/utilities/node-normalize-path.d.ts.map +1 -0
  713. package/dist/utilities/node-normalize-path.js +10 -0
  714. package/dist/utilities/node-normalize-path.js.map +1 -0
  715. package/package.json +87 -0
@@ -0,0 +1,62 @@
1
+ import { PLUGIN_NAME, compileFromBuildStart, compileFromWatchChange, getPluginState, loadVirtualModule, resolveVirtualModuleId, setIsServerExpression, } from "./plugin-core.js";
2
+ export const unpluginFactory = (args) => {
3
+ const state = getPluginState(args);
4
+ return {
5
+ name: PLUGIN_NAME,
6
+ enforce: "pre",
7
+ async buildStart() {
8
+ await compileFromBuildStart({
9
+ compilerOptions: args,
10
+ state,
11
+ addWatchFile: (id) => this.addWatchFile(id),
12
+ });
13
+ },
14
+ async watchChange(changedPath) {
15
+ await compileFromWatchChange({
16
+ compilerOptions: args,
17
+ state,
18
+ changedPath,
19
+ addWatchFile: (id) => this.addWatchFile(id),
20
+ });
21
+ },
22
+ resolveId(id, importer) {
23
+ return resolveVirtualModuleId({ id, importer, state });
24
+ },
25
+ load(id) {
26
+ return loadVirtualModule(id, state);
27
+ },
28
+ vite: {
29
+ config: {
30
+ handler: () => {
31
+ setIsServerExpression("import.meta.env?.SSR ?? typeof window === 'undefined'");
32
+ },
33
+ },
34
+ configEnvironment: {
35
+ handler: () => {
36
+ setIsServerExpression("import.meta.env?.SSR ?? typeof window === 'undefined'");
37
+ },
38
+ },
39
+ },
40
+ webpack(compiler) {
41
+ compiler.options.resolve = {
42
+ ...compiler.options.resolve,
43
+ fallback: {
44
+ ...compiler.options.resolve?.fallback,
45
+ // https://stackoverflow.com/a/72989932
46
+ async_hooks: false,
47
+ "node:async_hooks": false,
48
+ },
49
+ };
50
+ compiler.hooks.beforeRun.tapPromise(PLUGIN_NAME, async () => {
51
+ await compileFromBuildStart({
52
+ compilerOptions: args,
53
+ state,
54
+ // webpack cannot load virtual JS modules reliably — always emit
55
+ forceEmitFiles: true,
56
+ addWatchFile: () => { },
57
+ });
58
+ });
59
+ },
60
+ };
61
+ };
62
+ //# sourceMappingURL=unplugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unplugin.js","sourceRoot":"","sources":["../../src/bundler-plugins/unplugin.ts"],"names":[],"mappings":"AAEA,OAAO,EACN,WAAW,EACX,qBAAqB,EACrB,sBAAsB,EACtB,cAAc,EACd,iBAAiB,EACjB,sBAAsB,EACtB,qBAAqB,GACrB,MAAM,kBAAkB,CAAC;AAE1B,MAAM,CAAC,MAAM,eAAe,GAAqC,CAAC,IAAI,EAAE,EAAE;IACzE,MAAM,KAAK,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC;IACnC,OAAO;QACN,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE,KAAK;QACd,KAAK,CAAC,UAAU;YACf,MAAM,qBAAqB,CAAC;gBAC3B,eAAe,EAAE,IAAI;gBACrB,KAAK;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BACL,gEAAgE;oBAChE,cAAc,EAAE,IAAI;oBACpB,YAAY,EAAE,GAAG,EAAE,GAAE,CAAC;iBACtB,CAAC,CAAC;YACJ,CAAC,CAAC,CAAC;QACJ,CAAC;KACD,CAAC;AACH,CAAC,CAAC","sourcesContent":["import type { UnpluginFactory } from \"unplugin\";\nimport type { CompilerOptions } from \"../compiler/compiler-options.js\";\nimport {\n\tPLUGIN_NAME,\n\tcompileFromBuildStart,\n\tcompileFromWatchChange,\n\tgetPluginState,\n\tloadVirtualModule,\n\tresolveVirtualModuleId,\n\tsetIsServerExpression,\n} from \"./plugin-core.js\";\n\nexport const unpluginFactory: UnpluginFactory<CompilerOptions> = (args) => {\n\tconst state = getPluginState(args);\n\treturn {\n\t\tname: PLUGIN_NAME,\n\t\tenforce: \"pre\",\n\t\tasync buildStart() {\n\t\t\tawait compileFromBuildStart({\n\t\t\t\tcompilerOptions: args,\n\t\t\t\tstate,\n\t\t\t\taddWatchFile: (id) => this.addWatchFile(id),\n\t\t\t});\n\t\t},\n\t\tasync watchChange(changedPath) {\n\t\t\tawait compileFromWatchChange({\n\t\t\t\tcompilerOptions: args,\n\t\t\t\tstate,\n\t\t\t\tchangedPath,\n\t\t\t\taddWatchFile: (id) => this.addWatchFile(id),\n\t\t\t});\n\t\t},\n\t\tresolveId(id, importer) {\n\t\t\treturn resolveVirtualModuleId({ id, importer, state });\n\t\t},\n\t\tload(id) {\n\t\t\treturn loadVirtualModule(id, state);\n\t\t},\n\t\tvite: {\n\t\t\tconfig: {\n\t\t\t\thandler: () => {\n\t\t\t\t\tsetIsServerExpression(\n\t\t\t\t\t\t\"import.meta.env?.SSR ?? typeof window === 'undefined'\"\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t},\n\t\t\tconfigEnvironment: {\n\t\t\t\thandler: () => {\n\t\t\t\t\tsetIsServerExpression(\n\t\t\t\t\t\t\"import.meta.env?.SSR ?? typeof window === 'undefined'\"\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\twebpack(compiler) {\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\t\"node:async_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\tawait compileFromBuildStart({\n\t\t\t\t\tcompilerOptions: args,\n\t\t\t\t\tstate,\n\t\t\t\t\t// webpack cannot load virtual JS modules reliably — always emit\n\t\t\t\t\tforceEmitFiles: true,\n\t\t\t\t\taddWatchFile: () => {},\n\t\t\t\t});\n\t\t\t});\n\t\t},\n\t};\n};\n"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unplugin.test.d.ts","sourceRoot":"","sources":["../../src/bundler-plugins/unplugin.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,256 @@
1
+ import { test, expect, beforeEach, afterEach, vi } from "vitest";
2
+ import consola from "consola";
3
+ import path from "node:path";
4
+ import { memfs } from "memfs";
5
+ import { createPluginTestFs, defaultPluginCompileOptions, testMessageFilePath } from "../compiler/test-helpers.js";
6
+ let originalNodeEnv;
7
+ beforeEach(() => {
8
+ originalNodeEnv = process.env.NODE_ENV;
9
+ // Reset module state between tests so the module-scoped
10
+ // `previousCompilation` doesn't leak across tests.
11
+ vi.resetModules();
12
+ // Mock logging methods to suppress error messages in tests
13
+ consola.mockTypes(() => vi.fn());
14
+ });
15
+ afterEach(() => {
16
+ if (originalNodeEnv !== undefined) {
17
+ process.env.NODE_ENV = originalNodeEnv;
18
+ }
19
+ else {
20
+ delete process.env.NODE_ENV;
21
+ }
22
+ });
23
+ test("vite plugin does not throw when compilation is successful", async () => {
24
+ // Dynamic import so beforeEach's vi.resetModules() yields a fresh module
25
+ // (a static import would share module state across tests).
26
+ const { paraglideVitePlugin } = await import("../bundler-plugins/vite.js");
27
+ // Create and save a viable project to the virtual file system
28
+ const fs = createPluginTestFs();
29
+ const plugin = paraglideVitePlugin({
30
+ ...defaultPluginCompileOptions,
31
+ outdir: "/test-output",
32
+ fs: fs,
33
+ });
34
+ const mockContext = {
35
+ addWatchFile: () => { },
36
+ };
37
+ await expect(plugin.buildStart?.call(mockContext)).resolves.toBeUndefined();
38
+ });
39
+ test("vite plugin does not throw on compilation errors in development", async () => {
40
+ const { paraglideVitePlugin } = await import("../bundler-plugins/vite.js");
41
+ process.env.NODE_ENV = "development";
42
+ // Use memfs with no project (simulates missing project)
43
+ const fs = memfs().fs;
44
+ const plugin = paraglideVitePlugin({
45
+ messages: "./missing/{locale}.json", locales: ["en"], baseLocale: "en",
46
+ outdir: "/test-output",
47
+ fs: fs,
48
+ });
49
+ const mockContext = {
50
+ addWatchFile: () => { },
51
+ };
52
+ // In development mode - should catch errors and NOT throw
53
+ await expect(plugin.buildStart?.call(mockContext)).resolves.toBeUndefined();
54
+ });
55
+ test("vite plugin throws on compilation errors at build time", async () => {
56
+ const { paraglideVitePlugin } = await import("../bundler-plugins/vite.js");
57
+ process.env.NODE_ENV = "production";
58
+ // Use memfs with no project (simulates missing project)
59
+ const fs = memfs().fs;
60
+ const plugin = paraglideVitePlugin({
61
+ messages: "./missing/{locale}.json", locales: ["en"], baseLocale: "en",
62
+ outdir: "/test-output",
63
+ fs: fs,
64
+ });
65
+ const mockContext = {
66
+ addWatchFile: () => { },
67
+ };
68
+ // In production mode - should throw the error
69
+ await expect(plugin.buildStart?.call(mockContext)).rejects.toThrow();
70
+ });
71
+ // Regression test for https://github.com/opral/inlang-paraglide-js/issues/659:
72
+ // the bundler plugins used to wipe `outdir` on every fresh process, racing
73
+ // concurrent reads (SSR/prerender modules, sibling Vite processes, the
74
+ // config-watcher reload) and producing ENOENT/MISSING_EXPORT/ERR_LOAD_URL.
75
+ test("vite plugin does not wipe outdir during first buildStart (#659)", async () => {
76
+ const { paraglideVitePlugin: vitePlugin } = await import("../bundler-plugins/vite.js");
77
+ const fs = createPluginTestFs();
78
+ // Pre-seed outdir with a sentinel file mimicking a prior compilation
79
+ // still on disk from an earlier process.
80
+ await fs.promises.mkdir("/test-output", { recursive: true });
81
+ await fs.promises.writeFile("/test-output/__sentinel__.txt", "kept");
82
+ const rmSpy = vi.spyOn(fs.promises, "rm");
83
+ const plugin = vitePlugin({
84
+ ...defaultPluginCompileOptions,
85
+ outdir: "/test-output",
86
+ cleanOutdir: true,
87
+ fs: fs,
88
+ });
89
+ const mockContext = { addWatchFile: () => { } };
90
+ await plugin.buildStart?.call(mockContext);
91
+ // The plugin must not recursively remove the outdir during the first
92
+ // compile, even though previousCompilation is undefined. Concurrent
93
+ // readers may be holding file handles into outdir.
94
+ for (const call of rmSpy.mock.calls) {
95
+ expect(call[0]).not.toBe("/test-output");
96
+ }
97
+ });
98
+ test("vite plugin warm-restart writes nothing when inputs unchanged (#659)", async () => {
99
+ const fs = createPluginTestFs();
100
+ const mockContext = { addWatchFile: () => { } };
101
+ // First process: compile and persist files to outdir.
102
+ {
103
+ const { paraglideVitePlugin: vitePlugin } = await import("../bundler-plugins/vite.js");
104
+ const plugin = vitePlugin({
105
+ ...defaultPluginCompileOptions,
106
+ outdir: "/test-output",
107
+ fs: fs,
108
+ });
109
+ await plugin.buildStart?.call(mockContext);
110
+ }
111
+ // Second process: simulate a fresh node process by resetting modules so
112
+ // the module-scoped `previousCompilation` is undefined again. The plugin
113
+ // should seed from on-disk hashes and write zero files (no race window).
114
+ vi.resetModules();
115
+ const { paraglideVitePlugin: vitePluginFresh } = await import("../bundler-plugins/vite.js");
116
+ const plugin2 = vitePluginFresh({
117
+ ...defaultPluginCompileOptions,
118
+ outdir: "/test-output",
119
+ fs: fs,
120
+ });
121
+ const writeFileSpy = vi.spyOn(fs.promises, "writeFile");
122
+ await plugin2.buildStart?.call(mockContext);
123
+ expect(writeFileSpy).not.toHaveBeenCalled();
124
+ });
125
+ // Regression test for https://github.com/opral/paraglide-js/issues/693:
126
+ // `vite build` fires buildStart once per environment (client, ssr) and each
127
+ // run used to do a full compile() — project loading + message compilation —
128
+ // even though the inputs hadn't changed.
129
+ test("vite plugin skips compile() when buildStart fires again with unchanged inputs (#693)", async () => {
130
+ const actualCompileModule = await vi.importActual("../compiler/compile.js");
131
+ const compileSpy = vi.fn(actualCompileModule.compile);
132
+ vi.doMock("../compiler/compile.js", () => ({
133
+ ...actualCompileModule,
134
+ compile: compileSpy,
135
+ }));
136
+ try {
137
+ const { paraglideVitePlugin: vitePlugin } = await import("../bundler-plugins/vite.js");
138
+ const fs = createPluginTestFs();
139
+ const plugin = vitePlugin({
140
+ ...defaultPluginCompileOptions,
141
+ outdir: "/test-output",
142
+ fs: fs,
143
+ });
144
+ const mockContext = { addWatchFile: () => { } };
145
+ // First environment (e.g. client) compiles.
146
+ await plugin.buildStart?.call(mockContext);
147
+ expect(compileSpy).toHaveBeenCalledTimes(1);
148
+ // Second environment (e.g. ssr) — inputs unchanged, compile skipped.
149
+ await plugin.buildStart?.call(mockContext);
150
+ expect(compileSpy).toHaveBeenCalledTimes(1);
151
+ // Changing a message file invalidates the digest and recompiles.
152
+ const messagePath = testMessageFilePath("en");
153
+ const messages = JSON.parse(await fs.promises.readFile(messagePath, "utf-8"));
154
+ messages.changed = "trigger recompile";
155
+ await fs.promises.writeFile(messagePath, JSON.stringify(messages));
156
+ await plugin.buildStart?.call(mockContext);
157
+ expect(compileSpy).toHaveBeenCalledTimes(2);
158
+ }
159
+ finally {
160
+ vi.doUnmock("../compiler/compile.js");
161
+ }
162
+ });
163
+ // A new file added next to tracked inputs must invalidate the digest via
164
+ // the directory-listing part of the hash, not only edits to known files.
165
+ test("vite plugin recompiles when a file is added to a tracked directory (#693)", async () => {
166
+ const actualCompileModule = await vi.importActual("../compiler/compile.js");
167
+ const compileSpy = vi.fn(actualCompileModule.compile);
168
+ vi.doMock("../compiler/compile.js", () => ({
169
+ ...actualCompileModule,
170
+ compile: compileSpy,
171
+ }));
172
+ try {
173
+ const { paraglideVitePlugin: vitePlugin } = await import("../bundler-plugins/vite.js");
174
+ const fs = createPluginTestFs();
175
+ const plugin = vitePlugin({
176
+ ...defaultPluginCompileOptions,
177
+ outdir: "/test-output",
178
+ fs: fs,
179
+ });
180
+ const mockContext = { addWatchFile: () => { } };
181
+ await plugin.buildStart?.call(mockContext);
182
+ await plugin.buildStart?.call(mockContext);
183
+ expect(compileSpy).toHaveBeenCalledTimes(1);
184
+ // No tracked file changed, but the listing of a tracked directory did.
185
+ await fs.promises.writeFile(path.join(path.dirname(testMessageFilePath("en")), "added-later.txt"), "new");
186
+ await plugin.buildStart?.call(mockContext);
187
+ expect(compileSpy).toHaveBeenCalledTimes(2);
188
+ }
189
+ finally {
190
+ vi.doUnmock("../compiler/compile.js");
191
+ }
192
+ });
193
+ // After a failed compile the stored digest must not be reused: restoring an
194
+ // input to its previous content has to trigger a real recompile, because the
195
+ // failed attempt may have left no (or partial) output.
196
+ test("vite plugin does not reuse a digest from before a failed compile (#693)", async () => {
197
+ process.env.NODE_ENV = "development";
198
+ const actualCompileModule = await vi.importActual("../compiler/compile.js");
199
+ const compileSpy = vi.fn(actualCompileModule.compile);
200
+ vi.doMock("../compiler/compile.js", () => ({
201
+ ...actualCompileModule,
202
+ compile: compileSpy,
203
+ }));
204
+ try {
205
+ const { paraglideVitePlugin: vitePlugin } = await import("../bundler-plugins/vite.js");
206
+ const fs = createPluginTestFs();
207
+ const plugin = vitePlugin({
208
+ ...defaultPluginCompileOptions,
209
+ outdir: "/test-output",
210
+ fs: fs,
211
+ });
212
+ const mockContext = { addWatchFile: () => { } };
213
+ await plugin.buildStart?.call(mockContext);
214
+ expect(compileSpy).toHaveBeenCalledTimes(1);
215
+ const messagePath = testMessageFilePath("en");
216
+ const originalMessages = await fs.promises.readFile(messagePath, "utf-8");
217
+ // Break a message file — the compile attempt fails (dev mode
218
+ // swallows the error) and must clear the stored digest.
219
+ await fs.promises.writeFile(messagePath, "{ not json");
220
+ await plugin.buildStart?.call(mockContext);
221
+ expect(compileSpy).toHaveBeenCalledTimes(2);
222
+ // Restore the exact original content.
223
+ await fs.promises.writeFile(messagePath, originalMessages);
224
+ await plugin.buildStart?.call(mockContext);
225
+ expect(compileSpy).toHaveBeenCalledTimes(3);
226
+ }
227
+ finally {
228
+ vi.doUnmock("../compiler/compile.js");
229
+ }
230
+ });
231
+ // Two plugin instances with different filesystems must not share the tracked
232
+ // fs wrapper or cached compilation state — each compiles into its own fs.
233
+ test("vite plugin instances with different fs compile against their own fs (#693)", async () => {
234
+ const { paraglideVitePlugin: vitePlugin } = await import("../bundler-plugins/vite.js");
235
+ const makeProjectFs = async () => createPluginTestFs();
236
+ const fsA = await makeProjectFs();
237
+ const fsB = await makeProjectFs();
238
+ const mockContext = { addWatchFile: () => { } };
239
+ const pluginA = vitePlugin({
240
+ ...defaultPluginCompileOptions,
241
+ outdir: "/test-output",
242
+ fs: fsA,
243
+ });
244
+ await pluginA.buildStart?.call(mockContext);
245
+ const pluginB = vitePlugin({
246
+ ...defaultPluginCompileOptions,
247
+ outdir: "/test-output",
248
+ fs: fsB,
249
+ });
250
+ await pluginB.buildStart?.call(mockContext);
251
+ // B's output must exist in B's filesystem — with a shared tracked fs it
252
+ // would have been read from and written into A's filesystem instead.
253
+ const outputB = await fsB.promises.readdir("/test-output");
254
+ expect(outputB.length).toBeGreaterThan(0);
255
+ });
256
+ //# sourceMappingURL=unplugin.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unplugin.test.js","sourceRoot":"","sources":["../../src/bundler-plugins/unplugin.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACjE,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE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AAE,CAAC,EAAE,CAAC;IAE/C,MAAM,OAAO,GAAG,UAAU,CAAC;QAC1B,GAAG,2BAA2B;QAC9B,MAAM,EAAE,cAAc;QACtB,EAAE,EAAE,GAAG;KACP,CAAQ,CAAC;IACV,MAAM,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAE5C,MAAM,OAAO,GAAG,UAAU,CAAC;QAC1B,GAAG,2BAA2B;QAC9B,MAAM,EAAE,cAAc;QACtB,EAAE,EAAE,GAAG;KACP,CAAQ,CAAC;IACV,MAAM,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAE5C,wEAAwE;IACxE,qEAAqE;IACrE,MAAM,OAAO,GAAG,MAAM,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;IAC3D,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;AAC3C,CAAC,CAAC,CAAC","sourcesContent":["import { test, expect, beforeEach, afterEach, vi } from \"vitest\";\nimport consola from \"consola\";\nimport path from \"node:path\";\nimport { memfs } from \"memfs\";\nimport { createPluginTestFs, defaultPluginCompileOptions, testMessageFilePath } from \"../compiler/test-helpers.js\";\n\nlet originalNodeEnv: string | undefined;\n\nbeforeEach(() => {\n\toriginalNodeEnv = process.env.NODE_ENV;\n\n\t// Reset module state between tests so the module-scoped\n\t// `previousCompilation` doesn't leak across tests.\n\tvi.resetModules();\n\n\t// Mock logging methods to suppress error messages in tests\n\tconsola.mockTypes(() => vi.fn());\n});\n\nafterEach(() => {\n\tif (originalNodeEnv !== undefined) {\n\t\tprocess.env.NODE_ENV = originalNodeEnv;\n\t} else {\n\t\tdelete process.env.NODE_ENV;\n\t}\n});\n\ntest(\"vite plugin does not throw when compilation is successful\", async () => {\n\t// Dynamic import so beforeEach's vi.resetModules() yields a fresh module\n\t// (a static import would share module state across tests).\n\tconst { paraglideVitePlugin } = await import(\"../bundler-plugins/vite.js\");\n\n\t// Create and save a viable project to the virtual file system\n\tconst fs = createPluginTestFs();\n\n\tconst plugin = paraglideVitePlugin({\n\t\t...defaultPluginCompileOptions,\n\t\toutdir: \"/test-output\",\n\t\tfs: fs,\n\t}) as any;\n\n\tconst mockContext = {\n\t\taddWatchFile: () => {},\n\t};\n\n\tawait expect(plugin.buildStart?.call(mockContext)).resolves.toBeUndefined();\n});\n\ntest(\"vite plugin does not throw on compilation errors in development\", async () => {\n\tconst { paraglideVitePlugin } = await import(\"../bundler-plugins/vite.js\");\n\n\tprocess.env.NODE_ENV = \"development\";\n\n\t// Use memfs with no project (simulates missing project)\n\tconst fs = memfs().fs as unknown as typeof import(\"node:fs\");\n\n\tconst plugin = paraglideVitePlugin({\n\t\tmessages: \"./missing/{locale}.json\", locales: [\"en\"], baseLocale: \"en\",\n\t\toutdir: \"/test-output\",\n\t\tfs: fs,\n\t}) as any;\n\n\tconst mockContext = {\n\t\taddWatchFile: () => {},\n\t};\n\n\t// In development mode - should catch errors and NOT throw\n\tawait expect(plugin.buildStart?.call(mockContext)).resolves.toBeUndefined();\n});\n\ntest(\"vite plugin throws on compilation errors at build time\", async () => {\n\tconst { paraglideVitePlugin } = await import(\"../bundler-plugins/vite.js\");\n\n\tprocess.env.NODE_ENV = \"production\";\n\n\t// Use memfs with no project (simulates missing project)\n\tconst fs = memfs().fs as unknown as typeof import(\"node:fs\");\n\n\tconst plugin = paraglideVitePlugin({\n\t\tmessages: \"./missing/{locale}.json\", locales: [\"en\"], baseLocale: \"en\",\n\t\toutdir: \"/test-output\",\n\t\tfs: fs,\n\t}) as any;\n\n\tconst mockContext = {\n\t\taddWatchFile: () => {},\n\t};\n\n\t// In production mode - should throw the error\n\tawait expect(plugin.buildStart?.call(mockContext)).rejects.toThrow();\n});\n\n// Regression test for https://github.com/opral/inlang-paraglide-js/issues/659:\n// the bundler plugins used to wipe `outdir` on every fresh process, racing\n// concurrent reads (SSR/prerender modules, sibling Vite processes, the\n// config-watcher reload) and producing ENOENT/MISSING_EXPORT/ERR_LOAD_URL.\ntest(\"vite plugin does not wipe outdir during first buildStart (#659)\", async () => {\n\tconst { paraglideVitePlugin: vitePlugin } =\n\t\tawait import(\"../bundler-plugins/vite.js\");\n\n\tconst fs = createPluginTestFs();\n\n\t// Pre-seed outdir with a sentinel file mimicking a prior compilation\n\t// still on disk from an earlier process.\n\tawait fs.promises.mkdir(\"/test-output\", { recursive: true });\n\tawait fs.promises.writeFile(\"/test-output/__sentinel__.txt\", \"kept\");\n\n\tconst rmSpy = vi.spyOn(fs.promises, \"rm\");\n\n\tconst plugin = vitePlugin({\n\t\t...defaultPluginCompileOptions,\n\t\toutdir: \"/test-output\",\n\t\tcleanOutdir: true,\n\t\tfs: fs,\n\t}) as any;\n\n\tconst mockContext = { addWatchFile: () => {} };\n\tawait plugin.buildStart?.call(mockContext);\n\n\t// The plugin must not recursively remove the outdir during the first\n\t// compile, even though previousCompilation is undefined. Concurrent\n\t// readers may be holding file handles into outdir.\n\tfor (const call of rmSpy.mock.calls) {\n\t\texpect(call[0]).not.toBe(\"/test-output\");\n\t}\n});\n\ntest(\"vite plugin warm-restart writes nothing when inputs unchanged (#659)\", async () => {\n\tconst fs = createPluginTestFs();\n\n\tconst mockContext = { addWatchFile: () => {} };\n\n\t// First process: compile and persist files to outdir.\n\t{\n\t\tconst { paraglideVitePlugin: vitePlugin } =\n\t\t\tawait import(\"../bundler-plugins/vite.js\");\n\t\tconst plugin = vitePlugin({\n\t\t\t...defaultPluginCompileOptions,\n\t\t\toutdir: \"/test-output\",\n\t\t\tfs: fs,\n\t\t}) as any;\n\t\tawait plugin.buildStart?.call(mockContext);\n\t}\n\n\t// Second process: simulate a fresh node process by resetting modules so\n\t// the module-scoped `previousCompilation` is undefined again. The plugin\n\t// should seed from on-disk hashes and write zero files (no race window).\n\tvi.resetModules();\n\tconst { paraglideVitePlugin: vitePluginFresh } =\n\t\tawait import(\"../bundler-plugins/vite.js\");\n\tconst plugin2 = vitePluginFresh({\n\t\t...defaultPluginCompileOptions,\n\t\toutdir: \"/test-output\",\n\t\tfs: fs,\n\t}) as any;\n\n\tconst writeFileSpy = vi.spyOn(fs.promises, \"writeFile\");\n\tawait plugin2.buildStart?.call(mockContext);\n\n\texpect(writeFileSpy).not.toHaveBeenCalled();\n});\n\n// Regression test for https://github.com/opral/paraglide-js/issues/693:\n// `vite build` fires buildStart once per environment (client, ssr) and each\n// run used to do a full compile() — project loading + message compilation —\n// even though the inputs hadn't changed.\ntest(\"vite plugin skips compile() when buildStart fires again with unchanged inputs (#693)\", async () => {\n\tconst actualCompileModule = await vi.importActual<\n\t\ttypeof import(\"../compiler/compile.js\")\n\t>(\"../compiler/compile.js\");\n\tconst compileSpy = vi.fn(actualCompileModule.compile);\n\tvi.doMock(\"../compiler/compile.js\", () => ({\n\t\t...actualCompileModule,\n\t\tcompile: compileSpy,\n\t}));\n\n\ttry {\n\t\tconst { paraglideVitePlugin: vitePlugin } =\n\t\t\tawait import(\"../bundler-plugins/vite.js\");\n\n\t\tconst fs = createPluginTestFs();\n\n\t\tconst plugin = vitePlugin({\n\t\t\t...defaultPluginCompileOptions,\n\t\t\toutdir: \"/test-output\",\n\t\t\tfs: fs,\n\t\t}) as any;\n\n\t\tconst mockContext = { addWatchFile: () => {} };\n\n\t\t// First environment (e.g. client) compiles.\n\t\tawait plugin.buildStart?.call(mockContext);\n\t\texpect(compileSpy).toHaveBeenCalledTimes(1);\n\n\t\t// Second environment (e.g. ssr) — inputs unchanged, compile skipped.\n\t\tawait plugin.buildStart?.call(mockContext);\n\t\texpect(compileSpy).toHaveBeenCalledTimes(1);\n\n\t\t// Changing a message file invalidates the digest and recompiles.\n\t\tconst messagePath = testMessageFilePath(\"en\");\n\t\tconst messages = JSON.parse(await fs.promises.readFile(messagePath, \"utf-8\"));\n\t\tmessages.changed = \"trigger recompile\";\n\t\tawait fs.promises.writeFile(messagePath, JSON.stringify(messages));\n\n\t\tawait plugin.buildStart?.call(mockContext);\n\t\texpect(compileSpy).toHaveBeenCalledTimes(2);\n\t} finally {\n\t\tvi.doUnmock(\"../compiler/compile.js\");\n\t}\n});\n\n// A new file added next to tracked inputs must invalidate the digest via\n// the directory-listing part of the hash, not only edits to known files.\ntest(\"vite plugin recompiles when a file is added to a tracked directory (#693)\", async () => {\n\tconst actualCompileModule = await vi.importActual<\n\t\ttypeof import(\"../compiler/compile.js\")\n\t>(\"../compiler/compile.js\");\n\tconst compileSpy = vi.fn(actualCompileModule.compile);\n\tvi.doMock(\"../compiler/compile.js\", () => ({\n\t\t...actualCompileModule,\n\t\tcompile: compileSpy,\n\t}));\n\n\ttry {\n\t\tconst { paraglideVitePlugin: vitePlugin } =\n\t\t\tawait import(\"../bundler-plugins/vite.js\");\n\n\t\tconst fs = createPluginTestFs();\n\n\t\tconst plugin = vitePlugin({\n\t\t\t...defaultPluginCompileOptions,\n\t\t\toutdir: \"/test-output\",\n\t\t\tfs: fs,\n\t\t}) as any;\n\n\t\tconst mockContext = { addWatchFile: () => {} };\n\n\t\tawait plugin.buildStart?.call(mockContext);\n\t\tawait plugin.buildStart?.call(mockContext);\n\t\texpect(compileSpy).toHaveBeenCalledTimes(1);\n\n\t\t// No tracked file changed, but the listing of a tracked directory did.\n\t\tawait fs.promises.writeFile(\n\t\t\tpath.join(path.dirname(testMessageFilePath(\"en\")), \"added-later.txt\"),\n\t\t\t\"new\"\n\t\t);\n\n\t\tawait plugin.buildStart?.call(mockContext);\n\t\texpect(compileSpy).toHaveBeenCalledTimes(2);\n\t} finally {\n\t\tvi.doUnmock(\"../compiler/compile.js\");\n\t}\n});\n\n// After a failed compile the stored digest must not be reused: restoring an\n// input to its previous content has to trigger a real recompile, because the\n// failed attempt may have left no (or partial) output.\ntest(\"vite plugin does not reuse a digest from before a failed compile (#693)\", async () => {\n\tprocess.env.NODE_ENV = \"development\";\n\n\tconst actualCompileModule = await vi.importActual<\n\t\ttypeof import(\"../compiler/compile.js\")\n\t>(\"../compiler/compile.js\");\n\tconst compileSpy = vi.fn(actualCompileModule.compile);\n\tvi.doMock(\"../compiler/compile.js\", () => ({\n\t\t...actualCompileModule,\n\t\tcompile: compileSpy,\n\t}));\n\n\ttry {\n\t\tconst { paraglideVitePlugin: vitePlugin } =\n\t\t\tawait import(\"../bundler-plugins/vite.js\");\n\n\t\tconst fs = createPluginTestFs();\n\n\t\tconst plugin = vitePlugin({\n\t\t\t...defaultPluginCompileOptions,\n\t\t\toutdir: \"/test-output\",\n\t\t\tfs: fs,\n\t\t}) as any;\n\n\t\tconst mockContext = { addWatchFile: () => {} };\n\n\t\tawait plugin.buildStart?.call(mockContext);\n\t\texpect(compileSpy).toHaveBeenCalledTimes(1);\n\n\t\tconst messagePath = testMessageFilePath(\"en\");\n\t\tconst originalMessages = await fs.promises.readFile(messagePath, \"utf-8\");\n\n\t\t// Break a message file — the compile attempt fails (dev mode\n\t\t// swallows the error) and must clear the stored digest.\n\t\tawait fs.promises.writeFile(messagePath, \"{ not json\");\n\t\tawait plugin.buildStart?.call(mockContext);\n\t\texpect(compileSpy).toHaveBeenCalledTimes(2);\n\n\t\t// Restore the exact original content.\n\t\tawait fs.promises.writeFile(messagePath, originalMessages);\n\t\tawait plugin.buildStart?.call(mockContext);\n\t\texpect(compileSpy).toHaveBeenCalledTimes(3);\n\t} finally {\n\t\tvi.doUnmock(\"../compiler/compile.js\");\n\t}\n});\n\n// Two plugin instances with different filesystems must not share the tracked\n// fs wrapper or cached compilation state — each compiles into its own fs.\ntest(\"vite plugin instances with different fs compile against their own fs (#693)\", async () => {\n\tconst { paraglideVitePlugin: vitePlugin } =\n\t\tawait import(\"../bundler-plugins/vite.js\");\n\n\tconst makeProjectFs = async () => createPluginTestFs();\n\n\tconst fsA = await makeProjectFs();\n\tconst fsB = await makeProjectFs();\n\n\tconst mockContext = { addWatchFile: () => {} };\n\n\tconst pluginA = vitePlugin({\n\t\t...defaultPluginCompileOptions,\n\t\toutdir: \"/test-output\",\n\t\tfs: fsA,\n\t}) as any;\n\tawait pluginA.buildStart?.call(mockContext);\n\n\tconst pluginB = vitePlugin({\n\t\t...defaultPluginCompileOptions,\n\t\toutdir: \"/test-output\",\n\t\tfs: fsB,\n\t}) as any;\n\tawait pluginB.buildStart?.call(mockContext);\n\n\t// B's output must exist in B's filesystem — with a shared tracked fs it\n\t// would have been read from and written into A's filesystem instead.\n\tconst outputB = await fsB.promises.readdir(\"/test-output\");\n\texpect(outputB.length).toBeGreaterThan(0);\n});\n"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ {"version":3,"file":"virtual-modules.test.d.ts","sourceRoot":"","sources":["../../src/bundler-plugins/virtual-modules.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,77 @@
1
+ import { beforeEach, expect, test, vi } from "vitest";
2
+ import consola from "consola";
3
+ import path from "node:path";
4
+ import { createPluginTestFs, defaultPluginCompileOptions, } from "../compiler/test-helpers.js";
5
+ beforeEach(() => {
6
+ vi.resetModules();
7
+ consola.mockTypes(() => vi.fn());
8
+ });
9
+ test("virtual resolveId/load serve generated js when emitFiles is false", async () => {
10
+ const { paraglideVitePlugin } = await import("./vite.js");
11
+ const { resolveVirtualModuleId, loadVirtualModule, getPluginState, } = await import("./plugin-core.js");
12
+ const fs = createPluginTestFs();
13
+ const outdir = "/virtual-out";
14
+ const plugin = paraglideVitePlugin({
15
+ ...defaultPluginCompileOptions,
16
+ outdir,
17
+ emitFiles: false,
18
+ fs,
19
+ });
20
+ await plugin.buildStart?.call({ addWatchFile: () => { } });
21
+ const state = getPluginState({
22
+ ...defaultPluginCompileOptions,
23
+ outdir,
24
+ fs,
25
+ });
26
+ expect(state.virtualModules.size).toBeGreaterThan(0);
27
+ const runtimePath = path.resolve(outdir, "runtime.js");
28
+ const resolved = resolveVirtualModuleId({
29
+ id: "./runtime.js",
30
+ importer: path.resolve(outdir, "messages.js"),
31
+ state,
32
+ });
33
+ expect(resolved).toBe(runtimePath);
34
+ expect(loadVirtualModule(resolved, state)).toContain("export");
35
+ // No JS written to disk
36
+ await expect(fs.promises.readFile(runtimePath, "utf8")).rejects.toThrow();
37
+ });
38
+ test("virtual resolve does not claim unrelated runtime.js imports", async () => {
39
+ const { paraglideVitePlugin } = await import("./vite.js");
40
+ const { resolveVirtualModuleId, getPluginState } = await import("./plugin-core.js");
41
+ const fs = createPluginTestFs();
42
+ const outdir = "/scoped-out";
43
+ const plugin = paraglideVitePlugin({
44
+ ...defaultPluginCompileOptions,
45
+ outdir,
46
+ emitFiles: false,
47
+ fs,
48
+ });
49
+ await plugin.buildStart?.call({ addWatchFile: () => { } });
50
+ const state = getPluginState({
51
+ ...defaultPluginCompileOptions,
52
+ outdir,
53
+ fs,
54
+ });
55
+ expect(resolveVirtualModuleId({
56
+ id: "./runtime.js",
57
+ importer: "/node_modules/svelte/src/internal/client/context.js",
58
+ state,
59
+ })).toBeUndefined();
60
+ });
61
+ test("emitFiles types writes meta but not js", async () => {
62
+ const { paraglideVitePlugin } = await import("./vite.js");
63
+ const fs = createPluginTestFs();
64
+ const outdir = "/types-out";
65
+ const plugin = paraglideVitePlugin({
66
+ ...defaultPluginCompileOptions,
67
+ outdir,
68
+ emitFiles: "types",
69
+ emitTsDeclarations: true,
70
+ emitGitIgnore: true,
71
+ fs,
72
+ });
73
+ await plugin.buildStart?.call({ addWatchFile: () => { } });
74
+ await expect(fs.promises.readFile(path.resolve(outdir, "runtime.js"), "utf8")).rejects.toThrow();
75
+ await expect(fs.promises.readFile(path.resolve(outdir, ".gitignore"), "utf8")).resolves.toBeTruthy();
76
+ });
77
+ //# sourceMappingURL=virtual-modules.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"virtual-modules.test.js","sourceRoot":"","sources":["../../src/bundler-plugins/virtual-modules.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACtD,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,IAAI,MAAM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AW,CAAC,CAAC;IAC1D,MAAM,EAAE,GAAG,kBAAkB,EAAE,CAAC;IAChC,MAAM,MAAM,GAAG,YAAY,CAAC;IAE5B,MAAM,MAAM,GAAG,mBAAmB,CAAC;QAClC,GAAG,2BAA2B;QAC9B,MAAM;QACN,SAAS,EAAE,OAAO;QAClB,kBAAkB,EAAE,IAAI;QACxB,aAAa,EAAE,IAAI;QACnB,EAAE;KACF,CAAQ,CAAC;IAEV,MAAM,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE,YAAY,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,CAAC,CAAC;IAE1D,MAAM,MAAM,CACX,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,CAAC,CAChE,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;IACpB,MAAM,MAAM,CACX,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,CAAC,CAChE,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;AACzB,CAAC,CAAC,CAAC","sourcesContent":["import { beforeEach, expect, test, vi } from \"vitest\";\nimport consola from \"consola\";\nimport path from \"node:path\";\nimport {\n\tcreatePluginTestFs,\n\tdefaultPluginCompileOptions,\n} from \"../compiler/test-helpers.js\";\n\nbeforeEach(() => {\n\tvi.resetModules();\n\tconsola.mockTypes(() => vi.fn());\n});\n\ntest(\"virtual resolveId/load serve generated js when emitFiles is false\", async () => {\n\tconst { paraglideVitePlugin } = await import(\"./vite.js\");\n\tconst {\n\t\tresolveVirtualModuleId,\n\t\tloadVirtualModule,\n\t\tgetPluginState,\n\t} = await import(\"./plugin-core.js\");\n\n\tconst fs = createPluginTestFs();\n\tconst outdir = \"/virtual-out\";\n\n\tconst plugin = paraglideVitePlugin({\n\t\t...defaultPluginCompileOptions,\n\t\toutdir,\n\t\temitFiles: false,\n\t\tfs,\n\t}) as any;\n\n\tawait plugin.buildStart?.call({ addWatchFile: () => {} });\n\n\tconst state = getPluginState({\n\t\t...defaultPluginCompileOptions,\n\t\toutdir,\n\t\tfs,\n\t});\n\texpect(state.virtualModules.size).toBeGreaterThan(0);\n\n\tconst runtimePath = path.resolve(outdir, \"runtime.js\");\n\tconst resolved = resolveVirtualModuleId({\n\t\tid: \"./runtime.js\",\n\t\timporter: path.resolve(outdir, \"messages.js\"),\n\t\tstate,\n\t});\n\texpect(resolved).toBe(runtimePath);\n\texpect(loadVirtualModule(resolved!, state)).toContain(\"export\");\n\n\t// No JS written to disk\n\tawait expect(fs.promises.readFile(runtimePath, \"utf8\")).rejects.toThrow();\n});\n\ntest(\"virtual resolve does not claim unrelated runtime.js imports\", async () => {\n\tconst { paraglideVitePlugin } = await import(\"./vite.js\");\n\tconst { resolveVirtualModuleId, getPluginState } = await import(\n\t\t\"./plugin-core.js\"\n\t);\n\n\tconst fs = createPluginTestFs();\n\tconst outdir = \"/scoped-out\";\n\tconst plugin = paraglideVitePlugin({\n\t\t...defaultPluginCompileOptions,\n\t\toutdir,\n\t\temitFiles: false,\n\t\tfs,\n\t}) as any;\n\n\tawait plugin.buildStart?.call({ addWatchFile: () => {} });\n\tconst state = getPluginState({\n\t\t...defaultPluginCompileOptions,\n\t\toutdir,\n\t\tfs,\n\t});\n\n\texpect(\n\t\tresolveVirtualModuleId({\n\t\t\tid: \"./runtime.js\",\n\t\t\timporter: \"/node_modules/svelte/src/internal/client/context.js\",\n\t\t\tstate,\n\t\t})\n\t).toBeUndefined();\n});\n\ntest(\"emitFiles types writes meta but not js\", async () => {\n\tconst { paraglideVitePlugin } = await import(\"./vite.js\");\n\tconst fs = createPluginTestFs();\n\tconst outdir = \"/types-out\";\n\n\tconst plugin = paraglideVitePlugin({\n\t\t...defaultPluginCompileOptions,\n\t\toutdir,\n\t\temitFiles: \"types\",\n\t\temitTsDeclarations: true,\n\t\temitGitIgnore: true,\n\t\tfs,\n\t}) as any;\n\n\tawait plugin.buildStart?.call({ addWatchFile: () => {} });\n\n\tawait expect(\n\t\tfs.promises.readFile(path.resolve(outdir, \"runtime.js\"), \"utf8\")\n\t).rejects.toThrow();\n\tawait expect(\n\t\tfs.promises.readFile(path.resolve(outdir, \".gitignore\"), \"utf8\")\n\t).resolves.toBeTruthy();\n});\n"]}
@@ -0,0 +1,17 @@
1
+ import type { Plugin } from "vite";
2
+ import type { CompilerOptions } from "../compiler/compiler-options.js";
3
+ export type ParaglideVitePluginOptions = CompilerOptions & {
4
+ /**
5
+ * Emit one compiler-specialized client asset tree per project locale.
6
+ *
7
+ * Requires Vite 8+. Builds one untouched Rolldown client environment per
8
+ * locale and emits `paraglide-vite-locales.json`. Locale changes need to use
9
+ * full-document navigation. Framework SSR graph selection requires a public
10
+ * framework integration API.
11
+ *
12
+ * @experimental
13
+ * @default false
14
+ */
15
+ experimentalPerLocaleBuild?: boolean;
16
+ };
17
+ export declare function paraglideVitePlugin(options: ParaglideVitePluginOptions): Plugin | Plugin[];
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../../src/bundler-plugins/vite.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAIvE,MAAM,MAAM,0BAA0B,GAAG,eAAe,GAAG;IAC1D;;;;;;;;;;OAUG;IACH,0BAA0B,CAAC,EAAE,OAAO,CAAC;CACrC,CAAC;AAIF,wBAAgB,mBAAmB,CAClC,OAAO,EAAE,0BAA0B,GACjC,MAAM,GAAG,MAAM,EAAE,CAWnB"}
@@ -0,0 +1,15 @@
1
+ import { createVitePlugin } from "unplugin";
2
+ import { createPerLocaleBuildPlugins } from "./per-locale-build/index.js";
3
+ import { unpluginFactory } from "./unplugin.js";
4
+ const createCompilerVitePlugin = createVitePlugin(unpluginFactory);
5
+ export function paraglideVitePlugin(options) {
6
+ const { experimentalPerLocaleBuild, ...compilerOptions } = options;
7
+ if (!experimentalPerLocaleBuild) {
8
+ return createCompilerVitePlugin(compilerOptions);
9
+ }
10
+ return createPerLocaleBuildPlugins({
11
+ compilerOptions,
12
+ createCompilerPlugin: (options) => createCompilerVitePlugin(options),
13
+ });
14
+ }
15
+ //# sourceMappingURL=vite.js.map
@@ -0,0 +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 { CompilerOptions } from \"../compiler/compiler-options.js\";\nimport { createPerLocaleBuildPlugins } from \"./per-locale-build/index.js\";\nimport { unpluginFactory } from \"./unplugin.js\";\n\nexport type ParaglideVitePluginOptions = CompilerOptions & {\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"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite.test.d.ts","sourceRoot":"","sources":["../../src/bundler-plugins/vite.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,61 @@
1
+ import { createPluginTestFs, defaultPluginCompileOptions } from "../compiler/test-helpers.js";
2
+ import { expect, test } from "vitest";
3
+ import { perLocaleBuildStaticLocaleExpression } from "../compiler/per-locale-build.js";
4
+ import { paraglideVitePlugin } from "./vite.js";
5
+ test("experimentalPerLocaleBuild generates locale source modules and installs the Vite environment orchestrator", async () => {
6
+ const fs = createPluginTestFs();
7
+ const plugins = paraglideVitePlugin({
8
+ ...defaultPluginCompileOptions,
9
+ outdir: "/src/paraglide",
10
+ fs,
11
+ experimentalPerLocaleBuild: true,
12
+ strategy: ["preferredLanguage", "baseLocale"],
13
+ additionalFiles: { "custom.js": "export const custom = true;\n" },
14
+ });
15
+ if (!Array.isArray(plugins)) {
16
+ throw new Error("Expected multiple Vite plugins");
17
+ }
18
+ expect(plugins.map((plugin) => plugin.name)).toEqual([
19
+ "unplugin-paraglide-lite",
20
+ "paraglide-vite-locale-environments",
21
+ ]);
22
+ const compiler = plugins[0];
23
+ if (typeof compiler.buildStart !== "function") {
24
+ throw new Error("Expected the compiler buildStart hook");
25
+ }
26
+ await compiler.buildStart.call({ addWatchFile() { } }, {});
27
+ expect(await fs.promises.readFile("/src/paraglide/messages/en.js", "utf8")).toBeDefined();
28
+ expect(await fs.promises.readFile("/src/paraglide/messages/de.js", "utf8")).toBeDefined();
29
+ expect(await fs.promises.readFile("/src/paraglide/runtime.js", "utf8")).toContain(perLocaleBuildStaticLocaleExpression);
30
+ expect(await fs.promises.readFile("/src/paraglide/custom.js", "utf8")).toContain("export const custom = true;");
31
+ await expect(fs.promises.readFile("/src/paraglide/tanstack-start.server.js", "utf8")).rejects.toThrow();
32
+ });
33
+ test("experimentalPerLocaleBuild rejects conflicting compiler options", () => {
34
+ const common = { ...defaultPluginCompileOptions, outdir: "/src/paraglide" };
35
+ expect(() => paraglideVitePlugin({
36
+ ...common,
37
+ experimentalPerLocaleBuild: true,
38
+ experimentalStaticLocale: '"de"',
39
+ })).toThrow("cannot be combined with experimentalStaticLocale");
40
+ expect(() => paraglideVitePlugin({
41
+ ...common,
42
+ experimentalPerLocaleBuild: true,
43
+ experimentalMiddlewareLocaleSplitting: true,
44
+ })).toThrow("cannot be combined with experimentalMiddlewareLocaleSplitting");
45
+ expect(() => paraglideVitePlugin({
46
+ ...common,
47
+ experimentalPerLocaleBuild: true,
48
+ outputStructure: "message-modules",
49
+ })).toThrow('requires outputStructure: "locale-modules"');
50
+ expect(() => paraglideVitePlugin({
51
+ ...common,
52
+ experimentalPerLocaleBuild: true,
53
+ routeStrategies: [
54
+ {
55
+ match: "/api/:path(.*)?",
56
+ exclude: true,
57
+ },
58
+ ],
59
+ })).not.toThrow();
60
+ });
61
+ //# sourceMappingURL=vite.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite.test.js","sourceRoot":"","sources":["../../src/bundler-plugins/vite.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAC9F,OAAO,EAAE,MAAM,EAAE,IAAI,EA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,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 { createPluginTestFs, defaultPluginCompileOptions } from \"../compiler/test-helpers.js\";\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 fs = createPluginTestFs();\n\n\tconst plugins = paraglideVitePlugin({\n\t\t...defaultPluginCompileOptions,\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\"unplugin-paraglide-lite\",\n\t\t\"paraglide-vite-locale-environments\",\n\t]);\n\n\tconst compiler = plugins[0]!;\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 = { ...defaultPluginCompileOptions, 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"]}
@@ -0,0 +1 @@
1
+ export declare const paraglideWebpackPlugin: (options: import("../index.js").CompilerOptions) => WebpackPluginInstance;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webpack.d.ts","sourceRoot":"","sources":["../../src/bundler-plugins/webpack.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,sBAAsB,2EAAuC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { createWebpackPlugin } from "unplugin";
2
+ import { unpluginFactory } from "./unplugin.js";
3
+ export const paraglideWebpackPlugin = createWebpackPlugin(unpluginFactory);
4
+ //# sourceMappingURL=webpack.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webpack.js","sourceRoot":"","sources":["../../src/bundler-plugins/webpack.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,MAAM,CAAC,MAAM,sBAAsB,GAAG,mBAAmB,CAAC,eAAe,CAAC,CAAC","sourcesContent":["import { createWebpackPlugin } from \"unplugin\";\nimport { unpluginFactory } from \"./unplugin.js\";\n\nexport const paraglideWebpackPlugin = createWebpackPlugin(unpluginFactory);\n"]}
@@ -0,0 +1,2 @@
1
+ import { Command } from "commander";
2
+ export declare const compileCommand: Command;