@inlang/paraglide-js 2.22.0 → 2.23.1

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 (107) hide show
  1. package/README.md +6 -3
  2. package/dist/bundler-plugins/per-locale-build/constants.d.ts +0 -1
  3. package/dist/bundler-plugins/per-locale-build/constants.d.ts.map +1 -1
  4. package/dist/bundler-plugins/per-locale-build/constants.js +0 -1
  5. package/dist/bundler-plugins/per-locale-build/constants.js.map +1 -1
  6. package/dist/bundler-plugins/per-locale-build/index.d.ts.map +1 -1
  7. package/dist/bundler-plugins/per-locale-build/index.js +15 -38
  8. package/dist/bundler-plugins/per-locale-build/index.js.map +1 -1
  9. package/dist/bundler-plugins/per-locale-build/types.d.ts +0 -37
  10. package/dist/bundler-plugins/per-locale-build/types.d.ts.map +1 -1
  11. package/dist/bundler-plugins/per-locale-build/vite-environments.d.ts +52 -0
  12. package/dist/bundler-plugins/per-locale-build/vite-environments.d.ts.map +1 -0
  13. package/dist/bundler-plugins/per-locale-build/vite-environments.js +250 -0
  14. package/dist/bundler-plugins/per-locale-build/vite-environments.js.map +1 -0
  15. package/dist/bundler-plugins/per-locale-build/vite-environments.test.d.ts +2 -0
  16. package/dist/bundler-plugins/per-locale-build/vite-environments.test.d.ts.map +1 -0
  17. package/dist/bundler-plugins/per-locale-build/vite-environments.test.js +260 -0
  18. package/dist/bundler-plugins/per-locale-build/vite-environments.test.js.map +1 -0
  19. package/dist/bundler-plugins/vite.d.ts +4 -3
  20. package/dist/bundler-plugins/vite.d.ts.map +1 -1
  21. package/dist/bundler-plugins/vite.js.map +1 -1
  22. package/dist/bundler-plugins/vite.test.js +21 -46
  23. package/dist/bundler-plugins/vite.test.js.map +1 -1
  24. package/dist/compiler/compile-bundle.d.ts.map +1 -1
  25. package/dist/compiler/compile-bundle.js +16 -4
  26. package/dist/compiler/compile-bundle.js.map +1 -1
  27. package/dist/compiler/compile-bundle.test.js +42 -0
  28. package/dist/compiler/compile-bundle.test.js.map +1 -1
  29. package/dist/compiler/compile-project.d.ts.map +1 -1
  30. package/dist/compiler/compile-project.js +7 -6
  31. package/dist/compiler/compile-project.js.map +1 -1
  32. package/dist/compiler/compile-project.test.js +12 -29
  33. package/dist/compiler/compile-project.test.js.map +1 -1
  34. package/dist/compiler/runtime/create-runtime.d.ts.map +1 -1
  35. package/dist/compiler/runtime/create-runtime.js +2 -0
  36. package/dist/compiler/runtime/create-runtime.js.map +1 -1
  37. package/dist/compiler/runtime/extract-locale-from-request-async.d.ts.map +1 -1
  38. package/dist/compiler/runtime/extract-locale-from-request-async.js +1 -1
  39. package/dist/compiler/runtime/extract-locale-from-request-async.js.map +1 -1
  40. package/dist/compiler/runtime/extract-locale-from-request.d.ts.map +1 -1
  41. package/dist/compiler/runtime/extract-locale-from-request.js +2 -1
  42. package/dist/compiler/runtime/extract-locale-from-request.js.map +1 -1
  43. package/dist/compiler/runtime/extract-locale-from-url.js +1 -1
  44. package/dist/compiler/runtime/extract-locale-from-url.js.map +1 -1
  45. package/dist/compiler/runtime/get-locale.js +2 -1
  46. package/dist/compiler/runtime/get-locale.js.map +1 -1
  47. package/dist/compiler/runtime/get-url-origin.d.ts +1 -1
  48. package/dist/compiler/runtime/get-url-origin.js +1 -1
  49. package/dist/compiler/runtime/route-strategy.d.ts +33 -0
  50. package/dist/compiler/runtime/route-strategy.d.ts.map +1 -0
  51. package/dist/compiler/runtime/route-strategy.js +72 -0
  52. package/dist/compiler/runtime/route-strategy.js.map +1 -0
  53. package/dist/compiler/runtime/set-locale.d.ts +6 -3
  54. package/dist/compiler/runtime/set-locale.d.ts.map +1 -1
  55. package/dist/compiler/runtime/set-locale.js +8 -4
  56. package/dist/compiler/runtime/set-locale.js.map +1 -1
  57. package/dist/compiler/runtime/should-redirect.d.ts.map +1 -1
  58. package/dist/compiler/runtime/should-redirect.js +5 -3
  59. package/dist/compiler/runtime/should-redirect.js.map +1 -1
  60. package/dist/compiler/runtime/type.d.ts +3 -2
  61. package/dist/compiler/runtime/type.d.ts.map +1 -1
  62. package/dist/compiler/runtime/variables.d.ts +9 -17
  63. package/dist/compiler/runtime/variables.d.ts.map +1 -1
  64. package/dist/compiler/runtime/variables.js +11 -56
  65. package/dist/compiler/runtime/variables.js.map +1 -1
  66. package/dist/compiler/server/create-server-file.d.ts.map +1 -1
  67. package/dist/compiler/server/create-server-file.js +15 -6
  68. package/dist/compiler/server/create-server-file.js.map +1 -1
  69. package/dist/compiler/server/create-server-file.test.d.ts +2 -0
  70. package/dist/compiler/server/create-server-file.test.d.ts.map +1 -0
  71. package/dist/compiler/server/create-server-file.test.js +48 -0
  72. package/dist/compiler/server/create-server-file.test.js.map +1 -0
  73. package/dist/compiler/server/middleware.d.ts.map +1 -1
  74. package/dist/compiler/server/middleware.js +3 -2
  75. package/dist/compiler/server/middleware.js.map +1 -1
  76. package/dist/compiler/server/middleware.test.js +27 -0
  77. package/dist/compiler/server/middleware.test.js.map +1 -1
  78. package/dist/services/env-variables/index.js +1 -1
  79. package/package.json +1 -1
  80. package/dist/bundler-plugins/per-locale-build/framework-helpers.test.d.ts +0 -2
  81. package/dist/bundler-plugins/per-locale-build/framework-helpers.test.d.ts.map +0 -1
  82. package/dist/bundler-plugins/per-locale-build/framework-helpers.test.js +0 -57
  83. package/dist/bundler-plugins/per-locale-build/framework-helpers.test.js.map +0 -1
  84. package/dist/bundler-plugins/per-locale-build/frameworks/index.d.ts +0 -5
  85. package/dist/bundler-plugins/per-locale-build/frameworks/index.d.ts.map +0 -1
  86. package/dist/bundler-plugins/per-locale-build/frameworks/index.js +0 -21
  87. package/dist/bundler-plugins/per-locale-build/frameworks/index.js.map +0 -1
  88. package/dist/bundler-plugins/per-locale-build/frameworks/sveltekit.d.ts +0 -21
  89. package/dist/bundler-plugins/per-locale-build/frameworks/sveltekit.d.ts.map +0 -1
  90. package/dist/bundler-plugins/per-locale-build/frameworks/sveltekit.js +0 -137
  91. package/dist/bundler-plugins/per-locale-build/frameworks/sveltekit.js.map +0 -1
  92. package/dist/bundler-plugins/per-locale-build/frameworks/tanstack-start.d.ts +0 -23
  93. package/dist/bundler-plugins/per-locale-build/frameworks/tanstack-start.d.ts.map +0 -1
  94. package/dist/bundler-plugins/per-locale-build/frameworks/tanstack-start.js +0 -104
  95. package/dist/bundler-plugins/per-locale-build/frameworks/tanstack-start.js.map +0 -1
  96. package/dist/bundler-plugins/per-locale-build/specialize-bundle.d.ts +0 -18
  97. package/dist/bundler-plugins/per-locale-build/specialize-bundle.d.ts.map +0 -1
  98. package/dist/bundler-plugins/per-locale-build/specialize-bundle.js +0 -184
  99. package/dist/bundler-plugins/per-locale-build/specialize-bundle.js.map +0 -1
  100. package/dist/bundler-plugins/per-locale-build/vite-plugin.d.ts +0 -9
  101. package/dist/bundler-plugins/per-locale-build/vite-plugin.d.ts.map +0 -1
  102. package/dist/bundler-plugins/per-locale-build/vite-plugin.js +0 -87
  103. package/dist/bundler-plugins/per-locale-build/vite-plugin.js.map +0 -1
  104. package/dist/bundler-plugins/per-locale-build/vite-plugin.test.d.ts +0 -2
  105. package/dist/bundler-plugins/per-locale-build/vite-plugin.test.d.ts.map +0 -1
  106. package/dist/bundler-plugins/per-locale-build/vite-plugin.test.js +0 -429
  107. package/dist/bundler-plugins/per-locale-build/vite-plugin.test.js.map +0 -1
