chunk is not generated with import()

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

Report a bug

What is the current behavior?

Using import() does not generate a chunk

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

This is my webpack 4 setup

  mode: 'production',
  devtool: 'cheap-source-map',
  optimization: {
    splitChunks: {
      name: 'vendor',
      filename: 'vendorbundle.js',
      chunks: 'all',
      cacheGroups: {
        vendor(m) {
          // do not include ui-lib stuff in the vendor bundle
          if (m.context && m.context.indexOf('ui-lib/src') > -1) {
            return false;
          // include only src files, avoids to re-include react, react-dom etc
          return /node_modules/.test(m.context);
    minimize: true,
    minimizer: [
      new UglifyJSPlugin({
        uglifyOptions: {
          output: {
            comments: false,

Somewhere in my code I have the following line

 const messages = await import(/* webpackChunkName: "translations" */ '../i18n/de.json');

In my previous Webpack 3 setup this used to generated a chunk (translations).
Should I do something special for webpack 4?

What is the expected behavior?

Generate a chunk with the specified name

Please mention other relevant information such as the browser version, Node.js version, webpack version, and Operating System.

Webpack 4

Author: Fantashit

1 thought on “chunk is not generated with import()

Comments are closed.