@inlang/paraglide-js 2.17.0 โ 2.18.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/README.md +144 -19
- package/dist/bundler-plugins/unplugin.d.ts.map +1 -1
- package/dist/bundler-plugins/unplugin.js +38 -14
- package/dist/bundler-plugins/unplugin.js.map +1 -1
- package/dist/bundler-plugins/unplugin.test.js +83 -0
- package/dist/bundler-plugins/unplugin.test.js.map +1 -1
- package/dist/compiler/compile-local-variable.js +51 -0
- package/dist/compiler/compile-local-variable.js.map +1 -1
- package/dist/compiler/compile-local-variable.test.js +197 -0
- package/dist/compiler/compile-local-variable.test.js.map +1 -1
- package/dist/compiler/compile-message.test.js +109 -0
- package/dist/compiler/compile-message.test.js.map +1 -1
- package/dist/compiler/compile-project.test.js +276 -0
- package/dist/compiler/compile-project.test.js.map +1 -1
- package/dist/compiler/create-readme.js +1 -1
- package/dist/compiler/emit-ts-declarations.d.ts.map +1 -1
- package/dist/compiler/emit-ts-declarations.js +27 -1
- package/dist/compiler/emit-ts-declarations.js.map +1 -1
- package/dist/compiler/registry.d.ts.map +1 -1
- package/dist/compiler/registry.js +15 -0
- package/dist/compiler/registry.js.map +1 -1
- package/dist/services/env-variables/index.js +1 -1
- package/dist/services/file-handling/write-output.d.ts +13 -0
- package/dist/services/file-handling/write-output.d.ts.map +1 -1
- package/dist/services/file-handling/write-output.js +54 -0
- package/dist/services/file-handling/write-output.js.map +1 -1
- package/dist/services/file-handling/write-output.test.js +54 -0
- package/dist/services/file-handling/write-output.test.js.map +1 -1
- package/package.json +10 -2
package/README.md
CHANGED
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
|
|
6
6
|
<h1 align="center">๐ช Paraglide JS</h1>
|
|
7
7
|
<p align="center">
|
|
8
|
-
<strong>Compiler-
|
|
8
|
+
<strong>Compiler-first i18n for TanStack Start, SvelteKit, and Vite apps.</strong>
|
|
9
|
+
<br/>
|
|
10
|
+
Type-safe message functions, tree-shakable translations, and first-class SSR.
|
|
9
11
|
</p>
|
|
10
12
|
|
|
11
13
|
<p align="center">
|
|
@@ -29,9 +31,9 @@
|
|
|
29
31
|
</p>
|
|
30
32
|
|
|
31
33
|
<p align="center">
|
|
32
|
-
<sub>
|
|
34
|
+
<sub>Framework-authored and framework-tested</sub><br/><br/>
|
|
33
35
|
<a href="https://svelte.dev/docs/cli/paraglide"><img src="https://cdn.simpleicons.org/svelte/FF3E00" alt="Svelte" height="14" /> SvelteKit's official i18n integration</a><br/>
|
|
34
|
-
<a href="https://inlang.com/blog/tanstack-ci"><img src="https://tanstack.com/images/logos/logo-color-100.png" alt="TanStack" height="14" />
|
|
36
|
+
<a href="https://inlang.com/blog/tanstack-ci"><img src="https://tanstack.com/images/logos/logo-color-100.png" alt="TanStack" height="14" /> TanStack Router's e2e-tested i18n example</a>
|
|
35
37
|
</p>
|
|
36
38
|
|
|
37
39
|
## Code Preview
|
|
@@ -49,20 +51,20 @@ import { m } from "./paraglide/messages.js";
|
|
|
49
51
|
m.greeting({ name: "World" }); // "Hello World!" โ fully typesafe
|
|
50
52
|
```
|
|
51
53
|
|
|
52
|
-
The compiler
|
|
54
|
+
The compiler turns your messages into typed ESM functions. Vite, Rollup, and other modern bundlers can tree-shake unused translations before they reach the browser. Expect [**up to 70% smaller i18n bundle sizes**](https://inlang.com/m/gerre34r/library-inlang-paraglideJs/benchmark) compared to runtime i18n libraries (e.g. 47 KB vs 205 KB).
|
|
53
55
|
|
|
54
56
|
## Why Paraglide?
|
|
55
57
|
|
|
56
58
|
| | |
|
|
57
59
|
| ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
60
|
+
| **Vite-Native** | Designed for Vite and modern ESM bundlers. Works with TanStack Start, SvelteKit, React Router, Astro, Vue, Solid, and vanilla JS/TS. |
|
|
58
61
|
| **Smaller i18n Bundle** | Up to 70% smaller i18n bundle size than runtime i18n libraries. |
|
|
59
|
-
| **Tree-Shakable** |
|
|
62
|
+
| **Tree-Shakable** | Messages compile to ESM functions, so unused translations are eliminated by your bundler. |
|
|
60
63
|
| **Fully Typesafe** | Autocomplete for message keys and parameters. Typos become compile errors. |
|
|
61
|
-
| **Framework Agnostic** | Works with React, Vue, Svelte, Solid, TanStack, or vanilla JS/TS. |
|
|
62
64
|
| **Built-in i18n Routing** | URL-based locale detection and localized paths out of the box. |
|
|
63
|
-
| **
|
|
65
|
+
| **Open Localization Format** | Built on inlang: `project.inlang/settings.json` configures locales, plugins, and file patterns while translations stay in version-controlled files like `messages/en.json`. |
|
|
64
66
|
|
|
65
|
-
##
|
|
67
|
+
## Get Started With Your Framework
|
|
66
68
|
|
|
67
69
|
<p>
|
|
68
70
|
<a href="https://inlang.com/m/gerre34r/library-inlang-paraglideJs/vite"><img src="https://cdn.simpleicons.org/react/61DAFB" alt="React" width="18" height="18" /> React</a> ยท
|
|
@@ -74,8 +76,79 @@ The compiler generates typed message functions. Your bundler tree-shakes unused
|
|
|
74
76
|
<a href="https://inlang.com/m/gerre34r/library-inlang-paraglideJs/vanilla-js-ts"><img src="https://cdn.simpleicons.org/javascript/F7DF1E" alt="JavaScript" width="18" height="18" /> Vanilla JS/TS</a>
|
|
75
77
|
</p>
|
|
76
78
|
|
|
79
|
+
- **[TanStack Start example](https://github.com/TanStack/router/tree/main/examples/react/start-i18n-paraglide)** โ SSR, localized routing, and TanStack Router integration.
|
|
80
|
+
- **[SvelteKit guide](https://inlang.com/m/gerre34r/library-inlang-paraglideJs/sveltekit)** โ SvelteKit's official i18n integration.
|
|
81
|
+
- **[React Router guide](https://inlang.com/m/gerre34r/library-inlang-paraglideJs/react-router)** โ SSR and client routing.
|
|
82
|
+
- **[Astro guide](https://inlang.com/m/gerre34r/library-inlang-paraglideJs/astro)** โ static and server-rendered sites.
|
|
83
|
+
- **[Vite guide](https://inlang.com/m/gerre34r/library-inlang-paraglideJs/vite)** โ React, Vue, Solid, or vanilla JS/TS.
|
|
84
|
+
|
|
77
85
|
> [!TIP]
|
|
78
|
-
> <img src="https://vitejs.dev/logo.svg" alt="Vite" width="16" height="16" /> **Paraglide is ideal for
|
|
86
|
+
> <img src="https://vitejs.dev/logo.svg" alt="Vite" width="16" height="16" /> **Paraglide is ideal for Vite-based apps.** Setup is one plugin, messages compile to ESM, and Vite's tree-shaking eliminates unused translations automatically. [Get started โ](https://inlang.com/m/gerre34r/library-inlang-paraglideJs/vite)
|
|
87
|
+
|
|
88
|
+
## SSR Ready
|
|
89
|
+
|
|
90
|
+
Paraglide works in SSR apps with request-scoped locale handling. The server middleware detects the locale from each request and uses AsyncLocalStorage so `getLocale()` and message functions resolve the right locale even during concurrent requests.
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
import { paraglideMiddleware } from "./paraglide/server.js";
|
|
94
|
+
import { getLocale } from "./paraglide/runtime.js";
|
|
95
|
+
import { m } from "./paraglide/messages.js";
|
|
96
|
+
|
|
97
|
+
export function handle(request: Request) {
|
|
98
|
+
return paraglideMiddleware(request, async () => {
|
|
99
|
+
const html = `
|
|
100
|
+
<html lang="${getLocale()}">
|
|
101
|
+
<body>${m.greeting({ name: "Ada" })}</body>
|
|
102
|
+
</html>
|
|
103
|
+
`;
|
|
104
|
+
|
|
105
|
+
return new Response(html, {
|
|
106
|
+
headers: { "content-type": "text/html" },
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**[SSR Docs โ](https://inlang.com/m/gerre34r/library-inlang-paraglideJs/server-side-rendering)** ยท **[Middleware Docs โ](https://inlang.com/m/gerre34r/library-inlang-paraglideJs/middleware)**
|
|
113
|
+
|
|
114
|
+
## Router Composition
|
|
115
|
+
|
|
116
|
+
Paraglide coexists with your router. Your app keeps canonical routes like `/about`, while Paraglide maps browser-facing localized URLs like `/en/about` or `/de/ueber` to those canonical routes.
|
|
117
|
+
|
|
118
|
+
Use your framework or router for route definitions, loaders, navigation, and route typing. Use Paraglide for locale detection, localized URL generation, and message functions.
|
|
119
|
+
|
|
120
|
+
```ts
|
|
121
|
+
import { deLocalizeUrl, localizeUrl } from "./paraglide/runtime.js";
|
|
122
|
+
|
|
123
|
+
// Incoming request: localized URL -> canonical app route
|
|
124
|
+
deLocalizeUrl("https://example.com/de/ueber").href; // https://example.com/about
|
|
125
|
+
|
|
126
|
+
// Outgoing link: canonical app route -> localized URL
|
|
127
|
+
localizeUrl("https://example.com/about", { locale: "de" }).href; // https://example.com/de/ueber
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
For routers with rewrite hooks, call `deLocalizeUrl()` on incoming URLs and `localizeUrl()` on outgoing URLs. For file-based routers, keep your file routes canonical and localize at the routing boundary.
|
|
131
|
+
|
|
132
|
+
**[i18n Routing Docs โ](https://inlang.com/m/gerre34r/library-inlang-paraglideJs/i18n-routing)**
|
|
133
|
+
|
|
134
|
+
### TanStack Start
|
|
135
|
+
|
|
136
|
+
TanStack Start uses the same boundary pattern: TanStack Router owns the route tree, loaders, navigation, and typed links. Paraglide handles locale detection, localized URL mapping, and message functions.
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
import { paraglideMiddleware } from "./paraglide/server.js";
|
|
140
|
+
import handler from "@tanstack/react-start/server-entry";
|
|
141
|
+
|
|
142
|
+
export default {
|
|
143
|
+
fetch(req: Request): Promise<Response> {
|
|
144
|
+
return paraglideMiddleware(req, () => handler.fetch(req));
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Route code stays TanStack-native: TanStack Router owns route trees, loaders, server functions, navigation, and typed links. TanStack runs Paraglide in e2e tests on every router commit, and the guide covers router rewrites, localized links, prerendering, and SSR behavior.
|
|
150
|
+
|
|
151
|
+
**[TanStack Start i18n guide โ](https://github.com/TanStack/router/tree/main/examples/react/start-i18n-paraglide)**
|
|
79
152
|
|
|
80
153
|
## Quick Start
|
|
81
154
|
|
|
@@ -106,6 +179,31 @@ setLocale("de"); // switches to German
|
|
|
106
179
|
|
|
107
180
|
**[Full Getting Started Guide โ](https://inlang.com/m/gerre34r/library-inlang-paraglideJs)**
|
|
108
181
|
|
|
182
|
+
## Rich Text
|
|
183
|
+
|
|
184
|
+
For `<Trans>`-style rich text and component interpolation, use typed markup with your framework adapter.
|
|
185
|
+
|
|
186
|
+
```tsx
|
|
187
|
+
import { ParaglideMessage } from "@inlang/paraglide-js-react";
|
|
188
|
+
import { m } from "./paraglide/messages.js";
|
|
189
|
+
|
|
190
|
+
export function ContactCta() {
|
|
191
|
+
return (
|
|
192
|
+
<ParaglideMessage
|
|
193
|
+
message={m.cta}
|
|
194
|
+
markup={{
|
|
195
|
+
link: ({ children }) => <a href="/contact">{children}</a>,
|
|
196
|
+
strong: ({ children }) => <strong>{children}</strong>,
|
|
197
|
+
}}
|
|
198
|
+
/>
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
The markup names come from your message and are type-checked, so translators control where links and emphasis appear while your React app controls how they render.
|
|
204
|
+
|
|
205
|
+
**[Markup Docs โ](https://inlang.com/m/gerre34r/library-inlang-paraglideJs/markup)** ยท **[React](https://www.npmjs.com/package/@inlang/paraglide-js-react)** ยท **[Svelte](https://www.npmjs.com/package/@inlang/paraglide-js-svelte)** ยท **[Vue](https://www.npmjs.com/package/@inlang/paraglide-js-vue)** ยท **[Solid](https://www.npmjs.com/package/@inlang/paraglide-js-solid)**
|
|
206
|
+
|
|
109
207
|
## How It Works
|
|
110
208
|
|
|
111
209
|
Paraglide compiles an [inlang project](https://inlang.com/docs/introduction#how-it-works) into tree-shakable message functions. Your bundler eliminates unused messages at build time.
|
|
@@ -136,6 +234,7 @@ Paraglide supports locale-aware formatting via declaration formatters:
|
|
|
136
234
|
- `plural` (`Intl.PluralRules`) for plural and ordinal categories
|
|
137
235
|
- `number` (`Intl.NumberFormat`) for numbers, currency, compact notation, and more
|
|
138
236
|
- `datetime` (`Intl.DateTimeFormat`) for dates/times with locale-aware output
|
|
237
|
+
- `relativetime` (`Intl.RelativeTimeFormat`) for values like "yesterday", "in 2 days", or "3 hr. ago"
|
|
139
238
|
|
|
140
239
|
Gender and custom selects are supported via the variants system.
|
|
141
240
|
|
|
@@ -151,19 +250,45 @@ Message format is **plugin-based** โ use the default inlang format, or switch
|
|
|
151
250
|
|
|
152
251
|
**[Formatting Docs โ](https://inlang.com/m/gerre34r/library-inlang-paraglideJs/formatting)** ยท **[Pluralization & Variants Docs โ](https://inlang.com/m/gerre34r/library-inlang-paraglideJs/variants)**
|
|
153
252
|
|
|
253
|
+
## Why Compiler-First?
|
|
254
|
+
|
|
255
|
+
Runtime i18n libraries like i18next resolve message keys from dictionaries while your app runs. Paraglide compiles messages into typed ESM functions before your app ships.
|
|
256
|
+
|
|
257
|
+
That means Vite can tree-shake unused translations, TypeScript can autocomplete message keys and parameters, and your components call plain functions instead of resolving strings through a runtime lookup layer.
|
|
258
|
+
|
|
259
|
+
In the [Paraglide benchmark](https://inlang.com/m/gerre34r/library-inlang-paraglideJs/benchmark), typical scenarios shipped **47-144 KB with Paraglide** vs **205-422 KB with i18next**. With 5 locales, 100 used messages, and 200 total messages, Paraglide shipped **47 KB** while i18next shipped **205 KB**.
|
|
260
|
+
|
|
261
|
+
Tree-shaking also keeps Paraglide stable as your message catalog grows. In the benchmark, using 100 messages shipped **47 KB** with Paraglide whether the project had 200, 500, or 1,000 total messages. The i18next runtime bundle grew from **205 KB** to **414 KB**.
|
|
262
|
+
|
|
154
263
|
## Comparison
|
|
155
264
|
|
|
156
|
-
| Feature | Paraglide |
|
|
157
|
-
| ----------------------- | -------------------------------------------------------------------------------- |
|
|
158
|
-
| **
|
|
159
|
-
| **
|
|
160
|
-
| **
|
|
161
|
-
| **
|
|
162
|
-
| **
|
|
163
|
-
| **
|
|
265
|
+
| Feature | Paraglide | Lingui | i18next |
|
|
266
|
+
| ----------------------- | -------------------------------------------------------------------------------- | ---------------------------- | -------------------- |
|
|
267
|
+
| **Architecture** | Compiler-first ESM message functions | Extraction + compiled catalogs | Runtime dictionaries |
|
|
268
|
+
| **i18n bundle size** | Up to 70% smaller via message-level tree-shaking | Compiled catalogs | Runtime dictionaries |
|
|
269
|
+
| **Tree-shakable** | โ
Message functions | Catalog-based | โ |
|
|
270
|
+
| **Typesafe** | โ
Generated message functions | Macro/component workflow | Partial |
|
|
271
|
+
| **Framework support** | TanStack Start, SvelteKit, React Router, Astro, Vue, Solid, vanilla JS/TS | React, Vue, Astro, Svelte, Node.js, vanilla JS | Broad via wrappers |
|
|
272
|
+
| **Routing + SSR** | โ
Middleware, request isolation, and URL helpers | Use your framework/router | Use your framework/router |
|
|
273
|
+
| **Rich text** | โ
Typed markup adapters | โ
Rich-text components | Via framework wrappers |
|
|
274
|
+
| **ICU MessageFormat 1** | โ
[Via plugin](https://inlang.com/m/p7c8m1d2/plugin-inlang-icu-messageformat-1) | โ
| Via plugin |
|
|
164
275
|
|
|
165
276
|
**[Full Comparison โ](https://inlang.com/m/gerre34r/library-inlang-paraglideJs/comparison)**
|
|
166
277
|
|
|
278
|
+
## FAQ
|
|
279
|
+
|
|
280
|
+
### Does Paraglide support ICU MessageFormat?
|
|
281
|
+
|
|
282
|
+
Yes. Paraglide's message format is plugin-based. You can use the default inlang format, JSON, i18next, XLIFF, or ICU MessageFormat 1 via the [ICU plugin](https://inlang.com/m/p7c8m1d2/plugin-inlang-icu-messageformat-1).
|
|
283
|
+
|
|
284
|
+
### What about dynamic or CMS-driven keys?
|
|
285
|
+
|
|
286
|
+
Paraglide works best when message keys are known at build time, because that enables type safety and tree-shaking. For dynamic menus or CMS entries, use explicit mappings from CMS/content IDs to generated message functions, or let the CMS return already-localized content for the active locale. If most translations are only known at runtime, a runtime i18n library may be a better fit.
|
|
287
|
+
|
|
288
|
+
### Can I migrate from i18next?
|
|
289
|
+
|
|
290
|
+
Yes. Paraglide can compile existing i18next translation files through the [i18next plugin](https://inlang.com/m/3i8bor92/plugin-inlang-i18next), so you can keep your translation format while moving app code from `i18next.t("key")` to typed message functions over time.
|
|
291
|
+
|
|
167
292
|
## What Developers Say
|
|
168
293
|
|
|
169
294
|
> **"Paraglide JS is by far the best option when it comes to internationalization. Nothing better on the market."**
|
|
@@ -189,7 +314,7 @@ Message format is **plugin-based** โ use the default inlang format, or switch
|
|
|
189
314
|
|
|
190
315
|
## Ecosystem
|
|
191
316
|
|
|
192
|
-
Paraglide
|
|
317
|
+
Paraglide compiles messages from [inlang](https://github.com/opral/inlang), the open project file format for localization. In concrete terms, `project.inlang/settings.json` defines your locales, plugins, and translation file patterns; your translations stay as version-controlled files in your repo, such as `messages/en.json`, `locales/en.json`, or XLIFF files. Existing formats can be imported/exported through plugins. No account required; inlang tools are optional:
|
|
193
318
|
|
|
194
319
|
| Tool | Description |
|
|
195
320
|
| ----------------------------------------------------------------------- | ------------------------------------------------ |
|
|
@@ -205,7 +330,7 @@ Paraglide is built on the [open inlang format](https://github.com/opral/inlang-s
|
|
|
205
330
|
- [Getting Started](https://inlang.com/m/gerre34r/library-inlang-paraglideJs)
|
|
206
331
|
- [Framework Guides](https://inlang.com/m/gerre34r/library-inlang-paraglideJs/react-router) (React Router, SvelteKit, Astro, etc.)
|
|
207
332
|
- [Message Syntax & Pluralization](https://inlang.com/m/gerre34r/library-inlang-paraglideJs/variants)
|
|
208
|
-
- [Formatting (Number/Date)](https://inlang.com/m/gerre34r/library-inlang-paraglideJs/formatting)
|
|
333
|
+
- [Formatting (Number/Date/Relative Time)](https://inlang.com/m/gerre34r/library-inlang-paraglideJs/formatting)
|
|
209
334
|
- [Routing & SSR](https://inlang.com/m/gerre34r/library-inlang-paraglideJs/server-side-rendering)
|
|
210
335
|
- [API Reference](https://inlang.com/m/gerre34r/library-inlang-paraglideJs)
|
|
211
336
|
|
|
@@ -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;AAIhD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;
|
|
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;AAIhD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAiDvE,eAAO,MAAM,eAAe,EAAE,eAAe,CAAC,eAAe,CAqJ3D,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { compile } from "../compiler/compile.js";
|
|
2
|
-
import { relative } from "node:path";
|
|
2
|
+
import path, { relative } from "node:path";
|
|
3
3
|
import { Logger } from "../services/logger/index.js";
|
|
4
4
|
import { createTrackedFs, getWatchTargets, isPathWithinDirectories, } from "../services/file-watching/tracked-fs.js";
|
|
5
5
|
import { nodeNormalizePath } from "../utilities/node-normalize-path.js";
|
|
6
|
+
import { hashDirectory } from "../services/file-handling/write-output.js";
|
|
6
7
|
const PLUGIN_NAME = "unplugin-paraglide-js";
|
|
7
8
|
const logger = new Logger();
|
|
8
9
|
/**
|
|
@@ -11,6 +12,28 @@ const logger = new Logger();
|
|
|
11
12
|
let isServer;
|
|
12
13
|
let previousCompilation;
|
|
13
14
|
const { fs: trackedFs, readFiles, clearReadFiles } = createTrackedFs();
|
|
15
|
+
function withoutCleanOutdir(args) {
|
|
16
|
+
const { cleanOutdir, ...compileArgs } = args;
|
|
17
|
+
void cleanOutdir;
|
|
18
|
+
return compileArgs;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Seed a synthetic `previousCompilation` from files already on disk in
|
|
22
|
+
* `outdir`. This lets the first compile in a fresh process diff against
|
|
23
|
+
* the prior build's output instead of treating it as empty โ so warm
|
|
24
|
+
* restarts produce zero writes and we never wipe `outdir` out from under
|
|
25
|
+
* concurrent readers (SSR/prerender, sibling Vite processes).
|
|
26
|
+
*
|
|
27
|
+
* See https://github.com/opral/inlang-paraglide-js/issues/659.
|
|
28
|
+
*/
|
|
29
|
+
async function seedPreviousCompilation(outdir, fs) {
|
|
30
|
+
const absoluteOutdir = path.resolve(process.cwd(), outdir);
|
|
31
|
+
const resolvedFs = fs ?? (await import("node:fs"));
|
|
32
|
+
const outputHashes = await hashDirectory(absoluteOutdir, resolvedFs.promises);
|
|
33
|
+
if (!outputHashes)
|
|
34
|
+
return undefined;
|
|
35
|
+
return { outputHashes };
|
|
36
|
+
}
|
|
14
37
|
export const unpluginFactory = (args) => ({
|
|
15
38
|
name: PLUGIN_NAME,
|
|
16
39
|
enforce: "pre",
|
|
@@ -21,16 +44,18 @@ export const unpluginFactory = (args) => ({
|
|
|
21
44
|
const outputStructure = args.outputStructure ??
|
|
22
45
|
(isProduction ? "message-modules" : "locale-modules");
|
|
23
46
|
try {
|
|
47
|
+
// On a fresh process, seed previousCompilation from on-disk hashes
|
|
48
|
+
// so the first compile is a no-op when inputs are unchanged. Avoids
|
|
49
|
+
// racing concurrent readers that wiping outdir would interrupt.
|
|
50
|
+
const seededPrevious = previousCompilation ??
|
|
51
|
+
(await seedPreviousCompilation(args.outdir, args.fs));
|
|
24
52
|
previousCompilation = await compile({
|
|
25
53
|
fs: trackedFs,
|
|
26
|
-
previousCompilation,
|
|
54
|
+
previousCompilation: seededPrevious,
|
|
27
55
|
outputStructure,
|
|
28
|
-
// webpack invokes the `buildStart` api in watch mode,
|
|
29
|
-
// to avoid cleaning the output directory in watch mode,
|
|
30
|
-
// we only clean the output directory if there was no previous compilation
|
|
31
|
-
cleanOutdir: previousCompilation === undefined,
|
|
32
56
|
isServer,
|
|
33
|
-
...args,
|
|
57
|
+
...withoutCleanOutdir(args),
|
|
58
|
+
cleanOutdir: false,
|
|
34
59
|
});
|
|
35
60
|
logger.success(`Compilation complete (${outputStructure})`);
|
|
36
61
|
}
|
|
@@ -76,9 +101,9 @@ export const unpluginFactory = (args) => ({
|
|
|
76
101
|
fs: trackedFs,
|
|
77
102
|
previousCompilation,
|
|
78
103
|
outputStructure,
|
|
79
|
-
cleanOutdir: false,
|
|
80
104
|
isServer,
|
|
81
|
-
...args,
|
|
105
|
+
...withoutCleanOutdir(args),
|
|
106
|
+
cleanOutdir: false,
|
|
82
107
|
});
|
|
83
108
|
logger.success(`Re-compilation complete (${outputStructure})`);
|
|
84
109
|
// Add any new files to watch
|
|
@@ -128,15 +153,14 @@ export const unpluginFactory = (args) => ({
|
|
|
128
153
|
const outputStructure = args.outputStructure ??
|
|
129
154
|
(isProduction ? "message-modules" : "locale-modules");
|
|
130
155
|
try {
|
|
156
|
+
const seededPrevious = previousCompilation ??
|
|
157
|
+
(await seedPreviousCompilation(args.outdir, args.fs));
|
|
131
158
|
previousCompilation = await compile({
|
|
132
159
|
fs: trackedFs,
|
|
133
|
-
previousCompilation,
|
|
160
|
+
previousCompilation: seededPrevious,
|
|
134
161
|
outputStructure,
|
|
135
|
-
|
|
136
|
-
// of deleting the output directory and writing files at the same time for
|
|
137
|
-
// multi environment builds
|
|
162
|
+
...withoutCleanOutdir(args),
|
|
138
163
|
cleanOutdir: false,
|
|
139
|
-
...args,
|
|
140
164
|
});
|
|
141
165
|
logger.success(`Compilation complete (${outputStructure})`);
|
|
142
166
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unplugin.js","sourceRoot":"","sources":["../../src/bundler-plugins/unplugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAA0B,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"unplugin.js","sourceRoot":"","sources":["../../src/bundler-plugins/unplugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAA0B,MAAM,wBAAwB,CAAC;AACzE,OAAO,IAAI,EAAE,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,6B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AAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC;YAC3D,uEAAuE;YACvE,0DAA0D;YAC1D,MAAM,eAAe,GACpB,IAAI,CAAC,eAAe;gBACpB,CAAC,YAAY,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC;YACvD,IAAI,CAAC;gBACJ,MAAM,cAAc,GACnB,mBAAmB;oBACnB,CAAC,MAAM,uBAAuB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;gBACvD,mBAAmB,GAAG,MAAM,OAAO,CAAC;oBACnC,EAAE,EAAE,SAAS;oBACb,mBAAmB,EAAE,cAAc;oBACnC,eAAe;oBACf,GAAG,kBAAkB,CAAC,IAAI,CAAC;oBAC3B,WAAW,EAAE,KAAK;iBAClB,CAAC,CAAC;gBACH,MAAM,CAAC,OAAO,CAAC,yBAAyB,eAAe,GAAG,CAAC,CAAC;YAC7D,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,MAAM,CAAC,IAAI,CAAC,4BAA4B,EAAG,KAAe,CAAC,OAAO,CAAC,CAAC;gBACpE,MAAM,CAAC,IAAI,CAAC,wDAAwD,CAAC,CAAC;gBACtE,IAAI,YAAY;oBAAE,MAAM,KAAK,CAAC;YAC/B,CAAC;QACF,CAAC,CAAC,CAAC;IACJ,CAAC;CACD,CAAC,CAAC"}
|
|
@@ -6,6 +6,9 @@ import { loadProjectInMemory, newProject, saveProjectToDirectory, } from "@inlan
|
|
|
6
6
|
let originalNodeEnv;
|
|
7
7
|
beforeEach(() => {
|
|
8
8
|
originalNodeEnv = process.env.NODE_ENV;
|
|
9
|
+
// Reset module state between tests so the module-scoped
|
|
10
|
+
// `previousCompilation` doesn't leak across tests.
|
|
11
|
+
vi.resetModules();
|
|
9
12
|
// Mock logging methods to suppress error messages in tests
|
|
10
13
|
consola.mockTypes(() => vi.fn());
|
|
11
14
|
});
|
|
@@ -73,4 +76,84 @@ test("vite plugin throws on compilation errors at build time", async () => {
|
|
|
73
76
|
// In production mode - should throw the error
|
|
74
77
|
await expect(plugin.buildStart?.call(mockContext)).rejects.toThrow();
|
|
75
78
|
});
|
|
79
|
+
// Regression test for https://github.com/opral/inlang-paraglide-js/issues/659:
|
|
80
|
+
// the bundler plugins used to wipe `outdir` on every fresh process, racing
|
|
81
|
+
// concurrent reads (SSR/prerender modules, sibling Vite processes, the
|
|
82
|
+
// config-watcher reload) and producing ENOENT/MISSING_EXPORT/ERR_LOAD_URL.
|
|
83
|
+
test("vite plugin does not wipe outdir during first buildStart (#659)", async () => {
|
|
84
|
+
const { paraglideVitePlugin: vitePlugin } = await import("../bundler-plugins/vite.js");
|
|
85
|
+
const project = await loadProjectInMemory({
|
|
86
|
+
blob: await newProject({
|
|
87
|
+
settings: {
|
|
88
|
+
baseLocale: "en",
|
|
89
|
+
locales: ["en", "de", "fr"],
|
|
90
|
+
},
|
|
91
|
+
}),
|
|
92
|
+
});
|
|
93
|
+
const fs = memfs().fs;
|
|
94
|
+
await saveProjectToDirectory({
|
|
95
|
+
project,
|
|
96
|
+
path: "/project.inlang",
|
|
97
|
+
fs: fs.promises,
|
|
98
|
+
});
|
|
99
|
+
// Pre-seed outdir with a sentinel file mimicking a prior compilation
|
|
100
|
+
// still on disk from an earlier process.
|
|
101
|
+
await fs.promises.mkdir("/test-output", { recursive: true });
|
|
102
|
+
await fs.promises.writeFile("/test-output/__sentinel__.txt", "kept");
|
|
103
|
+
const rmSpy = vi.spyOn(fs.promises, "rm");
|
|
104
|
+
const plugin = vitePlugin({
|
|
105
|
+
project: "/project.inlang",
|
|
106
|
+
outdir: "/test-output",
|
|
107
|
+
cleanOutdir: true,
|
|
108
|
+
fs: fs,
|
|
109
|
+
});
|
|
110
|
+
const mockContext = { addWatchFile: () => { } };
|
|
111
|
+
await plugin.buildStart?.call(mockContext);
|
|
112
|
+
// The plugin must not recursively remove the outdir during the first
|
|
113
|
+
// compile, even though previousCompilation is undefined. Concurrent
|
|
114
|
+
// readers may be holding file handles into outdir.
|
|
115
|
+
for (const call of rmSpy.mock.calls) {
|
|
116
|
+
expect(call[0]).not.toBe("/test-output");
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
test("vite plugin warm-restart writes nothing when inputs unchanged (#659)", async () => {
|
|
120
|
+
const project = await loadProjectInMemory({
|
|
121
|
+
blob: await newProject({
|
|
122
|
+
settings: {
|
|
123
|
+
baseLocale: "en",
|
|
124
|
+
locales: ["en", "de", "fr"],
|
|
125
|
+
},
|
|
126
|
+
}),
|
|
127
|
+
});
|
|
128
|
+
const fs = memfs().fs;
|
|
129
|
+
await saveProjectToDirectory({
|
|
130
|
+
project,
|
|
131
|
+
path: "/project.inlang",
|
|
132
|
+
fs: fs.promises,
|
|
133
|
+
});
|
|
134
|
+
const mockContext = { addWatchFile: () => { } };
|
|
135
|
+
// First process: compile and persist files to outdir.
|
|
136
|
+
{
|
|
137
|
+
const { paraglideVitePlugin: vitePlugin } = await import("../bundler-plugins/vite.js");
|
|
138
|
+
const plugin = vitePlugin({
|
|
139
|
+
project: "/project.inlang",
|
|
140
|
+
outdir: "/test-output",
|
|
141
|
+
fs: fs,
|
|
142
|
+
});
|
|
143
|
+
await plugin.buildStart?.call(mockContext);
|
|
144
|
+
}
|
|
145
|
+
// Second process: simulate a fresh node process by resetting modules so
|
|
146
|
+
// the module-scoped `previousCompilation` is undefined again. The plugin
|
|
147
|
+
// should seed from on-disk hashes and write zero files (no race window).
|
|
148
|
+
vi.resetModules();
|
|
149
|
+
const { paraglideVitePlugin: vitePluginFresh } = await import("../bundler-plugins/vite.js");
|
|
150
|
+
const plugin2 = vitePluginFresh({
|
|
151
|
+
project: "/project.inlang",
|
|
152
|
+
outdir: "/test-output",
|
|
153
|
+
fs: fs,
|
|
154
|
+
});
|
|
155
|
+
const writeFileSpy = vi.spyOn(fs.promises, "writeFile");
|
|
156
|
+
await plugin2.buildStart?.call(mockContext);
|
|
157
|
+
expect(writeFileSpy).not.toHaveBeenCalled();
|
|
158
|
+
});
|
|
76
159
|
//# sourceMappingURL=unplugin.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unplugin.test.js","sourceRoot":"","sources":["../../src/bundler-plugins/unplugin.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EACN,mBAAmB,EACnB,UAAU,EACV,sBAAsB,GACtB,MAAM,aAAa,CAAC;AAErB,IAAI,eAAmC,CAAC;AAExC,UAAU,CAAC,GAAG,EAAE;IACf,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;IAEvC,2DAA2D;IAC3D,OAAO,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;AAClC,CAAC,CAAC,CAAC;AAEH,SAAS,CAAC,GAAG,EAAE;IACd,IAAI,eAAe,KAAK,SAAS,EAAE,CAAC;QACnC,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,eAAe,CAAC;IACxC,CAAC;SAAM,CAAC;QACP,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;IAC7B,CAAC;AACF,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,2DAA2D,EAAE,KAAK,IAAI,EAAE;IAC5E,8DAA8D;IAC9D,MAAM,OAAO,GAAG,MAAM,mBAAmB,CAAC;QACzC,IAAI,EAAE,MAAM,UAAU,CAAC;YACtB,QAAQ,EAAE;gBACT,UAAU,EAAE,IAAI;gBAChB,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;aAC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
|
20
20
|
if (!annotation) {
|
|
21
21
|
return str;
|
|
22
22
|
}
|
|
23
|
+
if (annotation.name === "relativetime") {
|
|
24
|
+
validateRelativeTimeOptions(annotation);
|
|
25
|
+
}
|
|
23
26
|
return `registry.${annotation.name}("${locale}", ${str}, ${compileOptions(annotation.name, annotation.options)})`;
|
|
24
27
|
}
|
|
25
28
|
function compileOptions(annotationName, options) {
|
|
@@ -55,8 +58,16 @@ const booleanOptionNamesByAnnotation = {
|
|
|
55
58
|
const jsNonNegativeIntegerPattern = /^(?:0|[1-9]\d*)$/;
|
|
56
59
|
function compileOptionLiteralOrVarRef(annotationName, optionName, value) {
|
|
57
60
|
if (value.type === "variable-reference") {
|
|
61
|
+
if (annotationName === "relativetime" && optionName === "unit") {
|
|
62
|
+
return `/** @type {import("../registry.js").RelativeTimeFormatUnit} */ (${compileInputAccess(value.name)})`;
|
|
63
|
+
}
|
|
58
64
|
return compileInputAccess(value.name);
|
|
59
65
|
}
|
|
66
|
+
if (annotationName === "relativetime" &&
|
|
67
|
+
optionName === "unit" &&
|
|
68
|
+
isDollarVariableReference(value.value)) {
|
|
69
|
+
return `/** @type {import("../registry.js").RelativeTimeFormatUnit} */ (${compileInputAccess(value.value.slice(1))})`;
|
|
70
|
+
}
|
|
60
71
|
if (shouldEmitNumberLiteral(annotationName, optionName, value.value)) {
|
|
61
72
|
return value.value;
|
|
62
73
|
}
|
|
@@ -81,4 +92,44 @@ function compileLiteralOrVarRef(value) {
|
|
|
81
92
|
return compileInputAccess(value.name);
|
|
82
93
|
}
|
|
83
94
|
}
|
|
95
|
+
const relativeTimeUnits = new Set([
|
|
96
|
+
"year",
|
|
97
|
+
"years",
|
|
98
|
+
"quarter",
|
|
99
|
+
"quarters",
|
|
100
|
+
"month",
|
|
101
|
+
"months",
|
|
102
|
+
"week",
|
|
103
|
+
"weeks",
|
|
104
|
+
"day",
|
|
105
|
+
"days",
|
|
106
|
+
"hour",
|
|
107
|
+
"hours",
|
|
108
|
+
"minute",
|
|
109
|
+
"minutes",
|
|
110
|
+
"second",
|
|
111
|
+
"seconds",
|
|
112
|
+
]);
|
|
113
|
+
function validateRelativeTimeOptions(annotation) {
|
|
114
|
+
const unitOptions = annotation.options.filter((option) => option.name === "unit");
|
|
115
|
+
if (unitOptions.length === 0) {
|
|
116
|
+
throw new Error('The "relativetime" formatter requires a "unit" option.');
|
|
117
|
+
}
|
|
118
|
+
if (unitOptions.length > 1) {
|
|
119
|
+
throw new Error('The "relativetime" formatter requires exactly one "unit" option.');
|
|
120
|
+
}
|
|
121
|
+
const [unitOption] = unitOptions;
|
|
122
|
+
if (!unitOption || unitOption.value.type === "variable-reference") {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
if (isDollarVariableReference(unitOption.value.value)) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
if (!relativeTimeUnits.has(unitOption.value.value)) {
|
|
129
|
+
throw new Error(`Invalid "relativetime" unit "${unitOption.value.value}". Expected one of: ${Array.from(relativeTimeUnits).join(", ")}.`);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
function isDollarVariableReference(value) {
|
|
133
|
+
return value.startsWith("$") && value.length > 1;
|
|
134
|
+
}
|
|
84
135
|
//# sourceMappingURL=compile-local-variable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile-local-variable.js","sourceRoot":"","sources":["../../src/compiler/compile-local-variable.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAE3E;;;;;;;;;;GAUG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAGpC;IACA,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,UAAU,CAAC;IAErD,MAAM,KAAK,GAAG,iBAAiB,CAC9B,sBAAsB,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,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CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,SAAS;YACb,OAAO,IAAI,0BAA0B,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;QACvD,KAAK,oBAAoB;YACxB,OAAO,kBAAkB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"compile-local-variable.js","sourceRoot":"","sources":["../../src/compiler/compile-local-variable.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAE3E;;;;;;;;;;GAUG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAGpC;IACA,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,UAAU,CAAC;IAErD,MAAM,KAAK,GAAG,iBAAiB,CAC9B,sBAAsB,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,EAClD,IAAI,CAAC,MAAM,EACX,UAAU,CACV,CAAC;IAEF,OAAO,SAAS,IAAI,CAAC,WAAW,CAAC,IAAI,MAAM,KAAK,GAAG,CAAC;AACrD,CAAC;AAED,SAAS,iBAAiB,CACzB,GAAW,EACX,MAAc,EACd,UAAiD;IAEjD,IAAI,CAAC,UAAU,EAAE,CAAC;QACjB,OAAO,GAAG,CAAC;IACZ,CAAC;IACD,IAAI,UAAU,CAAC,IAAI,KAAK,cAAc,EAAE,CAAC;QACxC,2BAA2B,CAAC,UAAU,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,YAAY,UAAU,CAAC,IAAI,KAAK,MAAM,MAAM,GAAG,KAAK,cAAc,CAAC,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC;AACnH,CAAC;AAED,SAAS,cAAc,CACtB,cAAsB,EACtB,OAAqC;IAErC,IAAI,OAAO,CAAC,MAAM,KAAK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