ms-vite-plugin 0.2.2 → 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.
File without changes
File without changes
package/dist/build.js CHANGED
@@ -71,7 +71,7 @@ async function findEntryFiles(src, baseDir) {
71
71
  }
72
72
  /**
73
73
  * 插件:将 main 函数调用替换为 return main();
74
- * 用于支持后续的 promise 调用
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
- chunk.code = chunk.code.replace(/\bmain\s*\(\s*\)\s*;/g, "return main();");
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
- return code.replace(/\bmain\s*\(\s*\)\s*;/g, "return main();");
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
  },
package/package.json CHANGED
@@ -1,33 +1,33 @@
1
- {
2
- "name": "ms-vite-plugin",
3
- "version": "0.2.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
  }