@inlang/paraglide-js 2.0.0-beta.26 → 2.0.0-beta.28

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 (164) hide show
  1. package/README.md +5 -1
  2. package/dist/bundler-plugins/unplugin.d.ts.map +1 -1
  3. package/dist/bundler-plugins/unplugin.js +17 -1
  4. package/dist/compiler/compile-bundle.d.ts +1 -0
  5. package/dist/compiler/compile-bundle.d.ts.map +1 -1
  6. package/dist/compiler/compile-bundle.js +6 -1
  7. package/dist/compiler/compile-bundle.test.js +6 -0
  8. package/dist/compiler/compile-message.d.ts.map +1 -1
  9. package/dist/compiler/compile-message.js +2 -7
  10. package/dist/compiler/compile-message.test.js +12 -33
  11. package/dist/compiler/compile-project.d.ts.map +1 -1
  12. package/dist/compiler/compile-project.js +30 -11
  13. package/dist/compiler/compile-project.test.js +167 -0
  14. package/dist/compiler/compiler-options.d.ts +39 -1
  15. package/dist/compiler/compiler-options.d.ts.map +1 -1
  16. package/dist/compiler/compiler-options.js +3 -0
  17. package/dist/compiler/output-structure/locale-modules.d.ts +2 -5
  18. package/dist/compiler/output-structure/locale-modules.d.ts.map +1 -1
  19. package/dist/compiler/output-structure/locale-modules.js +9 -19
  20. package/dist/compiler/output-structure/locale-modules.test.js +3 -6
  21. package/dist/compiler/output-structure/message-modules.d.ts +2 -5
  22. package/dist/compiler/output-structure/message-modules.d.ts.map +1 -1
  23. package/dist/compiler/output-structure/message-modules.js +52 -61
  24. package/dist/compiler/output-structure/message-modules.test.js +7 -17
  25. package/dist/compiler/runtime/create-runtime.d.ts +3 -0
  26. package/dist/compiler/runtime/create-runtime.d.ts.map +1 -1
  27. package/dist/compiler/runtime/create-runtime.js +32 -8
  28. package/dist/compiler/runtime/extract-locale-from-request.d.ts +2 -1
  29. package/dist/compiler/runtime/extract-locale-from-request.d.ts.map +1 -1
  30. package/dist/compiler/runtime/extract-locale-from-request.js +16 -6
  31. package/dist/compiler/runtime/extract-locale-from-request.test.js +105 -23
  32. package/dist/compiler/runtime/extract-locale-from-url.d.ts.map +1 -1
  33. package/dist/compiler/runtime/extract-locale-from-url.js +10 -33
  34. package/dist/compiler/runtime/extract-locale-from-url.test.js +44 -55
  35. package/dist/compiler/runtime/generate-static-localized-urls.d.ts +24 -0
  36. package/dist/compiler/runtime/generate-static-localized-urls.d.ts.map +1 -0
  37. package/dist/compiler/runtime/generate-static-localized-urls.js +91 -0
  38. package/dist/compiler/runtime/generate-static-localized-urls.test.d.ts +2 -0
  39. package/dist/compiler/runtime/generate-static-localized-urls.test.d.ts.map +1 -0
  40. package/dist/compiler/runtime/generate-static-localized-urls.test.js +169 -0
  41. package/dist/compiler/runtime/get-locale.d.ts.map +1 -1
  42. package/dist/compiler/runtime/get-locale.js +17 -6
  43. package/dist/compiler/runtime/get-locale.test.js +66 -13
  44. package/dist/compiler/runtime/localize-href.test.js +28 -54
  45. package/dist/compiler/runtime/localize-url.d.ts.map +1 -1
  46. package/dist/compiler/runtime/localize-url.js +61 -30
  47. package/dist/compiler/runtime/localize-url.test.js +130 -126
  48. package/dist/compiler/runtime/set-locale.d.ts +12 -2
  49. package/dist/compiler/runtime/set-locale.d.ts.map +1 -1
  50. package/dist/compiler/runtime/set-locale.js +47 -16
  51. package/dist/compiler/runtime/set-locale.test.js +100 -11
  52. package/dist/compiler/runtime/track-message-call.d.ts +6 -0
  53. package/dist/compiler/runtime/track-message-call.d.ts.map +1 -0
  54. package/dist/compiler/runtime/track-message-call.js +13 -0
  55. package/dist/compiler/runtime/track-message-call.test.d.ts +2 -0
  56. package/dist/compiler/runtime/track-message-call.test.d.ts.map +1 -0
  57. package/dist/compiler/runtime/track-message-call.test.js +21 -0
  58. package/dist/compiler/runtime/type.d.ts +4 -0
  59. package/dist/compiler/runtime/type.d.ts.map +1 -1
  60. package/dist/compiler/runtime/variables.d.ts +31 -14
  61. package/dist/compiler/runtime/variables.d.ts.map +1 -1
  62. package/dist/compiler/runtime/variables.js +18 -5
  63. package/dist/compiler/server/create-server-file.d.ts +8 -1
  64. package/dist/compiler/server/create-server-file.d.ts.map +1 -1
  65. package/dist/compiler/server/create-server-file.js +22 -2
  66. package/dist/compiler/server/middleware.d.ts +2 -4
  67. package/dist/compiler/server/middleware.d.ts.map +1 -1
  68. package/dist/compiler/server/middleware.js +72 -25
  69. package/dist/compiler/server/middleware.test.js +178 -47
  70. package/dist/services/env-variables/index.js +1 -1
  71. package/package.json +4 -4
  72. package/dist/adapter-utils/index.d.ts +0 -6
  73. package/dist/adapter-utils/index.d.ts.map +0 -1
  74. package/dist/adapter-utils/index.js +0 -5
  75. package/dist/adapter-utils/negotiation/language.d.ts +0 -10
  76. package/dist/adapter-utils/negotiation/language.d.ts.map +0 -1
  77. package/dist/adapter-utils/negotiation/language.js +0 -137
  78. package/dist/adapter-utils/negotiation/language.test.d.ts +0 -2
  79. package/dist/adapter-utils/negotiation/language.test.d.ts.map +0 -1
  80. package/dist/adapter-utils/negotiation/language.test.js +0 -24
  81. package/dist/adapter-utils/routing/detectLanguage.d.ts +0 -25
  82. package/dist/adapter-utils/routing/detectLanguage.d.ts.map +0 -1
  83. package/dist/adapter-utils/routing/detectLanguage.js +0 -32
  84. package/dist/adapter-utils/routing/detectLanguage.test.d.ts +0 -2
  85. package/dist/adapter-utils/routing/detectLanguage.test.d.ts.map +0 -1
  86. package/dist/adapter-utils/routing/detectLanguage.test.js +0 -37
  87. package/dist/adapter-utils/routing/resolveUserPathDefinition.test.d.ts +0 -2
  88. package/dist/adapter-utils/routing/resolveUserPathDefinition.test.d.ts.map +0 -1
  89. package/dist/adapter-utils/routing/resolveUserPathDefinition.test.js +0 -35
  90. package/dist/adapter-utils/routing/resolveUserPathDefinitions.d.ts +0 -40
  91. package/dist/adapter-utils/routing/resolveUserPathDefinitions.d.ts.map +0 -1
  92. package/dist/adapter-utils/routing/resolveUserPathDefinitions.js +0 -19
  93. package/dist/adapter-utils/routing/routeDefinitions.d.ts +0 -48
  94. package/dist/adapter-utils/routing/routeDefinitions.d.ts.map +0 -1
  95. package/dist/adapter-utils/routing/routeDefinitions.js +0 -224
  96. package/dist/adapter-utils/routing/routeDefinitions.test.d.ts +0 -2
  97. package/dist/adapter-utils/routing/routeDefinitions.test.d.ts.map +0 -1
  98. package/dist/adapter-utils/routing/routeDefinitions.test.js +0 -234
  99. package/dist/adapter-utils/routing/sortRoutes.d.ts +0 -2
  100. package/dist/adapter-utils/routing/sortRoutes.d.ts.map +0 -1
  101. package/dist/adapter-utils/routing/sortRoutes.js +0 -135
  102. package/dist/adapter-utils/routing/validatePathTranslations.d.ts +0 -15
  103. package/dist/adapter-utils/routing/validatePathTranslations.d.ts.map +0 -1
  104. package/dist/adapter-utils/routing/validatePathTranslations.js +0 -98
  105. package/dist/adapter-utils/routing/validatePathTranslations.test.d.ts +0 -2
  106. package/dist/adapter-utils/routing/validatePathTranslations.test.d.ts.map +0 -1
  107. package/dist/adapter-utils/routing/validatePathTranslations.test.js +0 -121
  108. package/dist/cli/steps/index.d.ts +0 -10
  109. package/dist/cli/steps/index.d.ts.map +0 -1
  110. package/dist/cli/steps/index.js +0 -9
  111. package/dist/cli/steps/run-compiler.d.ts +0 -9
  112. package/dist/cli/steps/run-compiler.d.ts.map +0 -1
  113. package/dist/cli/steps/run-compiler.js +0 -13
  114. package/dist/compiler/compile-expression.d.ts +0 -5
  115. package/dist/compiler/compile-expression.d.ts.map +0 -1
  116. package/dist/compiler/compile-expression.js +0 -41
  117. package/dist/compiler/runtime/de-localized-path.d.ts +0 -27
  118. package/dist/compiler/runtime/de-localized-path.d.ts.map +0 -1
  119. package/dist/compiler/runtime/de-localized-path.js +0 -32
  120. package/dist/compiler/runtime/de-localized-path.test.d.ts +0 -2
  121. package/dist/compiler/runtime/de-localized-path.test.d.ts.map +0 -1
  122. package/dist/compiler/runtime/de-localized-path.test.js +0 -48
  123. package/dist/compiler/runtime/get-locale-from-path.d.ts +0 -13
  124. package/dist/compiler/runtime/get-locale-from-path.d.ts.map +0 -1
  125. package/dist/compiler/runtime/get-locale-from-path.js +0 -17
  126. package/dist/compiler/runtime/get-locale-from-path.test.d.ts +0 -2
  127. package/dist/compiler/runtime/get-locale-from-path.test.d.ts.map +0 -1
  128. package/dist/compiler/runtime/get-locale-from-path.test.js +0 -22
  129. package/dist/compiler/runtime/jsdoc-runtime.d.ts +0 -2
  130. package/dist/compiler/runtime/jsdoc-runtime.d.ts.map +0 -1
  131. package/dist/compiler/runtime/jsdoc-runtime.js +0 -132
  132. package/dist/compiler/runtime/localized-path.d.ts +0 -32
  133. package/dist/compiler/runtime/localized-path.d.ts.map +0 -1
  134. package/dist/compiler/runtime/localized-path.js +0 -44
  135. package/dist/compiler/runtime/localized-path.test.d.ts +0 -2
  136. package/dist/compiler/runtime/localized-path.test.d.ts.map +0 -1
  137. package/dist/compiler/runtime/localized-path.test.js +0 -42
  138. package/dist/compiler/runtime/mock-runtime.d.ts +0 -6
  139. package/dist/compiler/runtime/mock-runtime.d.ts.map +0 -1
  140. package/dist/compiler/runtime/mock-runtime.js +0 -26
  141. package/dist/compiler/runtime/ts-runtime.d.ts +0 -2
  142. package/dist/compiler/runtime/ts-runtime.d.ts.map +0 -1
  143. package/dist/compiler/runtime/ts-runtime.js +0 -119
  144. package/dist/playground.d.ts +0 -2
  145. package/dist/playground.d.ts.map +0 -1
  146. package/dist/playground.js +0 -5
  147. package/dist/services/codegen/identifier.d.ts +0 -6
  148. package/dist/services/codegen/identifier.d.ts.map +0 -1
  149. package/dist/services/codegen/identifier.js +0 -11
  150. package/dist/services/codegen/indentifier.test.d.ts +0 -2
  151. package/dist/services/codegen/indentifier.test.d.ts.map +0 -1
  152. package/dist/services/codegen/indentifier.test.js +0 -8
  153. package/dist/services/telemetry/events.d.ts +0 -7
  154. package/dist/services/telemetry/events.d.ts.map +0 -1
  155. package/dist/services/telemetry/events.js +0 -1
  156. package/dist/services/valid-js-identifier/index.d.ts +0 -6
  157. package/dist/services/valid-js-identifier/index.d.ts.map +0 -1
  158. package/dist/services/valid-js-identifier/index.js +0 -24
  159. package/dist/services/valid-js-identifier/index.test.d.ts +0 -2
  160. package/dist/services/valid-js-identifier/index.test.d.ts.map +0 -1
  161. package/dist/services/valid-js-identifier/index.test.js +0 -30
  162. package/dist/services/valid-js-identifier/reserved-words.d.ts +0 -2
  163. package/dist/services/valid-js-identifier/reserved-words.d.ts.map +0 -1
  164. package/dist/services/valid-js-identifier/reserved-words.js +0 -50
