@inlang/paraglide-js 2.26.0 → 2.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (225) hide show
  1. package/README.md +11 -1
  2. package/dist/bundler-plugins/per-locale-build/index.js +14 -7
  3. package/dist/bundler-plugins/per-locale-build/index.js.map +1 -1
  4. package/dist/bundler-plugins/per-locale-build/vite-environments.test.js +237 -4
  5. package/dist/bundler-plugins/per-locale-build/vite-environments.test.js.map +1 -1
  6. package/dist/bundler-plugins/unplugin.d.ts +1 -1
  7. package/dist/bundler-plugins/unplugin.js +79 -10
  8. package/dist/bundler-plugins/unplugin.js.map +1 -1
  9. package/dist/bundler-plugins/unplugin.test.js +334 -1
  10. package/dist/bundler-plugins/unplugin.test.js.map +1 -1
  11. package/dist/bundler-plugins/vite.js +2 -1
  12. package/dist/bundler-plugins/vite.js.map +1 -1
  13. package/dist/bundler-plugins/vite.test.js +1 -1
  14. package/dist/bundler-plugins/vite.test.js.map +1 -1
  15. package/dist/cli/commands/compile/command.js +13 -0
  16. package/dist/cli/commands/compile/command.js.map +1 -1
  17. package/dist/cli/commands/compile/command.test.js +87 -3
  18. package/dist/cli/commands/compile/command.test.js.map +1 -1
  19. package/dist/cli/commands/init/command.d.ts +5 -0
  20. package/dist/cli/commands/init/command.js +216 -44
  21. package/dist/cli/commands/init/command.js.map +1 -1
  22. package/dist/cli/commands/init/command.test.d.ts +1 -0
  23. package/dist/cli/commands/init/command.test.js +123 -0
  24. package/dist/cli/commands/init/command.test.js.map +1 -0
  25. package/dist/cli/defaults.js +2 -2
  26. package/dist/cli/defaults.js.map +1 -1
  27. package/dist/cli/init-options.d.ts +11 -0
  28. package/dist/cli/init-options.js +2 -0
  29. package/dist/cli/init-options.js.map +1 -0
  30. package/dist/cli/steps/add-inlang-check.d.ts +19 -0
  31. package/dist/cli/steps/add-inlang-check.js +60 -0
  32. package/dist/cli/steps/add-inlang-check.js.map +1 -0
  33. package/dist/cli/steps/add-inlang-check.test.d.ts +1 -0
  34. package/dist/cli/steps/add-inlang-check.test.js +88 -0
  35. package/dist/cli/steps/add-inlang-check.test.js.map +1 -0
  36. package/dist/cli/steps/add-message-lint.d.ts +34 -0
  37. package/dist/cli/steps/add-message-lint.js +105 -0
  38. package/dist/cli/steps/add-message-lint.js.map +1 -0
  39. package/dist/cli/steps/add-message-lint.test.d.ts +1 -0
  40. package/dist/cli/steps/add-message-lint.test.js +74 -0
  41. package/dist/cli/steps/add-message-lint.test.js.map +1 -0
  42. package/dist/cli/steps/add-vite-plugin.d.ts +18 -0
  43. package/dist/cli/steps/add-vite-plugin.js +34 -6
  44. package/dist/cli/steps/add-vite-plugin.js.map +1 -1
  45. package/dist/cli/steps/add-vite-plugin.test.js +25 -9
  46. package/dist/cli/steps/add-vite-plugin.test.js.map +1 -1
  47. package/dist/cli/steps/agents-md-suggestion.d.ts +11 -0
  48. package/dist/cli/steps/agents-md-suggestion.js +19 -0
  49. package/dist/cli/steps/agents-md-suggestion.js.map +1 -0
  50. package/dist/cli/steps/agents-md-suggestion.test.d.ts +1 -0
  51. package/dist/cli/steps/agents-md-suggestion.test.js +36 -0
  52. package/dist/cli/steps/agents-md-suggestion.test.js.map +1 -0
  53. package/dist/cli/steps/check-for-uncomitted-changes.d.ts +3 -0
  54. package/dist/cli/steps/check-for-uncomitted-changes.js +15 -3
  55. package/dist/cli/steps/check-for-uncomitted-changes.js.map +1 -1
  56. package/dist/cli/steps/detect-bundler.d.ts +1 -0
  57. package/dist/cli/steps/detect-bundler.js +7 -1
  58. package/dist/cli/steps/detect-bundler.js.map +1 -1
  59. package/dist/cli/steps/initialize-inlang-project.d.ts +4 -3
  60. package/dist/cli/steps/initialize-inlang-project.js +60 -157
  61. package/dist/cli/steps/initialize-inlang-project.js.map +1 -1
  62. package/dist/cli/steps/maybe-add-machine-translation.d.ts +4 -0
  63. package/dist/cli/steps/maybe-add-machine-translation.js +14 -8
  64. package/dist/cli/steps/maybe-add-machine-translation.js.map +1 -1
  65. package/dist/cli/steps/maybe-add-sherlock.d.ts +2 -0
  66. package/dist/cli/steps/maybe-add-sherlock.js +13 -7
  67. package/dist/cli/steps/maybe-add-sherlock.js.map +1 -1
  68. package/dist/cli/steps/maybe-add-sherlock.test.d.ts +1 -0
  69. package/dist/cli/steps/maybe-add-sherlock.test.js +44 -0
  70. package/dist/cli/steps/maybe-add-sherlock.test.js.map +1 -0
  71. package/dist/cli/steps/prompt-for-outdir.d.ts +2 -0
  72. package/dist/cli/steps/prompt-for-outdir.js +4 -0
  73. package/dist/cli/steps/prompt-for-outdir.js.map +1 -1
  74. package/dist/cli/steps/update-package-json.js +8 -13
  75. package/dist/cli/steps/update-package-json.js.map +1 -1
  76. package/dist/cli/steps/update-ts-config.d.ts +6 -0
  77. package/dist/cli/steps/update-ts-config.js +27 -4
  78. package/dist/cli/steps/update-ts-config.js.map +1 -1
  79. package/dist/cli/utils.d.ts +11 -0
  80. package/dist/cli/utils.js +21 -0
  81. package/dist/cli/utils.js.map +1 -1
  82. package/dist/cli/utils.test.d.ts +1 -0
  83. package/dist/cli/utils.test.js +16 -0
  84. package/dist/cli/utils.test.js.map +1 -0
  85. package/dist/compiler/compile-annotation.d.ts +48 -1
  86. package/dist/compiler/compile-annotation.js +243 -10
  87. package/dist/compiler/compile-annotation.js.map +1 -1
  88. package/dist/compiler/compile-bundle.d.ts +7 -2
  89. package/dist/compiler/compile-bundle.js +97 -3
  90. package/dist/compiler/compile-bundle.js.map +1 -1
  91. package/dist/compiler/compile-bundle.test.js +232 -19
  92. package/dist/compiler/compile-bundle.test.js.map +1 -1
  93. package/dist/compiler/compile-lifecycle.test.d.ts +1 -0
  94. package/dist/compiler/compile-lifecycle.test.js +69 -0
  95. package/dist/compiler/compile-lifecycle.test.js.map +1 -0
  96. package/dist/compiler/compile-local-variable.d.ts +3 -0
  97. package/dist/compiler/compile-local-variable.js +5 -2
  98. package/dist/compiler/compile-local-variable.js.map +1 -1
  99. package/dist/compiler/compile-local-variable.test.js +55 -15
  100. package/dist/compiler/compile-local-variable.test.js.map +1 -1
  101. package/dist/compiler/compile-message.d.ts +29 -1
  102. package/dist/compiler/compile-message.exact-number.test.d.ts +1 -0
  103. package/dist/compiler/compile-message.exact-number.test.js +786 -0
  104. package/dist/compiler/compile-message.exact-number.test.js.map +1 -0
  105. package/dist/compiler/compile-message.js +162 -66
  106. package/dist/compiler/compile-message.js.map +1 -1
  107. package/dist/compiler/compile-message.locals.test.d.ts +1 -0
  108. package/dist/compiler/compile-message.locals.test.js +498 -0
  109. package/dist/compiler/compile-message.locals.test.js.map +1 -0
  110. package/dist/compiler/compile-message.test.js +113 -22
  111. package/dist/compiler/compile-message.test.js.map +1 -1
  112. package/dist/compiler/compile-pattern.d.ts +5 -0
  113. package/dist/compiler/compile-pattern.js +6 -18
  114. package/dist/compiler/compile-pattern.js.map +1 -1
  115. package/dist/compiler/compile-pattern.test.js +169 -5
  116. package/dist/compiler/compile-pattern.test.js.map +1 -1
  117. package/dist/compiler/compile-project.js +5 -1
  118. package/dist/compiler/compile-project.js.map +1 -1
  119. package/dist/compiler/compile-project.test.js +1260 -185
  120. package/dist/compiler/compile-project.test.js.map +1 -1
  121. package/dist/compiler/compile.js +36 -17
  122. package/dist/compiler/compile.js.map +1 -1
  123. package/dist/compiler/compile.test.js +71 -1
  124. package/dist/compiler/compile.test.js.map +1 -1
  125. package/dist/compiler/compiler-options.d.ts +41 -0
  126. package/dist/compiler/compiler-options.js.map +1 -1
  127. package/dist/compiler/create-readme.d.ts +4 -1
  128. package/dist/compiler/create-readme.js +33 -125
  129. package/dist/compiler/create-readme.js.map +1 -1
  130. package/dist/compiler/emit-ts-declarations.interop.test.js +2 -2
  131. package/dist/compiler/emit-ts-declarations.interop.test.js.map +1 -1
  132. package/dist/compiler/emit-ts-declarations.test.js +4 -4
  133. package/dist/compiler/emit-ts-declarations.test.js.map +1 -1
  134. package/dist/compiler/index.d.ts +1 -1
  135. package/dist/compiler/index.js +1 -1
  136. package/dist/compiler/index.js.map +1 -1
  137. package/dist/compiler/input-alias.d.ts +21 -0
  138. package/dist/compiler/input-alias.js +42 -0
  139. package/dist/compiler/input-alias.js.map +1 -0
  140. package/dist/compiler/input-alias.test.d.ts +1 -0
  141. package/dist/compiler/input-alias.test.js +58 -0
  142. package/dist/compiler/input-alias.test.js.map +1 -0
  143. package/dist/compiler/message-locals.d.ts +46 -0
  144. package/dist/compiler/message-locals.js +129 -0
  145. package/dist/compiler/message-locals.js.map +1 -0
  146. package/dist/compiler/output-structure/locale-modules.js +7 -1
  147. package/dist/compiler/output-structure/locale-modules.js.map +1 -1
  148. package/dist/compiler/output-structure/locale-modules.test.js +35 -0
  149. package/dist/compiler/output-structure/locale-modules.test.js.map +1 -1
  150. package/dist/compiler/output-structure/message-modules.js +6 -4
  151. package/dist/compiler/output-structure/message-modules.js.map +1 -1
  152. package/dist/compiler/output-structure/message-modules.test.js +35 -0
  153. package/dist/compiler/output-structure/message-modules.test.js.map +1 -1
  154. package/dist/compiler/registry.d.ts +12 -0
  155. package/dist/compiler/registry.js +158 -31
  156. package/dist/compiler/registry.js.map +1 -1
  157. package/dist/compiler/registry.test.d.ts +1 -0
  158. package/dist/compiler/registry.test.js +291 -0
  159. package/dist/compiler/registry.test.js.map +1 -0
  160. package/dist/compiler/runtime/create-runtime.d.ts +2 -0
  161. package/dist/compiler/runtime/create-runtime.js +9 -0
  162. package/dist/compiler/runtime/create-runtime.js.map +1 -1
  163. package/dist/compiler/runtime/extract-locale-from-cookie.js +8 -1
  164. package/dist/compiler/runtime/extract-locale-from-cookie.js.map +1 -1
  165. package/dist/compiler/runtime/extract-locale-from-cookie.test.js +26 -0
  166. package/dist/compiler/runtime/extract-locale-from-cookie.test.js.map +1 -1
  167. package/dist/compiler/runtime/extract-locale-from-header.js +47 -5
  168. package/dist/compiler/runtime/extract-locale-from-header.js.map +1 -1
  169. package/dist/compiler/runtime/extract-locale-from-header.test.js +58 -0
  170. package/dist/compiler/runtime/extract-locale-from-header.test.js.map +1 -1
  171. package/dist/compiler/runtime/get-locale.js +7 -1
  172. package/dist/compiler/runtime/get-locale.js.map +1 -1
  173. package/dist/compiler/runtime/get-locale.test.js +95 -0
  174. package/dist/compiler/runtime/get-locale.test.js.map +1 -1
  175. package/dist/compiler/runtime/localize-href.d.ts +8 -0
  176. package/dist/compiler/runtime/localize-href.js +60 -0
  177. package/dist/compiler/runtime/localize-href.js.map +1 -1
  178. package/dist/compiler/runtime/localize-href.test.js +227 -1
  179. package/dist/compiler/runtime/localize-href.test.js.map +1 -1
  180. package/dist/compiler/runtime/set-locale.js +24 -6
  181. package/dist/compiler/runtime/set-locale.js.map +1 -1
  182. package/dist/compiler/runtime/set-locale.test.js +182 -0
  183. package/dist/compiler/runtime/set-locale.test.js.map +1 -1
  184. package/dist/compiler/runtime/type.d.ts +2 -0
  185. package/dist/compiler/runtime/type.js.map +1 -1
  186. package/dist/compiler/runtime/type.test.js +34 -0
  187. package/dist/compiler/runtime/type.test.js.map +1 -1
  188. package/dist/compiler/runtime/variables.d.ts +2 -0
  189. package/dist/compiler/runtime/variables.js +7 -0
  190. package/dist/compiler/runtime/variables.js.map +1 -1
  191. package/dist/compiler/server/create-server-file.js +24 -0
  192. package/dist/compiler/server/create-server-file.js.map +1 -1
  193. package/dist/compiler/server/create-server-file.test.js +8 -2
  194. package/dist/compiler/server/create-server-file.test.js.map +1 -1
  195. package/dist/compiler/server/middleware.d.ts +8 -2
  196. package/dist/compiler/server/middleware.js +204 -11
  197. package/dist/compiler/server/middleware.js.map +1 -1
  198. package/dist/compiler/server/middleware.test.js +750 -3
  199. package/dist/compiler/server/middleware.test.js.map +1 -1
  200. package/dist/eslint/index.d.ts +4 -0
  201. package/dist/eslint/index.js +8 -0
  202. package/dist/eslint/index.js.map +1 -0
  203. package/dist/eslint/no-dynamic-message-access.d.ts +3 -0
  204. package/dist/eslint/no-dynamic-message-access.js +150 -0
  205. package/dist/eslint/no-dynamic-message-access.js.map +1 -0
  206. package/dist/eslint/no-dynamic-message-access.test.d.ts +1 -0
  207. package/dist/eslint/no-dynamic-message-access.test.js +126 -0
  208. package/dist/eslint/no-dynamic-message-access.test.js.map +1 -0
  209. package/dist/eslint/oxlint.test.d.ts +1 -0
  210. package/dist/eslint/oxlint.test.js +64 -0
  211. package/dist/eslint/oxlint.test.js.map +1 -0
  212. package/dist/services/config/config-schema.d.ts +2 -0
  213. package/dist/services/config/config-schema.js +2 -0
  214. package/dist/services/config/config-schema.js.map +1 -1
  215. package/dist/services/config/load-paraglide-config.test.js +12 -0
  216. package/dist/services/config/load-paraglide-config.test.js.map +1 -1
  217. package/dist/services/env-variables/index.js +1 -1
  218. package/dist/services/env-variables/index.js.map +1 -1
  219. package/dist/services/file-handling/write-output.bench.js +51 -11
  220. package/dist/services/file-handling/write-output.bench.js.map +1 -1
  221. package/dist/services/file-handling/write-output.js +60 -20
  222. package/dist/services/file-handling/write-output.js.map +1 -1
  223. package/dist/services/file-handling/write-output.test.js +175 -0
  224. package/dist/services/file-handling/write-output.test.js.map +1 -1
  225. package/package.json +15 -5
