webpack-contrib/cache-loader

memory leak when using different splitchunks optimizations options

sibelius opened this issue · 3 comments

  • Operating System: MacOsX
  • Node Version: 12.4.0
  • NPM Version: 6.14.2
  • webpack Version: 4.42.0
  • cache-loader Version: 4.1.0

Expected Behavior

it should not cause memory leak

Actual Behavior

it causes memory leak

Code

cache-loader babel-loader usage

{
        test: /\.(js|jsx|ts|tsx)?$/,
        exclude: [/node_modules/],
        // use: 'happypack/loader?id=js',
        use: ['cache-loader', 'babel-loader?cacheDirectory'],
        include: [srcPath, path.join(cwd, '../')],
      },

one optimization option that causes memory leak

optimization: {
     removeAvailableModules: false,
    removeEmptyChunks: false,
    splitChunks: false,
}

another optimization option that causes memory leak (create 1 chunk per monorepo package)

const outModulesPrefix = 'entria';
const ourModulePattern = new RegExp(`^@${outModulesPrefix}\/([a-z]+[-[a-z]+]*)$`);

splitChunks: {
      cacheGroups: {
        default: false,
        vendors: false,
        vendor: {
          name: 'vendor',
          chunks: 'all',
          test: /node_modules/,
          priority: 20,
        },
        common: {
          name: module => `feedback-${module.rawRequest.match(ourModulePattern)[1]}`,
          minChunks: 1,
          chunks: 'all',
          maxAsyncRequests: Infinity,
          maxInitialRequests: Infinity,
          minSize: 0,
          maxSize: 1,
          test: module => ourModulePattern.test(module.rawRequest),
          priority: 10,
          enforce: true,
        },
      },
    },

How Do We Reproduce?

try to use this babel-loader config with this optimization settings in a big codebase

Can't reproduce, problem still exists?

I will reopen when I got a better repro

@sibelius Feel free to ping me