vite-intlayer 6.1.6 → 7.0.0-canary.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.
@@ -1,68 +1,83 @@
1
- import { prepareIntlayer, runOnce, watch } from "@intlayer/chokidar";
2
- import intlayerConfig from "@intlayer/config/built";
3
- import { join, resolve } from "path";
4
- import { getAlias, getAppLogger } from "@intlayer/config";
5
1
  import { intlayerPrune } from "./intlayerPrunePlugin.mjs";
6
- const intlayerPlugin = () => {
7
- const { watch: isWatchMode } = intlayerConfig.content;
8
- const { optimize } = intlayerConfig.build;
9
- const appLogger = getAppLogger(intlayerConfig);
10
- const plugins = [
11
- {
12
- name: "vite-intlayer-plugin",
13
- config: (config) => {
14
- config.resolve = {
15
- ...config.resolve,
16
- alias: {
17
- ...config.resolve?.alias,
18
- ...getAlias({
19
- configuration: intlayerConfig,
20
- formatter: (value) => resolve(value)
21
- })
22
- }
23
- };
24
- if (isWatchMode) {
25
- config.optimizeDeps = {
26
- ...config.optimizeDeps,
27
- exclude: [
28
- ...config.optimizeDeps?.exclude ?? [],
29
- "@intlayer/dictionaries-entry",
30
- "@intlayer/config/built"
31
- ]
32
- };
33
- }
34
- return config;
35
- },
36
- configureServer: async (server) => {
37
- if (intlayerConfig.content.watch) {
38
- watch({ configuration: intlayerConfig });
39
- }
40
- },
41
- buildStart: async () => {
42
- const sentinelPath = join(
43
- intlayerConfig.content.baseDir,
44
- ".intlayer",
45
- "cache",
46
- "intlayer-prepared.lock"
47
- );
48
- await runOnce(
49
- sentinelPath,
50
- async () => await prepareIntlayer(intlayerConfig),
51
- () => appLogger("Intlayer prepared")
52
- );
53
- }
54
- }
55
- ];
56
- if (optimize) {
57
- plugins.push(intlayerPrune(intlayerConfig));
58
- }
59
- return plugins;
2
+ import { getAlias, getConfiguration } from "@intlayer/config";
3
+ import { resolve } from "node:path";
4
+ import { prepareIntlayer, watch } from "@intlayer/chokidar";
5
+
6
+ //#region src/intlayerPlugin.ts
7
+ /**
8
+ * @deprecated Rename to intlayer instead
9
+ *
10
+ * A Vite plugin that integrates Intlayer configuration into the build process
11
+ *
12
+ * ```ts
13
+ * // Example usage of the plugin in a Vite configuration
14
+ * export default defineConfig({
15
+ * plugins: [ intlayer() ],
16
+ * });
17
+ * ```
18
+ * */
19
+ const intlayerPlugin = (configOptions) => {
20
+ const intlayerConfig = getConfiguration(configOptions);
21
+ const { watch: isWatchMode } = intlayerConfig.content;
22
+ const { optimize } = intlayerConfig.build;
23
+ const plugins = [{
24
+ name: "vite-intlayer-plugin",
25
+ config: (config) => {
26
+ config.resolve = {
27
+ ...config.resolve,
28
+ alias: {
29
+ ...config.resolve?.alias,
30
+ ...getAlias({
31
+ configuration: intlayerConfig,
32
+ formatter: (value) => resolve(value)
33
+ })
34
+ }
35
+ };
36
+ if (isWatchMode) config.optimizeDeps = {
37
+ ...config.optimizeDeps,
38
+ exclude: [
39
+ ...config.optimizeDeps?.exclude ?? [],
40
+ "@intlayer/dictionaries-entry",
41
+ "@intlayer/config/built"
42
+ ]
43
+ };
44
+ return config;
45
+ },
46
+ configureServer: async (_server) => {
47
+ if (intlayerConfig.content.watch) watch({ configuration: intlayerConfig });
48
+ },
49
+ buildStart: async () => {
50
+ await prepareIntlayer(intlayerConfig);
51
+ }
52
+ }];
53
+ if (optimize) plugins.push(intlayerPrune(intlayerConfig));
54
+ return plugins;
60
55
  };
56
+ /**
57
+ * A Vite plugin that integrates Intlayer configuration into the build process
58
+ *
59
+ * ```ts
60
+ * // Example usage of the plugin in a Vite configuration
61
+ * export default defineConfig({
62
+ * plugins: [ intlayer() ],
63
+ * });
64
+ * ```
65
+ */
61
66
  const intlayer = intlayerPlugin;
67
+ /**
68
+ * @deprecated Rename to intlayer instead
69
+ *
70
+ * A Vite plugin that integrates Intlayer configuration into the build process
71
+ *
72
+ * ```ts
73
+ * // Example usage of the plugin in a Vite configuration
74
+ * export default defineConfig({
75
+ * plugins: [ intlayer() ],
76
+ * });
77
+ * ```
78
+ */
62
79
  const intLayerPlugin = intlayerPlugin;
63
- export {
64
- intLayerPlugin,
65
- intlayer,
66
- intlayerPlugin
67
- };
80
+
81
+ //#endregion
82
+ export { intLayerPlugin, intlayer, intlayerPlugin };
68
83
  //# sourceMappingURL=intlayerPlugin.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/intlayerPlugin.ts"],"sourcesContent":["import { prepareIntlayer, runOnce, watch } from '@intlayer/chokidar';\nimport intlayerConfig from '@intlayer/config/built';\nimport { join, resolve } from 'path';\n// @ts-ignore - Fix error Module '\"vite\"' has no exported member\nimport { getAlias, getAppLogger } from '@intlayer/config';\nimport { type PluginOption } from 'vite';\nimport { intlayerPrune } from './intlayerPrunePlugin';\n\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 = (): PluginOption => {\n const { watch: isWatchMode } = intlayerConfig.content;\n const { optimize } = intlayerConfig.build;\n const appLogger = getAppLogger(intlayerConfig);\n\n const plugins: PluginOption[] = [\n {\n name: 'vite-intlayer-plugin',\n\n config: (config) => {\n // Update Vite's resolve alias\n config.resolve = {\n ...config.resolve,\n alias: {\n ...config.resolve?.alias,\n ...getAlias({\n configuration: intlayerConfig,\n formatter: (value: string) => resolve(value),\n }),\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/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 const sentinelPath = join(\n intlayerConfig.content.baseDir,\n '.intlayer',\n 'cache',\n 'intlayer-prepared.lock'\n );\n\n // Code to run when Vite build starts\n // Only call prepareIntlayer once per server startup\n await runOnce(\n sentinelPath,\n async () => await prepareIntlayer(intlayerConfig),\n () => appLogger('Intlayer prepared')\n );\n },\n },\n ];\n\n // Add Babel transform plugin if enabled\n if (optimize) {\n plugins.push(intlayerPrune(intlayerConfig));\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":"AAAA,SAAS,iBAAiB,SAAS,aAAa;AAChD,OAAO,oBAAoB;AAC3B,SAAS,MAAM,eAAe;AAE9B,SAAS,UAAU,oBAAoB;AAEvC,SAAS,qBAAqB;AAcvB,MAAM,iBAAiB,MAAoB;AAChD,QAAM,EAAE,OAAO,YAAY,IAAI,eAAe;AAC9C,QAAM,EAAE,SAAS,IAAI,eAAe;AACpC,QAAM,YAAY,aAAa,cAAc;AAE7C,QAAM,UAA0B;AAAA,IAC9B;AAAA,MACE,MAAM;AAAA,MAEN,QAAQ,CAAC,WAAW;AAElB,eAAO,UAAU;AAAA,UACf,GAAG,OAAO;AAAA,UACV,OAAO;AAAA,YACL,GAAG,OAAO,SAAS;AAAA,YACnB,GAAG,SAAS;AAAA,cACV,eAAe;AAAA,cACf,WAAW,CAAC,UAAkB,QAAQ,KAAK;AAAA,YAC7C,CAAC;AAAA,UACH;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,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;AACtB,cAAM,eAAe;AAAA,UACnB,eAAe,QAAQ;AAAA,UACvB;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAIA,cAAM;AAAA,UACJ;AAAA,UACA,YAAY,MAAM,gBAAgB,cAAc;AAAA,UAChD,MAAM,UAAU,mBAAmB;AAAA,QACrC;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAGA,MAAI,UAAU;AACZ,YAAQ,KAAK,cAAc,cAAc,CAAC;AAAA,EAC5C;AAEA,SAAO;AACT;AAYO,MAAM,WAAW;AAajB,MAAM,iBAAiB;","names":[]}
1
+ {"version":3,"file":"intlayerPlugin.mjs","names":["plugins: PluginOption[]"],"sources":["../../src/intlayerPlugin.ts"],"sourcesContent":["import { resolve } from 'node:path';\nimport { prepareIntlayer, watch } from '@intlayer/chokidar';\nimport {\n type GetConfigurationOptions,\n getAlias,\n getConfiguration,\n} from '@intlayer/config';\n// @ts-ignore - Fix error Module '\"vite\"' has no exported member\nimport type { PluginOption } from 'vite';\nimport { intlayerPrune } from './intlayerPrunePlugin';\n\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 = (\n configOptions?: GetConfigurationOptions\n): PluginOption => {\n const intlayerConfig = getConfiguration(configOptions);\n const { watch: isWatchMode } = intlayerConfig.content;\n const { optimize } = intlayerConfig.build;\n\n const plugins: PluginOption[] = [\n {\n name: 'vite-intlayer-plugin',\n\n config: (config) => {\n // Update Vite's resolve alias\n config.resolve = {\n ...config.resolve,\n alias: {\n ...config.resolve?.alias,\n ...getAlias({\n configuration: intlayerConfig,\n formatter: (value: string) => resolve(value),\n }),\n },\n };\n\n if (isWatchMode) {\n config.optimizeDeps = {\n ...config.optimizeDeps,\n exclude: [\n ...(config.optimizeDeps?.exclude ?? []),\n '@intlayer/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(intlayerPrune(intlayerConfig));\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":";;;;;;;;;;;;;;;;;;AAuBA,MAAa,kBACX,kBACiB;CACjB,MAAM,iBAAiB,iBAAiB,cAAc;CACtD,MAAM,EAAE,OAAO,gBAAgB,eAAe;CAC9C,MAAM,EAAE,aAAa,eAAe;CAEpC,MAAMA,UAA0B,CAC9B;EACE,MAAM;EAEN,SAAS,WAAW;AAElB,UAAO,UAAU;IACf,GAAG,OAAO;IACV,OAAO;KACL,GAAG,OAAO,SAAS;KACnB,GAAG,SAAS;MACV,eAAe;MACf,YAAY,UAAkB,QAAQ,MAAM;MAC7C,CAAC;KACH;IACF;AAED,OAAI,YACF,QAAO,eAAe;IACpB,GAAG,OAAO;IACV,SAAS;KACP,GAAI,OAAO,cAAc,WAAW,EAAE;KACtC;KACA;KACD;IACF;AAGH,UAAO;;EAGT,iBAAiB,OAAO,YAAY;AAClC,OAAI,eAAe,QAAQ,MAEzB,OAAM,EAAE,eAAe,gBAAgB,CAAC;;EAI5C,YAAY,YAAY;AAEtB,SAAM,gBAAgB,eAAe;;EAExC,CACF;AAGD,KAAI,SACF,SAAQ,KAAK,cAAc,eAAe,CAAC;AAG7C,QAAO;;;;;;;;;;;;AAaT,MAAa,WAAW;;;;;;;;;;;;;AAaxB,MAAa,iBAAiB"}
@@ -1,92 +1,80 @@
1
+ import { __require } from "./_virtual/rolldown_runtime.mjs";
2
+ import { join } from "node:path";
1
3
  import { intlayerBabelPlugin } from "@intlayer/babel";
2
- import { ESMxCJSRequire } from "@intlayer/config";
3
- import dictionaries from "@intlayer/dictionaries-entry";
4
+ import { getDictionaries } from "@intlayer/dictionaries-entry";
4
5
  import fg from "fast-glob";
5
- import { join } from "path";
6
+
7
+ //#region src/intlayerPrunePlugin.ts
6
8
  const intlayerPrune = (intlayerConfig) => {
7
- const { optimize, importMode, traversePattern } = intlayerConfig.build;
8
- const {
9
- dictionariesDir,
10
- dynamicDictionariesDir,
11
- fetchDictionariesDir,
12
- mainDir,
13
- baseDir
14
- } = intlayerConfig.content;
15
- const filesListPattern = fg.sync(traversePattern, {
16
- cwd: baseDir
17
- }).map((file) => join(baseDir, file));
18
- const dictionariesEntryPath = join(mainDir, "dictionaries.mjs");
19
- const dynamicDictionariesEntryPath = join(
20
- mainDir,
21
- "dynamic_dictionaries.mjs"
22
- );
23
- const filesList = [
24
- ...filesListPattern,
25
- dictionariesEntryPath
26
- // should add dictionariesEntryPath to replace it by a empty object if import made dynamic
27
- ];
28
- const liveSyncKeys = Object.values(dictionaries).filter((dictionary) => dictionary.live).map((dictionary) => dictionary.key);
29
- return {
30
- name: "vite-intlayer-babel-transform",
31
- enforce: "post",
32
- // Run after other transformations as vue
33
- transform(code, id) {
34
- const filename = id.split("?", 1)[0];
35
- if (!filesList.includes(filename)) return null;
36
- if (!optimize) return null;
37
- try {
38
- const babel = ESMxCJSRequire("@babel/core");
39
- const result = babel.transformSync(code, {
40
- filename,
41
- plugins: [
42
- [
43
- intlayerBabelPlugin,
44
- {
45
- dictionariesDir,
46
- dictionariesEntryPath,
47
- dynamicDictionariesDir,
48
- dynamicDictionariesEntryPath,
49
- fetchDictionariesDir,
50
- importMode,
51
- filesList,
52
- replaceDictionaryEntry: false,
53
- liveSyncKeys
54
- }
55
- ]
56
- ],
57
- parserOpts: {
58
- sourceType: "module",
59
- allowImportExportEverywhere: true,
60
- plugins: [
61
- "typescript",
62
- "jsx",
63
- "decorators-legacy",
64
- "classProperties",
65
- "objectRestSpread",
66
- "asyncGenerators",
67
- "functionBind",
68
- "exportDefaultFrom",
69
- "exportNamespaceFrom",
70
- "dynamicImport",
71
- "nullishCoalescingOperator",
72
- "optionalChaining"
73
- ]
74
- }
75
- });
76
- if (result?.code) {
77
- return {
78
- code: result.code,
79
- map: result.map
80
- };
81
- }
82
- } catch (error) {
83
- console.warn("Failed to transform with Babel plugin:", error);
84
- }
85
- return null;
86
- }
87
- };
88
- };
89
- export {
90
- intlayerPrune
9
+ try {
10
+ const babel = __require("@babel/core");
11
+ const { optimize, importMode, traversePattern } = intlayerConfig.build;
12
+ const { dictionariesDir, dynamicDictionariesDir, fetchDictionariesDir, mainDir, baseDir } = intlayerConfig.content;
13
+ const filesListPattern = fg.sync(traversePattern, { cwd: baseDir }).map((file) => join(baseDir, file));
14
+ const dictionariesEntryPath = join(mainDir, "dictionaries.mjs");
15
+ const dynamicDictionariesEntryPath = join(mainDir, "dynamic_dictionaries.mjs");
16
+ const filesList = [...filesListPattern, dictionariesEntryPath];
17
+ const dictionaries = getDictionaries();
18
+ const liveSyncKeys = Object.values(dictionaries).filter((dictionary) => dictionary.live).map((dictionary) => dictionary.key);
19
+ return {
20
+ name: "vite-intlayer-babel-transform",
21
+ enforce: "post",
22
+ transform(code, id) {
23
+ /**
24
+ * Transform file as
25
+ * .../HelloWorld.vue?vue&type=script&setup=true&lang.ts
26
+ * Into
27
+ * .../HelloWorld.vue
28
+ *
29
+ * Prevention for virtual file
30
+ */
31
+ const filename = id.split("?", 1)[0];
32
+ if (!filesList.includes(filename)) return null;
33
+ if (!optimize) return null;
34
+ const result = babel.transformSync(code, {
35
+ filename,
36
+ plugins: [[intlayerBabelPlugin, {
37
+ dictionariesDir,
38
+ dictionariesEntryPath,
39
+ dynamicDictionariesDir,
40
+ dynamicDictionariesEntryPath,
41
+ fetchDictionariesDir,
42
+ importMode,
43
+ filesList,
44
+ replaceDictionaryEntry: false,
45
+ liveSyncKeys
46
+ }]],
47
+ parserOpts: {
48
+ sourceType: "module",
49
+ allowImportExportEverywhere: true,
50
+ plugins: [
51
+ "typescript",
52
+ "jsx",
53
+ "decorators-legacy",
54
+ "classProperties",
55
+ "objectRestSpread",
56
+ "asyncGenerators",
57
+ "functionBind",
58
+ "exportDefaultFrom",
59
+ "exportNamespaceFrom",
60
+ "dynamicImport",
61
+ "nullishCoalescingOperator",
62
+ "optionalChaining"
63
+ ]
64
+ }
65
+ });
66
+ if (result?.code) return {
67
+ code: result.code,
68
+ map: result.map
69
+ };
70
+ }
71
+ };
72
+ } catch (error) {
73
+ console.warn("Failed to transform with Babel plugin:", error);
74
+ return null;
75
+ }
91
76
  };
77
+
78
+ //#endregion
79
+ export { intlayerPrune };
92
80
  //# sourceMappingURL=intlayerPrunePlugin.mjs.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 dictionaries from '@intlayer/dictionaries-entry';\nimport fg from 'fast-glob';\nimport { join } from 'path';\nimport { type PluginOption } from 'vite';\n\nexport const intlayerPrune = (intlayerConfig: IntlayerConfig): PluginOption => {\n const { optimize, importMode, traversePattern } = intlayerConfig.build;\n\n const {\n dictionariesDir,\n dynamicDictionariesDir,\n fetchDictionariesDir,\n mainDir,\n baseDir,\n } = intlayerConfig.content;\n\n const filesListPattern = fg\n .sync(traversePattern, {\n cwd: baseDir,\n })\n .map((file) => join(baseDir, file));\n\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 const liveSyncKeys = Object.values(dictionaries)\n .filter((dictionary) => dictionary.live)\n .map((dictionary) => dictionary.key);\n\n return {\n name: 'vite-intlayer-babel-transform',\n enforce: 'post', // Run after other transformations as vue\n transform(code, id) {\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 fetchDictionariesDir,\n importMode,\n filesList,\n replaceDictionaryEntry: false,\n liveSyncKeys,\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,kBAAkB;AACzB,OAAO,QAAQ;AACf,SAAS,YAAY;AAGd,MAAM,gBAAgB,CAAC,mBAAiD;AAC7E,QAAM,EAAE,UAAU,YAAY,gBAAgB,IAAI,eAAe;AAEjE,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,eAAe;AAEnB,QAAM,mBAAmB,GACtB,KAAK,iBAAiB;AAAA,IACrB,KAAK;AAAA,EACP,CAAC,EACA,IAAI,CAAC,SAAS,KAAK,SAAS,IAAI,CAAC;AAEpC,QAAM,wBAAwB,KAAK,SAAS,kBAAkB;AAC9D,QAAM,+BAA+B;AAAA,IACnC;AAAA,IACA;AAAA,EACF;AAEA,QAAM,YAAY;AAAA,IAChB,GAAG;AAAA,IACH;AAAA;AAAA,EACF;AAEA,QAAM,eAAe,OAAO,OAAO,YAAY,EAC5C,OAAO,CAAC,eAAe,WAAW,IAAI,EACtC,IAAI,CAAC,eAAe,WAAW,GAAG;AAErC,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA;AAAA,IACT,UAAU,MAAM,IAAI;AASlB,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;AAAA,gBACA,wBAAwB;AAAA,gBACxB;AAAA,cACF;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
+ {"version":3,"file":"intlayerPrunePlugin.mjs","names":[],"sources":["../../src/intlayerPrunePlugin.ts"],"sourcesContent":["import { join } from 'node:path';\nimport { intlayerBabelPlugin } from '@intlayer/babel';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport fg from 'fast-glob';\nimport type { PluginOption } from 'vite';\n\nexport const intlayerPrune = (intlayerConfig: IntlayerConfig): PluginOption => {\n try {\n const babel = require('@babel/core');\n\n const { optimize, importMode, traversePattern } = intlayerConfig.build;\n\n const {\n dictionariesDir,\n dynamicDictionariesDir,\n fetchDictionariesDir,\n mainDir,\n baseDir,\n } = intlayerConfig.content;\n\n const filesListPattern = fg\n .sync(traversePattern, {\n cwd: baseDir,\n })\n .map((file) => join(baseDir, file));\n\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 const dictionaries = getDictionaries();\n const liveSyncKeys = Object.values(dictionaries)\n .filter((dictionary) => dictionary.live)\n .map((dictionary) => dictionary.key);\n\n return {\n name: 'vite-intlayer-babel-transform',\n enforce: 'post', // Run after other transformations as vue\n transform(code, id) {\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 const result = babel.transformSync(code, {\n filename,\n plugins: [\n [\n intlayerBabelPlugin,\n {\n dictionariesDir,\n dictionariesEntryPath,\n dynamicDictionariesDir,\n dynamicDictionariesEntryPath,\n fetchDictionariesDir,\n importMode,\n filesList,\n replaceDictionaryEntry: false,\n liveSyncKeys,\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 },\n };\n } catch (error) {\n console.warn('Failed to transform with Babel plugin:', error);\n\n return null;\n }\n};\n"],"mappings":";;;;;;;AAOA,MAAa,iBAAiB,mBAAiD;AAC7E,KAAI;EACF,MAAM,kBAAgB,cAAc;EAEpC,MAAM,EAAE,UAAU,YAAY,oBAAoB,eAAe;EAEjE,MAAM,EACJ,iBACA,wBACA,sBACA,SACA,YACE,eAAe;EAEnB,MAAM,mBAAmB,GACtB,KAAK,iBAAiB,EACrB,KAAK,SACN,CAAC,CACD,KAAK,SAAS,KAAK,SAAS,KAAK,CAAC;EAErC,MAAM,wBAAwB,KAAK,SAAS,mBAAmB;EAC/D,MAAM,+BAA+B,KACnC,SACA,2BACD;EAED,MAAM,YAAY,CAChB,GAAG,kBACH,sBACD;EAED,MAAM,eAAe,iBAAiB;EACtC,MAAM,eAAe,OAAO,OAAO,aAAa,CAC7C,QAAQ,eAAe,WAAW,KAAK,CACvC,KAAK,eAAe,WAAW,IAAI;AAEtC,SAAO;GACL,MAAM;GACN,SAAS;GACT,UAAU,MAAM,IAAI;;;;;;;;;IASlB,MAAM,WAAW,GAAG,MAAM,KAAK,EAAE,CAAC;AAClC,QAAI,CAAC,UAAU,SAAS,SAAS,CAAE,QAAO;AAC1C,QAAI,CAAC,SAAU,QAAO;IAEtB,MAAM,SAAS,MAAM,cAAc,MAAM;KACvC;KACA,SAAS,CACP,CACE,qBACA;MACE;MACA;MACA;MACA;MACA;MACA;MACA;MACA,wBAAwB;MACxB;MACD,CACF,CACF;KACD,YAAY;MACV,YAAY;MACZ,6BAA6B;MAC7B,SAAS;OACP;OACA;OACA;OACA;OACA;OACA;OACA;OACA;OACA;OACA;OACA;OACA;OACD;MACF;KACF,CAAC;AAEF,QAAI,QAAQ,KACV,QAAO;KACL,MAAM,OAAO;KACb,KAAK,OAAO;KACb;;GAGN;UACM,OAAO;AACd,UAAQ,KAAK,0CAA0C,MAAM;AAE7D,SAAO"}
@@ -1,4 +1,4 @@
1
- export * from './intlayerMiddlewarePlugin';
2
- export * from './intlayerPlugin';
3
- export * from './intlayerPrunePlugin';
4
- //# sourceMappingURL=index.d.ts.map
1
+ import { intLayerMiddleware, intlayerMiddleware, intlayerMiddlewarePlugin } from "./intlayerMiddlewarePlugin.js";
2
+ import { intLayerPlugin, intlayer, intlayerPlugin } from "./intlayerPlugin.js";
3
+ import { intlayerPrune } from "./intlayerPrunePlugin.js";
4
+ export { intLayerMiddleware, intLayerPlugin, intlayer, intlayerMiddleware, intlayerMiddlewarePlugin, intlayerPlugin, intlayerPrune };
@@ -1,4 +1,7 @@
1
- import type { Plugin } from 'vite';
1
+ import { Plugin } from "vite";
2
+
3
+ //#region src/intlayerMiddlewarePlugin.d.ts
4
+
2
5
  /**
3
6
  * @deprecated Rename to intlayerMiddleware instead
4
7
  *
@@ -9,7 +12,7 @@ import type { Plugin } from 'vite';
9
12
  * plugins: [ intlayerMiddleware() ],
10
13
  * });
11
14
  */
12
- export declare const intlayerMiddlewarePlugin: () => Plugin;
15
+ declare const intlayerMiddlewarePlugin: () => Plugin;
13
16
  /**
14
17
  * A Vite plugin that integrates a logic similar to the Next.js intlayer middleware.
15
18
  *
@@ -20,7 +23,7 @@ export declare const intlayerMiddlewarePlugin: () => Plugin;
20
23
  * });
21
24
  * ```
22
25
  */
23
- export declare const intlayerMiddleware: () => Plugin;
26
+ declare const intlayerMiddleware: () => Plugin;
24
27
  /**
25
28
  * @deprecated Rename to intlayerMiddleware instead
26
29
  *
@@ -33,5 +36,7 @@ export declare const intlayerMiddleware: () => Plugin;
33
36
  * });
34
37
  * ```
35
38
  */
36
- export declare const intLayerMiddleware: () => Plugin;
39
+ declare const intLayerMiddleware: () => Plugin;
40
+ //#endregion
41
+ export { intLayerMiddleware, intlayerMiddleware, intlayerMiddlewarePlugin };
37
42
  //# sourceMappingURL=intlayerMiddlewarePlugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"intlayerMiddlewarePlugin.d.ts","sourceRoot":"","sources":["../../src/intlayerMiddlewarePlugin.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAW,MAAM,EAAE,MAAM,MAAM,CAAC;AA0B5C;;;;;;;;;GASG;AACH,eAAO,MAAM,wBAAwB,QAAO,MAiD3C,CAAC;AA4TF;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,QAvXa,MAuXc,CAAC;AAE3D;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,kBAAkB,QArYa,MAqYc,CAAC"}
1
+ {"version":3,"file":"intlayerMiddlewarePlugin.d.ts","names":[],"sources":["../../src/intlayerMiddlewarePlugin.ts"],"sourcesContent":[],"mappings":";;;;;;AAqCA;AAqbA;AAcA;;;;;;cAnca,gCAA+B;;;;;;;;;;;cAqb/B,0BArb+B;;;;;;;;;;;;;cAmc/B,0BAnc+B"}
@@ -1,4 +1,8 @@
1
- import { type PluginOption } from 'vite';
1
+ import { PluginOption } from "vite";
2
+ import { GetConfigurationOptions } from "@intlayer/config";
3
+
4
+ //#region src/intlayerPlugin.d.ts
5
+
2
6
  /**
3
7
  * @deprecated Rename to intlayer instead
4
8
  *
@@ -11,7 +15,7 @@ import { type PluginOption } from 'vite';
11
15
  * });
12
16
  * ```
13
17
  * */
14
- export declare const intlayerPlugin: () => PluginOption;
18
+ declare const intlayerPlugin: (configOptions?: GetConfigurationOptions) => PluginOption;
15
19
  /**
16
20
  * A Vite plugin that integrates Intlayer configuration into the build process
17
21
  *
@@ -22,7 +26,7 @@ export declare const intlayerPlugin: () => PluginOption;
22
26
  * });
23
27
  * ```
24
28
  */
25
- export declare const intlayer: () => PluginOption;
29
+ declare const intlayer: (configOptions?: GetConfigurationOptions) => PluginOption;
26
30
  /**
27
31
  * @deprecated Rename to intlayer instead
28
32
  *
@@ -35,5 +39,7 @@ export declare const intlayer: () => PluginOption;
35
39
  * });
36
40
  * ```
37
41
  */
38
- export declare const intLayerPlugin: () => PluginOption;
42
+ declare const intLayerPlugin: (configOptions?: GetConfigurationOptions) => PluginOption;
43
+ //#endregion
44
+ export { intLayerPlugin, intlayer, intlayerPlugin };
39
45
  //# sourceMappingURL=intlayerPlugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"intlayerPlugin.d.ts","sourceRoot":"","sources":["../../src/intlayerPlugin.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,MAAM,CAAC;AAGzC;;;;;;;;;;;MAWM;AACN,eAAO,MAAM,cAAc,QAAO,YAqEjC,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,QAAQ,QAjFa,YAiFI,CAAC;AACvC;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,cAAc,QA9FO,YA8FU,CAAC"}
1
+ {"version":3,"file":"intlayerPlugin.d.ts","names":[],"sources":["../../src/intlayerPlugin.ts"],"sourcesContent":[],"mappings":";;;;;;;AAuBA;AAsEA;AAaA;;;;;;;;cAnFa,iCACK,4BACf;;;;;;;;;;;cAoEU,2BArEK,4BACf;;;;;;;;;;;;;cAiFU,iCAlFK,4BACf"}
@@ -1,4 +1,8 @@
1
- import { IntlayerConfig } from '@intlayer/config';
2
- import { type PluginOption } from 'vite';
3
- export declare const intlayerPrune: (intlayerConfig: IntlayerConfig) => PluginOption;
1
+ import { PluginOption } from "vite";
2
+ import { IntlayerConfig } from "@intlayer/types";
3
+
4
+ //#region src/intlayerPrunePlugin.d.ts
5
+ declare const intlayerPrune: (intlayerConfig: IntlayerConfig) => PluginOption;
6
+ //#endregion
7
+ export { intlayerPrune };
4
8
  //# sourceMappingURL=intlayerPrunePlugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"intlayerPrunePlugin.d.ts","sourceRoot":"","sources":["../../src/intlayerPrunePlugin.ts"],"names":[],"mappings":"AAEA,OAAO,EAAkB,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAIlE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,MAAM,CAAC;AAEzC,eAAO,MAAM,aAAa,GAAI,gBAAgB,cAAc,KAAG,YAsG9D,CAAC"}
1
+ {"version":3,"file":"intlayerPrunePlugin.d.ts","names":[],"sources":["../../src/intlayerPrunePlugin.ts"],"sourcesContent":[],"mappings":";;;;cAOa,gCAAiC,mBAAiB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-intlayer",
3
- "version": "6.1.6",
3
+ "version": "7.0.0-canary.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,58 +57,59 @@
57
57
  "./dist",
58
58
  "./package.json"
59
59
  ],
60
+ "scripts": {
61
+ "build": "tsdown --config tsdown.config.ts",
62
+ "build:ci": "tsdown --config tsdown.config.ts",
63
+ "clean": "rimraf ./dist .turbo",
64
+ "dev": "tsdown --config tsdown.config.ts --watch",
65
+ "format": "biome format . --check",
66
+ "format:fix": "biome format --write .",
67
+ "lint": "biome lint .",
68
+ "lint:fix": "biome lint --write .",
69
+ "prepublish": "cp -f ../../README.md ./README.md",
70
+ "test": "vitest run",
71
+ "test:watch": "vitest",
72
+ "typecheck": "tsc --noEmit --project tsconfig.types.json"
73
+ },
60
74
  "dependencies": {
61
- "@babel/core": "^7.28.4",
62
- "fast-glob": "^3.3.3",
63
- "@intlayer/chokidar": "6.1.6",
64
- "@intlayer/config": "6.1.6",
65
- "@intlayer/core": "6.1.6",
66
- "@intlayer/dictionaries-entry": "6.1.6",
67
- "@intlayer/babel": "6.1.6"
75
+ "@babel/core": "7.28.4",
76
+ "@intlayer/babel": "7.0.0-canary.2",
77
+ "@intlayer/chokidar": "7.0.0-canary.2",
78
+ "@intlayer/config": "7.0.0-canary.2",
79
+ "@intlayer/core": "7.0.0-canary.2",
80
+ "@intlayer/dictionaries-entry": "7.0.0-canary.2",
81
+ "@intlayer/types": "7.0.0-canary.2",
82
+ "fast-glob": "3.3.3",
83
+ "intlayer": "7.0.0-canary.2"
68
84
  },
69
85
  "devDependencies": {
70
- "@types/node": "^24.5.2",
71
- "@typescript-eslint/parser": "^8.44.1",
72
- "concurrently": "^9.2.1",
73
- "eslint": "^9.36.0",
74
- "prettier": "^3.6.2",
75
- "rimraf": "^6.0.1",
76
- "tsc-alias": "^1.8.16",
77
- "tsup": "^8.5.0",
78
- "typescript": "^5.9.2",
79
- "vitest": "^3.2.4",
80
- "@utils/ts-config": "1.0.4",
81
- "@utils/eslint-config": "1.0.4",
82
- "@utils/ts-config-types": "1.0.4",
83
- "@utils/tsup-config": "1.0.4"
86
+ "@types/node": "24.9.1",
87
+ "@utils/ts-config": "7.0.0-canary.2",
88
+ "@utils/ts-config-types": "7.0.0-canary.2",
89
+ "@utils/tsdown-config": "7.0.0-canary.2",
90
+ "rimraf": "6.0.1",
91
+ "tsdown": "0.15.9",
92
+ "typescript": "5.9.3",
93
+ "vitest": "4.0.3"
84
94
  },
85
95
  "peerDependencies": {
86
- "vite": ">=4.0.0",
87
- "@intlayer/chokidar": "6.1.6",
88
- "@intlayer/config": "6.1.6",
89
- "@intlayer/core": "6.1.6",
90
- "@intlayer/dictionaries-entry": "6.1.6"
96
+ "@babel/core": ">=6.0.0",
97
+ "@intlayer/chokidar": "7.0.0-canary.2",
98
+ "@intlayer/config": "7.0.0-canary.2",
99
+ "@intlayer/core": "7.0.0-canary.2",
100
+ "@intlayer/dictionaries-entry": "7.0.0-canary.2",
101
+ "@intlayer/types": "7.0.0-canary.2",
102
+ "vite": ">=4.0.0"
103
+ },
104
+ "peerDependenciesMeta": {
105
+ "@babel/core": {
106
+ "optional": true
107
+ }
91
108
  },
92
109
  "engines": {
93
110
  "node": ">=14.18"
94
111
  },
95
112
  "bug": {
96
113
  "url": "https://github.com/aymericzip/intlayer/issues"
97
- },
98
- "scripts": {
99
- "build": "pnpm clean & pnpm build:ci",
100
- "build:ci": "pnpm build:package & pnpm build:types",
101
- "build:package": "tsup",
102
- "build:types": "tsc --project ./tsconfig.types.json && tsc-alias --project ./tsconfig.types.json",
103
- "clean": "rimraf ./dist",
104
- "dev": "concurrently --prefix none \"tsup --watch\" \"tsc --project ./tsconfig.types.json --watch\" \"tsc-alias --project ./tsconfig.types.json --watch\"",
105
- "lint": "eslint . --cache",
106
- "lint:fix": "eslint . --cache --fix",
107
- "prettier": "prettier . --check",
108
- "prettier:fix": "prettier . --write",
109
- "prepublish": "cp -f ../../README.md ./README.md",
110
- "test": "vitest run",
111
- "test:watch": "vitest",
112
- "typecheck": "tsup --project ./tsconfig.json --noEmit"
113
114
  }
114
- }
115
+ }