@inlang/paraglide-js 2.6.0 → 2.7.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/webpack.d.ts +1 -1
- package/dist/bundler-plugins/webpack.d.ts.map +1 -1
- package/dist/cli/commands/compile/command.d.ts.map +1 -1
- package/dist/cli/commands/compile/command.js +3 -0
- package/dist/compiler/compile-project.d.ts.map +1 -1
- package/dist/compiler/compile-project.js +5 -0
- package/dist/compiler/compile-project.test.js +12 -0
- package/dist/compiler/compiler-options.d.ts +24 -0
- package/dist/compiler/compiler-options.d.ts.map +1 -1
- package/dist/compiler/compiler-options.js +1 -0
- package/dist/compiler/emit-ts-declarations.d.ts.map +1 -1
- package/dist/compiler/emit-ts-declarations.js +1 -0
- package/dist/compiler/output-file.d.ts +6 -0
- package/dist/compiler/output-file.d.ts.map +1 -0
- package/dist/compiler/output-file.js +1 -0
- package/dist/services/env-variables/index.js +1 -1
- package/package.json +5 -5
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const paraglideWebpackPlugin: (options: import("../index.js").CompilerOptions) => WebpackPluginInstance;
|
|
1
|
+
export declare const paraglideWebpackPlugin: (options: import("../index.js").CompilerOptions) => import("unplugin").WebpackPluginInstance;
|
|
2
2
|
//# sourceMappingURL=webpack.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webpack.d.ts","sourceRoot":"","sources":["../../src/bundler-plugins/webpack.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,sBAAsB,
|
|
1
|
+
{"version":3,"file":"webpack.d.ts","sourceRoot":"","sources":["../../src/bundler-plugins/webpack.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,sBAAsB,8FAAuC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/compile/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAUpC,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/compile/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAUpC,eAAO,MAAM,cAAc,SA4DzB,CAAC"}
|
|
@@ -16,6 +16,7 @@ export const compileCommand = new Command()
|
|
|
16
16
|
"Read more on https://inlang.com/m/gerre34r/library-inlang-paraglideJs/strategy",
|
|
17
17
|
].join("\n"))
|
|
18
18
|
.requiredOption("--silent", "Only log errors to the console", false)
|
|
19
|
+
.option("--emit-ts-declarations", "Emit .d.ts files for the generated output (requires the typescript package)", defaultCompilerOptions.emitTsDeclarations)
|
|
19
20
|
.action(async (options) => {
|
|
20
21
|
const logger = new Logger({ silent: options.silent, prefix: true });
|
|
21
22
|
const path = resolve(process.cwd(), options.project);
|
|
@@ -25,6 +26,8 @@ export const compileCommand = new Command()
|
|
|
25
26
|
project: path,
|
|
26
27
|
outdir: options.outdir,
|
|
27
28
|
strategy: options.strategy ?? defaultCompilerOptions.strategy,
|
|
29
|
+
emitTsDeclarations: options.emitTsDeclarations ??
|
|
30
|
+
defaultCompilerOptions.emitTsDeclarations,
|
|
28
31
|
});
|
|
29
32
|
}
|
|
30
33
|
catch (e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile-project.d.ts","sourceRoot":"","sources":["../../src/compiler/compile-project.ts"],"names":[],"mappings":"AACA,OAAO,EAAsB,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAIrE,OAAO,EAEN,KAAK,eAAe,EACpB,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"compile-project.d.ts","sourceRoot":"","sources":["../../src/compiler/compile-project.ts"],"names":[],"mappings":"AACA,OAAO,EAAsB,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAIrE,OAAO,EAEN,KAAK,eAAe,EACpB,MAAM,uBAAuB,CAAC;AAW/B;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,GAAU,MAAM;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,CA4EjC,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"}
|
|
@@ -7,6 +7,7 @@ import { defaultCompilerOptions, } from "./compiler-options.js";
|
|
|
7
7
|
import { createRuntimeFile } from "./runtime/create-runtime.js";
|
|
8
8
|
import { createServerFile } from "./server/create-server-file.js";
|
|
9
9
|
import { createRegistry } from "./registry.js";
|
|
10
|
+
import { emitTsDeclarations } from "./emit-ts-declarations.js";
|
|
10
11
|
const outputStructures = {
|
|
11
12
|
"locale-modules": localeModules,
|
|
12
13
|
"message-modules": messageModules,
|
|
@@ -73,6 +74,10 @@ export const compileProject = async (args) => {
|
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
76
|
}
|
|
77
|
+
if (optionsWithDefaults.emitTsDeclarations) {
|
|
78
|
+
const declarations = await emitTsDeclarations(output);
|
|
79
|
+
Object.assign(output, declarations);
|
|
80
|
+
}
|
|
76
81
|
return output;
|
|
77
82
|
};
|
|
78
83
|
export function getFallbackMap(locales, baseLocale) {
|
|
@@ -61,6 +61,18 @@ test("emitPrettierIgnore", async () => {
|
|
|
61
61
|
expect(_true).toHaveProperty(".prettierignore");
|
|
62
62
|
expect(_false).not.toHaveProperty(".prettierignore");
|
|
63
63
|
});
|
|
64
|
+
test("emitTsDeclarations generates declaration files", async () => {
|
|
65
|
+
const output = await compileProject({
|
|
66
|
+
project,
|
|
67
|
+
compilerOptions: {
|
|
68
|
+
emitTsDeclarations: true,
|
|
69
|
+
outputStructure: "locale-modules",
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
expect(output).toHaveProperty("messages/_index.d.ts");
|
|
73
|
+
expect(output).toHaveProperty("messages.d.ts");
|
|
74
|
+
expect(output["messages/_index.d.ts"]).toContain("sad_penguin_bundle");
|
|
75
|
+
});
|
|
64
76
|
test("handles message bundles with a : in the id", async () => {
|
|
65
77
|
const project = await loadProjectInMemory({
|
|
66
78
|
blob: await newProject({
|
|
@@ -4,6 +4,7 @@ export declare const defaultCompilerOptions: {
|
|
|
4
4
|
readonly emitGitIgnore: true;
|
|
5
5
|
readonly includeEslintDisableComment: true;
|
|
6
6
|
readonly emitPrettierIgnore: true;
|
|
7
|
+
readonly emitTsDeclarations: false;
|
|
7
8
|
readonly cleanOutdir: true;
|
|
8
9
|
readonly disableAsyncLocalStorage: false;
|
|
9
10
|
readonly experimentalMiddlewareLocaleSplitting: false;
|
|
@@ -164,6 +165,29 @@ export type CompilerOptions = {
|
|
|
164
165
|
* @default true
|
|
165
166
|
*/
|
|
166
167
|
emitPrettierIgnore?: boolean;
|
|
168
|
+
/**
|
|
169
|
+
* Emit `.d.ts` files for the generated output using the TypeScript compiler.
|
|
170
|
+
*
|
|
171
|
+
* Useful when `allowJs: true` cannot be set in your `tsconfig.json`
|
|
172
|
+
* (e.g., due to project constraints or conflicting compiler options).
|
|
173
|
+
*
|
|
174
|
+
* Requires `typescript` to be resolvable in your toolchain.
|
|
175
|
+
*
|
|
176
|
+
* **Note:** Enabling this option reduces compiler speed because TypeScript
|
|
177
|
+
* needs to generate declaration files for all output modules.
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* ```ts
|
|
181
|
+
* await compile({
|
|
182
|
+
* project: "./project.inlang",
|
|
183
|
+
* outdir: "./src/paraglide",
|
|
184
|
+
* emitTsDeclarations: true,
|
|
185
|
+
* });
|
|
186
|
+
* ```
|
|
187
|
+
*
|
|
188
|
+
* @default false
|
|
189
|
+
*/
|
|
190
|
+
emitTsDeclarations?: boolean;
|
|
167
191
|
/**
|
|
168
192
|
* https://inlang.com/m/gerre34r/library-inlang-paraglideJs/strategy#url
|
|
169
193
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compiler-options.d.ts","sourceRoot":"","sources":["../../src/compiler/compiler-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEjD,eAAO,MAAM,sBAAsB
|
|
1
|
+
{"version":3,"file":"compiler-options.d.ts","sourceRoot":"","sources":["../../src/compiler/compiler-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEjD,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;CAeU,CAAC;AAE9C,MAAM,MAAM,eAAe,GAAG;IAC7B;;;;;;;;;;OAUG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;;;;;;OAUG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;;;;;;;;;;;;;;OAgBG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IAC/B;;;;;;;;;;;;;;OAcG;IACH,qCAAqC,CAAC,EAAE,OAAO,CAAC;IAChD;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;;;;;;;;;;;;;;OAkBG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC;;;;;;;;;;;;OAYG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;IACrC;;;;OAIG;IACH,2BAA2B,CAAC,EAAE,OAAO,CAAC;IACtC;;;;;;;;;OASG;IACH,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC;;;;;;;;;;;;OAYG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiDG;IACH,eAAe,CAAC,EAAE,gBAAgB,GAAG,iBAAiB,CAAC;IACvD;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;;OAIG;IACH,EAAE,CAAC,EAAE,GAAG,CAAC;CACT,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emit-ts-declarations.d.ts","sourceRoot":"","sources":["../../src/compiler/emit-ts-declarations.ts"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AACH,wBAAsB,kBAAkB,CACvC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC5B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"emit-ts-declarations.d.ts","sourceRoot":"","sources":["../../src/compiler/emit-ts-declarations.ts"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AACH,wBAAsB,kBAAkB,CACvC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC5B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CA8HjC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-file.d.ts","sourceRoot":"","sources":["../../src/compiler/output-file.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
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.7.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"json5": "2.2.3",
|
|
32
32
|
"unplugin": "^2.1.2",
|
|
33
33
|
"urlpattern-polyfill": "^10.0.0",
|
|
34
|
-
"@inlang/
|
|
35
|
-
"@inlang/
|
|
34
|
+
"@inlang/sdk": "2.4.9",
|
|
35
|
+
"@inlang/recommend-sherlock": "0.2.1"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@rollup/plugin-virtual": "3.0.2",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"typedoc-plugin-missing-exports": "4.0.0",
|
|
49
49
|
"typescript": "5.8.3",
|
|
50
50
|
"vitest": "3.1.4",
|
|
51
|
-
"@
|
|
52
|
-
"@
|
|
51
|
+
"@opral/tsconfig": "1.1.0",
|
|
52
|
+
"@inlang/plugin-message-format": "4.0.0"
|
|
53
53
|
},
|
|
54
54
|
"keywords": [
|
|
55
55
|
"inlang",
|