@intlayer/docs 9.2.0 → 9.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.
Files changed (89) hide show
  1. package/blog/ar/index.md +1 -1
  2. package/blog/de/index.md +1 -1
  3. package/blog/en/index.md +1 -1
  4. package/blog/en-GB/index.md +1 -1
  5. package/blog/es/index.md +1 -1
  6. package/blog/fr/index.md +1 -1
  7. package/blog/hi/index.md +1 -1
  8. package/blog/id/index.md +1 -1
  9. package/blog/it/index.md +1 -1
  10. package/blog/ja/index.md +1 -1
  11. package/blog/ko/index.md +1 -1
  12. package/blog/pl/index.md +1 -1
  13. package/blog/pt/index.md +1 -1
  14. package/blog/ru/index.md +1 -1
  15. package/blog/uk/index.md +1 -1
  16. package/blog/vi/index.md +1 -1
  17. package/blog/zh/index.md +1 -1
  18. package/dist/cjs/common.cjs +24 -1
  19. package/dist/cjs/common.cjs.map +1 -1
  20. package/dist/cjs/generated/blog.entry.cjs +31 -4
  21. package/dist/cjs/generated/blog.entry.cjs.map +1 -1
  22. package/dist/cjs/generated/docs.entry.cjs +31 -4
  23. package/dist/cjs/generated/docs.entry.cjs.map +1 -1
  24. package/dist/cjs/generated/frequentQuestions.entry.cjs +31 -4
  25. package/dist/cjs/generated/frequentQuestions.entry.cjs.map +1 -1
  26. package/dist/cjs/generated/legal.entry.cjs +31 -4
  27. package/dist/cjs/generated/legal.entry.cjs.map +1 -1
  28. package/dist/esm/common.mjs +24 -1
  29. package/dist/esm/common.mjs.map +1 -1
  30. package/dist/esm/generated/blog.entry.mjs +31 -4
  31. package/dist/esm/generated/blog.entry.mjs.map +1 -1
  32. package/dist/esm/generated/docs.entry.mjs +31 -4
  33. package/dist/esm/generated/docs.entry.mjs.map +1 -1
  34. package/dist/esm/generated/frequentQuestions.entry.mjs +31 -4
  35. package/dist/esm/generated/frequentQuestions.entry.mjs.map +1 -1
  36. package/dist/esm/generated/legal.entry.mjs +31 -4
  37. package/dist/esm/generated/legal.entry.mjs.map +1 -1
  38. package/dist/types/common.d.ts.map +1 -1
  39. package/dist/types/generated/blog.entry.d.ts.map +1 -1
  40. package/dist/types/generated/docs.entry.d.ts.map +1 -1
  41. package/dist/types/generated/frequentQuestions.entry.d.ts.map +1 -1
  42. package/dist/types/generated/legal.entry.d.ts.map +1 -1
  43. package/docs/ar/bundle_optimization.md +58 -25
  44. package/docs/ar/live-sync.md +4 -0
  45. package/docs/bn/bundle_optimization.md +58 -25
  46. package/docs/cs/bundle_optimization.md +58 -25
  47. package/docs/de/bundle_optimization.md +58 -25
  48. package/docs/de/live-sync.md +4 -0
  49. package/docs/en/bundle_optimization.md +51 -23
  50. package/docs/en/live-sync.md +4 -0
  51. package/docs/en-GB/bundle_optimization.md +58 -25
  52. package/docs/en-GB/live-sync.md +4 -0
  53. package/docs/es/bundle_optimization.md +58 -25
  54. package/docs/es/live-sync.md +4 -0
  55. package/docs/fr/bundle_optimization.md +58 -25
  56. package/docs/fr/live-sync.md +4 -0
  57. package/docs/hi/bundle_optimization.md +58 -25
  58. package/docs/hi/live-sync.md +4 -0
  59. package/docs/id/bundle_optimization.md +58 -25
  60. package/docs/id/live-sync.md +4 -0
  61. package/docs/it/bundle_optimization.md +58 -25
  62. package/docs/it/live-sync.md +4 -0
  63. package/docs/ja/bundle_optimization.md +58 -25
  64. package/docs/ja/live-sync.md +4 -0
  65. package/docs/ko/bundle_optimization.md +58 -25
  66. package/docs/ko/live-sync.md +4 -0
  67. package/docs/nl/bundle_optimization.md +58 -25
  68. package/docs/pl/bundle_optimization.md +58 -25
  69. package/docs/pl/live-sync.md +4 -0
  70. package/docs/pt/bundle_optimization.md +58 -24
  71. package/docs/pt/live-sync.md +4 -0
  72. package/docs/ru/bundle_optimization.md +58 -25
  73. package/docs/ru/live-sync.md +4 -0
  74. package/docs/tr/bundle_optimization.md +58 -25
  75. package/docs/tr/live-sync.md +4 -0
  76. package/docs/uk/bundle_optimization.md +58 -25
  77. package/docs/uk/live-sync.md +4 -0
  78. package/docs/ur/bundle_optimization.md +58 -25
  79. package/docs/vi/bundle_optimization.md +58 -25
  80. package/docs/vi/live-sync.md +4 -0
  81. package/docs/zh/bundle_optimization.md +58 -25
  82. package/docs/zh/live-sync.md +4 -0
  83. package/docs/zh-TW/bundle_optimization.md +58 -25
  84. package/package.json +7 -7
  85. package/src/common.ts +39 -2
  86. package/src/generated/blog.entry.ts +39 -7
  87. package/src/generated/docs.entry.ts +39 -7
  88. package/src/generated/frequentQuestions.entry.ts +39 -7
  89. package/src/generated/legal.entry.ts +39 -7
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  createdAt: 2025-11-25
3
- updatedAt: 2026-06-07
3
+ updatedAt: 2026-08-09
4
4
  title: i18n Bundelgrootte & Prestatie-optimalisatie
5
5
  description: Verklein de bundelgrootte van uw applicatie door internationalisatie (i18n) content te optimaliseren. Leer hoe u tree shaking en lazy loading kunt inzetten voor woordenboeken met Intlayer.
6
6
  keywords:
@@ -16,6 +16,12 @@ slugs:
16
16
  - concept
17
17
  - bundle-optimization
