vite-intlayer 9.6.0 → 9.7.1
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/esm/IntlayerCompilerPlugin.mjs +5 -6
- package/dist/esm/dedupePlugin.mjs +1 -2
- package/dist/esm/index.mjs +6 -5
- package/dist/esm/intlayerChunkPlugin.mjs +1 -2
- package/dist/esm/intlayerDictionaryHmrPlugin.mjs +122 -0
- package/dist/esm/intlayerDictionaryHmrPlugin.mjs.map +1 -0
- package/dist/esm/intlayerMinifyPlugin.mjs +2 -3
- package/dist/esm/intlayerNitroHandler.mjs +2 -3
- package/dist/esm/intlayerOptimizePlugin.mjs +5 -6
- package/dist/esm/intlayerPlugin.mjs +10 -9
- package/dist/esm/intlayerPlugin.mjs.map +1 -1
- package/dist/esm/intlayerPreloadPlugin.mjs +1 -2
- package/dist/esm/intlayerProxyHandler.mjs +1 -2
- package/dist/esm/intlayerProxyPlugin.mjs +4 -5
- package/dist/esm/intlayerPrunePlugin.mjs +2 -3
- package/dist/esm/intlayerVueAsyncPlugin.mjs +1 -2
- package/dist/esm/intlayerWebProxyHandler.mjs +1 -2
- package/dist/types/IntlayerCompilerPlugin.d.ts +0 -2
- package/dist/types/IntlayerCompilerPlugin.d.ts.map +1 -1
- package/dist/types/dedupePlugin.d.ts +1 -2
- package/dist/types/dedupePlugin.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -2
- package/dist/types/intlayerChunkPlugin.d.ts +0 -2
- package/dist/types/intlayerChunkPlugin.d.ts.map +1 -1
- package/dist/types/intlayerDictionaryHmrPlugin.d.ts +52 -0
- package/dist/types/intlayerDictionaryHmrPlugin.d.ts.map +1 -0
- package/dist/types/intlayerMinifyPlugin.d.ts +0 -2
- package/dist/types/intlayerMinifyPlugin.d.ts.map +1 -1
- package/dist/types/intlayerNitroHandler.d.ts +0 -2
- package/dist/types/intlayerNitroHandler.d.ts.map +1 -1
- package/dist/types/intlayerOptimizePlugin.d.ts +0 -2
- package/dist/types/intlayerOptimizePlugin.d.ts.map +1 -1
- package/dist/types/intlayerPlugin.d.ts +0 -2
- package/dist/types/intlayerPlugin.d.ts.map +1 -1
- package/dist/types/intlayerPreloadPlugin.d.ts +0 -2
- package/dist/types/intlayerPreloadPlugin.d.ts.map +1 -1
- package/dist/types/intlayerProxyHandler.d.ts +0 -2
- package/dist/types/intlayerProxyHandler.d.ts.map +1 -1
- package/dist/types/intlayerProxyPlugin.d.ts +0 -2
- package/dist/types/intlayerProxyPlugin.d.ts.map +1 -1
- package/dist/types/intlayerPrunePlugin.d.ts +0 -2
- package/dist/types/intlayerPrunePlugin.d.ts.map +1 -1
- package/dist/types/intlayerVueAsyncPlugin.d.ts +0 -2
- package/dist/types/intlayerVueAsyncPlugin.d.ts.map +1 -1
- package/dist/types/intlayerWebProxyHandler.d.ts +0 -2
- package/dist/types/intlayerWebProxyHandler.d.ts.map +1 -1
- package/package.json +12 -12
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { createPrimaryInstanceGuard } from "./dedupePlugin.mjs";
|
|
2
|
-
import { colorize, colorizeKey, colorizeNumber, colorizePath, getAppLogger, x } from "@intlayer/config/logger";
|
|
3
|
-
import { normalizePath } from "@intlayer/config/utils";
|
|
4
|
-
import { dirname, relative } from "node:path";
|
|
5
|
-
import * as ANSIColors from "@intlayer/config/colors";
|
|
6
2
|
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { dirname, relative } from "node:path";
|
|
7
4
|
import { detectPackageName, extractContent, getExtractPluginOptions, writeContentHelper } from "@intlayer/babel";
|
|
5
|
+
import * as ANSIColors from "@intlayer/config/colors";
|
|
6
|
+
import { colorize, colorizeKey, colorizeNumber, colorizePath, getAppLogger, x } from "@intlayer/config/logger";
|
|
8
7
|
import { getConfiguration } from "@intlayer/config/node";
|
|
8
|
+
import { normalizePath } from "@intlayer/config/utils";
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
// src/IntlayerCompilerPlugin.ts
|
|
11
11
|
const COMPILER_PLUGIN_NAME = "vite-intlayer-compiler";
|
|
12
12
|
/**
|
|
13
13
|
* Create an IntlayerCompiler - A Vite-compatible compiler plugin for Intlayer
|
|
@@ -232,6 +232,5 @@ const intlayerCompiler = (options) => {
|
|
|
232
232
|
return plugin;
|
|
233
233
|
};
|
|
234
234
|
|
|
235
|
-
//#endregion
|
|
236
235
|
export { intlayerCompiler };
|
|
237
236
|
//# sourceMappingURL=IntlayerCompilerPlugin.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/dedupePlugin.ts
|
|
2
2
|
/**
|
|
3
3
|
* Create a {@link PrimaryInstanceGuard} for a plugin identified by `pluginName`.
|
|
4
4
|
*
|
|
@@ -20,6 +20,5 @@ const createPrimaryInstanceGuard = (pluginName) => {
|
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
//#endregion
|
|
24
23
|
export { createPrimaryInstanceGuard };
|
|
25
24
|
//# sourceMappingURL=dedupePlugin.mjs.map
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { createDictionaryModuleParser, intlayerChunk, resolveBoundaries, toBoundaryName } from "./intlayerChunkPlugin.mjs";
|
|
2
|
-
import { intlayerPrune } from "./intlayerPrunePlugin.mjs";
|
|
3
|
-
import { intlayerOptimize } from "./intlayerOptimizePlugin.mjs";
|
|
4
1
|
import { intlayerCompiler } from "./IntlayerCompilerPlugin.mjs";
|
|
2
|
+
import { createDictionaryModuleParser, intlayerChunk, resolveBoundaries, toBoundaryName } from "./intlayerChunkPlugin.mjs";
|
|
3
|
+
import { DICTIONARY_ENTRY_HMR_FOOTER, findDictionaryConsumers, intlayerDictionaryHmr } from "./intlayerDictionaryHmrPlugin.mjs";
|
|
5
4
|
import { intlayerMinify } from "./intlayerMinifyPlugin.mjs";
|
|
5
|
+
import { intlayerOptimize } from "./intlayerOptimizePlugin.mjs";
|
|
6
|
+
import { INTLAYER_NO_EXTERNAL_PATTERN, intLayerPlugin, intlayer, intlayerPlugin } from "./intlayerPlugin.mjs";
|
|
6
7
|
import { intlayerPreload } from "./intlayerPreloadPlugin.mjs";
|
|
7
8
|
import { createIntlayerProxyHandler, createRedirectOnlyMiddleware, intLayerMiddlewarePlugin, intlayerMiddleware, intlayerProxy, resolveNitroHandlerPath } from "./intlayerProxyPlugin.mjs";
|
|
8
|
-
import {
|
|
9
|
+
import { intlayerPrune } from "./intlayerPrunePlugin.mjs";
|
|
9
10
|
|
|
10
|
-
export { INTLAYER_NO_EXTERNAL_PATTERN, createDictionaryModuleParser, createIntlayerProxyHandler, createRedirectOnlyMiddleware, intLayerMiddlewarePlugin, intLayerPlugin, intlayer, intlayerChunk, intlayerCompiler, intlayerMiddleware, intlayerMinify, intlayerOptimize, intlayerPlugin, intlayerPreload, intlayerProxy, intlayerPrune, resolveBoundaries, resolveNitroHandlerPath, toBoundaryName };
|
|
11
|
+
export { DICTIONARY_ENTRY_HMR_FOOTER, INTLAYER_NO_EXTERNAL_PATTERN, createDictionaryModuleParser, createIntlayerProxyHandler, createRedirectOnlyMiddleware, findDictionaryConsumers, intLayerMiddlewarePlugin, intLayerPlugin, intlayer, intlayerChunk, intlayerCompiler, intlayerDictionaryHmr, intlayerMiddleware, intlayerMinify, intlayerOptimize, intlayerPlugin, intlayerPreload, intlayerProxy, intlayerPrune, resolveBoundaries, resolveNitroHandlerPath, toBoundaryName };
|
|
@@ -2,7 +2,7 @@ import { DYNAMIC_DICTIONARIES_JSON_SUBDIR } from "@intlayer/config/defaultValues
|
|
|
2
2
|
import { colorizeNumber, getAppLogger } from "@intlayer/config/logger";
|
|
3
3
|
import { normalizePath } from "@intlayer/config/utils";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/intlayerChunkPlugin.ts
|
|
6
6
|
/**
|
|
7
7
|
* Builds the parser that recognises a per-locale dictionary chunk emitted in
|
|
8
8
|
* `dynamic` import mode.
|
|
@@ -176,6 +176,5 @@ const intlayerChunk = (intlayerConfig) => {
|
|
|
176
176
|
};
|
|
177
177
|
};
|
|
178
178
|
|
|
179
|
-
//#endregion
|
|
180
179
|
export { createDictionaryModuleParser, intlayerChunk, resolveBoundaries, toBoundaryName };
|
|
181
180
|
//# sourceMappingURL=intlayerChunkPlugin.mjs.map
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { basename, dirname } from "node:path";
|
|
2
|
+
import { normalizePath } from "@intlayer/config/utils";
|
|
3
|
+
|
|
4
|
+
// src/intlayerDictionaryHmrPlugin.ts
|
|
5
|
+
/**
|
|
6
|
+
* Appended to the generated `.intlayer/main/*.mjs` entry points in the dev
|
|
7
|
+
* client.
|
|
8
|
+
*
|
|
9
|
+
* The entry accepts its own update and writes the fresh dictionaries into the
|
|
10
|
+
* object the previous instance exported. Every module that already imported it
|
|
11
|
+
* keeps that reference, so the content they read is updated in place and the
|
|
12
|
+
* update stops here instead of climbing through every `useIntlayer` consumer.
|
|
13
|
+
*
|
|
14
|
+
* Relies on the generated entry declaring its record as `const dictionaries`.
|
|
15
|
+
*/
|
|
16
|
+
const DICTIONARY_ENTRY_HMR_FOOTER = `
|
|
17
|
+
if (import.meta.hot) {
|
|
18
|
+
const previousDictionaries = import.meta.hot.data.dictionaries;
|
|
19
|
+
if (previousDictionaries && previousDictionaries !== dictionaries) {
|
|
20
|
+
for (const key of Object.keys(previousDictionaries)) {
|
|
21
|
+
if (!(key in dictionaries)) delete previousDictionaries[key];
|
|
22
|
+
}
|
|
23
|
+
Object.assign(previousDictionaries, dictionaries);
|
|
24
|
+
}
|
|
25
|
+
import.meta.hot.data.dictionaries = previousDictionaries ?? dictionaries;
|
|
26
|
+
import.meta.hot.accept();
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
29
|
+
/** Escapes a dictionary key for use inside a regular expression. */
|
|
30
|
+
const escapeRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
31
|
+
/**
|
|
32
|
+
* Callee names that read a dictionary by key — `useIntlayer`, `getIntlayer`,
|
|
33
|
+
* `getDictionary`, compat `useTranslation(s)` / `getTranslations` — including
|
|
34
|
+
* the `(0, module.useIntlayer)(…)` form of a transformed import.
|
|
35
|
+
*/
|
|
36
|
+
const CONTENT_ACCESSOR_CALLEE = String.raw`[\w$]*(?:Intlayer|Dictionary|Translations?)[\w$]*\)?\s*\(\s*`;
|
|
37
|
+
/**
|
|
38
|
+
* Lists the modules whose transformed source passes the dictionary key as the
|
|
39
|
+
* first argument of a content accessor — `useIntlayer('key')`,
|
|
40
|
+
* `getIntlayer("key", locale)`, a compat `useTranslation('key')`.
|
|
41
|
+
*
|
|
42
|
+
* Requiring the accessor keeps generic keys such as `code` from matching every
|
|
43
|
+
* `jsx("code")` or `type: "code"`. A module dragged in that cannot be hot
|
|
44
|
+
* swapped would invalidate up to a full page reload.
|
|
45
|
+
*/
|
|
46
|
+
const findDictionaryConsumers = (modules, dictionaryKey, excludedDir) => {
|
|
47
|
+
const keyCallPattern = new RegExp(`${CONTENT_ACCESSOR_CALLEE}(["'\`])${escapeRegExp(dictionaryKey)}\\1`);
|
|
48
|
+
return [...modules].filter((moduleNode) => {
|
|
49
|
+
const transformedCode = moduleNode.transformResult?.code;
|
|
50
|
+
if (!transformedCode) return false;
|
|
51
|
+
if (moduleNode.file !== null && normalizePath(moduleNode.file).startsWith(`${excludedDir}/`)) return false;
|
|
52
|
+
return keyCallPattern.test(transformedCode);
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Keeps a content edit from hot-updating the whole application in dev.
|
|
57
|
+
*
|
|
58
|
+
* Every consumer reaches dictionaries through the same generated entry point,
|
|
59
|
+
* so by default one rewritten `<key>.json` propagates to every module that
|
|
60
|
+
* imports an Intlayer package — hundreds of HMR boundaries, root layout and
|
|
61
|
+
* route files included, which remounts the tree like a full reload.
|
|
62
|
+
*
|
|
63
|
+
* Instead, the entry point absorbs the JSON update (see
|
|
64
|
+
* {@link DICTIONARY_ENTRY_HMR_FOOTER}) and only the modules that reference the
|
|
65
|
+
* changed key are hot-updated, so their framework re-renders them with the new
|
|
66
|
+
* content.
|
|
67
|
+
*
|
|
68
|
+
* Limitation: a dictionary that only reaches the screen through another
|
|
69
|
+
* dictionary's `nest()` is re-rendered on the next update of its consumer.
|
|
70
|
+
*
|
|
71
|
+
* @param intlayerConfig - Resolved Intlayer configuration.
|
|
72
|
+
*/
|
|
73
|
+
const intlayerDictionaryHmr = (intlayerConfig) => {
|
|
74
|
+
const { mainDir, dictionariesDir, unmergedDictionariesDir, remoteDictionariesDir } = intlayerConfig.system;
|
|
75
|
+
const mainEntryDir = normalizePath(mainDir);
|
|
76
|
+
const intlayerDir = normalizePath(dirname(mainDir));
|
|
77
|
+
/** Directories holding one `<key>.json` per dictionary. */
|
|
78
|
+
const dictionaryJsonDirs = new Set([
|
|
79
|
+
dictionariesDir,
|
|
80
|
+
unmergedDictionariesDir,
|
|
81
|
+
remoteDictionariesDir
|
|
82
|
+
].map((directory) => normalizePath(directory)));
|
|
83
|
+
/**
|
|
84
|
+
* Returns the key of the dictionary a changed file holds, or `undefined`
|
|
85
|
+
* when the file is not a compiled `<key>.json`.
|
|
86
|
+
*/
|
|
87
|
+
const getChangedDictionaryKey = (file) => {
|
|
88
|
+
const posixFile = normalizePath(file);
|
|
89
|
+
if (!posixFile.endsWith(".json")) return void 0;
|
|
90
|
+
if (!dictionaryJsonDirs.has(dirname(posixFile))) return void 0;
|
|
91
|
+
return basename(posixFile, ".json");
|
|
92
|
+
};
|
|
93
|
+
return {
|
|
94
|
+
name: "vite-intlayer-dictionary-hmr-plugin",
|
|
95
|
+
apply: "serve",
|
|
96
|
+
transform(code, moduleId, options) {
|
|
97
|
+
if (options?.ssr) return null;
|
|
98
|
+
const posixId = normalizePath(moduleId.split("?", 1)[0] ?? moduleId);
|
|
99
|
+
if (!posixId.endsWith(".mjs")) return null;
|
|
100
|
+
if (dirname(posixId) !== mainEntryDir) return null;
|
|
101
|
+
if (!/\bconst dictionaries\b/.test(code)) return null;
|
|
102
|
+
return {
|
|
103
|
+
code: `${code}${DICTIONARY_ENTRY_HMR_FOOTER}`,
|
|
104
|
+
map: null
|
|
105
|
+
};
|
|
106
|
+
},
|
|
107
|
+
hotUpdate({ file, modules }) {
|
|
108
|
+
if (this.environment.config.consumer !== "client") return;
|
|
109
|
+
const dictionaryKey = getChangedDictionaryKey(file);
|
|
110
|
+
if (!dictionaryKey) return;
|
|
111
|
+
return [...modules, ...findDictionaryConsumers(this.environment.moduleGraph.idToModuleMap.values(), dictionaryKey, intlayerDir)];
|
|
112
|
+
},
|
|
113
|
+
handleHotUpdate({ file, modules, server }) {
|
|
114
|
+
const dictionaryKey = getChangedDictionaryKey(file);
|
|
115
|
+
if (!dictionaryKey) return;
|
|
116
|
+
return [...modules, ...findDictionaryConsumers(server.moduleGraph.idToModuleMap.values(), dictionaryKey, intlayerDir)];
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
export { DICTIONARY_ENTRY_HMR_FOOTER, findDictionaryConsumers, intlayerDictionaryHmr };
|
|
122
|
+
//# sourceMappingURL=intlayerDictionaryHmrPlugin.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intlayerDictionaryHmrPlugin.mjs","names":[],"sources":["../../src/intlayerDictionaryHmrPlugin.ts"],"sourcesContent":["import { basename, dirname } from 'node:path';\nimport { normalizePath } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Plugin } from 'vite';\n\n/**\n * Appended to the generated `.intlayer/main/*.mjs` entry points in the dev\n * client.\n *\n * The entry accepts its own update and writes the fresh dictionaries into the\n * object the previous instance exported. Every module that already imported it\n * keeps that reference, so the content they read is updated in place and the\n * update stops here instead of climbing through every `useIntlayer` consumer.\n *\n * Relies on the generated entry declaring its record as `const dictionaries`.\n */\nexport const DICTIONARY_ENTRY_HMR_FOOTER = `\nif (import.meta.hot) {\n const previousDictionaries = import.meta.hot.data.dictionaries;\n if (previousDictionaries && previousDictionaries !== dictionaries) {\n for (const key of Object.keys(previousDictionaries)) {\n if (!(key in dictionaries)) delete previousDictionaries[key];\n }\n Object.assign(previousDictionaries, dictionaries);\n }\n import.meta.hot.data.dictionaries = previousDictionaries ?? dictionaries;\n import.meta.hot.accept();\n}\n`;\n\n/** The part of a Vite module node the consumer lookup reads. */\ntype TransformedModule = {\n file: string | null;\n transformResult: { code: string } | null;\n};\n\n/** Escapes a dictionary key for use inside a regular expression. */\nconst escapeRegExp = (value: string): string =>\n value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n\n/**\n * Callee names that read a dictionary by key — `useIntlayer`, `getIntlayer`,\n * `getDictionary`, compat `useTranslation(s)` / `getTranslations` — including\n * the `(0, module.useIntlayer)(…)` form of a transformed import.\n */\nconst CONTENT_ACCESSOR_CALLEE = String.raw`[\\w$]*(?:Intlayer|Dictionary|Translations?)[\\w$]*\\)?\\s*\\(\\s*`;\n\n/**\n * Lists the modules whose transformed source passes the dictionary key as the\n * first argument of a content accessor — `useIntlayer('key')`,\n * `getIntlayer(\"key\", locale)`, a compat `useTranslation('key')`.\n *\n * Requiring the accessor keeps generic keys such as `code` from matching every\n * `jsx(\"code\")` or `type: \"code\"`. A module dragged in that cannot be hot\n * swapped would invalidate up to a full page reload.\n */\nexport const findDictionaryConsumers = <Module extends TransformedModule>(\n modules: Iterable<Module>,\n dictionaryKey: string,\n excludedDir: string\n): Module[] => {\n const keyCallPattern = new RegExp(\n `${CONTENT_ACCESSOR_CALLEE}([\"'\\`])${escapeRegExp(dictionaryKey)}\\\\1`\n );\n\n return [...modules].filter((moduleNode) => {\n const transformedCode = moduleNode.transformResult?.code;\n if (!transformedCode) return false;\n\n const isGenerated =\n moduleNode.file !== null &&\n normalizePath(moduleNode.file).startsWith(`${excludedDir}/`);\n if (isGenerated) return false;\n\n return keyCallPattern.test(transformedCode);\n });\n};\n\n/**\n * Keeps a content edit from hot-updating the whole application in dev.\n *\n * Every consumer reaches dictionaries through the same generated entry point,\n * so by default one rewritten `<key>.json` propagates to every module that\n * imports an Intlayer package — hundreds of HMR boundaries, root layout and\n * route files included, which remounts the tree like a full reload.\n *\n * Instead, the entry point absorbs the JSON update (see\n * {@link DICTIONARY_ENTRY_HMR_FOOTER}) and only the modules that reference the\n * changed key are hot-updated, so their framework re-renders them with the new\n * content.\n *\n * Limitation: a dictionary that only reaches the screen through another\n * dictionary's `nest()` is re-rendered on the next update of its consumer.\n *\n * @param intlayerConfig - Resolved Intlayer configuration.\n */\nexport const intlayerDictionaryHmr = (\n intlayerConfig: IntlayerConfig\n): Plugin => {\n const {\n mainDir,\n dictionariesDir,\n unmergedDictionariesDir,\n remoteDictionariesDir,\n } = intlayerConfig.system;\n\n const mainEntryDir = normalizePath(mainDir);\n const intlayerDir = normalizePath(dirname(mainDir));\n\n /** Directories holding one `<key>.json` per dictionary. */\n const dictionaryJsonDirs = new Set(\n [dictionariesDir, unmergedDictionariesDir, remoteDictionariesDir].map(\n (directory) => normalizePath(directory)\n )\n );\n\n /**\n * Returns the key of the dictionary a changed file holds, or `undefined`\n * when the file is not a compiled `<key>.json`.\n */\n const getChangedDictionaryKey = (file: string): string | undefined => {\n const posixFile = normalizePath(file);\n\n if (!posixFile.endsWith('.json')) return undefined;\n if (!dictionaryJsonDirs.has(dirname(posixFile))) return undefined;\n\n return basename(posixFile, '.json');\n };\n\n return {\n name: 'vite-intlayer-dictionary-hmr-plugin',\n\n apply: 'serve',\n\n transform(code, moduleId, options) {\n // The server reloads its module runner on its own; only the browser\n // holds state worth preserving.\n if (options?.ssr) return null;\n\n const posixId = normalizePath(moduleId.split('?', 1)[0] ?? moduleId);\n if (!posixId.endsWith('.mjs')) return null;\n if (dirname(posixId) !== mainEntryDir) return null;\n if (!/\\bconst dictionaries\\b/.test(code)) return null;\n\n return { code: `${code}${DICTIONARY_ENTRY_HMR_FOOTER}`, map: null };\n },\n\n // Vite 6+: scoped to the client, so the consumers never join the server\n // environment's update.\n hotUpdate({ file, modules }) {\n if (this.environment.config.consumer !== 'client') return;\n\n const dictionaryKey = getChangedDictionaryKey(file);\n if (!dictionaryKey) return;\n\n // The JSON module first, so the entry point holds the new content by the\n // time the consumers re-render.\n return [\n ...modules,\n ...findDictionaryConsumers(\n this.environment.moduleGraph.idToModuleMap.values(),\n dictionaryKey,\n intlayerDir\n ),\n ];\n },\n\n // Vite 4 and 5, which ignore `hotUpdate`.\n handleHotUpdate({ file, modules, server }) {\n const dictionaryKey = getChangedDictionaryKey(file);\n if (!dictionaryKey) return;\n\n return [\n ...modules,\n ...findDictionaryConsumers(\n server.moduleGraph.idToModuleMap.values(),\n dictionaryKey,\n intlayerDir\n ),\n ];\n },\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;AAgBA,MAAa,8BAA8B;;;;;;;;;;;;;;AAqB3C,MAAM,gBAAgB,UACpB,MAAM,QAAQ,uBAAuB,MAAM;;;;;;AAO7C,MAAM,0BAA0B,OAAO,GAAG;;;;;;;;;;AAW1C,MAAa,2BACX,SACA,eACA,gBACa;CACb,MAAM,iBAAiB,IAAI,OACzB,GAAG,wBAAwB,UAAU,aAAa,aAAa,EAAE,IACnE;CAEA,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,QAAQ,eAAe;EACzC,MAAM,kBAAkB,WAAW,iBAAiB;EACpD,IAAI,CAAC,iBAAiB,OAAO;EAK7B,IAFE,WAAW,SAAS,QACpB,cAAc,WAAW,IAAI,CAAC,CAAC,WAAW,GAAG,YAAY,EAAE,GAC5C,OAAO;EAExB,OAAO,eAAe,KAAK,eAAe;CAC5C,CAAC;AACH;;;;;;;;;;;;;;;;;;;AAoBA,MAAa,yBACX,mBACW;CACX,MAAM,EACJ,SACA,iBACA,yBACA,0BACE,eAAe;CAEnB,MAAM,eAAe,cAAc,OAAO;CAC1C,MAAM,cAAc,cAAc,QAAQ,OAAO,CAAC;;CAGlD,MAAM,qBAAqB,IAAI,IAC7B;EAAC;EAAiB;EAAyB;CAAqB,CAAC,CAAC,KAC/D,cAAc,cAAc,SAAS,CACxC,CACF;;;;;CAMA,MAAM,2BAA2B,SAAqC;EACpE,MAAM,YAAY,cAAc,IAAI;EAEpC,IAAI,CAAC,UAAU,SAAS,OAAO,GAAG,OAAO;EACzC,IAAI,CAAC,mBAAmB,IAAI,QAAQ,SAAS,CAAC,GAAG,OAAO;EAExD,OAAO,SAAS,WAAW,OAAO;CACpC;CAEA,OAAO;EACL,MAAM;EAEN,OAAO;EAEP,UAAU,MAAM,UAAU,SAAS;GAGjC,IAAI,SAAS,KAAK,OAAO;GAEzB,MAAM,UAAU,cAAc,SAAS,MAAM,KAAK,CAAC,CAAC,CAAC,MAAM,QAAQ;GACnE,IAAI,CAAC,QAAQ,SAAS,MAAM,GAAG,OAAO;GACtC,IAAI,QAAQ,OAAO,MAAM,cAAc,OAAO;GAC9C,IAAI,CAAC,yBAAyB,KAAK,IAAI,GAAG,OAAO;GAEjD,OAAO;IAAE,MAAM,GAAG,OAAO;IAA+B,KAAK;GAAK;EACpE;EAIA,UAAU,EAAE,MAAM,WAAW;GAC3B,IAAI,KAAK,YAAY,OAAO,aAAa,UAAU;GAEnD,MAAM,gBAAgB,wBAAwB,IAAI;GAClD,IAAI,CAAC,eAAe;GAIpB,OAAO,CACL,GAAG,SACH,GAAG,wBACD,KAAK,YAAY,YAAY,cAAc,OAAO,GAClD,eACA,WACF,CACF;EACF;EAGA,gBAAgB,EAAE,MAAM,SAAS,UAAU;GACzC,MAAM,gBAAgB,wBAAwB,IAAI;GAClD,IAAI,CAAC,eAAe;GAEpB,OAAO,CACL,GAAG,SACH,GAAG,wBACD,OAAO,YAAY,cAAc,OAAO,GACxC,eACA,WACF,CACF;EACF;CACF;AACF"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { colorize, getAppLogger } from "@intlayer/config/logger";
|
|
2
1
|
import { join } from "node:path";
|
|
3
2
|
import * as ANSIColors from "@intlayer/config/colors";
|
|
3
|
+
import { colorize, getAppLogger } from "@intlayer/config/logger";
|
|
4
4
|
import { formatPath, runOnce } from "@intlayer/engine/utils";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/intlayerMinifyPlugin.ts
|
|
7
7
|
/**
|
|
8
8
|
* Recursively renames user-defined keys in a compiled intlayer content value
|
|
9
9
|
* using the provided `NestedRenameMap`.
|
|
@@ -170,6 +170,5 @@ const intlayerMinify = (intlayerConfig, pruneContext) => {
|
|
|
170
170
|
}];
|
|
171
171
|
};
|
|
172
172
|
|
|
173
|
-
//#endregion
|
|
174
173
|
export { intlayerMinify };
|
|
175
174
|
//# sourceMappingURL=intlayerMinifyPlugin.mjs.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createProxyHandler, isPrerenderProcess } from "./intlayerProxyHandler.mjs";
|
|
2
2
|
import { runProxyOnWebRequest } from "./intlayerWebProxyHandler.mjs";
|
|
3
|
+
import { formatProxyEnabledMessage } from "@intlayer/core/localization";
|
|
3
4
|
import { getAppLogger } from "@intlayer/config/logger";
|
|
4
5
|
import * as builtConfiguration from "@intlayer/config/built";
|
|
5
|
-
import { formatProxyEnabledMessage } from "@intlayer/core/localization";
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
// src/intlayerNitroHandler.ts
|
|
8
8
|
/**
|
|
9
9
|
* The configuration as a plain JSON object.
|
|
10
10
|
*
|
|
@@ -52,6 +52,5 @@ var intlayerNitroHandler_default = (event) => {
|
|
|
52
52
|
for (const [name, value] of outcome.headers) event.res.headers.append(name, value);
|
|
53
53
|
};
|
|
54
54
|
|
|
55
|
-
//#endregion
|
|
56
55
|
export { intlayerNitroHandler_default as default };
|
|
57
56
|
//# sourceMappingURL=intlayerNitroHandler.mjs.map
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { intlayerVueAsyncPlugin } from "./intlayerVueAsyncPlugin.mjs";
|
|
2
2
|
import { IMPORT_MODE } from "@intlayer/config/defaultValues";
|
|
3
|
-
import {
|
|
4
|
-
import { normalizePath } from "@intlayer/config/utils";
|
|
3
|
+
import { readFile, readdir } from "node:fs/promises";
|
|
5
4
|
import { join } from "node:path";
|
|
5
|
+
import { INTLAYER_USAGE_REGEX, SOURCE_FILE_REGEX, analyzeFieldUsageInFile, buildNestedRenameMapFromContent, buildUsageCheckRegex, getNestedRenameEntryAtPath, optimizeSourceFile, preserveNestedDictionaryFields } from "@intlayer/babel";
|
|
6
6
|
import * as ANSIColors from "@intlayer/config/colors";
|
|
7
|
+
import { colorize, colorizeKey, colorizeNumber, getAppLogger } from "@intlayer/config/logger";
|
|
8
|
+
import { normalizePath } from "@intlayer/config/utils";
|
|
7
9
|
import { buildComponentFilesList, formatPath, runOnce } from "@intlayer/engine/utils";
|
|
8
|
-
import { readFile, readdir } from "node:fs/promises";
|
|
9
|
-
import { INTLAYER_USAGE_REGEX, SOURCE_FILE_REGEX, analyzeFieldUsageInFile, buildNestedRenameMapFromContent, buildUsageCheckRegex, getNestedRenameEntryAtPath, optimizeSourceFile, preserveNestedDictionaryFields } from "@intlayer/babel";
|
|
10
10
|
import { requiresDictionaryRegistry } from "@intlayer/config/callers";
|
|
11
11
|
import { getNestedDictionaryGraph, getNestedDictionaryReferences } from "@intlayer/core/dictionaryManipulator";
|
|
12
12
|
import { getDictionaries } from "@intlayer/dictionaries-entry";
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
// src/intlayerOptimizePlugin.ts
|
|
15
15
|
/**
|
|
16
16
|
* Returns the Vite plugins responsible for the build optimisation step.
|
|
17
17
|
*
|
|
@@ -303,6 +303,5 @@ const intlayerOptimize = async (intlayerConfig, pruneContext, compatCallers) =>
|
|
|
303
303
|
}
|
|
304
304
|
};
|
|
305
305
|
|
|
306
|
-
//#endregion
|
|
307
306
|
export { intlayerOptimize };
|
|
308
307
|
//# sourceMappingURL=intlayerOptimizePlugin.mjs.map
|
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
import { intlayerChunk } from "./intlayerChunkPlugin.mjs";
|
|
2
|
-
import { intlayerPrune } from "./intlayerPrunePlugin.mjs";
|
|
3
|
-
import { intlayerOptimize } from "./intlayerOptimizePlugin.mjs";
|
|
4
1
|
import { intlayerCompiler } from "./IntlayerCompilerPlugin.mjs";
|
|
2
|
+
import { intlayerChunk } from "./intlayerChunkPlugin.mjs";
|
|
3
|
+
import { intlayerDictionaryHmr } from "./intlayerDictionaryHmrPlugin.mjs";
|
|
5
4
|
import { intlayerMinify } from "./intlayerMinifyPlugin.mjs";
|
|
5
|
+
import { intlayerOptimize } from "./intlayerOptimizePlugin.mjs";
|
|
6
6
|
import { intlayerPreload } from "./intlayerPreloadPlugin.mjs";
|
|
7
7
|
import { intlayerProxy } from "./intlayerProxyPlugin.mjs";
|
|
8
|
-
import {
|
|
9
|
-
import { getAlias, getHasDictionarySelector, getUnusedNodeTypesAsync } from "@intlayer/config/utils";
|
|
8
|
+
import { intlayerPrune } from "./intlayerPrunePlugin.mjs";
|
|
10
9
|
import { resolveProxyMode } from "@intlayer/core/localization";
|
|
11
10
|
import { resolve } from "node:path";
|
|
11
|
+
import { createPruneContext } from "@intlayer/babel";
|
|
12
12
|
import { BLUE } from "@intlayer/config/colors";
|
|
13
|
+
import { colorize, getAppLogger } from "@intlayer/config/logger";
|
|
14
|
+
import { getConfiguration } from "@intlayer/config/node";
|
|
15
|
+
import { getAlias, getHasDictionarySelector, getUnusedNodeTypesAsync } from "@intlayer/config/utils";
|
|
13
16
|
import { startContentWatcher } from "@intlayer/engine/utils";
|
|
14
|
-
import { createPruneContext } from "@intlayer/babel";
|
|
15
17
|
import { getDictionaries } from "@intlayer/dictionaries-entry";
|
|
16
18
|
import { formatDictionarySelectorEnvVar, formatNodeTypeToEnvVar, formatOptimizedNestingEnvVar, getConfigEnvVars } from "@intlayer/config/envVars";
|
|
17
|
-
import { getConfiguration } from "@intlayer/config/node";
|
|
18
19
|
import { logConfigDetails } from "@intlayer/engine/logConfigDetails";
|
|
19
20
|
|
|
20
|
-
|
|
21
|
+
// src/intlayerPlugin.ts
|
|
21
22
|
/**
|
|
22
23
|
* Packages that must go through Vite's transform pipeline instead of being
|
|
23
24
|
* loaded natively by Node.
|
|
@@ -117,6 +118,7 @@ const intlayerPlugin = (configOptions) => {
|
|
|
117
118
|
plugins.push(intlayerMinify(intlayerConfig, pruneContext));
|
|
118
119
|
plugins.push(intlayerChunk(intlayerConfig));
|
|
119
120
|
plugins.push(intlayerPreload(intlayerConfig));
|
|
121
|
+
plugins.push(intlayerDictionaryHmr(intlayerConfig));
|
|
120
122
|
if (intlayerConfig.compiler?.enabled && intlayerConfig.compiler?.output) plugins.push(intlayerCompiler({ configOptions: getConfigOptions }));
|
|
121
123
|
if (resolveProxyMode(intlayerConfig.routing.enableProxy) !== "disabled") plugins.push(intlayerProxy({
|
|
122
124
|
...proxy,
|
|
@@ -149,6 +151,5 @@ const intlayer = intlayerPlugin;
|
|
|
149
151
|
*/
|
|
150
152
|
const intLayerPlugin = intlayerPlugin;
|
|
151
153
|
|
|
152
|
-
//#endregion
|
|
153
154
|
export { INTLAYER_NO_EXTERNAL_PATTERN, intLayerPlugin, intlayer, intlayerPlugin };
|
|
154
155
|
//# sourceMappingURL=intlayerPlugin.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intlayerPlugin.mjs","names":[],"sources":["../../src/intlayerPlugin.ts"],"sourcesContent":["import { resolve } from 'node:path';\nimport { type CompatCallerConfig, createPruneContext } from '@intlayer/babel';\nimport { BLUE } from '@intlayer/config/colors';\nimport {\n formatDictionarySelectorEnvVar,\n formatNodeTypeToEnvVar,\n formatOptimizedNestingEnvVar,\n getConfigEnvVars,\n} from '@intlayer/config/envVars';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport {\n getAlias,\n getHasDictionarySelector,\n getUnusedNodeTypesAsync,\n} from '@intlayer/config/utils';\nimport { resolveProxyMode } from '@intlayer/core/localization';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport { logConfigDetails } from '@intlayer/engine/logConfigDetails';\nimport { startContentWatcher } from '@intlayer/engine/utils';\nimport type { PluginOption } from 'vite';\nimport { intlayerCompiler } from './IntlayerCompilerPlugin';\nimport { intlayerChunk } from './intlayerChunkPlugin';\nimport { intlayerMinify } from './intlayerMinifyPlugin';\nimport { intlayerOptimize } from './intlayerOptimizePlugin';\nimport { intlayerPreload } from './intlayerPreloadPlugin';\nimport {\n type IntlayerProxyPluginOptions,\n intlayerProxy,\n} from './intlayerProxyPlugin';\nimport { intlayerPrune } from './intlayerPrunePlugin';\n\n/**\n * Packages that must go through Vite's transform pipeline instead of being\n * loaded natively by Node.\n *\n * `intlayer` and every `@intlayer/*` package resolve `@intlayer/dictionaries-entry`\n * through a Vite alias pointing at the generated `.intlayer` entry. A package\n * loaded natively by Node never sees that alias: it resolves the published stub\n * instead, whose CJS `require` of the generated dictionaries is cached for the\n * lifetime of the process — so content edits stop reaching the running server.\n */\nexport const INTLAYER_NO_EXTERNAL_PATTERN = /(^@intlayer\\/|intlayer$)/;\n\n/**\n * Extended options accepted by the intlayer Vite plugin.\n *\n * Extends {@link GetConfigurationOptions} with compat-adapter caller\n * configurations. Compat adapter packages (e.g. `@intlayer/react-i18next/plugin`,\n * `@intlayer/vue-i18n/plugin`) inject their own caller configs here so the\n * field-usage analyser can recognise their translation function call patterns\n * and prune unused dictionary fields accordingly.\n */\nexport type IntlayerPluginOptions = GetConfigurationOptions & {\n /**\n * Compat-adapter namespace caller configurations to pass to the\n * field-usage analyser (Vite `buildStart` phase).\n *\n * Defined by each compat adapter package; the core `vite-intlayer` package\n * ships with an empty default to stay framework-agnostic.\n */\n compatCallers?: CompatCallerConfig[];\n\n /**\n * Options forwarded to the bundled locale-routing proxy (`intlayerProxy`).\n *\n * Since Intlayer v9 the proxy is plugged directly into the main `intlayer()`\n * plugin (controlled by `routing.enableProxy`, unset by default, which\n * selects auto mode). These routing options let you tune that bundled proxy\n * without registering it separately — e.g. ignore API routes from locale\n * routing.\n *\n * @example\n * ```ts\n * intlayer({ proxy: { ignore: (req) => req.url?.startsWith('/api') } })\n * ```\n */\n proxy?: Pick<IntlayerProxyPluginOptions, 'ignore'>;\n};\n\n/**\n * Vite plugin that integrates Intlayer into the Vite build process.\n *\n * It handles:\n * 1. Preparing Intlayer resources (dictionaries) before build.\n * 2. Configuring Vite aliases for dictionary access.\n * 3. Setting up dev-server watchers for content changes.\n * 4. Applying build optimizations (tree-shaking dictionaries).\n *\n * @param configOptions - Optional configuration to override default Intlayer settings.\n * @returns A Vite plugin option.\n *\n * @example\n * ```ts\n * import { intlayer } from 'vite-intlayer';\n *\n * export default defineConfig({\n * plugins: [intlayer()],\n * });\n *\n * ```\n * @deprecated Rename to intlayer instead\n */\nexport const intlayerPlugin = (\n configOptions?: IntlayerPluginOptions\n): PluginOption => {\n const { compatCallers, proxy, ...getConfigOptions } = configOptions ?? {};\n const intlayerConfig = getConfiguration(getConfigOptions);\n logConfigDetails(getConfigOptions);\n const appLogger = getAppLogger(intlayerConfig);\n\n const alias = getAlias({\n configuration: intlayerConfig,\n formatter: (value: string) => resolve(value),\n });\n\n const aliasPackages = Object.keys(alias);\n\n const plugins: PluginOption[] = [\n {\n name: 'vite-intlayer-plugin',\n\n apply: (_config, env) => {\n // Don't apply intlayer plugin during `preview` command\n const isPreviewCommand =\n env.command === 'serve' && env.mode === 'production';\n\n // But if liveSync is enabled, ensure the data are fresh\n const isLiveSyncEnabled = intlayerConfig.editor.liveSync;\n\n return !isPreviewCommand || isLiveSyncEnabled;\n },\n\n config: async (_config, env) => {\n const { mode } = intlayerConfig.build;\n\n const isDevCommand =\n env.command === 'serve' && env.mode === 'development';\n const isBuildCommand = env.command === 'build';\n\n // Only call prepareIntlayer during `dev` or `build` (not during `preview`)\n // If prod: clean and rebuild once\n // If dev: rebuild only once if it's more than 1 hour since last rebuild\n if (isDevCommand || isBuildCommand || mode === 'auto') {\n // Lazily load the heavy build pipeline (`@intlayer/engine/build`) only\n // when a rebuild is actually required, keeping the Vite config phase\n // lightweight (e.g. during `preview`).\n const { prepareIntlayer } = await import('@intlayer/engine/build');\n\n // prepareIntlayer use runOnce to ensure to run only once because will run twice on client and server side otherwise\n await prepareIntlayer(intlayerConfig, {\n clean: isBuildCommand,\n cacheTimeoutMs: isBuildCommand\n ? 1000 * 30 // 30 seconds for build (to ensure to rebuild all dictionaries)\n : 1000 * 60 * 60, // 1 hour for dev (default cache timeout)\n env: isBuildCommand ? 'prod' : 'dev',\n });\n }\n\n let define: Record<string, string> = {\n // Preset an env var to avoid 'process is not defined' error\n // Needed for some libraries that does not add process.env\n 'process.env.INTLAYER': '\"true\"',\n };\n\n if (isBuildCommand) {\n const dictionaries = getDictionaries(intlayerConfig);\n\n // Mirrors the optimize plugin's own `apply` condition: the local\n // `nest()` resolver may only be selected when that transform runs,\n // since it is the transform that injects the nest attachment.\n const isOptimizeEnabled = intlayerConfig.build.optimize !== false;\n\n if (Object.keys(dictionaries).length === 0) {\n appLogger(\n 'No dictionaries found. Please check your configuration.',\n {\n isVerbose: true,\n }\n );\n }\n\n const unusedNodeTypes = await getUnusedNodeTypesAsync(dictionaries);\n\n if (unusedNodeTypes.length > 0) {\n appLogger(\n [\n 'Filtering out unused logic:',\n unusedNodeTypes\n .filter(\n (key) =>\n !['reactNode', 'solidNode', 'preactNode'].includes(key)\n )\n .map((key) => colorize(key, BLUE))\n .join(', '),\n ],\n {\n isVerbose: true,\n }\n );\n }\n\n define = {\n ...define,\n\n // Tree shacking env var based on config\n ...formatNodeTypeToEnvVar(\n unusedNodeTypes,\n (key) => `process.env.${key}`,\n (value) => `\"${value}\"`\n ),\n\n // Selects the local `nest()` resolver, which reads the nest\n // targets attached to each dictionary by the optimize transform\n // instead of the registry that transform empties.\n ...formatOptimizedNestingEnvVar(\n isOptimizeEnabled,\n (key) => `process.env.${key}`,\n (value) => `\"${value}\"`\n ),\n\n // Tree shacking env var for the dictionary selector logic\n // (collections / variants)\n ...formatDictionarySelectorEnvVar(\n getHasDictionarySelector(dictionaries),\n (key) => `process.env.${key}`,\n (value) => `\"${value}\"`\n ),\n\n // Tree shacking env var based on config\n ...getConfigEnvVars(\n intlayerConfig,\n (key) => `process.env.${key}`,\n (value) => `\"${value}\"` // Wrap by \"\" to ensure env var set properly\n ),\n };\n }\n\n // mergeConfig handles both array and record alias formats,\n // and correctly appends to optimizeDeps.exclude / ssr.noExternal\n return {\n define,\n resolve: {\n alias,\n },\n optimizeDeps: {\n // Exclude alias entry points since they're local files, not npm packages\n exclude: aliasPackages,\n },\n ssr: {\n // Ensure intlayer packages are bundled so aliases are applied\n noExternal: [INTLAYER_NO_EXTERNAL_PATTERN],\n },\n };\n },\n\n configureServer: (server) => {\n if (server.config.mode === 'development') {\n // Takes the content watcher lock first, so a parallel\n // `intlayer watch` (or the VS Code extension) does not rebuild the\n // same dictionaries alongside this dev server.\n startContentWatcher(intlayerConfig, { label: 'vite-intlayer' });\n }\n },\n },\n ];\n\n // Shared mutable state: the optimize plugin writes field-usage data during\n // buildStart; the prune and minify plugins read it during transform.\n const pruneContext = createPruneContext();\n\n // Babel transform: rewrites useIntlayer/getIntlayer calls and injects\n // JSON / dynamic-mjs imports. Also runs the usage analyser in buildStart.\n plugins.push(intlayerOptimize(intlayerConfig, pruneContext, compatCallers));\n\n // Prune: removes unused content fields from dictionary JSON files.\n // Runs with enforce:'pre' so it intercepts raw JSON before Vite's\n // built-in JSON → ESM conversion.\n plugins.push(intlayerPrune(intlayerConfig, pruneContext));\n\n // Minify: compacts dictionary JSON files (parse + re-stringify).\n // Registered after prune so it receives already-pruned output when both options are active.\n plugins.push(intlayerMinify(intlayerConfig, pruneContext));\n\n // Chunk: regroups the per-dictionary chunks that `importMode: 'dynamic'`\n // emits, so each code-split boundary loads its content in one request.\n plugins.push(intlayerChunk(intlayerConfig));\n\n // Preload: makes each dynamic entry point await its locale's dictionary while\n // it evaluates, so the content travels with the chunk that needs it instead\n // of being fetched — and suspended on — once that chunk renders.\n plugins.push(intlayerPreload(intlayerConfig));\n\n // Compiler: extracts content declared inline in components into dictionaries.\n // Bundled directly into the main plugin so users no longer need to register\n // `intlayerCompiler()` separately. Only added when the compiler is enabled and\n // an `output` path is configured. Registering `intlayerCompiler()` manually as\n // well is safe — the compiler deduplicates itself.\n if (intlayerConfig.compiler?.enabled && intlayerConfig.compiler?.output) {\n plugins.push(intlayerCompiler({ configOptions: getConfigOptions }));\n }\n\n // Proxy: locale-routing middleware (detection / redirect / rewrite) for dev,\n // preview, and production SSR. Bundled directly into the main plugin and\n // controlled by the `routing.enableProxy` option, which is unset by default\n // and therefore resolves to auto mode. Only an explicit `false` skips\n // registration — a plain truthiness check would wrongly drop the proxy for\n // every project that never set the option.\n // Registering `intlayerProxy()` manually as well is safe — the proxy\n // deduplicates itself.\n if (resolveProxyMode(intlayerConfig.routing.enableProxy) !== 'disabled') {\n plugins.push(intlayerProxy({ ...proxy, configOptions: getConfigOptions }));\n }\n\n return plugins;\n};\n\n/**\n * A Vite plugin that integrates Intlayer configuration into the build process\n *\n * ```ts\n * // Example usage of the plugin in a Vite configuration\n * export default defineConfig({\n * plugins: [ intlayer() ],\n * });\n * ```\n */\nexport const intlayer = intlayerPlugin;\n/**\n * @deprecated Rename to intlayer instead\n *\n * A Vite plugin that integrates Intlayer configuration into the build process\n *\n * ```ts\n * // Example usage of the plugin in a Vite configuration\n * export default defineConfig({\n * plugins: [ intlayer() ],\n * });\n * ```\n */\nexport const intLayerPlugin = intlayerPlugin;\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"intlayerPlugin.mjs","names":[],"sources":["../../src/intlayerPlugin.ts"],"sourcesContent":["import { resolve } from 'node:path';\nimport { type CompatCallerConfig, createPruneContext } from '@intlayer/babel';\nimport { BLUE } from '@intlayer/config/colors';\nimport {\n formatDictionarySelectorEnvVar,\n formatNodeTypeToEnvVar,\n formatOptimizedNestingEnvVar,\n getConfigEnvVars,\n} from '@intlayer/config/envVars';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport {\n getAlias,\n getHasDictionarySelector,\n getUnusedNodeTypesAsync,\n} from '@intlayer/config/utils';\nimport { resolveProxyMode } from '@intlayer/core/localization';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport { logConfigDetails } from '@intlayer/engine/logConfigDetails';\nimport { startContentWatcher } from '@intlayer/engine/utils';\nimport type { PluginOption } from 'vite';\nimport { intlayerCompiler } from './IntlayerCompilerPlugin';\nimport { intlayerChunk } from './intlayerChunkPlugin';\nimport { intlayerDictionaryHmr } from './intlayerDictionaryHmrPlugin';\nimport { intlayerMinify } from './intlayerMinifyPlugin';\nimport { intlayerOptimize } from './intlayerOptimizePlugin';\nimport { intlayerPreload } from './intlayerPreloadPlugin';\nimport {\n type IntlayerProxyPluginOptions,\n intlayerProxy,\n} from './intlayerProxyPlugin';\nimport { intlayerPrune } from './intlayerPrunePlugin';\n\n/**\n * Packages that must go through Vite's transform pipeline instead of being\n * loaded natively by Node.\n *\n * `intlayer` and every `@intlayer/*` package resolve `@intlayer/dictionaries-entry`\n * through a Vite alias pointing at the generated `.intlayer` entry. A package\n * loaded natively by Node never sees that alias: it resolves the published stub\n * instead, whose CJS `require` of the generated dictionaries is cached for the\n * lifetime of the process — so content edits stop reaching the running server.\n */\nexport const INTLAYER_NO_EXTERNAL_PATTERN = /(^@intlayer\\/|intlayer$)/;\n\n/**\n * Extended options accepted by the intlayer Vite plugin.\n *\n * Extends {@link GetConfigurationOptions} with compat-adapter caller\n * configurations. Compat adapter packages (e.g. `@intlayer/react-i18next/plugin`,\n * `@intlayer/vue-i18n/plugin`) inject their own caller configs here so the\n * field-usage analyser can recognise their translation function call patterns\n * and prune unused dictionary fields accordingly.\n */\nexport type IntlayerPluginOptions = GetConfigurationOptions & {\n /**\n * Compat-adapter namespace caller configurations to pass to the\n * field-usage analyser (Vite `buildStart` phase).\n *\n * Defined by each compat adapter package; the core `vite-intlayer` package\n * ships with an empty default to stay framework-agnostic.\n */\n compatCallers?: CompatCallerConfig[];\n\n /**\n * Options forwarded to the bundled locale-routing proxy (`intlayerProxy`).\n *\n * Since Intlayer v9 the proxy is plugged directly into the main `intlayer()`\n * plugin (controlled by `routing.enableProxy`, unset by default, which\n * selects auto mode). These routing options let you tune that bundled proxy\n * without registering it separately — e.g. ignore API routes from locale\n * routing.\n *\n * @example\n * ```ts\n * intlayer({ proxy: { ignore: (req) => req.url?.startsWith('/api') } })\n * ```\n */\n proxy?: Pick<IntlayerProxyPluginOptions, 'ignore'>;\n};\n\n/**\n * Vite plugin that integrates Intlayer into the Vite build process.\n *\n * It handles:\n * 1. Preparing Intlayer resources (dictionaries) before build.\n * 2. Configuring Vite aliases for dictionary access.\n * 3. Setting up dev-server watchers for content changes.\n * 4. Applying build optimizations (tree-shaking dictionaries).\n *\n * @param configOptions - Optional configuration to override default Intlayer settings.\n * @returns A Vite plugin option.\n *\n * @example\n * ```ts\n * import { intlayer } from 'vite-intlayer';\n *\n * export default defineConfig({\n * plugins: [intlayer()],\n * });\n *\n * ```\n * @deprecated Rename to intlayer instead\n */\nexport const intlayerPlugin = (\n configOptions?: IntlayerPluginOptions\n): PluginOption => {\n const { compatCallers, proxy, ...getConfigOptions } = configOptions ?? {};\n const intlayerConfig = getConfiguration(getConfigOptions);\n logConfigDetails(getConfigOptions);\n const appLogger = getAppLogger(intlayerConfig);\n\n const alias = getAlias({\n configuration: intlayerConfig,\n formatter: (value: string) => resolve(value),\n });\n\n const aliasPackages = Object.keys(alias);\n\n const plugins: PluginOption[] = [\n {\n name: 'vite-intlayer-plugin',\n\n apply: (_config, env) => {\n // Don't apply intlayer plugin during `preview` command\n const isPreviewCommand =\n env.command === 'serve' && env.mode === 'production';\n\n // But if liveSync is enabled, ensure the data are fresh\n const isLiveSyncEnabled = intlayerConfig.editor.liveSync;\n\n return !isPreviewCommand || isLiveSyncEnabled;\n },\n\n config: async (_config, env) => {\n const { mode } = intlayerConfig.build;\n\n const isDevCommand =\n env.command === 'serve' && env.mode === 'development';\n const isBuildCommand = env.command === 'build';\n\n // Only call prepareIntlayer during `dev` or `build` (not during `preview`)\n // If prod: clean and rebuild once\n // If dev: rebuild only once if it's more than 1 hour since last rebuild\n if (isDevCommand || isBuildCommand || mode === 'auto') {\n // Lazily load the heavy build pipeline (`@intlayer/engine/build`) only\n // when a rebuild is actually required, keeping the Vite config phase\n // lightweight (e.g. during `preview`).\n const { prepareIntlayer } = await import('@intlayer/engine/build');\n\n // prepareIntlayer use runOnce to ensure to run only once because will run twice on client and server side otherwise\n await prepareIntlayer(intlayerConfig, {\n clean: isBuildCommand,\n cacheTimeoutMs: isBuildCommand\n ? 1000 * 30 // 30 seconds for build (to ensure to rebuild all dictionaries)\n : 1000 * 60 * 60, // 1 hour for dev (default cache timeout)\n env: isBuildCommand ? 'prod' : 'dev',\n });\n }\n\n let define: Record<string, string> = {\n // Preset an env var to avoid 'process is not defined' error\n // Needed for some libraries that does not add process.env\n 'process.env.INTLAYER': '\"true\"',\n };\n\n if (isBuildCommand) {\n const dictionaries = getDictionaries(intlayerConfig);\n\n // Mirrors the optimize plugin's own `apply` condition: the local\n // `nest()` resolver may only be selected when that transform runs,\n // since it is the transform that injects the nest attachment.\n const isOptimizeEnabled = intlayerConfig.build.optimize !== false;\n\n if (Object.keys(dictionaries).length === 0) {\n appLogger(\n 'No dictionaries found. Please check your configuration.',\n {\n isVerbose: true,\n }\n );\n }\n\n const unusedNodeTypes = await getUnusedNodeTypesAsync(dictionaries);\n\n if (unusedNodeTypes.length > 0) {\n appLogger(\n [\n 'Filtering out unused logic:',\n unusedNodeTypes\n .filter(\n (key) =>\n !['reactNode', 'solidNode', 'preactNode'].includes(key)\n )\n .map((key) => colorize(key, BLUE))\n .join(', '),\n ],\n {\n isVerbose: true,\n }\n );\n }\n\n define = {\n ...define,\n\n // Tree shacking env var based on config\n ...formatNodeTypeToEnvVar(\n unusedNodeTypes,\n (key) => `process.env.${key}`,\n (value) => `\"${value}\"`\n ),\n\n // Selects the local `nest()` resolver, which reads the nest\n // targets attached to each dictionary by the optimize transform\n // instead of the registry that transform empties.\n ...formatOptimizedNestingEnvVar(\n isOptimizeEnabled,\n (key) => `process.env.${key}`,\n (value) => `\"${value}\"`\n ),\n\n // Tree shacking env var for the dictionary selector logic\n // (collections / variants)\n ...formatDictionarySelectorEnvVar(\n getHasDictionarySelector(dictionaries),\n (key) => `process.env.${key}`,\n (value) => `\"${value}\"`\n ),\n\n // Tree shacking env var based on config\n ...getConfigEnvVars(\n intlayerConfig,\n (key) => `process.env.${key}`,\n (value) => `\"${value}\"` // Wrap by \"\" to ensure env var set properly\n ),\n };\n }\n\n // mergeConfig handles both array and record alias formats,\n // and correctly appends to optimizeDeps.exclude / ssr.noExternal\n return {\n define,\n resolve: {\n alias,\n },\n optimizeDeps: {\n // Exclude alias entry points since they're local files, not npm packages\n exclude: aliasPackages,\n },\n ssr: {\n // Ensure intlayer packages are bundled so aliases are applied\n noExternal: [INTLAYER_NO_EXTERNAL_PATTERN],\n },\n };\n },\n\n configureServer: (server) => {\n if (server.config.mode === 'development') {\n // Takes the content watcher lock first, so a parallel\n // `intlayer watch` (or the VS Code extension) does not rebuild the\n // same dictionaries alongside this dev server.\n startContentWatcher(intlayerConfig, { label: 'vite-intlayer' });\n }\n },\n },\n ];\n\n // Shared mutable state: the optimize plugin writes field-usage data during\n // buildStart; the prune and minify plugins read it during transform.\n const pruneContext = createPruneContext();\n\n // Babel transform: rewrites useIntlayer/getIntlayer calls and injects\n // JSON / dynamic-mjs imports. Also runs the usage analyser in buildStart.\n plugins.push(intlayerOptimize(intlayerConfig, pruneContext, compatCallers));\n\n // Prune: removes unused content fields from dictionary JSON files.\n // Runs with enforce:'pre' so it intercepts raw JSON before Vite's\n // built-in JSON → ESM conversion.\n plugins.push(intlayerPrune(intlayerConfig, pruneContext));\n\n // Minify: compacts dictionary JSON files (parse + re-stringify).\n // Registered after prune so it receives already-pruned output when both options are active.\n plugins.push(intlayerMinify(intlayerConfig, pruneContext));\n\n // Chunk: regroups the per-dictionary chunks that `importMode: 'dynamic'`\n // emits, so each code-split boundary loads its content in one request.\n plugins.push(intlayerChunk(intlayerConfig));\n\n // Preload: makes each dynamic entry point await its locale's dictionary while\n // it evaluates, so the content travels with the chunk that needs it instead\n // of being fetched — and suspended on — once that chunk renders.\n plugins.push(intlayerPreload(intlayerConfig));\n\n // Dictionary HMR: a content edit hot-updates only the modules reading the\n // changed dictionary, instead of every module importing an Intlayer package.\n plugins.push(intlayerDictionaryHmr(intlayerConfig));\n\n // Compiler: extracts content declared inline in components into dictionaries.\n // Bundled directly into the main plugin so users no longer need to register\n // `intlayerCompiler()` separately. Only added when the compiler is enabled and\n // an `output` path is configured. Registering `intlayerCompiler()` manually as\n // well is safe — the compiler deduplicates itself.\n if (intlayerConfig.compiler?.enabled && intlayerConfig.compiler?.output) {\n plugins.push(intlayerCompiler({ configOptions: getConfigOptions }));\n }\n\n // Proxy: locale-routing middleware (detection / redirect / rewrite) for dev,\n // preview, and production SSR. Bundled directly into the main plugin and\n // controlled by the `routing.enableProxy` option, which is unset by default\n // and therefore resolves to auto mode. Only an explicit `false` skips\n // registration — a plain truthiness check would wrongly drop the proxy for\n // every project that never set the option.\n // Registering `intlayerProxy()` manually as well is safe — the proxy\n // deduplicates itself.\n if (resolveProxyMode(intlayerConfig.routing.enableProxy) !== 'disabled') {\n plugins.push(intlayerProxy({ ...proxy, configOptions: getConfigOptions }));\n }\n\n return plugins;\n};\n\n/**\n * A Vite plugin that integrates Intlayer configuration into the build process\n *\n * ```ts\n * // Example usage of the plugin in a Vite configuration\n * export default defineConfig({\n * plugins: [ intlayer() ],\n * });\n * ```\n */\nexport const intlayer = intlayerPlugin;\n/**\n * @deprecated Rename to intlayer instead\n *\n * A Vite plugin that integrates Intlayer configuration into the build process\n *\n * ```ts\n * // Example usage of the plugin in a Vite configuration\n * export default defineConfig({\n * plugins: [ intlayer() ],\n * });\n * ```\n */\nexport const intLayerPlugin = intlayerPlugin;\n"],"mappings":"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"}
|
|
@@ -3,7 +3,7 @@ import { normalizePath } from "@intlayer/config/utils";
|
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { DYNAMIC_ENTRY_PATTERN, addDynamicEntryPreload, resolvePreloadModuleId } from "@intlayer/config/dictionaryPreload";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/intlayerPreloadPlugin.ts
|
|
7
7
|
/**
|
|
8
8
|
* Absolute id of the locale resolver the injected preamble imports.
|
|
9
9
|
*
|
|
@@ -83,6 +83,5 @@ const intlayerPreload = (intlayerConfig) => {
|
|
|
83
83
|
};
|
|
84
84
|
};
|
|
85
85
|
|
|
86
|
-
//#endregion
|
|
87
86
|
export { intlayerPreload };
|
|
88
87
|
//# sourceMappingURL=intlayerPreloadPlugin.mjs.map
|
|
@@ -2,7 +2,7 @@ import { ROUTING_MODE } from "@intlayer/config/defaultValues";
|
|
|
2
2
|
import { getCanonicalPath, getDomainHostname, getDomainOrigin, getInternalPath, getLocaleFromDomain, getRewriteRules, isProxyStorageLocaleEnabled, localeDetector, resolveLocalizedPath, resolveProxyMode } from "@intlayer/core/localization";
|
|
3
3
|
import { getCookie, getLocaleFromStorageServer, setLocaleInStorageServer } from "@intlayer/core/utils";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/intlayerProxyHandler.ts
|
|
6
6
|
/**
|
|
7
7
|
* Header Nitro's prerenderer sets on every request it issues to the server it
|
|
8
8
|
* is generating pages from. Its value is the route being generated.
|
|
@@ -511,6 +511,5 @@ const createProxyHandler = (options) => {
|
|
|
511
511
|
};
|
|
512
512
|
};
|
|
513
513
|
|
|
514
|
-
//#endregion
|
|
515
514
|
export { createProxyHandler, isPrerenderProcess };
|
|
516
515
|
//# sourceMappingURL=intlayerProxyHandler.mjs.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { createProxyHandler } from "./intlayerProxyHandler.mjs";
|
|
2
1
|
import { createPrimaryInstanceGuard } from "./dedupePlugin.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { normalizePath } from "@intlayer/config/utils";
|
|
2
|
+
import { createProxyHandler } from "./intlayerProxyHandler.mjs";
|
|
5
3
|
import { formatProxyEnabledMessage, isProxyStorageLocaleEnabled, resolveProxyMode } from "@intlayer/core/localization";
|
|
4
|
+
import { getAppLogger } from "@intlayer/config/logger";
|
|
6
5
|
import { getConfiguration } from "@intlayer/config/node";
|
|
6
|
+
import { normalizePath } from "@intlayer/config/utils";
|
|
7
7
|
import { fileURLToPath } from "node:url";
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
// src/intlayerProxyPlugin.ts
|
|
10
10
|
const PROXY_PLUGIN_NAME = "vite-intlayer-middleware-plugin";
|
|
11
11
|
/**
|
|
12
12
|
* Name of the Vite plugin `nitro/vite` registers in preview mode. It mounts the
|
|
@@ -219,6 +219,5 @@ const intlayerMiddleware = intlayerProxy;
|
|
|
219
219
|
*/
|
|
220
220
|
const intLayerMiddlewarePlugin = intlayerProxy;
|
|
221
221
|
|
|
222
|
-
//#endregion
|
|
223
222
|
export { createIntlayerProxyHandler, createRedirectOnlyMiddleware, intLayerMiddlewarePlugin, intlayerMiddleware, intlayerProxy, resolveNitroHandlerPath };
|
|
224
223
|
//# sourceMappingURL=intlayerProxyPlugin.mjs.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { colorize, colorizeKey, colorizeNumber, getAppLogger } from "@intlayer/config/logger";
|
|
2
1
|
import { join } from "node:path";
|
|
3
2
|
import * as ANSIColors from "@intlayer/config/colors";
|
|
3
|
+
import { colorize, colorizeKey, colorizeNumber, getAppLogger } from "@intlayer/config/logger";
|
|
4
4
|
import { formatPath, runOnce } from "@intlayer/engine/utils";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/intlayerPrunePlugin.ts
|
|
7
7
|
const isTranslationNode = (value) => typeof value === "object" && value !== null && value.nodeType === "translation" && typeof value.translation === "object";
|
|
8
8
|
const isPlainRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9
9
|
/**
|
|
@@ -239,6 +239,5 @@ const intlayerPrune = (intlayerConfig, pruneContext) => {
|
|
|
239
239
|
}];
|
|
240
240
|
};
|
|
241
241
|
|
|
242
|
-
//#endregion
|
|
243
242
|
export { intlayerPrune };
|
|
244
243
|
//# sourceMappingURL=intlayerPrunePlugin.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { normalizePath } from "@intlayer/config/utils";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// src/intlayerVueAsyncPlugin.ts
|
|
4
4
|
const intlayerVueAsyncPlugin = (configuration, filesList) => {
|
|
5
5
|
const { optimize } = configuration.build;
|
|
6
6
|
const normalizedFilesList = filesList.map(normalizePath);
|
|
@@ -39,6 +39,5 @@ const intlayerVueAsyncPlugin = (configuration, filesList) => {
|
|
|
39
39
|
};
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
-
//#endregion
|
|
43
42
|
export { intlayerVueAsyncPlugin };
|
|
44
43
|
//# sourceMappingURL=intlayerVueAsyncPlugin.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createProxyHandler } from "./intlayerProxyHandler.mjs";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// src/intlayerWebProxyHandler.ts
|
|
4
4
|
/**
|
|
5
5
|
* Header names the proxy reads from the incoming request.
|
|
6
6
|
*/
|
|
@@ -108,6 +108,5 @@ const createIntlayerWebProxyHandler = (options) => {
|
|
|
108
108
|
return (request) => runProxyOnWebRequest(nodeMiddleware, request);
|
|
109
109
|
};
|
|
110
110
|
|
|
111
|
-
//#endregion
|
|
112
111
|
export { createIntlayerWebProxyHandler, runProxyOnWebRequest };
|
|
113
112
|
//# sourceMappingURL=intlayerWebProxyHandler.mjs.map
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { GetConfigurationOptions } from "@intlayer/config/node";
|
|
2
2
|
import { CompilerConfig } from "@intlayer/types/config";
|
|
3
3
|
import { PluginOption } from "vite";
|
|
4
|
-
//#region src/IntlayerCompilerPlugin.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Options for initializing the compiler
|
|
7
6
|
*/
|
|
@@ -38,5 +37,4 @@ export type IntlayerCompilerOptions = {
|
|
|
38
37
|
* @deprecated Since Intlayer v9, the compiler is bundled directly into the `intlayer()` plugin and activates automatically once `compiler.enabled` is set with a `compiler.output` path. Registering `intlayerCompiler()` separately as shown below is now optional. See the [v9 release notes](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/releases/v9.md).
|
|
39
38
|
*/
|
|
40
39
|
export declare const intlayerCompiler: (options?: IntlayerCompilerOptions) => PluginOption;
|
|
41
|
-
//#endregion
|
|
42
40
|
//# sourceMappingURL=IntlayerCompilerPlugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntlayerCompilerPlugin.d.ts","names":[],"sources":["../../src/IntlayerCompilerPlugin.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"IntlayerCompilerPlugin.d.ts","names":[],"sources":["../../src/IntlayerCompilerPlugin.ts"],"mappings":";;;;;;YAkCY;;;;EAIV,gBAAgB;;;;EAKhB,iBAAiB,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;qBAyBd,mBAAgB,UACjB,4BACT"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Plugin } from "vite";
|
|
2
|
-
//#region src/dedupePlugin.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Minimal shape of the resolved Vite config needed to deduplicate plugins.
|
|
5
4
|
* Only the `plugins` array (read during `configResolved`) is required.
|
|
@@ -42,5 +41,5 @@ export type PrimaryInstanceGuard = {
|
|
|
42
41
|
* @param pluginName - The `name` of the Vite plugin to deduplicate.
|
|
43
42
|
*/
|
|
44
43
|
export declare const createPrimaryInstanceGuard: (pluginName: string) => PrimaryInstanceGuard;
|
|
45
|
-
|
|
44
|
+
export {};
|
|
46
45
|
//# sourceMappingURL=dedupePlugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dedupePlugin.d.ts","names":[],"sources":["../../src/dedupePlugin.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"dedupePlugin.d.ts","names":[],"sources":["../../src/dedupePlugin.ts"],"mappings":";;;;;KAMK;EACH;IAAoB;;;;;;;;;;;;;YAaV;;;;;EAKV,YAAY,QAAQ;;;;;EAMpB,UAAU,QAAQ;;;;;WAMT;;;;;;;qBAQE,6BAA0B,uBAEpC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { IntlayerCompilerOptions, intlayerCompiler } from "./IntlayerCompilerPlugin.js";
|
|
2
2
|
import { ChunkingContext, DictionaryModule, ModuleGraphNode, createDictionaryModuleParser, intlayerChunk, resolveBoundaries, toBoundaryName } from "./intlayerChunkPlugin.js";
|
|
3
|
+
import { DICTIONARY_ENTRY_HMR_FOOTER, findDictionaryConsumers, intlayerDictionaryHmr } from "./intlayerDictionaryHmrPlugin.js";
|
|
3
4
|
import { intlayerMinify } from "./intlayerMinifyPlugin.js";
|
|
4
5
|
import { intlayerOptimize } from "./intlayerOptimizePlugin.js";
|
|
5
|
-
import { IntlayerProxyPluginOptions, createIntlayerProxyHandler, createRedirectOnlyMiddleware, intLayerMiddlewarePlugin, intlayerMiddleware, intlayerProxy, resolveNitroHandlerPath } from "./intlayerProxyPlugin.js";
|
|
6
6
|
import { INTLAYER_NO_EXTERNAL_PATTERN, IntlayerPluginOptions, intLayerPlugin, intlayer, intlayerPlugin } from "./intlayerPlugin.js";
|
|
7
7
|
import { intlayerPreload } from "./intlayerPreloadPlugin.js";
|
|
8
|
+
import { IntlayerProxyPluginOptions, createIntlayerProxyHandler, createRedirectOnlyMiddleware, intLayerMiddlewarePlugin, intlayerMiddleware, intlayerProxy, resolveNitroHandlerPath } from "./intlayerProxyPlugin.js";
|
|
8
9
|
import { intlayerPrune } from "./intlayerPrunePlugin.js";
|
|
9
|
-
export { ChunkingContext, DictionaryModule, INTLAYER_NO_EXTERNAL_PATTERN, IntlayerCompilerOptions, IntlayerPluginOptions, IntlayerProxyPluginOptions, ModuleGraphNode, createDictionaryModuleParser, createIntlayerProxyHandler, createRedirectOnlyMiddleware, intLayerMiddlewarePlugin, intLayerPlugin, intlayer, intlayerChunk, intlayerCompiler, intlayerMiddleware, intlayerMinify, intlayerOptimize, intlayerPlugin, intlayerPreload, intlayerProxy, intlayerPrune, resolveBoundaries, resolveNitroHandlerPath, toBoundaryName };
|
|
10
|
+
export { ChunkingContext, DICTIONARY_ENTRY_HMR_FOOTER, DictionaryModule, INTLAYER_NO_EXTERNAL_PATTERN, IntlayerCompilerOptions, IntlayerPluginOptions, IntlayerProxyPluginOptions, ModuleGraphNode, createDictionaryModuleParser, createIntlayerProxyHandler, createRedirectOnlyMiddleware, findDictionaryConsumers, intLayerMiddlewarePlugin, intLayerPlugin, intlayer, intlayerChunk, intlayerCompiler, intlayerDictionaryHmr, intlayerMiddleware, intlayerMinify, intlayerOptimize, intlayerPlugin, intlayerPreload, intlayerProxy, intlayerPrune, resolveBoundaries, resolveNitroHandlerPath, toBoundaryName };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { IntlayerConfig } from "@intlayer/types/config";
|
|
2
2
|
import { Plugin } from "vite";
|
|
3
|
-
//#region src/intlayerChunkPlugin.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Module-graph accessor Rolldown passes to a chunk-name function.
|
|
6
5
|
*
|
|
@@ -83,5 +82,4 @@ export declare const resolveBoundaries: (jsonModuleId: string, context: Chunking
|
|
|
83
82
|
* @param intlayerConfig - Resolved Intlayer configuration.
|
|
84
83
|
*/
|
|
85
84
|
export declare const intlayerChunk: (intlayerConfig: IntlayerConfig) => Plugin;
|
|
86
|
-
//#endregion
|
|
87
85
|
//# sourceMappingURL=intlayerChunkPlugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intlayerChunkPlugin.d.ts","names":[],"sources":["../../src/intlayerChunkPlugin.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"intlayerChunkPlugin.d.ts","names":[],"sources":["../../src/intlayerChunkPlugin.ts"],"mappings":";;;;;;;;;YAaY;EACV,gBAAgB,qBAAqB;;YAG3B;EACV;EACA;;EAEA;;EAEA;;;YAIU;EACV;EACA;;;;;;;;;;;;;;;;qBAiBW,+BAA4B,qCAEpC,qBAAqB;;qBAuCb,iBAAc;;;;;;;;;;;;;;;qBAuBd,oBAAiB,sBACR,SACX;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAyDE,gBAAa,gBAAoB,mBAAiB"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { IntlayerConfig } from "@intlayer/types/config";
|
|
2
|
+
import { Plugin } from "vite";
|
|
3
|
+
/**
|
|
4
|
+
* Appended to the generated `.intlayer/main/*.mjs` entry points in the dev
|
|
5
|
+
* client.
|
|
6
|
+
*
|
|
7
|
+
* The entry accepts its own update and writes the fresh dictionaries into the
|
|
8
|
+
* object the previous instance exported. Every module that already imported it
|
|
9
|
+
* keeps that reference, so the content they read is updated in place and the
|
|
10
|
+
* update stops here instead of climbing through every `useIntlayer` consumer.
|
|
11
|
+
*
|
|
12
|
+
* Relies on the generated entry declaring its record as `const dictionaries`.
|
|
13
|
+
*/
|
|
14
|
+
export declare const DICTIONARY_ENTRY_HMR_FOOTER = "\nif (import.meta.hot) {\n const previousDictionaries = import.meta.hot.data.dictionaries;\n if (previousDictionaries && previousDictionaries !== dictionaries) {\n for (const key of Object.keys(previousDictionaries)) {\n if (!(key in dictionaries)) delete previousDictionaries[key];\n }\n Object.assign(previousDictionaries, dictionaries);\n }\n import.meta.hot.data.dictionaries = previousDictionaries ?? dictionaries;\n import.meta.hot.accept();\n}\n";
|
|
15
|
+
/** The part of a Vite module node the consumer lookup reads. */
|
|
16
|
+
type TransformedModule = {
|
|
17
|
+
file: string | null;
|
|
18
|
+
transformResult: {
|
|
19
|
+
code: string;
|
|
20
|
+
} | null;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Lists the modules whose transformed source passes the dictionary key as the
|
|
24
|
+
* first argument of a content accessor — `useIntlayer('key')`,
|
|
25
|
+
* `getIntlayer("key", locale)`, a compat `useTranslation('key')`.
|
|
26
|
+
*
|
|
27
|
+
* Requiring the accessor keeps generic keys such as `code` from matching every
|
|
28
|
+
* `jsx("code")` or `type: "code"`. A module dragged in that cannot be hot
|
|
29
|
+
* swapped would invalidate up to a full page reload.
|
|
30
|
+
*/
|
|
31
|
+
export declare const findDictionaryConsumers: <Module extends TransformedModule>(modules: Iterable<Module>, dictionaryKey: string, excludedDir: string) => Module[];
|
|
32
|
+
/**
|
|
33
|
+
* Keeps a content edit from hot-updating the whole application in dev.
|
|
34
|
+
*
|
|
35
|
+
* Every consumer reaches dictionaries through the same generated entry point,
|
|
36
|
+
* so by default one rewritten `<key>.json` propagates to every module that
|
|
37
|
+
* imports an Intlayer package — hundreds of HMR boundaries, root layout and
|
|
38
|
+
* route files included, which remounts the tree like a full reload.
|
|
39
|
+
*
|
|
40
|
+
* Instead, the entry point absorbs the JSON update (see
|
|
41
|
+
* {@link DICTIONARY_ENTRY_HMR_FOOTER}) and only the modules that reference the
|
|
42
|
+
* changed key are hot-updated, so their framework re-renders them with the new
|
|
43
|
+
* content.
|
|
44
|
+
*
|
|
45
|
+
* Limitation: a dictionary that only reaches the screen through another
|
|
46
|
+
* dictionary's `nest()` is re-rendered on the next update of its consumer.
|
|
47
|
+
*
|
|
48
|
+
* @param intlayerConfig - Resolved Intlayer configuration.
|
|
49
|
+
*/
|
|
50
|
+
export declare const intlayerDictionaryHmr: (intlayerConfig: IntlayerConfig) => Plugin;
|
|
51
|
+
export {};
|
|
52
|
+
//# sourceMappingURL=intlayerDictionaryHmrPlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intlayerDictionaryHmrPlugin.d.ts","names":[],"sources":["../../src/intlayerDictionaryHmrPlugin.ts"],"mappings":";;;;;;;;;;;;;qBAgBa;;KAeR;EACH;EACA;IAAmB;;;;;;;;;;;;qBAuBR,0BAA2B,eAAe,mBAAiB,SAC7D,SAAS,SAAO,uBACJ,wBAEpB;;;;;;;;;;;;;;;;;;;qBAoCU,wBAAqB,gBAChB,mBACf"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { IntlayerConfig } from "@intlayer/types/config";
|
|
2
2
|
import { PluginOption } from "vite";
|
|
3
3
|
import { PruneContext } from "@intlayer/babel";
|
|
4
|
-
//#region src/intlayerMinifyPlugin.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Returns the Vite plugin that minifies compiled dictionary JSON files by
|
|
7
6
|
* removing all unnecessary whitespace and optionally renaming content field
|
|
@@ -39,5 +38,4 @@ import { PruneContext } from "@intlayer/babel";
|
|
|
39
38
|
* if the prune plugin is not active.
|
|
40
39
|
*/
|
|
41
40
|
export declare const intlayerMinify: (intlayerConfig: IntlayerConfig, pruneContext: PruneContext | null) => PluginOption[];
|
|
42
|
-
//#endregion
|
|
43
41
|
//# sourceMappingURL=intlayerMinifyPlugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intlayerMinifyPlugin.d.ts","names":[],"sources":["../../src/intlayerMinifyPlugin.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"intlayerMinifyPlugin.d.ts","names":[],"sources":["../../src/intlayerMinifyPlugin.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAwKa,iBAAc,gBACT,gBAAc,cAChB,wBACb"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/intlayerNitroHandler.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Minimal duck-type for h3 v2's H3Event.
|
|
4
3
|
*
|
|
@@ -47,6 +46,5 @@ type H3EventLike = {
|
|
|
47
46
|
* the next handler / route.
|
|
48
47
|
*/
|
|
49
48
|
declare function _default(event: H3EventLike): Response | undefined;
|
|
50
|
-
//#endregion
|
|
51
49
|
export { _default as default };
|
|
52
50
|
//# sourceMappingURL=intlayerNitroHandler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intlayerNitroHandler.d.ts","names":[],"sources":["../../src/intlayerNitroHandler.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"intlayerNitroHandler.d.ts","names":[],"sources":["../../src/intlayerNitroHandler.ts"],"mappings":";;;;;;;;KAyBK;;;;;;EAMH,KAAK;;;;;WAKI,SAAS;;;;;WAKT;aACE,SAAS;;;;;;;;;;;;;;;;;;;;;;iBAoCN,SAAA,OAAO,cAAc"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { IntlayerConfig } from "@intlayer/types/config";
|
|
2
2
|
import { PluginOption } from "vite";
|
|
3
3
|
import { CallerDescriptor, PruneContext } from "@intlayer/babel";
|
|
4
|
-
//#region src/intlayerOptimizePlugin.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Returns the Vite plugins responsible for the build optimisation step.
|
|
7
6
|
*
|
|
@@ -25,5 +24,4 @@ import { CallerDescriptor, PruneContext } from "@intlayer/babel";
|
|
|
25
24
|
* disabled).
|
|
26
25
|
*/
|
|
27
26
|
export declare const intlayerOptimize: (intlayerConfig: IntlayerConfig, pruneContext: PruneContext | null, compatCallers?: CallerDescriptor[]) => Promise<PluginOption[]>;
|
|
28
|
-
//#endregion
|
|
29
27
|
//# sourceMappingURL=intlayerOptimizePlugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intlayerOptimizePlugin.d.ts","names":[],"sources":["../../src/intlayerOptimizePlugin.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"intlayerOptimizePlugin.d.ts","names":[],"sources":["../../src/intlayerOptimizePlugin.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;qBA+Da,mBAAgB,gBACX,gBAAc,cAChB,qBAAmB,gBACjB,uBACf,QAAQ"}
|
|
@@ -2,7 +2,6 @@ import { IntlayerProxyPluginOptions } from "./intlayerProxyPlugin.js";
|
|
|
2
2
|
import { GetConfigurationOptions } from "@intlayer/config/node";
|
|
3
3
|
import { PluginOption } from "vite";
|
|
4
4
|
import { CompatCallerConfig } from "@intlayer/babel";
|
|
5
|
-
//#region src/intlayerPlugin.d.ts
|
|
6
5
|
/**
|
|
7
6
|
* Packages that must go through Vite's transform pipeline instead of being
|
|
8
7
|
* loaded natively by Node.
|
|
@@ -96,5 +95,4 @@ export declare const intlayer: typeof intlayerPlugin;
|
|
|
96
95
|
* ```
|
|
97
96
|
*/
|
|
98
97
|
export declare const intLayerPlugin: typeof intlayerPlugin;
|
|
99
|
-
//#endregion
|
|
100
98
|
//# sourceMappingURL=intlayerPlugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intlayerPlugin.d.ts","names":[],"sources":["../../src/intlayerPlugin.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"intlayerPlugin.d.ts","names":[],"sources":["../../src/intlayerPlugin.ts"],"mappings":";;;;;;;;;;;;;;qBA8Ca,8BAA4B;;;;;;;;;;YAW7B,wBAAwB;;;;;;;;EAQlC,gBAAgB;;;;;;;;;;;;;;;EAgBhB,QAAQ,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;qBA0BF,iBAAc,gBACT,0BACf;;;;;;;;;;;qBAkOU,iBAAQ;;;;;;;;;;;;;qBAaR,uBAAc"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { IntlayerConfig } from "@intlayer/types/config";
|
|
2
2
|
import { Plugin } from "vite";
|
|
3
|
-
//#region src/intlayerPreloadPlugin.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Makes dictionaries load with the chunk that needs them, instead of being
|
|
6
5
|
* requested once that chunk renders.
|
|
@@ -29,5 +28,4 @@ import { Plugin } from "vite";
|
|
|
29
28
|
* @param intlayerConfig - Resolved Intlayer configuration.
|
|
30
29
|
*/
|
|
31
30
|
export declare const intlayerPreload: (intlayerConfig: IntlayerConfig) => Plugin;
|
|
32
|
-
//#endregion
|
|
33
31
|
//# sourceMappingURL=intlayerPreloadPlugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intlayerPreloadPlugin.d.ts","names":[],"sources":["../../src/intlayerPreloadPlugin.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"intlayerPreloadPlugin.d.ts","names":[],"sources":["../../src/intlayerPreloadPlugin.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAmDa,kBAAe,gBAAoB,mBAAiB"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { IntlayerConfig } from "@intlayer/types/config";
|
|
2
2
|
import { IncomingMessage, ServerResponse } from "node:http";
|
|
3
|
-
//#region src/intlayerProxyHandler.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Detects a process that only exists to prerender pages: a TanStack Start
|
|
6
5
|
* build (flag set on the build process, which loads the server in-process) or
|
|
@@ -57,5 +56,4 @@ export type IntlayerProxyHandlerOptions = {
|
|
|
57
56
|
* @see `createIntlayerProxyHandler` for the public, configuration-loading entry point.
|
|
58
57
|
*/
|
|
59
58
|
export declare const createProxyHandler: (options: IntlayerProxyHandlerOptions) => NodeMiddleware;
|
|
60
|
-
//#endregion
|
|
61
59
|
//# sourceMappingURL=intlayerProxyHandler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intlayerProxyHandler.d.ts","names":[],"sources":["../../src/intlayerProxyHandler.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"intlayerProxyHandler.d.ts","names":[],"sources":["../../src/intlayerProxyHandler.ts"],"mappings":";;;;;;;;;;;;;qBAyDa;;;;;;YAuFD,kBACV,KAAK,iBACL,KAAK,eAAe,kBACpB;YAGU;;;;EAIV,eAAe;;;;;;;EAOf,UAAU,KAAK;;;;;;;;;EASf;;;;;;;;;;;;;;;;;qBAkBW,qBAAkB,SACpB,gCACR"}
|
|
@@ -2,7 +2,6 @@ import { NodeMiddleware } from "./intlayerProxyHandler.js";
|
|
|
2
2
|
import { GetConfigurationOptions } from "@intlayer/config/node";
|
|
3
3
|
import { Plugin } from "vite";
|
|
4
4
|
import { IncomingMessage } from "node:http";
|
|
5
|
-
//#region src/intlayerProxyPlugin.d.ts
|
|
6
5
|
/**
|
|
7
6
|
* Restricts a proxy middleware to its redirects: a request the proxy lets
|
|
8
7
|
* through continues with the URL the browser sent, any internal rewrite
|
|
@@ -154,5 +153,4 @@ export declare const intlayerMiddleware: typeof intlayerProxy;
|
|
|
154
153
|
* ```
|
|
155
154
|
*/
|
|
156
155
|
export declare const intLayerMiddlewarePlugin: typeof intlayerProxy;
|
|
157
|
-
//#endregion
|
|
158
156
|
//# sourceMappingURL=intlayerProxyPlugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intlayerProxyPlugin.d.ts","names":[],"sources":["../../src/intlayerProxyPlugin.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"intlayerProxyPlugin.d.ts","names":[],"sources":["../../src/intlayerProxyPlugin.ts"],"mappings":";;;;;;;;;qBAqDa,+BAA4B,SAC7B,mBAAiB;YAUjB;;;;;;;;;;;;;;EAcV,UAAU,KAAK;;;;;;;;;;;EAWf,gBAAgB;;;;;;;;;;;;;;;;;EAiBhB;;;;;;;;;;;;;;;;;;;;;;;;qBAyBW,6BAA0B,UAC3B,+BACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAyDU,0BAAuB,mBACjB,UACR,KAAK;qBAIH,gBAAa,UAAc,+BAA6B;;;;;;;;;;;;;qBA+KxD,2BAAkB;;;;;;;;;;;;;qBAclB,iCAAwB"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { IntlayerConfig } from "@intlayer/types/config";
|
|
2
2
|
import { PluginOption } from "vite";
|
|
3
3
|
import { PruneContext } from "@intlayer/babel";
|
|
4
|
-
//#region src/intlayerPrunePlugin.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Returns the Vite plugin that removes unused content fields from compiled
|
|
7
6
|
* dictionary JSON files during a production build.
|
|
@@ -35,5 +34,4 @@ import { PruneContext } from "@intlayer/babel";
|
|
|
35
34
|
* runs inside `intlayerOptimizePlugin`.
|
|
36
35
|
*/
|
|
37
36
|
export declare const intlayerPrune: (intlayerConfig: IntlayerConfig, pruneContext: PruneContext) => PluginOption[];
|
|
38
|
-
//#endregion
|
|
39
37
|
//# sourceMappingURL=intlayerPrunePlugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intlayerPrunePlugin.d.ts","names":[],"sources":["../../src/intlayerPrunePlugin.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"intlayerPrunePlugin.d.ts","names":[],"sources":["../../src/intlayerPrunePlugin.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAiNa,gBAAa,gBACR,gBAAc,cAChB,iBACb"}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { IntlayerConfig } from "@intlayer/types/config";
|
|
2
2
|
import { PluginOption } from "vite";
|
|
3
|
-
//#region src/intlayerVueAsyncPlugin.d.ts
|
|
4
3
|
export declare const intlayerVueAsyncPlugin: (configuration: IntlayerConfig, filesList: string[]) => PluginOption;
|
|
5
|
-
//#endregion
|
|
6
4
|
//# sourceMappingURL=intlayerVueAsyncPlugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intlayerVueAsyncPlugin.d.ts","names":[],"sources":["../../src/intlayerVueAsyncPlugin.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"intlayerVueAsyncPlugin.d.ts","names":[],"sources":["../../src/intlayerVueAsyncPlugin.ts"],"mappings":";;qBAIa,yBAAsB,eAClB,gBAAc,wBAE5B"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { IntlayerProxyHandlerOptions, NodeMiddleware } from "./intlayerProxyHandler.js";
|
|
2
|
-
//#region src/intlayerWebProxyHandler.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Subset of a Web request the proxy needs.
|
|
5
4
|
*/
|
|
@@ -62,5 +61,4 @@ export type IntlayerWebProxyHandler = (request: WebProxyRequest) => WebProxyOutc
|
|
|
62
61
|
* ```
|
|
63
62
|
*/
|
|
64
63
|
export declare const createIntlayerWebProxyHandler: (options: IntlayerProxyHandlerOptions) => IntlayerWebProxyHandler;
|
|
65
|
-
//#endregion
|
|
66
64
|
//# sourceMappingURL=intlayerWebProxyHandler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intlayerWebProxyHandler.d.ts","names":[],"sources":["../../src/intlayerWebProxyHandler.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"intlayerWebProxyHandler.d.ts","names":[],"sources":["../../src/intlayerWebProxyHandler.ts"],"mappings":";;;;YAsBY;;EAEV,KAAK;;EAEL,SAAS;;;;;;;;;;;;YAaC;EACN;EAAkB,UAAU;;EAC5B;EAAc;EAAmC,SAAS;;;;;;;;;;;;;;;;qBA8BnD,uBAAoB,gBACf,gBAAc,SACrB,oBACR;;;;YAoFS,2BACV,SAAS,oBACN;;;;;;;;;;;;;;;;qBAiBQ,gCAA6B,SAC/B,gCACR"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-intlayer",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.7.1",
|
|
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": [
|
|
@@ -87,27 +87,27 @@
|
|
|
87
87
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
88
88
|
},
|
|
89
89
|
"dependencies": {
|
|
90
|
-
"@intlayer/babel": "9.
|
|
91
|
-
"@intlayer/config": "9.
|
|
92
|
-
"@intlayer/core": "9.
|
|
93
|
-
"@intlayer/dictionaries-entry": "9.
|
|
94
|
-
"@intlayer/engine": "9.
|
|
95
|
-
"@intlayer/types": "9.
|
|
90
|
+
"@intlayer/babel": "9.7.1",
|
|
91
|
+
"@intlayer/config": "9.7.1",
|
|
92
|
+
"@intlayer/core": "9.7.1",
|
|
93
|
+
"@intlayer/dictionaries-entry": "9.7.1",
|
|
94
|
+
"@intlayer/engine": "9.7.1",
|
|
95
|
+
"@intlayer/types": "9.7.1"
|
|
96
96
|
},
|
|
97
97
|
"devDependencies": {
|
|
98
|
-
"@types/node": "^
|
|
98
|
+
"@types/node": "^26",
|
|
99
99
|
"@utils/ts-config": "1.0.4",
|
|
100
100
|
"@utils/ts-config-types": "1.0.4",
|
|
101
101
|
"@utils/tsdown-config": "1.0.4",
|
|
102
102
|
"rimraf": "6.1.3",
|
|
103
|
-
"tsdown": "0.23.
|
|
103
|
+
"tsdown": "0.23.4",
|
|
104
104
|
"typescript": "7.0.2",
|
|
105
|
-
"vitest": "5.0
|
|
105
|
+
"vitest": "5.1.0"
|
|
106
106
|
},
|
|
107
107
|
"peerDependencies": {
|
|
108
108
|
"@babel/core": ">=6.0.0",
|
|
109
|
-
"@intlayer/svelte-compiler": "9.
|
|
110
|
-
"@intlayer/vue-compiler": "9.
|
|
109
|
+
"@intlayer/svelte-compiler": "9.7.1",
|
|
110
|
+
"@intlayer/vue-compiler": "9.7.1",
|
|
111
111
|
"h3": ">=1.0.0",
|
|
112
112
|
"vite": ">=4.0.0"
|
|
113
113
|
},
|