ms-vite-plugin 0.2.1 → 0.2.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.
- package/bin/linux/ms-bundle-enc +0 -0
- package/bin/mac/ms-bundle-enc +0 -0
- package/dist/build.js +27 -5
- package/package.json +32 -32
package/bin/linux/ms-bundle-enc
CHANGED
|
File without changes
|
package/bin/mac/ms-bundle-enc
CHANGED
|
File without changes
|
package/dist/build.js
CHANGED
|
@@ -71,15 +71,37 @@ async function findEntryFiles(src, baseDir) {
|
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
73
73
|
* 插件:将 main 函数调用替换为 return main();
|
|
74
|
-
*
|
|
74
|
+
* 用于开发环境,不压缩变量名
|
|
75
75
|
* @returns 返回 Vite 插件实例
|
|
76
76
|
*/
|
|
77
|
-
function
|
|
77
|
+
function devReturnMain() {
|
|
78
|
+
return {
|
|
79
|
+
name: "return-main",
|
|
80
|
+
generateBundle(_, bundle) {
|
|
81
|
+
for (const fileName in bundle) {
|
|
82
|
+
const chunk = bundle[fileName];
|
|
83
|
+
if (chunk.type === "chunk") {
|
|
84
|
+
if (chunk.code.includes("setAsyncMode(true)")) {
|
|
85
|
+
chunk.code = chunk.code.replace(/\bmain\s*\(\s*\)\s*;/g, "return main();");
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* 插件:将 main 函数调用替换为 return main();
|
|
94
|
+
* 用于生产环境,压缩后执行
|
|
95
|
+
* @returns 返回 Vite 插件实例
|
|
96
|
+
*/
|
|
97
|
+
function prodReturnMain() {
|
|
78
98
|
return {
|
|
79
99
|
name: "return-main",
|
|
80
100
|
renderChunk(code, chunk) {
|
|
81
101
|
if (chunk.isEntry) {
|
|
82
|
-
|
|
102
|
+
if (code.includes("setAsyncMode(true)")) {
|
|
103
|
+
return code.replace(/\bmain\s*\(\s*\)\s*;/g, "return main();");
|
|
104
|
+
}
|
|
83
105
|
}
|
|
84
106
|
return code;
|
|
85
107
|
},
|
|
@@ -109,9 +131,9 @@ const buildAll = async (isDev = true, workspacePath) => {
|
|
|
109
131
|
minify: !isDev, // 开发环境不压缩变量名
|
|
110
132
|
},
|
|
111
133
|
plugins: isDev
|
|
112
|
-
? [
|
|
134
|
+
? [devReturnMain()]
|
|
113
135
|
: [
|
|
114
|
-
|
|
136
|
+
prodReturnMain(),
|
|
115
137
|
(0, vite_plugin_bundle_obfuscator_1.default)({
|
|
116
138
|
autoExcludeNodeModules: true,
|
|
117
139
|
threadPool: true,
|
package/package.json
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "ms-vite-plugin",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"type": "commonjs",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"publishConfig": {
|
|
7
|
-
"access": "public"
|
|
8
|
-
},
|
|
9
|
-
"files": [
|
|
10
|
-
"dist",
|
|
11
|
-
"bin"
|
|
12
|
-
],
|
|
13
|
-
"bin": {
|
|
14
|
-
"ms-cli": "./dist/cli.js",
|
|
15
|
-
"ms": "./dist/cli.js"
|
|
16
|
-
},
|
|
17
|
-
"scripts": {
|
|
18
|
-
"build": "tsc",
|
|
19
|
-
"prepublishOnly": "npm run build"
|
|
20
|
-
},
|
|
21
|
-
"dependencies": {
|
|
22
|
-
"commander": "^14.0.2",
|
|
23
|
-
"fs-extra": "^11.3.2",
|
|
24
|
-
"vite": "^7.2.2",
|
|
25
|
-
"vite-plugin-bundle-obfuscator": "^1.8.0",
|
|
26
|
-
"zip-a-folder": "^3.1.9"
|
|
27
|
-
},
|
|
28
|
-
"devDependencies": {
|
|
29
|
-
"@types/fs-extra": "^11.0.4",
|
|
30
|
-
"@types/node": "^24.10.0",
|
|
31
|
-
"typescript": "~5.9.3"
|
|
32
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "ms-vite-plugin",
|
|
3
|
+
"version": "0.2.3",
|
|
4
|
+
"type": "commonjs",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"bin"
|
|
12
|
+
],
|
|
13
|
+
"bin": {
|
|
14
|
+
"ms-cli": "./dist/cli.js",
|
|
15
|
+
"ms": "./dist/cli.js"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc",
|
|
19
|
+
"prepublishOnly": "npm run build"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"commander": "^14.0.2",
|
|
23
|
+
"fs-extra": "^11.3.2",
|
|
24
|
+
"vite": "^7.2.2",
|
|
25
|
+
"vite-plugin-bundle-obfuscator": "^1.8.0",
|
|
26
|
+
"zip-a-folder": "^3.1.9"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/fs-extra": "^11.0.4",
|
|
30
|
+
"@types/node": "^24.10.0",
|
|
31
|
+
"typescript": "~5.9.3"
|
|
32
|
+
}
|
|
33
33
|
}
|