@@ -1,5 +1,6 @@
1
- import { test, expect } from "vitest";
1
+ import { describe, test, expect } from "vitest";
2
2
  import { compilePattern } from "./compile-pattern.js";
3
+ import { createRegistry } from "./registry.js";
3
4
  test("should compile a text only pattern", () => {
4
5
  const pattern = [{ type: "text", value: "Hello" }];
5
6
  const { code } = compilePattern({ pattern, declarations: [] });
@@ -119,7 +120,7 @@ test("compiles a pattern expression annotation to a registry call", () => {
119
120
  declarations: [{ type: "input-variable", name: "count" }],
120
121
  locale: "en",
121
122
  });
122
- expect(code).toBe('`${registry.number("en", i?.count, {})} views`');
123
+ expect(code).toBe('`${registry.number("en", i?.count, {}, true)} views`');
123
124
  });
124
125
  test("compiles pattern expression annotation options like local variable annotations", () => {
125
126
  const pattern = [
@@ -144,7 +145,7 @@ test("compiles pattern expression annotation options like local variable annotat
144
145
  declarations: [{ type: "input-variable", name: "price" }],
145
146
  locale: "de",
146
147
  });
147
- expect(code).toBe('`${registry.number("de", i?.price, { minimumFractionDigits: 2, style: "percent" })}`');
148
+ expect(code).toBe('`${registry.number("de", i?.price, { minimumFractionDigits: 2, style: "percent" }, true)}`');
148
149
  });
149
150
  test("compiles pattern annotation options that reference local variables", () => {
150
151
  const pattern = [
@@ -175,7 +176,7 @@ test("compiles pattern annotation options that reference local variables", () =>
175
176
  ],
176
177
  locale: "en",
177
178
  });
178
- expect(code).toBe('`${registry.number("en", i?.price, { minimumFractionDigits: digits })}`');
179
+ expect(code).toBe('`${registry.number("en", i?.price, { minimumFractionDigits: digits }, true)}`');
179
180
  });
180
181
  test("parts mode compiles pattern expression annotations to registry calls", () => {
181
182
  const pattern = [
@@ -192,7 +193,7 @@ test("parts mode compiles pattern expression annotations to registry calls", ()
192
193
  declarations: [{ type: "input-variable", name: "count" }],
193
194
  locale: "en",
194
195
  });
195
- expect(code).toBe('[{ type: "text", value: String(registry.number("en", i?.count, {})) }, { type: "text", value: " views" }]');
196
+ expect(code).toBe('[{ type: "text", value: String(registry.number("en", i?.count, {}, true)) }, { type: "text", value: " views" }]');
196
197
  });
