vite-intlayer 9.3.2 → 9.3.3

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.
@@ -0,0 +1,88 @@
1
+ import { IntlayerConfig } from "@intlayer/types/config";
2
+ import { Plugin } from "vite";
3
+ //#region src/intlayerChunkPlugin.d.ts
4
+ /**
5
+ * Module-graph accessor Rolldown passes to a chunk-name function.
6
+ *
7
+ * Declared structurally rather than imported from `rolldown` so this plugin
8
+ * keeps working against the Rolldown bundled inside Vite, whose types are not
9
+ * re-exported.
10
+ */
11
+ type ChunkingContext = {
12
+ getModuleInfo: (moduleId: string) => ModuleGraphNode | null;
13
+ };
14
+ type ModuleGraphNode = {
15
+ id: string;
16
+ isEntry: boolean;
17
+ /** Ids of the modules that statically `import` this one. */
18
+ importers: string[];
19
+ /** Ids of the modules that reach this one through `import()`. */
20
+ dynamicImporters: string[];
21
+ };
22
+ /** A per-locale dictionary chunk, identified from its module id. */
23
+ type DictionaryModule = {
24
+ key: string;
25
+ locale: string;
26
+ };
27
+ /**
28
+ * Builds the parser that recognises a per-locale dictionary chunk emitted in
29
+ * `dynamic` import mode.
30
+ *
31
+ * The layout is read relative to `dynamicDictionariesDir` rather than matched
32
+ * anywhere in the path, so an application file that happens to sit under its own
33
+ * `json/<something>/<something>.json` cannot be mistaken for a dictionary.
34
+ * Everything between the key and the locale is a qualifier dimension
35
+ * (collections, variants), which is why the middle segments are skipped instead
36
+ * of being required to be absent.
37
+ *
38
+ * @param dynamicDictionariesDir - Absolute, POSIX-normalized dictionaries root.
39
+ * @returns Parser returning the key and locale, or `null` for any other module.
40
+ */
41
+ declare const createDictionaryModuleParser: (dynamicDictionariesDir: string) => ((moduleId: string) => DictionaryModule | null);
42
+ /** Turns a boundary module id into a readable chunk-name fragment. */
43
+ declare const toBoundaryName: (moduleId: string) => string;
44
+ /**
45
+ * Walks up the import graph from a dictionary JSON to the code-split boundaries
46
+ * that reach it.
47
+ *
48
+ * A module pulled in through `import()` — a `React.lazy` section, a split
49
+ * route — begins its own chunk, so it is the unit whose dictionaries should
50
+ * travel together: one request per Suspense boundary rather than one per
51
+ * dictionary. The walk deliberately starts from the JSON's importers rather
52
+ * than the JSON itself, because *every* dictionary is reached through
53
+ * `import()` and would otherwise be read as its own boundary.
54
+ *
55
+ * @returns Boundary ids reaching this dictionary, empty when the graph is
56
+ * unavailable (the module was pruned, or resolution failed).
57
+ */
58
+ declare const resolveBoundaries: (jsonModuleId: string, context: ChunkingContext) => string[];
59
+ /**
60
+ * Groups dynamically imported dictionaries by the code-split boundary that
61
+ * consumes them, so each lazily loaded page or section fetches its content in
62
+ * a single request instead of one per dictionary.
63
+ *
64
+ * Without this, `importMode: 'dynamic'` emits a chunk per dictionary per
65
+ * locale. A page assembled from many components then issues dozens of ~3 KB
66
+ * requests, and because each is discovered only once its consumer has
67
+ * executed, they land in the last wave of the request waterfall — page text
68
+ * arrives after everything else.
69
+ *
70
+ * Switching to `importMode: 'static'` would collapse those requests but inline
71
+ * every locale into the bundle, which does not scale past a handful of
72
+ * languages. Grouping keeps the per-locale split and removes the fragmentation.
73
+ *
74
+ * Dictionaries reached from more than one boundary are placed in a shared
75
+ * chunk, so no page ships another page's content and the bytes are not
76
+ * duplicated across chunks.
77
+ *
78
+ * Because a boundary's dictionaries share one chunk, warming that chunk warms
79
+ * the whole boundary in a single request — which is why the top-level-await
80
+ * preload (`intlayerPreload`) costs one request per boundary rather than one
81
+ * per dictionary, without any page loading content belonging to another.
82
+ *
83
+ * @param intlayerConfig - Resolved Intlayer configuration.
84
+ */
85
+ declare const intlayerChunk: (intlayerConfig: IntlayerConfig) => Plugin;
86
+ //#endregion
87
+ export { ChunkingContext, DictionaryModule, ModuleGraphNode, createDictionaryModuleParser, intlayerChunk, resolveBoundaries, toBoundaryName };
88
+ //# sourceMappingURL=intlayerChunkPlugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intlayerChunkPlugin.d.ts","names":[],"sources":["../../src/intlayerChunkPlugin.ts"],"mappings":";;;;;;;;;;KAaY;EACV,gBAAgB,qBAAqB;;KAG3B;EACV;EACA;;EAEA;;EAEA;;;KAIU;EACV;EACA;;;;;;;;;;;;;;;;cAiBW,+BAA4B,qCAEpC,qBAAqB;;cAuCb,iBAAc;;;;;;;;;;;;;;;cAuBd,oBAAiB,sBACR,SACX;;;;;;;;;;;;;;;;;;;;;;;;;;;cAyDE,gBAAa,gBAAoB,mBAAiB"}
@@ -40,7 +40,7 @@ type H3EventLike = {
40
40
  * and Deno — where `event.node` is `undefined` and `fromNodeMiddleware` crashes with
41
41
  * "undefined is not an object (evaluating 'event.node.req')".
42
42
  *
43
- * It bridges h3 v2 events to the Node.js-style `createIntlayerProxyHandler` middleware
43
+ * It bridges h3 v2 events to the Node.js-style proxy middleware
44
44
  * via lightweight IncomingMessage / ServerResponse shims:
45
45
  *
46
46
  * - **Redirect** (301 / 5xx): builds a Web API `Response` and returns it — Nitro sends
@@ -1 +1 @@
1
- {"version":3,"file":"intlayerNitroHandler.d.ts","names":[],"sources":["../../src/intlayerNitroHandler.ts"],"mappings":";;;;;;;;;KAcK;;;;;WAKM;;;;;;EAMT,KAAK;;;;;WAKI,SAAS;;;;;WAKT;aACE,SAAS;;;;;;;;;;;;;;;;;;;;;;iBAmCA,SAAA,OAAO,cAAc,QAAQ"}
1
+ {"version":3,"file":"intlayerNitroHandler.d.ts","names":[],"sources":["../../src/intlayerNitroHandler.ts"],"mappings":";;;;;;;;;KAyBK;;;;;WAKM;;;;;;EAMT,KAAK;;;;;WAKI,SAAS;;;;;WAKT;aACE,SAAS;;;;;;;;;;;;;;;;;;;;;;iBAmCA,SAAA,OAAO,cAAc,QAAQ"}
@@ -1 +1 @@
1
- {"version":3,"file":"intlayerPlugin.d.ts","names":[],"sources":["../../src/intlayerPlugin.ts"],"mappings":";;;;;;;;;;;;;;KAyCY,wBAAwB;;;;;;;;EAQlC,gBAAgB;;;;;;;;;;;;;;;EAgBhB,QAAQ,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;cA0BF,iBAAc,gBACT,0BACf;;;;;;;;;;;cAuNU,iBAAQ;;;;;;;;;;;;;cAaR,uBAAc"}
1
+ {"version":3,"file":"intlayerPlugin.d.ts","names":[],"sources":["../../src/intlayerPlugin.ts"],"mappings":";;;;;;;;;;;;;;KA2CY,wBAAwB;;;;;;;;EAQlC,gBAAgB;;;;;;;;;;;;;;;EAgBhB,QAAQ,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;cA0BF,iBAAc,gBACT,0BACf;;;;;;;;;;;cAgOU,iBAAQ;;;;;;;;;;;;;cAaR,uBAAc"}
@@ -0,0 +1,34 @@
1
+ import { IntlayerConfig } from "@intlayer/types/config";
2
+ import { Plugin } from "vite";
3
+ //#region src/intlayerPreloadPlugin.d.ts
4
+ /**
5
+ * Makes dictionaries load with the chunk that needs them, instead of being
6
+ * requested once that chunk renders.
7
+ *
8
+ * In `importMode: 'dynamic'` a component reads its dictionary through a loader
9
+ * map and suspends while the matching chunk is fetched. The fetch is only
10
+ * discovered once the component executes, so it lands at the very end of the
11
+ * request waterfall and every navigation flashes the pending fallback before
12
+ * any text appears — the cost that used to push applications towards
13
+ * `importMode: 'static'`, which inlines every locale into the bundle.
14
+ *
15
+ * Starting that fetch from the generated entry point itself moves it forward to
16
+ * module-evaluation time: it leaves with the chunk that needs it — on a
17
+ * router's `import()` of a route, including a preload on hover — instead of
18
+ * waiting for the consuming component to execute. By the time the read happens
19
+ * the content is usually already there and the render is synchronous.
20
+ *
21
+ * The fetch is deliberately not awaited at the top level. Doing so would make
22
+ * the entry point an async module and hold up every chunk that imports it,
23
+ * which permanently strands `React.lazy` boundaries resolving during hydration
24
+ * on their fallback — see `addDynamicEntryPreload`.
25
+ *
26
+ * Complements the grouping in `intlayerChunk`: grouping decides how many
27
+ * requests a boundary makes, this decides when they start.
28
+ *
29
+ * @param intlayerConfig - Resolved Intlayer configuration.
30
+ */
31
+ declare const intlayerPreload: (intlayerConfig: IntlayerConfig) => Plugin;
32
+ //#endregion
33
+ export { intlayerPreload };
34
+ //# sourceMappingURL=intlayerPreloadPlugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intlayerPreloadPlugin.d.ts","names":[],"sources":["../../src/intlayerPreloadPlugin.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAmDa,kBAAe,gBAAoB,mBAAiB"}
@@ -0,0 +1,50 @@
1
+ import { IntlayerConfig } from "@intlayer/types/config";
2
+ import { IncomingMessage, ServerResponse } from "node:http";
3
+ //#region src/intlayerProxyHandler.d.ts
4
+ /**
5
+ * A Node.js-compatible Connect middleware function.
6
+ * Compatible with Vite dev/preview server, Node.js http, Express, and h3's
7
+ * `fromNodeMiddleware` wrapper for Nitro/TanStack Start production use.
8
+ */
9
+ type NodeMiddleware = (req: IncomingMessage, res: ServerResponse<IncomingMessage>, next: () => void) => void;
10
+ type IntlayerProxyHandlerOptions = {
11
+ /**
12
+ * The resolved Intlayer configuration driving locale detection and routing.
13
+ */
14
+ configuration: IntlayerConfig;
15
+ /**
16
+ * A function that allows you to ignore specific requests from the intlayer proxy.
17
+ *
18
+ * @param req - The incoming request.
19
+ * @returns A boolean value indicating whether to ignore the request.
20
+ */
21
+ ignore?: (req: IncomingMessage) => boolean | undefined;
22
+ /**
23
+ * Whether a development or preview server is serving the app.
24
+ *
25
+ * It only matters in the proxy's auto mode, where a dev server keeps locale
26
+ * routing URL-driven by ignoring the stored locale as a redirect source.
27
+ *
28
+ * @default false
29
+ */
30
+ isDevServer?: boolean;
31
+ };
32
+ /**
33
+ * Creates the locale-routing middleware from an already-resolved configuration.
34
+ *
35
+ * This is the runtime core shared by every environment - dev server, preview
36
+ * server and the production Nitro server. It deliberately receives the
37
+ * configuration instead of loading it: loading it would pull
38
+ * `@intlayer/config/node` - and therefore `esbuild` - into the server bundle,
39
+ * which then fails to boot wherever `node_modules` is not shipped next to the
40
+ * build output.
41
+ *
42
+ * @param options - The resolved configuration plus optional handler behaviour.
43
+ * @returns A Connect-compatible `(req, res, next) => void` middleware.
44
+ *
45
+ * @see `createIntlayerProxyHandler` for the public, configuration-loading entry point.
46
+ */
47
+ declare const createProxyHandler: (options: IntlayerProxyHandlerOptions) => NodeMiddleware;
48
+ //#endregion
49
+ export { IntlayerProxyHandlerOptions, NodeMiddleware, createProxyHandler };
50
+ //# sourceMappingURL=intlayerProxyHandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intlayerProxyHandler.d.ts","names":[],"sources":["../../src/intlayerProxyHandler.ts"],"mappings":";;;;;;;;KAyEY,kBACV,KAAK,iBACL,KAAK,eAAe,kBACpB;KAGU;;;;EAIV,eAAe;;;;;;;EAOf,UAAU,KAAK;;;;;;;;;EASf;;;;;;;;;;;;;;;;;cAkBW,qBAAkB,SACpB,gCACR"}
@@ -1,6 +1,7 @@
1
+ import { NodeMiddleware } from "./intlayerProxyHandler.js";
1
2
  import { GetConfigurationOptions } from "@intlayer/config/node";
2
3
  import { Plugin } from "vite";
3
- import { IncomingMessage, ServerResponse } from "node:http";
4
+ import { IncomingMessage } from "node:http";
4
5
  //#region src/intlayerProxyPlugin.d.ts
5
6
  type IntlayerProxyPluginOptions = {
6
7
  /**
@@ -43,18 +44,11 @@ type IntlayerProxyPluginOptions = {
43
44
  */
44
45
  isDevServer?: boolean;
45
46
  };
46
- /**
47
- * A Node.js-compatible Connect middleware function.
48
- * Compatible with Vite dev/preview server, Node.js http, Express, and h3's
49
- * `fromNodeMiddleware` wrapper for Nitro/TanStack Start production use.
50
- */
51
- type NodeMiddleware = (req: IncomingMessage, res: ServerResponse<IncomingMessage>, next: () => void) => void;
52
47
  /**
53
48
  * Creates a standalone, framework-agnostic locale-routing middleware.
54
49
  *
55
- * This function contains all the locale detection, redirect, and rewrite logic.
56
- * It is intentionally separated from the Vite plugin so the same handler can be
57
- * used in every environment:
50
+ * It loads the Intlayer configuration and hands it to the runtime handler in
51
+ * `intlayerProxyHandler`, so it can be used in every environment:
58
52
  *
59
53
  * - **Dev**: wired up automatically by `intlayerProxy` via `configureServer`
60
54
  * - **Preview**: wired up automatically by `intlayerProxy` via `configurePreviewServer`
@@ -71,7 +65,6 @@ type NodeMiddleware = (req: IncomingMessage, res: ServerResponse<IncomingMessage
71
65
  *
72
66
  * @param options - Plugin-specific options, such as path ignoring and Intlayer configuration overrides.
73
67
  * @returns A Connect-compatible `(req, res, next) => void` middleware.
74
- *
75
68
  */
76
69
  declare const createIntlayerProxyHandler: (options?: IntlayerProxyPluginOptions) => NodeMiddleware;
77
70
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"intlayerProxyPlugin.d.ts","names":[],"sources":["../../src/intlayerProxyPlugin.ts"],"mappings":";;;;KA0EY;;;;;;;;;;;;;;EAcV,UAAU,KAAK;;;;;;;;;;;EAWf,gBAAgB;;;;;;;;;;;;;;EAchB;;;;;;;KAQG,kBACH,KAAK,iBACL,KAAK,eAAe,kBACpB;;;;;;;;;;;;;;;;;;;;;;;;;cA2BW,6BAA0B,UAC3B,+BACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA27BU,gBAAa,UAAc,+BAA6B;;;;;;;;;;;;;cAuIxD,2BAAkB;;;;;;;;;;;;;cAclB,iCAAwB"}
1
+ {"version":3,"file":"intlayerProxyPlugin.d.ts","names":[],"sources":["../../src/intlayerProxyPlugin.ts"],"mappings":";;;;;KA6BY;;;;;;;;;;;;;;EAcV,UAAU,KAAK;;;;;;;;;;;EAWf,gBAAgB;;;;;;;;;;;;;;EAchB;;;;;;;;;;;;;;;;;;;;;;;;cAyBW,6BAA0B,UAC3B,+BACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAgDU,gBAAa,UAAc,+BAA6B;;;;;;;;;;;;;cAuIxD,2BAAkB;;;;;;;;;;;;;cAclB,iCAAwB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-intlayer",
3
- "version": "9.3.2",
3
+ "version": "9.3.3",
4
4
  "private": false,
5
5
  "description": "A Vite plugin for seamless internationalization (i18n), providing locale detection, redirection, and environment-based configuration",
6
6
  "keywords": [
@@ -82,11 +82,11 @@
82
82
  },
83
83
  "dependencies": {
84
84
  "@intlayer/babel": "9.3.2",
85
- "@intlayer/config": "9.3.2",
86
- "@intlayer/core": "9.3.2",
87
- "@intlayer/dictionaries-entry": "9.3.2",
85
+ "@intlayer/config": "9.3.3",
86
+ "@intlayer/core": "9.3.3",
87
+ "@intlayer/dictionaries-entry": "9.3.3",
88
88
  "@intlayer/engine": "9.3.2",
89
- "@intlayer/types": "9.3.2"
89
+ "@intlayer/types": "9.3.3"
90
90
  },
91
91
  "devDependencies": {
92
92
  "@types/node": "26.2.0",
@@ -96,12 +96,12 @@
96
96
  "rimraf": "6.1.3",
97
97
  "tsdown": "0.22.14",
98
98
  "typescript": "7.0.2",
99
- "vitest": "4.1.10"
99
+ "vitest": "4.1.11"
100
100
  },
101
101
  "peerDependencies": {
102
102
  "@babel/core": ">=6.0.0",
103
- "@intlayer/svelte-compiler": "9.3.2",
104
- "@intlayer/vue-compiler": "9.3.2",
103
+ "@intlayer/svelte-compiler": "9.3.3",
104
+ "@intlayer/vue-compiler": "9.3.3",
105
105
  "h3": ">=1.0.0",
106
106
  "vite": ">=4.0.0"
107
107
  },