@inlang/paraglide-js 2.2.0 → 2.3.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.
- package/dist/bundler-plugins/rspack.d.ts +1 -1
- package/dist/bundler-plugins/rspack.d.ts.map +1 -1
- package/dist/bundler-plugins/unplugin.d.ts.map +1 -1
- package/dist/bundler-plugins/unplugin.js +4 -0
- package/dist/bundler-plugins/unplugin.test.d.ts +2 -0
- package/dist/bundler-plugins/unplugin.test.d.ts.map +1 -0
- package/dist/bundler-plugins/unplugin.test.js +75 -0
- package/dist/compiler/compile.d.ts.map +1 -1
- package/dist/compiler/compile.js +15 -10
- package/dist/compiler/compile.test.js +2 -2
- package/dist/services/env-variables/index.d.ts +1 -1
- package/dist/services/env-variables/index.js +2 -2
- package/package.json +6 -7
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const paraglideRspackPlugin: (options: import("../index.js").CompilerOptions) => RspackPluginInstance;
|
|
1
|
+
export declare const paraglideRspackPlugin: (options: import("../index.js").CompilerOptions) => import("unplugin").RspackPluginInstance;
|
|
2
2
|
//# sourceMappingURL=rspack.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rspack.d.ts","sourceRoot":"","sources":["../../src/bundler-plugins/rspack.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,qBAAqB,
|
|
1
|
+
{"version":3,"file":"rspack.d.ts","sourceRoot":"","sources":["../../src/bundler-plugins/rspack.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,qBAAqB,6FAAsC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unplugin.d.ts","sourceRoot":"","sources":["../../src/bundler-plugins/unplugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAMhD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAavE,eAAO,MAAM,eAAe,EAAE,eAAe,CAAC,eAAe,
|
|
1
|
+
{"version":3,"file":"unplugin.d.ts","sourceRoot":"","sources":["../../src/bundler-plugins/unplugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAMhD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAavE,eAAO,MAAM,eAAe,EAAE,eAAe,CAAC,eAAe,CA2H3D,CAAC"}
|
|
@@ -36,6 +36,8 @@ export const unpluginFactory = (args) => ({
|
|
|
36
36
|
catch (error) {
|
|
37
37
|
logger.error("Failed to compile project:", error.message);
|
|
38
38
|
logger.info("Please check your translation files for syntax errors.");
|
|
39
|
+
if (isProduction)
|
|
40
|
+
throw error;
|
|
39
41
|
}
|
|
40
42
|
finally {
|
|
41
43
|
// in any case add the files to watch
|
|
@@ -118,6 +120,8 @@ export const unpluginFactory = (args) => ({
|
|
|
118
120
|
catch (error) {
|
|
119
121
|
logger.warn("Failed to compile project:", error.message);
|
|
120
122
|
logger.warn("Please check your translation files for syntax errors.");
|
|
123
|
+
if (isProduction)
|
|
124
|
+
throw error;
|
|
121
125
|
}
|
|
122
126
|
});
|
|
123
127
|
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unplugin.test.d.ts","sourceRoot":"","sources":["../../src/bundler-plugins/unplugin.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { test, expect, beforeEach, afterEach, vi } from "vitest";
|
|
2
|
+
import { paraglideVitePlugin } from "../bundler-plugins/vite.js";
|
|
3
|
+
import consola from "consola";
|
|
4
|
+
import { memfs } from "memfs";
|
|
5
|
+
import { loadProjectInMemory, newProject, saveProjectToDirectory, } from "@inlang/sdk";
|
|
6
|
+
let originalNodeEnv;
|
|
7
|
+
beforeEach(() => {
|
|
8
|
+
originalNodeEnv = process.env.NODE_ENV;
|
|
9
|
+
// Mock logging methods to suppress error messages in tests
|
|
10
|
+
consola.mockTypes(() => vi.fn());
|
|
11
|
+
});
|
|
12
|
+
afterEach(() => {
|
|
13
|
+
if (originalNodeEnv !== undefined) {
|
|
14
|
+
process.env.NODE_ENV = originalNodeEnv;
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
delete process.env.NODE_ENV;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
test("vite plugin does not throw when compilation is successful", async () => {
|
|
21
|
+
// Create and save a viable project to the virtual file system
|
|
22
|
+
const project = await loadProjectInMemory({
|
|
23
|
+
blob: await newProject({
|
|
24
|
+
settings: {
|
|
25
|
+
baseLocale: "en",
|
|
26
|
+
locales: ["en", "de", "fr"],
|
|
27
|
+
},
|
|
28
|
+
}),
|
|
29
|
+
});
|
|
30
|
+
const fs = memfs().fs;
|
|
31
|
+
await saveProjectToDirectory({
|
|
32
|
+
project,
|
|
33
|
+
path: "/project.inlang",
|
|
34
|
+
fs: fs.promises,
|
|
35
|
+
});
|
|
36
|
+
const plugin = paraglideVitePlugin({
|
|
37
|
+
project: "/project.inlang",
|
|
38
|
+
outdir: "/test-output",
|
|
39
|
+
fs: fs,
|
|
40
|
+
});
|
|
41
|
+
const mockContext = {
|
|
42
|
+
addWatchFile: () => { },
|
|
43
|
+
};
|
|
44
|
+
await expect(plugin.buildStart?.call(mockContext)).resolves.toBeUndefined();
|
|
45
|
+
});
|
|
46
|
+
test("vite plugin does not throw on compilation errors in development", async () => {
|
|
47
|
+
process.env.NODE_ENV = "development";
|
|
48
|
+
// Use memfs with no project (simulates missing project)
|
|
49
|
+
const fs = memfs().fs;
|
|
50
|
+
const plugin = paraglideVitePlugin({
|
|
51
|
+
project: "/non-existent-project.inlang",
|
|
52
|
+
outdir: "/test-output",
|
|
53
|
+
fs: fs,
|
|
54
|
+
});
|
|
55
|
+
const mockContext = {
|
|
56
|
+
addWatchFile: () => { },
|
|
57
|
+
};
|
|
58
|
+
// In development mode - should catch errors and NOT throw
|
|
59
|
+
await expect(plugin.buildStart?.call(mockContext)).resolves.toBeUndefined();
|
|
60
|
+
});
|
|
61
|
+
test("vite plugin throws on compilation errors at build time", async () => {
|
|
62
|
+
process.env.NODE_ENV = "production";
|
|
63
|
+
// Use memfs with no project (simulates missing project)
|
|
64
|
+
const fs = memfs().fs;
|
|
65
|
+
const plugin = paraglideVitePlugin({
|
|
66
|
+
project: "/non-existent-project.inlang",
|
|
67
|
+
outdir: "/test-output",
|
|
68
|
+
fs: fs,
|
|
69
|
+
});
|
|
70
|
+
const mockContext = {
|
|
71
|
+
addWatchFile: () => { },
|
|
72
|
+
};
|
|
73
|
+
// In production mode - should throw the error
|
|
74
|
+
await expect(plugin.buildStart?.call(mockContext)).rejects.toThrow();
|
|
75
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../src/compiler/compile.ts"],"names":[],"mappings":"AASA,OAAO,EAEN,KAAK,eAAe,EACpB,MAAM,uBAAuB,CAAC;AAS/B,MAAM,MAAM,iBAAiB,GAAG;IAC/B,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;CACjD,CAAC;AAIF;;;;;;;;;;;;GAYG;AACH,wBAAsB,OAAO,CAC5B,OAAO,EAAE,eAAe,GAAG;IAC1B,mBAAmB,CAAC,EAAE,iBAAiB,CAAC;CACxC,GACC,OAAO,CAAC,iBAAiB,CAAC,
|
|
1
|
+
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../src/compiler/compile.ts"],"names":[],"mappings":"AASA,OAAO,EAEN,KAAK,eAAe,EACpB,MAAM,uBAAuB,CAAC;AAS/B,MAAM,MAAM,iBAAiB,GAAG;IAC/B,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;CACjD,CAAC;AAIF;;;;;;;;;;;;GAYG;AACH,wBAAsB,OAAO,CAC5B,OAAO,EAAE,eAAe,GAAG;IAC1B,mBAAmB,CAAC,EAAE,iBAAiB,CAAC;CACxC,GACC,OAAO,CAAC,iBAAiB,CAAC,CAuE5B"}
|
package/dist/compiler/compile.js
CHANGED
|
@@ -3,7 +3,10 @@ import path from "node:path";
|
|
|
3
3
|
import { ENV_VARIABLES } from "../services/env-variables/index.js";
|
|
4
4
|
import { compileProject } from "./compile-project.js";
|
|
5
5
|
import { writeOutput } from "../services/file-handling/write-output.js";
|
|
6
|
-
import {
|
|
6
|
+
// import {
|
|
7
|
+
// getLocalAccount,
|
|
8
|
+
// saveLocalAccount,
|
|
9
|
+
// } from "../services/account/index.js";
|
|
7
10
|
import { defaultCompilerOptions, } from "./compiler-options.js";
|
|
8
11
|
import { Logger } from "../services/logger/index.js";
|
|
9
12
|
// This is a workaround to prevent multiple compilations from running at the same time.
|
|
@@ -35,11 +38,11 @@ export async function compile(options) {
|
|
|
35
38
|
try {
|
|
36
39
|
const fs = withDefaultOptions.fs ?? (await import("node:fs"));
|
|
37
40
|
const absoluteOutdir = path.resolve(process.cwd(), withDefaultOptions.outdir);
|
|
38
|
-
const localAccount = getLocalAccount({ fs });
|
|
41
|
+
// const localAccount = getLocalAccount({ fs });
|
|
39
42
|
const project = await loadProjectFromDirectory({
|
|
40
43
|
path: withDefaultOptions.project,
|
|
41
44
|
fs,
|
|
42
|
-
account: localAccount,
|
|
45
|
+
// account: localAccount,
|
|
43
46
|
appId: ENV_VARIABLES.PARJS_APP_ID,
|
|
44
47
|
});
|
|
45
48
|
const output = await compileProject({
|
|
@@ -53,13 +56,15 @@ export async function compile(options) {
|
|
|
53
56
|
fs: fs.promises,
|
|
54
57
|
previousOutputHashes: options.previousCompilation?.outputHashes,
|
|
55
58
|
});
|
|
56
|
-
if (!localAccount) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
// if (!localAccount) {
|
|
60
|
+
// const activeAccount = await project.lix.db
|
|
61
|
+
// .selectFrom("active_account as aa")
|
|
62
|
+
// .innerJoin("account_all as a", "a.id", "aa.account_id")
|
|
63
|
+
// .where("a.lixcol_version_id", "=", "global")
|
|
64
|
+
// .select(["a.id", "a.name"])
|
|
65
|
+
// .executeTakeFirstOrThrow();
|
|
66
|
+
// saveLocalAccount({ fs, account: activeAccount });
|
|
67
|
+
// }
|
|
63
68
|
const warningsAndErrors = await project.errors.get();
|
|
64
69
|
for (const warningOrError of warningsAndErrors) {
|
|
65
70
|
logger.warn(warningOrError);
|
|
@@ -30,7 +30,7 @@ test("loads a project and compiles it", async () => {
|
|
|
30
30
|
//runtime.js and messages.js are always compiled with the default options
|
|
31
31
|
expect(files).toEqual(expect.arrayContaining(["runtime.js", "server.js", "messages.js"]));
|
|
32
32
|
});
|
|
33
|
-
test("loads a local account from app data if exists", async () => {
|
|
33
|
+
test.skip("loads a local account from app data if exists", async () => {
|
|
34
34
|
const accountPath = getAccountFilePath();
|
|
35
35
|
const fs = memfs({
|
|
36
36
|
[accountPath]: JSON.stringify({ id: "mock", name: "test" }),
|
|
@@ -56,7 +56,7 @@ test("loads a local account from app data if exists", async () => {
|
|
|
56
56
|
});
|
|
57
57
|
expect(spy).toHaveBeenCalledWith(accountPath, "utf8");
|
|
58
58
|
});
|
|
59
|
-
test("saves the local account to app data if not exists", async () => {
|
|
59
|
+
test.skip("saves the local account to app data if not exists", async () => {
|
|
60
60
|
const accountPath = getAccountFilePath();
|
|
61
61
|
const fs = memfs().fs;
|
|
62
62
|
const project = await loadProjectInMemory({
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inlang/paraglide-js",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.3.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public",
|
|
@@ -26,13 +26,13 @@
|
|
|
26
26
|
"./urlpattern-polyfill": "./dist/urlpattern-polyfill/index.js"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
+
"@inlang/sdk": "2.4.9",
|
|
29
30
|
"commander": "11.1.0",
|
|
30
31
|
"consola": "3.4.0",
|
|
31
32
|
"json5": "2.2.3",
|
|
32
33
|
"unplugin": "^2.1.2",
|
|
33
34
|
"urlpattern-polyfill": "^10.0.0",
|
|
34
|
-
"@inlang/recommend-sherlock": "0.2.1"
|
|
35
|
-
"@inlang/sdk": "2.4.9"
|
|
35
|
+
"@inlang/recommend-sherlock": "0.2.1"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@eslint/js": "^9.18.0",
|
|
@@ -44,14 +44,13 @@
|
|
|
44
44
|
"memfs": "4.17.0",
|
|
45
45
|
"prettier": "^3.4.2",
|
|
46
46
|
"rolldown": "1.0.0-beta.1",
|
|
47
|
-
"typedoc": "
|
|
48
|
-
"typedoc-plugin-markdown": "
|
|
47
|
+
"typedoc": "0.28.12",
|
|
48
|
+
"typedoc-plugin-markdown": "4.7.0",
|
|
49
49
|
"typedoc-plugin-missing-exports": "4.0.0",
|
|
50
|
-
"typescript": "
|
|
50
|
+
"typescript": "5.8.3",
|
|
51
51
|
"typescript-eslint": "^8.20.0",
|
|
52
52
|
"vitest": "2.1.8",
|
|
53
53
|
"@inlang/plugin-message-format": "4.0.0",
|
|
54
|
-
"@inlang/paraglide-js": "2.2.0",
|
|
55
54
|
"@opral/tsconfig": "1.1.0"
|
|
56
55
|
},
|
|
57
56
|
"keywords": [
|