18
18
  history:
19
+ - version: 9.2.1
20
+ date: 2026-08-09
21
+ changes: "`purge` en `minify` werken nu op Next.js via `@intlayer/swc` — geen `babel.config.js` vereist"
22
+ - version: 8.12.0
23
+ date: 2026-06-24
24
+ changes: "Babel-plugins in de vereiste pipelinevolgorde vermelden (extract → purge → minify → optimize) in de referentietabellen"
19
25
  - version: 8.12.0
20
26
  date: 2026-06-07
21
27
  changes: "Toevoeging van `intlayerPurgeBabelPlugin` en `intlayerMinifyBabelPlugin` voor Babel/Webpack; verduidelijking van de plugin-pipeline"
@@ -191,12 +197,14 @@ De build-optimalisatie van Intlayer is opgesplitst in verschillende discrete plu
191
197
 
192
198
  Deze worden direct in `babel.config.js` gebruikt voor Webpack-gebaseerde setups (Next.js met Babel, CRA, aangepaste Webpack, enz.).
193
199
 
200
+ De onderstaande tabel toont ze in hun vereiste pipelinevolgorde (dezelfde volgorde waarin ze in `babel.config.js` moeten staan):
201
+
194
202
  | Plugin | Wat het doet |
195
203
  | :---------------------------- | :----------------------------------------------------------------------------------------------------------------------------------- |
196
204
  | `intlayerExtractBabelPlugin` | Scant `.content.ts`-bestanden en schrijft gecompileerde woordenboeken naar `.intlayer/` |
197
- | `intlayerOptimizeBabelPlugin` | Herschrijft `useIntlayer('key')` → `useDictionary(hash)` en voegt de bijpassende woordenboek `import` in |
198
205
  | `intlayerPurgeBabelPlugin` | Scant alle bronbestanden en verwijdert **ongebruikte contentvelden** uit de gecompileerde `.intlayer/**/*.json`-woordenboekbestanden |
199
206
  | `intlayerMinifyBabelPlugin` | **Hernoemt contentveld-sleutels** naar korte alfabetische aliassen (`title` → `a`) in zowel JSON-bestanden als de broncode |
207
+ | `intlayerOptimizeBabelPlugin` | Herschrijft `useIntlayer('key')` → `useDictionary(hash)` en voegt de bijpassende woordenboek `import` in |
200
208
 
201
209
  > **De volgorde van plugins is belangrijk.** In uw `babel.config.js` moeten de purge- en minify-plugins **vóór** de optimize-plugin staan. De optimize-stap vervangt `useIntlayer('key')` door een ondoorzichtige `useDictionary(hash)` aanroep, waardoor de woordenboeksleutelinformatie wordt gewist die de purge- en minify-stappen nodig hebben om te bepalen welke velden worden gebruikt.
202
210
 
@@ -205,9 +213,9 @@ Elke Babel-plugin heeft een bijpassende optie-helper die uw `intlayer.config.ts`
205
213
  | Optie helper | Gebruikt met |
206
214
  | :--------------------------- | :---------------------------- |
207
215
  | `getExtractPluginOptions()` | `intlayerExtractBabelPlugin` |
208
- | `getOptimizePluginOptions()` | `intlayerOptimizeBabelPlugin` |
209
216
  | `getPurgePluginOptions()` | `intlayerPurgeBabelPlugin` |
210
217
  | `getMinifyPluginOptions()` | `intlayerMinifyBabelPlugin` |
218
+ | `getOptimizePluginOptions()` | `intlayerOptimizeBabelPlugin` |
211
219
 
212
220
  ### Vite plugins (`vite-intlayer`)
213
221
 
@@ -220,6 +228,20 @@ Vite gebruikers **configureren deze nooit direct**. Ze worden automatisch gekopp
220
228
  | Dictionary minify | Zelfde als `intlayerMinifyBabelPlugin` JSON-schrijfstap |
221
229
  | Babel transform | Zelfde als `intlayerMinifyBabelPlugin` broncode hernoemen + `intlayerOptimizeBabelPlugin` |
222
230
 
231
+ ### SWC-plugin (`@intlayer/swc`)
232
+
233
+ Ook Next.js-gebruikers **configureren deze nooit rechtstreeks**. Sinds **v9.2.1** voert `withIntlayer()` in `next.config.ts` de volledige pipeline uit — purge, minify en het herschrijven van imports — uitsluitend op basis van de vlaggen `build.purge` en `build.minify`.
234
+
235
+ Het werk is in tweeën gesplitst, want een SWC-Wasm-plugin transformeert één bestand tegelijk en heeft geen toegang tot het bestandssysteem:
236
+
237
+ | Fase | Waar die draait | Wat die doet |
238
+ | :--------------------------------------------- | :---------------------------- | :------------------------------------------------------------------------------------------------- |
239
+ | Gebruiksanalyse + JSON-purge/minify | Node, binnen `withIntlayer()` | Leest elk componentbronbestand, herschrijft `.intlayer/**/*.json` en produceert de hernoemtabellen |
240
+ | Broncode herschrijven (`content.title` → `.a`) | `@intlayer/swc` (Wasm) | Past de hernoemtabellen toe op de bijbehorende eigenschapstoegangen in je code |
241
+ | Imports herschrijven (`useIntlayer` → dict) | `@intlayer/swc` (Wasm) | Hetzelfde als `intlayerOptimizeBabelPlugin` |
242
+
243
+ Bepalen _welke_ velden ongebruikt zijn en _welke_ alias elk veld krijgt, vereist status over bestanden heen en bestands-I/O; die helft draait daarom in Node en de SWC-plugin ontvangt alleen de resulterende tabellen.
244
+
223
245
  ## Setup per platform
224
246
 
225
247
  <Tabs>
@@ -227,10 +249,12 @@ Vite gebruikers **configureren deze nooit direct**. Ze worden automatisch gekopp
227
249
 
228
250
  ### Next.js
229
251
 
230
- Next.js vereist de `@intlayer/swc` plugin voor de optimize-stap (import-herschrijving), omdat Next.js SWC gebruikt voor builds.
252
+ Next.js vereist de `@intlayer/swc`-plugin, omdat Next.js SWC gebruikt voor builds. Sinds **v9.2.1** dekt dit ene pakket de volledige pipeline — optimalisatie (imports herschrijven), purge en minify.
231
253
 
