Skip to content

Commit 53b7eb1

Browse files
paraglide js version 2.7.0
1 parent 9267dca commit 53b7eb1

File tree

7 files changed

+80
-54
lines changed

7 files changed

+80
-54
lines changed

.changeset/locale-declaration-opt-in.md

Lines changed: 0 additions & 24 deletions
This file was deleted.

inlang/packages/paraglide/paraglide-js/CHANGELOG.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,58 @@
11
# @inlang/paraglide-js
22

3+
## 2.7.0
4+
5+
### Minor Changes
6+
7+
- Add an opt-in `emitTsDeclarations` compiler flag to generate `.d.ts` files for the compiled output.
8+
9+
This is useful when `allowJs: true` cannot be set in your `tsconfig.json` (e.g., due to project constraints or conflicting compiler options).
10+
11+
**Usage:**
12+
13+
```ts
14+
// vite.config.ts
15+
import { defineConfig } from "vite";
16+
import { paraglideVitePlugin } from "@inlang/paraglide-js";
17+
18+
export default defineConfig({
19+
plugins: [
20+
paraglideVitePlugin({
21+
project: "./project.inlang",
22+
outdir: "./src/paraglide",
23+
emitTsDeclarations: true,
24+
}),
25+
],
26+
});
27+
```
28+
29+
Or via CLI:
30+
31+
```bash
32+
paraglide compile --project ./project.inlang --outdir ./src/paraglide --emitTsDeclarations
33+
```
34+
35+
**Note:** Enabling this option reduces compiler speed because TypeScript needs to generate declaration files for all output modules.
36+
37+
Closes https://github.com/opral/inlang-paraglide-js/issues/566
38+
Closes https://github.com/opral/inlang-paraglide-js/issues/238
39+
Closes https://github.com/opral/inlang-paraglide-js/issues/160
40+
41+
Example output (locale-modules):
42+
43+
```diff
44+
src/paraglide/
45+
messages/
46+
_index.js
47+
+ _index.d.ts
48+
de.js
49+
+ de.d.ts
50+
en.js
51+
+ en.d.ts
52+
messages.js
53+
+ messages.d.ts
54+
```
55+
356
## 2.6.0
457

558
### Minor Changes

inlang/packages/paraglide/paraglide-js/docs-api/compiler-options.md

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ The output will look like this:
4040

