@inlang/paraglide-js 2.29.0 → 2.29.2
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-bundle.js +58 -12
- package/dist/compiler/compile-bundle.js.map +1 -1
- package/dist/compiler/compile-bundle.test.js +208 -26
- package/dist/compiler/compile-bundle.test.js.map +1 -1
- package/dist/compiler/compile-lifecycle.test.js +83 -0
- package/dist/compiler/compile-lifecycle.test.js.map +1 -1
- package/dist/compiler/compile-message.d.ts +9 -0
- package/dist/compiler/compile-message.js +29 -12
- package/dist/compiler/compile-message.js.map +1 -1
- package/dist/compiler/compile-project.js +6 -1
- package/dist/compiler/compile-project.js.map +1 -1
- package/dist/compiler/compile-project.test.js +157 -0
- package/dist/compiler/compile-project.test.js.map +1 -1
- package/dist/compiler/compile.js +12 -0
- package/dist/compiler/compile.js.map +1 -1
- package/dist/compiler/compiler-options.d.ts +5 -2
- package/dist/compiler/compiler-options.js.map +1 -1
- package/dist/compiler/emit-ts-declarations.d.ts +4 -1
- package/dist/compiler/emit-ts-declarations.js +18 -11
- package/dist/compiler/emit-ts-declarations.js.map +1 -1
- package/dist/compiler/emit-ts-declarations.native.test.d.ts +1 -0
- package/dist/compiler/emit-ts-declarations.native.test.js +86 -0
- package/dist/compiler/emit-ts-declarations.native.test.js.map +1 -0
- package/dist/compiler/emit-ts-declarations.test.js +3 -0
- package/dist/compiler/emit-ts-declarations.test.js.map +1 -1
- package/dist/compiler/resolve-tsc-js-path.d.ts +6 -0
- package/dist/compiler/resolve-tsc-js-path.js +34 -1
- package/dist/compiler/resolve-tsc-js-path.js.map +1 -1
- package/dist/compiler/resolve-tsc-js-path.test.d.ts +1 -0
- package/dist/compiler/resolve-tsc-js-path.test.js +31 -0
- package/dist/compiler/resolve-tsc-js-path.test.js.map +1 -0
- package/dist/services/env-variables/index.js +1 -1
- package/dist/services/env-variables/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
-
import { existsSync } from "node:fs";
|
|
2
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
4
5
|
/**
|
|
5
6
|
* Resolves the path to the `tsc` CLI entry point of the installed
|
|
6
7
|
* `typescript` package.
|
|
@@ -20,4 +21,36 @@ export function resolveTscJsPath() {
|
|
|
20
21
|
}
|
|
21
22
|
return tscJsPath;
|
|
22
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Resolves the `tsc` CLI of TypeScript 7+ installed beside TypeScript 5/6
|
|
26
|
+
* under the `@typescript/native` npm alias, as documented for
|
|
27
|
+
* `svelte-check --tsgo`, or returns `undefined` when there is none.
|
|
28
|
+
*/
|
|
29
|
+
export function resolveNativeTscJsPath() {
|
|
30
|
+
const require = createRequire(import.meta.url);
|
|
31
|
+
try {
|
|
32
|
+
// the working directory first, so that an app's alias is found in a
|
|
33
|
+
// workspace without hoisting
|
|
34
|
+
const packageJsonPath = require.resolve("@typescript/native/package.json", {
|
|
35
|
+
paths: [process.cwd(), path.dirname(fileURLToPath(import.meta.url))],
|
|
36
|
+
});
|
|
37
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
38
|
+
const version = typeof packageJson === "object" &&
|
|
39
|
+
packageJson !== null &&
|
|
40
|
+
"version" in packageJson
|
|
41
|
+
? packageJson.version
|
|
42
|
+
: undefined;
|
|
43
|
+
// the CLI of TypeScript 5/6 emits invalid quoted export aliases, which
|
|
44
|
+
// only the compiler-API path corrects
|
|
45
|
+
const isTypeScript7OrNewer = typeof version === "string" && Number.parseInt(version, 10) >= 7;
|
|
46
|
+
const tscJsPath = path.join(path.dirname(packageJsonPath), "lib", "tsc.js");
|
|
47
|
+
return isTypeScript7OrNewer && existsSync(tscJsPath)
|
|
48
|
+
? tscJsPath
|
|
49
|
+
: undefined;
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
// an alias that can't be read leaves the other emit paths in place
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
23
56
|
//# sourceMappingURL=resolve-tsc-js-path.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-tsc-js-path.js","sourceRoot":"","sources":["../../src/compiler/resolve-tsc-js-path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"resolve-tsc-js-path.js","sourceRoot":"","sources":["../../src/compiler/resolve-tsc-js-path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB;IAC/B,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/C,MAAM,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC;IACnE,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC5E,0EAA0E;IAC1E,qEAAqE;IACrE,IAAI,UAAU,CAAC,SAAS,CAAC,KAAK,KAAK,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CACd,sFAAsF,SAAS,gFAAgF,CAC/K,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,sBAAsB;IACrC,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/C,IAAI,CAAC;QACJ,oEAAoE;QACpE,6BAA6B;QAC7B,MAAM,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,iCAAiC,EAAE;YAC1E,KAAK,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;SACpE,CAAC,CAAC;QACH,MAAM,WAAW,GAAY,IAAI,CAAC,KAAK,CACtC,YAAY,CAAC,eAAe,EAAE,OAAO,CAAC,CACtC,CAAC;QACF,MAAM,OAAO,GACZ,OAAO,WAAW,KAAK,QAAQ;YAC/B,WAAW,KAAK,IAAI;YACpB,SAAS,IAAI,WAAW;YACvB,CAAC,CAAC,WAAW,CAAC,OAAO;YACrB,CAAC,CAAC,SAAS,CAAC;QACd,uEAAuE;QACvE,sCAAsC;QACtC,MAAM,oBAAoB,GACzB,OAAO,OAAO,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;QAClE,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;QAC5E,OAAO,oBAAoB,IAAI,UAAU,CAAC,SAAS,CAAC;YACnD,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,SAAS,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACR,mEAAmE;QACnE,OAAO,SAAS,CAAC;IAClB,CAAC;AACF,CAAC","sourcesContent":["import { createRequire } from \"node:module\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\n/**\n * Resolves the path to the `tsc` CLI entry point of the installed\n * `typescript` package.\n *\n * Lives in its own module so tests can point the TypeScript 7 emit\n * path at a different TypeScript installation than the one the repo\n * itself depends on.\n */\nexport function resolveTscJsPath(): string {\n\tconst require = createRequire(import.meta.url);\n\tconst packageJsonPath = require.resolve(\"typescript/package.json\");\n\tconst tscJsPath = path.join(path.dirname(packageJsonPath), \"lib\", \"tsc.js\");\n\t// `lib/tsc.js` is internal package layout rather than a public export, so\n\t// fail with a pointed error if a future TypeScript version moves it.\n\tif (existsSync(tscJsPath) === false) {\n\t\tthrow new Error(\n\t\t\t`Paraglide's \"emitTsDeclarations\" option could not locate TypeScript's \"tsc\" CLI at ${tscJsPath}. As a workaround, install TypeScript 5 or 6, or disable \"emitTsDeclarations\".`\n\t\t);\n\t}\n\treturn tscJsPath;\n}\n\n/**\n * Resolves the `tsc` CLI of TypeScript 7+ installed beside TypeScript 5/6\n * under the `@typescript/native` npm alias, as documented for\n * `svelte-check --tsgo`, or returns `undefined` when there is none.\n */\nexport function resolveNativeTscJsPath(): string | undefined {\n\tconst require = createRequire(import.meta.url);\n\ttry {\n\t\t// the working directory first, so that an app's alias is found in a\n\t\t// workspace without hoisting\n\t\tconst packageJsonPath = require.resolve(\"@typescript/native/package.json\", {\n\t\t\tpaths: [process.cwd(), path.dirname(fileURLToPath(import.meta.url))],\n\t\t});\n\t\tconst packageJson: unknown = JSON.parse(\n\t\t\treadFileSync(packageJsonPath, \"utf-8\")\n\t\t);\n\t\tconst version =\n\t\t\ttypeof packageJson === \"object\" &&\n\t\t\tpackageJson !== null &&\n\t\t\t\"version\" in packageJson\n\t\t\t\t? packageJson.version\n\t\t\t\t: undefined;\n\t\t// the CLI of TypeScript 5/6 emits invalid quoted export aliases, which\n\t\t// only the compiler-API path corrects\n\t\tconst isTypeScript7OrNewer =\n\t\t\ttypeof version === \"string\" && Number.parseInt(version, 10) >= 7;\n\t\tconst tscJsPath = path.join(path.dirname(packageJsonPath), \"lib\", \"tsc.js\");\n\t\treturn isTypeScript7OrNewer && existsSync(tscJsPath)\n\t\t\t? tscJsPath\n\t\t\t: undefined;\n\t} catch {\n\t\t// an alias that can't be read leaves the other emit paths in place\n\t\treturn undefined;\n\t}\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { expect, test, vi } from "vitest";
|
|
2
|
+
import fs from "node:fs/promises";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { resolveNativeTscJsPath } from "./resolve-tsc-js-path.js";
|
|
6
|
+
test("resolveNativeTscJsPath only accepts TypeScript 7+ under the @typescript/native alias", async () => {
|
|
7
|
+
const project = await fs.realpath(await fs.mkdtemp(path.join(os.tmpdir(), "paraglide-native-tsc-")));
|
|
8
|
+
const alias = path.join(project, "node_modules", "@typescript", "native");
|
|
9
|
+
const tscJsPath = path.join(alias, "lib", "tsc.js");
|
|
10
|
+
await fs.mkdir(path.dirname(tscJsPath), { recursive: true });
|
|
11
|
+
await fs.writeFile(tscJsPath, "");
|
|
12
|
+
vi.spyOn(process, "cwd").mockReturnValue(project);
|
|
13
|
+
try {
|
|
14
|
+
const cases = [
|
|
15
|
+
[{ name: "typescript", version: "7.0.2" }, tscJsPath],
|
|
16
|
+
// the CLI of TypeScript 5/6 would emit invalid quoted export aliases
|
|
17
|
+
[{ name: "typescript", version: "6.0.3" }, undefined],
|
|
18
|
+
[{ name: "typescript" }, undefined],
|
|
19
|
+
[null, undefined],
|
|
20
|
+
];
|
|
21
|
+
for (const [packageJson, expected] of cases) {
|
|
22
|
+
await fs.writeFile(path.join(alias, "package.json"), JSON.stringify(packageJson));
|
|
23
|
+
expect(resolveNativeTscJsPath()).toBe(expected);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
finally {
|
|
27
|
+
vi.restoreAllMocks();
|
|
28
|
+
await fs.rm(project, { recursive: true, force: true });
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=resolve-tsc-js-path.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
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AE,EAAE,SAAS,CAAC;YACrD,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,SAAS,CAAC;YACnC,CAAC,IAAI,EAAE,SAAS,CAAC;SACjB,CAAC;QACF,KAAK,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,IAAI,KAAK,EAAE,CAAC;YAC7C,MAAM,EAAE,CAAC,SAAS,CACjB,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,cAAc,CAAC,EAChC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAC3B,CAAC;YACF,MAAM,CAAC,sBAAsB,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACjD,CAAC;IACF,CAAC;YAAS,CAAC;QACV,EAAE,CAAC,eAAe,EAAE,CAAC;QACrB,MAAM,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACxD,CAAC;AACF,CAAC,CAAC,CAAC","sourcesContent":["import { expect, test, vi } from \"vitest\";\nimport fs from \"node:fs/promises\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport { resolveNativeTscJsPath } from \"./resolve-tsc-js-path.js\";\n\ntest(\"resolveNativeTscJsPath only accepts TypeScript 7+ under the @typescript/native alias\", async () => {\n\tconst project = await fs.realpath(\n\t\tawait fs.mkdtemp(path.join(os.tmpdir(), \"paraglide-native-tsc-\"))\n\t);\n\tconst alias = path.join(project, \"node_modules\", \"@typescript\", \"native\");\n\tconst tscJsPath = path.join(alias, \"lib\", \"tsc.js\");\n\tawait fs.mkdir(path.dirname(tscJsPath), { recursive: true });\n\tawait fs.writeFile(tscJsPath, \"\");\n\tvi.spyOn(process, \"cwd\").mockReturnValue(project);\n\n\ttry {\n\t\tconst cases: Array<[packageJson: unknown, expected: string | undefined]> = [\n\t\t\t[{ name: \"typescript\", version: \"7.0.2\" }, tscJsPath],\n\t\t\t// the CLI of TypeScript 5/6 would emit invalid quoted export aliases\n\t\t\t[{ name: \"typescript\", version: \"6.0.3\" }, undefined],\n\t\t\t[{ name: \"typescript\" }, undefined],\n\t\t\t[null, undefined],\n\t\t];\n\t\tfor (const [packageJson, expected] of cases) {\n\t\t\tawait fs.writeFile(\n\t\t\t\tpath.join(alias, \"package.json\"),\n\t\t\t\tJSON.stringify(packageJson)\n\t\t\t);\n\t\t\texpect(resolveNativeTscJsPath()).toBe(expected);\n\t\t}\n\t} finally {\n\t\tvi.restoreAllMocks();\n\t\tawait fs.rm(project, { recursive: true, force: true });\n\t}\n});\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/env-variables/index.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,aAAa,GAAG;IAC5B,qBAAqB,EAAE,QAAQ;CAC/B,CAAA","sourcesContent":["\nexport const ENV_VARIABLES = {\n\tPARJS_PACKAGE_VERSION: \"2.29.
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/env-variables/index.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,aAAa,GAAG;IAC5B,qBAAqB,EAAE,QAAQ;CAC/B,CAAA","sourcesContent":["\nexport const ENV_VARIABLES = {\n\tPARJS_PACKAGE_VERSION: \"2.29.2\",\n}\n"]}
|