ms-vite-plugin 0.2.2 → 0.2.5
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/build.js +7 -3
- package/package.json +1 -1
package/dist/build.js
CHANGED
|
@@ -71,7 +71,7 @@ async function findEntryFiles(src, baseDir) {
|
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
73
73
|
* 插件:将 main 函数调用替换为 return main();
|
|
74
|
-
*
|
|
74
|
+
* 用于开发环境,不压缩变量名
|
|
75
75
|
* @returns 返回 Vite 插件实例
|
|
76
76
|
*/
|
|
77
77
|
function devReturnMain() {
|
|
@@ -81,7 +81,9 @@ function devReturnMain() {
|
|
|
81
81
|
for (const fileName in bundle) {
|
|
82
82
|
const chunk = bundle[fileName];
|
|
83
83
|
if (chunk.type === "chunk") {
|
|
84
|
-
|
|
84
|
+
if (chunk.code.includes("setAsyncMode(true)")) {
|
|
85
|
+
chunk.code = chunk.code.replace(/\bmain\s*\(\s*\)\s*;/g, "return main();");
|
|
86
|
+
}
|
|
85
87
|
}
|
|
86
88
|
}
|
|
87
89
|
},
|
|
@@ -97,7 +99,9 @@ function prodReturnMain() {
|
|
|
97
99
|
name: "return-main",
|
|
98
100
|
renderChunk(code, chunk) {
|
|
99
101
|
if (chunk.isEntry) {
|
|
100
|
-
|
|
102
|
+
if (code.includes("setAsyncMode(true)")) {
|
|
103
|
+
return code.replace(/\bmain\s*\(\s*\)\s*;/g, "return main();");
|
|
104
|
+
}
|
|
101
105
|
}
|
|
102
106
|
return code;
|
|
103
107
|
},
|