Ver código fonte

切换为 terser 压缩,修复 esbuild 导致的 TDZ JS 初始化错误

esbuild 压缩时变量重排导致 "Cannot access 'xT' before initialization",
改用 terser 压缩规避此问题。terser 更保守,不会引入 TDZ 异常。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
skyline 2 dias atrás
pai
commit
14d4f06d9d
3 arquivos alterados com 10 adições e 22 exclusões
  1. 6 22
      admin-h5/package-lock.json
  2. 1 0
      admin-h5/package.json
  3. 3 0
      admin-h5/vite.config.js

+ 6 - 22
admin-h5/package-lock.json

@@ -1,11 +1,11 @@
 {
-  "name": "admin-app",
+  "name": "admin-h5",
   "version": "1.0.0",
   "lockfileVersion": 3,
   "requires": true,
   "packages": {
     "": {
-      "name": "admin-app",
+      "name": "admin-h5",
       "version": "1.0.0",
       "license": "ISC",
       "dependencies": {
@@ -35,6 +35,7 @@
         "@dcloudio/vite-plugin-uni": "3.0.0-alpha-5000020260104004",
         "@vue/compiler-sfc": "^3.4.21",
         "sass": "^1.99.0",
+        "terser": "^5.48.0",
         "vite": "5.2.8",
         "vue-tsc": "^1.0.24"
       }
@@ -4693,7 +4694,6 @@
       "version": "2.5.6",
       "resolved": "https://registry.npmmirror.com/@parcel/watcher/-/watcher-2.5.6.tgz",
       "integrity": "sha512-tmmZ3lQxAe/k/+rNnXQRawJ4NjxO2hqiOLTHvWchtGZULp4RyFeh6aU4XdOYBFe2KE1oShQTv4AblOs2iOrNnQ==",
-      "dev": true,
       "hasInstallScript": true,
       "license": "MIT",
       "optional": true,
@@ -4733,7 +4733,6 @@
       "cpu": [
         "arm64"
       ],
-      "dev": true,
       "license": "MIT",
       "optional": true,
       "os": [
@@ -4754,7 +4753,6 @@
       "cpu": [
         "arm64"
       ],
-      "dev": true,
       "license": "MIT",
       "optional": true,
       "os": [
@@ -4775,7 +4773,6 @@
       "cpu": [
         "x64"
       ],
-      "dev": true,
       "license": "MIT",
       "optional": true,
       "os": [
@@ -4796,7 +4793,6 @@
       "cpu": [
         "x64"
       ],
-      "dev": true,
       "license": "MIT",
       "optional": true,
       "os": [
@@ -4817,7 +4813,6 @@
       "cpu": [
         "arm"
       ],
-      "dev": true,
       "license": "MIT",
       "optional": true,
       "os": [
@@ -4838,7 +4833,6 @@
       "cpu": [
         "arm"
       ],
-      "dev": true,
       "license": "MIT",
       "optional": true,
       "os": [
@@ -4859,7 +4853,6 @@
       "cpu": [
         "arm64"
       ],
-      "dev": true,
       "license": "MIT",
       "optional": true,
       "os": [
@@ -4880,7 +4873,6 @@
       "cpu": [
         "arm64"
       ],
-      "dev": true,
       "license": "MIT",
       "optional": true,
       "os": [
@@ -4901,7 +4893,6 @@
       "cpu": [
         "x64"
       ],
-      "dev": true,
       "license": "MIT",
       "optional": true,
       "os": [
@@ -4922,7 +4913,6 @@
       "cpu": [
         "x64"
       ],
-      "dev": true,
       "license": "MIT",
       "optional": true,
       "os": [
@@ -4943,7 +4933,6 @@
       "cpu": [
         "arm64"
       ],
-      "dev": true,
       "license": "MIT",
       "optional": true,
       "os": [
@@ -4964,7 +4953,6 @@
       "cpu": [
         "ia32"
       ],
-      "dev": true,
       "license": "MIT",
       "optional": true,
       "os": [
@@ -4985,7 +4973,6 @@
       "cpu": [
         "x64"
       ],
-      "dev": true,
       "license": "MIT",
       "optional": true,
       "os": [
@@ -5003,7 +4990,6 @@
       "version": "4.0.4",
       "resolved": "https://registry.npmmirror.com/picomatch/-/picomatch-4.0.4.tgz",
       "integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==",
-      "dev": true,
       "license": "MIT",
       "optional": true,
       "engines": {
@@ -7328,7 +7314,6 @@
       "version": "2.1.2",
       "resolved": "https://registry.npmmirror.com/detect-libc/-/detect-libc-2.1.2.tgz",
       "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==",
-      "dev": true,
       "license": "Apache-2.0",
       "optional": true,
       "engines": {
@@ -11304,7 +11289,6 @@
       "version": "7.1.1",
       "resolved": "https://registry.npmmirror.com/node-addon-api/-/node-addon-api-7.1.1.tgz",
       "integrity": "sha512-5m3bsyrjFWE1xf7nz7YXdN4udnVtXK6/Yfgn5qnahL6bCkf2yKt4k3nuTKAtT4r3IG8JNR2ncsIMdZuAzJjHQQ==",
-      "dev": true,
       "license": "MIT",
       "optional": true
     },
@@ -13064,9 +13048,9 @@
       }
     },
     "node_modules/terser": {
-      "version": "5.44.1",
-      "resolved": "https://registry.npmmirror.com/terser/-/terser-5.44.1.tgz",
-      "integrity": "sha512-t/R3R/n0MSwnnazuPpPNVO60LX0SKL45pyl9YlvxIdkH0Of7D5qM2EVe+yASRIlY5pZ73nclYJfNANGWPwFDZw==",
+      "version": "5.48.0",
+      "resolved": "https://registry.npmmirror.com/terser/-/terser-5.48.0.tgz",
+      "integrity": "sha512-J/9An6vs9Us6wKRriSFXBWdRZapREHqFzdNUKk0pmu804EMR6dr6winwo7e5JDxN4xahxQsuysyYFwlwj4XN/Q==",
       "devOptional": true,
       "license": "BSD-2-Clause",
       "dependencies": {

+ 1 - 0
admin-h5/package.json

@@ -37,6 +37,7 @@
     "@dcloudio/vite-plugin-uni": "3.0.0-alpha-5000020260104004",
     "@vue/compiler-sfc": "^3.4.21",
     "sass": "^1.99.0",
+    "terser": "^5.48.0",
     "vite": "5.2.8",
     "vue-tsc": "^1.0.24"
   },

+ 3 - 0
admin-h5/vite.config.js

@@ -7,6 +7,9 @@ export default defineConfig(({ command, mode }) => {
   return {
     base: isBuild ? '/admin/h5/' : './',
     plugins: [uni()],
+    build: {
+      minify: 'terser'
+    },
     css: {
       preprocessorOptions: {
         scss: {