package/README.md CHANGED
@@ -2,4 +2,8 @@
2
2
 
3
3
  A compiler-based i18n library that emits tree-shakable message functions. This means that only the messages you actually use are loaded without asynchronous waterfalls.
4
4
 
5
- Visit https://inlang.com/m/gerre34r/library-inlang-paraglideJs to learn more.
5
+ Visit https://inlang.com/m/gerre34r/library-inlang-paraglideJs to learn more.
6
+
7
+ ## Contributing
8
+
9
+ Read the [CONTRIBUTING.md](https://github.com/opral/monorepo/blob/main/inlang/packages/paraglide/paraglide-js/CONTRIBUTING.md) file to learn more on how to contribute.
@@ -1 +1 @@
1
- {"version":3,"file":"unplugin.d.ts","sourceRoot":"","sources":["../../src/bundler-plugins/unplugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAMhD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAQvE,eAAO,MAAM,eAAe,EAAE,eAAe,CAAC,eAAe,CAuF3D,CAAC"}
1
+ {"version":3,"file":"unplugin.d.ts","sourceRoot":"","sources":["../../src/bundler-plugins/unplugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAMhD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAavE,eAAO,MAAM,eAAe,EAAE,eAAe,CAAC,eAAe,CAmG3D,CAAC"}
@@ -5,6 +5,10 @@ import { nodeNormalizePath } from "../utilities/node-normalize-path.js";
5
5
  import { Logger } from "../services/logger/index.js";
6
6
  const PLUGIN_NAME = "unplugin-paraglide-js";
7
7
  const logger = new Logger();
8
+ /**
9
+ * Default isServer which differs per bundler.
10
+ */
11
+ let isServer;
8
12
  let previousCompilation;
9
13
  export const unpluginFactory = (args) => ({
10
14
  name: PLUGIN_NAME,
@@ -19,6 +23,7 @@ export const unpluginFactory = (args) => ({
19
23
  // to avoid cleaning the output directory in watch mode,
20
24
  // we only clean the output directory if there was no previous compilation
21
25
  cleanOutdir: previousCompilation === undefined,
26
+ isServer,
22
27
  ...args,
23
28
  });
24
29
  logger.success("Compilation complete");
@@ -48,6 +53,7 @@ export const unpluginFactory = (args) => ({
48
53
  fs: wrappedFs,
49
54
  previousCompilation,
50
55
  cleanOutdir: false,
56
+ isServer,
51
57
  ...args,
52
58
  });
53
59
  logger.success("Re-compilation complete");
@@ -63,6 +69,13 @@ export const unpluginFactory = (args) => ({
63
69
  logger.warn("Failed to re-compile project:", e.message);
64
70
  }
65
71
  },
72
+ vite: {
73
+ config: {
74
+ handler: () => {
75
+ isServer = "import.meta.env?.SSR ?? typeof window === 'undefined'";
76
+ },
77
+ },
78
+ },
66
79
  webpack(compiler) {
67
80
  compiler.options.resolve = {
68
81
  ...compiler.options.resolve,
@@ -77,7 +90,10 @@ export const unpluginFactory = (args) => ({
77
90
  previousCompilation = await compile({
78
91
  fs: wrappedFs,
79
92
  previousCompilation,
80
- cleanOutdir: true,
93
+ // clean dir needs to be false. otherwise webpack get's into a race condition
94
+ // of deleting the output directory and writing files at the same time for
95
+ // multi environment builds
96
+ cleanOutdir: false,
81
97
  ...args,
82
98
  });
83
99
  logger.success("Compilation complete");
@@ -14,5 +14,6 @@ export type CompiledBundleWithMessages = {
14
14
  export declare const compileBundle: (args: {
15
15
  bundle: BundleNested;
16
16
  fallbackMap: Record<string, string | undefined>;
17
+ messageReferenceExpression: (locale: string, bundleId: string) => string;
17
18
  }) => CompiledBundleWithMessages;
18
19
  //# sourceMappingURL=compile-bundle.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"compile-bundle.d.ts","sourceRoot":"","sources":["../../src/compiler/compile-bundle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEjE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAK3C,MAAM,MAAM,0BAA0B,GAAG;IACxC,kDAAkD;IAClD,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IACzB,gDAAgD;IAChD,QAAQ,EAAE;QACT,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;KACpC,CAAC;CACF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,SAAU;IACnC,MAAM,EAAE,YAAY,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;CAChD,KAAG,0BAyBH,CAAC"}
1
+ {"version":3,"file":"compile-bundle.d.ts","sourceRoot":"","sources":["../../src/compiler/compile-bundle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEjE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAK3C,MAAM,MAAM,0BAA0B,GAAG;IACxC,kDAAkD;IAClD,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IACzB,gDAAgD;IAChD,QAAQ,EAAE;QACT,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;KACpC,CAAC;CACF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,SAAU;IACnC,MAAM,EAAE,YAAY,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IAChD,0BAA0B,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC;CACzE,KAAG,0BA0BH,CAAC"}
@@ -19,6 +19,7 @@ export const compileBundle = (args) => {
19
19
  bundle: compileBundleFunction({
20
20
  bundle: args.bundle,
21
21
  availableLocales: Object.keys(args.fallbackMap),
22
+ messageReferenceExpression: args.messageReferenceExpression,
22
23
  }),
23
24
  messages: compiledMessages,
24
25
  };
@@ -39,9 +40,13 @@ const compileBundleFunction = (args) => {
39
40
  */
40
41
  /* @__NO_SIDE_EFFECTS__ */
41
42
  ${isSafeBundleId ? "export " : ""}const ${safeBundleId} = (inputs${hasInputs ? "" : " = {}"}, options = {}) => {
43
+ if (experimentalMiddlewareLocaleSplitting && isServer === false) {
44
+ return /** @type {any} */ (globalThis).__paraglide_ssr.${safeBundleId}(inputs)
45
+ }
42
46
  const locale = options.locale ?? getLocale()
47
+ trackMessageCall("${safeBundleId}", locale)
43
48
  ${args.availableLocales
44
- .map((locale, index) => `${index > 0 ? " " : ""}if (locale === "${locale}") return ${toSafeModuleId(locale)}.${safeBundleId}(inputs)`)
49
+ .map((locale, index) => `${index > 0 ? " " : ""}if (locale === "${locale}") return ${args.messageReferenceExpression(locale, args.bundle.id)}(inputs)`)
45
50
  .join("\n")}
46
51
  return "${args.bundle.id}"
47
52
  };`;
@@ -34,6 +34,7 @@ test("compiles to jsdoc", async () => {
34
34
  "en-US": "en",
35
35
  },
36
36
  bundle: mockBundle,
37
+ messageReferenceExpression: (locale) => `${toSafeModuleId(locale)}.blue_moon_bottle`,
37
38
  });
38
39
  expect(result.bundle.code).toMatchInlineSnapshot(`"/**
39
40
  * This function has been compiled by [Paraglide JS](https://inlang.com/m/gerre34r).
@@ -49,7 +50,11 @@ test("compiles to jsdoc", async () => {
49
50
  */
50
51
  /* @__NO_SIDE_EFFECTS__ */
51
52
  export const blue_moon_bottle = (inputs, options = {}) => {
53
+ if (experimentalMiddlewareLocaleSplitting && isServer === false) {
54
+ return /** @type {any} */ (globalThis).__paraglide_ssr.blue_moon_bottle(inputs)
55
+ }
52
56
  const locale = options.locale ?? getLocale()
57
+ trackMessageCall("blue_moon_bottle", locale)
53
58
  if (locale === "en") return en.blue_moon_bottle(inputs)
54
59
  if (locale === "en-US") return en_us.blue_moon_bottle(inputs)
55
60
  return "blue_moon_bottle"
@@ -86,6 +91,7 @@ test("compiles bundles with arbitrary module identifiers", async () => {
86
91
  const result = compileBundle({
87
92
  fallbackMap: {},
88
93
  bundle: mockBundle,
94
+ messageReferenceExpression: (locale) => `${toSafeModuleId(locale)}.blue_moon_bottle`,
89
95
  });
90
96
  expect(result.bundle.code).includes(`export { ${toSafeModuleId("$p@44🍌")} as "$p@44🍌" }`);
91
97
  });
@@ -1 +1 @@
1
- {"version":3,"file":"compile-message.d.ts","sourceRoot":"","sources":["../../src/compiler/compile-message.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEjE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAM3C;;;GAGG;AACH,eAAO,MAAM,cAAc,iBACZ,WAAW,EAAE,WAClB,OAAO,YACN,OAAO,EAAE,KACjB,QAAQ,CAAC,OAAO,CAUlB,CAAC"}
1
+ {"version":3,"file":"compile-message.d.ts","sourceRoot":"","sources":["../../src/compiler/compile-message.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEjE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAK3C;;;GAGG;AACH,eAAO,MAAM,cAAc,iBACZ,WAAW,EAAE,WAClB,OAAO,YACN,OAAO,EAAE,KACjB,QAAQ,CAAC,OAAO,CAUlB,CAAC"}
@@ -2,7 +2,6 @@ import { compilePattern } from "./compile-pattern.js";
2
2
  import { doubleQuote } from "../services/codegen/quotes.js";
3
3
  import { inputsType } from "./jsdoc-types.js";
4
4
  import { compileLocalVariable } from "./compile-local-variable.js";
5
- import { toSafeModuleId } from "./safe-module-id.js";
6
5
  /**
7
6
  * Returns the compiled message as a string
8
7
  *
@@ -34,9 +33,7 @@ function compileMessageWithOneVariant(declarations, message, variants) {
34
33
  compiledLocalVariables.push(compileLocalVariable({ declaration, locale: message.locale }));
35
34
  }
36
35
  }
37
- const safeModuleId = toSafeModuleId(message.bundleId);
38
- const code = `/** @type {(inputs: ${inputsType(inputs)}) => string} */
39
- export const ${safeModuleId} = (${hasInputs ? "i" : ""}) => {
36
+ const code = `/** @type {(inputs: ${inputsType(inputs)}) => string} */ (${hasInputs ? "i" : ""}) => {
40
37
  ${compiledLocalVariables.join("\n\t")}return ${compiledPattern.code}
41
38
  };`;
42
39
  return { code, node: message };
@@ -84,9 +81,7 @@ function compileMessageWithMultipleVariants(declarations, message, variants) {
84
81
  compiledLocalVariables.push(compileLocalVariable({ declaration, locale: message.locale }));
85
82
  }
86
83
  }
87
- const safeModuleId = toSafeModuleId(message.bundleId);
88
- const code = `/** @type {(inputs: ${inputsType(inputs)}) => string} */
89
- export const ${safeModuleId} = (${hasInputs ? "i" : ""}) => {${compiledLocalVariables.join("\n\t")}
84
+ const code = `/** @type {(inputs: ${inputsType(inputs)}) => string} */ (${hasInputs ? "i" : ""}) => {${compiledLocalVariables.join("\n\t")}
90
85
  ${compiledVariants.join("\n\t")}
91
86
  ${hasCatchAll ? "" : `return "${message.bundleId}";`}
92
87
  };`;
@@ -1,7 +1,6 @@
1
1
  import { test, expect } from "vitest";
2
2
  import { compileMessage } from "./compile-message.js";
3
3
  import { createRegistry } from "./registry.js";
4
- import { toSafeModuleId } from "./safe-module-id.js";
5
4
  test("compiles a message with a single variant", async () => {
6
5
  const declarations = [];
7
6
  const message = {
@@ -19,7 +18,8 @@ test("compiles a message with a single variant", async () => {
19
18
  },
20
19
  ];
21
20
  const compiled = compileMessage(declarations, message, variants);
22
- const { some_message } = await import("data:text/javascript;base64," + btoa(compiled.code));
21
+ const { some_message } = await import("data:text/javascript;base64," +
22
+ btoa("export const some_message =" + compiled.code));
23
23
  expect(some_message()).toBe("Hello");
24
24
  });
25
25
  test("compiles a message with variants", async () => {
@@ -68,7 +68,8 @@ test("compiles a message with variants", async () => {
68
68
  },
69
69
  ];
70
70
  const compiled = compileMessage(declarations, message, variants);
71
- const { some_message } = await import("data:text/javascript;base64," + btoa(compiled.code));
71
+ const { some_message } = await import("data:text/javascript;base64," +
72
+ btoa("export const some_message =" + compiled.code));
72
73
  expect(some_message({ fistInput: 1, secondInput: 2 })).toBe("The inputs are 1 and 2");
73
74
  expect(some_message({ fistInput: 3, secondInput: 4 })).toBe("Catch all");
74
75
  expect(some_message({ fistInput: 1, secondInput: 5 })).toBe("Catch all");
@@ -119,7 +120,8 @@ test("compiles multi-variant message with a fallback in case the variants are no
119
120
  },
120
121
  ];
121
122
  const compiled = compileMessage(declarations, message, variants);
122
- const { some_message } = await import("data:text/javascript;base64," + btoa(compiled.code));
123
+ const { some_message } = await import("data:text/javascript;base64," +
124
+ btoa("export const some_message = " + compiled.code));
123
125
  expect(some_message({ secondInput: 2 })).toBe("Catch all");
124
126
  expect(some_message({})).toBe("some_message");
125
127
  });
@@ -140,10 +142,7 @@ test("only emits input arguments when inputs exist", async () => {
140
142
  },
141
143
  ];
142
144
  const compiled = compileMessage(declarations, message, variants);
143
- expect(compiled.code).toBe([
144
- "/** @type {(inputs: {}) => string} */",
145
- "export const some_message = () => {\n\treturn `Hello`\n};",
146
- ].join("\n"));
145
+ expect(compiled.code).toBe("/** @type {(inputs: {}) => string} */ () => {\n\treturn `Hello`\n};");
147
146
  });
148
147
  // https://github.com/opral/inlang-paraglide-js/issues/379
149
148
  test("compiles messages that use plural()", async () => {
@@ -193,7 +192,7 @@ test("compiles messages that use plural()", async () => {
193
192
  const { plural_test } = await import("data:text/javascript;base64," +
194
193
  // bundling the registry inline to avoid managing module imports here
195
194
  btoa(createRegistry()) +
196
- btoa(compiled.code.replace("registry.", "")));
195
+ btoa("export const plural_test = " + compiled.code.replace("registry.", "")));
197
196
  expect(plural_test({ count: 1 })).toBe("There is one cat.");
198
197
  expect(plural_test({ count: 2 })).toBe("There are many cats.");
199
198
  // INTL.plural will match "other" for undefined
@@ -242,7 +241,8 @@ test("compiles messages that use datetime()", async () => {
242
241
  const { datetime_test } = await import("data:text/javascript;base64," +
243
242
  // bundling the registry inline to avoid managing module imports here
244
243
  btoa(createRegistry()) +
245
- btoa(compiled.code.replace("registry.", "")));
244
+ btoa("export const datetime_test =" +
245
+ compiled.code.replace("registry.", "")));
246
246
  return datetime_test;
247
247
  };
248
248
  const enMessage = await createMessage("en");
@@ -296,7 +296,8 @@ test("compiles messages that use datetime a function with options", async () =>
296
296
  const { datetime_test } = await import("data:text/javascript;base64," +
297
297
  // bundling the registry inline to avoid managing module imports here
298
298
  btoa(createRegistry()) +
299
- btoa(compiled.code.replace("registry.", "")));
299
+ btoa("export const datetime_test = " +
300
+ compiled.code.replace("registry.", "")));
300
301
  return datetime_test;
301
302
  };
302
303
  const enMessage = await createMessage("en");
@@ -305,25 +306,3 @@ test("compiles messages that use datetime a function with options", async () =>
305
306
  expect(enMessage({ date: "2022-03-31" })).toMatch(/Today is March \d{1,2}\./);
306
307
  expect(deMessage({ date: "2022-03-31" })).toMatch(/Today is \d{1,2}\. März\./);
307
308
  });
308
- // https://github.com/opral/inlang-paraglide-js/issues/285
309
- test("compiles messages with arbitrary module identifiers", async () => {
310
- const declarations = [];
311
- const message = {
312
- locale: "en",
313
- bundleId: "$p@44🍌",
314
- id: "message-id",
315
- selectors: [],
316
- };
317
- const variants = [
318
- {
319
- id: "1",
320
- messageId: "message-id",
321
- matches: [],
322
- pattern: [{ type: "text", value: "Hello" }],
323
- },
324
- ];
325
- const compiled = compileMessage(declarations, message, variants);
326
- const m = await import("data:text/javascript;base64," +
327
- Buffer.from(compiled.code).toString("base64"));
328
- expect(m[toSafeModuleId("$p@44🍌")]()).toBe("Hello");
329
- });
@@ -1 +1 @@
1
- {"version":3,"file":"compile-project.d.ts","sourceRoot":"","sources":["../../src/compiler/compile-project.ts"],"names":[],"mappings":"AACA,OAAO,EAAsB,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAIrE,OAAO,EAEN,KAAK,eAAe,EACpB,MAAM,uBAAuB,CAAC;AAE/B;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,SAAgB;IAC1C,OAAO,EAAE,aAAa,CAAC;IACvB,eAAe,CAAC,EAAE,IAAI,CAAC,eAAe,EAAE,IAAI,GAAG,SAAS,GAAG,QAAQ,CAAC,CAAC;CACrE,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAgEjC,CAAC;AAEF,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAC9C,OAAO,EAAE,CAAC,EAAE,EACZ,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC,GACpB,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,CAY1B"}
1
+ {"version":3,"file":"compile-project.d.ts","sourceRoot":"","sources":["../../src/compiler/compile-project.ts"],"names":[],"mappings":"AACA,OAAO,EAAsB,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAIrE,OAAO,EAEN,KAAK,eAAe,EACpB,MAAM,uBAAuB,CAAC;AAU/B;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,SAAgB;IAC1C,OAAO,EAAE,aAAa,CAAC;IACvB,eAAe,CAAC,EAAE,IAAI,CAAC,eAAe,EAAE,IAAI,GAAG,SAAS,GAAG,QAAQ,CAAC,CAAC;CACrE,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAsEjC,CAAC;AAEF,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAC9C,OAAO,EAAE,CAAC,EAAE,EACZ,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC,GACpB,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,CAY1B"}
@@ -1,9 +1,16 @@
1
1
  import { compileBundle } from "./compile-bundle.js";
2
2
  import { selectBundleNested } from "@inlang/sdk";
3
3
  import { lookup } from "../services/lookup.js";
4
- import { generateLocaleModules } from "./output-structure/locale-modules.js";
5
- import { generateMessageModules } from "./output-structure/message-modules.js";
4
+ import * as localeModules from "./output-structure/locale-modules.js";
5
+ import * as messageModules from "./output-structure/message-modules.js";
6
6
  import { defaultCompilerOptions, } from "./compiler-options.js";
7
+ import { createRuntimeFile } from "./runtime/create-runtime.js";
8
+ import { createServerFile } from "./server/create-server-file.js";
9
+ import { createRegistry } from "./registry.js";
10
+ const outputStructures = {
11
+ "locale-modules": localeModules,
12
+ "message-modules": messageModules,
13
+ };
7
14
  /**
8
15
  * Takes an inlang project and compiles it into a set of files.
9
16
  *
@@ -24,19 +31,31 @@ export const compileProject = async (args) => {
24
31
  //Maps each language to it's fallback
25
32
  //If there is no fallback, it will be undefined
26
33
  const fallbackMap = getFallbackMap(settings.locales, settings.baseLocale);
34
+ const outputStructure = outputStructures[optionsWithDefaults.outputStructure];
27
35
  const compiledBundles = bundles.map((bundle) => compileBundle({
28
36
  bundle,
29
37
  fallbackMap,
38
+ messageReferenceExpression: outputStructure.messageReferenceExpression,
30
39
  }));
31
- const output = {};
32
- if (optionsWithDefaults.outputStructure === "locale-modules") {
33
- const regularOutput = generateLocaleModules(compiledBundles, settings, fallbackMap, optionsWithDefaults);
34
- Object.assign(output, regularOutput);
35
- }
36
- if (optionsWithDefaults.outputStructure === "message-modules") {
37
- const messageModuleOutput = generateMessageModules(compiledBundles, settings, fallbackMap, optionsWithDefaults);
38
- Object.assign(output, messageModuleOutput);
39
- }
40
+ const output = {
41
+ ["runtime.js"]: createRuntimeFile({
42
+ baseLocale: settings.baseLocale,
43
+ locales: settings.locales,
44
+ compilerOptions: optionsWithDefaults,
45
+ }),
46
+ ["server.js"]: createServerFile({
47
+ compiledBundles,
48
+ compilerOptions: optionsWithDefaults,
49
+ }),
50
+ ["registry.js"]: createRegistry(),
51
+ ["messages.js"]: [
52
+ "export * from './messages/_index.js'",
53
+ "// enabling auto-import by exposing all messages as m",
54
+ "export * as m from './messages/_index.js'",
55
+ ].join("\n"),
56
+ };
57
+ // generate the output modules
58
+ Object.assign(output, outputStructure.generateOutput(compiledBundles, settings, fallbackMap));
40
59
  if (optionsWithDefaults.emitGitIgnore) {
41
60
  output[".gitignore"] = ignoreDirectory;
42
61
  }
@@ -1,4 +1,5 @@
1
1
  import { expect, test, describe, vi, beforeEach } from "vitest";
2
+ import { AsyncLocalStorage } from "async_hooks";
2
3
  import { createProject as typescriptProject, ts, } from "@ts-morph/bootstrap";
3
4
  import { Declaration, insertBundleNested, loadProjectInMemory, newProject, Pattern, VariableReference, } from "@inlang/sdk";
4
5
  import { compileProject } from "./compile-project.js";
@@ -354,6 +355,117 @@ describe.each([
354
355
  runtime.setLocale("en-US");
355
356
  expect(m.missingInGerman()).toBe("A simple message.");
356
357
  });
358
+ test("message tracking works", async () => {
359
+ const project = await loadProjectInMemory({
360
+ blob: await newProject({
361
+ settings: { locales: ["en", "de", "fr"], baseLocale: "en" },
362
+ }),
363
+ });
364
+ // Add test messages
365
+ await insertBundleNested(project.db, createBundleNested({
366
+ id: "greeting",
367
+ messages: [
368
+ {
369
+ locale: "en",
370
+ variants: [{ pattern: [{ type: "text", value: "Hello" }] }],
371
+ },
372
+ {
373
+ locale: "de",
374
+ variants: [{ pattern: [{ type: "text", value: "Hallo" }] }],
375
+ },
376
+ {
377
+ locale: "fr",
378
+ variants: [{ pattern: [{ type: "text", value: "Bonjour" }] }],
379
+ },
380
+ ],
381
+ }));
382
+ await insertBundleNested(project.db, createBundleNested({
383
+ id: "farewell",
384
+ messages: [
385
+ {
386
+ locale: "en",
387
+ variants: [{ pattern: [{ type: "text", value: "Goodbye" }] }],
388
+ },
389
+ {
390
+ locale: "de",
391
+ variants: [
392
+ { pattern: [{ type: "text", value: "Auf Wiedersehen" }] },
393
+ ],
394
+ },
395
+ {
396
+ locale: "fr",
397
+ variants: [{ pattern: [{ type: "text", value: "Au revoir" }] }],
398
+ },
399
+ ],
400
+ }));
401
+ // Compile the project
402
+ const output = await compileProject({
403
+ project,
404
+ compilerOptions,
405
+ });
406
+ const code = await bundleCode(output, `export * as m from "./paraglide/messages.js"
407
+ export * as runtime from "./paraglide/runtime.js"`);
408
+ const { m, runtime } = await importCode(code);
409
+ // Setup AsyncLocalStorage for tracking
410
+ runtime.overwriteServerAsyncLocalStorage(new AsyncLocalStorage());
411
+ // Test tracking in English
412
+ runtime.setLocale("en");
413
+ const messageCalls1 = new Set();
414
+ const result1 = await runtime.serverAsyncLocalStorage.run({ messageCalls: messageCalls1 }, () => {
415
+ const greeting = m.greeting();
416
+ const farewell = m.farewell();
417
+ expect(greeting).toBe("Hello");
418
+ expect(farewell).toBe("Goodbye");
419
+ return "english";
420
+ });
421
+ expect(result1).toBe("english");
422
+ expect(messageCalls1).toEqual(new Set(["greeting:en", "farewell:en"]));
423
+ // Test tracking in German
424
+ runtime.setLocale("de");
425
+ const messageCalls2 = new Set();
426
+ const result2 = await runtime.serverAsyncLocalStorage.run({ messageCalls: messageCalls2 }, () => {
427
+ const greeting = m.greeting();
428
+ expect(greeting).toBe("Hallo");
429
+ return "german";
430
+ });
431
+ expect(result2).toBe("german");
432
+ expect(messageCalls2).toEqual(new Set(["greeting:de"]));
433
+ expect(messageCalls2.has("farewell:de")).toBe(false);
434
+ // Test tracking with explicit locale
435
+ const messageCalls3 = new Set();
436
+ const result3 = await runtime.serverAsyncLocalStorage.run({ messageCalls: messageCalls3 }, () => {
437
+ const greeting = m.greeting(undefined, { locale: "fr" });
438
+ expect(greeting).toBe("Bonjour");
439
+ return "explicit";
440
+ });
441
+ expect(result3).toBe("explicit");
442
+ expect(messageCalls3).toEqual(new Set(["greeting:fr"]));
443
+ // Test nested tracking contexts
444
+ const messageCalls4 = new Set();
445
+ const result4 = await runtime.serverAsyncLocalStorage.run({ messageCalls: messageCalls4 }, () => {
446
+ // Access a message in the outer context
447
+ const outerGreeting = m.greeting();
448
+ expect(outerGreeting).toBe("Hallo"); // Still in German locale
449
+ // Create a nested tracking context
450
+ const nestedMessageCalls = new Set();
451
+ const nestedResult = runtime.serverAsyncLocalStorage.run({ messageCalls: nestedMessageCalls }, () => {
452
+ // Access different messages in the nested context
453
+ const nestedFarewell = m.farewell();
454
+ expect(nestedFarewell).toBe("Auf Wiedersehen");
455
+ return "nested";
456
+ });
457
+ // Verify nested tracking
458
+ expect(nestedResult).toBe("nested");
459
+ expect(nestedMessageCalls).toEqual(new Set(["farewell:de"]));
460
+ expect(nestedMessageCalls.has("greeting:de")).toBe(false); // Not accessed in nested context
461
+ return "outer";
462
+ });
463
+ // Verify outer context only contains its own calls
464
+ expect(result4).toBe("outer");
465
+ expect(messageCalls4).toEqual(new Set(["greeting:de"]));
466
+ // The farewell message should not be in the outer context
467
+ expect(messageCalls4.has("farewell:de")).toBe(false);
468
+ });
357
469
  test("arbitrary module identifiers work", async () => {
358
470
  const project = await loadProjectInMemory({
359
471
  blob: await newProject({
@@ -434,6 +546,61 @@ describe.each([
434
546
  expect(m.missing_in_en_US()).toBe("Fallback message.");
435
547
  });
436
548
  });
549
+ test("case sensitivity handling for bundle IDs", async () => {
550
+ // skip local modules for now because the option might get removed in the future
551
+ if (compilerOptions.outputStructure === "locale-modules") {
552
+ return;
553
+ }
554
+ const project = await loadProjectInMemory({
555
+ blob: await newProject({
556
+ settings: { locales: ["en"], baseLocale: "en" },
557
+ }),
558
+ });
559
+ // Create two bundles with the same name but different case
560
+ await insertBundleNested(project.db, createBundleNested({
561
+ id: "Helloworld",
562
+ messages: [
563
+ {
564
+ locale: "en",
565
+ variants: [
566
+ {
567
+ pattern: [
568
+ { type: "text", value: "Hello from uppercase bundle" },
569
+ ],
570
+ },
571
+ ],
572
+ },
573
+ ],
574
+ }));
575
+ await insertBundleNested(project.db, createBundleNested({
576
+ id: "helloworld",
577
+ messages: [
578
+ {
579
+ locale: "en",
580
+ variants: [
581
+ {
582
+ pattern: [
583
+ { type: "text", value: "Hello from lowercase bundle" },
584
+ ],
585
+ },
586
+ ],
587
+ },
588
+ ],
589
+ }));
590
+ const output = await compileProject({
591
+ project,
592
+ compilerOptions,
593
+ });
594
+ const code = await bundleCode(output, `export * as m from "./paraglide/messages.js"
595
+ export { helloworld, Helloworld } from "./paraglide/messages.js"`);
596
+ const imported = await importCode(code);
597
+ // Both message functions should be available
598
+ expect(imported.helloworld()).toBe("Hello from lowercase bundle");
599
+ expect(imported.Helloworld()).toBe("Hello from uppercase bundle");
600
+ // They should also be available through the m namespace
601
+ expect(imported.m.helloworld()).toBe("Hello from lowercase bundle");
602
+ expect(imported.m.Helloworld()).toBe("Hello from uppercase bundle");
603
+ });
437
604
  // whatever the strictest users use, this is the ultimate nothing gets stricter than this
438
605
  // (to avoid developers opening issues "i get a ts warning in my code")
439
606
  const superStrictRuleOutAnyErrorTsSettings = {
@@ -5,6 +5,9 @@ export declare const defaultCompilerOptions: {
5
5
  readonly includeEslintDisableComment: true;
6
6
  readonly emitPrettierIgnore: true;
7
7
  readonly cleanOutdir: true;
8
+ readonly experimentalMiddlewareLocaleSplitting: false;
9
+ readonly localStorageKey: "PARAGLIDE_LOCALE";
10
+ readonly isServer: "typeof window === 'undefined'";
8
11
  readonly strategy: ["cookie", "globalVariable", "baseLocale"];
9
12
  readonly cookieName: "PARAGLIDE_LOCALE";
10
13
  };
@@ -49,6 +52,41 @@ export type CompilerOptions = {
49
52
  * @default ["url", "cookie", "variable", "baseLocale"]
50
53
  */
51
54
  strategy?: Runtime["strategy"];
55
+ /**
56
+ * Whether or not to use experimental middleware locale splitting.
57
+ *
58
+ * ⚠️ This feature is experimental and only works in SSR/SSG environment
59
+ * without client-side routing. Do not rely on this feature for production.
60
+ *
61
+ * This feature is part of the exploration of per locale splitting. The
62
+ * issue is ongoing and can be followed here [#88](https://github.com/opral/inlang-paraglide-js/issues/88).
63
+ *
64
+ * - The client bundle will tree-shake all messages (have close to 0kb JS).
65
+ * - The server middleware will inject the used messages into the HTML.
66
+ * - The client will re-trieve the messages from the injected HTML.
67
+ *
68
+ * @default false
69
+ */
70
+ experimentalMiddlewareLocaleSplitting?: boolean;
71
+ /**
72
+ * The name of the localStorage key to use for the localStorage strategy.
73
+ *
74
+ * @default 'PARAGLIDE_LOCALE'
75
+ */
76
+ localStorageKey?: string;
77
+ /**
78
+ * Tree-shaking flag if the code is running on the server.
79
+ *
80
+ * Dependent on the bundler, this flag must be adapted to
81
+ * enable tree-shaking.
82
+ *
83
+ * @example
84
+ * // vite
85
+ * isServer: "import.meta.env.SSR"
86
+ *
87
+ * @default typeof window === "undefined"
88
+ */
89
+ isServer?: string;
52
90
  /**
53
91
  * The name of the cookie to use for the cookie strategy.
54
92
  *
@@ -96,7 +134,7 @@ export type CompilerOptions = {
96
134
  */
97
135
  emitPrettierIgnore?: boolean;
98
136
  /**
99
- * TODO documentation
137
+ * https://inlang.com/m/gerre34r/library-inlang-paraglideJs/strategy#url
100
138
  */
101
139
  urlPatterns?: Runtime["urlPatterns"];
102
140
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"compiler-options.d.ts","sourceRoot":"","sources":["../../src/compiler/compiler-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEjD,eAAO,MAAM,sBAAsB;;;;;;;;CAQU,CAAC;AAE9C,MAAM,MAAM,eAAe,GAAG;IAC7B;;;;;;;;;;OAUG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;;;;;;OAUG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;;;;;;;;;;;;OAcG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IAC/B;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC;;;;;;;;;;;;OAYG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;IACrC;;;;OAIG;IACH,2BAA2B,CAAC,EAAE,OAAO,CAAC;IACtC;;;;;;;;;;;;OAYG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6CG;IACH,eAAe,CAAC,EAAE,gBAAgB,GAAG,iBAAiB,CAAC;IACvD;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;;OAIG;IACH,EAAE,CAAC,EAAE,GAAG,CAAC;CACT,CAAC"}
1
+ {"version":3,"file":"compiler-options.d.ts","sourceRoot":"","sources":["../../src/compiler/compiler-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEjD,eAAO,MAAM,sBAAsB;;;;;;;;;;;CAWU,CAAC;AAE9C,MAAM,MAAM,eAAe,GAAG;IAC7B;;;;;;;;;;OAUG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;;;;;;OAUG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;;;;;;;;;;;;OAcG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IAC/B;;;;;;;;;;;;;;OAcG;IACH,qCAAqC,CAAC,EAAE,OAAO,CAAC;IAChD;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC;;;;;;;;;;;;OAYG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;IACrC;;;;OAIG;IACH,2BAA2B,CAAC,EAAE,OAAO,CAAC;IACtC;;;;;;;;;;;;OAYG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6CG;IACH,eAAe,CAAC,EAAE,gBAAgB,GAAG,iBAAiB,CAAC;IACvD;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;;OAIG;IACH,EAAE,CAAC,EAAE,GAAG,CAAC;CACT,CAAC"}
@@ -4,6 +4,9 @@ export const defaultCompilerOptions = {
4
4
  includeEslintDisableComment: true,
5
5
  emitPrettierIgnore: true,
6
6
  cleanOutdir: true,
7
+ experimentalMiddlewareLocaleSplitting: false,
8
+ localStorageKey: "PARAGLIDE_LOCALE",
9
+ isServer: "typeof window === 'undefined'",
7
10
  strategy: ["cookie", "globalVariable", "baseLocale"],
8
11
  cookieName: "PARAGLIDE_LOCALE",
9
12
  };
@@ -1,8 +1,5 @@
1
1
  import type { ProjectSettings } from "@inlang/sdk";
2
2
  import type { CompiledBundleWithMessages } from "../compile-bundle.js";
3
- import type { CompilerOptions } from "../compiler-options.js";
4
- export declare function generateLocaleModules(compiledBundles: CompiledBundleWithMessages[], settings: Pick<ProjectSettings, "locales" | "baseLocale">, fallbackMap: Record<string, string | undefined>, compilerOptions: {
5
- strategy: NonNullable<CompilerOptions["strategy"]>;
6
- cookieName: NonNullable<CompilerOptions["cookieName"]>;
7
- }): Record<string, string>;
3
+ export declare function messageReferenceExpression(locale: string, bundleId: string): string;
4
+ export declare function generateOutput(compiledBundles: CompiledBundleWithMessages[], settings: Pick<ProjectSettings, "locales" | "baseLocale">, fallbackMap: Record<string, string | undefined>): Record<string, string>;
8
5
  //# sourceMappingURL=locale-modules.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"locale-modules.d.ts","sourceRoot":"","sources":["../../../src/compiler/output-structure/locale-modules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAGvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAI9D,wBAAgB,qBAAqB,CACpC,eAAe,EAAE,0BAA0B,EAAE,EAC7C,QAAQ,EAAE,IAAI,CAAC,eAAe,EAAE,SAAS,GAAG,YAAY,CAAC,EACzD,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,EAC/C,eAAe,EAAE;IAChB,QAAQ,EAAE,WAAW,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,CAAC;IACnD,UAAU,EAAE,WAAW,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC,CAAC;CACvD,GACC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA4DxB"}
1
+ {"version":3,"file":"locale-modules.d.ts","sourceRoot":"","sources":["../../../src/compiler/output-structure/locale-modules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAIvE,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,UAE1E;AAED,wBAAgB,cAAc,CAC7B,eAAe,EAAE,0BAA0B,EAAE,EAC7C,QAAQ,EAAE,IAAI,CAAC,eAAe,EAAE,SAAS,GAAG,YAAY,CAAC,EACzD,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAC7C,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAoDxB"}