webpack / webpack-dev-server

Serves a webpack app. Updates the browser on changes. Documentation https://webpack.js.org/configuration/dev-server/.
MIT License
7.76k stars 1.43k forks source link

The memory usage during project runtime after upgrade is very high #5158

Closed ChenBin12138 closed 3 months ago

ChenBin12138 commented 3 months ago

Bug report

upgradation :

vue@2.6.10 => vue@2.7.16 webpack@4.47.0 => webpack@5.91.0 webpack-dev-server@3.11.3 => webpack-dev-server@4.15.2

The memory usage during project runtime after upgrade is very high, Modifying code compilation also lags behind.

Actual Behavior

Expected Behavior

How Do We Reproduce?

Please paste the results of npx webpack-cli info here, and mention other relevant information

` const { defineConfig } = require('@vue/cli-service') const path = require('path'); const fs = require('fs'); const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");

function resolve(dir) { return path.join(__dirname, dir) }

const webpackConfig = { // 打包环境 production: { optimization: { runtimeChunk: "single", splitChunks: { chunks: 'all', cacheGroups: { libs: { name: 'chunk-libs', test: /[\/]node_modules[\/]/, priority: 10, chunks: 'initial' // only package third parties that are initially dependent }, elementUI: { name: 'chunk-elementUI', // split elementUI into a single package priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app test: /[\/]nodemodules[\/]?element-ui(.)/ // in order to adapt to cnpm }, vxEasyui: { name: 'chunk-vx-easyui', // split vx-easyui into a single package priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app test: /[\/]nodemodules[\/]?vx-easyui(.)/ // in order to adapt to cnpm }, commons: { name: 'chunk-commons', test: resolve('src/components'), // can customize your rules minChunks: 3, // minimum common number priority: 5, reuseExistingChunk: true } } } }, }, // 开发环境 development: { watchOptions: { ignored: [ // 忽略监听的目录或文件 '/node_modules/', '/dist/', ], }, devtool: "eval-cheap-module-source-map", output: { pathinfo: false, }, optimization: { runtimeChunk: true, removeAvailableModules: false, removeEmptyChunks: false, splitChunks: false, }, } }[process.env.NODE_ENV]

module.exports = defineConfig({ transpileDependencies: true, runtimeCompiler: true, publicPath: '/', outputDir: 'dist', productionSourceMap: false, configureWebpack: { plugins: [ new NodePolyfillPlugin() ], cache: { type: 'filesystem', buildDependencies: { config: [filename], package: [path.resolve(dirname, 'package-lock.json')] }, }, externals: { 'echarts': 'echarts', './cptable': 'var cptable', fs }, module: { rules: [ { test: /.js$/, use: { loader: 'babel-loader', options: { cacheDirectory: true } }, exclude: /node_modules/, include: [resolve('src')] }, ] }, resolve: { alias: { '@': resolve('src') }, fallback: { dgram: 'empty', fs: 'empty', net: 'empty', tls: 'empty', child_process: 'empty', crypto: false }, }, ...webpackConfig }, devServer: { port: 81, hot: true, client: { overlay: false, }, proxy: { '/_gataway': { target: "", changeOrigin: true, pathRewrite: { '^/_gataway': '/' }, router: () => { return fs.readFileSync(process.cwd() + '/proxyUrl.env', 'utf8') } } }, } })

`

ChenBin12138 commented 3 months ago

Snipaste_2024-04-20_16-17-37

alexander-akait commented 3 months ago

Please use https://github.com/webpack/webpack/discussions for such questions, because we don't know the real reason, also please provide minimum reproducible test repo or profiling, otherwise we can't help sorry, also please run npm ls webpack and show me this in https://github.com/webpack/webpack/discussions, thank you