Skip to content

Browser fails to load async chunk. References file with "chunkhash" undefined. #7061

@b12k

Description

@b12k

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

What is the current behavior?
Browser fails to import chunk because filechunkhash is undefined in vendor.js.
But chunks generated correctly.
Screenshots:

It works in WP3. It also works if [chunkhash] is removed or [hash] is used in output.filename

If the current behavior is a bug, please provide the steps to reproduce.
I have a tree of async chunks which are imported the following way:
import(/* webpackChunkName: "home" */ './home.js')
when home is mounded it imports
import(/* webpackChunkName: "socketio" */ 'socket.io-client')
WP4 config:

// config written in ES6 class syntax
...
output.filename = 'js/[name].[chunkhash].js';
optimization = {
    namedChunks: true,
    runtimeChunk: {
      name: 'vendor',
    },
    splitChunks: {
      cacheGroups: {
        vendors: {
          test: /[\\/]node_modules[\\/]/,
          name: 'vendor',
          chunks: 'all',
        },
      },
    },
  };
...

What is the expected behavior?
Correct file name reference in vendor.js is expected.

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

  • Win10x64
  • Node 9.11.1
  • NPM 5.6.0
  • Webpack 4.5.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions