Closed as not planned
Description
I have searched the issues of this repository and believe that this is not a duplicate.
Version
4.x
Environment
mac 15.5, node18.18.0, ci基础镜像为自封装debian10+node18.18.0
Reproduction link
内部项目,无法提供复现连接
Steps to reproduce
我的package.json文件是这样的
{
"name": "frontend",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "NODE_ENV=development vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"@antv/g6": "^5.0.45",
"@antv/g6-extension-react": "^0.2.1",
"@antv/x6": "2.1.2",
"@antv/x6-vue-shape": "^2.1.2",
"@babel/plugin-transform-private-methods": "^7.25.9",
"@element-plus/icons-vue": "^2.1.0",
"ant-design-vue": "4.x",
"axios": "^1.8.4",
"codemirror": "^6.0.1",
"cookiejs": "^2.1.3",
"core-js": "^3.8.3",
"echarts": "^5.4.3",
"element-plus": "^2.3.9",
"element-ui": "^2.15.14",
"eslint-config-prettier": "^10.1.1",
"js-cookie": "^3.0.5",
"lodash-es": "^4.17.21",
"normalize-wheel": "^1.0.1",
"pinia": "^3.0.1",
"react": "^19.1.0",
"react-dom": "^19.1.0",
"vue": "^3.2.13",
"vue-codemirror": "^6.1.1",
"vue-eslint-parser": "^10.1.1",
"vue-router": "^4.2.4",
"vuera": "^0.2.7",
"vuex": "^4.1.0"
},
"devDependencies": {
"@babel/core": "^7.12.16",
"@babel/eslint-parser": "^7.12.16",
"@eslint/js": "^8.4.1",
"@typescript-eslint/eslint-plugin": "^8.29.0",
"@typescript-eslint/parser": "^8.29.0",
"@vue/cli-plugin-babel": "~5.0.0",
"@vue/cli-plugin-eslint": "~5.0.0",
"@vue/cli-service": "^5.0.8",
"eslint": "^8.4.1",
"eslint-plugin-vue": "^10.0.0",
"globals": "^16.0.0",
"handlebars": "^4.7.8",
"prettier": "^3.5.3"
},
"eslintConfig": {
"root": true,
"env": {
"node": true,
"vue/setup-compiler-macros": true
},
"extends": [
"plugin:vue/vue3-essential",
"eslint:recommended"
],
"parserOptions": {
"parser": "@babel/eslint-parser"
},
"rules": {
"vue/multi-word-component-names": "off"
}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead",
"not ie 11"
]
}
vue.config.mjs是这样的
import { defineConfig } from '@vue/cli-service';
export const proxyConfig = {
};
const defatltProxy = {
};
export default defineConfig({
transpileDependencies: [
'ml-matrix',
'ant-design-vue',
'@babel/runtime',
/node_modules[\\/]@babel[\\/]runtime/, // 显式包含babel运行时路径
],
chainWebpack: config => {
config.module
.rule('js')
.use('babel-loader')
.tap(options => {
options.plugins = options.plugins || [];
options.plugins.push(
'@babel/plugin-transform-private-methods',
'@babel/plugin-transform-modules-commonjs' // 添加模块转换插件
);
return options;
});
config.module
.rule('mjs')
.test(/\.mjs$/)
.include.add(/node_modules/)
.end()
.type('javascript/auto');
},
devServer: {
// eslint-disable-next-line no-undef
proxy:
// eslint-disable-next-line no-undef
{ ...proxyConfig[process.env.NODE_ENV], ...defatltProxy } || defatltProxy,
},
configureWebpack: {
module: {
rules: [
{
test: /\.mjs$/,
include: /node_modules/,
type: 'javascript/auto',
},
],
},
resolve: {
extensions: ['.mjs', '.js', '.vue', '.json'],
},
},
});
编译命令为RUN yarn install --registry https://registry.npmmirror.com --production=false && \ NODE_ENV=${NODE_ENV} yarn build
,在gitlab runner中使用上述镜像进行打包,打包文件直接放入nginx中
What is expected?
修复问题
What is actually happening?
用户访问前段时console出现报错:
objectSpread2.js:4
Uncaught ReferenceError: exports is not defined
at eval (objectSpread2.js:4:23)
at ./node_modules/@babel/runtime/helpers/esm/objectSpread2.js (app.js:17520:1)
at __webpack_require__ (app.js:45838:42)
at eval (index.js:8:45)
at ./node_modules/ant-design-vue/es/affix/index.js (app.js:18936:1)
at __webpack_require__ (app.js:45838:42)
at eval (components.js:836:37)
at ./node_modules/ant-design-vue/es/components.js (app.js:19684:1)
at __webpack_require__ (app.js:45838:42)
at eval (index.js:35:42)