webpack-contrib / cache-loader

[DEPRECATED] Caches the result of following loaders on disk
MIT License
638 stars 51 forks source link

memory leak when using different splitchunks optimizations options #100

Closed sibelius closed 4 years ago

sibelius commented 4 years ago

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

alexander-akait commented 4 years ago

Can't reproduce, problem still exists?

sibelius commented 4 years ago

I will reopen when I got a better repro

alexander-akait commented 4 years ago

@sibelius Feel free to ping me