232
254
  > Deze plugin is niet standaard geïnstalleerd omdat SWC plugins nog experimenteel zijn voor Next.js. Dit kan in de toekomst veranderen.
233
255
 
256
+ > **Next.js 16.1.0 is de minimumversie.** Het is de eerste release die gebouwd is op SWC's voorwaarts-compatibele Wasm-plugin-ABI; eerdere releases weigeren de plugin. `withIntlayer` leest je Next.js-versie en registreert de plugin onder 16.1.0 eenvoudigweg niet — die builds slagen nog steeds, ze draaien alleen zonder bundeloptimalisatie.
257
+
234
258
  <Tabs>
235
259
  <Tab value="npm">
236
260
 
@@ -265,33 +289,40 @@ intlayer-swc-plugin = "*"
265
289
 
266
290
  Zodra geïnstalleerd, zal Intlayer de plugin automatisch detecteren en gebruiken.
267
291
 
268
- Voor de **purge en minify** stappen (veldverwijdering en veldhernoeming), installeert u `@intlayer/babel` en voegt u de Babel-plugins toe. Omdat Next.js SWC gebruikt voor transformatie maar nog steeds `babel.config.js` evalueert voor pluginconfiguratie, draaien de Babel-plugins als een pre-stap voor SWC.
292
+ De **purge- en minify-fasen** (velden verwijderen en hernoemen) vereisen geen extra pakket en geen `babel.config.js`. Wikkel je configuratie in `withIntlayer` en zet de vlaggen aan in `intlayer.config.ts`:
269
293
 
270
- ```bash packageManager="npm"
271
- npm install -D @intlayer/babel
294
+ ```typescript fileName="next.config.ts"
295
+ import { withIntlayer } from "next-intlayer/server";
296
+ import type { NextConfig } from "next";
297
+
298
+ const nextConfig: NextConfig = {/* jouw configuratie */};
299
+
300
+ export default withIntlayer(nextConfig);
272
301
  ```
273
302
 
274
- ```javascript fileName="babel.config.js"
275
- const {
276
- intlayerPurgeBabelPlugin,
277
- intlayerMinifyBabelPlugin,
278
- getPurgePluginOptions,
279
- getMinifyPluginOptions,
280
- } = require("@intlayer/babel");
303
+ ```typescript fileName="intlayer.config.ts"
304
+ import type { IntlayerConfig } from "intlayer";
281
305
 
282
- module.exports = {
283
- presets: ["next/babel"],
284
- plugins: [
285
- // Purge: verwijder ongebruikte contentvelden uit .intlayer/**/*.json
286
- [intlayerPurgeBabelPlugin, getPurgePluginOptions()],
287
- // Minify: hernoem contentveld-sleutels in JSON + broncode
288
- [intlayerMinifyBabelPlugin, getMinifyPluginOptions()],
289
- // Let op: intlayerOptimizeBabelPlugin is hier NIET nodig omdat
290
- // @intlayer/swc de useIntlayer → useDictionary herschrijving afhandelt.
291
- ],
306
+ const config: IntlayerConfig = {
307
+ build: {
308
+ purge: true, // verwijdert ongebruikte contentvelden uit de gebundelde JSON
309
+ minify: true, // hernoemt contentveldsleutels naar korte aliassen
310
+ },
292
311
  };
312
+
313
+ export default config;
293
314
  ```
294
315
 
316
+ Tijdens `next build` analyseert `withIntlayer` je bronnen, herschrijft het de gecompileerde woordenboeken en geeft het de resulterende hernoemtabellen door aan `@intlayer/swc`, dat de bijbehorende eigenschapstoegangen in je code bijwerkt.
317
+
318
+ > Gebruik het asynchrone `withIntlayer`, niet `withIntlayerSync`. De synchrone variant draait de analysepipeline niet, dus purge en minify hebben er geen effect mee.
319
+
320
+ > Purge en minify draaien alleen bij `next build` — de optimalisatiepipeline staat uit tijdens `next dev`.
321
+
322
+ > Ze worden ook uitgeschakeld wanneer compat-adapter-aanroepers geconfigureerd zijn (`swcExtraCallers`, ingesteld door de compat-pakketten zoals `@intlayer/next-intl` of `@intlayer/react-i18next`): die aanroeppunten zijn onzichtbaar voor de gebruiksanalysator, dus purgen zou velden verwijderen die de code nog leest. Het herschrijven van imports blijft actief.
323
+
324
+ **Eerdere versies (vóór 9.2.1)** vereisten `@intlayer/babel` en een `babel.config.js` die `intlayerPurgeBabelPlugin` en `intlayerMinifyBabelPlugin` declareert. Dat bestand is niet langer nodig en kan verwijderd worden.
325
+
295
326
  </Tab>
296
327
  <Tab value="vite">
297
328
 
@@ -447,6 +478,8 @@ export default config;
447
478
 
448
479
  > Minificatie wordt overgeslagen wanneer `optimize` `false` is of wanneer `editor.enabled` `true` is (de visuele editor vereist de originele veldnamen om bewerken mogelijk te maken).
449
480
 
481
+ > Op Next.js wordt minificatie ook overgeslagen wanneer `@intlayer/swc` niet geïnstalleerd is of niet geladen kan worden (Next.js onder 16.1.0). De plugin is de helft die de broncodetoegangen herschrijft, dus de woordenboeken hernoemen zonder die plugin zou je code veldnamen laten lezen die niet meer bestaan.
482
+
450
483
  > Minificatie wordt ook overgeslagen voor woordenboeken die geladen worden via `importMode: 'fetch'` omdat hun JSON wordt geserveerd vanuit een externe API met de originele veldnamen — het hernoemen van de client-side sleutels zou het server/client contract verbreken.
451
484
 
452
485
  ### Purging (verwijderen van ongebruikte velden)
@@ -475,7 +508,7 @@ export default config;
475
508
  { "title": "…", "subtitle": "…" }
476
509
  ```
477
510
 
478
- > Purge wordt overgeslagen wanneer `optimize` `false` is of wanneer `editor.enabled` `true` is.
511
+ > Purge wordt overgeslagen wanneer `optimize` `false` is of wanneer `editor.enabled` `true` is. Op Next.js wordt het bovendien overgeslagen wanneer `@intlayer/swc` niet beschikbaar is en wanneer compat-adapter-aanroepers geconfigureerd zijn.
479
512
 
480
513
  > Purge wordt ook conservatief overgeslagen wanneer een bronbestand niet geparseerd kan worden, of wanneer het resultaat van `useIntlayer` wordt toegewezen aan een variabele en wordt doorgegeven op manieren die de statische analyzer niet kan volgen (bijv. uitgespreid in een object, doorgegeven als een prop zonder destructuring). In dergelijke gevallen wordt het volledige woordenboek behouden.
481
514
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  createdAt: 2025-11-25
3
- updatedAt: 2026-06-07
3
+ updatedAt: 2026-08-09
4
4
  title: Optymalizacja Rozmiaru Paczki i Wydajności i18n
5
5
  description: Zmniejsz rozmiar paczki swojej aplikacji, optymalizując treści umiędzynarodowienia (i18n). Dowiedz się, jak wykorzystać tree shaking i leniwe ładowanie (lazy loading) dla słowników dzięki Intlayer.
6
6
  keywords:
@@ -16,6 +16,12 @@ slugs:
16
16
  - concept
17
17
  - bundle-optimization
18
18
  history:
19
+ - version: 9.2.1
20
+ date: 2026-08-09
21
+ changes: "`purge` i `minify` działają teraz w Next.js poprzez `@intlayer/swc` — plik `babel.config.js` nie jest wymagany"
22
+ - version: 8.12.0
23
+ date: 2026-06-24
24
+ changes: "Wypisanie wtyczek Babel w wymaganej kolejności potoku (extract → purge → minify → optimize) w tabelach referencyjnych"
19
25
  - version: 8.12.0
20
26
  date: 2026-06-07
21
27
  changes: "Dodano `intlayerPurgeBabelPlugin` i `intlayerMinifyBabelPlugin` dla Babel/Webpack; wyjaśnienie działania przepływu wtyczek (pipeline)"
@@ -191,12 +197,14 @@ Optymalizacja w trakcie budowania przez Intlayer podzielona jest na kilka niezal
191
197
 
192
198
  Wtyczki te są wykorzystywane bezpośrednio w `babel.config.js` dla środowisk opartych na Webpacku (Next.js z Babel, CRA, własne konfiguracje Webpack itp.).
193
199
 
200
+ Poniższa tabela wymienia je w wymaganej kolejności potoku (tej samej, w jakiej muszą wystąpić w `babel.config.js`):
201
+
194
202
  | Wtyczka | Działanie |
195
203
  | :---------------------------- | :---------------------------------------------------------------------------------------------------------------------- |
196
204
  | `intlayerExtractBabelPlugin` | Skanuje pliki `.content.ts` i zapisuje skompilowane słowniki w katalogu `.intlayer/` |
197
- | `intlayerOptimizeBabelPlugin` | Przepisuje kod `useIntlayer('key')` → `useDictionary(hash)` i wstrzykuje import pasującego słownika |
198
205
  | `intlayerPurgeBabelPlugin` | Skanuje wszystkie pliki źródłowe, usuwając **nieużywane pola treści** ze skompilowanych słowników `.intlayer/**/*.json` |
199
206
  | `intlayerMinifyBabelPlugin` | **Zmienia nazwy kluczy pól treści** na krótkie, literowe aliasy (np. `title` → `a`) w plikach JSON i kodzie źródłowym |
207
+ | `intlayerOptimizeBabelPlugin` | Przepisuje kod `useIntlayer('key')` → `useDictionary(hash)` i wstrzykuje import pasującego słownika |
200
208
 
201
209
  > **Kolejność wtyczek ma znaczenie.** W Twoim `babel.config.js` wtyczki purge i minify muszą pojawić się **przed** wtyczką optimize. Krok optymalizacji zastępuje bowiem `useIntlayer('key')` nieprzejrzystym wywołaniem `useDictionary(hash)`, usuwając informację o kluczu słownika. Właśnie tej informacji potrzebują etapy purge i minify, aby móc określić, które pola są wykorzystywane.
202
210
 
@@ -205,9 +213,9 @@ Każda z wtyczek dla Babel ma swój dedykowany helper dla opcji, który odczytuj
205
213
  | Helper opcji | Zastosowanie z wtyczką |
206
214
  | :--------------------------- | :---------------------------- |
207
215
  | `getExtractPluginOptions()` | `intlayerExtractBabelPlugin` |
208
- | `getOptimizePluginOptions()` | `intlayerOptimizeBabelPlugin` |
209
216
  | `getPurgePluginOptions()` | `intlayerPurgeBabelPlugin` |
210
217
  | `getMinifyPluginOptions()` | `intlayerMinifyBabelPlugin` |
218
+ | `getOptimizePluginOptions()` | `intlayerOptimizeBabelPlugin` |
211
219
 
212
220
  ### Wtyczki Vite (`vite-intlayer`)
213
221
 
@@ -220,6 +228,20 @@ Użytkownicy Vite **nigdy nie konfigurują ich bezpośrednio**. Są one podłąc
220
228
  | Dictionary minify | Działa jak etap zapisu JSON we wtyczce `intlayerMinifyBabelPlugin` |
221
229
  | Babel transform | Działa jak etap zmiany nazewnictwa z `intlayerMinifyBabelPlugin` + `intlayerOptimizeBabelPlugin` |
222
230
 
231
+ ### Wtyczka SWC (`@intlayer/swc`)
232
+
233
+ Użytkownicy Next.js również **nigdy nie konfigurują tego bezpośrednio**. Od wersji **9.2.1** `withIntlayer()` w `next.config.ts` uruchamia cały potok — purge, minifikację i przepisywanie importów — wyłącznie na podstawie flag `build.purge` i `build.minify`.
234
+
235
+ Praca jest podzielona na dwie części, ponieważ wtyczka Wasm SWC przekształca jeden plik naraz i nie ma dostępu do systemu plików:
236
+
237
+ | Przebieg | Gdzie działa | Co robi |
238
+ | :----------------------------------------------------- | :------------------------------ | :-------------------------------------------------------------------------------------------------- |
239
+ | Analiza użycia + purge/minifikacja JSON | Node, wewnątrz `withIntlayer()` | Czyta każdy plik źródłowy komponentu, przepisuje `.intlayer/**/*.json` i tworzy tablice zmiany nazw |
240
+ | Przepisywanie kodu źródłowego (`content.title` → `.a`) | `@intlayer/swc` (Wasm) | Stosuje tablice zmiany nazw do odpowiadających odwołań do właściwości w Twoim kodzie |
241
+ | Przepisywanie importów (`useIntlayer` → dict) | `@intlayer/swc` (Wasm) | Tak samo jak `intlayerOptimizeBabelPlugin` |
242
+
243
+ Ustalenie, _które_ pola są nieużywane i _jaki_ alias otrzyma każde z nich, wymaga stanu obejmującego wiele plików oraz operacji wejścia/wyjścia na plikach, więc ta połowa działa w Node; wtyczka SWC otrzymuje jedynie wynikowe tablice.
244
+
223
245
  ## Konfiguracja wg Platformy
224
246
 
225
247
  <Tabs>
@@ -227,10 +249,12 @@ Użytkownicy Vite **nigdy nie konfigurują ich bezpośrednio**. Są one podłąc
227
249
 
228
250
  ### Next.js
229
251
 
230
- Next.js wymaga instalacji wtyczki `@intlayer/swc` na etapie optymalizacji (przepisywania importów), ponieważ Next.js wykorzystuje do budowania SWC.
252
+ Next.js wymaga wtyczki `@intlayer/swc`, ponieważ Next.js używa SWC do budowania. Od wersji **9.2.1** ten jeden pakiet obsługuje cały potok — optymalizację (przepisywanie importów), purge i minifikację.
231
253
 
232
254
  > Ta wtyczka nie jest instalowana domyślnie, ponieważ wtyczki SWC dla Next.js mają wciąż charakter eksperymentalny. Może się to zmienić w przyszłości.
233
255
 
256
+ > **Next.js 16.1.0 to wersja minimalna.** To pierwsze wydanie zbudowane na zgodnym w przód ABI wtyczek Wasm SWC; wcześniejsze wydania odrzucają wtyczkę. `withIntlayer` odczytuje Twoją wersję Next.js i po prostu nie rejestruje wtyczki poniżej 16.1.0 — takie buildy nadal się udają, po prostu działają bez optymalizacji bundla.
257
+
234
258
  <Tabs>
235
259
  <Tab value="npm">
236
260
 
@@ -265,33 +289,40 @@ intlayer-swc-plugin = "*"
265
289
 
266
290
  Po jej zainstalowaniu Intlayer automatycznie wykryje i wykorzysta tę wtyczkę.
267
291
 
268
- Do przejścia etapów **purge i minify** (usuwania i skracania pól), należy zainstalować równolegle `@intlayer/babel` i dodać wtyczki Babel. Choć Next.js do transformacji korzysta z SWC, wciąż interpretuje `babel.config.js` w zakresie konfiguracji wtyczek, co sprawia, że wtyczki dla Babel uruchamiane są jeszcze przed etapem SWC.
292
+ Przebiegi **purge i minifikacji** (usuwanie i zmiana nazw pól) nie wymagają dodatkowego pakietu ani pliku `babel.config.js`. Owiń swoją konfigurację funkcją `withIntlayer` i włącz flagi w `intlayer.config.ts`:
269
293
 
270
- ```bash packageManager="npm"
271
- npm install -D @intlayer/babel
294
+ ```typescript fileName="next.config.ts"
295
+ import { withIntlayer } from "next-intlayer/server";
296
+ import type { NextConfig } from "next";
297
+
298
+ const nextConfig: NextConfig = {/* twoja konfiguracja */};
299
+
300
+ export default withIntlayer(nextConfig);
272
301
  ```