197
198
  test("falls back to plain interpolation for unknown formatters", () => {
198
199
  const pattern = [
@@ -283,4 +284,167 @@ test("parts mode compiles text, markup, options and attributes", () => {
283
284
  });
284
285
  expect(code).toBe('[{ type: "text", value: "Read " }, { type: "markup-start", name: "link", options: { "to": "/docs", "rel": i?.relationship }, attributes: { "track": true, "variant": "hero" } }, { type: "text", value: "docs" }, { type: "markup-end", name: "link", options: { "to": "/docs" }, attributes: { "track": true } }, { type: "markup-standalone", name: "icon", options: { "name": "arrow" }, attributes: { "filled": true } }]');
285
286
  });
287
+ describe("ICU MessageFormat 1 styles, as imported by the ICU1 plugin", () => {
288
+ const date = new Date(Date.UTC(2026, 9, 9, 14, 30));
289
+ /** Compiles `{arg :name style=style}` and runs it with the registry. */
290
+ const run = async (name, style, input) => {
291
+ const { code } = compilePattern({
292
+ pattern: [
293
+ {
294
+ type: "expression",
295
+ arg: { type: "variable-reference", name: "value" },
296
+ annotation: {
297
+ type: "function-reference",
298
+ name,
299
+ options: style === undefined
300
+ ? []
301
+ : [{ name: "style", value: { type: "literal", value: style } }],
302
+ },
303
+ },
304
+ ],
305
+ declarations: [{ type: "input-variable", name: "value" }],
306
+ locale: "en",
307
+ });
308
+ const { format } = await import("data:text/javascript;base64," +
309
+ btoa(createRegistry() +
310
+ `export const format = (i) => ${code.replaceAll("registry.", "")};`));
311
+ return { code, output: format({ value: input }) };
312
+ };
313
+ test.each([
314
+ ["short", { dateStyle: "short" }],
315
+ ["medium", { dateStyle: "medium" }],
316
+ ["long", { dateStyle: "long" }],
317
+ ["full", { dateStyle: "full" }],
318
+ // ICU's and MessageFormat 2's default date style
319
+ [undefined, { dateStyle: "medium" }],
320
+ ])("formats {d, date, %s} like Intl", async (style, options) => {
321
+ const { code, output } = await run("date", style, date);
322
+ expect(code).toContain("registry.datetime(");
323
+ expect(output).toBe(new Intl.DateTimeFormat("en", options).format(date));
324
+ });
325
+ test.each([
326
+ ["short", { timeStyle: "short" }],
327
+ ["medium", { timeStyle: "medium" }],
328
+ ["long", { timeStyle: "long" }],
329
+ ["full", { timeStyle: "full" }],
330
+ // ICU's default time style
331
+ [undefined, { timeStyle: "medium" }],
332
+ ])("formats {d, time, %s} like Intl", async (style, options) => {
333
+ const { output } = await run("time", style, date);
334
+ expect(output).toBe(new Intl.DateTimeFormat("en", options).format(date));
335
+ });
336
+ test("formats {n, number, integer} without fraction digits", async () => {
337
+ const { code, output } = await run("number", "integer", 1234.5);
338
+ expect(code).toContain("{ maximumFractionDigits: 0 }");
339
+ expect(output).toBe("1,235");
340
+ });
341
+ test("keeps Intl number styles", async () => {
342
+ expect((await run("number", "percent", 0.256)).output).toBe("26%");
343
+ });
344
+ test.each([
345
+ // ICU number skeletons
346
+ ["number", "::currency/EUR", 1234.5, "1,234.5"],
347
+ // "currency" needs a "currency" option
348
+ ["number", "currency", 1234.5, "1,234.5"],
349
+ // ICU time skeletons format like {d, time}
350
+ [
351
+ "time",
352
+ "::HHmm",
353
+ date,
354
+ new Intl.DateTimeFormat("en", { timeStyle: "medium" }).format(date),
355
+ ],
356
+ // ICU date skeletons format like {d, date}
357
+ [
358
+ "date",
359
+ "::yyyyMMdd",
360
+ date,
361
+ new Intl.DateTimeFormat("en", { dateStyle: "medium" }).format(date),
362
+ ],
363
+ ])("ignores the unsupported style {%s, %s} instead of throwing", async (name, style, input, expected) => {
364
+ const { code, output } = await run(name, style, input);
365
+ expect(code).not.toContain(style);
366
+ expect(output).toBe(expected);
367
+ });
368
+ });
369
+ describe("default date and time styles", () => {
370
+ const date = new Date(Date.UTC(2026, 9, 9, 14, 30));
371
+ /** Compiles `{$value :name option=value ...}` and runs it with the registry. */
372
+ const run = async (name, options = {}) => {
373
+ const { code } = compilePattern({
374
+ pattern: [
375
+ {
376
+ type: "expression",
377
+ arg: { type: "variable-reference", name: "value" },
378
+ annotation: {
379
+ type: "function-reference",
380
+ name,
381
+ options: Object.entries(options).map(([name, value]) => ({
382
+ name,
383
+ value: { type: "literal", value },
384
+ })),
385
+ },
386
+ },
387
+ ],
388
+ declarations: [{ type: "input-variable", name: "value" }],
389
+ locale: "en",
390
+ });
391
+ const { format } = await import("data:text/javascript;base64," +
392
+ btoa(createRegistry() +
393
+ `export const format = (i) => ${code.replaceAll("registry.", "")};`));
394
+ return { code, output: format({ value: date }) };
395
+ };
396
+ test("{$d :date} defaults to style=medium, like ICU and MessageFormat 2", async () => {
397
+ const { code, output } = await run("date", { timeZone: "UTC" });
398
+ expect(code).toContain('{ dateStyle: "medium", timeZone: "UTC" }');
399
+ expect(output).toBe("Oct 9, 2026");
400
+ });
401
+ test("{$d :time} defaults to ICU's style=medium", async () => {
402
+ const { code, output } = await run("time", { timeZone: "UTC" });
403
+ expect(code).toContain('{ timeStyle: "medium", timeZone: "UTC" }');
404
+ expect(output).toMatch(/^2:30:00\sPM$/);
405
+ });
406
+ test("{$d :datetime} defaults to dateStyle=medium timeStyle=short, like MessageFormat 2", async () => {
407
+ expect((await run("datetime")).code).toContain('{ dateStyle: "medium", timeStyle: "short" }');
408
+ const { output } = await run("datetime", { timeZone: "UTC" });
409
+ expect(output).toMatch(/^Oct 9, 2026, 2:30\sPM$/);
410
+ });
411
+ test.each([
412
+ ["datetime", { year: "numeric", timeZone: "UTC" }, "2026"],
413
+ ["datetime", { dateStyle: "long", timeZone: "UTC" }, "October 9, 2026"],
414
+ ["date", { month: "long", timeZone: "UTC" }, "October"],
415
+ // Intl throws for timeStyle together with hour
416
+ ["time", { hour: "numeric", hour12: "false", timeZone: "UTC" }, "14"],
417
+ ])("options that pick fields replace the default of %s %j", async (name, options, expected) => {
418
+ const { code, output } = await run(name, options);
419
+ // no default dateStyle=medium or timeStyle=medium/short is added
420
+ expect(code).not.toMatch(/"medium"|"short"/);
421
+ expect(output).toBe(expected);
422
+ });
423
+ });
424
+ test("a style from a variable replaces the default date style", () => {
425
+ const { code } = compilePattern({
426
+ pattern: [
427
+ {
428
+ type: "expression",
429
+ arg: { type: "variable-reference", name: "d" },
430
+ annotation: {
431
+ type: "function-reference",
432
+ name: "date",
433
+ options: [
434
+ {
435
+ name: "style",
436
+ value: { type: "variable-reference", name: "s" },
437
+ },
438
+ ],
439
+ },
440
+ },
441
+ ],
442
+ declarations: [
443
+ { type: "input-variable", name: "d" },
444
+ { type: "input-variable", name: "s" },
445
+ ],
446
+ locale: "en",
447
+ });
448
+ expect(code).toBe('`${registry.datetime("en", i?.d, { dateStyle: i?.s }, true)}`');
449
+ });
286
450
  //# sourceMappingURL=compile-pattern.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"compile-pattern.test.js","sourceRoot":"","sources":["../../src/compiler/compile-pattern.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD,IAAI,CAAC,oCAAoC,EAAE,GAAG,EAAE;IAC/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AM;YACZ,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC;YACvE,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;SAC7C;KACD,CAAC;IAEF,MAAM,EAAE,IAAI,EAAE,GAAG,cAAc,CAAC;QAC/B,IAAI,EAAE,OAAO;QACb,OAAO;QACP,YAAY,EAAE,CAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC;KAChE,CAAC,CAAC;IAEH,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAChB,+ZAA+Z,CAC/Z,CAAC;AACH,CAAC,CAAC,CAAC","sourcesContent":["import { test, expect } from \"vitest\";\nimport { compilePattern } from \"./compile-pattern.js\";\nimport type { Pattern } from \"@inlang/sdk\";\n\ntest(\"should compile a text only pattern\", () => {\n\tconst pattern: Pattern = [{ type: \"text\", value: \"Hello\" }];\n\tconst { code } = compilePattern({ pattern, declarations: [] });\n\texpect(code).toBe(\"`Hello`\");\n});\n\ntest(\"should compile a pattern with multiple VariableReference's\", () => {\n\tconst pattern: Pattern = [\n\t\t{ type: \"text\", value: \"Hello \" },\n\t\t{\n\t\t\ttype: \"expression\",\n\t\t\targ: {\n\t\t\t\ttype: \"variable-reference\",\n\t\t\t\tname: \"name\",\n\t\t\t},\n\t\t},\n\t\t{ type: \"text\", value: \"! You have \" },\n\t\t{ type: \"expression\", arg: { type: \"variable-reference\", name: \"count\" } },\n\t\t{ type: \"text\", value: \" messages.\" },\n\t];\n\n\tconst { code } = compilePattern({\n\t\tpattern,\n\t\tdeclarations: [\n\t\t\t{ type: \"input-variable\", name: \"name\" },\n\t\t\t{ type: \"input-variable\", name: \"count\" },\n\t\t],\n\t});\n\n\texpect(code).toBe(\"`Hello ${i?.name}! You have ${i?.count} messages.`\");\n});\n\ntest(\"uses bracket notation for input variables with non-identifier names\", () => {\n\tconst pattern: Pattern = [\n\t\t{ type: \"text\", value: \"Half \" },\n\t\t{\n\t\t\ttype: \"expression\",\n\t\t\targ: {\n\t\t\t\ttype: \"variable-reference\",\n\t\t\t\tname: \"half!\",\n\t\t\t},\n\t\t},\n\t];\n\n\tconst { code } = compilePattern({\n\t\tpattern,\n\t\tdeclarations: [{ type: \"input-variable\", name: \"half!\" }],\n\t});\n\n\texpect(code).toBe('`Half ${i?.[\"half!\"]}`');\n});\n\ntest(\"should escape backticks\", () => {\n\tconst pattern: Pattern = [{ type: \"text\", value: \"`Hello world`\" }];\n\tconst { code } = compilePattern({ pattern, declarations: [] });\n\texpect(code).toBe(\"`\\\\`Hello world\\\\``\");\n});\n\ntest(\"should escape backslashes\", () => {\n\tconst pattern: Pattern = [{ type: \"text\", value: \"\\\\Hello world\\\\\" }];\n\tconst { code } = compilePattern({ pattern, declarations: [] });\n\n\texpect(code).toBe(\"`\\\\\\\\Hello world\\\\\\\\`\");\n});\n\ntest(\"should escape escaped backticks\", () => {\n\tconst pattern: Pattern = [{ type: \"text\", value: \"\\\\`Hello world\\\\`\" }];\n\tconst { code } = compilePattern({ pattern, declarations: [] });\n\n\texpect(code).toBe(\"`\\\\\\\\\\\\`Hello world\\\\\\\\\\\\``\");\n});\n\ntest(\"should escape variable interpolation ( ${} )\", () => {\n\tconst pattern: Pattern = [{ type: \"text\", value: \"${name\" }];\n\tconst { code } = compilePattern({ pattern, declarations: [] });\n\n\texpect(code).toBe(\"`\\\\${name`\");\n});\n\ntest(\"it can reference local variables\", () => {\n\tconst { code } = compilePattern({\n\t\tpattern: [\n\t\t\t{ type: \"text\", value: \"Hello \" },\n\t\t\t{\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: {\n\t\t\t\t\ttype: \"variable-reference\",\n\t\t\t\t\tname: \"name\",\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t\tdeclarations: [\n\t\t\t{\n\t\t\t\ttype: \"local-variable\",\n\t\t\t\tname: \"name\",\n\t\t\t\tvalue: {\n\t\t\t\t\ttype: \"expression\",\n\t\t\t\t\targ: { type: \"literal\", value: \"Peter\" },\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t});\n\n\texpect(code).toBe(\"`Hello ${name}`\");\n});\n\ntest(\"plain string mode strips markup wrappers\", () => {\n\tconst pattern: Pattern = [\n\t\t{ type: \"text\", value: \"Hello \" },\n\t\t{ type: \"markup-start\", name: \"b\" },\n\t\t{ type: \"expression\", arg: { type: \"variable-reference\", name: \"name\" } },\n\t\t{ type: \"markup-end\", name: \"b\" },\n\t\t{ type: \"text\", value: \"!\" },\n\t];\n\n\tconst { code } = compilePattern({\n\t\tpattern,\n\t\tdeclarations: [{ type: \"input-variable\", name: \"name\" }],\n\t});\n\n\texpect(code).toBe(\"`Hello ${i?.name}!`\");\n});\n\ntest(\"compiles a pattern expression annotation to a registry call\", () => {\n\t// https://github.com/opral/paraglide-js/issues/694\n\tconst pattern: Pattern = [\n\t\t{\n\t\t\ttype: \"expression\",\n\t\t\targ: { type: \"variable-reference\", name: \"count\" },\n\t\t\tannotation: { type: \"function-reference\", name: \"number\", options: [] },\n\t\t},\n\t\t{ type: \"text\", value: \" views\" },\n\t];\n\n\tconst { code } = compilePattern({\n\t\tpattern,\n\t\tdeclarations: [{ type: \"input-variable\", name: \"count\" }],\n\t\tlocale: \"en\",\n\t});\n\n\texpect(code).toBe('`${registry.number(\"en\", i?.count, {})} views`');\n});\n\ntest(\"compiles pattern expression annotation options like local variable annotations\", () => {\n\tconst pattern: Pattern = [\n\t\t{\n\t\t\ttype: \"expression\",\n\t\t\targ: { type: \"variable-reference\", name: \"price\" },\n\t\t\tannotation: {\n\t\t\t\ttype: \"function-reference\",\n\t\t\t\tname: \"number\",\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"minimumFractionDigits\",\n\t\t\t\t\t\tvalue: { type: \"literal\", value: \"2\" },\n\t\t\t\t\t},\n\t\t\t\t\t{ name: \"style\", value: { type: \"literal\", value: \"percent\" } },\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t];\n\n\tconst { code } = compilePattern({\n\t\tpattern,\n\t\tdeclarations: [{ type: \"input-variable\", name: \"price\" }],\n\t\tlocale: \"de\",\n\t});\n\n\texpect(code).toBe(\n\t\t'`${registry.number(\"de\", i?.price, { minimumFractionDigits: 2, style: \"percent\" })}`'\n\t);\n});\n\ntest(\"compiles pattern annotation options that reference local variables\", () => {\n\tconst pattern: Pattern = [\n\t\t{\n\t\t\ttype: \"expression\",\n\t\t\targ: { type: \"variable-reference\", name: \"price\" },\n\t\t\tannotation: {\n\t\t\t\ttype: \"function-reference\",\n\t\t\t\tname: \"number\",\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"minimumFractionDigits\",\n\t\t\t\t\t\tvalue: { type: \"variable-reference\", name: \"digits\" },\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t];\n\n\tconst { code } = compilePattern({\n\t\tpattern,\n\t\tdeclarations: [\n\t\t\t{ type: \"input-variable\", name: \"price\" },\n\t\t\t{\n\t\t\t\ttype: \"local-variable\",\n\t\t\t\tname: \"digits\",\n\t\t\t\tvalue: { type: \"expression\", arg: { type: \"literal\", value: \"2\" } },\n\t\t\t},\n\t\t],\n\t\tlocale: \"en\",\n\t});\n\n\texpect(code).toBe(\n\t\t'`${registry.number(\"en\", i?.price, { minimumFractionDigits: digits })}`'\n\t);\n});\n\ntest(\"parts mode compiles pattern expression annotations to registry calls\", () => {\n\tconst pattern: Pattern = [\n\t\t{\n\t\t\ttype: \"expression\",\n\t\t\targ: { type: \"variable-reference\", name: \"count\" },\n\t\t\tannotation: { type: \"function-reference\", name: \"number\", options: [] },\n\t\t},\n\t\t{ type: \"text\", value: \" views\" },\n\t];\n\n\tconst { code } = compilePattern({\n\t\tmode: \"parts\",\n\t\tpattern,\n\t\tdeclarations: [{ type: \"input-variable\", name: \"count\" }],\n\t\tlocale: \"en\",\n\t});\n\n\texpect(code).toBe(\n\t\t'[{ type: \"text\", value: String(registry.number(\"en\", i?.count, {})) }, { type: \"text\", value: \" views\" }]'\n\t);\n});\n\ntest(\"falls back to plain interpolation for unknown formatters\", () => {\n\tconst pattern: Pattern = [\n\t\t{\n\t\t\ttype: \"expression\",\n\t\t\targ: { type: \"variable-reference\", name: \"name\" },\n\t\t\tannotation: {\n\t\t\t\ttype: \"function-reference\",\n\t\t\t\tname: \"uppercase\",\n\t\t\t\toptions: [],\n\t\t\t},\n\t\t},\n\t];\n\n\tconst { code } = compilePattern({\n\t\tpattern,\n\t\tdeclarations: [{ type: \"input-variable\", name: \"name\" }],\n\t\tlocale: \"en\",\n\t});\n\n\texpect(code).toBe(\"`${i?.name}`\");\n});\n\ntest(\"throws when a pattern annotation is compiled without a locale\", () => {\n\tconst pattern: Pattern = [\n\t\t{\n\t\t\ttype: \"expression\",\n\t\t\targ: { type: \"variable-reference\", name: \"count\" },\n\t\t\tannotation: { type: \"function-reference\", name: \"number\", options: [] },\n\t\t},\n\t];\n\n\texpect(() =>\n\t\tcompilePattern({\n\t\t\tpattern,\n\t\t\tdeclarations: [{ type: \"input-variable\", name: \"count\" }],\n\t\t})\n\t).toThrow('requires a locale to compile the formatter \"number\"');\n});\n\ntest(\"validates relativetime options on pattern annotations\", () => {\n\tconst pattern: Pattern = [\n\t\t{\n\t\t\ttype: \"expression\",\n\t\t\targ: { type: \"variable-reference\", name: \"days\" },\n\t\t\tannotation: {\n\t\t\t\ttype: \"function-reference\",\n\t\t\t\tname: \"relativetime\",\n\t\t\t\toptions: [],\n\t\t\t},\n\t\t},\n\t];\n\n\texpect(() =>\n\t\tcompilePattern({\n\t\t\tpattern,\n\t\t\tdeclarations: [{ type: \"input-variable\", name: \"days\" }],\n\t\t\tlocale: \"en\",\n\t\t})\n\t).toThrow('The \"relativetime\" formatter requires a \"unit\" option.');\n});\n\ntest(\"parts mode compiles text, markup, options and attributes\", () => {\n\tconst pattern: Pattern = [\n\t\t{ type: \"text\", value: \"Read \" },\n\t\t{\n\t\t\ttype: \"markup-start\",\n\t\t\tname: \"link\",\n\t\t\toptions: [\n\t\t\t\t{ name: \"to\", value: { type: \"literal\", value: \"/docs\" } },\n\t\t\t\t{\n\t\t\t\t\tname: \"rel\",\n\t\t\t\t\tvalue: { type: \"variable-reference\", name: \"relationship\" },\n\t\t\t\t},\n\t\t\t],\n\t\t\tattributes: [\n\t\t\t\t{ name: \"track\", value: true },\n\t\t\t\t{ name: \"variant\", value: { type: \"literal\", value: \"hero\" } },\n\t\t\t],\n\t\t},\n\t\t{ type: \"text\", value: \"docs\" },\n\t\t{\n\t\t\ttype: \"markup-end\",\n\t\t\tname: \"link\",\n\t\t\toptions: [{ name: \"to\", value: { type: \"literal\", value: \"/docs\" } }],\n\t\t\tattributes: [{ name: \"track\", value: true }],\n\t\t},\n\t\t{\n\t\t\ttype: \"markup-standalone\",\n\t\t\tname: \"icon\",\n\t\t\toptions: [{ name: \"name\", value: { type: \"literal\", value: \"arrow\" } }],\n\t\t\tattributes: [{ name: \"filled\", value: true }],\n\t\t},\n\t];\n\n\tconst { code } = compilePattern({\n\t\tmode: \"parts\",\n\t\tpattern,\n\t\tdeclarations: [{ type: \"input-variable\", name: \"relationship\" }],\n\t});\n\n\texpect(code).toBe(\n\t\t'[{ type: \"text\", value: \"Read \" }, { type: \"markup-start\", name: \"link\", options: { \"to\": \"/docs\", \"rel\": i?.relationship }, attributes: { \"track\": true, \"variant\": \"hero\" } }, { type: \"text\", value: \"docs\" }, { type: \"markup-end\", name: \"link\", options: { \"to\": \"/docs\" }, attributes: { \"track\": true } }, { type: \"markup-standalone\", name: \"icon\", options: { \"name\": \"arrow\" }, attributes: { \"filled\": true } }]'\n\t);\n});\n"]}
1
+ {"version":3,"file":"compile-pattern.test.js","sourceRoot":"","sources":["../../src/compiler/compile-pattern.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ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import { describe, test, expect } from \"vitest\";\nimport { compilePattern } from \"./compile-pattern.js\";\nimport type { Pattern } from \"@inlang/sdk\";\nimport { createRegistry } from \"./registry.js\";\n\ntest(\"should compile a text only pattern\", () => {\n\tconst pattern: Pattern = [{ type: \"text\", value: \"Hello\" }];\n\tconst { code } = compilePattern({ pattern, declarations: [] });\n\texpect(code).toBe(\"`Hello`\");\n});\n\ntest(\"should compile a pattern with multiple VariableReference's\", () => {\n\tconst pattern: Pattern = [\n\t\t{ type: \"text\", value: \"Hello \" },\n\t\t{\n\t\t\ttype: \"expression\",\n\t\t\targ: {\n\t\t\t\ttype: \"variable-reference\",\n\t\t\t\tname: \"name\",\n\t\t\t},\n\t\t},\n\t\t{ type: \"text\", value: \"! You have \" },\n\t\t{ type: \"expression\", arg: { type: \"variable-reference\", name: \"count\" } },\n\t\t{ type: \"text\", value: \" messages.\" },\n\t];\n\n\tconst { code } = compilePattern({\n\t\tpattern,\n\t\tdeclarations: [\n\t\t\t{ type: \"input-variable\", name: \"name\" },\n\t\t\t{ type: \"input-variable\", name: \"count\" },\n\t\t],\n\t});\n\n\texpect(code).toBe(\"`Hello ${i?.name}! You have ${i?.count} messages.`\");\n});\n\ntest(\"uses bracket notation for input variables with non-identifier names\", () => {\n\tconst pattern: Pattern = [\n\t\t{ type: \"text\", value: \"Half \" },\n\t\t{\n\t\t\ttype: \"expression\",\n\t\t\targ: {\n\t\t\t\ttype: \"variable-reference\",\n\t\t\t\tname: \"half!\",\n\t\t\t},\n\t\t},\n\t];\n\n\tconst { code } = compilePattern({\n\t\tpattern,\n\t\tdeclarations: [{ type: \"input-variable\", name: \"half!\" }],\n\t});\n\n\texpect(code).toBe('`Half ${i?.[\"half!\"]}`');\n});\n\ntest(\"should escape backticks\", () => {\n\tconst pattern: Pattern = [{ type: \"text\", value: \"`Hello world`\" }];\n\tconst { code } = compilePattern({ pattern, declarations: [] });\n\texpect(code).toBe(\"`\\\\`Hello world\\\\``\");\n});\n\ntest(\"should escape backslashes\", () => {\n\tconst pattern: Pattern = [{ type: \"text\", value: \"\\\\Hello world\\\\\" }];\n\tconst { code } = compilePattern({ pattern, declarations: [] });\n\n\texpect(code).toBe(\"`\\\\\\\\Hello world\\\\\\\\`\");\n});\n\ntest(\"should escape escaped backticks\", () => {\n\tconst pattern: Pattern = [{ type: \"text\", value: \"\\\\`Hello world\\\\`\" }];\n\tconst { code } = compilePattern({ pattern, declarations: [] });\n\n\texpect(code).toBe(\"`\\\\\\\\\\\\`Hello world\\\\\\\\\\\\``\");\n});\n\ntest(\"should escape variable interpolation ( ${} )\", () => {\n\tconst pattern: Pattern = [{ type: \"text\", value: \"${name\" }];\n\tconst { code } = compilePattern({ pattern, declarations: [] });\n\n\texpect(code).toBe(\"`\\\\${name`\");\n});\n\ntest(\"it can reference local variables\", () => {\n\tconst { code } = compilePattern({\n\t\tpattern: [\n\t\t\t{ type: \"text\", value: \"Hello \" },\n\t\t\t{\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: {\n\t\t\t\t\ttype: \"variable-reference\",\n\t\t\t\t\tname: \"name\",\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t\tdeclarations: [\n\t\t\t{\n\t\t\t\ttype: \"local-variable\",\n\t\t\t\tname: \"name\",\n\t\t\t\tvalue: {\n\t\t\t\t\ttype: \"expression\",\n\t\t\t\t\targ: { type: \"literal\", value: \"Peter\" },\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t});\n\n\texpect(code).toBe(\"`Hello ${name}`\");\n});\n\ntest(\"plain string mode strips markup wrappers\", () => {\n\tconst pattern: Pattern = [\n\t\t{ type: \"text\", value: \"Hello \" },\n\t\t{ type: \"markup-start\", name: \"b\" },\n\t\t{ type: \"expression\", arg: { type: \"variable-reference\", name: \"name\" } },\n\t\t{ type: \"markup-end\", name: \"b\" },\n\t\t{ type: \"text\", value: \"!\" },\n\t];\n\n\tconst { code } = compilePattern({\n\t\tpattern,\n\t\tdeclarations: [{ type: \"input-variable\", name: \"name\" }],\n\t});\n\n\texpect(code).toBe(\"`Hello ${i?.name}!`\");\n});\n\ntest(\"compiles a pattern expression annotation to a registry call\", () => {\n\t// https://github.com/opral/paraglide-js/issues/694\n\tconst pattern: Pattern = [\n\t\t{\n\t\t\ttype: \"expression\",\n\t\t\targ: { type: \"variable-reference\", name: \"count\" },\n\t\t\tannotation: { type: \"function-reference\", name: \"number\", options: [] },\n\t\t},\n\t\t{ type: \"text\", value: \" views\" },\n\t];\n\n\tconst { code } = compilePattern({\n\t\tpattern,\n\t\tdeclarations: [{ type: \"input-variable\", name: \"count\" }],\n\t\tlocale: \"en\",\n\t});\n\n\texpect(code).toBe('`${registry.number(\"en\", i?.count, {}, true)} views`');\n});\n\ntest(\"compiles pattern expression annotation options like local variable annotations\", () => {\n\tconst pattern: Pattern = [\n\t\t{\n\t\t\ttype: \"expression\",\n\t\t\targ: { type: \"variable-reference\", name: \"price\" },\n\t\t\tannotation: {\n\t\t\t\ttype: \"function-reference\",\n\t\t\t\tname: \"number\",\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"minimumFractionDigits\",\n\t\t\t\t\t\tvalue: { type: \"literal\", value: \"2\" },\n\t\t\t\t\t},\n\t\t\t\t\t{ name: \"style\", value: { type: \"literal\", value: \"percent\" } },\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t];\n\n\tconst { code } = compilePattern({\n\t\tpattern,\n\t\tdeclarations: [{ type: \"input-variable\", name: \"price\" }],\n\t\tlocale: \"de\",\n\t});\n\n\texpect(code).toBe(\n\t\t'`${registry.number(\"de\", i?.price, { minimumFractionDigits: 2, style: \"percent\" }, true)}`'\n\t);\n});\n\ntest(\"compiles pattern annotation options that reference local variables\", () => {\n\tconst pattern: Pattern = [\n\t\t{\n\t\t\ttype: \"expression\",\n\t\t\targ: { type: \"variable-reference\", name: \"price\" },\n\t\t\tannotation: {\n\t\t\t\ttype: \"function-reference\",\n\t\t\t\tname: \"number\",\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"minimumFractionDigits\",\n\t\t\t\t\t\tvalue: { type: \"variable-reference\", name: \"digits\" },\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t];\n\n\tconst { code } = compilePattern({\n\t\tpattern,\n\t\tdeclarations: [\n\t\t\t{ type: \"input-variable\", name: \"price\" },\n\t\t\t{\n\t\t\t\ttype: \"local-variable\",\n\t\t\t\tname: \"digits\",\n\t\t\t\tvalue: { type: \"expression\", arg: { type: \"literal\", value: \"2\" } },\n\t\t\t},\n\t\t],\n\t\tlocale: \"en\",\n\t});\n\n\texpect(code).toBe(\n\t\t'`${registry.number(\"en\", i?.price, { minimumFractionDigits: digits }, true)}`'\n\t);\n});\n\ntest(\"parts mode compiles pattern expression annotations to registry calls\", () => {\n\tconst pattern: Pattern = [\n\t\t{\n\t\t\ttype: \"expression\",\n\t\t\targ: { type: \"variable-reference\", name: \"count\" },\n\t\t\tannotation: { type: \"function-reference\", name: \"number\", options: [] },\n\t\t},\n\t\t{ type: \"text\", value: \" views\" },\n\t];\n\n\tconst { code } = compilePattern({\n\t\tmode: \"parts\",\n\t\tpattern,\n\t\tdeclarations: [{ type: \"input-variable\", name: \"count\" }],\n\t\tlocale: \"en\",\n\t});\n\n\texpect(code).toBe(\n\t\t'[{ type: \"text\", value: String(registry.number(\"en\", i?.count, {}, true)) }, { type: \"text\", value: \" views\" }]'\n\t);\n});\n\ntest(\"falls back to plain interpolation for unknown formatters\", () => {\n\tconst pattern: Pattern = [\n\t\t{\n\t\t\ttype: \"expression\",\n\t\t\targ: { type: \"variable-reference\", name: \"name\" },\n\t\t\tannotation: {\n\t\t\t\ttype: \"function-reference\",\n\t\t\t\tname: \"uppercase\",\n\t\t\t\toptions: [],\n\t\t\t},\n\t\t},\n\t];\n\n\tconst { code } = compilePattern({\n\t\tpattern,\n\t\tdeclarations: [{ type: \"input-variable\", name: \"name\" }],\n\t\tlocale: \"en\",\n\t});\n\n\texpect(code).toBe(\"`${i?.name}`\");\n});\n\ntest(\"throws when a pattern annotation is compiled without a locale\", () => {\n\tconst pattern: Pattern = [\n\t\t{\n\t\t\ttype: \"expression\",\n\t\t\targ: { type: \"variable-reference\", name: \"count\" },\n\t\t\tannotation: { type: \"function-reference\", name: \"number\", options: [] },\n\t\t},\n\t];\n\n\texpect(() =>\n\t\tcompilePattern({\n\t\t\tpattern,\n\t\t\tdeclarations: [{ type: \"input-variable\", name: \"count\" }],\n\t\t})\n\t).toThrow('requires a locale to compile the formatter \"number\"');\n});\n\ntest(\"validates relativetime options on pattern annotations\", () => {\n\tconst pattern: Pattern = [\n\t\t{\n\t\t\ttype: \"expression\",\n\t\t\targ: { type: \"variable-reference\", name: \"days\" },\n\t\t\tannotation: {\n\t\t\t\ttype: \"function-reference\",\n\t\t\t\tname: \"relativetime\",\n\t\t\t\toptions: [],\n\t\t\t},\n\t\t},\n\t];\n\n\texpect(() =>\n\t\tcompilePattern({\n\t\t\tpattern,\n\t\t\tdeclarations: [{ type: \"input-variable\", name: \"days\" }],\n\t\t\tlocale: \"en\",\n\t\t})\n\t).toThrow('The \"relativetime\" formatter requires a \"unit\" option.');\n});\n\ntest(\"parts mode compiles text, markup, options and attributes\", () => {\n\tconst pattern: Pattern = [\n\t\t{ type: \"text\", value: \"Read \" },\n\t\t{\n\t\t\ttype: \"markup-start\",\n\t\t\tname: \"link\",\n\t\t\toptions: [\n\t\t\t\t{ name: \"to\", value: { type: \"literal\", value: \"/docs\" } },\n\t\t\t\t{\n\t\t\t\t\tname: \"rel\",\n\t\t\t\t\tvalue: { type: \"variable-reference\", name: \"relationship\" },\n\t\t\t\t},\n\t\t\t],\n\t\t\tattributes: [\n\t\t\t\t{ name: \"track\", value: true },\n\t\t\t\t{ name: \"variant\", value: { type: \"literal\", value: \"hero\" } },\n\t\t\t],\n\t\t},\n\t\t{ type: \"text\", value: \"docs\" },\n\t\t{\n\t\t\ttype: \"markup-end\",\n\t\t\tname: \"link\",\n\t\t\toptions: [{ name: \"to\", value: { type: \"literal\", value: \"/docs\" } }],\n\t\t\tattributes: [{ name: \"track\", value: true }],\n\t\t},\n\t\t{\n\t\t\ttype: \"markup-standalone\",\n\t\t\tname: \"icon\",\n\t\t\toptions: [{ name: \"name\", value: { type: \"literal\", value: \"arrow\" } }],\n\t\t\tattributes: [{ name: \"filled\", value: true }],\n\t\t},\n\t];\n\n\tconst { code } = compilePattern({\n\t\tmode: \"parts\",\n\t\tpattern,\n\t\tdeclarations: [{ type: \"input-variable\", name: \"relationship\" }],\n\t});\n\n\texpect(code).toBe(\n\t\t'[{ type: \"text\", value: \"Read \" }, { type: \"markup-start\", name: \"link\", options: { \"to\": \"/docs\", \"rel\": i?.relationship }, attributes: { \"track\": true, \"variant\": \"hero\" } }, { type: \"text\", value: \"docs\" }, { type: \"markup-end\", name: \"link\", options: { \"to\": \"/docs\" }, attributes: { \"track\": true } }, { type: \"markup-standalone\", name: \"icon\", options: { \"name\": \"arrow\" }, attributes: { \"filled\": true } }]'\n\t);\n});\n\ndescribe(\"ICU MessageFormat 1 styles, as imported by the ICU1 plugin\", () => {\n\tconst date = new Date(Date.UTC(2026, 9, 9, 14, 30));\n\n\t/** Compiles `{arg :name style=style}` and runs it with the registry. */\n\tconst run = async (\n\t\tname: string,\n\t\tstyle: string | undefined,\n\t\tinput: unknown\n\t) => {\n\t\tconst { code } = compilePattern({\n\t\t\tpattern: [\n\t\t\t\t{\n\t\t\t\t\ttype: \"expression\",\n\t\t\t\t\targ: { type: \"variable-reference\", name: \"value\" },\n\t\t\t\t\tannotation: {\n\t\t\t\t\t\ttype: \"function-reference\",\n\t\t\t\t\t\tname,\n\t\t\t\t\t\toptions:\n\t\t\t\t\t\t\tstyle === undefined\n\t\t\t\t\t\t\t\t? []\n\t\t\t\t\t\t\t\t: [{ name: \"style\", value: { type: \"literal\", value: style } }],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t\tdeclarations: [{ type: \"input-variable\", name: \"value\" }],\n\t\t\tlocale: \"en\",\n\t\t});\n\t\tconst { format } = await import(\n\t\t\t\"data:text/javascript;base64,\" +\n\t\t\t\tbtoa(\n\t\t\t\t\tcreateRegistry() +\n\t\t\t\t\t\t`export const format = (i) => ${code.replaceAll(\"registry.\", \"\")};`\n\t\t\t\t)\n\t\t);\n\t\treturn { code, output: format({ value: input }) as string };\n\t};\n\n\ttest.each([\n\t\t[\"short\", { dateStyle: \"short\" }],\n\t\t[\"medium\", { dateStyle: \"medium\" }],\n\t\t[\"long\", { dateStyle: \"long\" }],\n\t\t[\"full\", { dateStyle: \"full\" }],\n\t\t// ICU's and MessageFormat 2's default date style\n\t\t[undefined, { dateStyle: \"medium\" }],\n\t] as const)(\"formats {d, date, %s} like Intl\", async (style, options) => {\n\t\tconst { code, output } = await run(\"date\", style, date);\n\t\texpect(code).toContain(\"registry.datetime(\");\n\t\texpect(output).toBe(new Intl.DateTimeFormat(\"en\", options).format(date));\n\t});\n\n\ttest.each([\n\t\t[\"short\", { timeStyle: \"short\" }],\n\t\t[\"medium\", { timeStyle: \"medium\" }],\n\t\t[\"long\", { timeStyle: \"long\" }],\n\t\t[\"full\", { timeStyle: \"full\" }],\n\t\t// ICU's default time style\n\t\t[undefined, { timeStyle: \"medium\" }],\n\t] as const)(\"formats {d, time, %s} like Intl\", async (style, options) => {\n\t\tconst { output } = await run(\"time\", style, date);\n\t\texpect(output).toBe(new Intl.DateTimeFormat(\"en\", options).format(date));\n\t});\n\n\ttest(\"formats {n, number, integer} without fraction digits\", async () => {\n\t\tconst { code, output } = await run(\"number\", \"integer\", 1234.5);\n\t\texpect(code).toContain(\"{ maximumFractionDigits: 0 }\");\n\t\texpect(output).toBe(\"1,235\");\n\t});\n\n\ttest(\"keeps Intl number styles\", async () => {\n\t\texpect((await run(\"number\", \"percent\", 0.256)).output).toBe(\"26%\");\n\t});\n\n\ttest.each([\n\t\t// ICU number skeletons\n\t\t[\"number\", \"::currency/EUR\", 1234.5, \"1,234.5\"],\n\t\t// \"currency\" needs a \"currency\" option\n\t\t[\"number\", \"currency\", 1234.5, \"1,234.5\"],\n\t\t// ICU time skeletons format like {d, time}\n\t\t[\n\t\t\t\"time\",\n\t\t\t\"::HHmm\",\n\t\t\tdate,\n\t\t\tnew Intl.DateTimeFormat(\"en\", { timeStyle: \"medium\" }).format(date),\n\t\t],\n\t\t// ICU date skeletons format like {d, date}\n\t\t[\n\t\t\t\"date\",\n\t\t\t\"::yyyyMMdd\",\n\t\t\tdate,\n\t\t\tnew Intl.DateTimeFormat(\"en\", { dateStyle: \"medium\" }).format(date),\n\t\t],\n\t] as const)(\n\t\t\"ignores the unsupported style {%s, %s} instead of throwing\",\n\t\tasync (name, style, input, expected) => {\n\t\t\tconst { code, output } = await run(name, style, input);\n\t\t\texpect(code).not.toContain(style);\n\t\t\texpect(output).toBe(expected);\n\t\t}\n\t);\n});\n\ndescribe(\"default date and time styles\", () => {\n\tconst date = new Date(Date.UTC(2026, 9, 9, 14, 30));\n\n\t/** Compiles `{$value :name option=value ...}` and runs it with the registry. */\n\tconst run = async (name: string, options: Record<string, string> = {}) => {\n\t\tconst { code } = compilePattern({\n\t\t\tpattern: [\n\t\t\t\t{\n\t\t\t\t\ttype: \"expression\",\n\t\t\t\t\targ: { type: \"variable-reference\", name: \"value\" },\n\t\t\t\t\tannotation: {\n\t\t\t\t\t\ttype: \"function-reference\",\n\t\t\t\t\t\tname,\n\t\t\t\t\t\toptions: Object.entries(options).map(([name, value]) => ({\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\tvalue: { type: \"literal\", value },\n\t\t\t\t\t\t})),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t\tdeclarations: [{ type: \"input-variable\", name: \"value\" }],\n\t\t\tlocale: \"en\",\n\t\t});\n\t\tconst { format } = await import(\n\t\t\t\"data:text/javascript;base64,\" +\n\t\t\t\tbtoa(\n\t\t\t\t\tcreateRegistry() +\n\t\t\t\t\t\t`export const format = (i) => ${code.replaceAll(\"registry.\", \"\")};`\n\t\t\t\t)\n\t\t);\n\t\treturn { code, output: format({ value: date }) as string };\n\t};\n\n\ttest(\"{$d :date} defaults to style=medium, like ICU and MessageFormat 2\", async () => {\n\t\tconst { code, output } = await run(\"date\", { timeZone: \"UTC\" });\n\t\texpect(code).toContain('{ dateStyle: \"medium\", timeZone: \"UTC\" }');\n\t\texpect(output).toBe(\"Oct 9, 2026\");\n\t});\n\n\ttest(\"{$d :time} defaults to ICU's style=medium\", async () => {\n\t\tconst { code, output } = await run(\"time\", { timeZone: \"UTC\" });\n\t\texpect(code).toContain('{ timeStyle: \"medium\", timeZone: \"UTC\" }');\n\t\texpect(output).toMatch(/^2:30:00\\sPM$/);\n\t});\n\n\ttest(\"{$d :datetime} defaults to dateStyle=medium timeStyle=short, like MessageFormat 2\", async () => {\n\t\texpect((await run(\"datetime\")).code).toContain(\n\t\t\t'{ dateStyle: \"medium\", timeStyle: \"short\" }'\n\t\t);\n\t\tconst { output } = await run(\"datetime\", { timeZone: \"UTC\" });\n\t\texpect(output).toMatch(/^Oct 9, 2026, 2:30\\sPM$/);\n\t});\n\n\ttest.each([\n\t\t[\"datetime\", { year: \"numeric\", timeZone: \"UTC\" }, \"2026\"],\n\t\t[\"datetime\", { dateStyle: \"long\", timeZone: \"UTC\" }, \"October 9, 2026\"],\n\t\t[\"date\", { month: \"long\", timeZone: \"UTC\" }, \"October\"],\n\t\t// Intl throws for timeStyle together with hour\n\t\t[\"time\", { hour: \"numeric\", hour12: \"false\", timeZone: \"UTC\" }, \"14\"],\n\t] as const)(\n\t\t\"options that pick fields replace the default of %s %j\",\n\t\tasync (name, options, expected) => {\n\t\t\tconst { code, output } = await run(name, options);\n\t\t\t// no default dateStyle=medium or timeStyle=medium/short is added\n\t\t\texpect(code).not.toMatch(/\"medium\"|\"short\"/);\n\t\t\texpect(output).toBe(expected);\n\t\t}\n\t);\n});\n\ntest(\"a style from a variable replaces the default date style\", () => {\n\tconst { code } = compilePattern({\n\t\tpattern: [\n\t\t\t{\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: { type: \"variable-reference\", name: \"d\" },\n\t\t\t\tannotation: {\n\t\t\t\t\ttype: \"function-reference\",\n\t\t\t\t\tname: \"date\",\n\t\t\t\t\toptions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: \"style\",\n\t\t\t\t\t\t\tvalue: { type: \"variable-reference\", name: \"s\" },\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t\tdeclarations: [\n\t\t\t{ type: \"input-variable\", name: \"d\" },\n\t\t\t{ type: \"input-variable\", name: \"s\" },\n\t\t],\n\t\tlocale: \"en\",\n\t});\n\texpect(code).toBe('`${registry.datetime(\"en\", i?.d, { dateStyle: i?.s }, true)}`');\n});\n"]}
@@ -40,6 +40,7 @@ export const compileProject = async (args) => {
40
40
  const compiledBundles = bundles.map((bundle) => compileBundle({
41
41
  bundle,
42
42
  fallbackMap,
43
+ inlineMessages: optionsWithDefaults.outputStructure === "message-modules",
43
44
  messageReferenceExpression: outputStructure.messageReferenceExpression,
44
45
  settings,
45
46
  experimentalMiddlewareLocaleSplitting: optionsWithDefaults.experimentalMiddlewareLocaleSplitting,
@@ -71,7 +72,10 @@ export const compileProject = async (args) => {
71
72
  output[".prettierignore"] = ignoreDirectory;
72
73
  }
73
74
  if (optionsWithDefaults.emitReadme) {
74
- output["README.md"] = createReadme({ projectPath: args.projectPath });
75
+ output["README.md"] = createReadme({
76
+ projectPath: args.projectPath,
77
+ gitignored: optionsWithDefaults.emitGitIgnore,
78
+ });
75
79
  }
76
80
  // Declare the generated message modules side-effect-free so bundlers can drop
77
81
  // unused re-exports from the `m` barrel per entry, instead of bundling every
@@ -1 +1 @@
1
- {"version":3,"file":"compile-project.js","sourceRoot":"","sources":["../../src/compiler/compile-project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAs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AC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACvE,MAAM,IAAI,KAAK,CACd,2BAA2B,KAAK,YAAY,aAAa,CAAC,KAAK,iCAAiC,OAAO,EAAE,CACzG,CAAC;QACH,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["import { compileBundle } from \"./compile-bundle.js\";\nimport { selectBundleNested, type InlangProject } from \"@inlang/sdk\";\nimport { lookup } from \"../services/lookup.js\";\nimport * as localeModules from \"./output-structure/locale-modules.js\";\nimport * as messageModules from \"./output-structure/message-modules.js\";\nimport {\n\tdefaultCompilerOptions,\n\ttype CompilerOptions,\n} from \"./compiler-options.js\";\nimport { createRuntimeFile } from \"./runtime/create-runtime.js\";\nimport { createServerFile } from \"./server/create-server-file.js\";\nimport { createRegistry } from \"./registry.js\";\nimport { emitTsDeclarations } from \"./emit-ts-declarations.js\";\nimport { createReadme } from \"./create-readme.js\";\nimport { perLocaleBuildStaticLocaleExpression } from \"./per-locale-build.js\";\n\nconst outputStructures = {\n\t\"locale-modules\": localeModules,\n\t\"message-modules\": messageModules,\n};\n\n/**\n * Takes an inlang project and compiles it into a set of files.\n *\n * Use this function for more programmatic control than `compile()`.\n * You can adjust the output structure and get the compiled files as a return value.\n *\n * @example\n * const output = await compileProject({ project, projectPath: \"./project.inlang\" });\n * await writeOutput('path', output, fs.promises);\n */\nexport const compileProject = async (args: {\n\tproject: InlangProject;\n\tprojectPath?: string;\n\tcompilerOptions?: Omit<CompilerOptions, \"fs\" | \"project\" | \"outdir\">;\n}): Promise<Record<string, string>> => {\n\tconst optionsWithDefaults = {\n\t\t...defaultCompilerOptions,\n\t\t...args.compilerOptions,\n\t};\n\tawait ensureURLPatternAvailable();\n\tvalidateRouteStrategyMatchers(optionsWithDefaults.routeStrategies);\n\n\tconst settings = await args.project.settings.get();\n\tconst bundles = await selectBundleNested(args.project.db).execute();\n\n\t//Maps each language to it's fallback\n\t//If there is no fallback, it will be undefined\n\tconst fallbackMap = getFallbackMap(settings.locales, settings.baseLocale);\n\n\tconst outputStructure = outputStructures[optionsWithDefaults.outputStructure];\n\n\tconst compiledBundles = bundles.map((bundle) =>\n\t\tcompileBundle({\n\t\t\tbundle,\n\t\t\tfallbackMap,\n\t\t\tmessageReferenceExpression: outputStructure.messageReferenceExpression,\n\t\t\tsettings,\n\t\t\texperimentalMiddlewareLocaleSplitting:\n\t\t\t\toptionsWithDefaults.experimentalMiddlewareLocaleSplitting,\n\t\t\texperimentalStaticLocale: optionsWithDefaults.experimentalStaticLocale,\n\t\t})\n\t);\n\n\tconst output: Record<string, string> = {\n\t\t[\"runtime.js\"]: createRuntimeFile({\n\t\t\tbaseLocale: settings.baseLocale,\n\t\t\tlocales: settings.locales,\n\t\t\tcompilerOptions: optionsWithDefaults,\n\t\t}),\n\t\t[\"server.js\"]: createServerFile({\n\t\t\tcompiledBundles,\n\t\t\tcompilerOptions: optionsWithDefaults,\n\t\t}),\n\t\t[\"registry.js\"]: createRegistry(),\n\t\t[\"messages.js\"]: [\n\t\t\t\"export * from './messages/_index.js'\",\n\t\t\t\"// enabling auto-import by exposing all messages as m\",\n\t\t\t\"export * as m from './messages/_index.js'\",\n\t\t].join(\"\\n\"),\n\t};\n\n\t// generate the output modules\n\tObject.assign(\n\t\toutput,\n\t\toutputStructure.generateOutput(\n\t\t\tcompiledBundles,\n\t\t\tsettings,\n\t\t\tfallbackMap,\n\t\t\toptionsWithDefaults.experimentalMiddlewareLocaleSplitting\n\t\t)\n\t);\n\n\tif (optionsWithDefaults.emitGitIgnore) {\n\t\toutput[\".gitignore\"] = ignoreDirectory;\n\t}\n\n\tif (optionsWithDefaults.emitPrettierIgnore) {\n\t\toutput[\".prettierignore\"] = ignoreDirectory;\n\t}\n\n\tif (optionsWithDefaults.emitReadme) {\n\t\toutput[\"README.md\"] = createReadme({ projectPath: args.projectPath });\n\t}\n\n\t// Declare the generated message modules side-effect-free so bundlers can drop\n\t// unused re-exports from the `m` barrel per entry, instead of bundling every\n\t// message used anywhere in the app into one shared chunk that every entry\n\t// downloads. Scoped to `messages/` so `runtime.js` (one level up, which has\n\t// real side effects) is unaffected. This also lets locale-specialized builds\n\t// discard the unselected locale modules before Rolldown creates source maps.\n\t//\n\t// `type: \"module\"` is required: this package.json creates a new module scope\n\t// for `messages/`, and a package.json without a `type` field defaults to\n\t// CommonJS in Node — even when the consuming project is `type: \"module\"`.\n\t// Without it, the generated ESM `.js` files in `messages/` would be treated\n\t// as CommonJS and fail to resolve.\n\t// See https://github.com/opral/paraglide-js/issues/668\n\tif (\n\t\toptionsWithDefaults.outputStructure === \"message-modules\" ||\n\t\toptionsWithDefaults.experimentalStaticLocale ===\n\t\t\tperLocaleBuildStaticLocaleExpression\n\t) {\n\t\toutput[\"messages/package.json\"] =\n\t\t\tJSON.stringify({ type: \"module\", sideEffects: false }, undefined, \"\\t\") +\n\t\t\t\"\\n\";\n\t}\n\n\tfor (const [filename, content] of Object.entries(\n\t\toptionsWithDefaults.additionalFiles ?? {}\n\t)) {\n\t\toutput[filename] = content;\n\t}\n\n\tfor (const [filename, content] of Object.entries(output)) {\n\t\tif (optionsWithDefaults.includeEslintDisableComment) {\n\t\t\tif (filename.endsWith(\".js\")) {\n\t\t\t\toutput[filename] = `/* eslint-disable */\\n${content}`;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (optionsWithDefaults.emitTsDeclarations) {\n\t\tconst declarations = await emitTsDeclarations(output);\n\t\tObject.assign(output, declarations);\n\t}\n\n\treturn output;\n};\n\nexport function getFallbackMap<T extends string>(\n\tlocales: T[],\n\tbaseLocale: NoInfer<T>\n): Record<T, T | undefined> {\n\treturn Object.fromEntries(\n\t\tlocales.map((lang) => {\n\t\t\tif (lang === baseLocale) return [lang, undefined];\n\t\t\tconst fallbackLanguage = lookup(lang, {\n\t\t\t\tlocales: locales.filter((l) => l !== lang),\n\t\t\t\tbaseLocale,\n\t\t\t});\n\n\t\t\tif (lang === fallbackLanguage) return [lang, undefined];\n\t\t\telse return [lang, fallbackLanguage];\n\t\t})\n\t) as Record<T, T | undefined>;\n}\n\nconst ignoreDirectory = `# ignore everything because the directory is auto-generated by inlang paraglide-js\n# for more info visit https://paraglidejs.com\n*\n`;\n\nasync function ensureURLPatternAvailable() {\n\ttry {\n\t\tnew URLPattern({ pathname: \"/:path(.*)?\" });\n\t} catch {\n\t\tawait import(\"urlpattern-polyfill\");\n\t}\n}\n\nfunction validateRouteStrategyMatchers(\n\trouteStrategies: CompilerOptions[\"routeStrategies\"]\n) {\n\tif (!routeStrategies?.length) {\n\t\treturn;\n\t}\n\n\tfor (const [index, routeStrategy] of routeStrategies.entries()) {\n\t\ttry {\n\t\t\tnew URLPattern(routeStrategy.match, \"https://example.com\");\n\t\t} catch (error) {\n\t\t\tconst details = error instanceof Error ? error.message : String(error);\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid routeStrategies[${index}].match \"${routeStrategy.match}\". URLPattern parsing failed: ${details}`\n\t\t\t);\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"compile-project.js","sourceRoot":"","sources":["../../src/compiler/compile-project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAsB,MAAM,aAAa,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,KAAK,aAAa,MAAM,sCAAsC,CAAC;AACtE,OAAO,KAAK,cAAc,MAAM,uCAAuC,CAAC;AACxE,OAAO,EACN,sBAAsB,GAEtB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,oBA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,IAAI,CAAC;YAC1C,UAAU;SACV,CAAC,CAAC;QAEH,IAAI,IAAI,KAAK,gBAAgB;YAAE,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;;YACnD,OAAO,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;IACtC,CAAC,CAAC,CAC0B,CAAC;AAC/B,CAAC;AAED,MAAM,eAAe,GAAG;;;CAGvB,CAAC;AAEF,KAAK,UAAU,yBAAyB;IACvC,IAAI,CAAC;QACJ,IAAI,UAAU,CAAC,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC,CAAC;IAC7C,CAAC;IAAC,MAAM,CAAC;QACR,MAAM,MAAM,CAAC,qBAAqB,CAAC,CAAC;IACrC,CAAC;AACF,CAAC;AAED,SAAS,6BAA6B,CACrC,eAAmD;IAEnD,IAAI,CAAC,eAAe,EAAE,MAAM,EAAE,CAAC;QAC9B,OAAO;IACR,CAAC;IAED,KAAK,MAAM,CAAC,KAAK,EAAE,aAAa,CAAC,IAAI,eAAe,CAAC,OAAO,EAAE,EAAE,CAAC;QAChE,IAAI,CAAC;YACJ,IAAI,UAAU,CAAC,aAAa,CAAC,KAAK,EAAE,qBAAqB,CAAC,CAAC;QAC5D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACvE,MAAM,IAAI,KAAK,CACd,2BAA2B,KAAK,YAAY,aAAa,CAAC,KAAK,iCAAiC,OAAO,EAAE,CACzG,CAAC;QACH,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["import { compileBundle } from \"./compile-bundle.js\";\nimport { selectBundleNested, type InlangProject } from \"@inlang/sdk\";\nimport { lookup } from \"../services/lookup.js\";\nimport * as localeModules from \"./output-structure/locale-modules.js\";\nimport * as messageModules from \"./output-structure/message-modules.js\";\nimport {\n\tdefaultCompilerOptions,\n\ttype CompilerOptions,\n} from \"./compiler-options.js\";\nimport { createRuntimeFile } from \"./runtime/create-runtime.js\";\nimport { createServerFile } from \"./server/create-server-file.js\";\nimport { createRegistry } from \"./registry.js\";\nimport { emitTsDeclarations } from \"./emit-ts-declarations.js\";\nimport { createReadme } from \"./create-readme.js\";\nimport { perLocaleBuildStaticLocaleExpression } from \"./per-locale-build.js\";\n\nconst outputStructures = {\n\t\"locale-modules\": localeModules,\n\t\"message-modules\": messageModules,\n};\n\n/**\n * Takes an inlang project and compiles it into a set of files.\n *\n * Use this function for more programmatic control than `compile()`.\n * You can adjust the output structure and get the compiled files as a return value.\n *\n * @example\n * const output = await compileProject({ project, projectPath: \"./project.inlang\" });\n * await writeOutput('path', output, fs.promises);\n */\nexport const compileProject = async (args: {\n\tproject: InlangProject;\n\tprojectPath?: string;\n\tcompilerOptions?: Omit<CompilerOptions, \"fs\" | \"project\" | \"outdir\">;\n}): Promise<Record<string, string>> => {\n\tconst optionsWithDefaults = {\n\t\t...defaultCompilerOptions,\n\t\t...args.compilerOptions,\n\t};\n\tawait ensureURLPatternAvailable();\n\tvalidateRouteStrategyMatchers(optionsWithDefaults.routeStrategies);\n\n\tconst settings = await args.project.settings.get();\n\tconst bundles = await selectBundleNested(args.project.db).execute();\n\n\t//Maps each language to it's fallback\n\t//If there is no fallback, it will be undefined\n\tconst fallbackMap = getFallbackMap(settings.locales, settings.baseLocale);\n\n\tconst outputStructure = outputStructures[optionsWithDefaults.outputStructure];\n\n\tconst compiledBundles = bundles.map((bundle) =>\n\t\tcompileBundle({\n\t\t\tbundle,\n\t\t\tfallbackMap,\n\t\t\tinlineMessages: optionsWithDefaults.outputStructure === \"message-modules\",\n\t\t\tmessageReferenceExpression: outputStructure.messageReferenceExpression,\n\t\t\tsettings,\n\t\t\texperimentalMiddlewareLocaleSplitting:\n\t\t\t\toptionsWithDefaults.experimentalMiddlewareLocaleSplitting,\n\t\t\texperimentalStaticLocale: optionsWithDefaults.experimentalStaticLocale,\n\t\t})\n\t);\n\n\tconst output: Record<string, string> = {\n\t\t[\"runtime.js\"]: createRuntimeFile({\n\t\t\tbaseLocale: settings.baseLocale,\n\t\t\tlocales: settings.locales,\n\t\t\tcompilerOptions: optionsWithDefaults,\n\t\t}),\n\t\t[\"server.js\"]: createServerFile({\n\t\t\tcompiledBundles,\n\t\t\tcompilerOptions: optionsWithDefaults,\n\t\t}),\n\t\t[\"registry.js\"]: createRegistry(),\n\t\t[\"messages.js\"]: [\n\t\t\t\"export * from './messages/_index.js'\",\n\t\t\t\"// enabling auto-import by exposing all messages as m\",\n\t\t\t\"export * as m from './messages/_index.js'\",\n\t\t].join(\"\\n\"),\n\t};\n\n\t// generate the output modules\n\tObject.assign(\n\t\toutput,\n\t\toutputStructure.generateOutput(\n\t\t\tcompiledBundles,\n\t\t\tsettings,\n\t\t\tfallbackMap,\n\t\t\toptionsWithDefaults.experimentalMiddlewareLocaleSplitting\n\t\t)\n\t);\n\n\tif (optionsWithDefaults.emitGitIgnore) {\n\t\toutput[\".gitignore\"] = ignoreDirectory;\n\t}\n\n\tif (optionsWithDefaults.emitPrettierIgnore) {\n\t\toutput[\".prettierignore\"] = ignoreDirectory;\n\t}\n\n\tif (optionsWithDefaults.emitReadme) {\n\t\toutput[\"README.md\"] = createReadme({\n\t\t\tprojectPath: args.projectPath,\n\t\t\tgitignored: optionsWithDefaults.emitGitIgnore,\n\t\t});\n\t}\n\n\t// Declare the generated message modules side-effect-free so bundlers can drop\n\t// unused re-exports from the `m` barrel per entry, instead of bundling every\n\t// message used anywhere in the app into one shared chunk that every entry\n\t// downloads. Scoped to `messages/` so `runtime.js` (one level up, which has\n\t// real side effects) is unaffected. This also lets locale-specialized builds\n\t// discard the unselected locale modules before Rolldown creates source maps.\n\t//\n\t// `type: \"module\"` is required: this package.json creates a new module scope\n\t// for `messages/`, and a package.json without a `type` field defaults to\n\t// CommonJS in Node — even when the consuming project is `type: \"module\"`.\n\t// Without it, the generated ESM `.js` files in `messages/` would be treated\n\t// as CommonJS and fail to resolve.\n\t// See https://github.com/opral/paraglide-js/issues/668\n\tif (\n\t\toptionsWithDefaults.outputStructure === \"message-modules\" ||\n\t\toptionsWithDefaults.experimentalStaticLocale ===\n\t\t\tperLocaleBuildStaticLocaleExpression\n\t) {\n\t\toutput[\"messages/package.json\"] =\n\t\t\tJSON.stringify({ type: \"module\", sideEffects: false }, undefined, \"\\t\") +\n\t\t\t\"\\n\";\n\t}\n\n\tfor (const [filename, content] of Object.entries(\n\t\toptionsWithDefaults.additionalFiles ?? {}\n\t)) {\n\t\toutput[filename] = content;\n\t}\n\n\tfor (const [filename, content] of Object.entries(output)) {\n\t\tif (optionsWithDefaults.includeEslintDisableComment) {\n\t\t\tif (filename.endsWith(\".js\")) {\n\t\t\t\toutput[filename] = `/* eslint-disable */\\n${content}`;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (optionsWithDefaults.emitTsDeclarations) {\n\t\tconst declarations = await emitTsDeclarations(output);\n\t\tObject.assign(output, declarations);\n\t}\n\n\treturn output;\n};\n\nexport function getFallbackMap<T extends string>(\n\tlocales: T[],\n\tbaseLocale: NoInfer<T>\n): Record<T, T | undefined> {\n\treturn Object.fromEntries(\n\t\tlocales.map((lang) => {\n\t\t\tif (lang === baseLocale) return [lang, undefined];\n\t\t\tconst fallbackLanguage = lookup(lang, {\n\t\t\t\tlocales: locales.filter((l) => l !== lang),\n\t\t\t\tbaseLocale,\n\t\t\t});\n\n\t\t\tif (lang === fallbackLanguage) return [lang, undefined];\n\t\t\telse return [lang, fallbackLanguage];\n\t\t})\n\t) as Record<T, T | undefined>;\n}\n\nconst ignoreDirectory = `# ignore everything because the directory is auto-generated by inlang paraglide-js\n# for more info visit https://paraglidejs.com\n*\n`;\n\nasync function ensureURLPatternAvailable() {\n\ttry {\n\t\tnew URLPattern({ pathname: \"/:path(.*)?\" });\n\t} catch {\n\t\tawait import(\"urlpattern-polyfill\");\n\t}\n}\n\nfunction validateRouteStrategyMatchers(\n\trouteStrategies: CompilerOptions[\"routeStrategies\"]\n) {\n\tif (!routeStrategies?.length) {\n\t\treturn;\n\t}\n\n\tfor (const [index, routeStrategy] of routeStrategies.entries()) {\n\t\ttry {\n\t\t\tnew URLPattern(routeStrategy.match, \"https://example.com\");\n\t\t} catch (error) {\n\t\t\tconst details = error instanceof Error ? error.message : String(error);\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid routeStrategies[${index}].match \"${routeStrategy.match}\". URLPattern parsing failed: ${details}`\n\t\t\t);\n\t\t}\n\t}\n}\n"]}