next-intlayer 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.
- package/dist/cjs/server/prepareSwcOptimization.cjs +190 -0
- package/dist/cjs/server/prepareSwcOptimization.cjs.map +1 -0
- package/dist/cjs/server/swcPluginCompatibility.cjs +57 -0
- package/dist/cjs/server/swcPluginCompatibility.cjs.map +1 -0
- package/dist/cjs/server/withIntlayer.cjs +64 -17
- package/dist/cjs/server/withIntlayer.cjs.map +1 -1
- package/dist/esm/server/prepareSwcOptimization.mjs +185 -0
- package/dist/esm/server/prepareSwcOptimization.mjs.map +1 -0
- package/dist/esm/server/swcPluginCompatibility.mjs +55 -0
- package/dist/esm/server/swcPluginCompatibility.mjs.map +1 -0
- package/dist/esm/server/withIntlayer.mjs +64 -19
- package/dist/esm/server/withIntlayer.mjs.map +1 -1
- package/dist/types/server/prepareSwcOptimization.d.ts +67 -0
- package/dist/types/server/prepareSwcOptimization.d.ts.map +1 -0
- package/dist/types/server/swcPluginCompatibility.d.ts +52 -0
- package/dist/types/server/swcPluginCompatibility.d.ts.map +1 -0
- package/dist/types/server/withIntlayer.d.ts +12 -1
- package/dist/types/server/withIntlayer.d.ts.map +1 -1
- package/package.json +10 -9
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { SwcExtraCallerConfig } from "@intlayer/config/callers";
|
|
2
|
+
import { GetConfigurationOptions } from "@intlayer/config/node";
|
|
3
|
+
import { SerializedFieldRenameMap } from "@intlayer/babel";
|
|
4
|
+
import { IntlayerConfig } from "@intlayer/types/config";
|
|
5
|
+
import { Dictionary } from "@intlayer/types/dictionary";
|
|
6
|
+
//#region src/server/prepareSwcOptimization.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Field-rename tables keyed by dictionary key, forwarded to the
|
|
9
|
+
* `@intlayer/swc` plugin's `fieldRenameMap` option.
|
|
10
|
+
*/
|
|
11
|
+
type FieldRenameMapByDictionaryKey = Record<string, SerializedFieldRenameMap>;
|
|
12
|
+
/** Verbosity forwarded to the `@intlayer/swc` plugin's `logLevel` option. */
|
|
13
|
+
type SwcLogLevel = 'off' | 'info' | 'debug';
|
|
14
|
+
/**
|
|
15
|
+
* Resolves the verbosity the `@intlayer/swc` plugin should report at.
|
|
16
|
+
*
|
|
17
|
+
* Off unless {@link SWC_LOG_LEVEL_ENV_VAR} asks for tracing: `log.mode` governs
|
|
18
|
+
* the purge and minify reporting, which the pipeline emits in Node so the
|
|
19
|
+
* Next.js build reads the same as the Vite one.
|
|
20
|
+
*/
|
|
21
|
+
declare const resolveSwcLogLevel: (intlayerConfig: IntlayerConfig) => SwcLogLevel;
|
|
22
|
+
/**
|
|
23
|
+
* Whether the purge / minify pipeline can run at all, i.e. whether a usable
|
|
24
|
+
* `@intlayer/babel` is resolvable from the project.
|
|
25
|
+
*
|
|
26
|
+
* Used by `withIntlayer` to keep the build report honest: announcing
|
|
27
|
+
* `Dictionary minification enabled` while the pipeline cannot load would describe a
|
|
28
|
+
* pass that never happens.
|
|
29
|
+
*/
|
|
30
|
+
declare const getIsPurgePipelineAvailable: (intlayerConfig: IntlayerConfig) => boolean;
|
|
31
|
+
type PrepareSwcOptimizationParams = {
|
|
32
|
+
/** Options forwarded to the intlayer configuration loader. */
|
|
33
|
+
configOptions?: GetConfigurationOptions;
|
|
34
|
+
/** Pre-loaded dictionaries, to avoid a second `getDictionaries` call. */
|
|
35
|
+
dictionaries?: Dictionary[];
|
|
36
|
+
/** Compat-adapter callers declared by the consuming plugin, if any. */
|
|
37
|
+
swcExtraCallers?: SwcExtraCallerConfig[];
|
|
38
|
+
/**
|
|
39
|
+
* Whether the `@intlayer/swc` plugin is installed *and* the resolved Next.js
|
|
40
|
+
* version can load it. False leaves the compiled dictionaries untouched.
|
|
41
|
+
*/
|
|
42
|
+
isSwcPluginUsable: boolean;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Prepares the parts of the build optimisation the `@intlayer/swc` plugin
|
|
46
|
+
* cannot do itself, and returns the field-rename tables it needs.
|
|
47
|
+
*
|
|
48
|
+
* Removing unused content fields (`build.purge`) and assigning short field
|
|
49
|
+
* aliases (`build.minify`) require reading every component source file and
|
|
50
|
+
* rewriting the compiled dictionary JSON — file I/O and cross-file state that a
|
|
51
|
+
* per-file Wasm transform has no access to. That analysis therefore runs here,
|
|
52
|
+
* in Node, through `@intlayer/babel`; the plugin only receives the resulting
|
|
53
|
+
* tables and rewrites the matching source accesses
|
|
54
|
+
* (`content.title` → `content.a`).
|
|
55
|
+
*
|
|
56
|
+
* The work is coordinated by a sentinel file: Next.js loads `next.config.*` in
|
|
57
|
+
* several processes per build, and running the minify pass twice would derive
|
|
58
|
+
* the aliases from the already-renamed dictionaries. Processes that lose the
|
|
59
|
+
* race read the tables the winner cached.
|
|
60
|
+
*
|
|
61
|
+
* @returns The field-rename tables, keyed by dictionary key. Empty when the
|
|
62
|
+
* pipeline is disabled, unavailable, or renamed nothing.
|
|
63
|
+
*/
|
|
64
|
+
declare const prepareSwcOptimization: (intlayerConfig: IntlayerConfig, params: PrepareSwcOptimizationParams) => Promise<FieldRenameMapByDictionaryKey>;
|
|
65
|
+
//#endregion
|
|
66
|
+
export { FieldRenameMapByDictionaryKey, SwcLogLevel, getIsPurgePipelineAvailable, prepareSwcOptimization, resolveSwcLogLevel };
|
|
67
|
+
//# sourceMappingURL=prepareSwcOptimization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepareSwcOptimization.d.ts","names":[],"sources":["../../../src/server/prepareSwcOptimization.ts"],"mappings":";;;;;;;;;;KAsBY,gCAAgC,eAE1C;;KAIU;;;;;;;;cAoDC,qBAAkB,gBACb,mBACf;;;;;;;;;cAmGU,8BAA2B,gBACtB;KAkGb;;EAEH,gBAAgB;;EAEhB,eAAe;;EAEf,kBAAkB;;;;;EAKlB;;;;;;;;;;;;;;;;;;;;;;cAuBW,yBAAsB,gBACjB,gBAAc,QACtB,iCACP,QAAQ"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
//#region src/server/swcPluginCompatibility.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Oldest Next.js release whose bundled SWC can load the `@intlayer/swc` Wasm
|
|
4
|
+
* plugin.
|
|
5
|
+
*
|
|
6
|
+
* A Wasm plugin only loads in a host that speaks its `swc_ecma_ast` schema.
|
|
7
|
+
* Next.js 16.1.0 is the first release built on SWC's forward-compatible plugin
|
|
8
|
+
* ABI — the AST travels as self-describing CBOR instead of rkyv, so a plugin
|
|
9
|
+
* compiled against an older `swc_core` keeps loading in newer hosts. Every
|
|
10
|
+
* earlier release uses the rkyv ABI, which requires an exact schema match and
|
|
11
|
+
* rejects the plugin outright, failing the build with `failed to invoke
|
|
12
|
+
* plugin`.
|
|
13
|
+
*
|
|
14
|
+
* Verified by driving `transformSync` on the shipped `@next/swc` binaries with
|
|
15
|
+
* the plugin attached:
|
|
16
|
+
*
|
|
17
|
+
* | Next.js | swc_ecma_ast | plugin loads |
|
|
18
|
+
* | ------- | ------------ | ------------ |
|
|
19
|
+
* | 14.2.x | 0.112.7 | no |
|
|
20
|
+
* | 15.5.x | 14.0.0 | no |
|
|
21
|
+
* | 16.0.x | 16.0.0 | no |
|
|
22
|
+
* | 16.1.x | 19.0.0 | yes |
|
|
23
|
+
* | 16.2.x | 20.0.1 | yes |
|
|
24
|
+
* | 16.3.x | 25.0.0 | yes |
|
|
25
|
+
*
|
|
26
|
+
* Keep in sync with the `swc_core` pin in
|
|
27
|
+
* `packages/@intlayer/swc/Cargo.toml`: the plugin must stay on the
|
|
28
|
+
* `swc_ecma_ast` version this Next.js release ships, never a newer one, or the
|
|
29
|
+
* floor moves up with it.
|
|
30
|
+
*/
|
|
31
|
+
declare const MINIMUM_SWC_PLUGIN_NEXT_VERSION = "16.1.0";
|
|
32
|
+
/**
|
|
33
|
+
* Whether `nextVersion` bundles an SWC able to load the `@intlayer/swc` Wasm
|
|
34
|
+
* plugin.
|
|
35
|
+
*
|
|
36
|
+
* Pre-releases of a supported version (`16.1.0-canary.4`, `16.3.0-preview.5`)
|
|
37
|
+
* count as supported: they track the release they lead to, and opting into a
|
|
38
|
+
* canary already means opting into its churn.
|
|
39
|
+
*
|
|
40
|
+
* @param nextVersion - Version string read from the project's `next/package.json`.
|
|
41
|
+
* @returns `true` when the plugin can be registered in `experimental.swcPlugins`.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* getIsSwcPluginSupported('16.3.0'); // true
|
|
46
|
+
* getIsSwcPluginSupported('15.5.18'); // false
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
declare const getIsSwcPluginSupported: (nextVersion: string) => boolean;
|
|
50
|
+
//#endregion
|
|
51
|
+
export { MINIMUM_SWC_PLUGIN_NEXT_VERSION, getIsSwcPluginSupported };
|
|
52
|
+
//# sourceMappingURL=swcPluginCompatibility.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swcPluginCompatibility.d.ts","names":[],"sources":["../../../src/server/swcPluginCompatibility.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA+Ba;;;;;;;;;;;;;;;;;;cAmBA,0BAAuB"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { FieldRenameMapByDictionaryKey } from "./prepareSwcOptimization.js";
|
|
2
|
+
import { MINIMUM_SWC_PLUGIN_NEXT_VERSION, getIsSwcPluginSupported } from "./swcPluginCompatibility.js";
|
|
1
3
|
import { NextConfig } from "next";
|
|
2
4
|
import { SwcExtraCallerConfig } from "@intlayer/config/callers";
|
|
3
5
|
import { GetConfigurationOptions } from "@intlayer/config/node";
|
|
@@ -5,6 +7,15 @@ import { GetConfigurationOptions } from "@intlayer/config/node";
|
|
|
5
7
|
type WithIntlayerOptions = GetConfigurationOptions & {
|
|
6
8
|
enableTurbopack?: boolean;
|
|
7
9
|
swcExtraCallers?: SwcExtraCallerConfig[];
|
|
10
|
+
/**
|
|
11
|
+
* Field-rename tables produced by the purge / minify pipeline, forwarded to
|
|
12
|
+
* the `@intlayer/swc` plugin so it rewrites source accesses to match the
|
|
13
|
+
* renamed dictionaries.
|
|
14
|
+
*
|
|
15
|
+
* @internal Set by {@link withIntlayer}; `withIntlayerSync` on its own runs
|
|
16
|
+
* no dictionary rewrite, so it leaves this unset and no rename is applied.
|
|
17
|
+
*/
|
|
18
|
+
fieldRenameMap?: FieldRenameMapByDictionaryKey;
|
|
8
19
|
};
|
|
9
20
|
/**
|
|
10
21
|
* A Next.js plugin that adds the intlayer configuration to the webpack configuration
|
|
@@ -35,5 +46,5 @@ declare const withIntlayerSync: <T extends Partial<NextConfig>>(nextConfig?: T,
|
|
|
35
46
|
*/
|
|
36
47
|
declare const withIntlayer: <T extends NextConfig | Partial<NextConfig>>(nextConfig?: T | Promise<T>, configOptions?: WithIntlayerOptions) => Promise<NextConfig & T>;
|
|
37
48
|
//#endregion
|
|
38
|
-
export { withIntlayer, withIntlayerSync };
|
|
49
|
+
export { MINIMUM_SWC_PLUGIN_NEXT_VERSION, getIsSwcPluginSupported, withIntlayer, withIntlayerSync };
|
|
39
50
|
//# sourceMappingURL=withIntlayer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withIntlayer.d.ts","names":[],"sources":["../../../src/server/withIntlayer.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"withIntlayer.d.ts","names":[],"sources":["../../../src/server/withIntlayer.ts"],"mappings":";;;;;;KA4XK,sBAAsB;EACzB;EACA,kBAAkB;;;;;;;;;EAUlB,iBAAiB;;;;;;;;;;;;;cAuDN,mBAAoB,UAAU,QAAQ,aAAW,aAChD,GAAC,gBACG,wBACf,aAAa;;;;;;;;;;;;;;;;cA4QH,eAAsB,UAAU,aAAa,QAAQ,aAAW,aAC/D,IAAI,QAAQ,IAAE,gBACV,wBACf,QAAQ,aAAa"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-intlayer",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.3.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Simplify internationalization i18n in Next.js with context providers, hooks, locale detection, and multilingual content integration.",
|
|
6
6
|
"keywords": [
|
|
@@ -133,18 +133,19 @@
|
|
|
133
133
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
134
134
|
},
|
|
135
135
|
"dependencies": {
|
|
136
|
-
"@intlayer/config": "9.
|
|
137
|
-
"@intlayer/core": "9.
|
|
138
|
-
"@intlayer/dictionaries-entry": "9.
|
|
139
|
-
"@intlayer/engine": "9.
|
|
140
|
-
"@intlayer/types": "9.
|
|
141
|
-
"@intlayer/webpack": "9.
|
|
136
|
+
"@intlayer/config": "9.3.0",
|
|
137
|
+
"@intlayer/core": "9.3.0",
|
|
138
|
+
"@intlayer/dictionaries-entry": "9.3.0",
|
|
139
|
+
"@intlayer/engine": "9.3.0",
|
|
140
|
+
"@intlayer/types": "9.3.0",
|
|
141
|
+
"@intlayer/webpack": "9.3.0",
|
|
142
142
|
"defu": "6.1.7",
|
|
143
143
|
"node-loader": "2.1.0",
|
|
144
|
-
"react-intlayer": "9.
|
|
144
|
+
"react-intlayer": "9.3.0"
|
|
145
145
|
},
|
|
146
146
|
"devDependencies": {
|
|
147
|
-
"@
|
|
147
|
+
"@intlayer/babel": "9.3.0",
|
|
148
|
+
"@types/node": "26.2.0",
|
|
148
149
|
"@types/react": ">=16.0.0",
|
|
149
150
|
"@types/react-dom": ">=16.0.0",
|
|
150
151
|
"@utils/ts-config": "1.0.4",
|