package/README.md CHANGED
@@ -27,7 +27,8 @@
27
27
  <a href="https://www.idealista.com/"><img src="https://github.com/opral/paraglide-js/blob/main/assets/used-by/idealista.svg?raw=true" alt="idealista" height="18"></a>&nbsp;&nbsp;&nbsp;
28
28
  <a href="https://www.architonic.com/"><img src="https://github.com/opral/paraglide-js/blob/main/assets/used-by/architonic.png?raw=true" alt="Architonic" height="18"></a>&nbsp;&nbsp;&nbsp;
29
29
  <a href="https://lovable.dev/"><img src="https://github.com/opral/paraglide-js/blob/main/assets/used-by/lovable.svg?raw=true" alt="Lovable" height="18"></a>&nbsp;&nbsp;&nbsp;
30
- <a href="https://www.klaviyo.com/"><img src="https://github.com/opral/paraglide-js/blob/main/assets/used-by/klaviyo.svg?raw=true" alt="Klaviyo" height="18"></a>
30
+ <a href="https://www.klaviyo.com/"><img src="https://github.com/opral/paraglide-js/blob/main/assets/used-by/klaviyo.svg?raw=true" alt="Klaviyo" height="18"></a>&nbsp;&nbsp;&nbsp;
31
+ <a href="https://reland.com.br/"><img src="https://github.com/opral/paraglide-js/blob/main/assets/used-by/reland.svg?raw=true" alt="Reland" height="18"></a>
31
32
  </p>
32
33
 
33
34
  <p align="center">
@@ -125,7 +126,9 @@ export default defineConfig({
125
126
 
126
127
  `emitTsDeclarations` requires TypeScript 5.6 or newer and keeps editor types in sync when message files change. Set it to `false` to use the faster JavaScript/JSDoc inference path instead.
127
128
 
128
- The `Greeting` component shown above is all the app code you need. `setLocale()` reloads the page by default so every message re-renders — a deliberate design choice: a user switches language once, so a reload keeps things simple and avoids framework-specific state/scroll-preservation logic (the same approach YouTube and others take). Pass `setLocale("de", { reload: false })` to drive re-rendering yourself.
129
+ The `Greeting` component shown above is all the app code you need. By default, `setLocale()` updates the selection through your configured strategies and performs a full document navigation: it navigates to the localized URL when URL routing is enabled, or reloads the current document otherwise. The new document renders the app and any document-level locale settings together, with no i18n provider or framework reactivity to wire up.
130
+
131
+ For the deliberately narrow browser-only `setLocale(locale, { reload: false })` escape hatch, see [the warning in Basics](https://paraglidejs.com/basics#advanced-stay-on-the-current-document). It is for a fully client-rendered, non-URL surface that must preserve non-restorable in-memory work and transfers all reactive and document-state updates to the application.
129
132
 
130
133
  **[Full React + Vite example →](https://github.com/opral/paraglide-js/tree/main/examples/react)** · **[React Router (SSR) guide →](https://paraglidejs.com/react-router)**
131
134
 
@@ -220,7 +223,7 @@ m.greeting({ name: "Ada" });
220
223
 
221
224
  // Get/set locale
222
225
  getLocale(); // "en"
223
- setLocale("de"); // switches to German
226
+ setLocale("de"); // loads the German document
224
227
  ```
225
228
 
226
229
  **[Full Getting Started Guide →](https://paraglidejs.com)**
@@ -1,4 +1,3 @@
1
- export declare const PER_LOCALE_BUILD_MANIFEST = "paraglide-per-locale.json";
2
1
  export declare const PER_LOCALE_BUILD_MARKER = "__PARAGLIDE_STATIC_LOCALE__";
3
2
  export declare const PER_LOCALE_BUILD_DEFINE = "globalThis.__PARAGLIDE_STATIC_LOCALE__";
4
3
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/bundler-plugins/per-locale-build/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,yBAAyB,8BAA8B,CAAC;AACrE,eAAO,MAAM,uBAAuB,gCAAgC,CAAC;AACrE,eAAO,MAAM,uBAAuB,2CAA0C,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/bundler-plugins/per-locale-build/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,gCAAgC,CAAC;AACrE,eAAO,MAAM,uBAAuB,2CAA0C,CAAC"}
@@ -1,4 +1,3 @@
1
- export const PER_LOCALE_BUILD_MANIFEST = "paraglide-per-locale.json";
2
1
  export const PER_LOCALE_BUILD_MARKER = "__PARAGLIDE_STATIC_LOCALE__";
3
2
  export const PER_LOCALE_BUILD_DEFINE = `globalThis.${PER_LOCALE_BUILD_MARKER}`;
4
3
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/bundler-plugins/per-locale-build/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,yBAAyB,GAAG,2BAA2B,CAAC;AACrE,MAAM,CAAC,MAAM,uBAAuB,GAAG,6BAA6B,CAAC;AACrE,MAAM,CAAC,MAAM,uBAAuB,GAAG,cAAc,uBAAuB,EAAE,CAAC"}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/bundler-plugins/per-locale-build/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,uBAAuB,GAAG,6BAA6B,CAAC;AACrE,MAAM,CAAC,MAAM,uBAAuB,GAAG,cAAc,uBAAuB,EAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/bundler-plugins/per-locale-build/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAK1E,wBAAgB,2BAA2B,CAAC,IAAI,EAAE;IACjD,eAAe,EAAE,eAAe,CAAC;IACjC,oBAAoB,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,MAAM,CAAC;CAC3D,GAAG,MAAM,EAAE,CAgCX"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/bundler-plugins/per-locale-build/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAK1E,wBAAgB,2BAA2B,CAAC,IAAI,EAAE;IACjD,eAAe,EAAE,eAAe,CAAC;IACjC,oBAAoB,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,MAAM,CAAC;CAC3D,GAAG,MAAM,EAAE,CASX"}
@@ -1,44 +1,28 @@
1
1
  import nodeFs from "node:fs";
2
2
  import { loadProjectFromDirectory } from "@inlang/sdk";
3
3
  import { perLocaleBuildStaticLocaleExpression } from "../../compiler/per-locale-build.js";
4
- import { createPerLocaleBuildVitePlugin } from "./vite-plugin.js";
4
+ import { createViteLocaleEnvironmentPlugin } from "./vite-environments.js";
5
5
  export function createPerLocaleBuildPlugins(args) {
6
- const { compilerOptions } = args;
7
- validateCompilerOptions(compilerOptions);
8
- const perLocaleCompilerOptions = {
6
+ validateCompilerOptions(args.compilerOptions);
7
+ const compilerOptions = createPerLocaleCompilerOptions(args.compilerOptions);
8
+ return [
9
+ args.createCompilerPlugin(compilerOptions),
10
+ createViteLocaleEnvironmentPlugin({
11
+ settings: () => loadSettings(compilerOptions),
12
+ }),
13
+ ];
14
+ }
15
+ function createPerLocaleCompilerOptions(compilerOptions) {
16
+ return {
9
17
  ...compilerOptions,
10
- outputStructure: compilerOptions.outputStructure ?? "message-modules",
18
+ outputStructure: compilerOptions.outputStructure ?? "locale-modules",
11
19
  experimentalStaticLocale: perLocaleBuildStaticLocaleExpression,
12
20
  additionalFiles: {
13
21
  ...compilerOptions.additionalFiles,
14
22
  },
15
23
  };
16
- return [
17
- args.createCompilerPlugin(perLocaleCompilerOptions),
18
- createPerLocaleBuildVitePlugin({
19
- // Reload settings for every client build so Vite build --watch picks up
20
- // locale additions/removals instead of reusing the first build's project.
21
- settings: () => loadSettings(perLocaleCompilerOptions),
22
- generatedDirectory: perLocaleCompilerOptions.outdir,
23
- onFrameworkDetected(frameworkFiles) {
24
- assertGeneratedFilesAvailable(frameworkFiles, compilerOptions.additionalFiles);
25
- perLocaleCompilerOptions.additionalFiles = {
26
- ...perLocaleCompilerOptions.additionalFiles,
27
- ...frameworkFiles,
28
- };
29
- },
30
- }),
31
- ];
32
24
  }
33
25
  function validateCompilerOptions(options) {
34
- if (options.strategy !== undefined &&
35
- options.strategy[0] !== "url" &&
36
- options.strategy[0] !== "cookie") {
37
- throw new Error('experimentalPerLocaleBuild requires the first locale strategy to be "url" or "cookie".');
38
- }
39
- if (options.routeStrategies !== undefined) {
40
- throw new Error("experimentalPerLocaleBuild does not support routeStrategies.");
41
- }
42
26
  if (options.experimentalStaticLocale !== undefined) {
43
27
  throw new Error("experimentalPerLocaleBuild cannot be combined with experimentalStaticLocale because it controls the compiler's static locale expression.");
44
28
  }
@@ -46,15 +30,8 @@ function validateCompilerOptions(options) {
46
30
  throw new Error("experimentalPerLocaleBuild cannot be combined with experimentalMiddlewareLocaleSplitting.");
47
31
  }
48
32
  if (options.outputStructure !== undefined &&
49
- options.outputStructure !== "message-modules") {
50
- throw new Error('experimentalPerLocaleBuild currently requires outputStructure: "message-modules".');
51
- }
52
- }
53
- function assertGeneratedFilesAvailable(generatedFiles, additionalFiles) {
54
- for (const fileName of Object.keys(generatedFiles)) {
55
- if (Object.hasOwn(additionalFiles ?? {}, fileName)) {
56
- throw new Error(`experimentalPerLocaleBuild needs to generate ${JSON.stringify(fileName)}, but additionalFiles already defines that path.`);
57
- }
33
+ options.outputStructure !== "locale-modules") {
34
+ throw new Error('experimentalPerLocaleBuild requires outputStructure: "locale-modules".');
58
35
  }
59
36
  }
60
37
  async function loadSettings(options) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/bundler-plugins/per-locale-build/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAGvD,OAAO,EAAE,oCAAoC,EAAE,MAAM,oCAAoC,CAAC;AAE1F,OAAO,EAAE,8BAA8B,EAAE,MAAM,kBAAkB,CAAC;AAElE,MAAM,UAAU,2BAA2B,CAAC,IAG3C;IACA,MAAM,EAAE,eAAe,EAAE,GAAG,IAAI,CAAC;IACjC,uBAAuB,CAAC,eAAe,CAAC,CAAC;IAEzC,MAAM,wBAAwB,GAAoB;QACjD,GAAG,eAAe;QAClB,eAAe,EAAE,eAAe,CAAC,eAAe,IAAI,iBAAiB;QACrE,wBAAwB,EAAE,oCAAoC;QAC9D,eAAe,EAAE;YAChB,GAAG,eAAe,CAAC,eAAe;SAClC;KACD,CAAC;IAEF,OAAO;QACN,IAAI,CAAC,oBAAoB,CAAC,wBAAwB,CAAC;QACnD,8BAA8B,CAAC;YAC9B,wEAAwE;YACxE,0EAA0E;YAC1E,QAAQ,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,wBAAwB,CAAC;YACtD,kBAAkB,EAAE,wBAAwB,CAAC,MAAM;YACnD,mBAAmB,CAAC,cAAc;gBACjC,6BAA6B,CAC5B,cAAc,EACd,eAAe,CAAC,eAA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BAAgB;QACpE,wBAAwB,EAAE,oCAAoC;QAC9D,eAAe,EAAE;YAChB,GAAG,eAAe,CAAC,eAAe;SAClC;KACD,CAAC;AACH,CAAC;AAED,SAAS,uBAAuB,CAAC,OAAwB;IACxD,IAAI,OAAO,CAAC,wBAAwB,KAAK,SAAS,EAAE,CAAC;QACpD,MAAM,IAAI,KAAK,CACd,0IAA0I,CAC1I,CAAC;IACH,CAAC;IACD,IAAI,OAAO,CAAC,qCAAqC,EAAE,CAAC;QACnD,MAAM,IAAI,KAAK,CACd,2FAA2F,CAC3F,CAAC;IACH,CAAC;IACD,IACC,OAAO,CAAC,eAAe,KAAK,SAAS;QACrC,OAAO,CAAC,eAAe,KAAK,gBAAgB,EAC3C,CAAC;QACF,MAAM,IAAI,KAAK,CACd,wEAAwE,CACxE,CAAC;IACH,CAAC;AACF,CAAC;AAED,KAAK,UAAU,YAAY,CAC1B,OAAgD;IAEhD,MAAM,OAAO,GAAG,MAAM,wBAAwB,CAAC;QAC9C,IAAI,EAAE,OAAO,CAAC,OAAO;QACrB,EAAE,EAAE,OAAO,CAAC,EAAE,IAAI,MAAM;KACxB,CAAC,CAAC;IACH,IAAI,CAAC;QACJ,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;QAC9C,OAAO;YACN,UAAU,EAAE,QAAQ,CAAC,UAAU;YAC/B,OAAO,EAAE,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC;SAC9B,CAAC;IACH,CAAC;YAAS,CAAC;QACV,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;AACF,CAAC"}
@@ -2,41 +2,4 @@ export type PerLocaleBuildSettings = {
2
2
  baseLocale: string;
3
3
  locales: string[];
4
4
  };
5
- export type PerLocaleBuildManifest = {
6
- version: 1;
7
- baseLocale: string;
8
- locales: Record<string, {
9
- /** Public URL prefix. Empty for the canonical/base-locale build. */
10
- prefix: string;
11
- /** Canonical public URL to locale-specific public URL. */
12
- assets: Record<string, string>;
13
- }>;
14
- };
15
- export type ViteOxcApi = Pick<typeof import("vite"), "version" | "transformWithOxc" | "minify">;
16
- /** Framework-neutral description of a client bundle's output namespace. */
17
- export type PerLocaleBuildLayout = {
18
- /** Reject unsupported framework output before specialization begins. */
19
- validateOutput?: (fileName: string, type: "asset" | "chunk") => void;
20
- getLocalePrefix: (locale: string, baseLocale: string) => string;
21
- /** Returning the original filename keeps that output locale-neutral. */
22
- getLocalizedFileName: (fileName: string, locale: string, baseLocale: string) => string;
23
- };
24
- export type PerLocaleBuildServerIntegration = {
25
- resolveId: (id: string) => string | undefined;
26
- load: (id: string) => string | undefined;
27
- transform: (code: string, id: string) => {
28
- code: string;
29
- map: null;
30
- } | undefined;
31
- assertPatched: () => void;
32
- };
33
- /** Framework policy consumed by the Vite lifecycle orchestrator. */
34
- export type PerLocaleBuildFramework = {
35
- layout: PerLocaleBuildLayout;
36
- generatedFiles?: Record<string, string>;
37
- createServerIntegration?: (args: {
38
- root: string;
39
- generatedDirectory: string;
40
- }) => PerLocaleBuildServerIntegration;
41
- };
42
5
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/bundler-plugins/per-locale-build/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,sBAAsB,GAAG;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACpC,OAAO,EAAE,CAAC,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CACd,MAAM,EACN;QACC,oEAAoE;QACpE,MAAM,EAAE,MAAM,CAAC;QACf,0DAA0D;QAC1D,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAC/B,CACD,CAAC;CACF,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,IAAI,C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MAAM,MAAM,sBAAsB,GAAG;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC"}
@@ -0,0 +1,52 @@
1
+ import type { Plugin } from "vite";
2
+ import type { PerLocaleBuildSettings } from "./types.js";
3
+ export declare const VITE_LOCALE_BUILD_MANIFEST = "paraglide-vite-locales.json";
4
+ export declare const VITE_LOCALE_ENVIRONMENT_PREFIX = "paraglide_client_";
5
+ export type ViteLocaleBuildPlan = {
6
+ outputDirectory: string;
7
+ variants: Array<{
8
+ locale: string;
9
+ environmentName: string;
10
+ directory: string;
11
+ outputDirectory: string;
12
+ define: Record<string, string>;
13
+ }>;
14
+ };
15
+ export type ViteLocaleBuildManifest = {
16
+ version: 1;
17
+ backend: "vite-rolldown-environments";
18
+ viteVersion: string;
19
+ rolldownVersion: string;
20
+ baseLocale: string;
21
+ locales: Record<string, {
22
+ environment: string;
23
+ directory: string;
24
+ entries: Record<string, string>;
25
+ files: Array<{
26
+ fileName: string;
27
+ type: "asset" | "chunk";
28
+ bytes: number;
29
+ entry?: boolean;
30
+ dynamicEntry?: boolean;
31
+ imports?: string[];
32
+ dynamicImports?: string[];
33
+ externalImports?: string[];
34
+ externalDynamicImports?: string[];
35
+ }>;
36
+ }>;
37
+ };
38
+ export declare function createViteLocaleBuildPlan(args: {
39
+ settings: PerLocaleBuildSettings;
40
+ outputDirectory?: string;
41
+ }): ViteLocaleBuildPlan;
42
+ /**
43
+ * Build one untouched Rolldown client graph per locale.
44
+ *
45
+ * This plugin owns app-build orchestration. It deliberately rejects another
46
+ * custom buildApp orchestrator rather than guessing how a framework builds.
47
+ */
48
+ export declare function createViteLocaleEnvironmentPlugin(args: {
49
+ settings: () => Promise<PerLocaleBuildSettings>;
50
+ outputDirectory?: string;
51
+ }): Plugin;
52
+ //# sourceMappingURL=vite-environments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite-environments.d.ts","sourceRoot":"","sources":["../../../src/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B,CAAC,EAAE,MAAM,EAAE,CAAC;SAClC,CAAC,CAAC;KACH,CACD,CAAC;CACF,CAAC;AAQF,wBAAgB,yBAAyB,CAAC,IAAI,EAAE;IAC/C,QAAQ,EAAE,sBAAsB,CAAC;IACjC,eAAe,CAAC,EAAE,MAAM,CAAC;CACzB,GAAG,mBAAmB,CAoBtB;AAED;;;;;GAKG;AACH,wBAAgB,iCAAiC,CAAC,IAAI,EAAE;IACvD,QAAQ,EAAE,MAAM,OAAO,CAAC,sBAAsB,CAAC,CAAC;IAChD,eAAe,CAAC,EAAE,MAAM,CAAC;CACzB,GAAG,MAAM,CAuET"}
@@ -0,0 +1,250 @@
1
+ import nodeFs from "node:fs/promises";
2
+ import nodePath from "node:path";
3
+ import * as vite from "vite";
4
+ import { PER_LOCALE_BUILD_DEFINE } from "./constants.js";
5
+ import { getPerLocaleBuildLocaleId } from "./locale-id.js";
6
+ export const VITE_LOCALE_BUILD_MANIFEST = "paraglide-vite-locales.json";
7
+ export const VITE_LOCALE_ENVIRONMENT_PREFIX = "paraglide_client_";
8
+ const viteVersion = vite.version;
9
+ const detectedRolldownVersion = vite.rolldownVersion;
10
+ export function createViteLocaleBuildPlan(args) {
11
+ const outputDirectory = normalizeOutputDirectory(args.outputDirectory ?? "dist");
12
+ return {
13
+ outputDirectory,
14
+ variants: args.settings.locales.map((locale) => {
15
+ const localeId = getPerLocaleBuildLocaleId(locale);
16
+ const directory = nodePath.posix.join("__paraglide", localeId);
17
+ return {
18
+ locale,
19
+ environmentName: `${VITE_LOCALE_ENVIRONMENT_PREFIX}${localeId.replaceAll(/[^a-zA-Z0-9_$]/g, "_")}`,
20
+ directory,
21
+ outputDirectory: nodePath.posix.join(outputDirectory, directory),
22
+ define: {
23
+ [PER_LOCALE_BUILD_DEFINE]: JSON.stringify(locale),
24
+ },
25
+ };
26
+ }),
27
+ };
28
+ }
29
+ /**
30
+ * Build one untouched Rolldown client graph per locale.
31
+ *
32
+ * This plugin owns app-build orchestration. It deliberately rejects another
33
+ * custom buildApp orchestrator rather than guessing how a framework builds.
34
+ */
35
+ export function createViteLocaleEnvironmentPlugin(args) {
36
+ let plan;
37
+ let settings;
38
+ let buildApp;
39
+ return {
40
+ name: "paraglide-vite-locale-environments",
41
+ enforce: "post",
42
+ async config(config, env) {
43
+ if (env.command !== "build")
44
+ return;
45
+ if (Number.parseInt(viteVersion, 10) < 8) {
46
+ throw new Error(`experimentalPerLocaleBuild Vite environments require Vite 8 or newer; found ${viteVersion}.`);
47
+ }
48
+ if (config.builder?.buildApp !== undefined) {
49
+ throw new Error("experimentalPerLocaleBuild Vite environments cannot compose with an existing builder.buildApp orchestrator. A framework must expose a public client-variant API before using this backend.");
50
+ }
51
+ settings = await args.settings();
52
+ validateViteLocaleBuildSettings(settings);
53
+ plan = createViteLocaleBuildPlan({
54
+ settings,
55
+ outputDirectory: args.outputDirectory ?? config.build?.outDir,
56
+ });
57
+ for (const variant of plan.variants) {
58
+ if (config.environments?.[variant.environmentName] !== undefined) {
59
+ throw new Error(`experimentalPerLocaleBuild cannot create Vite environment ${JSON.stringify(variant.environmentName)} because the application already defines it.`);
60
+ }
61
+ }
62
+ buildApp = async (builder) => {
63
+ await buildViteLocaleEnvironments({
64
+ builder,
65
+ plan: plan,
66
+ settings: settings,
67
+ });
68
+ };
69
+ return {
70
+ builder: {
71
+ ...config.builder,
72
+ buildApp,
73
+ },
74
+ environments: Object.fromEntries(plan.variants.map((variant) => [
75
+ variant.environmentName,
76
+ createLocaleEnvironment(variant),
77
+ ])),
78
+ };
79
+ },
80
+ configResolved(config) {
81
+ if (config.command !== "build")
82
+ return;
83
+ if (config.builder?.buildApp !== buildApp) {
84
+ throw new Error("experimentalPerLocaleBuild Vite environments must own builder.buildApp. Another plugin replaced the locale build orchestrator.");
85
+ }
86
+ },
87
+ buildStart() {
88
+ if (!this.meta.rolldownVersion) {
89
+ throw new Error("experimentalPerLocaleBuild Vite environments require a Rolldown-powered Vite build (Vite 8 or newer).");
90
+ }
91
+ },
92
+ };
93
+ }
94
+ function createLocaleEnvironment(variant) {
95
+ return {
96
+ consumer: "client",
97
+ define: variant.define,
98
+ build: {
99
+ outDir: variant.outputDirectory,
100
+ emptyOutDir: true,
101
+ manifest: true,
102
+ },
103
+ };
104
+ }
105
+ async function buildViteLocaleEnvironments(args) {
106
+ const outputRoot = nodePath.resolve(args.builder.config.root, args.plan.outputDirectory);
107
+ await Promise.all([
108
+ nodeFs.rm(nodePath.join(outputRoot, "__paraglide"), {
109
+ recursive: true,
110
+ force: true,
111
+ }),
112
+ nodeFs.rm(nodePath.join(outputRoot, VITE_LOCALE_BUILD_MANIFEST), {
113
+ force: true,
114
+ }),
115
+ ]);
116
+ const results = [];
117
+ for (const variant of args.plan.variants) {
118
+ const environment = args.builder.environments[variant.environmentName];
119
+ if (!environment) {
120
+ throw new Error(`Vite did not create the locale environment ${JSON.stringify(variant.environmentName)}.`);
121
+ }
122
+ const result = await args.builder.build(environment);
123
+ results.push({
124
+ variant,
125
+ outputs: getRolldownOutputs(result),
126
+ });
127
+ }
128
+ const manifest = {
129
+ version: 1,
130
+ backend: "vite-rolldown-environments",
131
+ viteVersion,
132
+ rolldownVersion: typeof detectedRolldownVersion === "string"
133
+ ? detectedRolldownVersion
134
+ : "unknown",
135
+ baseLocale: args.settings.baseLocale,
136
+ locales: {},
137
+ };
138
+ for (const { variant, outputs } of results) {
139
+ manifest.locales[variant.locale] = createLocaleManifest({
140
+ variant,
141
+ outputs,
142
+ });
143
+ }
144
+ await nodeFs.mkdir(outputRoot, { recursive: true });
145
+ await nodeFs.writeFile(nodePath.join(outputRoot, VITE_LOCALE_BUILD_MANIFEST), JSON.stringify(manifest, undefined, "\t") + "\n");
146
+ }
147
+ function getRolldownOutputs(result) {
148
+ if (Array.isArray(result)) {
149
+ return result.filter((item) => "output" in item);
150
+ }
151
+ if ("output" in result)
152
+ return [result];
153
+ throw new Error("experimentalPerLocaleBuild Vite environments do not support watch-mode Rolldown output.");
154
+ }
155
+ function createLocaleManifest(args) {
156
+ const outputFiles = args.outputs.flatMap((output) => output.output);
157
+ const emittedFileNames = new Set(outputFiles.map((output) => output.fileName));
158
+ const files = outputFiles
159
+ .map((output) => {
160
+ if (output.type === "asset") {
161
+ return {
162
+ fileName: output.fileName,
163
+ type: "asset",
164
+ bytes: getByteLength(output.source),
165
+ };
166
+ }
167
+ const staticImports = partitionImports(output.imports, emittedFileNames);
168
+ const dynamicImports = partitionImports(output.dynamicImports, emittedFileNames);
169
+ return {
170
+ fileName: output.fileName,
171
+ type: "chunk",
172
+ bytes: getByteLength(output.code),
173
+ ...(output.isEntry ? { entry: true } : {}),
174
+ ...(output.isDynamicEntry ? { dynamicEntry: true } : {}),
175
+ ...(staticImports.internal.length > 0
176
+ ? { imports: staticImports.internal }
177
+ : {}),
178
+ ...(dynamicImports.internal.length > 0
179
+ ? { dynamicImports: dynamicImports.internal }
180
+ : {}),
181
+ ...(staticImports.external.length > 0
182
+ ? { externalImports: staticImports.external }
183
+ : {}),
184
+ ...(dynamicImports.external.length > 0
185
+ ? {
186
+ externalDynamicImports: dynamicImports.external,
187
+ }
188
+ : {}),
189
+ };
190
+ })
191
+ .sort((left, right) => left.fileName.localeCompare(right.fileName));
192
+ const fileNames = new Set(files.map((file) => file.fileName));
193
+ for (const file of files) {
194
+ for (const imported of [
195
+ ...(file.imports ?? []),
196
+ ...(file.dynamicImports ?? []),
197
+ ]) {
198
+ if (!fileNames.has(imported)) {
199
+ throw new Error(`Vite emitted an open locale graph for ${JSON.stringify(args.variant.locale)}: ${file.fileName} imports missing ${imported}.`);
200
+ }
201
+ }
202
+ }
203
+ const entryPairs = [];
204
+ for (const output of args.outputs.flatMap((result) => result.output)) {
205
+ if (output.type === "chunk" && output.isEntry) {
206
+ entryPairs.push([output.facadeModuleId ?? output.name, output.fileName]);
207
+ }
208
+ }
209
+ const entries = Object.fromEntries(entryPairs.sort(([left], [right]) => left.localeCompare(right)));
210
+ return {
211
+ environment: args.variant.environmentName,
212
+ directory: args.variant.directory,
213
+ entries,
214
+ files,
215
+ };
216
+ }
217
+ function partitionImports(imports, emittedFileNames) {
218
+ const internal = [];
219
+ const external = [];
220
+ for (const imported of imports) {
221
+ (emittedFileNames.has(imported) ? internal : external).push(imported);
222
+ }
223
+ return { internal, external };
224
+ }
225
+ function getByteLength(source) {
226
+ return typeof source === "string"
227
+ ? new TextEncoder().encode(source).byteLength
228
+ : source.byteLength;
229
+ }
230
+ function normalizeOutputDirectory(directory) {
231
+ const normalized = directory.replaceAll("\\", "/").replace(/\/+$/, "");
232
+ if (normalized === "" ||
233
+ normalized === "." ||
234
+ normalized.startsWith("/") ||
235
+ normalized === ".." ||
236
+ normalized.startsWith("../")) {
237
+ throw new Error("experimentalPerLocaleBuild Vite environment outputDirectory must be a project-relative directory.");
238
+ }
239
+ return normalized;
240
+ }
241
+ function validateViteLocaleBuildSettings(settings) {
242
+ if (!settings.baseLocale || !settings.locales.includes(settings.baseLocale)) {
243
+ throw new Error("experimentalPerLocaleBuild Vite environments require baseLocale to be present in locales.");
244
+ }
245
+ if (settings.locales.length === 0 ||
246
+ new Set(settings.locales).size !== settings.locales.length) {
247
+ throw new Error("experimentalPerLocaleBuild Vite environments require at least one unique locale.");
248
+ }
249
+ }
250
+ //# sourceMappingURL=vite-environments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite-environments.js","sourceRoot":"","sources":["../../../src/bundler-plugins/per-locale-build/vite-environments.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,QAAQ,MAAM,WAAW,CAAC;AAEjC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAG3D,MAAM,CAAC,MAAM,0BAA0B,GAAG,6BAA6B,CAAC;AACxE,MAAM,CAAC,MAAM,8BAA8B,GAAG,mBAAmB,CAAC;A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,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=vite-environments.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite-environments.test.d.ts","sourceRoot":"","sources":["../../../src/bundler-plugins/per-locale-build/vite-environments.test.ts"],"names":[],"mappings":""}