vite-intlayer 4.1.1 → 4.1.2
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.
|
@@ -36,17 +36,19 @@ var import_process = __toESM(require("process"));
|
|
|
36
36
|
var import_chokidar = require("@intlayer/chokidar");
|
|
37
37
|
var import_config = require("@intlayer/config");
|
|
38
38
|
var import_vite = require("vite");
|
|
39
|
+
let mode;
|
|
39
40
|
const intlayerPlugin = (_pluginOptions = {}) => ({
|
|
40
41
|
name: "vite-intlayer-plugin",
|
|
41
|
-
config: (config,
|
|
42
|
-
|
|
43
|
-
const { mainDir, baseDir, watch: isWatchMode } = intlayerConfig.content;
|
|
42
|
+
config: (config, envObject) => {
|
|
43
|
+
mode = envObject.mode;
|
|
44
44
|
const env = (0, import_config.formatEnvVariable)("vite");
|
|
45
45
|
import_process.default.env = {
|
|
46
46
|
...import_process.default.env,
|
|
47
47
|
...(0, import_vite.loadEnv)(mode, import_process.default.cwd()),
|
|
48
48
|
...env
|
|
49
49
|
};
|
|
50
|
+
const intlayerConfig = (0, import_config.getConfiguration)();
|
|
51
|
+
const { mainDir, baseDir, watch: isWatchMode } = intlayerConfig.content;
|
|
50
52
|
const dictionariesPath = (0, import_path.join)(mainDir, "dictionaries.mjs");
|
|
51
53
|
const relativeDictionariesPath = (0, import_path.relative)(baseDir, dictionariesPath);
|
|
52
54
|
config.resolve = {
|
|
@@ -75,10 +77,12 @@ const intlayerPlugin = (_pluginOptions = {}) => ({
|
|
|
75
77
|
};
|
|
76
78
|
return config;
|
|
77
79
|
},
|
|
78
|
-
buildStart: () => {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
buildStart: async () => {
|
|
81
|
+
try {
|
|
82
|
+
await (0, import_chokidar.buildAndWatchIntlayer)();
|
|
83
|
+
} catch (error) {
|
|
84
|
+
console.error("Error starting the watch process:", error);
|
|
85
|
+
}
|
|
82
86
|
}
|
|
83
87
|
});
|
|
84
88
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/intlayerPlugin.ts"],"sourcesContent":["import { join, relative, resolve } from 'path';\nimport process from 'process';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/intlayerPlugin.ts"],"sourcesContent":["import { join, relative, resolve } from 'path';\nimport process from 'process';\nimport { buildAndWatchIntlayer } from '@intlayer/chokidar';\nimport { getConfiguration, formatEnvVariable } from '@intlayer/config';\n// @ts-ignore - Fix error Module '\"vite\"' has no exported member\nimport { loadEnv, type PluginOption } from 'vite';\n\n// Plugin options type definition\ntype PluginOptions = {\n // Custom options for your plugin, if any\n};\n\nlet mode: string; // Shared variable to store the mode\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: [ intlayerPlugin() ],\n * });\n * ```\n * */\nexport const intlayerPlugin = (\n _pluginOptions: PluginOptions = {}\n): PluginOption => ({\n name: 'vite-intlayer-plugin',\n\n config: (config, envObject) => {\n // Store the mode\n mode = envObject.mode;\n\n // Set all configuration values as environment variables\n const env = formatEnvVariable('vite');\n\n process.env = {\n ...process.env,\n ...loadEnv(mode, process.cwd()),\n ...env,\n };\n\n const intlayerConfig = getConfiguration();\n const { mainDir, baseDir, watch: isWatchMode } = intlayerConfig.content;\n\n const dictionariesPath = join(mainDir, 'dictionaries.mjs');\n const relativeDictionariesPath = relative(baseDir, dictionariesPath);\n\n // Update Vite's resolve alias\n config.resolve = {\n ...config.resolve,\n alias: {\n ...config.resolve?.alias,\n '@intlayer/dictionaries-entry': resolve(relativeDictionariesPath),\n },\n };\n\n if (isWatchMode) {\n // Ajout de l'option optimizeDeps.exclude\n config.optimizeDeps = {\n ...config.optimizeDeps,\n exclude: [\n ...(config.optimizeDeps?.exclude || []),\n '@intlayer/dictionaries-entry',\n ],\n };\n }\n\n const externals: string[] = (config.build?.rollupOptions?.external ??\n []) as string[];\n\n config.build = {\n ...config.build,\n rollupOptions: {\n ...config.build?.rollupOptions,\n external: [...externals, 'module'],\n },\n };\n\n return config;\n },\n\n buildStart: async () => {\n // Code to run when Vite build starts\n try {\n await buildAndWatchIntlayer();\n } catch (error) {\n console.error('Error starting the watch process:', error);\n }\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAwC;AACxC,qBAAoB;AACpB,sBAAsC;AACtC,oBAAoD;AAEpD,kBAA2C;AAO3C,IAAI;AAaG,MAAM,iBAAiB,CAC5B,iBAAgC,CAAC,OACf;AAAA,EAClB,MAAM;AAAA,EAEN,QAAQ,CAAC,QAAQ,cAAc;AAE7B,WAAO,UAAU;AAGjB,UAAM,UAAM,iCAAkB,MAAM;AAEpC,mBAAAA,QAAQ,MAAM;AAAA,MACZ,GAAG,eAAAA,QAAQ;AAAA,MACX,OAAG,qBAAQ,MAAM,eAAAA,QAAQ,IAAI,CAAC;AAAA,MAC9B,GAAG;AAAA,IACL;AAEA,UAAM,qBAAiB,gCAAiB;AACxC,UAAM,EAAE,SAAS,SAAS,OAAO,YAAY,IAAI,eAAe;AAEhE,UAAM,uBAAmB,kBAAK,SAAS,kBAAkB;AACzD,UAAM,+BAA2B,sBAAS,SAAS,gBAAgB;AAGnE,WAAO,UAAU;AAAA,MACf,GAAG,OAAO;AAAA,MACV,OAAO;AAAA,QACL,GAAG,OAAO,SAAS;AAAA,QACnB,oCAAgC,qBAAQ,wBAAwB;AAAA,MAClE;AAAA,IACF;AAEA,QAAI,aAAa;AAEf,aAAO,eAAe;AAAA,QACpB,GAAG,OAAO;AAAA,QACV,SAAS;AAAA,UACP,GAAI,OAAO,cAAc,WAAW,CAAC;AAAA,UACrC;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAEA,UAAM,YAAuB,OAAO,OAAO,eAAe,YACxD,CAAC;AAEH,WAAO,QAAQ;AAAA,MACb,GAAG,OAAO;AAAA,MACV,eAAe;AAAA,QACb,GAAG,OAAO,OAAO;AAAA,QACjB,UAAU,CAAC,GAAG,WAAW,QAAQ;AAAA,MACnC;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAAA,EAEA,YAAY,YAAY;AAEtB,QAAI;AACF,gBAAM,uCAAsB;AAAA,IAC9B,SAAS,OAAO;AACd,cAAQ,MAAM,qCAAqC,KAAK;AAAA,IAC1D;AAAA,EACF;AACF;","names":["process"]}
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import { join, relative, resolve } from "path";
|
|
2
2
|
import process from "process";
|
|
3
|
-
import {
|
|
3
|
+
import { buildAndWatchIntlayer } from "@intlayer/chokidar";
|
|
4
4
|
import { getConfiguration, formatEnvVariable } from "@intlayer/config";
|
|
5
5
|
import { loadEnv } from "vite";
|
|
6
|
+
let mode;
|
|
6
7
|
const intlayerPlugin = (_pluginOptions = {}) => ({
|
|
7
8
|
name: "vite-intlayer-plugin",
|
|
8
|
-
config: (config,
|
|
9
|
-
|
|
10
|
-
const { mainDir, baseDir, watch: isWatchMode } = intlayerConfig.content;
|
|
9
|
+
config: (config, envObject) => {
|
|
10
|
+
mode = envObject.mode;
|
|
11
11
|
const env = formatEnvVariable("vite");
|
|
12
12
|
process.env = {
|
|
13
13
|
...process.env,
|
|
14
14
|
...loadEnv(mode, process.cwd()),
|
|
15
15
|
...env
|
|
16
16
|
};
|
|
17
|
+
const intlayerConfig = getConfiguration();
|
|
18
|
+
const { mainDir, baseDir, watch: isWatchMode } = intlayerConfig.content;
|
|
17
19
|
const dictionariesPath = join(mainDir, "dictionaries.mjs");
|
|
18
20
|
const relativeDictionariesPath = relative(baseDir, dictionariesPath);
|
|
19
21
|
config.resolve = {
|
|
@@ -42,10 +44,12 @@ const intlayerPlugin = (_pluginOptions = {}) => ({
|
|
|
42
44
|
};
|
|
43
45
|
return config;
|
|
44
46
|
},
|
|
45
|
-
buildStart: () => {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
buildStart: async () => {
|
|
48
|
+
try {
|
|
49
|
+
await buildAndWatchIntlayer();
|
|
50
|
+
} catch (error) {
|
|
51
|
+
console.error("Error starting the watch process:", error);
|
|
52
|
+
}
|
|
49
53
|
}
|
|
50
54
|
});
|
|
51
55
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/intlayerPlugin.ts"],"sourcesContent":["import { join, relative, resolve } from 'path';\nimport process from 'process';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/intlayerPlugin.ts"],"sourcesContent":["import { join, relative, resolve } from 'path';\nimport process from 'process';\nimport { buildAndWatchIntlayer } from '@intlayer/chokidar';\nimport { getConfiguration, formatEnvVariable } from '@intlayer/config';\n// @ts-ignore - Fix error Module '\"vite\"' has no exported member\nimport { loadEnv, type PluginOption } from 'vite';\n\n// Plugin options type definition\ntype PluginOptions = {\n // Custom options for your plugin, if any\n};\n\nlet mode: string; // Shared variable to store the mode\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: [ intlayerPlugin() ],\n * });\n * ```\n * */\nexport const intlayerPlugin = (\n _pluginOptions: PluginOptions = {}\n): PluginOption => ({\n name: 'vite-intlayer-plugin',\n\n config: (config, envObject) => {\n // Store the mode\n mode = envObject.mode;\n\n // Set all configuration values as environment variables\n const env = formatEnvVariable('vite');\n\n process.env = {\n ...process.env,\n ...loadEnv(mode, process.cwd()),\n ...env,\n };\n\n const intlayerConfig = getConfiguration();\n const { mainDir, baseDir, watch: isWatchMode } = intlayerConfig.content;\n\n const dictionariesPath = join(mainDir, 'dictionaries.mjs');\n const relativeDictionariesPath = relative(baseDir, dictionariesPath);\n\n // Update Vite's resolve alias\n config.resolve = {\n ...config.resolve,\n alias: {\n ...config.resolve?.alias,\n '@intlayer/dictionaries-entry': resolve(relativeDictionariesPath),\n },\n };\n\n if (isWatchMode) {\n // Ajout de l'option optimizeDeps.exclude\n config.optimizeDeps = {\n ...config.optimizeDeps,\n exclude: [\n ...(config.optimizeDeps?.exclude || []),\n '@intlayer/dictionaries-entry',\n ],\n };\n }\n\n const externals: string[] = (config.build?.rollupOptions?.external ??\n []) as string[];\n\n config.build = {\n ...config.build,\n rollupOptions: {\n ...config.build?.rollupOptions,\n external: [...externals, 'module'],\n },\n };\n\n return config;\n },\n\n buildStart: async () => {\n // Code to run when Vite build starts\n try {\n await buildAndWatchIntlayer();\n } catch (error) {\n console.error('Error starting the watch process:', error);\n }\n },\n});\n"],"mappings":"AAAA,SAAS,MAAM,UAAU,eAAe;AACxC,OAAO,aAAa;AACpB,SAAS,6BAA6B;AACtC,SAAS,kBAAkB,yBAAyB;AAEpD,SAAS,eAAkC;AAO3C,IAAI;AAaG,MAAM,iBAAiB,CAC5B,iBAAgC,CAAC,OACf;AAAA,EAClB,MAAM;AAAA,EAEN,QAAQ,CAAC,QAAQ,cAAc;AAE7B,WAAO,UAAU;AAGjB,UAAM,MAAM,kBAAkB,MAAM;AAEpC,YAAQ,MAAM;AAAA,MACZ,GAAG,QAAQ;AAAA,MACX,GAAG,QAAQ,MAAM,QAAQ,IAAI,CAAC;AAAA,MAC9B,GAAG;AAAA,IACL;AAEA,UAAM,iBAAiB,iBAAiB;AACxC,UAAM,EAAE,SAAS,SAAS,OAAO,YAAY,IAAI,eAAe;AAEhE,UAAM,mBAAmB,KAAK,SAAS,kBAAkB;AACzD,UAAM,2BAA2B,SAAS,SAAS,gBAAgB;AAGnE,WAAO,UAAU;AAAA,MACf,GAAG,OAAO;AAAA,MACV,OAAO;AAAA,QACL,GAAG,OAAO,SAAS;AAAA,QACnB,gCAAgC,QAAQ,wBAAwB;AAAA,MAClE;AAAA,IACF;AAEA,QAAI,aAAa;AAEf,aAAO,eAAe;AAAA,QACpB,GAAG,OAAO;AAAA,QACV,SAAS;AAAA,UACP,GAAI,OAAO,cAAc,WAAW,CAAC;AAAA,UACrC;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAEA,UAAM,YAAuB,OAAO,OAAO,eAAe,YACxD,CAAC;AAEH,WAAO,QAAQ;AAAA,MACb,GAAG,OAAO;AAAA,MACV,eAAe;AAAA,QACb,GAAG,OAAO,OAAO;AAAA,QACjB,UAAU,CAAC,GAAG,WAAW,QAAQ;AAAA,MACnC;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAAA,EAEA,YAAY,YAAY;AAEtB,QAAI;AACF,YAAM,sBAAsB;AAAA,IAC9B,SAAS,OAAO;AACd,cAAQ,MAAM,qCAAqC,KAAK;AAAA,IAC1D;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type PluginOption } from 'vite';
|
|
2
2
|
type PluginOptions = {};
|
|
3
3
|
/**
|
|
4
4
|
*
|
|
@@ -11,6 +11,6 @@ type PluginOptions = {};
|
|
|
11
11
|
* });
|
|
12
12
|
* ```
|
|
13
13
|
* */
|
|
14
|
-
export declare const intlayerPlugin: (_pluginOptions?: PluginOptions) =>
|
|
14
|
+
export declare const intlayerPlugin: (_pluginOptions?: PluginOptions) => PluginOption;
|
|
15
15
|
export {};
|
|
16
16
|
//# sourceMappingURL=intlayerPlugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intlayerPlugin.d.ts","sourceRoot":"","sources":["../../src/intlayerPlugin.ts"],"names":[],"mappings":"AAKA,OAAO,EAAW,KAAK,
|
|
1
|
+
{"version":3,"file":"intlayerPlugin.d.ts","sourceRoot":"","sources":["../../src/intlayerPlugin.ts"],"names":[],"mappings":"AAKA,OAAO,EAAW,KAAK,YAAY,EAAE,MAAM,MAAM,CAAC;AAGlD,KAAK,aAAa,GAAG,EAEpB,CAAC;AAIF;;;;;;;;;;MAUM;AACN,eAAO,MAAM,cAAc,oBACT,aAAa,KAC5B,YAgED,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-intlayer",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.2",
|
|
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": [
|
|
@@ -57,10 +57,10 @@
|
|
|
57
57
|
"./package.json"
|
|
58
58
|
],
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"vite": "^6.0.
|
|
61
|
-
"@intlayer/config": "4.1.
|
|
62
|
-
"@intlayer/core": "4.1.
|
|
63
|
-
"@intlayer/chokidar": "4.1.
|
|
60
|
+
"vite": "^6.0.11",
|
|
61
|
+
"@intlayer/config": "4.1.2",
|
|
62
|
+
"@intlayer/core": "4.1.2",
|
|
63
|
+
"@intlayer/chokidar": "4.1.2"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@types/node": "^22.10.6",
|
|
@@ -72,16 +72,16 @@
|
|
|
72
72
|
"tsc-alias": "^1.8.10",
|
|
73
73
|
"tsup": "^8.3.5",
|
|
74
74
|
"typescript": "^5.7.3",
|
|
75
|
-
"@utils/eslint-config": "1.0.4",
|
|
76
75
|
"@utils/ts-config": "1.0.4",
|
|
76
|
+
"@utils/eslint-config": "1.0.4",
|
|
77
77
|
"@utils/ts-config-types": "1.0.4",
|
|
78
78
|
"@utils/tsup-config": "1.0.4"
|
|
79
79
|
},
|
|
80
80
|
"peerDependencies": {
|
|
81
81
|
"vite": ">=4.0.0",
|
|
82
|
-
"@intlayer/
|
|
83
|
-
"@intlayer/
|
|
84
|
-
"@intlayer/core": "4.1.
|
|
82
|
+
"@intlayer/chokidar": "4.1.2",
|
|
83
|
+
"@intlayer/config": "4.1.2",
|
|
84
|
+
"@intlayer/core": "4.1.2"
|
|
85
85
|
},
|
|
86
86
|
"engines": {
|
|
87
87
|
"node": ">=14.18"
|