@inlang/paraglide-js 2.0.0-beta.14 → 2.0.0-beta.15
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.
- package/dist/compiler/compile-message.js +3 -4
- package/dist/compiler/compile-project.d.ts +1 -1
- package/dist/compiler/compile-project.d.ts.map +1 -1
- package/dist/compiler/compile-project.js +13 -5
- package/dist/compiler/compile-project.test.js +9 -5
- package/dist/compiler/compile.d.ts +25 -0
- package/dist/compiler/compile.d.ts.map +1 -1
- package/dist/compiler/compile.js +3 -11
- package/dist/compiler/compile.test.js +11 -3
- package/dist/compiler/output-structure/locale-modules.d.ts +5 -1
- package/dist/compiler/output-structure/locale-modules.d.ts.map +1 -1
- package/dist/compiler/output-structure/locale-modules.js +8 -3
- package/dist/compiler/output-structure/locale-modules.test.js +3 -2
- package/dist/compiler/output-structure/message-modules.d.ts +5 -1
- package/dist/compiler/output-structure/message-modules.d.ts.map +1 -1
- package/dist/compiler/output-structure/message-modules.js +13 -5
- package/dist/compiler/output-structure/message-modules.test.js +2 -1
- package/dist/compiler/runtime/assert-is-locale.d.ts.map +1 -1
- package/dist/compiler/runtime/assert-is-locale.js +2 -0
- package/dist/compiler/runtime/assert-is-locale.test.js +19 -12
- package/dist/compiler/runtime/base-locale.d.ts +10 -0
- package/dist/compiler/runtime/base-locale.d.ts.map +1 -0
- package/dist/compiler/runtime/base-locale.js +9 -0
- package/dist/compiler/runtime/cookie-name.d.ts +3 -0
- package/dist/compiler/runtime/cookie-name.d.ts.map +1 -0
- package/dist/compiler/runtime/cookie-name.js +2 -0
- package/dist/compiler/runtime/create-runtime.d.ts +27 -2
- package/dist/compiler/runtime/create-runtime.d.ts.map +1 -1
- package/dist/compiler/runtime/create-runtime.js +116 -7
- package/dist/compiler/runtime/de-localize-path.d.ts.map +1 -1
- package/dist/compiler/runtime/de-localize-path.js +2 -1
- package/dist/compiler/runtime/de-localize-path.test.js +40 -41
- package/dist/compiler/runtime/extract-locale-from-cookie.d.ts +10 -0
- package/dist/compiler/runtime/extract-locale-from-cookie.d.ts.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-cookie.js +16 -0
- package/dist/compiler/runtime/extract-locale-from-cookie.test.d.ts +2 -0
- package/dist/compiler/runtime/extract-locale-from-cookie.test.d.ts.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-cookie.test.js +27 -0
- package/dist/compiler/runtime/extract-locale-from-pathname.d.ts +13 -0
- package/dist/compiler/runtime/extract-locale-from-pathname.d.ts.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-pathname.js +19 -0
- package/dist/compiler/runtime/extract-locale-from-pathname.test.d.ts +2 -0
- package/dist/compiler/runtime/extract-locale-from-pathname.test.d.ts.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-pathname.test.js +20 -0
- package/dist/compiler/runtime/extract-locale-from-request.d.ts +10 -0
- package/dist/compiler/runtime/extract-locale-from-request.d.ts.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-request.js +42 -0
- package/dist/compiler/runtime/extract-locale-from-request.test.d.ts +2 -0
- package/dist/compiler/runtime/extract-locale-from-request.test.d.ts.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-request.test.js +66 -0
- package/dist/compiler/runtime/get-locale.d.ts +14 -0
- package/dist/compiler/runtime/get-locale.d.ts.map +1 -0
- package/dist/compiler/runtime/get-locale.js +52 -0
- package/dist/compiler/runtime/get-locale.test.d.ts +2 -0
- package/dist/compiler/runtime/get-locale.test.d.ts.map +1 -0
- package/dist/compiler/runtime/get-locale.test.js +42 -0
- package/dist/compiler/runtime/is-locale.d.ts.map +1 -1
- package/dist/compiler/runtime/is-locale.js +2 -1
- package/dist/compiler/runtime/locales.d.ts +10 -0
- package/dist/compiler/runtime/locales.d.ts.map +1 -0
- package/dist/compiler/runtime/locales.js +9 -0
- package/dist/compiler/runtime/localize-path.d.ts.map +1 -1
- package/dist/compiler/runtime/localize-path.js +4 -1
- package/dist/compiler/runtime/localize-path.test.js +40 -34
- package/dist/compiler/runtime/set-locale.d.ts +10 -0
- package/dist/compiler/runtime/set-locale.d.ts.map +1 -0
- package/dist/compiler/runtime/set-locale.js +64 -0
- package/dist/compiler/runtime/set-locale.test.d.ts +2 -0
- package/dist/compiler/runtime/set-locale.test.d.ts.map +1 -0
- package/dist/compiler/runtime/set-locale.test.js +41 -0
- package/dist/compiler/runtime/strategy.d.ts +5 -0
- package/dist/compiler/runtime/strategy.d.ts.map +1 -0
- package/dist/compiler/runtime/strategy.js +4 -0
- package/dist/compiler/runtime/type.d.ts +8 -4
- package/dist/compiler/runtime/type.d.ts.map +1 -1
- package/dist/compiler/runtime/type.test.js +17 -8
- package/dist/services/env-variables/index.js +1 -1
- package/package.json +3 -3
- package/dist/compiler/runtime/de-localized-path.d.ts +0 -27
- package/dist/compiler/runtime/de-localized-path.d.ts.map +0 -1
- package/dist/compiler/runtime/de-localized-path.js +0 -32
- package/dist/compiler/runtime/de-localized-path.test.d.ts +0 -2
- package/dist/compiler/runtime/de-localized-path.test.d.ts.map +0 -1
- package/dist/compiler/runtime/de-localized-path.test.js +0 -48
- package/dist/compiler/runtime/get-locale-from-path.d.ts +0 -13
- package/dist/compiler/runtime/get-locale-from-path.d.ts.map +0 -1
- package/dist/compiler/runtime/get-locale-from-path.js +0 -17
- package/dist/compiler/runtime/get-locale-from-path.test.d.ts +0 -2
- package/dist/compiler/runtime/get-locale-from-path.test.d.ts.map +0 -1
- package/dist/compiler/runtime/get-locale-from-path.test.js +0 -22
- package/dist/compiler/runtime/jsdoc-runtime.d.ts +0 -2
- package/dist/compiler/runtime/jsdoc-runtime.d.ts.map +0 -1
- package/dist/compiler/runtime/jsdoc-runtime.js +0 -131
- package/dist/compiler/runtime/locale-in-path.d.ts +0 -13
- package/dist/compiler/runtime/locale-in-path.d.ts.map +0 -1
- package/dist/compiler/runtime/locale-in-path.js +0 -17
- package/dist/compiler/runtime/locale-in-path.test.d.ts +0 -2
- package/dist/compiler/runtime/locale-in-path.test.d.ts.map +0 -1
- package/dist/compiler/runtime/locale-in-path.test.js +0 -22
- package/dist/compiler/runtime/localized-path.d.ts +0 -32
- package/dist/compiler/runtime/localized-path.d.ts.map +0 -1
- package/dist/compiler/runtime/localized-path.js +0 -44
- package/dist/compiler/runtime/localized-path.test.d.ts +0 -2
- package/dist/compiler/runtime/localized-path.test.d.ts.map +0 -1
- package/dist/compiler/runtime/localized-path.test.js +0 -42
- package/dist/compiler/runtime/mock-runtime.d.ts +0 -6
- package/dist/compiler/runtime/mock-runtime.d.ts.map +0 -1
- package/dist/compiler/runtime/mock-runtime.js +0 -26
- package/dist/compiler/runtime/ts-runtime.d.ts +0 -2
- package/dist/compiler/runtime/ts-runtime.d.ts.map +0 -1
- package/dist/compiler/runtime/ts-runtime.js +0 -119
|
@@ -56,9 +56,8 @@ function compileMessageWithMultipleVariants(declarations, message, variants, reg
|
|
|
56
56
|
continue;
|
|
57
57
|
compiledVariants.push(`if (${conditions.join(" && ")}) return ${compiledPattern.code};`);
|
|
58
58
|
}
|
|
59
|
-
const code = `
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}`;
|
|
59
|
+
const code = `export const ${message.bundleId} = (i) => {
|
|
60
|
+
${compiledVariants.join("\n\t")}
|
|
61
|
+
}`;
|
|
63
62
|
return { code, node: message };
|
|
64
63
|
}
|
|
@@ -12,7 +12,7 @@ import { type CompilerOptions } from "./compile.js";
|
|
|
12
12
|
*/
|
|
13
13
|
export declare const compileProject: (args: {
|
|
14
14
|
project: InlangProject;
|
|
15
|
-
compilerOptions?:
|
|
15
|
+
compilerOptions?: Omit<CompilerOptions, "fs" | "project" | "outdir">;
|
|
16
16
|
}) => Promise<Record<string, string>>;
|
|
17
17
|
export declare function getFallbackMap<T extends string>(locales: T[], baseLocale: NoInfer<T>): Record<T, T | undefined>;
|
|
18
18
|
//# sourceMappingURL=compile-project.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile-project.d.ts","sourceRoot":"","sources":["../../src/compiler/compile-project.ts"],"names":[],"mappings":"AAEA,OAAO,EAAsB,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAIrE,OAAO,EAA0B,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAE5E;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,SAAgB;IAC1C,OAAO,EAAE,aAAa,CAAC;IACvB,eAAe,CAAC,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"compile-project.d.ts","sourceRoot":"","sources":["../../src/compiler/compile-project.ts"],"names":[],"mappings":"AAEA,OAAO,EAAsB,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAIrE,OAAO,EAA0B,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAE5E;;;;;;;;;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,CAoEjC,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"}
|
|
@@ -32,11 +32,11 @@ export const compileProject = async (args) => {
|
|
|
32
32
|
}));
|
|
33
33
|
const output = {};
|
|
34
34
|
if (optionsWithDefaults.outputStructure === "locale-modules") {
|
|
35
|
-
const regularOutput = generateLocaleModules(compiledBundles, settings, fallbackMap);
|
|
35
|
+
const regularOutput = generateLocaleModules(compiledBundles, settings, fallbackMap, optionsWithDefaults);
|
|
36
36
|
Object.assign(output, regularOutput);
|
|
37
37
|
}
|
|
38
38
|
if (optionsWithDefaults.outputStructure === "message-modules") {
|
|
39
|
-
const messageModuleOutput = generateMessageModules(compiledBundles, settings, fallbackMap);
|
|
39
|
+
const messageModuleOutput = generateMessageModules(compiledBundles, settings, fallbackMap, optionsWithDefaults);
|
|
40
40
|
Object.assign(output, messageModuleOutput);
|
|
41
41
|
}
|
|
42
42
|
if (optionsWithDefaults.emitGitIgnore) {
|
|
@@ -45,9 +45,17 @@ export const compileProject = async (args) => {
|
|
|
45
45
|
if (optionsWithDefaults.emitPrettierIgnore) {
|
|
46
46
|
output[".prettierignore"] = ignoreDirectory;
|
|
47
47
|
}
|
|
48
|
-
for (const
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
for (const [filename, content] of Object.entries(optionsWithDefaults.additionalFiles ?? {})) {
|
|
49
|
+
output[filename] = content;
|
|
50
|
+
}
|
|
51
|
+
for (const [filename, content] of Object.entries(output)) {
|
|
52
|
+
if (filename.endsWith(".js") || filename.endsWith(".ts")) {
|
|
53
|
+
output[filename] = `// @ts-nocheck\n${output[filename]}`;
|
|
54
|
+
}
|
|
55
|
+
if (optionsWithDefaults.includeEslintDisableComment) {
|
|
56
|
+
if (filename.endsWith(".js")) {
|
|
57
|
+
output[filename] = `// eslint-disable\n${content}`;
|
|
58
|
+
}
|
|
51
59
|
}
|
|
52
60
|
}
|
|
53
61
|
return output;
|
|
@@ -8,6 +8,12 @@ beforeEach(() => {
|
|
|
8
8
|
// reset the imports to make sure that the runtime is reloaded
|
|
9
9
|
vi.resetModules();
|
|
10
10
|
vi.clearAllMocks();
|
|
11
|
+
// mocking DOM globals
|
|
12
|
+
// @ts-expect-error - global variable definition
|
|
13
|
+
globalThis.window = {};
|
|
14
|
+
// @ts-expect-error - global variable definition
|
|
15
|
+
globalThis.window.location = {};
|
|
16
|
+
globalThis.window.location.reload = () => { };
|
|
11
17
|
});
|
|
12
18
|
test("emitGitignore", async () => {
|
|
13
19
|
const project = await loadProjectInMemory({
|
|
@@ -61,9 +67,11 @@ describe.each([
|
|
|
61
67
|
// useTsImports must be true to test emitTs. Otherwise, rolldown can't resolve the imports
|
|
62
68
|
{
|
|
63
69
|
outputStructure: "locale-modules",
|
|
70
|
+
strategy: ["variable", "baseLocale"],
|
|
64
71
|
},
|
|
65
72
|
{
|
|
66
73
|
outputStructure: "message-modules",
|
|
74
|
+
strategy: ["variable", "baseLocale"],
|
|
67
75
|
},
|
|
68
76
|
])("options", async (compilerOptions) => {
|
|
69
77
|
const output = await compileProject({ project, compilerOptions });
|
|
@@ -280,6 +288,7 @@ describe.each([
|
|
|
280
288
|
strict: true,
|
|
281
289
|
},
|
|
282
290
|
});
|
|
291
|
+
console.log(output["runtime.js"]);
|
|
283
292
|
for (const [fileName, code] of Object.entries(output)) {
|
|
284
293
|
if (fileName.endsWith(".js") || fileName.endsWith(".ts")) {
|
|
285
294
|
project.createSourceFile(fileName, code);
|
|
@@ -375,11 +384,6 @@ describe.each([
|
|
|
375
384
|
async function bundleCode(output, file) {
|
|
376
385
|
const bundle = await rolldown({
|
|
377
386
|
input: ["main.js"],
|
|
378
|
-
resolve: {
|
|
379
|
-
extensionAlias: {
|
|
380
|
-
".js": [".ts", ".js"],
|
|
381
|
-
},
|
|
382
|
-
},
|
|
383
387
|
plugins: [
|
|
384
388
|
// @ts-expect-error - rollup types are not up to date
|
|
385
389
|
virtual({
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import type { Runtime } from "./runtime/type.js";
|
|
1
2
|
export declare const defaultCompilerOptions: {
|
|
2
3
|
readonly outputStructure: "message-modules";
|
|
3
4
|
readonly emitGitIgnore: true;
|
|
4
5
|
readonly includeEslintDisableComment: true;
|
|
5
6
|
readonly emitPrettierIgnore: true;
|
|
7
|
+
readonly strategy: ["cookie", "variable", "baseLocale"];
|
|
8
|
+
readonly cookieName: "PARAGLIDE_LOCALE";
|
|
6
9
|
};
|
|
7
10
|
export type CompilerOptions = {
|
|
8
11
|
/**
|
|
@@ -19,6 +22,28 @@ export type CompilerOptions = {
|
|
|
19
22
|
* './src/paraglide'
|
|
20
23
|
*/
|
|
21
24
|
outdir: string;
|
|
25
|
+
/**
|
|
26
|
+
* The strategy to use for getting the locale.
|
|
27
|
+
*
|
|
28
|
+
* The order of the strategy defines the precendence of matches.
|
|
29
|
+
*
|
|
30
|
+
* For example, in `['pathname', 'cookie', 'baseLocale']`, the locale will be
|
|
31
|
+
* first tried to be detected in the pathname, then in a cookie, and finally
|
|
32
|
+
* fallback to the base locale.
|
|
33
|
+
*
|
|
34
|
+
* The default ensures that the browser takes a cookie approach,
|
|
35
|
+
* server-side takes the variable (because cookie is unvailable),
|
|
36
|
+
* whereas both fallback to the base locale if not available.
|
|
37
|
+
*
|
|
38
|
+
* @default ["cookie", "variable", "baseLocale"]
|
|
39
|
+
*/
|
|
40
|
+
strategy?: Runtime["strategy"];
|
|
41
|
+
/**
|
|
42
|
+
* The name of the cookie to use for the cookie strategy.
|
|
43
|
+
*
|
|
44
|
+
* @default 'PARAGLIDE_LOCALE'
|
|
45
|
+
*/
|
|
46
|
+
cookieName?: string;
|
|
22
47
|
/**
|
|
23
48
|
* Additional files that should be emmited in the outdir.
|
|
24
49
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../src/compiler/compile.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../src/compiler/compile.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEjD,eAAO,MAAM,sBAAsB;;;;;;;CAOU,CAAC;AAE9C,MAAM,MAAM,eAAe,GAAG;IAC7B;;;;;OAKG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;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;;;;;;;OAOG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B;;;;OAIG;IACH,2BAA2B,CAAC,EAAE,OAAO,CAAC;IACtC;;;;OAIG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;OAIG;IACH,eAAe,CAAC,EAAE,gBAAgB,GAAG,iBAAiB,CAAC;IACvD;;;;OAIG;IACH,EAAE,CAAC,EAAE,cAAc,SAAS,CAAC,CAAC;CAC9B,CAAC;AAMF;;;;;;;;;;;;GAYG;AACH,wBAAsB,OAAO,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CA+CrE"}
|
package/dist/compiler/compile.js
CHANGED
|
@@ -9,6 +9,8 @@ export const defaultCompilerOptions = {
|
|
|
9
9
|
emitGitIgnore: true,
|
|
10
10
|
includeEslintDisableComment: true,
|
|
11
11
|
emitPrettierIgnore: true,
|
|
12
|
+
strategy: ["cookie", "variable", "baseLocale"],
|
|
13
|
+
cookieName: "PARAGLIDE_LOCALE",
|
|
12
14
|
};
|
|
13
15
|
// This is a workaround to prevent multiple compilations from running at the same time.
|
|
14
16
|
// https://github.com/opral/inlang-paraglide-js/issues/320#issuecomment-2596951222
|
|
@@ -45,19 +47,9 @@ export async function compile(options) {
|
|
|
45
47
|
appId: ENV_VARIABLES.PARJS_APP_ID,
|
|
46
48
|
});
|
|
47
49
|
const output = await compileProject({
|
|
48
|
-
|
|
50
|
+
compilerOptions: withDefaultOptions,
|
|
49
51
|
project,
|
|
50
52
|
});
|
|
51
|
-
for (const [filename, content] of Object.entries(withDefaultOptions.additionalFiles ?? {})) {
|
|
52
|
-
output[filename] = content;
|
|
53
|
-
}
|
|
54
|
-
if (withDefaultOptions.includeEslintDisableComment) {
|
|
55
|
-
for (const [filename, content] of Object.entries(output)) {
|
|
56
|
-
if (filename.endsWith(".js")) {
|
|
57
|
-
output[filename] = `// eslint-disable-next-line\n${content}`;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
53
|
await writeOutput(absoluteOutdir, output, fs.promises);
|
|
62
54
|
if (!localAccount) {
|
|
63
55
|
const activeAccount = await project.lix.db
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { loadProjectInMemory, newProject, saveProjectToDirectory, } from "@inlang/sdk";
|
|
2
2
|
import { memfs } from "memfs";
|
|
3
3
|
import { test, expect, vi } from "vitest";
|
|
4
|
-
import { compile } from "./compile.js";
|
|
4
|
+
import { compile, defaultCompilerOptions } from "./compile.js";
|
|
5
5
|
import { getAccountFilePath } from "../services/account/index.js";
|
|
6
6
|
test("loads a project and compiles it", async () => {
|
|
7
7
|
const project = await loadProjectInMemory({
|
|
@@ -183,7 +183,7 @@ test("includes eslint-disable comment", async () => {
|
|
|
183
183
|
fs: fs,
|
|
184
184
|
});
|
|
185
185
|
const messages = await fs.promises.readFile("/output/messages.js", "utf8");
|
|
186
|
-
expect(messages).toContain("// eslint-disable
|
|
186
|
+
expect(messages).toContain("// eslint-disable");
|
|
187
187
|
await compile({
|
|
188
188
|
project: "/project.inlang",
|
|
189
189
|
outdir: "/output",
|
|
@@ -191,5 +191,13 @@ test("includes eslint-disable comment", async () => {
|
|
|
191
191
|
fs: fs,
|
|
192
192
|
});
|
|
193
193
|
const messagesWithoutComment = await fs.promises.readFile("/output/messages.js", "utf8");
|
|
194
|
-
expect(messagesWithoutComment).not.toContain("// eslint-disable
|
|
194
|
+
expect(messagesWithoutComment).not.toContain("// eslint-disable");
|
|
195
|
+
});
|
|
196
|
+
test("default compiler options should include variable and baseLocale to ensure easy try out of paraglide js, working both in server and browser environemnts", () => {
|
|
197
|
+
// someone trying out paraglide js should be able to call `getLocale()` and `setLocale()`
|
|
198
|
+
// without getting an error slammed in their face saying "define your strategy".
|
|
199
|
+
//
|
|
200
|
+
// instead, make the apis work out of the box and once the developer is convinced that
|
|
201
|
+
// paraglide js is the right tool for them, they can then define their own strategy.
|
|
202
|
+
expect(defaultCompilerOptions.strategy).toEqual(expect.arrayContaining(["variable", "baseLocale"]));
|
|
195
203
|
});
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import type { ProjectSettings } from "@inlang/sdk";
|
|
2
2
|
import type { CompiledBundleWithMessages } from "../compile-bundle.js";
|
|
3
|
-
|
|
3
|
+
import { type CompilerOptions } from "../compile.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>;
|
|
4
8
|
//# 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;
|
|
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,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD,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,CA0DxB"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsIdentifier } from "../../services/codegen/identifier.js";
|
|
2
|
-
import {
|
|
2
|
+
import { createRuntimeFile } from "../runtime/create-runtime.js";
|
|
3
3
|
import { createRegistry } from "../registry.js";
|
|
4
|
-
|
|
4
|
+
import {} from "../compile.js";
|
|
5
|
+
export function generateLocaleModules(compiledBundles, settings, fallbackMap, compilerOptions) {
|
|
5
6
|
const fileExt = "js";
|
|
6
7
|
const importExt = "js";
|
|
7
8
|
const indexFile = [
|
|
@@ -12,7 +13,11 @@ export function generateLocaleModules(compiledBundles, settings, fallbackMap) {
|
|
|
12
13
|
compiledBundles.map(({ bundle }) => bundle.code).join("\n"),
|
|
13
14
|
].join("\n");
|
|
14
15
|
const output = {
|
|
15
|
-
["runtime." + fileExt]:
|
|
16
|
+
["runtime." + fileExt]: createRuntimeFile({
|
|
17
|
+
baseLocale: settings.baseLocale,
|
|
18
|
+
locales: settings.locales,
|
|
19
|
+
compilerOptions,
|
|
20
|
+
}),
|
|
16
21
|
["registry." + fileExt]: createRegistry(),
|
|
17
22
|
["messages." + fileExt]: indexFile,
|
|
18
23
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { test, expect } from "vitest";
|
|
2
2
|
import { generateLocaleModules } from "./locale-modules.js";
|
|
3
|
+
import { defaultCompilerOptions } from "../compile.js";
|
|
3
4
|
test("should emit per locale message files", () => {
|
|
4
5
|
const bundles = [
|
|
5
6
|
{
|
|
@@ -29,7 +30,7 @@ test("should emit per locale message files", () => {
|
|
|
29
30
|
en: "de",
|
|
30
31
|
de: "en",
|
|
31
32
|
};
|
|
32
|
-
const output = generateLocaleModules(bundles, settings, fallbackMap);
|
|
33
|
+
const output = generateLocaleModules(bundles, settings, fallbackMap, defaultCompilerOptions);
|
|
33
34
|
expect(output).toHaveProperty("messages.js");
|
|
34
35
|
expect(output).toHaveProperty("messages/en.js");
|
|
35
36
|
expect(output).toHaveProperty("messages/de.js");
|
|
@@ -55,7 +56,7 @@ test("the files should include files for each locale, even if there are no messa
|
|
|
55
56
|
en: "de",
|
|
56
57
|
de: "en",
|
|
57
58
|
};
|
|
58
|
-
const output = generateLocaleModules(bundles, settings, fallbackMap);
|
|
59
|
+
const output = generateLocaleModules(bundles, settings, fallbackMap, defaultCompilerOptions);
|
|
59
60
|
expect(output).toHaveProperty("messages.js");
|
|
60
61
|
expect(output).toHaveProperty("messages/en.js");
|
|
61
62
|
expect(output).toHaveProperty("messages/de.js");
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import type { ProjectSettings } from "@inlang/sdk";
|
|
2
2
|
import type { CompiledBundleWithMessages } from "../compile-bundle.js";
|
|
3
|
-
|
|
3
|
+
import type { CompilerOptions } from "../compile.js";
|
|
4
|
+
export declare function generateMessageModules(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>;
|
|
4
8
|
//# sourceMappingURL=message-modules.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-modules.d.ts","sourceRoot":"","sources":["../../../src/compiler/output-structure/message-modules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"message-modules.d.ts","sourceRoot":"","sources":["../../../src/compiler/output-structure/message-modules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAKvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD,wBAAgB,sBAAsB,CACrC,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,CAkExB"}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createRuntimeFile } from "../runtime/create-runtime.js";
|
|
2
2
|
import { createRegistry } from "../registry.js";
|
|
3
3
|
import { jsIdentifier } from "../../services/codegen/identifier.js";
|
|
4
4
|
import { escapeForSingleQuoteString } from "../../services/codegen/escape.js";
|
|
5
|
-
export function generateMessageModules(compiledBundles, settings, fallbackMap) {
|
|
5
|
+
export function generateMessageModules(compiledBundles, settings, fallbackMap, compilerOptions) {
|
|
6
6
|
const output = {
|
|
7
|
-
["runtime.js"]:
|
|
7
|
+
["runtime.js"]: createRuntimeFile({
|
|
8
|
+
baseLocale: settings.baseLocale,
|
|
9
|
+
locales: settings.locales,
|
|
10
|
+
compilerOptions,
|
|
11
|
+
}),
|
|
8
12
|
["registry.js"]: createRegistry(),
|
|
9
13
|
};
|
|
10
14
|
// messages index file
|
|
@@ -15,7 +19,6 @@ export function generateMessageModules(compiledBundles, settings, fallbackMap) {
|
|
|
15
19
|
for (const compiledBundle of compiledBundles) {
|
|
16
20
|
const filename = `messages/${compiledBundle.bundle.node.id}/index.js`;
|
|
17
21
|
const code = [
|
|
18
|
-
`import * as registry from '../../registry.js'`,
|
|
19
22
|
settings.locales
|
|
20
23
|
.map((locale) => `import * as ${jsIdentifier(locale)} from "./${locale}.js"`)
|
|
21
24
|
.join("\n"),
|
|
@@ -27,7 +30,7 @@ export function generateMessageModules(compiledBundles, settings, fallbackMap) {
|
|
|
27
30
|
}
|
|
28
31
|
for (const locale of settings.locales) {
|
|
29
32
|
for (const compiledBundle of compiledBundles) {
|
|
30
|
-
let file =
|
|
33
|
+
let file = "";
|
|
31
34
|
const compiledMessage = compiledBundle.messages[locale];
|
|
32
35
|
const id = jsIdentifier(compiledBundle.bundle.node.id);
|
|
33
36
|
if (!compiledMessage) {
|
|
@@ -45,6 +48,11 @@ export function generateMessageModules(compiledBundles, settings, fallbackMap) {
|
|
|
45
48
|
else {
|
|
46
49
|
file += `\n${compiledMessage.code}`;
|
|
47
50
|
}
|
|
51
|
+
// Add the registry import to the message file
|
|
52
|
+
// if registry is used
|
|
53
|
+
if (file.includes("registry.")) {
|
|
54
|
+
file = `import { registry } from '../../registry.js'\n` + file;
|
|
55
|
+
}
|
|
48
56
|
output[`messages/${compiledBundle.bundle.node.id}/${locale}.js`] = file;
|
|
49
57
|
}
|
|
50
58
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { test, expect } from "vitest";
|
|
2
2
|
import { generateMessageModules } from "./message-modules.js";
|
|
3
|
+
import { defaultCompilerOptions } from "../compile.js";
|
|
3
4
|
test("should emit per locale message files", () => {
|
|
4
5
|
const resources = [
|
|
5
6
|
{
|
|
@@ -29,7 +30,7 @@ test("should emit per locale message files", () => {
|
|
|
29
30
|
en: "de",
|
|
30
31
|
de: "en",
|
|
31
32
|
};
|
|
32
|
-
const output = generateMessageModules(resources, settings, fallbackMap);
|
|
33
|
+
const output = generateMessageModules(resources, settings, fallbackMap, defaultCompilerOptions);
|
|
33
34
|
expect(output).not.toHaveProperty("messages/en.js");
|
|
34
35
|
expect(output).not.toHaveProperty("messages/de.js");
|
|
35
36
|
expect(output).toHaveProperty("messages/happy_elephant/en.js");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assert-is-locale.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/assert-is-locale.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"assert-is-locale.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/assert-is-locale.js"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,sCAJW,GAAG,GACD,MAAM,CAUlB"}
|
|
@@ -1,18 +1,25 @@
|
|
|
1
|
-
import { assertIsLocale } from "./assert-is-locale.js";
|
|
2
1
|
import { test, expect } from "vitest";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import { createRuntimeForTesting } from "./create-runtime.js";
|
|
3
|
+
test("throws if the locale is not available", async () => {
|
|
4
|
+
const runtime = await createRuntimeForTesting({
|
|
5
|
+
baseLocale: "en",
|
|
6
|
+
locales: ["en", "de"],
|
|
7
|
+
});
|
|
8
|
+
expect(() => runtime.assertIsLocale("es")).toThrow();
|
|
7
9
|
});
|
|
8
|
-
test("
|
|
9
|
-
|
|
10
|
+
test("passes if the locale is available", async () => {
|
|
11
|
+
const runtime = await createRuntimeForTesting({
|
|
12
|
+
baseLocale: "en",
|
|
13
|
+
locales: ["en", "de"],
|
|
14
|
+
});
|
|
15
|
+
expect(() => runtime.assertIsLocale("en")).not.toThrow();
|
|
10
16
|
});
|
|
11
|
-
test("
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
test("the return value is a Locale", async () => {
|
|
18
|
+
const runtime = await createRuntimeForTesting({
|
|
19
|
+
baseLocale: "en",
|
|
20
|
+
locales: ["en", "de"],
|
|
21
|
+
});
|
|
22
|
+
const locale = runtime.assertIsLocale("en");
|
|
16
23
|
// a bit of a wacky test given that locale is `any`
|
|
17
24
|
// in the ambient type definition
|
|
18
25
|
locale;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-locale.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/base-locale.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,yBAA0B,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cookie-name.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/cookie-name.js"],"names":[],"mappings":"AAAA,qBAAqB;AACrB,yBADW,MAAM,CACyB"}
|
|
@@ -1,6 +1,31 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type CompilerOptions } from "../compile.js";
|
|
2
|
+
import type { Runtime } from "./type.js";
|
|
2
3
|
/**
|
|
3
4
|
* Returns the code for the `runtime.js` module
|
|
4
5
|
*/
|
|
5
|
-
export declare function
|
|
6
|
+
export declare function createRuntimeFile(args: {
|
|
7
|
+
baseLocale: string;
|
|
8
|
+
locales: string[];
|
|
9
|
+
compilerOptions: {
|
|
10
|
+
strategy: NonNullable<CompilerOptions["strategy"]>;
|
|
11
|
+
cookieName: NonNullable<CompilerOptions["cookieName"]>;
|
|
12
|
+
};
|
|
13
|
+
}): string;
|
|
14
|
+
/**
|
|
15
|
+
* Returns the runtime module as an object for testing purposes.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* const runtime = await createRuntime({
|
|
19
|
+
* baseLocale: "en",
|
|
20
|
+
* locales: ["en", "de"],
|
|
21
|
+
* })
|
|
22
|
+
*/
|
|
23
|
+
export declare function createRuntimeForTesting(args: {
|
|
24
|
+
baseLocale: string;
|
|
25
|
+
locales: string[];
|
|
26
|
+
compilerOptions?: {
|
|
27
|
+
strategy?: CompilerOptions["strategy"];
|
|
28
|
+
cookieName?: CompilerOptions["cookieName"];
|
|
29
|
+
};
|
|
30
|
+
}): Promise<Runtime>;
|
|
6
31
|
//# sourceMappingURL=create-runtime.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-runtime.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/create-runtime.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-runtime.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/create-runtime.ts"],"names":[],"mappings":"AACA,OAAO,EAA0B,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAC7E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,eAAe,EAAE;QAChB,QAAQ,EAAE,WAAW,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,CAAC;QACnD,UAAU,EAAE,WAAW,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC,CAAC;KACvD,CAAC;CACF,GAAG,MAAM,CA+ET;AAgBD;;;;;;;;GAQG;AACH,wBAAsB,uBAAuB,CAAC,IAAI,EAAE;IACnD,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,eAAe,CAAC,EAAE;QACjB,QAAQ,CAAC,EAAE,eAAe,CAAC,UAAU,CAAC,CAAC;QACvC,UAAU,CAAC,EAAE,eAAe,CAAC,YAAY,CAAC,CAAC;KAC3C,CAAC;CACF,GAAG,OAAO,CAAC,OAAO,CAAC,CAcnB"}
|
|
@@ -1,11 +1,120 @@
|
|
|
1
|
-
import
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import { defaultCompilerOptions } from "../compile.js";
|
|
2
3
|
/**
|
|
3
4
|
* Returns the code for the `runtime.js` module
|
|
4
5
|
*/
|
|
5
|
-
export function
|
|
6
|
-
return
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
export function createRuntimeFile(args) {
|
|
7
|
+
return `
|
|
8
|
+
|
|
9
|
+
${injectCode("./base-locale.js").replace(`<base-locale>`, `${args.baseLocale}`)}
|
|
10
|
+
|
|
11
|
+
${injectCode("./locales.js").replace(`["<base-locale>"]`, `["${args.locales.join('", "')}"]`)}
|
|
12
|
+
|
|
13
|
+
${injectCode("./strategy.js").replace(`["variable"]`, `["${args.compilerOptions.strategy.join('", "')}"]`)}
|
|
14
|
+
|
|
15
|
+
${injectCode("./cookie-name.js").replace(`<cookie-name>`, `${args.compilerOptions.cookieName}`)}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Define the \`getLocale()\` function.
|
|
19
|
+
*
|
|
20
|
+
* Use this function to define how the locale is resolved. For example,
|
|
21
|
+
* you can resolve the locale from the browser's preferred language,
|
|
22
|
+
* a cookie, env variable, or a user's preference.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* defineGetLocale(() => {
|
|
26
|
+
* // resolve the locale from a cookie. fallback to the base locale.
|
|
27
|
+
* return Cookies.get('locale') ?? baseLocale
|
|
28
|
+
* }
|
|
29
|
+
*
|
|
30
|
+
* @param {() => Locale} fn
|
|
31
|
+
* @type {(fn: () => Locale) => void}
|
|
32
|
+
*/
|
|
33
|
+
export const defineGetLocale = (fn) => {
|
|
34
|
+
getLocale = fn;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Define the \`setLocale()\` function.
|
|
39
|
+
*
|
|
40
|
+
* Use this function to define how the locale is set. For example,
|
|
41
|
+
* modify a cookie, env variable, or a user's preference.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* defineSetLocale((newLocale) => {
|
|
45
|
+
* // set the locale in a cookie
|
|
46
|
+
* return Cookies.set('locale', newLocale)
|
|
47
|
+
* });
|
|
48
|
+
*
|
|
49
|
+
* @param {(newLocale: Locale) => void} fn
|
|
50
|
+
*/
|
|
51
|
+
export const defineSetLocale = (fn) => {
|
|
52
|
+
setLocale = fn;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
${injectCode("./get-locale.js")}
|
|
56
|
+
|
|
57
|
+
${injectCode("./set-locale.js")}
|
|
58
|
+
|
|
59
|
+
${injectCode("./is-locale.js")}
|
|
60
|
+
|
|
61
|
+
${injectCode("./assert-is-locale.js")}
|
|
62
|
+
|
|
63
|
+
${injectCode("./localize-path.js")}
|
|
64
|
+
|
|
65
|
+
${injectCode("./de-localize-path.js")}
|
|
66
|
+
|
|
67
|
+
${injectCode("./extract-locale-from-pathname.js")}
|
|
68
|
+
|
|
69
|
+
${injectCode("./extract-locale-from-request.js")}
|
|
70
|
+
|
|
71
|
+
${injectCode("./extract-locale-from-cookie.js")}
|
|
72
|
+
|
|
73
|
+
// ------ TYPES ------
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* A locale that is available in the project.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* setLocale(request.locale as Locale)
|
|
80
|
+
*
|
|
81
|
+
* @typedef {(typeof locales)[number]} Locale
|
|
82
|
+
*/
|
|
83
|
+
|
|
84
|
+
`;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Load a file from the current directory.
|
|
88
|
+
*
|
|
89
|
+
* Prunes the imports on top of the file as the runtime is
|
|
90
|
+
* self-contained.
|
|
91
|
+
*
|
|
92
|
+
* @param {string} path
|
|
93
|
+
* @returns {string}
|
|
94
|
+
*/
|
|
95
|
+
function injectCode(path) {
|
|
96
|
+
const code = fs.readFileSync(new URL(path, import.meta.url), "utf-8");
|
|
97
|
+
return code.replace(/import\s+.*?;?\n/g, "");
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Returns the runtime module as an object for testing purposes.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* const runtime = await createRuntime({
|
|
104
|
+
* baseLocale: "en",
|
|
105
|
+
* locales: ["en", "de"],
|
|
106
|
+
* })
|
|
107
|
+
*/
|
|
108
|
+
export async function createRuntimeForTesting(args) {
|
|
109
|
+
const file = createRuntimeFile({
|
|
110
|
+
baseLocale: args.baseLocale,
|
|
111
|
+
locales: args.locales,
|
|
112
|
+
compilerOptions: {
|
|
113
|
+
...defaultCompilerOptions,
|
|
114
|
+
strategy: ["variable"],
|
|
115
|
+
...args.compilerOptions,
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
return await import("data:text/javascript;base64," +
|
|
119
|
+
Buffer.from(file, "utf-8").toString("base64"));
|
|
11
120
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"de-localize-path.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/de-localize-path.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"de-localize-path.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/de-localize-path.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,qCAHW,MAAM,GACJ,MAAM,CAQlB"}
|