Skip to content

ModuleConcatenationPlugin memory usage increases dramatically with chunk module count #5992

@filipesilva

Description

@filipesilva

Do you want to request a feature or report a bug?
I want to report a bug.

What is the current behavior?
ModuleConcatenationPlugin memory usage increases dramatically with chunk module count.

If the current behavior is a bug, please provide the steps to reproduce.

git clone https://github.com/filipesilva/webpack-module-concatenation-memory
cd webpack-module-concatenation-memory
npm install
npm run ngc
npm run webpack

This will result in peak memory usage of about 17GB.

Commenting out new webpack.optimize.ModuleConcatenationPlugin(), in webpack.config.js results in
peak 1.8GB memory usage.

npm run ngc is necessary because it also generates some files in node_modules/ that are
imported by the app.

The app has a 12 lazy loaded chunks by default.
These can be imported into the main chunk by editing src/app/app-routing.module.js (after npm run ngc), commenting out the System.import: and uncommenting import declarations as shown in the repo readme. This will increase memory usage further.

Note: this repo uses a minimal webpack.config.json with no loaders:

const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const ProgressPlugin = require('webpack/lib/ProgressPlugin');

module.exports = {
  entry: './src/main.js',
  output: {
    path: path.resolve(__dirname, './dist'),
    filename: 'bundle.js'
  },
  plugins: [
    new ProgressPlugin(),
    // Ignore `Critical dependency: the request of a dependency is an expression` warnings.
    new webpack.ContextReplacementPlugin(
      /angular(\\|\/)core(\\|\/)esm5/,
      __dirname
    ),
    new HtmlWebpackPlugin({
      template: './src/index.html'
    }),
    new webpack.optimize.ModuleConcatenationPlugin(),
  ]
};

What is the expected behavior?
Memory usage should be more in line with base webpack usage (around 1.8GB instead of 17GB).

Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.
No browser was used, node v8.9.1, webpack 3.8.1, Windows 10

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions