vite-intlayer 5.6.0 → 5.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/cjs/intlayerPlugin.cjs +17 -10
- package/dist/cjs/intlayerPlugin.cjs.map +1 -1
- package/dist/cjs/intlayerPrunePlugin.cjs +6 -5
- package/dist/cjs/intlayerPrunePlugin.cjs.map +1 -1
- package/dist/esm/intlayerPlugin.mjs +5 -8
- package/dist/esm/intlayerPlugin.mjs.map +1 -1
- package/dist/esm/intlayerPrunePlugin.mjs +6 -5
- package/dist/esm/intlayerPrunePlugin.mjs.map +1 -1
- package/dist/types/intlayerPlugin.d.ts.map +1 -1
- package/dist/types/intlayerPrunePlugin.d.ts +2 -1
- package/dist/types/intlayerPrunePlugin.d.ts.map +1 -1
- package/package.json +11 -11
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
var intlayerPlugin_exports = {};
|
|
20
30
|
__export(intlayerPlugin_exports, {
|
|
@@ -22,19 +32,18 @@ __export(intlayerPlugin_exports, {
|
|
|
22
32
|
});
|
|
23
33
|
module.exports = __toCommonJS(intlayerPlugin_exports);
|
|
24
34
|
var import_chokidar = require("@intlayer/chokidar");
|
|
25
|
-
var
|
|
35
|
+
var import_built = __toESM(require("@intlayer/config/built"));
|
|
26
36
|
var import_path = require("path");
|
|
27
37
|
var import_intlayerPrunePlugin = require('./intlayerPrunePlugin.cjs');
|
|
28
38
|
(0, import_chokidar.cleanOutputDir)();
|
|
29
39
|
const intlayerPlugin = (pluginOptions = {}) => {
|
|
30
|
-
const intlayerConfig = (0, import_config.getConfiguration)();
|
|
31
40
|
const {
|
|
32
41
|
mainDir,
|
|
33
42
|
configDir,
|
|
34
43
|
baseDir,
|
|
35
44
|
watch: isWatchMode
|
|
36
|
-
} =
|
|
37
|
-
const { optimize } =
|
|
45
|
+
} = import_built.default.content;
|
|
46
|
+
const { optimize } = import_built.default.build;
|
|
38
47
|
const plugins = [
|
|
39
48
|
{
|
|
40
49
|
name: "vite-intlayer-plugin",
|
|
@@ -76,19 +85,17 @@ const intlayerPlugin = (pluginOptions = {}) => {
|
|
|
76
85
|
return config;
|
|
77
86
|
},
|
|
78
87
|
configureServer: async (server) => {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
(0, import_chokidar.watch)({ configuration: intlayerConfig2 });
|
|
88
|
+
if (import_built.default.content.watch) {
|
|
89
|
+
(0, import_chokidar.watch)({ configuration: import_built.default });
|
|
82
90
|
}
|
|
83
91
|
},
|
|
84
92
|
buildStart: async () => {
|
|
85
|
-
|
|
86
|
-
await (0, import_chokidar.prepareIntlayer)(intlayerConfig2);
|
|
93
|
+
await (0, import_chokidar.prepareIntlayer)(import_built.default);
|
|
87
94
|
}
|
|
88
95
|
}
|
|
89
96
|
];
|
|
90
97
|
if (optimize) {
|
|
91
|
-
plugins.push((0, import_intlayerPrunePlugin.IntlayerPrunePlugin)());
|
|
98
|
+
plugins.push((0, import_intlayerPrunePlugin.IntlayerPrunePlugin)(import_built.default));
|
|
92
99
|
}
|
|
93
100
|
return plugins;
|
|
94
101
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/intlayerPlugin.ts"],"sourcesContent":["import { cleanOutputDir, prepareIntlayer, watch } from '@intlayer/chokidar';\nimport
|
|
1
|
+
{"version":3,"sources":["../../src/intlayerPlugin.ts"],"sourcesContent":["import { cleanOutputDir, prepareIntlayer, watch } from '@intlayer/chokidar';\nimport intlayerConfig from '@intlayer/config/built';\nimport { join, relative, resolve } from 'path';\n// @ts-ignore - Fix error Module '\"vite\"' has no exported member\nimport { type PluginOption } from 'vite';\nimport { IntlayerPrunePlugin } from './intlayerPrunePlugin';\n\ncleanOutputDir();\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 = (pluginOptions = {}): PluginOption => {\n const {\n mainDir,\n configDir,\n baseDir,\n watch: isWatchMode,\n } = intlayerConfig.content;\n const { optimize } = intlayerConfig.build;\n\n const plugins: PluginOption[] = [\n {\n name: 'vite-intlayer-plugin',\n\n config: (config) => {\n const dictionariesPath = join(mainDir, 'dictionaries.mjs');\n const relativeDictionariesPath = relative(baseDir, dictionariesPath);\n\n const unmergedDictionariesPath = join(\n mainDir,\n 'unmerged_dictionaries.mjs'\n );\n const relativeUnmergedDictionariesPath = relative(\n baseDir,\n unmergedDictionariesPath\n );\n\n const configurationPath = join(configDir, 'configuration.json');\n const relativeConfigurationPath = relative(baseDir, configurationPath);\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 '@intlayer/unmerged-dictionaries-entry': resolve(\n relativeUnmergedDictionariesPath\n ),\n '@intlayer/config/built': resolve(relativeConfigurationPath),\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 '@intlayer/unmerged-dictionaries-entry',\n '@intlayer/config/built',\n ],\n };\n }\n\n return config;\n },\n\n configureServer: async (server) => {\n if (intlayerConfig.content.watch) {\n // Start watching (assuming watch is also async)\n watch({ configuration: intlayerConfig });\n }\n },\n\n buildStart: async () => {\n // Code to run when Vite build starts\n await prepareIntlayer(intlayerConfig);\n },\n },\n ];\n\n // Add Babel transform plugin if enabled\n if (optimize) {\n plugins.push(IntlayerPrunePlugin(intlayerConfig));\n }\n\n return plugins;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAuD;AACvD,mBAA2B;AAC3B,kBAAwC;AAGxC,iCAAoC;AAAA,IAEpC,gCAAe;AAaR,MAAM,iBAAiB,CAAC,gBAAgB,CAAC,MAAoB;AAClE,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO;AAAA,EACT,IAAI,aAAAA,QAAe;AACnB,QAAM,EAAE,SAAS,IAAI,aAAAA,QAAe;AAEpC,QAAM,UAA0B;AAAA,IAC9B;AAAA,MACE,MAAM;AAAA,MAEN,QAAQ,CAAC,WAAW;AAClB,cAAM,uBAAmB,kBAAK,SAAS,kBAAkB;AACzD,cAAM,+BAA2B,sBAAS,SAAS,gBAAgB;AAEnE,cAAM,+BAA2B;AAAA,UAC/B;AAAA,UACA;AAAA,QACF;AACA,cAAM,uCAAmC;AAAA,UACvC;AAAA,UACA;AAAA,QACF;AAEA,cAAM,wBAAoB,kBAAK,WAAW,oBAAoB;AAC9D,cAAM,gCAA4B,sBAAS,SAAS,iBAAiB;AAGrE,eAAO,UAAU;AAAA,UACf,GAAG,OAAO;AAAA,UACV,OAAO;AAAA,YACL,GAAG,OAAO,SAAS;AAAA,YACnB,oCAAgC,qBAAQ,wBAAwB;AAAA,YAChE,6CAAyC;AAAA,cACvC;AAAA,YACF;AAAA,YACA,8BAA0B,qBAAQ,yBAAyB;AAAA,UAC7D;AAAA,QACF;AAEA,YAAI,aAAa;AAEf,iBAAO,eAAe;AAAA,YACpB,GAAG,OAAO;AAAA,YACV,SAAS;AAAA,cACP,GAAI,OAAO,cAAc,WAAW,CAAC;AAAA,cACrC;AAAA,cACA;AAAA,cACA;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAEA,eAAO;AAAA,MACT;AAAA,MAEA,iBAAiB,OAAO,WAAW;AACjC,YAAI,aAAAA,QAAe,QAAQ,OAAO;AAEhC,qCAAM,EAAE,eAAe,aAAAA,QAAe,CAAC;AAAA,QACzC;AAAA,MACF;AAAA,MAEA,YAAY,YAAY;AAEtB,kBAAM,iCAAgB,aAAAA,OAAc;AAAA,MACtC;AAAA,IACF;AAAA,EACF;AAGA,MAAI,UAAU;AACZ,YAAQ,SAAK,gDAAoB,aAAAA,OAAc,CAAC;AAAA,EAClD;AAEA,SAAO;AACT;","names":["intlayerConfig"]}
|
|
@@ -33,12 +33,12 @@ __export(intlayerPrunePlugin_exports, {
|
|
|
33
33
|
module.exports = __toCommonJS(intlayerPrunePlugin_exports);
|
|
34
34
|
var import_babel = require("@intlayer/babel");
|
|
35
35
|
var import_config = require("@intlayer/config");
|
|
36
|
-
var import_built = __toESM(require("@intlayer/config/built"));
|
|
37
36
|
var import_fast_glob = __toESM(require("fast-glob"));
|
|
38
37
|
var import_path = require("path");
|
|
39
|
-
const IntlayerPrunePlugin = () => {
|
|
40
|
-
const { optimize,
|
|
41
|
-
|
|
38
|
+
const IntlayerPrunePlugin = (intlayerConfig) => {
|
|
39
|
+
const { optimize, importMode, traversePattern } = intlayerConfig.build;
|
|
40
|
+
console.log("intlayerConfig", intlayerConfig);
|
|
41
|
+
const { dictionariesDir, dynamicDictionariesDir, mainDir, baseDir } = intlayerConfig.content;
|
|
42
42
|
const filesListPattern = import_fast_glob.default.sync(traversePattern, {
|
|
43
43
|
cwd: baseDir
|
|
44
44
|
}).map((file) => (0, import_path.join)(baseDir, file));
|
|
@@ -72,7 +72,7 @@ const IntlayerPrunePlugin = () => {
|
|
|
72
72
|
dictionariesEntryPath,
|
|
73
73
|
dynamicDictionariesDir,
|
|
74
74
|
dynamicDictionariesEntryPath,
|
|
75
|
-
|
|
75
|
+
importMode,
|
|
76
76
|
filesList,
|
|
77
77
|
replaceDictionaryEntry: false
|
|
78
78
|
}
|
|
@@ -98,6 +98,7 @@ const IntlayerPrunePlugin = () => {
|
|
|
98
98
|
}
|
|
99
99
|
});
|
|
100
100
|
if (result?.code) {
|
|
101
|
+
console.log("result.code", result.code);
|
|
101
102
|
return {
|
|
102
103
|
code: result.code,
|
|
103
104
|
map: result.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/intlayerPrunePlugin.ts"],"sourcesContent":["// @ts-ignore - Fix error Module '\"vite\"' has no exported member\nimport { intlayerBabelPlugin } from '@intlayer/babel';\nimport { ESMxCJSRequire } from '@intlayer/config';\nimport
|
|
1
|
+
{"version":3,"sources":["../../src/intlayerPrunePlugin.ts"],"sourcesContent":["// @ts-ignore - Fix error Module '\"vite\"' has no exported member\nimport { intlayerBabelPlugin } from '@intlayer/babel';\nimport { ESMxCJSRequire, IntlayerConfig } from '@intlayer/config';\nimport fg from 'fast-glob';\nimport { join } from 'path';\nimport { type PluginOption } from 'vite';\n\nexport const IntlayerPrunePlugin = (\n intlayerConfig: IntlayerConfig\n): PluginOption => {\n const { optimize, importMode, traversePattern } = intlayerConfig.build;\n\n console.log('intlayerConfig', intlayerConfig);\n\n const { dictionariesDir, dynamicDictionariesDir, mainDir, baseDir } =\n intlayerConfig.content;\n\n const filesListPattern = fg\n .sync(traversePattern, {\n cwd: baseDir,\n })\n .map((file) => join(baseDir, file));\n\n return {\n name: 'vite-intlayer-babel-transform',\n enforce: 'post', // Run after other transformations as vue\n transform(code, id) {\n const dictionariesEntryPath = join(mainDir, 'dictionaries.mjs');\n const dynamicDictionariesEntryPath = join(\n mainDir,\n 'dynamic_dictionaries.mjs'\n );\n\n const filesList = [\n ...filesListPattern,\n dictionariesEntryPath, // should add dictionariesEntryPath to replace it by a empty object if import made dynamic\n ];\n\n /**\n * Transform file as\n * .../HelloWorld.vue?vue&type=script&setup=true&lang.ts\n * Into\n * .../HelloWorld.vue\n *\n * Prevention for virtual file\n */\n const filename = id.split('?', 1)[0];\n if (!filesList.includes(filename)) return null;\n if (!optimize) return null;\n\n try {\n const babel = ESMxCJSRequire('@babel/core');\n\n const result = babel.transformSync(code, {\n filename,\n plugins: [\n [\n intlayerBabelPlugin,\n {\n dictionariesDir,\n dictionariesEntryPath,\n dynamicDictionariesDir,\n dynamicDictionariesEntryPath,\n importMode,\n filesList,\n replaceDictionaryEntry: false,\n },\n ],\n ],\n parserOpts: {\n sourceType: 'module',\n allowImportExportEverywhere: true,\n plugins: [\n 'typescript',\n 'jsx',\n 'decorators-legacy',\n 'classProperties',\n 'objectRestSpread',\n 'asyncGenerators',\n 'functionBind',\n 'exportDefaultFrom',\n 'exportNamespaceFrom',\n 'dynamicImport',\n 'nullishCoalescingOperator',\n 'optionalChaining',\n ],\n },\n });\n\n if (result?.code) {\n console.log('result.code', result.code);\n return {\n code: result.code,\n map: result.map,\n };\n }\n } catch (error) {\n console.warn('Failed to transform with Babel plugin:', error);\n }\n\n return null;\n },\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAoC;AACpC,oBAA+C;AAC/C,uBAAe;AACf,kBAAqB;AAGd,MAAM,sBAAsB,CACjC,mBACiB;AACjB,QAAM,EAAE,UAAU,YAAY,gBAAgB,IAAI,eAAe;AAEjE,UAAQ,IAAI,kBAAkB,cAAc;AAE5C,QAAM,EAAE,iBAAiB,wBAAwB,SAAS,QAAQ,IAChE,eAAe;AAEjB,QAAM,mBAAmB,iBAAAA,QACtB,KAAK,iBAAiB;AAAA,IACrB,KAAK;AAAA,EACP,CAAC,EACA,IAAI,CAAC,aAAS,kBAAK,SAAS,IAAI,CAAC;AAEpC,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA;AAAA,IACT,UAAU,MAAM,IAAI;AAClB,YAAM,4BAAwB,kBAAK,SAAS,kBAAkB;AAC9D,YAAM,mCAA+B;AAAA,QACnC;AAAA,QACA;AAAA,MACF;AAEA,YAAM,YAAY;AAAA,QAChB,GAAG;AAAA,QACH;AAAA;AAAA,MACF;AAUA,YAAM,WAAW,GAAG,MAAM,KAAK,CAAC,EAAE,CAAC;AACnC,UAAI,CAAC,UAAU,SAAS,QAAQ,EAAG,QAAO;AAC1C,UAAI,CAAC,SAAU,QAAO;AAEtB,UAAI;AACF,cAAM,YAAQ,8BAAe,aAAa;AAE1C,cAAM,SAAS,MAAM,cAAc,MAAM;AAAA,UACvC;AAAA,UACA,SAAS;AAAA,YACP;AAAA,cACE;AAAA,cACA;AAAA,gBACE;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA,wBAAwB;AAAA,cAC1B;AAAA,YACF;AAAA,UACF;AAAA,UACA,YAAY;AAAA,YACV,YAAY;AAAA,YACZ,6BAA6B;AAAA,YAC7B,SAAS;AAAA,cACP;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,YACF;AAAA,UACF;AAAA,QACF,CAAC;AAED,YAAI,QAAQ,MAAM;AAChB,kBAAQ,IAAI,eAAe,OAAO,IAAI;AACtC,iBAAO;AAAA,YACL,MAAM,OAAO;AAAA,YACb,KAAK,OAAO;AAAA,UACd;AAAA,QACF;AAAA,MACF,SAAS,OAAO;AACd,gBAAQ,KAAK,0CAA0C,KAAK;AAAA,MAC9D;AAEA,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":["fg"]}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { cleanOutputDir, prepareIntlayer, watch } from "@intlayer/chokidar";
|
|
2
|
-
import
|
|
2
|
+
import intlayerConfig from "@intlayer/config/built";
|
|
3
3
|
import { join, relative, resolve } from "path";
|
|
4
4
|
import { IntlayerPrunePlugin } from "./intlayerPrunePlugin.mjs";
|
|
5
5
|
cleanOutputDir();
|
|
6
6
|
const intlayerPlugin = (pluginOptions = {}) => {
|
|
7
|
-
const intlayerConfig = getConfiguration();
|
|
8
7
|
const {
|
|
9
8
|
mainDir,
|
|
10
9
|
configDir,
|
|
@@ -53,19 +52,17 @@ const intlayerPlugin = (pluginOptions = {}) => {
|
|
|
53
52
|
return config;
|
|
54
53
|
},
|
|
55
54
|
configureServer: async (server) => {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
watch({ configuration: intlayerConfig2 });
|
|
55
|
+
if (intlayerConfig.content.watch) {
|
|
56
|
+
watch({ configuration: intlayerConfig });
|
|
59
57
|
}
|
|
60
58
|
},
|
|
61
59
|
buildStart: async () => {
|
|
62
|
-
|
|
63
|
-
await prepareIntlayer(intlayerConfig2);
|
|
60
|
+
await prepareIntlayer(intlayerConfig);
|
|
64
61
|
}
|
|
65
62
|
}
|
|
66
63
|
];
|
|
67
64
|
if (optimize) {
|
|
68
|
-
plugins.push(IntlayerPrunePlugin());
|
|
65
|
+
plugins.push(IntlayerPrunePlugin(intlayerConfig));
|
|
69
66
|
}
|
|
70
67
|
return plugins;
|
|
71
68
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/intlayerPlugin.ts"],"sourcesContent":["import { cleanOutputDir, prepareIntlayer, watch } from '@intlayer/chokidar';\nimport
|
|
1
|
+
{"version":3,"sources":["../../src/intlayerPlugin.ts"],"sourcesContent":["import { cleanOutputDir, prepareIntlayer, watch } from '@intlayer/chokidar';\nimport intlayerConfig from '@intlayer/config/built';\nimport { join, relative, resolve } from 'path';\n// @ts-ignore - Fix error Module '\"vite\"' has no exported member\nimport { type PluginOption } from 'vite';\nimport { IntlayerPrunePlugin } from './intlayerPrunePlugin';\n\ncleanOutputDir();\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 = (pluginOptions = {}): PluginOption => {\n const {\n mainDir,\n configDir,\n baseDir,\n watch: isWatchMode,\n } = intlayerConfig.content;\n const { optimize } = intlayerConfig.build;\n\n const plugins: PluginOption[] = [\n {\n name: 'vite-intlayer-plugin',\n\n config: (config) => {\n const dictionariesPath = join(mainDir, 'dictionaries.mjs');\n const relativeDictionariesPath = relative(baseDir, dictionariesPath);\n\n const unmergedDictionariesPath = join(\n mainDir,\n 'unmerged_dictionaries.mjs'\n );\n const relativeUnmergedDictionariesPath = relative(\n baseDir,\n unmergedDictionariesPath\n );\n\n const configurationPath = join(configDir, 'configuration.json');\n const relativeConfigurationPath = relative(baseDir, configurationPath);\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 '@intlayer/unmerged-dictionaries-entry': resolve(\n relativeUnmergedDictionariesPath\n ),\n '@intlayer/config/built': resolve(relativeConfigurationPath),\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 '@intlayer/unmerged-dictionaries-entry',\n '@intlayer/config/built',\n ],\n };\n }\n\n return config;\n },\n\n configureServer: async (server) => {\n if (intlayerConfig.content.watch) {\n // Start watching (assuming watch is also async)\n watch({ configuration: intlayerConfig });\n }\n },\n\n buildStart: async () => {\n // Code to run when Vite build starts\n await prepareIntlayer(intlayerConfig);\n },\n },\n ];\n\n // Add Babel transform plugin if enabled\n if (optimize) {\n plugins.push(IntlayerPrunePlugin(intlayerConfig));\n }\n\n return plugins;\n};\n"],"mappings":"AAAA,SAAS,gBAAgB,iBAAiB,aAAa;AACvD,OAAO,oBAAoB;AAC3B,SAAS,MAAM,UAAU,eAAe;AAGxC,SAAS,2BAA2B;AAEpC,eAAe;AAaR,MAAM,iBAAiB,CAAC,gBAAgB,CAAC,MAAoB;AAClE,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO;AAAA,EACT,IAAI,eAAe;AACnB,QAAM,EAAE,SAAS,IAAI,eAAe;AAEpC,QAAM,UAA0B;AAAA,IAC9B;AAAA,MACE,MAAM;AAAA,MAEN,QAAQ,CAAC,WAAW;AAClB,cAAM,mBAAmB,KAAK,SAAS,kBAAkB;AACzD,cAAM,2BAA2B,SAAS,SAAS,gBAAgB;AAEnE,cAAM,2BAA2B;AAAA,UAC/B;AAAA,UACA;AAAA,QACF;AACA,cAAM,mCAAmC;AAAA,UACvC;AAAA,UACA;AAAA,QACF;AAEA,cAAM,oBAAoB,KAAK,WAAW,oBAAoB;AAC9D,cAAM,4BAA4B,SAAS,SAAS,iBAAiB;AAGrE,eAAO,UAAU;AAAA,UACf,GAAG,OAAO;AAAA,UACV,OAAO;AAAA,YACL,GAAG,OAAO,SAAS;AAAA,YACnB,gCAAgC,QAAQ,wBAAwB;AAAA,YAChE,yCAAyC;AAAA,cACvC;AAAA,YACF;AAAA,YACA,0BAA0B,QAAQ,yBAAyB;AAAA,UAC7D;AAAA,QACF;AAEA,YAAI,aAAa;AAEf,iBAAO,eAAe;AAAA,YACpB,GAAG,OAAO;AAAA,YACV,SAAS;AAAA,cACP,GAAI,OAAO,cAAc,WAAW,CAAC;AAAA,cACrC;AAAA,cACA;AAAA,cACA;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAEA,eAAO;AAAA,MACT;AAAA,MAEA,iBAAiB,OAAO,WAAW;AACjC,YAAI,eAAe,QAAQ,OAAO;AAEhC,gBAAM,EAAE,eAAe,eAAe,CAAC;AAAA,QACzC;AAAA,MACF;AAAA,MAEA,YAAY,YAAY;AAEtB,cAAM,gBAAgB,cAAc;AAAA,MACtC;AAAA,IACF;AAAA,EACF;AAGA,MAAI,UAAU;AACZ,YAAQ,KAAK,oBAAoB,cAAc,CAAC;AAAA,EAClD;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { intlayerBabelPlugin } from "@intlayer/babel";
|
|
2
2
|
import { ESMxCJSRequire } from "@intlayer/config";
|
|
3
|
-
import configuration from "@intlayer/config/built";
|
|
4
3
|
import fg from "fast-glob";
|
|
5
4
|
import { join } from "path";
|
|
6
|
-
const IntlayerPrunePlugin = () => {
|
|
7
|
-
const { optimize,
|
|
8
|
-
|
|
5
|
+
const IntlayerPrunePlugin = (intlayerConfig) => {
|
|
6
|
+
const { optimize, importMode, traversePattern } = intlayerConfig.build;
|
|
7
|
+
console.log("intlayerConfig", intlayerConfig);
|
|
8
|
+
const { dictionariesDir, dynamicDictionariesDir, mainDir, baseDir } = intlayerConfig.content;
|
|
9
9
|
const filesListPattern = fg.sync(traversePattern, {
|
|
10
10
|
cwd: baseDir
|
|
11
11
|
}).map((file) => join(baseDir, file));
|
|
@@ -39,7 +39,7 @@ const IntlayerPrunePlugin = () => {
|
|
|
39
39
|
dictionariesEntryPath,
|
|
40
40
|
dynamicDictionariesDir,
|
|
41
41
|
dynamicDictionariesEntryPath,
|
|
42
|
-
|
|
42
|
+
importMode,
|
|
43
43
|
filesList,
|
|
44
44
|
replaceDictionaryEntry: false
|
|
45
45
|
}
|
|
@@ -65,6 +65,7 @@ const IntlayerPrunePlugin = () => {
|
|
|
65
65
|
}
|
|
66
66
|
});
|
|
67
67
|
if (result?.code) {
|
|
68
|
+
console.log("result.code", result.code);
|
|
68
69
|
return {
|
|
69
70
|
code: result.code,
|
|
70
71
|
map: result.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/intlayerPrunePlugin.ts"],"sourcesContent":["// @ts-ignore - Fix error Module '\"vite\"' has no exported member\nimport { intlayerBabelPlugin } from '@intlayer/babel';\nimport { ESMxCJSRequire } from '@intlayer/config';\nimport
|
|
1
|
+
{"version":3,"sources":["../../src/intlayerPrunePlugin.ts"],"sourcesContent":["// @ts-ignore - Fix error Module '\"vite\"' has no exported member\nimport { intlayerBabelPlugin } from '@intlayer/babel';\nimport { ESMxCJSRequire, IntlayerConfig } from '@intlayer/config';\nimport fg from 'fast-glob';\nimport { join } from 'path';\nimport { type PluginOption } from 'vite';\n\nexport const IntlayerPrunePlugin = (\n intlayerConfig: IntlayerConfig\n): PluginOption => {\n const { optimize, importMode, traversePattern } = intlayerConfig.build;\n\n console.log('intlayerConfig', intlayerConfig);\n\n const { dictionariesDir, dynamicDictionariesDir, mainDir, baseDir } =\n intlayerConfig.content;\n\n const filesListPattern = fg\n .sync(traversePattern, {\n cwd: baseDir,\n })\n .map((file) => join(baseDir, file));\n\n return {\n name: 'vite-intlayer-babel-transform',\n enforce: 'post', // Run after other transformations as vue\n transform(code, id) {\n const dictionariesEntryPath = join(mainDir, 'dictionaries.mjs');\n const dynamicDictionariesEntryPath = join(\n mainDir,\n 'dynamic_dictionaries.mjs'\n );\n\n const filesList = [\n ...filesListPattern,\n dictionariesEntryPath, // should add dictionariesEntryPath to replace it by a empty object if import made dynamic\n ];\n\n /**\n * Transform file as\n * .../HelloWorld.vue?vue&type=script&setup=true&lang.ts\n * Into\n * .../HelloWorld.vue\n *\n * Prevention for virtual file\n */\n const filename = id.split('?', 1)[0];\n if (!filesList.includes(filename)) return null;\n if (!optimize) return null;\n\n try {\n const babel = ESMxCJSRequire('@babel/core');\n\n const result = babel.transformSync(code, {\n filename,\n plugins: [\n [\n intlayerBabelPlugin,\n {\n dictionariesDir,\n dictionariesEntryPath,\n dynamicDictionariesDir,\n dynamicDictionariesEntryPath,\n importMode,\n filesList,\n replaceDictionaryEntry: false,\n },\n ],\n ],\n parserOpts: {\n sourceType: 'module',\n allowImportExportEverywhere: true,\n plugins: [\n 'typescript',\n 'jsx',\n 'decorators-legacy',\n 'classProperties',\n 'objectRestSpread',\n 'asyncGenerators',\n 'functionBind',\n 'exportDefaultFrom',\n 'exportNamespaceFrom',\n 'dynamicImport',\n 'nullishCoalescingOperator',\n 'optionalChaining',\n ],\n },\n });\n\n if (result?.code) {\n console.log('result.code', result.code);\n return {\n code: result.code,\n map: result.map,\n };\n }\n } catch (error) {\n console.warn('Failed to transform with Babel plugin:', error);\n }\n\n return null;\n },\n };\n};\n"],"mappings":"AACA,SAAS,2BAA2B;AACpC,SAAS,sBAAsC;AAC/C,OAAO,QAAQ;AACf,SAAS,YAAY;AAGd,MAAM,sBAAsB,CACjC,mBACiB;AACjB,QAAM,EAAE,UAAU,YAAY,gBAAgB,IAAI,eAAe;AAEjE,UAAQ,IAAI,kBAAkB,cAAc;AAE5C,QAAM,EAAE,iBAAiB,wBAAwB,SAAS,QAAQ,IAChE,eAAe;AAEjB,QAAM,mBAAmB,GACtB,KAAK,iBAAiB;AAAA,IACrB,KAAK;AAAA,EACP,CAAC,EACA,IAAI,CAAC,SAAS,KAAK,SAAS,IAAI,CAAC;AAEpC,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA;AAAA,IACT,UAAU,MAAM,IAAI;AAClB,YAAM,wBAAwB,KAAK,SAAS,kBAAkB;AAC9D,YAAM,+BAA+B;AAAA,QACnC;AAAA,QACA;AAAA,MACF;AAEA,YAAM,YAAY;AAAA,QAChB,GAAG;AAAA,QACH;AAAA;AAAA,MACF;AAUA,YAAM,WAAW,GAAG,MAAM,KAAK,CAAC,EAAE,CAAC;AACnC,UAAI,CAAC,UAAU,SAAS,QAAQ,EAAG,QAAO;AAC1C,UAAI,CAAC,SAAU,QAAO;AAEtB,UAAI;AACF,cAAM,QAAQ,eAAe,aAAa;AAE1C,cAAM,SAAS,MAAM,cAAc,MAAM;AAAA,UACvC;AAAA,UACA,SAAS;AAAA,YACP;AAAA,cACE;AAAA,cACA;AAAA,gBACE;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA,wBAAwB;AAAA,cAC1B;AAAA,YACF;AAAA,UACF;AAAA,UACA,YAAY;AAAA,YACV,YAAY;AAAA,YACZ,6BAA6B;AAAA,YAC7B,SAAS;AAAA,cACP;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,YACF;AAAA,UACF;AAAA,QACF,CAAC;AAED,YAAI,QAAQ,MAAM;AAChB,kBAAQ,IAAI,eAAe,OAAO,IAAI;AACtC,iBAAO;AAAA,YACL,MAAM,OAAO;AAAA,YACb,KAAK,OAAO;AAAA,UACd;AAAA,QACF;AAAA,MACF,SAAS,OAAO;AACd,gBAAQ,KAAK,0CAA0C,KAAK;AAAA,MAC9D;AAEA,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intlayerPlugin.d.ts","sourceRoot":"","sources":["../../src/intlayerPlugin.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,MAAM,CAAC;AAKzC;;;;;;;;;;MAUM;AACN,eAAO,MAAM,cAAc,GAAI,kBAAkB,KAAG,
|
|
1
|
+
{"version":3,"file":"intlayerPlugin.d.ts","sourceRoot":"","sources":["../../src/intlayerPlugin.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,MAAM,CAAC;AAKzC;;;;;;;;;;MAUM;AACN,eAAO,MAAM,cAAc,GAAI,kBAAkB,KAAG,YA8EnD,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IntlayerConfig } from '@intlayer/config';
|
|
1
2
|
import { type PluginOption } from 'vite';
|
|
2
|
-
export declare const IntlayerPrunePlugin: () => PluginOption;
|
|
3
|
+
export declare const IntlayerPrunePlugin: (intlayerConfig: IntlayerConfig) => PluginOption;
|
|
3
4
|
//# sourceMappingURL=intlayerPrunePlugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intlayerPrunePlugin.d.ts","sourceRoot":"","sources":["../../src/intlayerPrunePlugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"intlayerPrunePlugin.d.ts","sourceRoot":"","sources":["../../src/intlayerPrunePlugin.ts"],"names":[],"mappings":"AAEA,OAAO,EAAkB,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,MAAM,CAAC;AAEzC,eAAO,MAAM,mBAAmB,GAC9B,gBAAgB,cAAc,KAC7B,YA8FF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-intlayer",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.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": [
|
|
@@ -58,10 +58,10 @@
|
|
|
58
58
|
"./package.json"
|
|
59
59
|
],
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@intlayer/
|
|
62
|
-
"@intlayer/
|
|
63
|
-
"@intlayer/
|
|
64
|
-
"@intlayer/babel": "5.
|
|
61
|
+
"@intlayer/core": "5.7.1",
|
|
62
|
+
"@intlayer/config": "5.7.1",
|
|
63
|
+
"@intlayer/chokidar": "5.7.1",
|
|
64
|
+
"@intlayer/babel": "5.7.1"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@types/node": "^22.15.30",
|
|
@@ -74,16 +74,16 @@
|
|
|
74
74
|
"tsup": "^8.5.0",
|
|
75
75
|
"typescript": "^5.8.3",
|
|
76
76
|
"vitest": "^3.2.2",
|
|
77
|
-
"@utils/eslint-config": "1.0.4",
|
|
78
77
|
"@utils/ts-config": "1.0.4",
|
|
79
|
-
"@utils/
|
|
80
|
-
"@utils/ts-config-types": "1.0.4"
|
|
78
|
+
"@utils/eslint-config": "1.0.4",
|
|
79
|
+
"@utils/ts-config-types": "1.0.4",
|
|
80
|
+
"@utils/tsup-config": "1.0.4"
|
|
81
81
|
},
|
|
82
82
|
"peerDependencies": {
|
|
83
83
|
"vite": ">=4.0.0",
|
|
84
|
-
"@intlayer/chokidar": "5.
|
|
85
|
-
"@intlayer/config": "5.
|
|
86
|
-
"@intlayer/core": "5.
|
|
84
|
+
"@intlayer/chokidar": "5.7.1",
|
|
85
|
+
"@intlayer/config": "5.7.1",
|
|
86
|
+
"@intlayer/core": "5.7.1"
|
|
87
87
|
},
|
|
88
88
|
"engines": {
|
|
89
89
|
"node": ">=14.18"
|