from Terser plugin Unexpected token: punc ({)
Describe the bug
我代码配置为
import mermaid from 'mermaid';
// import katex from 'katex';
config({
editorExtensions: {
mermaid: {
instance: mermaid, // Mermaid 实例
},
// katex: {
// instance: katex, // Katex 实例
// },
},
});
npm run dev正常 npm run build异常
错误内容
- Compiling task web... assets by status 29.9 MiB [cached] 473 assets webpack 5.88.2 compiled with 36 errors and 1 warning in 157357 ms
ERROR Webpack compile error. 16:08:24
Build Error Error: js/6662-eb001cb6033e7377e4db.js from Terser plugin
Unexpected token: punc ({) [js/6662-eb001cb6033e7377e4db.js:208,9]
js/8914-f381aeb7708642721e2b.js from Terser plugin Unexpected token: punc ({) [js/8914-f381aeb7708642721e2b.js:50,9]
js/8806-3606a52d3af620d8b065.js from Terser plugin Unexpected token: punc ({) [js/8806-3606a52d3af620d8b065.js:22,9]
js/1-5f0a4b56467982c18bff.js from Terser plugin Unexpected token: punc ({) [js/1-5f0a4b56467982c18bff.js:1067,9]
js/7787-e3a3de56b142daf002c7.js from Terser plugin Unexpected token: punc ({) [js/7787-e3a3de56b142daf002c7.js:752,9]
js/6355-a046ae553c348f954f37.js from Terser plugin Unexpected token: punc ({) [js/6355-a046ae553c348f954f37.js:2097,9]
js/5588-28eee6e71d55a4a6880b.js from Terser plugin Unexpected token: punc ({) [js/5588-28eee6e71d55a4a6880b.js:768,9]
js/9570-9b4ac962a581bfb4a361.js from Terser plugin Unexpected token: punc ({) [js/9570-9b4ac962a581bfb4a361.js:1007,9]
js/3614-5f58bd8749b79ab05bf2.js from Terser plugin Unexpected token: punc ({) [js/3614-5f58bd8749b79ab05bf2.js:62,9]
js/5716-c00c2b86607c0b467911.js from Terser plugin Unexpected token: punc ({) [js/5716-c00c2b86607c0b467911.js:903,9]
js/1420-2f9205f6942fca443eab.js from Terser plugin Unexpected token: punc ({) [js/1420-2f9205f6942fca443eab.js:1279,9]
js/8542-d29bd6c8be9cb7812b21.js from Terser plugin Unexpected token: punc ({) [js/8542-d29bd6c8be9cb7812b21.js:107,9]
js/4498-c2d015fc49c7d4dea30b.js from Terser plugin Unexpected token: punc ({) [js/4498-c2d015fc49c7d4dea30b.js:10151,9]
js/fb773c24-92914185198e27f4ed93.js from Terser plugin Unexpected token: punc ({) [js/fb773c24-92914185198e27f4ed93.js:1082,9]
js/2491-8eb881a803be19fd84be.js from Terser plugin Unexpected token: punc ({) [js/2491-8eb881a803be19fd84be.js:1248,9]
js/7329-54525b61033d92b2b4d1.js from Terser plugin Unexpected token: punc ({) [js/7329-54525b61033d92b2b4d1.js:1077,9]
js/834-853ac5d1e3cf576fb290.js from Terser plugin Unexpected token: punc ({) [js/834-853ac5d1e3cf576fb290.js:1382,9]
js/3936-55e64d2da2fc937b81fd.js from Terser plugin Unexpected token: punc ({) [js/3936-55e64d2da2fc937b81fd.js:53341,9]
js/6662-f5397fd3eb674fae353a.js from Terser plugin Unexpected token: punc ({) [js/6662-f5397fd3eb674fae353a.js:208,9]
js/8806-82c54b25396f91674551.js from Terser plugin Unexpected token: punc ({) [js/8806-82c54b25396f91674551.js:22,9]
js/8542-4d84a2889475a36befe6.js from Terser plugin Unexpected token: punc ({) [js/8542-4d84a2889475a36befe6.js:107,9]
js/8914-db6b0ed3a5f7e35c86ed.js from Terser plugin Unexpected token: punc ({) [js/8914-db6b0ed3a5f7e35c86ed.js:50,9]
js/1-a4ef424216fa9d527bb3.js from Terser plugin Unexpected token: punc ({) [js/1-a4ef424216fa9d527bb3.js:1067,9]
js/3614-89940c6cad6c7a6dad02.js from Terser plugin Unexpected token: punc ({) [js/3614-89940c6cad6c7a6dad02.js:62,9]
js/6355-4d6a06bca4538724a536.js from Terser plugin Unexpected token: punc ({) [js/6355-4d6a06bca4538724a536.js:2097,9]
js/fb773c24-9f9faf02a4ff28e03b0e.js from Terser plugin Unexpected token: punc ({) [js/fb773c24-9f9faf02a4ff28e03b0e.js:1082,9]
js/7787-625898790b8ff220e170.js from Terser plugin Unexpected token: punc ({) [js/7787-625898790b8ff220e170.js:752,9]
js/7329-4cd4a85fc76e4598f1cc.js from Terser plugin Unexpected token: punc ({) [js/7329-4cd4a85fc76e4598f1cc.js:1077,9]
js/5588-6949a3b927f0c213bbec.js from Terser plugin Unexpected token: punc ({) [js/5588-6949a3b927f0c213bbec.js:768,9]
js/2491-e48f0455d647c7b8048d.js from Terser plugin Unexpected token: punc ({) [js/2491-e48f0455d647c7b8048d.js:1248,9]
js/834-e531409ee153b0a068ce.js from Terser plugin Unexpected token: punc ({) [js/834-e531409ee153b0a068ce.js:1382,9]
js/1420-086411e76609a5c6bf52.js from Terser plugin Unexpected token: punc ({) [js/1420-086411e76609a5c6bf52.js:1279,9]
js/9570-a6023f5aadd34b318179.js from Terser plugin Unexpected token: punc ({) [js/9570-a6023f5aadd34b318179.js:1007,9]
js/5716-903ea877df6b0c68a05c.js from Terser plugin Unexpected token: punc ({) [js/5716-903ea877df6b0c68a05c.js:903,9]
js/4498-dcac3cc1a8dedeb422a8.js from Terser plugin Unexpected token: punc ({) [js/4498-dcac3cc1a8dedeb422a8.js:10151,9]
js/3936-971095b8eff8b0dcd5de.js from Terser plugin Unexpected token: punc ({) [js/3936-971095b8eff8b0dcd5de.js:53341,9] at file:///C:/Users/AI/Downloads/web/node_modules/@ice/app/esm/bundler/webpack/build.js:38:24 at C:\Users\AI\Downloads\web\node_modules@ice\bundles\compiled\webpack\bundle.js:77218:14 at processQueueWorker (C:\Users\AI\Downloads\web\node_modules@ice\bundles\compiled\webpack\bundle.js:77155:6) at processTicksAndRejections (node:internal/process/task_queues:77:11)
我的ice.config.mts文件为
import { defineConfig } from '@ice/app';
import request from '@ice/plugin-request';
import store from '@ice/plugin-store';
import auth from '@ice/plugin-auth';
import antd from '@ice/plugin-antd';
// The project config, see https://v3.ice.work/docs/guide/basic/config
export default defineConfig(() => ({
ssr: false,
ssg: false,
hash: 'contenthash',
publicPath: '/aigw-web/',
devPublicPath: '/aigw-web/',
compileDependencies: ['mermaid'],
routes: {
defineRoutes: (route) => {
// route("*", "404.tsx");
},
},
proxy: {
'/api/v1/chat': {
target: 'http://10.15.32.57',
changeOrigin: true,
pathRewrite: { '^/api/v1/chat': '/v1/chat' },
},
'/aigw/': {
target: 'http://10.21.15.15:32040',
changeOrigin: true,
// pathRewrite: { '^/api': '' },
},
},
terserOptions: Object.assign(terserPluginOptions.terserOptions || {}, options),
plugins: [
request(),
store(),
auth(),
antd({
theme: {
'border-radius-base': '8px',
},
}),
],
}));
Expected behavior
希望可以正常打包,icejs版本为^3.0.0
Actual behavior
No response
Version of ice.js
^3.0.0zuixinbanben
Content of build.json or ice.config.mts
{
"name": "@ice/antd-pro-scaffold",
"version": "0.1.0",
"description": "aigateway console",
"dependencies": {
"@ant-design/charts": "^1.4.2",
"@ant-design/icons": "^4.7.0",
"@ant-design/pro-components": "^2.3.51",
"@ant-design/pro-form": "^2.2.8",
"@ant-design/pro-layout": "^7.1.6",
"@ant-design/pro-table": "^3.0.17",
"@ice/runtime": "^1.0.0",
"@monaco-editor/react": "^4.4.6",
"antd": "^4.24.0",
"axios": "1.2.1",
"dayjs": "^1.11.13",
"i18next": "^22.4.9",
"i18next-browser-languagedetector": "^7.0.1",
"i18next-http-backend": "^2.1.1",
"js-yaml": "^4.1.0",
"katex": "^0.16.25",
"lucide-react": "^0.539.0",
"md-editor-rt": "^6.1.0",
"mermaid": "^11.12.0",
"monaco-editor": "0.34.0",
"monaco-yaml": "^4.0.4",
"react": "^18.2.0",
"react-chatgpt-modal": "^0.1.8",
"react-dom": "^18.2.0",
"react-i18next": "^12.1.4",
"react-syntax-highlighter": "^15.6.1",
"recharts": "^3.1.2",
"remixicon": "^4.7.0"
},
"devDependencies": {
"@ice/app": "^3.0.0",
"@ice/plugin-antd": "^1.0.2",
"@ice/plugin-auth": "^1.0.0",
"@ice/plugin-request": "^1.0.0",
"@ice/plugin-store": "^1.0.0",
"@iceworks/spec": "^1.0.0",
"@types/js-yaml": "^4.0.9",
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
"@typescript-eslint/eslint-plugin": "^5.60.1",
"ahooks": "^3.7.2",
"cross-env": "^7.0.3",
"eslint": "7.30.0",
"husky": "^8.0.3",
"lint-staged": "^13.1.2",
"lodash": "^4.17.21",
"qs": "^6.11.0",
"stylelint": "13.2.1",
"typescript": "^4.4.4"
},
"scripts": {
"start": "cross-env NODE_ENV=development NODE_OPTIONS=--max-old-space-size=8192 && ice start",
"build": "cross-env NODE_ENV=production && node ./compatible-wujie.js && ice build",
"build-dev": "cross-env NODE_ENV=development && ice build",
"lint": "npm run eslint && npm run stylelint",
"lint:lint-staged": "lint-staged",
"eslint": "eslint --cache --ext .js,.ts,.jsx,.tsx ./",
"eslint:fix": "npm run eslint -- --fix",
"stylelint": "stylelint \"**/*.{css,scss,less}\"",
"postinstall": "node ./compatible-wujie.js"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"private": true,
"originTemplate": "@ice/antd-pro-scaffold",
"packageManager": "[email protected]+sha512.5383cc12567a95f1d668fbe762dfe0075c595b4bfff433be478dbbe24e05251a8e8c3eb992a986667c1d53b6c3a9c85b8398c35a960587fbd9fa3a0915406728"
}
Additional context
No response
提供下复现代码