273
302
 
274
- ```javascript fileName="babel.config.js"
275
- const {
276
- intlayerPurgeBabelPlugin,
277
- intlayerMinifyBabelPlugin,
278
- getPurgePluginOptions,
279
- getMinifyPluginOptions,
280
- } = require("@intlayer/babel");
303
+ ```typescript fileName="intlayer.config.ts"
304
+ import type { IntlayerConfig } from "intlayer";
281
305
 
282
- module.exports = {
283
- presets: ["next/babel"],
284
- plugins: [
285
- // Purge: usuwa nieużywane pola ze słowników z .intlayer/**/*.json
286
- [intlayerPurgeBabelPlugin, getPurgePluginOptions()],
287
- // Minify: skraca nazwy kluczy w polach w plikach JSON i kodzie źródłowym
288
- [intlayerMinifyBabelPlugin, getMinifyPluginOptions()],
289
- // Uwaga: intlayerOptimizeBabelPlugin NIE JEST TUTAJ POTRZEBNY, ponieważ
290
- // to @intlayer/swc obsługuje zastępowanie useIntlayer → useDictionary.
291
- ],
306
+ const config: IntlayerConfig = {
307
+ build: {
308
+ purge: true, // usuwa nieużywane pola treści z dołączonego JSON-a
309
+ minify: true, // zmienia klucze pól treści na krótkie aliasy
310
+ },
292
311
  };
312
+
313
+ export default config;
293
314
  ```
294
315
 
316
+ Podczas `next build` `withIntlayer` analizuje Twoje źródła, przepisuje skompilowane słowniki i przekazuje wynikowe tablice zmiany nazw pól do `@intlayer/swc`, które aktualizuje odpowiadające odwołania do właściwości w Twoim kodzie.
317
+
318
+ > Używaj asynchronicznego `withIntlayer`, a nie `withIntlayerSync`. Wariant synchroniczny nie uruchamia potoku analizy, więc purge i minifikacja nie mają z nim żadnego efektu.
319
+
320
+ > Purge i minifikacja działają tylko przy `next build` — potok optymalizacji jest wyłączony podczas `next dev`.
321
+
322
+ > Są też wyłączone, gdy skonfigurowano wywołujących z adapterów kompatybilności (`swcExtraCallers`, ustawiane przez pakiety kompatybilności takie jak `@intlayer/next-intl` czy `@intlayer/react-i18next`): te miejsca wywołań są niewidoczne dla analizatora użycia, więc purge usunąłby pola, które kod nadal odczytuje. Przepisywanie importów pozostaje aktywne.
323
+
324
+ **Wcześniejsze wersje (przed 9.2.1)** wymagały `@intlayer/babel` oraz pliku `babel.config.js` deklarującego `intlayerPurgeBabelPlugin` i `intlayerMinifyBabelPlugin`. Ten plik nie jest już potrzebny i można go usunąć.
325
+
295
326
  </Tab>
296
327
  <Tab value="vite">
297
328
 
@@ -447,6 +478,8 @@ export default config;
447
478
 
448
479
  > Krok dla minifikacji musi zostać oddalony w odstawkę, gdy Twoja opcja to `optimize` lub jeżeli udostępniasz systemowo `editor.enabled` i ustawiasz na domyślne `true` (wymuszone jest, aby pola trzymały na ten czas swe niezmącone relacje, dla potrzeb odpowiedniego renderowania Wizualnego Edytora).
449
480
 
481
+ > W Next.js minifikacja jest również pomijana, gdy `@intlayer/swc` nie jest zainstalowany albo nie może zostać załadowany (Next.js poniżej 16.1.0). Wtyczka to ta połowa, która przepisuje odwołania w kodzie źródłowym, więc zmiana nazw w słownikach bez niej pozostawiłaby kod odczytujący nazwy pól, które już nie istnieją.
482
+
450
483
  > Ten sam manewr odłożenia ma miejsce w słownikach przywoływanych jako typ opcji z użyciem `importMode: 'fetch'`, gdzie zawarte odpowiedzi napływają niezwłocznie dzięki połączonemu formatowi JSON. Gdyby zastosowano sztuczne przeinaczenie ze stron zewnętrznych, serwer stałby się bezużyteczny z perspektywy klienta i połącznie zostałoby połamane.
451
484
 
452
485
  ### Purging (Usuwanie Nieużytych Przestrzeni)
@@ -475,7 +508,7 @@ export default config;
475
508
  { "title": "…", "subtitle": "…" }
476
509
  ```
477
510
 
478
- > Mechanizm obalenia Purge opiera się głównie o pominięcia w wypadku kiedy brakuje `optimize` opcjonalnej flagi tudzież podczas zadeklarowania trybu pod system Visual Editor (ustawiając `editor.enabled` na rzecz trybu `true`).
511
+ > Mechanizm obalenia Purge opiera się głównie o pominięcia w wypadku kiedy brakuje `optimize` opcjonalnej flagi tudzież podczas zadeklarowania trybu pod system Visual Editor (ustawiając `editor.enabled` na rzecz trybu `true`). W Next.js jest dodatkowo pomijany, gdy `@intlayer/swc` jest niedostępny oraz gdy skonfigurowano wywołujących z adapterów kompatybilności.
479
512
 
480
513
  > Co rzadsze zjawiska również tyczą się tego obejścia - dla niemożności sprawdzenia wycinka czy pospolitych struktur dla `useIntlayer` - silnik bezbłędnie zablokuje akcję. Przykładowo dla wywołań w niejednoznacznych tablicach powiązanych metod bez destrukturyzacji by zachować słownikową formę naturalną.
481
514
 
@@ -13,6 +13,10 @@ keywords:
13
13
  - Intlayer
14
14
  - Next.js
15
15
  - Vite
16
+ slugs:
17
+ - doc
18
+ - concept
19
+ - live-sync
16
20
  history:
17
21
  - version: 9.0.0
18
22
  date: 2026-07-08
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  createdAt: 2025-11-25
3
- updatedAt: 2026-06-07
3
+ updatedAt: 2026-08-09
4
4
  title: Otimizando o Tamanho e a Performance do Bundle i18n
5
5
  description: Reduza o tamanho do bundle da sua aplicação otimizando o conteúdo de internacionalização (i18n). Aprenda como aproveitar o tree shaking e lazy loading para dicionários usando o Intlayer.
6
6
  keywords:
@@ -16,6 +16,12 @@ slugs:
16
16
  - concept
17
17
  - bundle-optimization
18
18
  history:
19
+ - version: 9.2.1
20
+ date: 2026-08-09
21
+ changes: "`purge` e `minify` agora funcionam no Next.js através do `@intlayer/swc` — nenhum `babel.config.js` necessário"
22
+ - version: 8.12.0
23
+ date: 2026-06-24
24
+ changes: "Listar os plugins Babel na ordem de pipeline exigida (extract → purge → minify → optimize) nas tabelas de referência"
19
25
  - version: 8.12.0
20
26
  date: 2026-06-07
21
27
  changes: "Adicionado `intlayerPurgeBabelPlugin` e `intlayerMinifyBabelPlugin` para Babel/Webpack; esclarecimento do pipeline de plugins"
@@ -191,12 +197,14 @@ As vertentes pautadas do ecossistema otimizado base pelo Intlayer consistem num
191
197
 
192
198
  Este ramo abrange puramente escopos direcionados e voltados ao processo em setups no núcleo interno de implementações em formato Webpack operando com arquivos predefinidos nas bases (como é o caso natural do Babel associado de base, Webpack modular customizado em sua integridade nativa do CRA entre outros propósitos da extensão `babel.config.js` ).
193
199
 
200
+ A tabela abaixo os lista na ordem de pipeline exigida (a mesma ordem em que devem aparecer no `babel.config.js`):
201
+
194
202
  | Funções do Plugin Base | Fatores Práticos Do Recurso E Suas Integrações Com Componentes |
195
203
  | :---------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
196
204
  | `intlayerExtractBabelPlugin` | Percorre todo núcleo do escopo com premissa modular ligando fatores associativos entre funções `.content.ts` com as propostas associadas à destinação em pastas `.intlayer/` |
197
- | `intlayerOptimizeBabelPlugin` | Adota premissas nativas mudando o sentido focado de `useIntlayer('key')` para abranger a otimizada base `useDictionary(hash)` gerindo implementações no escopo do `import` |
198
205
  | `intlayerPurgeBabelPlugin` | Mapeia e integra lógicas puramente atreladas a varreduras com intento final na premissa base de descartar os **campos sem uso das diretivas** com base final dos dicionários |
199
206
  | `intlayerMinifyBabelPlugin` | Transcreve sua **chave matriz base na nomeclatura compacta sob a extensão de referências nativas alfabéticas limitadas em seus núcleos** (`title` → `a`) sob suas origens JSON |
207
+ | `intlayerOptimizeBabelPlugin` | Adota premissas nativas mudando o sentido focado de `useIntlayer('key')` para abranger a otimizada base `useDictionary(hash)` gerindo implementações no escopo do `import` |
200
208
 
201
209
  > **Cuidado Atrelado Com A Ordem Da Execução Preestabelecida Do Arquivo Principal:** O esquema atrelado com os focos das bases de expurgo (purge) e premissas curtas em definições (minify) tendem inevitavelmente estarem e persistirem em um nível que antecede de antemão e antes que se executem e apliquem o método referencial em otimização (`optimize`) na base primária do arquivo nativo `babel.config.js`. Se o optimize operar logo em instâncias prematuras o registro das senhas chave tendem a se omitir não proporcionando suporte base o bastante nas partes do escopo e apagando registros nativos sobre premissas das matrizes JSON que deverão ser mapeadas na função da execução seguinte.
202
210
 
@@ -205,9 +213,9 @@ Tais modelos adquirem opções e propósitos associados com integrações perant
205
213
  | Helpers de Opcionais | Integração Destinada Relacionada Ao Base |
206
214
  | :--------------------------- | :--------------------------------------- |
207
215
  | `getExtractPluginOptions()` | `intlayerExtractBabelPlugin` |
208
- | `getOptimizePluginOptions()` | `intlayerOptimizeBabelPlugin` |
209
216
  | `getPurgePluginOptions()` | `intlayerPurgeBabelPlugin` |
210
217
  | `getMinifyPluginOptions()` | `intlayerMinifyBabelPlugin` |
218
+ | `getOptimizePluginOptions()` | `intlayerOptimizeBabelPlugin` |
211
219
 
212
220
  ### O Setup Por Trás De Vite (`vite-intlayer`)
213
221
 
@@ -220,6 +228,20 @@ O usuário da base focada na plataforma gerada do esquema no Vite não fará man
220
228
  | Dictionary minify | Base análoga e integrada de premissas com ligações nos escritos pautando referências no molde JSON nativo voltada do `intlayerMinifyBabelPlugin` |
221
229
  | Babel transform | Associa parâmetros no suporte transformativo que atua nas esferas associativas dos diretórios voltados do renome natural em conjunto focado ao `intlayerMinifyBabelPlugin` e também ao respectivo processo preestabelecido da função modular `intlayerOptimizeBabelPlugin` |
222
230
 
231
+ ### Plugin SWC (`@intlayer/swc`)
232
+
233
+ Os usuários do Next.js também **nunca configuram isto diretamente**. Desde a **v9.2.1**, o `withIntlayer()` no `next.config.ts` executa todo o pipeline — purge, minificação e reescrita de imports — apenas a partir das flags `build.purge` e `build.minify`.
234
+
235
+ O trabalho é dividido em dois, porque um plugin Wasm do SWC transforma um arquivo por vez e não tem acesso ao sistema de arquivos:
236
+
237
+ | Passagem | Onde é executada | O que faz |
238
+ | :------------------------------------------------- | :------------------------------- | :----------------------------------------------------------------------------------------------------- |
239
+ | Análise de uso + purge/minificação do JSON | Node, dentro de `withIntlayer()` | Lê cada arquivo-fonte de componente, reescreve `.intlayer/**/*.json` e produz as tabelas de renomeação |
240
+ | Reescrita do código-fonte (`content.title` → `.a`) | `@intlayer/swc` (Wasm) | Aplica as tabelas de renomeação aos acessos de propriedade correspondentes no seu código |
241
+ | Reescrita de imports (`useIntlayer` → dict) | `@intlayer/swc` (Wasm) | Igual ao `intlayerOptimizeBabelPlugin` |
242
+
243
+ Decidir _quais_ campos não são usados e _qual_ alias cada um recebe exige estado entre arquivos e E/S de arquivos, então essa metade roda no Node; o plugin SWC recebe apenas as tabelas resultantes.
244
+
223
245
  ## Etapas Em Modos Variados (Plataformas)
224
246
 
225
247
  <Tabs>
@@ -227,10 +249,12 @@ O usuário da base focada na plataforma gerada do esquema no Vite não fará man
227
249
 
228
250
  ### Next.js
229
251
 
230
- Os propósitos focais relativos com ecossistemas formatados a propósitos otimizados necessitam aderirem sobre implementações preteridas nativas associadas aos componentes pautados em referências no padrão construtivo em `@intlayer/swc`. Esse foco ocorre puramente de maneira interna pois essa vertente pautada trabalha perante construções atreladas sobre formatos definidos sob escopo formatado nativamente pelo formato modular `SWC`.
252
+ O Next.js requer o plugin `@intlayer/swc`, porque o Next.js usa SWC para as builds. Desde a **v9.2.1**, este único pacote cobre todo o pipeline otimização (reescrita de imports), purge e minificação.
231
253
 
232
254
  > Este recurso opera de maneira indireta preestabelecida na função que o construtor opera base com propósitos sem estarem enquadrados nativamente uma vez construtor `SWC` e sua arquitetura encontrarem cenários passíveis ainda experimentais por propósitos do projeto base no esquema das funcionalidades e das perspectivas. Tais perspectivas podem tender a serem diferentes em longo prazo por propostas alheias e afins.
233
255
 
256
+ > **Next.js 16.1.0 é a versão mínima.** É a primeira versão construída sobre a ABI de plugins Wasm do SWC compatível com versões futuras; versões anteriores rejeitam o plugin. O `withIntlayer` lê a sua versão do Next.js e simplesmente não registra o plugin abaixo da 16.1.0 — essas builds continuam a ser bem-sucedidas, apenas rodam sem a otimização de bundle.
257
+
234
258
  <Tabs>
235
259
  <Tab value="npm">
236
260
 
@@ -265,32 +289,40 @@ intlayer-swc-plugin = "*"
265
289
 
266
290
  Os processos automatizam os engajamentos atrelando sua extensão integrativa assim em propostas isoladas.
267
291
 
268
- O panorama atua mediante referências relacionadas do **purge e também atrelado a extensões minificadas (minify)** para proporcionar ligações atreladas mediante inserção atrelada com apoio referencial focado de `@intlayer/babel`. Como ocorrem as ligações base no transformativo `SWC` os plugins Babel operam em vias em propósitos associados com pre-procedimentos base.
292
+ As passagens de **purge e minificação** (remoção e renomeação de campos) não exigem nenhum pacote adicional nem `babel.config.js`. Envolva a sua configuração com `withIntlayer` e ative as flags no `intlayer.config.ts`:
269
293
 
270
- ```bash packageManager="npm"
271
- npm install -D @intlayer/babel
294
+ ```typescript fileName="next.config.ts"
295
+ import { withIntlayer } from "next-intlayer/server";
296
+ import type { NextConfig } from "next";
297
+
298
+ const nextConfig: NextConfig = {/* sua configuração */};
299
+
300
+ export default withIntlayer(nextConfig);
272
301
  ```
273
302
 
274
- ```javascript fileName="babel.config.js"
275
- const {
276
- intlayerPurgeBabelPlugin,
277
- intlayerMinifyBabelPlugin,
278
- getPurgePluginOptions,
279
- getMinifyPluginOptions,
280
- } = require("@intlayer/babel");
303
+ ```typescript fileName="intlayer.config.ts"
304
+ import type { IntlayerConfig } from "intlayer";
281
305
 
282
- module.exports = {
283
- presets: ["next/babel"],
284
- plugins: [
285
- // Purge: Otimiza seu diretório na base focada sem o envolvimento associativo sobre chaves nulas JSON formatadas nas origens de suporte ".intlayer/**/*.json"
286
- [intlayerPurgeBabelPlugin, getPurgePluginOptions()],
287
- // Minify: Trata chaves nativas da função JSON diminuindo na transcrição compacta da implementação
288
- [intlayerMinifyBabelPlugin, getMinifyPluginOptions()],
289
- // Note: Foco sem amparo de obrigatoriedade perante a relação e ligações do `@intlayer/swc` por ser passível ao suporte da formatação relativa focado no formato com rescrição no `useIntlayer` em vias perante `useDictionary`.
290
- ],
306
+ const config: IntlayerConfig = {
307
+ build: {
308
+ purge: true, // remove campos de conteúdo não usados do JSON empacotado
309
+ minify: true, // renomeia as chaves dos campos para aliases curtos
310
+ },
291
311
  };
312
+
313
+ export default config;
292
314
  ```
293
315
 
316
+ Durante o `next build`, o `withIntlayer` analisa seus fontes, reescreve os dicionários compilados e repassa as tabelas de renomeação resultantes ao `@intlayer/swc`, que atualiza os acessos de propriedade correspondentes no seu código.
317
+
318
+ > Use o `withIntlayer` assíncrono, não o `withIntlayerSync`. A variante síncrona não executa o pipeline de análise, então purge e minificação não têm efeito com ela.
319
+
320
+ > Purge e minificação são executados apenas no `next build` — o pipeline de otimização fica desligado durante o `next dev`.
321
+
322
+ > Eles também são desativados quando chamadores de adaptadores de compatibilidade estão configurados (`swcExtraCallers`, definidos pelos pacotes de compatibilidade como `@intlayer/next-intl` ou `@intlayer/react-i18next`): esses pontos de chamada são invisíveis para o analisador de uso, então o purge removeria campos que o código ainda lê. A reescrita de imports permanece ativa.
323
+
324
+ **Versões anteriores (antes da 9.2.1)** exigiam `@intlayer/babel` e um `babel.config.js` declarando `intlayerPurgeBabelPlugin` e `intlayerMinifyBabelPlugin`. Esse arquivo não é mais necessário e pode ser excluído.
325
+
294
326
  </Tab>
295
327
  <Tab value="vite">
296
328
 
@@ -442,6 +474,8 @@ export default config;
442
474
 
443
475
  > Os propósitos associativos das exclusões nas transformações focando nas extensões da minimização acabam por pautar no pulo perante processos integrando false no seu escopo no otimizador e false focando nos diretórios `editor.enabled`.
444
476
 
477
+ > No Next.js, a minificação também é ignorada quando o `@intlayer/swc` não está instalado ou não pode ser carregado (Next.js abaixo da 16.1.0). O plugin é a metade que reescreve os acessos no código-fonte, então renomear os dicionários sem ele deixaria seu código lendo nomes de campos que não existem mais.
478
+
445
479
  > Dicionários perante processos focados base do tipo no fetch (sob escopo formatado da extensão da variável no método `importMode: 'fetch'`) não são minificados a título em evitar problemas focados na sua essência nativa.
446
480
 
447
481
  ### Foco Modular Constante Relativo Em Extensões (Exclusões Focadas)
@@ -470,7 +504,7 @@ export default config;
470
504
  { "title": "…", "subtitle": "…" }
471
505
  ```
472
506
 
473
- > Processos atrelados pautando focos purificados são limitados atrelados nos parâmetros atrelados nos propósitos e diretórios de optimize em restrições do false no otimizador integrando ao formato modular no limite focando no suporte das formatações base false nos diretórios da edição e formatos no construto formatado da extensão construtiva.
507
+ > Processos atrelados pautando focos purificados são limitados atrelados nos parâmetros atrelados nos propósitos e diretórios de optimize em restrições do false no otimizador integrando ao formato modular no limite focando no suporte das formatações base false nos diretórios da edição e formatos no construto formatado da extensão construtiva. No Next.js ele é adicionalmente ignorado quando o `@intlayer/swc` está indisponível e quando chamadores de adaptadores de compatibilidade estão configurados.
474
508
 
475
509
  > Processos perante o uso na purificação também são suspensos perante focos no método nativo que limitam análises do suporte da base com dados referenciados da função de predefinições e diretrizes voltadas atrelando propósitos de extensão.
476
510
 
@@ -13,6 +13,10 @@ keywords:
13
13
  - Intlayer
14
14
  - Next.js
15
15
  - Vite
16
+ slugs:
17
+ - doc
18
+ - concept
19
+ - live-sync
16
20
  history:
17
21
  - version: 9.0.0
18
22
  date: 2026-07-08