vite-intlayer 5.7.2 → 5.7.4
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 +1 -1
- package/dist/cjs/intlayerPlugin.cjs.map +1 -1
- package/dist/cjs/intlayerPrunePlugin.cjs +0 -2
- package/dist/cjs/intlayerPrunePlugin.cjs.map +1 -1
- package/dist/esm/intlayerPlugin.mjs +1 -1
- package/dist/esm/intlayerPlugin.mjs.map +1 -1
- package/dist/esm/intlayerPrunePlugin.mjs +0 -2
- package/dist/esm/intlayerPrunePlugin.mjs.map +1 -1
- package/dist/types/intlayerPlugin.d.ts +1 -1
- package/dist/types/intlayerPlugin.d.ts.map +1 -1
- package/dist/types/intlayerPrunePlugin.d.ts.map +1 -1
- package/package.json +13 -13
|
@@ -36,7 +36,7 @@ var import_built = __toESM(require("@intlayer/config/built"));
|
|
|
36
36
|
var import_path = require("path");
|
|
37
37
|
var import_intlayerPrunePlugin = require('./intlayerPrunePlugin.cjs');
|
|
38
38
|
(0, import_chokidar.cleanOutputDir)();
|
|
39
|
-
const intlayerPlugin = (
|
|
39
|
+
const intlayerPlugin = () => {
|
|
40
40
|
const {
|
|
41
41
|
mainDir,
|
|
42
42
|
configDir,
|
|
@@ -1 +1 @@
|
|
|
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 = (
|
|
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 = (): 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,MAAoB;AAChD,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"]}
|
|
@@ -37,7 +37,6 @@ var import_fast_glob = __toESM(require("fast-glob"));
|
|
|
37
37
|
var import_path = require("path");
|
|
38
38
|
const IntlayerPrunePlugin = (intlayerConfig) => {
|
|
39
39
|
const { optimize, importMode, traversePattern } = intlayerConfig.build;
|
|
40
|
-
console.log("intlayerConfig", intlayerConfig);
|
|
41
40
|
const { dictionariesDir, dynamicDictionariesDir, mainDir, baseDir } = intlayerConfig.content;
|
|
42
41
|
const filesListPattern = import_fast_glob.default.sync(traversePattern, {
|
|
43
42
|
cwd: baseDir
|
|
@@ -98,7 +97,6 @@ const IntlayerPrunePlugin = (intlayerConfig) => {
|
|
|
98
97
|
}
|
|
99
98
|
});
|
|
100
99
|
if (result?.code) {
|
|
101
|
-
console.log("result.code", result.code);
|
|
102
100
|
return {
|
|
103
101
|
code: result.code,
|
|
104
102
|
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, 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
|
|
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 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 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,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,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"]}
|
|
@@ -3,7 +3,7 @@ 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
|
-
const intlayerPlugin = (
|
|
6
|
+
const intlayerPlugin = () => {
|
|
7
7
|
const {
|
|
8
8
|
mainDir,
|
|
9
9
|
configDir,
|
|
@@ -1 +1 @@
|
|
|
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 = (
|
|
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 = (): 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,MAAoB;AAChD,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":[]}
|
|
@@ -4,7 +4,6 @@ import fg from "fast-glob";
|
|
|
4
4
|
import { join } from "path";
|
|
5
5
|
const IntlayerPrunePlugin = (intlayerConfig) => {
|
|
6
6
|
const { optimize, importMode, traversePattern } = intlayerConfig.build;
|
|
7
|
-
console.log("intlayerConfig", intlayerConfig);
|
|
8
7
|
const { dictionariesDir, dynamicDictionariesDir, mainDir, baseDir } = intlayerConfig.content;
|
|
9
8
|
const filesListPattern = fg.sync(traversePattern, {
|
|
10
9
|
cwd: baseDir
|
|
@@ -65,7 +64,6 @@ const IntlayerPrunePlugin = (intlayerConfig) => {
|
|
|
65
64
|
}
|
|
66
65
|
});
|
|
67
66
|
if (result?.code) {
|
|
68
|
-
console.log("result.code", result.code);
|
|
69
67
|
return {
|
|
70
68
|
code: result.code,
|
|
71
69
|
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, 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
|
|
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 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 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,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,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,
|
|
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,QAAO,YA8EjC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,YA2FF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-intlayer",
|
|
3
|
-
"version": "5.7.
|
|
3
|
+
"version": "5.7.4",
|
|
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.7.
|
|
61
|
+
"@intlayer/chokidar": "5.7.4",
|
|
62
|
+
"@intlayer/config": "5.7.4",
|
|
63
|
+
"@intlayer/core": "5.7.4",
|
|
64
|
+
"@intlayer/babel": "5.7.4"
|
|
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/ts-config": "1.0.4",
|
|
78
77
|
"@utils/eslint-config": "1.0.4",
|
|
79
|
-
"@utils/
|
|
80
|
-
"@utils/ts-config-types": "1.0.4"
|
|
78
|
+
"@utils/ts-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.7.
|
|
85
|
-
"@intlayer/
|
|
86
|
-
"@intlayer/
|
|
84
|
+
"@intlayer/chokidar": "5.7.4",
|
|
85
|
+
"@intlayer/config": "5.7.4",
|
|
86
|
+
"@intlayer/core": "5.7.4"
|
|
87
87
|
},
|
|
88
88
|
"engines": {
|
|
89
89
|
"node": ">=14.18"
|
|
@@ -92,7 +92,8 @@
|
|
|
92
92
|
"url": "https://github.com/aymericzip/intlayer/issues"
|
|
93
93
|
},
|
|
94
94
|
"scripts": {
|
|
95
|
-
"build": "pnpm
|
|
95
|
+
"build": "pnpm clean & pnpm build:ci",
|
|
96
|
+
"build:ci": "pnpm build:package & pnpm build:types",
|
|
96
97
|
"build:package": "tsup",
|
|
97
98
|
"build:types": "tsc --project ./tsconfig.types.json && tsc-alias --project ./tsconfig.types.json",
|
|
98
99
|
"clean": "rimraf ./dist",
|
|
@@ -101,7 +102,6 @@
|
|
|
101
102
|
"lint:fix": "eslint . --cache --fix",
|
|
102
103
|
"prettier": "prettier . --check",
|
|
103
104
|
"prettier:fix": "prettier . --write",
|
|
104
|
-
"reset": "pnpm clean & pnpm build",
|
|
105
105
|
"test": "vitest run",
|
|
106
106
|
"test:watch": "vitest",
|
|
107
107
|
"typecheck": "tsup --project ./tsconfig.json --noEmit"
|