ms-vite-plugin 0.1.9 → 0.2.1

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.
Files changed (2) hide show
  1. package/dist/build.js +5 -14
  2. package/package.json +1 -2
package/dist/build.js CHANGED
@@ -77,13 +77,11 @@ async function findEntryFiles(src, baseDir) {
77
77
  function returnMain() {
78
78
  return {
79
79
  name: "return-main",
80
- generateBundle(_, bundle) {
81
- for (const fileName in bundle) {
82
- const chunk = bundle[fileName];
83
- if (chunk.type === "chunk") {
84
- chunk.code = chunk.code.replace(/\bmain\s*\(\s*\)\s*;/g, "return main();");
85
- }
80
+ renderChunk(code, chunk) {
81
+ if (chunk.isEntry) {
82
+ return code.replace(/\bmain\s*\(\s*\)\s*;/g, "return main();");
86
83
  }
84
+ return code;
87
85
  },
88
86
  };
89
87
  }
@@ -108,14 +106,7 @@ const buildAll = async (isDev = true, workspacePath) => {
108
106
  outDir: isDev ? "dist/scripts" : "msbundle/scripts",
109
107
  emptyOutDir: false, // 不要每次清空输出目录
110
108
  sourcemap: isDev,
111
- minify: isDev ? false : "terser", // 开发环境不压缩变量名
112
- terserOptions: {
113
- // @ts-ignore
114
- mangle: {
115
- reserved: ["main"],
116
- },
117
- keep_fnames: /main/,
118
- },
109
+ minify: !isDev, // 开发环境不压缩变量名
119
110
  },
120
111
  plugins: isDev
121
112
  ? [returnMain()]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ms-vite-plugin",
3
- "version": "0.1.9",
3
+ "version": "0.2.1",
4
4
  "type": "commonjs",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -21,7 +21,6 @@
21
21
  "dependencies": {
22
22
  "commander": "^14.0.2",
23
23
  "fs-extra": "^11.3.2",
24
- "terser": "^5.44.1",
25
24
  "vite": "^7.2.2",
26
25
  "vite-plugin-bundle-obfuscator": "^1.8.0",
27
26
  "zip-a-folder": "^3.1.9"