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.
- package/dist/cjs/_virtual/rolldown_runtime.cjs +25 -0
- package/dist/cjs/index.cjs +11 -27
- package/dist/cjs/intlayerMiddlewarePlugin.cjs +217 -224
- package/dist/cjs/intlayerMiddlewarePlugin.cjs.map +1 -1
- package/dist/cjs/intlayerPlugin.cjs +85 -100
- package/dist/cjs/intlayerPlugin.cjs.map +1 -1
- package/dist/cjs/intlayerPrunePlugin.cjs +81 -123
- package/dist/cjs/intlayerPrunePlugin.cjs.map +1 -1
- package/dist/esm/_virtual/rolldown_runtime.mjs +8 -0
- package/dist/esm/index.mjs +5 -4
- package/dist/esm/intlayerMiddlewarePlugin.mjs +210 -197
- package/dist/esm/intlayerMiddlewarePlugin.mjs.map +1 -1
- package/dist/esm/intlayerPlugin.mjs +78 -63
- package/dist/esm/intlayerPlugin.mjs.map +1 -1
- package/dist/esm/intlayerPrunePlugin.mjs +75 -87
- package/dist/esm/intlayerPrunePlugin.mjs.map +1 -1
- package/dist/types/index.d.ts +4 -4
- package/dist/types/intlayerMiddlewarePlugin.d.ts +9 -4
- package/dist/types/intlayerMiddlewarePlugin.d.ts.map +1 -1
- package/dist/types/intlayerPlugin.d.ts +10 -4
- package/dist/types/intlayerPlugin.d.ts.map +1 -1
- package/dist/types/intlayerPrunePlugin.d.ts +7 -3
- package/dist/types/intlayerPrunePlugin.d.ts.map +1 -1
- package/package.json +45 -44
- package/LICENSE +0 -202
- package/dist/cjs/index.cjs.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
|
@@ -1,104 +1,89 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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 {
|
|
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,84 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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 node_path = require("node:path");
|
|
3
|
+
node_path = require_rolldown_runtime.__toESM(node_path);
|
|
4
|
+
let __intlayer_babel = require("@intlayer/babel");
|
|
5
|
+
__intlayer_babel = require_rolldown_runtime.__toESM(__intlayer_babel);
|
|
6
|
+
let __intlayer_dictionaries_entry = require("@intlayer/dictionaries-entry");
|
|
7
|
+
__intlayer_dictionaries_entry = require_rolldown_runtime.__toESM(__intlayer_dictionaries_entry);
|
|
8
|
+
let fast_glob = require("fast-glob");
|
|
9
|
+
fast_glob = require_rolldown_runtime.__toESM(fast_glob);
|
|
10
|
+
|
|
11
|
+
//#region src/intlayerPrunePlugin.ts
|
|
39
12
|
const intlayerPrune = (intlayerConfig) => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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
|
-
};
|
|
13
|
+
try {
|
|
14
|
+
const babel = require("@babel/core");
|
|
15
|
+
const { optimize, importMode, traversePattern } = intlayerConfig.build;
|
|
16
|
+
const { dictionariesDir, dynamicDictionariesDir, fetchDictionariesDir, mainDir, baseDir } = intlayerConfig.content;
|
|
17
|
+
const filesListPattern = fast_glob.default.sync(traversePattern, { cwd: baseDir }).map((file) => (0, node_path.join)(baseDir, file));
|
|
18
|
+
const dictionariesEntryPath = (0, node_path.join)(mainDir, "dictionaries.mjs");
|
|
19
|
+
const dynamicDictionariesEntryPath = (0, node_path.join)(mainDir, "dynamic_dictionaries.mjs");
|
|
20
|
+
const filesList = [...filesListPattern, dictionariesEntryPath];
|
|
21
|
+
const dictionaries = (0, __intlayer_dictionaries_entry.getDictionaries)();
|
|
22
|
+
const liveSyncKeys = Object.values(dictionaries).filter((dictionary) => dictionary.live).map((dictionary) => dictionary.key);
|
|
23
|
+
return {
|
|
24
|
+
name: "vite-intlayer-babel-transform",
|
|
25
|
+
enforce: "post",
|
|
26
|
+
transform(code, id) {
|
|
27
|
+
/**
|
|
28
|
+
* Transform file as
|
|
29
|
+
* .../HelloWorld.vue?vue&type=script&setup=true&lang.ts
|
|
30
|
+
* Into
|
|
31
|
+
* .../HelloWorld.vue
|
|
32
|
+
*
|
|
33
|
+
* Prevention for virtual file
|
|
34
|
+
*/
|
|
35
|
+
const filename = id.split("?", 1)[0];
|
|
36
|
+
if (!filesList.includes(filename)) return null;
|
|
37
|
+
if (!optimize) return null;
|
|
38
|
+
const result = babel.transformSync(code, {
|
|
39
|
+
filename,
|
|
40
|
+
plugins: [[__intlayer_babel.intlayerBabelPlugin, {
|
|
41
|
+
dictionariesDir,
|
|
42
|
+
dictionariesEntryPath,
|
|
43
|
+
dynamicDictionariesDir,
|
|
44
|
+
dynamicDictionariesEntryPath,
|
|
45
|
+
fetchDictionariesDir,
|
|
46
|
+
importMode,
|
|
47
|
+
filesList,
|
|
48
|
+
replaceDictionaryEntry: false,
|
|
49
|
+
liveSyncKeys
|
|
50
|
+
}]],
|
|
51
|
+
parserOpts: {
|
|
52
|
+
sourceType: "module",
|
|
53
|
+
allowImportExportEverywhere: true,
|
|
54
|
+
plugins: [
|
|
55
|
+
"typescript",
|
|
56
|
+
"jsx",
|
|
57
|
+
"decorators-legacy",
|
|
58
|
+
"classProperties",
|
|
59
|
+
"objectRestSpread",
|
|
60
|
+
"asyncGenerators",
|
|
61
|
+
"functionBind",
|
|
62
|
+
"exportDefaultFrom",
|
|
63
|
+
"exportNamespaceFrom",
|
|
64
|
+
"dynamicImport",
|
|
65
|
+
"nullishCoalescingOperator",
|
|
66
|
+
"optionalChaining"
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
if (result?.code) return {
|
|
71
|
+
code: result.code,
|
|
72
|
+
map: result.map
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
} catch (error) {
|
|
77
|
+
console.warn("Failed to transform with Babel plugin:", error);
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
121
80
|
};
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
});
|
|
81
|
+
|
|
82
|
+
//#endregion
|
|
83
|
+
exports.intlayerPrune = intlayerPrune;
|
|
126
84
|
//# sourceMappingURL=intlayerPrunePlugin.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/intlayerPrunePlugin.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"intlayerPrunePlugin.cjs","names":["fg","intlayerBabelPlugin"],"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,QAAQ,QAAQ,cAAc;EAEpC,MAAM,EAAE,UAAU,YAAY,oBAAoB,eAAe;EAEjE,MAAM,EACJ,iBACA,wBACA,sBACA,SACA,YACE,eAAe;EAEnB,MAAM,mBAAmBA,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 };
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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 };
|