vite-intlayer 6.1.6 → 7.0.0-canary.3

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,104 +1,89 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
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
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var intlayerPlugin_exports = {};
30
- __export(intlayerPlugin_exports, {
31
- intLayerPlugin: () => intLayerPlugin,
32
- intlayer: () => intlayer,
33
- intlayerPlugin: () => intlayerPlugin
34
- });
35
- module.exports = __toCommonJS(intlayerPlugin_exports);
36
- var import_chokidar = require("@intlayer/chokidar");
37
- var import_built = __toESM(require("@intlayer/config/built"));
38
- var import_path = require("path");
39
- var import_config = require("@intlayer/config");
40
- var import_intlayerPrunePlugin = require('./intlayerPrunePlugin.cjs');
41
- const intlayerPlugin = () => {
42
- const { watch: isWatchMode } = import_built.default.content;
43
- const { optimize } = import_built.default.build;
44
- const appLogger = (0, import_config.getAppLogger)(import_built.default);
45
- const plugins = [
46
- {
47
- name: "vite-intlayer-plugin",
48
- config: (config) => {
49
- config.resolve = {
50
- ...config.resolve,
51
- alias: {
52
- ...config.resolve?.alias,
53
- ...(0, import_config.getAlias)({
54
- configuration: import_built.default,
55
- formatter: (value) => (0, import_path.resolve)(value)
56
- })
57
- }
58
- };
59
- if (isWatchMode) {
60
- config.optimizeDeps = {
61
- ...config.optimizeDeps,
62
- exclude: [
63
- ...config.optimizeDeps?.exclude ?? [],
64
- "@intlayer/dictionaries-entry",
65
- "@intlayer/config/built"
66
- ]
67
- };
68
- }
69
- return config;
70
- },
71
- configureServer: async (server) => {
72
- if (import_built.default.content.watch) {
73
- (0, import_chokidar.watch)({ configuration: import_built.default });
74
- }
75
- },
76
- buildStart: async () => {
77
- const sentinelPath = (0, import_path.join)(
78
- import_built.default.content.baseDir,
79
- ".intlayer",
80
- "cache",
81
- "intlayer-prepared.lock"
82
- );
83
- await (0, import_chokidar.runOnce)(
84
- sentinelPath,
85
- async () => await (0, import_chokidar.prepareIntlayer)(import_built.default),
86
- () => appLogger("Intlayer prepared")
87
- );
88
- }
89
- }
90
- ];
91
- if (optimize) {
92
- plugins.push((0, import_intlayerPrunePlugin.intlayerPrune)(import_built.default));
93
- }
94
- return plugins;
1
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
+ const require_intlayerPrunePlugin = require('./intlayerPrunePlugin.cjs');
3
+ let __intlayer_config = require("@intlayer/config");
4
+ __intlayer_config = require_rolldown_runtime.__toESM(__intlayer_config);
5
+ let node_path = require("node:path");
6
+ node_path = require_rolldown_runtime.__toESM(node_path);
7
+ let __intlayer_chokidar = require("@intlayer/chokidar");
8
+ __intlayer_chokidar = require_rolldown_runtime.__toESM(__intlayer_chokidar);
9
+
10
+ //#region src/intlayerPlugin.ts
11
+ /**
12
+ * @deprecated Rename to intlayer instead
13
+ *
14
+ * A Vite plugin that integrates Intlayer configuration into the build process
15
+ *
16
+ * ```ts
17
+ * // Example usage of the plugin in a Vite configuration
18
+ * export default defineConfig({
19
+ * plugins: [ intlayer() ],
20
+ * });
21
+ * ```
22
+ * */
23
+ const intlayerPlugin = (configOptions) => {
24
+ const intlayerConfig = (0, __intlayer_config.getConfiguration)(configOptions);
25
+ const { watch: isWatchMode } = intlayerConfig.content;
26
+ const { optimize } = intlayerConfig.build;
27
+ const plugins = [{
28
+ name: "vite-intlayer-plugin",
29
+ config: (config) => {
30
+ config.resolve = {
31
+ ...config.resolve,
32
+ alias: {
33
+ ...config.resolve?.alias,
34
+ ...(0, __intlayer_config.getAlias)({
35
+ configuration: intlayerConfig,
36
+ formatter: (value) => (0, node_path.resolve)(value)
37
+ })
38
+ }
39
+ };
40
+ if (isWatchMode) config.optimizeDeps = {
41
+ ...config.optimizeDeps,
42
+ exclude: [
43
+ ...config.optimizeDeps?.exclude ?? [],
44
+ "@intlayer/dictionaries-entry",
45
+ "@intlayer/config/built"
46
+ ]
47
+ };
48
+ return config;
49
+ },
50
+ configureServer: async (_server) => {
51
+ if (intlayerConfig.content.watch) (0, __intlayer_chokidar.watch)({ configuration: intlayerConfig });
52
+ },
53
+ buildStart: async () => {
54
+ await (0, __intlayer_chokidar.prepareIntlayer)(intlayerConfig);
55
+ }
56
+ }];
57
+ if (optimize) plugins.push(require_intlayerPrunePlugin.intlayerPrune(intlayerConfig));
58
+ return plugins;
95
59
  };
60
+ /**
61
+ * A Vite plugin that integrates Intlayer configuration into the build process
62
+ *
63
+ * ```ts
64
+ * // Example usage of the plugin in a Vite configuration
65
+ * export default defineConfig({
66
+ * plugins: [ intlayer() ],
67
+ * });
68
+ * ```
69
+ */
96
70
  const intlayer = intlayerPlugin;
71
+ /**
72
+ * @deprecated Rename to intlayer instead
73
+ *
74
+ * A Vite plugin that integrates Intlayer configuration into the build process
75
+ *
76
+ * ```ts
77
+ * // Example usage of the plugin in a Vite configuration
78
+ * export default defineConfig({
79
+ * plugins: [ intlayer() ],
80
+ * });
81
+ * ```
82
+ */
97
83
  const intLayerPlugin = intlayerPlugin;
98
- // Annotate the CommonJS export names for ESM import in node:
99
- 0 && (module.exports = {
100
- intLayerPlugin,
101
- intlayer,
102
- intlayerPlugin
103
- });
84
+
85
+ //#endregion
86
+ exports.intLayerPlugin = intLayerPlugin;
87
+ exports.intlayer = intlayer;
88
+ exports.intlayerPlugin = intlayerPlugin;
104
89
  //# sourceMappingURL=intlayerPlugin.cjs.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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAgD;AAChD,mBAA2B;AAC3B,kBAA8B;AAE9B,oBAAuC;AAEvC,iCAA8B;AAcvB,MAAM,iBAAiB,MAAoB;AAChD,QAAM,EAAE,OAAO,YAAY,IAAI,aAAAA,QAAe;AAC9C,QAAM,EAAE,SAAS,IAAI,aAAAA,QAAe;AACpC,QAAM,gBAAY,4BAAa,aAAAA,OAAc;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,OAAG,wBAAS;AAAA,cACV,eAAe,aAAAA;AAAA,cACf,WAAW,CAAC,cAAkB,qBAAQ,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,aAAAA,QAAe,QAAQ,OAAO;AAEhC,qCAAM,EAAE,eAAe,aAAAA,QAAe,CAAC;AAAA,QACzC;AAAA,MACF;AAAA,MAEA,YAAY,YAAY;AACtB,cAAM,mBAAe;AAAA,UACnB,aAAAA,QAAe,QAAQ;AAAA,UACvB;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAIA,kBAAM;AAAA,UACJ;AAAA,UACA,YAAY,UAAM,iCAAgB,aAAAA,OAAc;AAAA,UAChD,MAAM,UAAU,mBAAmB;AAAA,QACrC;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAGA,MAAI,UAAU;AACZ,YAAQ,SAAK,0CAAc,aAAAA,OAAc,CAAC;AAAA,EAC5C;AAEA,SAAO;AACT;AAYO,MAAM,WAAW;AAajB,MAAM,iBAAiB;","names":["intlayerConfig"]}
1
+ {"version":3,"file":"intlayerPlugin.cjs","names":["plugins: PluginOption[]","intlayerPrune"],"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,yDAAkC,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,mCAAY;MACV,eAAe;MACf,YAAY,iCAA0B,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,gCAAM,EAAE,eAAe,gBAAgB,CAAC;;EAI5C,YAAY,YAAY;AAEtB,kDAAsB,eAAe;;EAExC,CACF;AAGD,KAAI,SACF,SAAQ,KAAKC,0CAAc,eAAe,CAAC;AAG7C,QAAO;;;;;;;;;;;;AAaT,MAAa,WAAW;;;;;;;;;;;;;AAaxB,MAAa,iBAAiB"}
@@ -1,126 +1,88 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
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
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var intlayerPrunePlugin_exports = {};
30
- __export(intlayerPrunePlugin_exports, {
31
- intlayerPrune: () => intlayerPrune
32
- });
33
- module.exports = __toCommonJS(intlayerPrunePlugin_exports);
34
- var import_babel = require("@intlayer/babel");
35
- var import_config = require("@intlayer/config");
36
- var import_dictionaries_entry = __toESM(require("@intlayer/dictionaries-entry"));
37
- var import_fast_glob = __toESM(require("fast-glob"));
38
- var import_path = require("path");
1
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
+ let __intlayer_config = require("@intlayer/config");
3
+ __intlayer_config = require_rolldown_runtime.__toESM(__intlayer_config);
4
+ let node_path = require("node:path");
5
+ node_path = require_rolldown_runtime.__toESM(node_path);
6
+ let node_module = require("node:module");
7
+ node_module = require_rolldown_runtime.__toESM(node_module);
8
+ let __intlayer_babel = require("@intlayer/babel");
9
+ __intlayer_babel = require_rolldown_runtime.__toESM(__intlayer_babel);
10
+ let __intlayer_dictionaries_entry = require("@intlayer/dictionaries-entry");
11
+ __intlayer_dictionaries_entry = require_rolldown_runtime.__toESM(__intlayer_dictionaries_entry);
12
+ let fast_glob = require("fast-glob");
13
+ fast_glob = require_rolldown_runtime.__toESM(fast_glob);
14
+
15
+ //#region src/intlayerPrunePlugin.ts
39
16
  const intlayerPrune = (intlayerConfig) => {
40
- const { optimize, importMode, traversePattern } = intlayerConfig.build;
41
- const {
42
- dictionariesDir,
43
- dynamicDictionariesDir,
44
- fetchDictionariesDir,
45
- mainDir,
46
- baseDir
47
- } = intlayerConfig.content;
48
- const filesListPattern = import_fast_glob.default.sync(traversePattern, {
49
- cwd: baseDir
50
- }).map((file) => (0, import_path.join)(baseDir, file));
51
- const dictionariesEntryPath = (0, import_path.join)(mainDir, "dictionaries.mjs");
52
- const dynamicDictionariesEntryPath = (0, import_path.join)(
53
- mainDir,
54
- "dynamic_dictionaries.mjs"
55
- );
56
- const filesList = [
57
- ...filesListPattern,
58
- dictionariesEntryPath
59
- // should add dictionariesEntryPath to replace it by a empty object if import made dynamic
60
- ];
61
- const liveSyncKeys = Object.values(import_dictionaries_entry.default).filter((dictionary) => dictionary.live).map((dictionary) => dictionary.key);
62
- return {
63
- name: "vite-intlayer-babel-transform",
64
- enforce: "post",
65
- // Run after other transformations as vue
66
- transform(code, id) {
67
- const filename = id.split("?", 1)[0];
68
- if (!filesList.includes(filename)) return null;
69
- if (!optimize) return null;
70
- try {
71
- const babel = (0, import_config.ESMxCJSRequire)("@babel/core");
72
- const result = babel.transformSync(code, {
73
- filename,
74
- plugins: [
75
- [
76
- import_babel.intlayerBabelPlugin,
77
- {
78
- dictionariesDir,
79
- dictionariesEntryPath,
80
- dynamicDictionariesDir,
81
- dynamicDictionariesEntryPath,
82
- fetchDictionariesDir,
83
- importMode,
84
- filesList,
85
- replaceDictionaryEntry: false,
86
- liveSyncKeys
87
- }
88
- ]
89
- ],
90
- parserOpts: {
91
- sourceType: "module",
92
- allowImportExportEverywhere: true,
93
- plugins: [
94
- "typescript",
95
- "jsx",
96
- "decorators-legacy",
97
- "classProperties",
98
- "objectRestSpread",
99
- "asyncGenerators",
100
- "functionBind",
101
- "exportDefaultFrom",
102
- "exportNamespaceFrom",
103
- "dynamicImport",
104
- "nullishCoalescingOperator",
105
- "optionalChaining"
106
- ]
107
- }
108
- });
109
- if (result?.code) {
110
- return {
111
- code: result.code,
112
- map: result.map
113
- };
114
- }
115
- } catch (error) {
116
- console.warn("Failed to transform with Babel plugin:", error);
117
- }
118
- return null;
119
- }
120
- };
17
+ try {
18
+ const babel = (__intlayer_config.isESModule ? (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href) : require)("@babel/core");
19
+ const { optimize, importMode, traversePattern } = intlayerConfig.build;
20
+ const { dictionariesDir, dynamicDictionariesDir, fetchDictionariesDir, mainDir, baseDir } = intlayerConfig.content;
21
+ const filesListPattern = fast_glob.default.sync(traversePattern, { cwd: baseDir }).map((file) => (0, node_path.join)(baseDir, file));
22
+ const dictionariesEntryPath = (0, node_path.join)(mainDir, "dictionaries.mjs");
23
+ const dynamicDictionariesEntryPath = (0, node_path.join)(mainDir, "dynamic_dictionaries.mjs");
24
+ const filesList = [...filesListPattern, dictionariesEntryPath];
25
+ const dictionaries = (0, __intlayer_dictionaries_entry.getDictionaries)();
26
+ const liveSyncKeys = Object.values(dictionaries).filter((dictionary) => dictionary.live).map((dictionary) => dictionary.key);
27
+ return {
28
+ name: "vite-intlayer-babel-transform",
29
+ enforce: "post",
30
+ transform(code, id) {
31
+ /**
32
+ * Transform file as
33
+ * .../HelloWorld.vue?vue&type=script&setup=true&lang.ts
34
+ * Into
35
+ * .../HelloWorld.vue
36
+ *
37
+ * Prevention for virtual file
38
+ */
39
+ const filename = id.split("?", 1)[0];
40
+ if (!filesList.includes(filename)) return null;
41
+ if (!optimize) return null;
42
+ const result = babel.transformSync(code, {
43
+ filename,
44
+ plugins: [[__intlayer_babel.intlayerBabelPlugin, {
45
+ dictionariesDir,
46
+ dictionariesEntryPath,
47
+ dynamicDictionariesDir,
48
+ dynamicDictionariesEntryPath,
49
+ fetchDictionariesDir,
50
+ importMode,
51
+ filesList,
52
+ replaceDictionaryEntry: false,
53
+ liveSyncKeys
54
+ }]],
55
+ parserOpts: {
56
+ sourceType: "module",
57
+ allowImportExportEverywhere: true,
58
+ plugins: [
59
+ "typescript",
60
+ "jsx",
61
+ "decorators-legacy",
62
+ "classProperties",
63
+ "objectRestSpread",
64
+ "asyncGenerators",
65
+ "functionBind",
66
+ "exportDefaultFrom",
67
+ "exportNamespaceFrom",
68
+ "dynamicImport",
69
+ "nullishCoalescingOperator",
70
+ "optionalChaining"
71
+ ]
72
+ }
73
+ });
74
+ if (result?.code) return {
75
+ code: result.code,
76
+ map: result.map
77
+ };
78
+ }
79
+ };
80
+ } catch (error) {
81
+ console.warn("Failed to transform with Babel plugin:", error);
82
+ return null;
83
+ }
121
84
  };
122
- // Annotate the CommonJS export names for ESM import in node:
123
- 0 && (module.exports = {
124
- intlayerPrune
125
- });
85
+
86
+ //#endregion
87
+ exports.intlayerPrune = intlayerPrune;
126
88
  //# sourceMappingURL=intlayerPrunePlugin.cjs.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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAoC;AACpC,oBAA+C;AAC/C,gCAAyB;AACzB,uBAAe;AACf,kBAAqB;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,iBAAAA,QACtB,KAAK,iBAAiB;AAAA,IACrB,KAAK;AAAA,EACP,CAAC,EACA,IAAI,CAAC,aAAS,kBAAK,SAAS,IAAI,CAAC;AAEpC,QAAM,4BAAwB,kBAAK,SAAS,kBAAkB;AAC9D,QAAM,mCAA+B;AAAA,IACnC;AAAA,IACA;AAAA,EACF;AAEA,QAAM,YAAY;AAAA,IAChB,GAAG;AAAA,IACH;AAAA;AAAA,EACF;AAEA,QAAM,eAAe,OAAO,OAAO,0BAAAC,OAAY,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,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;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":["fg","dictionaries"]}
1
+ {"version":3,"file":"intlayerPrunePlugin.cjs","names":["isESModule","fg","intlayerBabelPlugin"],"sources":["../../src/intlayerPrunePlugin.ts"],"sourcesContent":["import { createRequire } from 'node:module';\nimport { join } from 'node:path';\nimport { intlayerBabelPlugin } from '@intlayer/babel';\nimport { isESModule } from '@intlayer/config';\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 localeRequire = isESModule ? createRequire(import.meta.url) : require;\n const babel = localeRequire('@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":";;;;;;;;;;;;;;;AASA,MAAa,iBAAiB,mBAAiD;AAC7E,KAAI;EAEF,MAAM,SADgBA,4GAA2C,GAAG,SACxC,cAAc;EAE1C,MAAM,EAAE,UAAU,YAAY,oBAAoB,eAAe;EAEjE,MAAM,EACJ,iBACA,wBACA,sBACA,SACA,YACE,eAAe;EAEnB,MAAM,mBAAmBC,kBACtB,KAAK,iBAAiB,EACrB,KAAK,SACN,CAAC,CACD,KAAK,6BAAc,SAAS,KAAK,CAAC;EAErC,MAAM,4CAA6B,SAAS,mBAAmB;EAC/D,MAAM,mDACJ,SACA,2BACD;EAED,MAAM,YAAY,CAChB,GAAG,kBACH,sBACD;EAED,MAAM,mEAAgC;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,CACEC,sCACA;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"}
@@ -0,0 +1,8 @@
1
+ //#region rolldown:runtime
2
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof require !== "undefined" ? require : a)[b] }) : x)(function(x) {
3
+ if (typeof require !== "undefined") return require.apply(this, arguments);
4
+ throw Error("Calling `require` for \"" + x + "\" in an environment that doesn't expose the `require` function.");
5
+ });
6
+
7
+ //#endregion
8
+ export { __require };
@@ -1,4 +1,5 @@
1
- export * from "./intlayerMiddlewarePlugin.mjs";
2
- export * from "./intlayerPlugin.mjs";
3
- export * from "./intlayerPrunePlugin.mjs";
4
- //# sourceMappingURL=index.mjs.map
1
+ import { intLayerMiddleware, intlayerMiddleware, intlayerMiddlewarePlugin } from "./intlayerMiddlewarePlugin.mjs";
2
+ import { intlayerPrune } from "./intlayerPrunePlugin.mjs";
3
+ import { intLayerPlugin, intlayer, intlayerPlugin } from "./intlayerPlugin.mjs";
4
+
5
+ export { intLayerMiddleware, intLayerPlugin, intlayer, intlayerMiddleware, intlayerMiddlewarePlugin, intlayerPlugin, intlayerPrune };