Issue 1:
Do you want to request a feature or report a bug?

Regression bug - as described here: #433 (comment)

What is the current behavior?

When adding HMR support to a project that has async chunks (was imported using syntax-dynamic-import) webpack does not keep the same name of the changed chunk. Therefore calls to x-undefined.js are being made.

For some reason everything seems to be working only when also adding NamedModulesPlugin which is according to the docs optional. It seems it's actually mandatory.

Important Note: I did NOT test it using the CLI option. Everything has been tested using the WebpackDevServer API.

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

Just add an HMR support to a project by adding:

filename: '[name]-[chunkhash].js',
chunkFilename: '[name]-[chunkhash].js',

config.entry.application.unshift('react-hot-loader/patch');
config.entry.application.unshift('webpack/hot/dev-server');
config.entry.application.unshift(`webpack-dev-server/client?${config.output.publicPath}`);

// HMR (Hot Module Replacement) plugins
config.plugins.push(new webpack.HotModuleReplacementPlugin());

Add hot: true to the WebpackDevServer configurations.

The above fails.

Now, try also adding:

config.plugins.push(new webpack.NamedModulesPlugin());

Now everything is working again.

What is the expected behavior?

The expected behavior would be that HMR will work without the need to add NamedModulesPlugin.

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

Webpack version: 2.3.3

Node.js version: 6.10.1

OS: macOS

Issue 2:
Bug report

What is the current behavior?

Certain chunk requests use undefined instead of the hash. Example of the resulting error in chrome:

Uncaught (in promise) Error: Loading chunk 63 failed.
(error: https://{hostname}/app/63.undefined.feasContentHashV1.chunk.js)
at HTMLScriptElement.i ({appName}.d5b0c78176fe6ff82a0f.bundle.js:1)

The request for chunk 63 looks like this:

https://{hostname}/app/63.undefined.chunk.js

Stepping through the webpack build, it appears as though the function getScriptSrcPath in JsonpMainTemplatePlugin.js (link) creates a mapping of chunk Id to hash. Looking at the result, the entry for the chunk Id 63 is missing entirely, resulting in the undefined hash in the request.

However, looking through the resulting build, there appears to be a valid chunk 63 with a valid hash in the file name. I'm guessing that somewhere along the line, the reference is lost to this chunk?

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

This is somewhat difficult to reproduce, I think its related to the total number of async chunks made by splitChunksPlugin, but I'm not 100% sure. I'm unable to reproduce a build that can do this. please let me now what other information would be useful.

I think this may be related to #7061 since the behavior sounds similar. However, according to the maintainers that bug was fixed in 4.6.0. Since we are at a later version (4.29.0) I would expect that fix to be included.

What is the expected behavior?

I would expect JsonpMainTemplatePlugin to produce code that has a valid mapping of all chunk Id's to their respective hashes, and for all requests for chunks to have defined hashes.

Other relevant information:

webpack version: 4.29.0 (I also tried linking to a develop build of webpack)

Node.js version: v8.11.1

Operating System: MacOS

Additional tools: