@inlang/paraglide-js 2.20.2 → 2.22.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 (161) hide show
  1. package/README.md +7 -1
  2. package/dist/bundler-plugins/index.d.ts +1 -1
  3. package/dist/bundler-plugins/index.d.ts.map +1 -1
  4. package/dist/bundler-plugins/index.js +1 -1
  5. package/dist/bundler-plugins/index.js.map +1 -1
  6. package/dist/bundler-plugins/per-locale-build/constants.d.ts +4 -0
  7. package/dist/bundler-plugins/per-locale-build/constants.d.ts.map +1 -0
  8. package/dist/bundler-plugins/per-locale-build/constants.js +4 -0
  9. package/dist/bundler-plugins/per-locale-build/constants.js.map +1 -0
  10. package/dist/bundler-plugins/per-locale-build/framework-helpers.test.d.ts +2 -0
  11. package/dist/bundler-plugins/per-locale-build/framework-helpers.test.d.ts.map +1 -0
  12. package/dist/bundler-plugins/per-locale-build/framework-helpers.test.js +57 -0
  13. package/dist/bundler-plugins/per-locale-build/framework-helpers.test.js.map +1 -0
  14. package/dist/bundler-plugins/per-locale-build/frameworks/index.d.ts +5 -0
  15. package/dist/bundler-plugins/per-locale-build/frameworks/index.d.ts.map +1 -0
  16. package/dist/bundler-plugins/per-locale-build/frameworks/index.js +21 -0
  17. package/dist/bundler-plugins/per-locale-build/frameworks/index.js.map +1 -0
  18. package/dist/bundler-plugins/per-locale-build/frameworks/sveltekit.d.ts +21 -0
  19. package/dist/bundler-plugins/per-locale-build/frameworks/sveltekit.d.ts.map +1 -0
  20. package/dist/bundler-plugins/per-locale-build/frameworks/sveltekit.js +137 -0
  21. package/dist/bundler-plugins/per-locale-build/frameworks/sveltekit.js.map +1 -0
  22. package/dist/bundler-plugins/per-locale-build/frameworks/tanstack-start.d.ts +23 -0
  23. package/dist/bundler-plugins/per-locale-build/frameworks/tanstack-start.d.ts.map +1 -0
  24. package/dist/bundler-plugins/per-locale-build/frameworks/tanstack-start.js +104 -0
  25. package/dist/bundler-plugins/per-locale-build/frameworks/tanstack-start.js.map +1 -0
  26. package/dist/bundler-plugins/per-locale-build/index.d.ts +7 -0
  27. package/dist/bundler-plugins/per-locale-build/index.d.ts.map +1 -0
  28. package/dist/bundler-plugins/per-locale-build/index.js +76 -0
  29. package/dist/bundler-plugins/per-locale-build/index.js.map +1 -0
  30. package/dist/bundler-plugins/per-locale-build/locale-id.d.ts +9 -0
  31. package/dist/bundler-plugins/per-locale-build/locale-id.d.ts.map +1 -0
  32. package/dist/bundler-plugins/per-locale-build/locale-id.js +13 -0
  33. package/dist/bundler-plugins/per-locale-build/locale-id.js.map +1 -0
  34. package/dist/bundler-plugins/per-locale-build/specialize-bundle.d.ts +18 -0
  35. package/dist/bundler-plugins/per-locale-build/specialize-bundle.d.ts.map +1 -0
  36. package/dist/bundler-plugins/per-locale-build/specialize-bundle.js +184 -0
  37. package/dist/bundler-plugins/per-locale-build/specialize-bundle.js.map +1 -0
  38. package/dist/bundler-plugins/per-locale-build/types.d.ts +42 -0
  39. package/dist/bundler-plugins/per-locale-build/types.d.ts.map +1 -0
  40. package/dist/bundler-plugins/per-locale-build/types.js +2 -0
  41. package/dist/bundler-plugins/per-locale-build/types.js.map +1 -0
  42. package/dist/bundler-plugins/per-locale-build/vite-plugin.d.ts +9 -0
  43. package/dist/bundler-plugins/per-locale-build/vite-plugin.d.ts.map +1 -0
  44. package/dist/bundler-plugins/per-locale-build/vite-plugin.js +87 -0
  45. package/dist/bundler-plugins/per-locale-build/vite-plugin.js.map +1 -0
  46. package/dist/bundler-plugins/per-locale-build/vite-plugin.test.d.ts +2 -0
  47. package/dist/bundler-plugins/per-locale-build/vite-plugin.test.d.ts.map +1 -0
  48. package/dist/bundler-plugins/per-locale-build/vite-plugin.test.js +429 -0
  49. package/dist/bundler-plugins/per-locale-build/vite-plugin.test.js.map +1 -0
  50. package/dist/bundler-plugins/rolldown.d.ts +1 -1
  51. package/dist/bundler-plugins/rollup.d.ts +1 -1
  52. package/dist/bundler-plugins/vite.d.ts +16 -1
  53. package/dist/bundler-plugins/vite.d.ts.map +1 -1
  54. package/dist/bundler-plugins/vite.js +12 -1
  55. package/dist/bundler-plugins/vite.js.map +1 -1
  56. package/dist/bundler-plugins/vite.test.d.ts +2 -0
  57. package/dist/bundler-plugins/vite.test.d.ts.map +1 -0
  58. package/dist/bundler-plugins/vite.test.js +97 -0
  59. package/dist/bundler-plugins/vite.test.js.map +1 -0
  60. package/dist/cli/defaults.d.ts.map +1 -1
  61. package/dist/cli/steps/initialize-inlang-project.d.ts.map +1 -1
  62. package/dist/cli/steps/update-ts-config.d.ts.map +1 -1
  63. package/dist/cli/steps/update-ts-config.js.map +1 -1
  64. package/dist/cli/utils.d.ts.map +1 -1
  65. package/dist/cli/utils.js.map +1 -1
  66. package/dist/compiler/compile-bundle.d.ts +2 -0
  67. package/dist/compiler/compile-bundle.d.ts.map +1 -1
  68. package/dist/compiler/compile-bundle.js +11 -2
  69. package/dist/compiler/compile-bundle.js.map +1 -1
  70. package/dist/compiler/compile-bundle.test.js +64 -4
  71. package/dist/compiler/compile-bundle.test.js.map +1 -1
  72. package/dist/compiler/compile-message.d.ts.map +1 -1
  73. package/dist/compiler/compile-pattern.d.ts.map +1 -1
  74. package/dist/compiler/compile-project.d.ts.map +1 -1
  75. package/dist/compiler/compile-project.js +3 -0
  76. package/dist/compiler/compile-project.js.map +1 -1
  77. package/dist/compiler/compile-project.test.js +35 -1
  78. package/dist/compiler/compile-project.test.js.map +1 -1
  79. package/dist/compiler/compile.bench.js.map +1 -1
  80. package/dist/compiler/compiler-options.d.ts +7 -1
  81. package/dist/compiler/compiler-options.d.ts.map +1 -1
  82. package/dist/compiler/emit-ts-declarations.d.ts.map +1 -1
  83. package/dist/compiler/emit-ts-declarations.interop.test.d.ts +2 -0
  84. package/dist/compiler/emit-ts-declarations.interop.test.d.ts.map +1 -0
  85. package/dist/compiler/emit-ts-declarations.interop.test.js +62 -0
  86. package/dist/compiler/emit-ts-declarations.interop.test.js.map +1 -0
  87. package/dist/compiler/emit-ts-declarations.js +150 -0
  88. package/dist/compiler/emit-ts-declarations.js.map +1 -1
  89. package/dist/compiler/emit-ts-declarations.test.d.ts +2 -0
  90. package/dist/compiler/emit-ts-declarations.test.d.ts.map +1 -0
  91. package/dist/compiler/emit-ts-declarations.test.js +181 -0
  92. package/dist/compiler/emit-ts-declarations.test.js.map +1 -0
  93. package/dist/compiler/output-structure/message-modules.test.js.map +1 -1
  94. package/dist/compiler/per-locale-build.d.ts +3 -0
  95. package/dist/compiler/per-locale-build.d.ts.map +1 -0
  96. package/dist/compiler/per-locale-build.js +3 -0
  97. package/dist/compiler/per-locale-build.js.map +1 -0
  98. package/dist/compiler/resolve-tsc-js-path.d.ts +10 -0
  99. package/dist/compiler/resolve-tsc-js-path.d.ts.map +1 -0
  100. package/dist/compiler/resolve-tsc-js-path.js +23 -0
  101. package/dist/compiler/resolve-tsc-js-path.js.map +1 -0
  102. package/dist/compiler/runtime/check-locale.d.ts +3 -3
  103. package/dist/compiler/runtime/check-locale.d.ts.map +1 -1
  104. package/dist/compiler/runtime/create-runtime.d.ts.map +1 -1
  105. package/dist/compiler/runtime/create-runtime.js +5 -1
  106. package/dist/compiler/runtime/create-runtime.js.map +1 -1
  107. package/dist/compiler/runtime/extract-locale-from-cookie.d.ts +2 -2
  108. package/dist/compiler/runtime/extract-locale-from-cookie.d.ts.map +1 -1
  109. package/dist/compiler/runtime/extract-locale-from-header.d.ts +1 -1
  110. package/dist/compiler/runtime/extract-locale-from-header.d.ts.map +1 -1
  111. package/dist/compiler/runtime/extract-locale-from-navigator.d.ts +1 -1
  112. package/dist/compiler/runtime/extract-locale-from-navigator.d.ts.map +1 -1
  113. package/dist/compiler/runtime/extract-locale-from-request-async.d.ts +33 -2
  114. package/dist/compiler/runtime/extract-locale-from-request-async.d.ts.map +1 -1
  115. package/dist/compiler/runtime/extract-locale-from-request.d.ts +36 -4
  116. package/dist/compiler/runtime/extract-locale-from-request.d.ts.map +1 -1
  117. package/dist/compiler/runtime/extract-locale-from-url.d.ts +1 -1
  118. package/dist/compiler/runtime/extract-locale-from-url.d.ts.map +1 -1
  119. package/dist/compiler/runtime/generate-static-localized-urls.d.ts +1 -1
  120. package/dist/compiler/runtime/generate-static-localized-urls.d.ts.map +1 -1
  121. package/dist/compiler/runtime/get-locale.d.ts +36 -3
  122. package/dist/compiler/runtime/get-locale.d.ts.map +1 -1
  123. package/dist/compiler/runtime/get-text-direction.d.ts +1 -1
  124. package/dist/compiler/runtime/get-text-direction.d.ts.map +1 -1
  125. package/dist/compiler/runtime/get-url-origin.d.ts +10 -2
  126. package/dist/compiler/runtime/get-url-origin.d.ts.map +1 -1
  127. package/dist/compiler/runtime/localize-href.d.ts +3 -3
  128. package/dist/compiler/runtime/localize-href.d.ts.map +1 -1
  129. package/dist/compiler/runtime/localize-url.d.ts +4 -4
  130. package/dist/compiler/runtime/localize-url.d.ts.map +1 -1
  131. package/dist/compiler/runtime/set-locale.d.ts +19 -5
  132. package/dist/compiler/runtime/set-locale.d.ts.map +1 -1
  133. package/dist/compiler/runtime/set-locale.js +7 -1
  134. package/dist/compiler/runtime/set-locale.js.map +1 -1
  135. package/dist/compiler/runtime/set-locale.test.js +31 -0
  136. package/dist/compiler/runtime/set-locale.test.js.map +1 -1
  137. package/dist/compiler/runtime/should-redirect.d.ts +29 -29
  138. package/dist/compiler/runtime/should-redirect.d.ts.map +1 -1
  139. package/dist/compiler/runtime/strategy.d.ts +36 -36
  140. package/dist/compiler/runtime/strategy.d.ts.map +1 -1
  141. package/dist/compiler/runtime/track-message-call.d.ts +1 -1
  142. package/dist/compiler/runtime/track-message-call.d.ts.map +1 -1
  143. package/dist/compiler/runtime/type-definitions.d.ts +144 -43
  144. package/dist/compiler/runtime/type-definitions.d.ts.map +1 -1
  145. package/dist/compiler/runtime/type.test.js.map +1 -1
  146. package/dist/compiler/runtime/variables.d.ts +60 -60
  147. package/dist/compiler/runtime/variables.d.ts.map +1 -1
  148. package/dist/compiler/server/create-server-file.js.map +1 -1
  149. package/dist/compiler/server/middleware.d.ts +1 -1
  150. package/dist/compiler/server/middleware.d.ts.map +1 -1
  151. package/dist/services/codegen/quotes.d.ts.map +1 -1
  152. package/dist/services/env-variables/create-index-file.d.ts +8 -0
  153. package/dist/services/env-variables/create-index-file.d.ts.map +1 -1
  154. package/dist/services/env-variables/create-index-file.js.map +1 -1
  155. package/dist/services/env-variables/index.d.ts.map +1 -1
  156. package/dist/services/env-variables/index.js +1 -1
  157. package/dist/services/file-watching/tracked-fs.js.map +1 -1
  158. package/dist/services/logger/index.d.ts.map +1 -1
  159. package/dist/services/logger/index.js.map +1 -1
  160. package/dist/utilities/detect-json-formatting.d.ts.map +1 -1
  161. package/package.json +8 -2
@@ -0,0 +1,429 @@
1
+ import { expect, test } from "vitest";
2
+ import { minify, transformWithOxc, version } from "vite";
3
+ import { PER_LOCALE_BUILD_DEFINE, PER_LOCALE_BUILD_MANIFEST, } from "./constants.js";
4
+ import { detectPerLocaleBuildFramework } from "./frameworks/index.js";
5
+ import { createSvelteKitLayout, createSvelteKitServerIntegration, patchSvelteKitRenderModule, } from "./frameworks/sveltekit.js";
6
+ import { createTanStackStartFramework } from "./frameworks/tanstack-start.js";
7
+ import { specializePerLocaleBundle, validatePerLocaleBuildSettings, } from "./specialize-bundle.js";
8
+ import { createPerLocaleBuildVitePlugin } from "./vite-plugin.js";
9
+ import { getPerLocaleBuildLocaleId } from "./locale-id.js";
10
+ import { getPerLocaleBuildPrefix } from "./frameworks/tanstack-start.js";
11
+ const viteOxc = { version, minify, transformWithOxc };
12
+ test("specializes the canonical client and emits non-base assets with identical filenames", async () => {
13
+ const bundle = createBundle({
14
+ "assets/app-deadbeef.js": localeBranchFixture,
15
+ "assets/app-deadbeef.css": "body { color: rebeccapurple }",
16
+ });
17
+ const result = await specializePerLocaleBundle({
18
+ bundle,
19
+ layout: createTanStackStartFramework().layout,
20
+ settings: { baseLocale: "en", locales: ["en", "de"] },
21
+ vite: viteOxc,
22
+ });
23
+ const canonical = bundle["assets/app-deadbeef.js"];
24
+ expect(canonical?.type).toBe("chunk");
25
+ if (canonical?.type !== "chunk")
26
+ throw new Error("Expected a chunk");
27
+ expect(canonical.code).toContain("__SENTINEL_EN__");
28
+ expect(canonical.code).not.toContain("__SENTINEL_DE__");
29
+ expect(canonical.code).not.toContain(PER_LOCALE_BUILD_DEFINE);
30
+ const dePrefix = getPerLocaleBuildPrefix("de").replace(/^\//, "");
31
+ const deChunk = result.assets.find((asset) => asset.fileName === `${dePrefix}/assets/app-deadbeef.js`);
32
+ expect(deChunk?.source.toString()).toContain("__SENTINEL_DE__");
33
+ expect(deChunk?.source.toString()).not.toContain("__SENTINEL_EN__");
34
+ expect(deChunk?.source.toString()).not.toContain(PER_LOCALE_BUILD_DEFINE);
35
+ expect(result.assets.find((asset) => asset.fileName === `${dePrefix}/assets/app-deadbeef.css`)?.source).toBe("body { color: rebeccapurple }");
36
+ expect(result.manifest).toEqual({
37
+ version: 1,
38
+ baseLocale: "en",
39
+ locales: {
40
+ en: {
41
+ prefix: "",
42
+ assets: {
43
+ "/assets/app-deadbeef.css": "/assets/app-deadbeef.css",
44
+ "/assets/app-deadbeef.js": "/assets/app-deadbeef.js",
45
+ },
46
+ },
47
+ de: {
48
+ prefix: getPerLocaleBuildPrefix("de"),
49
+ assets: {
50
+ "/assets/app-deadbeef.css": `${getPerLocaleBuildPrefix("de")}/assets/app-deadbeef.css`,
51
+ "/assets/app-deadbeef.js": `${getPerLocaleBuildPrefix("de")}/assets/app-deadbeef.js`,
52
+ },
53
+ },
54
+ },
55
+ });
56
+ });
57
+ test("keeps localized CSS references closed and canonicalizes public assets", async () => {
58
+ const css = [
59
+ '@import "../public-theme.css";',
60
+ '@font-face { src: url("../public-font.woff2") }',
61
+ ".emitted { src: url(./emitted-font.woff2?#iefix) }",
62
+ ".external { src: url(https://cdn.example/font.woff2) }",
63
+ ].join("\n");
64
+ const bundle = createBundle({
65
+ "assets/app.js": localeBranchFixture,
66
+ "assets/styles.css": css,
67
+ "assets/emitted-font.woff2": "emitted-font",
68
+ });
69
+ const result = await specializePerLocaleBundle({
70
+ bundle,
71
+ layout: createTanStackStartFramework().layout,
72
+ settings: { baseLocale: "en", locales: ["en", "de"] },
73
+ vite: viteOxc,
74
+ });
75
+ const expected = [
76
+ '@import "/public-theme.css";',
77
+ '@font-face { src: url("/public-font.woff2") }',
78
+ ".emitted { src: url(./emitted-font.woff2?#iefix) }",
79
+ ".external { src: url(https://cdn.example/font.woff2) }",
80
+ ].join("\n");
81
+ const canonicalCss = bundle["assets/styles.css"];
82
+ expect(canonicalCss?.type).toBe("asset");
83
+ if (canonicalCss?.type !== "asset")
84
+ throw new Error("Expected CSS asset");
85
+ expect(canonicalCss.source).toBe(expected);
86
+ const dePrefix = getPerLocaleBuildPrefix("de").replace(/^\//, "");
87
+ expect(result.assets.find((asset) => asset.fileName === `${dePrefix}/assets/styles.css`)?.source).toBe(expected);
88
+ expect(result.assets.find((asset) => asset.fileName === `${dePrefix}/assets/emitted-font.woff2`)?.source).toBe("emitted-font");
89
+ });
90
+ test("keeps SvelteKit locale copies inside its immutable cache directory", async () => {
91
+ const bundle = createBundle({
92
+ "_app/immutable/entry/app.js": localeBranchFixture,
93
+ "_app/immutable/assets/app.css": 'body { background: url("../../../favicon.png") }',
94
+ "_app/version.json": '{"version":"1"}',
95
+ });
96
+ const result = await specializePerLocaleBundle({
97
+ bundle,
98
+ layout: createSvelteKitLayout(),
99
+ settings: { baseLocale: "en", locales: ["en", "de"] },
100
+ vite: viteOxc,
101
+ });
102
+ const localizedRoot = "_app/immutable/__paraglide/de-6465";
103
+ expect(result.assets
104
+ .find((asset) => asset.fileName === `${localizedRoot}/entry/app.js`)
105
+ ?.source.toString()).toContain("__SENTINEL_DE__");
106
+ expect(result.assets.find((asset) => asset.fileName === `${localizedRoot}/assets/app.css`)?.source).toBe('body { background: url("/favicon.png") }');
107
+ expect(result.assets.some((asset) => asset.fileName.includes("version.json"))).toBe(false);
108
+ expect(result.manifest.locales.en).toEqual({
109
+ prefix: "",
110
+ assets: {
111
+ "/_app/immutable/assets/app.css": "/_app/immutable/assets/app.css",
112
+ "/_app/immutable/entry/app.js": "/_app/immutable/entry/app.js",
113
+ "/_app/version.json": "/_app/version.json",
114
+ },
115
+ });
116
+ expect(result.manifest.locales.de).toEqual({
117
+ prefix: `/${localizedRoot}`,
118
+ assets: {
119
+ "/_app/immutable/assets/app.css": `/${localizedRoot}/assets/app.css`,
120
+ "/_app/immutable/entry/app.js": `/${localizedRoot}/entry/app.js`,
121
+ "/_app/version.json": "/_app/version.json",
122
+ },
123
+ });
124
+ });
125
+ test("non-base JavaScript copies are emitted as assets, not entry chunks", async () => {
126
+ const plugin = createPerLocaleBuildVitePlugin({
127
+ settings: async () => ({ baseLocale: "en", locales: ["en", "de"] }),
128
+ generatedDirectory: "src/paraglide",
129
+ loadVite: async () => viteOxc,
130
+ });
131
+ const emitted = [];
132
+ const warnings = [];
133
+ const generateBundle = plugin.generateBundle;
134
+ if (!generateBundle || typeof generateBundle === "function") {
135
+ throw new Error("Expected an ordered generateBundle hook");
136
+ }
137
+ if (typeof plugin.configResolved !== "function") {
138
+ throw new Error("Expected configResolved hook");
139
+ }
140
+ plugin.configResolved.call({}, {
141
+ plugins: [{ name: "tanstack-start-core:config" }],
142
+ define: {},
143
+ build: { ssr: false },
144
+ });
145
+ await generateBundle.handler.call({
146
+ environment: { config: { consumer: "client" } },
147
+ emitFile(file) {
148
+ emitted.push(file);
149
+ return "reference-id";
150
+ },
151
+ warn(message) {
152
+ warnings.push(message);
153
+ },
154
+ }, {}, createBundle({ "assets/app.js": localeBranchFixture }), false);
155
+ const localizedJs = emitted.find((file) => typeof file.fileName === "string" && file.fileName.endsWith("/app.js"));
156
+ expect(localizedJs).toMatchObject({ type: "asset" });
157
+ expect(localizedJs).not.toHaveProperty("isEntry");
158
+ expect(emitted).toContainEqual(expect.objectContaining({
159
+ type: "asset",
160
+ fileName: PER_LOCALE_BUILD_MANIFEST,
161
+ }));
162
+ const emittedManifest = emitted.find((file) => file.fileName === PER_LOCALE_BUILD_MANIFEST);
163
+ expect(JSON.parse(String(emittedManifest?.source))).toMatchObject({
164
+ version: 1,
165
+ baseLocale: "en",
166
+ locales: {
167
+ en: { prefix: "" },
168
+ de: { prefix: "/__paraglide/de-6465" },
169
+ },
170
+ });
171
+ expect(warnings).toEqual([]);
172
+ });
173
+ test("configures locale-safe asset URLs and reserves final minification", async () => {
174
+ const plugin = createPerLocaleBuildVitePlugin({
175
+ settings: async () => ({ baseLocale: "en", locales: ["en"] }),
176
+ generatedDirectory: "src/paraglide",
177
+ });
178
+ const config = plugin.config;
179
+ const configEnvironment = plugin.configEnvironment;
180
+ if (!config ||
181
+ typeof config !== "function" ||
182
+ !configEnvironment ||
183
+ typeof configEnvironment !== "function") {
184
+ throw new Error("Expected Vite config hooks");
185
+ }
186
+ expect(() => config.call({}, { base: "/app/" }, { command: "build" })).toThrow("custom Vite base");
187
+ expect(() => config.call({}, { build: { minify: false } }, {
188
+ command: "build",
189
+ })).toThrow("requires client minification");
190
+ expect(() => config.call({}, { build: { sourcemap: true } }, {
191
+ command: "build",
192
+ })).toThrow("does not support client sourcemaps");
193
+ const configured = await config.call({}, {}, {
194
+ command: "build",
195
+ });
196
+ if (!configured)
197
+ throw new Error("Expected a Vite config result");
198
+ expect(configured).toMatchObject({ base: "" });
199
+ const renderBuiltUrl = configured?.experimental?.renderBuiltUrl;
200
+ if (!renderBuiltUrl)
201
+ throw new Error("Expected renderBuiltUrl");
202
+ expect(renderBuiltUrl("assets/styles.css", {
203
+ type: "asset",
204
+ hostId: "server.js",
205
+ hostType: "js",
206
+ ssr: true,
207
+ })).toBe("/assets/styles.css");
208
+ expect(renderBuiltUrl("assets/app.js", {
209
+ type: "asset",
210
+ hostId: "index.html",
211
+ hostType: "html",
212
+ ssr: false,
213
+ })).toEqual({ relative: true });
214
+ expect(() => config.call({}, {
215
+ experimental: {
216
+ renderBuiltUrl: () => "https://cdn.example/asset.js",
217
+ },
218
+ }, { command: "build" })).toThrow("cannot be combined with experimental.renderBuiltUrl");
219
+ expect(() => configEnvironment.call({}, "client", { consumer: "client", build: { minify: "oxc", sourcemap: true } }, { command: "build" })).toThrow("does not support client sourcemaps");
220
+ expect(() => configEnvironment.call({}, "client", { consumer: "client", build: { minify: false } }, { command: "build" })).toThrow("requires client minification");
221
+ expect(configEnvironment.call({}, "client", { build: { minify: "oxc" } }, { command: "build" })).toEqual({ build: { minify: false, sourcemap: false } });
222
+ expect(configEnvironment.call({}, "ssr", { consumer: "server" }, {
223
+ command: "build",
224
+ })).toEqual({ define: { [PER_LOCALE_BUILD_DEFINE]: "undefined" } });
225
+ expect(configEnvironment.call({}, "client", { consumer: "client" }, {
226
+ command: "serve",
227
+ })).toEqual({ define: { [PER_LOCALE_BUILD_DEFINE]: "undefined" } });
228
+ });
229
+ test.each(["7.3.0", "9.0.0"])("rejects unsupported Vite %s", async (version) => {
230
+ await expect(specializePerLocaleBundle({
231
+ bundle: createBundle({ "app.js": localeBranchFixture }),
232
+ layout: createTanStackStartFramework().layout,
233
+ settings: { baseLocale: "en", locales: ["en"] },
234
+ vite: {
235
+ ...viteOxc,
236
+ version,
237
+ },
238
+ })).rejects.toThrow("requires Vite 8");
239
+ });
240
+ test("detects TanStack Start and SvelteKit and rejects unsupported frameworks", () => {
241
+ expect(detectPerLocaleBuildFramework({
242
+ plugins: [{ name: "tanstack-start-core:config" }],
243
+ define: {},
244
+ })).toHaveProperty("layout");
245
+ const svelteSetup = createSvelteKitSetup();
246
+ const svelte = detectPerLocaleBuildFramework({
247
+ plugins: [svelteSetup],
248
+ define: { __SVELTEKIT_APP_DIR__: '"_app"' },
249
+ });
250
+ expect(svelte.layout).toBeDefined();
251
+ expect(() => detectPerLocaleBuildFramework({
252
+ plugins: [{ name: "vite-plugin-svelte" }],
253
+ define: {},
254
+ })).toThrow("supports TanStack Start and SvelteKit");
255
+ expect(() => detectPerLocaleBuildFramework({
256
+ plugins: [svelteSetup, { name: "tanstack-start-core:config" }],
257
+ define: {},
258
+ })).toThrow("both TanStack Start and SvelteKit");
259
+ for (const unsupported of [
260
+ { appDir: "app" },
261
+ { paths: { base: "/docs", assets: "" } },
262
+ { output: { bundleStrategy: "inline" } },
263
+ { router: { resolution: "server" } },
264
+ { files: { serviceWorker: new URL(import.meta.url).pathname } },
265
+ ]) {
266
+ expect(() => detectPerLocaleBuildFramework({
267
+ plugins: [createSvelteKitSetup(unsupported)],
268
+ define: {},
269
+ })).toThrow("supports only the tested SvelteKit 2.69.x defaults");
270
+ }
271
+ const plugin = createPerLocaleBuildVitePlugin({
272
+ settings: async () => ({ baseLocale: "en", locales: ["en"] }),
273
+ generatedDirectory: "src/paraglide",
274
+ });
275
+ const configResolved = plugin.configResolved;
276
+ if (!configResolved || typeof configResolved !== "function") {
277
+ throw new Error("Expected configResolved hook");
278
+ }
279
+ expect(() => configResolved.call({}, { plugins: [] })).toThrow("supports TanStack Start and SvelteKit");
280
+ });
281
+ test("guards multi-locale SvelteKit SPA fallbacks in the virtual adapter", async () => {
282
+ const plugin = createPerLocaleBuildVitePlugin({
283
+ settings: async () => ({ baseLocale: "en", locales: ["en", "de"] }),
284
+ generatedDirectory: "src/paraglide",
285
+ });
286
+ if (typeof plugin.configResolved !== "function") {
287
+ throw new Error("Expected configResolved hook");
288
+ }
289
+ plugin.configResolved.call({}, {
290
+ root: "/app",
291
+ plugins: [createSvelteKitSetup()],
292
+ define: { __SVELTEKIT_APP_DIR__: '"_app"' },
293
+ build: { ssr: true },
294
+ });
295
+ if (typeof plugin.load !== "function") {
296
+ throw new Error("Expected load hook");
297
+ }
298
+ const source = await plugin.load.call({}, "\0virtual:paraglide-per-locale-build/sveltekit");
299
+ expect(source).toContain("locales.length > 1");
300
+ expect(source).toContain("does not support SvelteKit SPA fallback pages");
301
+ expect(source).toContain('marker + "__paraglide/" + getLocaleId(locale)');
302
+ expect(source).not.toContain("per-locale-build.js");
303
+ if (typeof source !== "string")
304
+ throw new Error("Expected virtual source");
305
+ const executableSource = source.replace(/^import .*;$/m, 'const baseLocale = "en"; const locales = ["en", "de"]; let currentLocale = "de"; const getLocale = () => currentLocale; export const setTestLocale = (locale) => currentLocale = locale;');
306
+ const virtualModule = (await import(`data:text/javascript;base64,${Buffer.from(executableSource).toString("base64")}`));
307
+ const localized = `_app/immutable/__paraglide/${getPerLocaleBuildLocaleId("de")}/chunks/app.js`;
308
+ expect(virtualModule.localizeSvelteKitAssetPath("_app/immutable/chunks/app.js")).toBe(localized);
309
+ expect(virtualModule.localizeSvelteKitAssetPath(localized)).toBe(localized);
310
+ expect(virtualModule.localizeSvelteKitAssetPath("favicon.png")).toBe("favicon.png");
311
+ virtualModule.setTestLocale("en");
312
+ expect(virtualModule.localizeSvelteKitAssetPath("_app/immutable/chunks/app.js")).toBe("_app/immutable/chunks/app.js");
313
+ for (const locale of ["pt-BR", "中文", "en/us", "en?us"]) {
314
+ virtualModule.setTestLocale(locale);
315
+ expect(virtualModule.localizeSvelteKitAssetPath("_app/immutable/chunks/app.js")).toBe(`_app/immutable/__paraglide/${getPerLocaleBuildLocaleId(locale)}/chunks/app.js`);
316
+ }
317
+ });
318
+ test("patches SvelteKit asset rendering before preload and CSP generation", () => {
319
+ const render = patchSvelteKitRenderModule(`
320
+ export async function render_response({ state }) {
321
+ if (state.prerendering) {
322
+ state.prerendering = true;
323
+ }
324
+ const prefixed = (path) => {
325
+ return path;
326
+ };
327
+ }
328
+ `);
329
+ expect(render).toContain(SVELTEKIT_VIRTUAL_IMPORT_SNIPPET);
330
+ expect(render).toContain("path = __paraglideLocalizeSvelteKitAssetPath(path);");
331
+ expect(render).toContain("__paraglideAssertSvelteKitPerLocaleFallbackSupported(state.prerendering?.fallback)");
332
+ expect(() => patchSvelteKitRenderModule("const changed = true;")).toThrow("differs from the tested SvelteKit 2.69.x");
333
+ });
334
+ test("requires the tested SvelteKit render module to be patched", () => {
335
+ const integration = createSvelteKitServerIntegration({
336
+ root: "/app",
337
+ generatedDirectory: "src/paraglide",
338
+ });
339
+ expect(() => integration.assertPatched()).toThrow("server rendering internals were not found");
340
+ integration.transform(`export async function render_response({ state }) {
341
+ if (state.prerendering) {}
342
+ const prefixed = (path) => {
343
+ return path;
344
+ };
345
+ }`, "/node_modules/@sveltejs/kit/src/runtime/server/page/render.js");
346
+ expect(() => integration.assertPatched()).not.toThrow();
347
+ });
348
+ test("validates project locale invariants", () => {
349
+ expect(() => validatePerLocaleBuildSettings({ baseLocale: "en", locales: ["de"] })).toThrow("is not present");
350
+ expect(() => validatePerLocaleBuildSettings({
351
+ baseLocale: "en",
352
+ locales: ["en", "en"],
353
+ })).toThrow("unique");
354
+ });
355
+ function createBundle(files) {
356
+ return Object.fromEntries(Object.entries(files).map(([fileName, source]) => {
357
+ if (fileName.endsWith(".js")) {
358
+ return [
359
+ fileName,
360
+ {
361
+ type: "chunk",
362
+ fileName,
363
+ name: "app",
364
+ code: source,
365
+ map: null,
366
+ imports: [],
367
+ dynamicImports: [],
368
+ exports: ["message"],
369
+ facadeModuleId: "/src/app.js",
370
+ isEntry: true,
371
+ isDynamicEntry: false,
372
+ moduleIds: ["/src/app.js"],
373
+ modules: {},
374
+ preliminaryFileName: fileName,
375
+ sourcemapFileName: null,
376
+ },
377
+ ];
378
+ }
379
+ return [
380
+ fileName,
381
+ {
382
+ type: "asset",
383
+ fileName,
384
+ name: fileName,
385
+ names: [fileName],
386
+ originalFileName: null,
387
+ originalFileNames: [],
388
+ source,
389
+ },
390
+ ];
391
+ }));
392
+ }
393
+ function createSvelteKitSetup(overrides = {}) {
394
+ return {
395
+ name: "vite-plugin-sveltekit-setup",
396
+ api: {
397
+ options: {
398
+ kit: {
399
+ appDir: "_app",
400
+ output: { bundleStrategy: "split" },
401
+ paths: { base: "", assets: "" },
402
+ router: { resolution: "client" },
403
+ ...overrides,
404
+ },
405
+ },
406
+ },
407
+ };
408
+ }
409
+ const localeBranchFixture = `
410
+ const staticLocaleInput = ${PER_LOCALE_BUILD_DEFINE};
411
+ const staticLocale = staticLocaleInput === undefined
412
+ ? undefined
413
+ : staticLocaleInput === "en"
414
+ ? "en"
415
+ : staticLocaleInput === "de"
416
+ ? "de"
417
+ : staticLocaleInput;
418
+ const en = () => "__SENTINEL_EN__";
419
+ const de = () => "__SENTINEL_DE__";
420
+ export const message = () => {
421
+ if (${PER_LOCALE_BUILD_DEFINE} === "en") return en();
422
+ if (${PER_LOCALE_BUILD_DEFINE} === "de") return de();
423
+ const locale = staticLocale ?? "en";
424
+ if (locale === "en") return en();
425
+ return de();
426
+ };
427
+ `;
428
+ const SVELTEKIT_VIRTUAL_IMPORT_SNIPPET = "virtual:paraglide-per-locale-build/sveltekit";
429
+ //# sourceMappingURL=vite-plugin.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite-plugin.test.js","sourceRoot":"","sources":["../../../src/bundler-plugins/per-locale-build/vite-plugin.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACzD,OAAO,EACN,uBAAuB,EACvB,yBAAyB,GACzB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EACN,qBAAqB,EACrB,gCAAgC,EAChC,0BAA0B,GAC1B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EACN,yBAAyB,EACzB,8BAA8B,GAC9B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,8BAA8B,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEzE,MAAM,OAAO,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE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AAE,UAAU,EAAE,QAAQ,EAAE;oBAChC,GAAG,SAAS;iBACZ;aACD;SACD;KACD,CAAC;AACH,CAAC;AAED,MAAM,mBAAmB,GAAG;4BACA,uBAAuB;;;;;;;;;;;OAW5C,uBAAuB;OACvB,uBAAuB;;;;;CAK7B,CAAC;AAEF,MAAM,gCAAgC,GACrC,8CAA8C,CAAC"}
@@ -1,2 +1,2 @@
1
- export declare const paraglideRolldownPlugin: (options: import("../index.js").CompilerOptions) => import("unplugin").RolldownPlugin<any> | import("unplugin").RolldownPlugin<any>[];
1
+ export declare const paraglideRolldownPlugin: (options: import("../index.js").CompilerOptions) => import("unplugin").RolldownPlugin<any>[] | import("unplugin").RolldownPlugin<any>;
2
2
  //# sourceMappingURL=rolldown.d.ts.map
@@ -1,2 +1,2 @@
1
- export declare const paraglideRollupPlugin: (options: import("../index.js").CompilerOptions) => import("unplugin").RollupPlugin<any> | import("unplugin").RollupPlugin<any>[];
1
+ export declare const paraglideRollupPlugin: (options: import("../index.js").CompilerOptions) => import("unplugin").RollupPlugin<any>[] | import("unplugin").RollupPlugin<any>;
2
2
  //# sourceMappingURL=rollup.d.ts.map
@@ -1,2 +1,17 @@
1
- export declare const paraglideVitePlugin: (options: import("../index.js").CompilerOptions) => import("vite").Plugin<any> | import("vite").Plugin<any>[];
1
+ import type { Plugin } from "vite";
2
+ import type { CompilerOptions } from "../compiler/compiler-options.js";
3
+ export type ParaglideVitePluginOptions = CompilerOptions & {
4
+ /**
5
+ * Emit one compiler-specialized client asset tree per project locale.
6
+ *
7
+ * Supports the documented default configurations of TanStack Start and
8
+ * SvelteKit on Vite 8.x. Unsupported framework and asset configurations fail
9
+ * during the build. Locale changes need to use full-document navigation.
10
+ *
11
+ * @experimental
12
+ * @default false
13
+ */
14
+ experimentalPerLocaleBuild?: boolean;
15
+ };
16
+ export declare function paraglideVitePlugin(options: ParaglideVitePluginOptions): Plugin | Plugin[];
2
17
  //# sourceMappingURL=vite.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../../src/bundler-plugins/vite.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,mBAAmB,+GAAoC,CAAC"}
1
+ {"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../../src/bundler-plugins/vite.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAIvE,MAAM,MAAM,0BAA0B,GAAG,eAAe,GAAG;IAC1D;;;;;;;;;OASG;IACH,0BAA0B,CAAC,EAAE,OAAO,CAAC;CACrC,CAAC;AAIF,wBAAgB,mBAAmB,CAClC,OAAO,EAAE,0BAA0B,GACjC,MAAM,GAAG,MAAM,EAAE,CAWnB"}
@@ -1,4 +1,15 @@
1
1
  import { createVitePlugin } from "unplugin";
2
+ import { createPerLocaleBuildPlugins } from "./per-locale-build/index.js";
2
3
  import { unpluginFactory } from "./unplugin.js";
3
- export const paraglideVitePlugin = createVitePlugin(unpluginFactory);
4
+ const createCompilerVitePlugin = createVitePlugin(unpluginFactory);
5
+ export function paraglideVitePlugin(options) {
6
+ const { experimentalPerLocaleBuild, ...compilerOptions } = options;
7
+ if (!experimentalPerLocaleBuild) {
8
+ return createCompilerVitePlugin(compilerOptions);
9
+ }
10
+ return createPerLocaleBuildPlugins({
11
+ compilerOptions,
12
+ createCompilerPlugin: (options) => createCompilerVitePlugin(options),
13
+ });
14
+ }
4
15
  //# sourceMappingURL=vite.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"vite.js","sourceRoot":"","sources":["../../src/bundler-plugins/vite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,MAAM,CAAC,MAAM,mBAAmB,GAAG,gBAAgB,CAAC,eAAe,CAAC,CAAC"}
1
+ {"version":3,"file":"vite.js","sourceRoot":"","sources":["../../src/bundler-plugins/vite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAG5C,OAAO,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAgBhD,MAAM,wBAAwB,GAAG,gBAAgB,CAAC,eAAe,CAAC,CAAC;AAEnE,MAAM,UAAU,mBAAmB,CAClC,OAAmC;IAEnC,MAAM,EAAE,0BAA0B,EAAE,GAAG,eAAe,EAAE,GAAG,OAAO,CAAC;IACnE,IAAI,CAAC,0BAA0B,EAAE,CAAC;QACjC,OAAO,wBAAwB,CAAC,eAAe,CAAW,CAAC;IAC5D,CAAC;IAED,OAAO,2BAA2B,CAAC;QAClC,eAAe;QACf,oBAAoB,EAAE,CAAC,OAAO,EAAE,EAAE,CACjC,wBAAwB,CAAC,OAAO,CAAW;KAC5C,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=vite.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite.test.d.ts","sourceRoot":"","sources":["../../src/bundler-plugins/vite.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,97 @@
1
+ import { expect, test } from "vitest";
2
+ import { memfs } from "memfs";
3
+ import { loadProjectInMemory, newProject, saveProjectToDirectory, } from "@inlang/sdk";
4
+ import { paraglideVitePlugin } from "./vite.js";
5
+ import { perLocaleBuildStaticLocaleExpression } from "../compiler/per-locale-build.js";
6
+ test("experimentalPerLocaleBuild configures the compiler and emits the detected framework adapter", async () => {
7
+ const project = await loadProjectInMemory({
8
+ blob: await newProject({
9
+ settings: { baseLocale: "en", locales: ["en", "de"] },
10
+ }),
11
+ });
12
+ const fs = memfs().fs;
13
+ await saveProjectToDirectory({
14
+ project,
15
+ path: "/project.inlang",
16
+ fs: fs.promises,
17
+ });
18
+ const plugins = paraglideVitePlugin({
19
+ project: "/project.inlang",
20
+ outdir: "/src/paraglide",
21
+ fs,
22
+ experimentalPerLocaleBuild: true,
23
+ additionalFiles: { "custom.js": "export const custom = true;\n" },
24
+ });
25
+ expect(Array.isArray(plugins)).toBe(true);
26
+ if (!Array.isArray(plugins))
27
+ throw new Error("Expected multiple Vite plugins");
28
+ expect(plugins.map((plugin) => plugin.name)).toEqual([
29
+ "unplugin-paraglide-js",
30
+ "paraglide-per-locale-build",
31
+ ]);
32
+ const compiler = plugins[0];
33
+ const perLocaleBuild = plugins[1];
34
+ if (typeof perLocaleBuild.configResolved !== "function") {
35
+ throw new Error("Expected the per-locale configResolved hook");
36
+ }
37
+ perLocaleBuild.configResolved.call({}, {
38
+ root: "/",
39
+ plugins: [{ name: "tanstack-start-core:config" }],
40
+ define: {},
41
+ build: { ssr: false },
42
+ });
43
+ if (typeof compiler.buildStart !== "function") {
44
+ throw new Error("Expected the compiler buildStart hook");
45
+ }
46
+ await compiler.buildStart.call({ addWatchFile() { } }, {});
47
+ expect(await fs.promises.readFile("/src/paraglide/tanstack-start.server.js", "utf8")).toContain("createStartHandler");
48
+ expect(await fs.promises.readFile("/src/paraglide/custom.js", "utf8")).toContain("export const custom = true;");
49
+ expect(await fs.promises.readFile("/src/paraglide/runtime.js", "utf8")).toContain(perLocaleBuildStaticLocaleExpression);
50
+ });
51
+ test("experimentalPerLocaleBuild rejects conflicting compiler options", () => {
52
+ const common = { project: "/project.inlang", outdir: "/src/paraglide" };
53
+ expect(() => paraglideVitePlugin({
54
+ ...common,
55
+ experimentalPerLocaleBuild: true,
56
+ experimentalStaticLocale: '"de"',
57
+ })).toThrow("cannot be combined with experimentalStaticLocale");
58
+ expect(() => paraglideVitePlugin({
59
+ ...common,
60
+ experimentalPerLocaleBuild: true,
61
+ experimentalMiddlewareLocaleSplitting: true,
62
+ })).toThrow("cannot be combined with experimentalMiddlewareLocaleSplitting");
63
+ expect(() => paraglideVitePlugin({
64
+ ...common,
65
+ experimentalPerLocaleBuild: true,
66
+ outputStructure: "locale-modules",
67
+ })).toThrow('requires outputStructure: "message-modules"');
68
+ expect(() => paraglideVitePlugin({
69
+ ...common,
70
+ experimentalPerLocaleBuild: true,
71
+ strategy: ["preferredLanguage", "baseLocale"],
72
+ })).toThrow('first locale strategy to be "url" or "cookie"');
73
+ expect(() => paraglideVitePlugin({
74
+ ...common,
75
+ experimentalPerLocaleBuild: true,
76
+ routeStrategies: [],
77
+ })).toThrow("does not support routeStrategies");
78
+ const plugins = paraglideVitePlugin({
79
+ ...common,
80
+ experimentalPerLocaleBuild: true,
81
+ additionalFiles: { "tanstack-start.server.js": "user content" },
82
+ });
83
+ if (!Array.isArray(plugins)) {
84
+ throw new Error("Expected multiple Vite plugins");
85
+ }
86
+ const configResolved = plugins[1]?.configResolved;
87
+ if (typeof configResolved !== "function") {
88
+ throw new Error("Expected the per-locale configResolved hook");
89
+ }
90
+ expect(() => configResolved.call({}, {
91
+ root: "/",
92
+ plugins: [{ name: "tanstack-start-core:config" }],
93
+ define: {},
94
+ build: { ssr: false },
95
+ })).toThrow("additionalFiles already defines that path");
96
+ });
97
+ //# sourceMappingURL=vite.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite.test.js","sourceRoot":"","sources":["../../src/bundler-plugins/vite.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EACN,mBAAmB,EACnB,UAAU,EACV,sBAAsB,GACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,oCAAoC,EAAE,MAAM,iCAAiC,CAAC;AAEvF,IAAI,CAAC,6FAA6F,EAAE,KAAK,IAAI,EAAE;IAC9G,MAAM,OAAO,GAAG,MAAM,mBAAmB,CAAC;QACzC,IAAI,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GAAG,EAAE,KAAK,EAAE;KACZ,CACV,CACD,CAAC,OAAO,CAAC,2CAA2C,CAAC,CAAC;AACxD,CAAC,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/cli/defaults.ts"],"names":[],"mappings":"AAmBA;;GAEG;AACH,wBAAgB,qBAAqB;;;;;;;;EAEpC;AAED,eAAO,MAAM,oBAAoB,qBAAqB,CAAC;AACvD,eAAO,MAAM,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/cli/defaults.ts"],"names":[],"mappings":"AAmBA;;GAEG;AACH,wBAAgB,qBAAqB;;;;;;QAPnC,WAAW;;EASZ;AAED,eAAO,MAAM,oBAAoB,qBAAqB,CAAC;AACvD,eAAO,MAAM,cAAc,oBAAoB,CAAC"}