@intlayer/swc 9.0.0-canary.11 → 9.0.0-canary.12
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
CHANGED
|
@@ -1,14 +1,60 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://intlayer.org" rel="">
|
|
3
|
+
<img src="https://raw.githubusercontent.com/aymericzip/intlayer/main/docs/assets/cover.png" width="60%" alt="Intlayer Logo" />
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
2
6
|
|
|
3
|
-
|
|
4
|
-
the open-source i18n framework for React, Next.js, Vue, Svelte, and more.
|
|
7
|
+
<h1 align="center">intlayer-swc-plugin</h1>
|
|
5
8
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
<p align="center">
|
|
10
|
+
<a href="https://intlayer.org/doc/concept/content" rel="">Docs</a> •
|
|
11
|
+
<a href="https://intlayer.org/doc/environment/nextjs" rel="">Next.js</a> •
|
|
12
|
+
<a href="https://intlayer.org/doc/environment/vite-and-react" rel="">React + Vite</a> •
|
|
13
|
+
<a href="https://intlayer.org/doc/concept/cms" rel="">CMS</a> •
|
|
14
|
+
<a href="https://discord.gg/7uxamYVeCk" rel="noopener noreferrer nofollow">Discord</a>
|
|
15
|
+
</p>
|
|
10
16
|
|
|
11
|
-
|
|
17
|
+
<p align="center" style="margin-top:15px;">
|
|
18
|
+
<a href="https://www.npmjs.com/package/@intlayer/swc" target="_blank" rel="noopener noreferrer nofollow"><img src="https://img.shields.io/npm/v/@intlayer/swc?style=for-the-badge&labelColor=FFFFFF&color=000000&logoColor=FFFFFF" alt="npm version" height="24"/></a>
|
|
19
|
+
<a href="https://github.com/aymericzip/intlayer/stargazers" target="_blank" rel="noopener noreferrer nofollow"><img src="https://img.shields.io/github/stars/aymericzip/intlayer?style=for-the-badge&labelColor=000000&color=FFFFFF&logo=github&logoColor=FFD700" alt="GitHub Stars" height="24"/></a>
|
|
20
|
+
<a href="https://www.npmjs.org/package/@intlayer/swc" target="_blank" rel="noopener noreferrer nofollow"><img src="https://img.shields.io/npm/dm/@intlayer/swc?style=for-the-badge&labelColor=000000&color=FFFFFF&logoColor=000000&cacheSeconds=86400" alt="monthly downloads" height="24"/></a>
|
|
21
|
+
</p>
|
|
22
|
+
|
|
23
|
+
An [SWC](https://swc.rs) transform plugin for [Intlayer](https://intlayer.org) — the open-source i18n framework for React, Next.js, Vue, Svelte, and more.
|
|
24
|
+
|
|
25
|
+
**Intlayer** is a **modern i18n solution** for web and mobile apps. It’s framework-agnostic, **AI-powered**, and includes a free **CMS & visual editor**. With **per-locale content files**, **TypeScript autocompletion**, **tree-shakable dictionaries**, and **CI/CD integration**, Intlayer makes internationalization **faster, cleaner, and smarter**.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## 🚀 Key Features
|
|
30
|
+
|
|
31
|
+
Intlayer provides a variety of features to help you scale your internationalization efforts.
|
|
32
|
+
|
|
33
|
+
- **Cross-Framework Support**: Compatible with all major frameworks and libraries, including Next.js, React, Vite, Vue.js, Nuxt, Preact, Express, and more.
|
|
34
|
+
- **JavaScript-Powered Content Management**: Harness the flexibility of JavaScript to define and manage your content efficiently.
|
|
35
|
+
- **Per-Locale Content Declaration File**: Speed up your development by declaring your content once, before auto generation.
|
|
36
|
+
- **Compiler**: The Intlayer Compiler extracts automatically the content from the components and generates the dictionary files.
|
|
37
|
+
- **Type-Safe Environment**: Leverage TypeScript to ensure your content definitions and code are error-free, while also benefiting from IDE autocompletion.
|
|
38
|
+
- **Simplified Setup**: Get up and running quickly with minimal configuration. Adjust settings for internationalization, routing, AI, build, and content handling with ease.
|
|
39
|
+
- **Simplified Content Retrieval**: No need to call your `t` function for each piece of content. Retrieve all your content directly using a single hook.
|
|
40
|
+
- **Consistent Server Component Implementation**: Perfectly suited for Next.js server components, use the same implementation for both client and server components.
|
|
41
|
+
- **Organized Codebase**: Keep your codebase more organized: 1 component = 1 dictionary in the same folder.
|
|
42
|
+
- **Enhanced Routing**: Full support of app routing, adapting seamlessly to complex application structures, for Next.js, React, Vite, Vue.js, etc.
|
|
43
|
+
- **Markdown Support**: Import and interpret locale files and remote Markdown for multilingual content like privacy policies, documentation, etc.
|
|
44
|
+
- **Free Visual Editor & CMS**: A free visual editor and CMS are available for content writers, removing the need for a localization platform.
|
|
45
|
+
- **Tree-shakable Content**: Tree-shakable content, reducing the size of the final bundle. Loads content per component, excluding any unused content from your bundle.
|
|
46
|
+
- **Static Rendering**: Doesn't block Static Rendering in Next.js.
|
|
47
|
+
- **AI-Powered Translation**: Transform your website into 231 languages with just one click using Intlayer's advanced AI-powered translation tools.
|
|
48
|
+
- **MCP Server Integration**: Provides an MCP server for IDE automation, enabling seamless content management and i18n workflows.
|
|
49
|
+
- **VSCode Extension**: Intlayer provides a VSCode extension to help you manage your content and translations.
|
|
50
|
+
- **Interoperability**: Allow interoperability with react-i18next, next-i18next, next-intl, react-intl, vue-i18n.
|
|
51
|
+
- **Performances & Benchmark**: Uses advanced tree-shaking and dynamic loading to boost performances and keep the solution as light as possible.
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## 🛠️ How the plugin works
|
|
56
|
+
|
|
57
|
+
The plugin rewrites `useIntlayer` / `getIntlayer` / `useTranslations` call arguments at compile time, replacing string dictionary keys with pre-loaded dictionary imports. This eliminates runtime registry lookups and enables tree-shaking for per-locale bundles.
|
|
12
58
|
|
|
13
59
|
**Before** (source code):
|
|
14
60
|
|
|
@@ -37,8 +83,7 @@ Three import modes are supported:
|
|
|
37
83
|
|
|
38
84
|
## Usage: Next.js / SWC Wasm plugin (recommended)
|
|
39
85
|
|
|
40
|
-
The Wasm binary is distributed via npm as
|
|
41
|
-
[`@intlayer/swc`](https://www.npmjs.com/package/@intlayer/swc).
|
|
86
|
+
The Wasm binary is distributed via npm as [`@intlayer/swc`](https://www.npmjs.com/package/@intlayer/swc).
|
|
42
87
|
You do not need to add this Rust crate as a dependency for that use-case.
|
|
43
88
|
|
|
44
89
|
```bash
|
|
@@ -76,10 +121,7 @@ const nextConfig: NextConfig = {
|
|
|
76
121
|
export default nextConfig;
|
|
77
122
|
```
|
|
78
123
|
|
|
79
|
-
In practice you should use the
|
|
80
|
-
[`@intlayer/webpack`](https://www.npmjs.com/package/@intlayer/webpack) or
|
|
81
|
-
[`@intlayer/vite`](https://www.npmjs.com/package/@intlayer/vite) plugin, which
|
|
82
|
-
configures the SWC plugin automatically based on your `intlayer.config.*` file.
|
|
124
|
+
In practice you should use the [`@intlayer/webpack`](https://www.npmjs.com/package/@intlayer/webpack) or [`@intlayer/vite`](https://www.npmjs.com/package/@intlayer/vite) plugin, which configures the SWC plugin automatically based on your `intlayer.config.*` file.
|
|
83
125
|
|
|
84
126
|
---
|
|
85
127
|
|
|
@@ -115,8 +157,7 @@ fn my_transform(program: Program, file_path: &str) -> Program {
|
|
|
115
157
|
|
|
116
158
|
### Building the Wasm plugin yourself
|
|
117
159
|
|
|
118
|
-
The `plugin` Cargo feature enables the `#[plugin_transform]` Wasm entry point.
|
|
119
|
-
Without it the crate compiles as a standard native Rust library.
|
|
160
|
+
The `plugin` Cargo feature enables the `#[plugin_transform]` Wasm entry point. Without it the crate compiles as a standard native Rust library.
|
|
120
161
|
|
|
121
162
|
```bash
|
|
122
163
|
# Uses the alias defined in .cargo/config.toml
|
|
@@ -129,8 +170,7 @@ cargo build --target wasm32-wasip1 --features plugin --release
|
|
|
129
170
|
|
|
130
171
|
## Plugin configuration reference
|
|
131
172
|
|
|
132
|
-
All fields correspond to the JSON object passed as the second element of each
|
|
133
|
-
`swcPlugins` tuple.
|
|
173
|
+
All fields correspond to the JSON object passed as the second element of each `swcPlugins` tuple.
|
|
134
174
|
|
|
135
175
|
| Field | Type | Default | Description |
|
|
136
176
|
| ------------------------ | ---------------------------------- | ---------- | --------------------------------------------------- |
|
|
@@ -150,10 +190,120 @@ All fields correspond to the JSON object passed as the second element of each
|
|
|
150
190
|
The following symbols are exported by this crate:
|
|
151
191
|
|
|
152
192
|
- **`PluginConfig`** – configuration struct (mirrors the JSON options above).
|
|
153
|
-
- **`process_transform(program, cfg, filename) -> Program`** – core transform
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
193
|
+
- **`process_transform(program, cfg, filename) -> Program`** – core transform function; accepts and returns an SWC `Program` AST.
|
|
194
|
+
- **`normalize_path(path: &str) -> String`** – normalises Windows-style backslash paths to forward slashes for cross-platform path diffing.
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## Documentation
|
|
199
|
+
|
|
200
|
+
Explore our comprehensive documentation to get started with Intlayer and learn how to integrate it into your projects.
|
|
201
|
+
|
|
202
|
+
<details open>
|
|
203
|
+
<summary style="font-size:16px; font-weight:bold;">📘 Get Started</summary>
|
|
204
|
+
<ul>
|
|
205
|
+
<li><a href="https://intlayer.org/doc/why" rel=''>Why Intlayer?</a></li>
|
|
206
|
+
<li><a href="https://intlayer.org/doc" rel=''>Introduction</a></li>
|
|
207
|
+
</ul>
|
|
208
|
+
</details>
|
|
209
|
+
|
|
210
|
+
<details>
|
|
211
|
+
<summary style="font-size:16px; font-weight:bold;">⚙️ Concept</summary>
|
|
212
|
+
<ul>
|
|
213
|
+
<li><a href="https://intlayer.org/doc/concept/how-works-intlayer" rel=''>How Intlayer Works</a></li>
|
|
214
|
+
<li><a href="https://intlayer.org/doc/concept/configuration" rel=''>Configuration</a></li>
|
|
215
|
+
<li><a href="https://intlayer.org/doc/concept/cli" rel=''>Intlayer CLI</a></li>
|
|
216
|
+
<li><a href="https://intlayer.org/doc/compiler" rel=''>Compiler</a></li>
|
|
217
|
+
<li><a href="https://intlayer.org/doc/concept/editor" rel=''>Intlayer Editor</a></li>
|
|
218
|
+
<li><a href="https://intlayer.org/doc/concept/cms" rel=''>Intlayer CMS</a></li>
|
|
219
|
+
<li><a href="https://intlayer.org/doc/concept/content" rel=''>Dictionary</a>
|
|
220
|
+
<ul>
|
|
221
|
+
<li><a href="https://intlayer.org/doc/concept/content/per-locale-file" rel=''>Per-Locale Content Declaration File</a></li>
|
|
222
|
+
<li><a href="https://intlayer.org/doc/concept/content/translation" rel=''>Translation</a></li>
|
|
223
|
+
<li><a href="https://intlayer.org/doc/concept/content/enumeration" rel=''>Enumeration</a></li>
|
|
224
|
+
<li><a href="https://intlayer.org/doc/concept/content/condition" rel=''>Condition</a></li>
|
|
225
|
+
<li><a href="https://intlayer.org/doc/concept/content/nesting" rel=''>Nesting</a></li>
|
|
226
|
+
<li><a href="https://intlayer.org/doc/concept/content/markdown" rel=''>Markdown</a></li>
|
|
227
|
+
<li><a href="https://intlayer.org/doc/concept/content/function-fetching" rel=''>Function Fetching</a></li>
|
|
228
|
+
<li><a href="https://intlayer.org/doc/concept/content/insertion" rel=''>Insertion</a></li>
|
|
229
|
+
<li><a href="https://intlayer.org/doc/concept/content/file" rel=''>File</a></li>
|
|
230
|
+
</ul>
|
|
231
|
+
</li>
|
|
232
|
+
</ul>
|
|
233
|
+
</details>
|
|
234
|
+
|
|
235
|
+
<details open>
|
|
236
|
+
<summary style="font-size:16px; font-weight:bold;">🌐 Environment</summary>
|
|
237
|
+
<ul>
|
|
238
|
+
<li><a href="https://intlayer.org/doc/environment/nextjs" rel=''>Intlayer with Next.js 16</a>
|
|
239
|
+
<ul>
|
|
240
|
+
<li><a href="https://intlayer.org/doc/environment/nextjs/15" rel=''>Next.js 15</a></li>
|
|
241
|
+
<li><a href="https://intlayer.org/doc/environment/nextjs/14" rel=''>Next.js 14 (App Router)</a></li>
|
|
242
|
+
<li><a href="https://intlayer.org/doc/environment/nextjs/next-with-Page-Router" rel=''>Next.js Page Router</a></li>
|
|
243
|
+
<li><a href="https://intlayer.org/doc/environment/nextjs/compiler" rel=''>Next.js using Compiler</a></li>
|
|
244
|
+
</ul>
|
|
245
|
+
</li>
|
|
246
|
+
<li><a href="https://intlayer.org/doc/environment/create-react-app" rel=''>React CRA</a></li>
|
|
247
|
+
<li><a href="https://intlayer.org/doc/environment/vite-and-react" rel=''>Vite + React</a></li>
|
|
248
|
+
<li><a href="https://intlayer.org/doc/environment/vite-and-react" rel=''>Vite + React using Compiler</a></li>
|
|
249
|
+
<li><a href="https://intlayer.org/doc/environment/vite-and-react/compiler" rel=''>React-router-v7</a></li>
|
|
250
|
+
<li><a href="https://intlayer.org/doc/environment/tanstack-start" rel=''>Tanstack start</a>
|
|
251
|
+
<ul>
|
|
252
|
+
<li><a href="https://intlayer.org/doc/environment/tanstack-start/solid" rel=''>Solid</a></li>
|
|
253
|
+
</ul>
|
|
254
|
+
</li>
|
|
255
|
+
<li><a href="https://intlayer.org/doc/environment/astro" rel=''>Astro</a>
|
|
256
|
+
<ul>
|
|
257
|
+
<li><a href="https://intlayer.org/doc/environment/astro/react" rel=''>React</a></li>
|
|
258
|
+
<li><a href="https://intlayer.org/doc/environment/astro/vue" rel=''>Vue</a></li>
|
|
259
|
+
<li><a href="https://intlayer.org/doc/environment/astro/svelte" rel=''>Svelte</a></li>
|
|
260
|
+
<li><a href="https://intlayer.org/doc/environment/astro/solid" rel=''>Solid</a></li>
|
|
261
|
+
<li><a href="https://intlayer.org/doc/environment/astro/vanilla" rel=''>Vanilla JS</a></li>
|
|
262
|
+
<li><a href="https://intlayer.org/doc/environment/astro/lit" rel=''>Lit</a></li>
|
|
263
|
+
</ul>
|
|
264
|
+
</li>
|
|
265
|
+
<li><a href="https://intlayer.org/doc/environment/react-native-and-expo" rel=''>React Native</a></li>
|
|
266
|
+
<li><a href="https://intlayer.org/doc/environment/vite-and-svelte" rel=''>Vite + Svelte</a></li>
|
|
267
|
+
<li><a href="https://intlayer.org/doc/environment/sveltekit" rel=''>SvelteKit</a></li>
|
|
268
|
+
<li><a href="https://intlayer.org/doc/environment/vite-and-preact" rel=''>Vite + Preact</a></li>
|
|
269
|
+
<li><a href="https://intlayer.org/doc/environment/vite-and-vue" rel=''>Vite + Vue</a></li>
|
|
270
|
+
<li><a href="https://intlayer.org/doc/environment/vite-and-nuxt" rel=''>Vite + Nuxt</a></li>
|
|
271
|
+
<li><a href="https://intlayer.org/doc/environment/vite-and-solid" rel=''>Vite + Solid</a></li>
|
|
272
|
+
<li><a href="https://intlayer.org/doc/environment/angular" rel=''>Angular</a></li>
|
|
273
|
+
<li>
|
|
274
|
+
<a href="https://intlayer.org/doc/environment/express" rel=''>Backend</a>
|
|
275
|
+
<ul>
|
|
276
|
+
<li><a href="https://intlayer.org/doc/environment/express" rel=''>Express</a></li>
|
|
277
|
+
<li><a href="https://intlayer.org/doc/environment/nest" rel=''>NestJS</a></li>
|
|
278
|
+
<li><a href="https://intlayer.org/doc/environment/fastify" rel=''>Fastify</a></li>
|
|
279
|
+
<li><a href="https://intlayer.org/doc/environment/adonisjs" rel=''>AdonisJS</a></li>
|
|
280
|
+
<li><a href="https://intlayer.org/doc/environment/hono" rel=''>Hono</a></li>
|
|
281
|
+
</ul>
|
|
282
|
+
</li>
|
|
283
|
+
</ul>
|
|
284
|
+
</details>
|
|
285
|
+
|
|
286
|
+
<details>
|
|
287
|
+
<summary style="font-size:16px; font-weight:bold;">📊 Benchmark</summary>
|
|
288
|
+
<ul>
|
|
289
|
+
<li><a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/benchmark/nextjs.md" rel=''>Next.js</a></li>
|
|
290
|
+
<li><a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/benchmark/tanstack.md" rel=''>TanStack Start</a></li>
|
|
291
|
+
<li><a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/benchmark/vue.md" rel=''>Vue</a></li>
|
|
292
|
+
<li><a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/benchmark/solid.md" rel=''>Solid</a></li>
|
|
293
|
+
<li><a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/benchmark/svelte.md" rel=''>Svelte</a></li>
|
|
294
|
+
</ul>
|
|
295
|
+
</details>
|
|
296
|
+
|
|
297
|
+
<details>
|
|
298
|
+
<summary style="font-size:16px; font-weight:bold;">📰 Blog</summary>
|
|
299
|
+
<ul>
|
|
300
|
+
<li><a href="https://github.com/aymericzip/intlayer/blob/main/docs/blog/en/what_is_internationalization.md" rel=''>What is i18n</a></li>
|
|
301
|
+
<li><a href="https://intlayer.org/blog/SEO-and-i18n" rel=''>i18n and SEO</a></li>
|
|
302
|
+
<li><a href="https://intlayer.org/blog/intlayer-with-next-i18next" rel=''>Intlayer and i18next</a></li>
|
|
303
|
+
<li><a href="https://intlayer.org/blog/intlayer-with-react-i18next" rel=''>Intlayer and react-intl</a></li>
|
|
304
|
+
<li><a href="https://intlayer.org/blog/intlayer-with-next-intl" rel=''>Intlayer and next-intl</a></li>
|
|
305
|
+
</ul>
|
|
306
|
+
</details>
|
|
157
307
|
|
|
158
308
|
---
|
|
159
309
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/swc",
|
|
3
|
-
"version": "9.0.0-canary.
|
|
3
|
+
"version": "9.0.0-canary.12",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A SWC plugin for Intlayer that transforms declaration files and provides internationalization features during the build process according to the Intlayer configuration.",
|
|
6
6
|
"keywords": [
|
|
Binary file
|