4141
> `optional` **cleanOutdir**: `boolean`
4242
43-
Defined in: [compiler-options.ts:280](https://github.com/opral/monorepo/tree/main/inlang/packages/paraglide/paraglide-js/src/compiler/compiler-options.ts)
43+
Defined in: [compiler-options.ts:284](https://github.com/opral/monorepo/tree/main/inlang/packages/paraglide/paraglide-js/src/compiler/compiler-options.ts)
4444

4545
Whether to clean the output directory before writing the new files.
4646

@@ -111,7 +111,7 @@ The name of the cookie to use for the cookie strategy.
111111

112112
> `optional` **disableAsyncLocalStorage**: `boolean`
113113
114-
Defined in: [compiler-options.ts:209](https://github.com/opral/monorepo/tree/main/inlang/packages/paraglide/paraglide-js/src/compiler/compiler-options.ts)
114+
Defined in: [compiler-options.ts:213](https://github.com/opral/monorepo/tree/main/inlang/packages/paraglide/paraglide-js/src/compiler/compiler-options.ts)
115115

116116
Replaces AsyncLocalStorage with a synchronous implementation.
117117

@@ -126,7 +126,7 @@ leak into another concurrent request.
126126

127127
> `optional` **emitGitIgnore**: `boolean`
128128
129-
Defined in: [compiler-options.ts:223](https://github.com/opral/monorepo/tree/main/inlang/packages/paraglide/paraglide-js/src/compiler/compiler-options.ts)
129+
Defined in: [compiler-options.ts:227](https://github.com/opral/monorepo/tree/main/inlang/packages/paraglide/paraglide-js/src/compiler/compiler-options.ts)
130130

131131
If `emitGitIgnore` is set to `true` a `.gitignore` file will be emitted in the output directory. Defaults to `true`.
132132

@@ -170,13 +170,17 @@ true
170170

171171
> `optional` **emitTsDeclarations**: `boolean`
172172
173-
Defined in: [compiler-options.ts:188](https://github.com/opral/monorepo/tree/main/inlang/packages/paraglide/paraglide-js/src/compiler/compiler-options.ts)
173+
Defined in: [compiler-options.ts:192](https://github.com/opral/monorepo/tree/main/inlang/packages/paraglide/paraglide-js/src/compiler/compiler-options.ts)
174174

175175
Emit `.d.ts` files for the generated output using the TypeScript compiler.
176176

177-
Enable this to give IDEs fresh, explicit typings for generated message modules
178-
(useful when using `locale-modules` during development). Requires `typescript`
179-
to be resolvable in your toolchain.
177+
Useful when `allowJs: true` cannot be set in your `tsconfig.json`
178+
(e.g., due to project constraints or conflicting compiler options).
179+
180+
Requires `typescript` to be resolvable in your toolchain.
181+
182+
**Note:** Enabling this option reduces compiler speed because TypeScript
183+
needs to generate declaration files for all output modules.
180184

181185
##### Example
182186

@@ -222,7 +226,7 @@ false
222226

223227
> `optional` **fs**: `any`
224228
225-
Defined in: [compiler-options.ts:287](https://github.com/opral/monorepo/tree/main/inlang/packages/paraglide/paraglide-js/src/compiler/compiler-options.ts)
229+
Defined in: [compiler-options.ts:291](https://github.com/opral/monorepo/tree/main/inlang/packages/paraglide/paraglide-js/src/compiler/compiler-options.ts)
226230

227231
The file system to use. Defaults to `await import('node:fs')`.
228232

@@ -232,7 +236,7 @@ Useful for testing the paraglide compiler by mocking the fs.
232236

233237
> `optional` **includeEslintDisableComment**: `boolean`
234238
235-
Defined in: [compiler-options.ts:198](https://github.com/opral/monorepo/tree/main/inlang/packages/paraglide/paraglide-js/src/compiler/compiler-options.ts)
239+
Defined in: [compiler-options.ts:202](https://github.com/opral/monorepo/tree/main/inlang/packages/paraglide/paraglide-js/src/compiler/compiler-options.ts)
236240

237241
Whether to include an eslint-disable comment at the top of each .js file.
238242

@@ -301,7 +305,7 @@ await compile({
301305

302306
> `optional` **outputStructure**: `"locale-modules"` \| `"message-modules"`
303307
304-
Defined in: [compiler-options.ts:274](https://github.com/opral/monorepo/tree/main/inlang/packages/paraglide/paraglide-js/src/compiler/compiler-options.ts)
308+
Defined in: [compiler-options.ts:278](https://github.com/opral/monorepo/tree/main/inlang/packages/paraglide/paraglide-js/src/compiler/compiler-options.ts)
305309

306310
The `outputStructure` defines how modules are structured in the output.
307311

@@ -403,7 +407,7 @@ Custom strategies with the pattern `custom-[A-Za-z0-9]+` are supported.
403407

404408
> `optional` **urlPatterns**: [`Runtime`](runtime/type/README.md#runtime)\[`"urlPatterns"`\]
405409
406-
Defined in: [compiler-options.ts:192](https://github.com/opral/monorepo/tree/main/inlang/packages/paraglide/paraglide-js/src/compiler/compiler-options.ts)
410+
Defined in: [compiler-options.ts:196](https://github.com/opral/monorepo/tree/main/inlang/packages/paraglide/paraglide-js/src/compiler/compiler-options.ts)
407411

408412
https://inlang.com/m/gerre34r/library-inlang-paraglideJs/strategy#url
409413

inlang/packages/paraglide/paraglide-js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@inlang/paraglide-js",
33
"type": "module",
4-
"version": "2.6.0",
4+
"version": "2.7.0",
55
"license": "MIT",
66
"publishConfig": {
77
"access": "public",

inlang/packages/paraglide/paraglide-js/src/compiler/compiler-options.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,13 @@ export type CompilerOptions = {
170170
/**
171171
* Emit `.d.ts` files for the generated output using the TypeScript compiler.
172172
*
173-
* Enable this to give IDEs fresh, explicit typings for generated message modules
174-
* (useful when using `locale-modules` during development). Requires `typescript`
175-
* to be resolvable in your toolchain.
173+
* Useful when `allowJs: true` cannot be set in your `tsconfig.json`
174+
* (e.g., due to project constraints or conflicting compiler options).
175+
*
176+
* Requires `typescript` to be resolvable in your toolchain.
177+
*
178+
* **Note:** Enabling this option reduces compiler speed because TypeScript
179+
* needs to generate declaration files for all output modules.
176180
*
177181
* @example
178182
* ```ts

inlang/packages/paraglide/paraglide-js/src/compiler/emit-ts-declarations.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export async function emitTsDeclarations(
5959
checkJs: true,
6060
declaration: true,
6161
emitDeclarationOnly: true,
62+
isolatedDeclarations: true,
6263
esModuleInterop: true,
6364
lib: ["ESNext", "DOM"],
6465
module: ts.ModuleKind.ESNext,

pnpm-lock.yaml

Lines changed: 3 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)