html-webpack-plugin icon indicating copy to clipboard operation
html-webpack-plugin copied to clipboard

HMR multiStep mode is broken in webpack 2

Open bebraw opened this issue 9 years ago • 10 comments

Currently enabling multiStep mode in HotModuleReplacementPlugin breaks html-webpack-plugin. The page simply won't refresh correctly breaking the system. The fix for this requires an underlying change as discussed below.

To quote @sokra

the hot update chunks are also "chunk assets" and it looks like that the html-plugin generates a script tag for them. html-plugin should use the new stats.entrypoints data to generate the script tags. This contains all needed files for an entrypoint in correct order.

Here's a quick search against webpack source, but I can't find a definitive plugin example on a quick look.

To keep this backwards compatible we would need some way to check webpack version. A simple way to do that is to go through require('webpack/package.json').version although it would be better if plugins received the version information from webpack (does this happen already?).

Related to #401.

bebraw avatar Dec 28 '16 10:12 bebraw

Could we expose stats.entrypoints also in webpack 1.x? This would allow us to have a clean upgrade path for plugin relying on it stats.entrypoints in webpack 2.x

jantimon avatar Dec 29 '16 09:12 jantimon

stats.entrypoints is webpack 2 only. We added it for your use case. It lists all files required for an entrypoint in the correct order. So you don't have to do the ordering yourself. It's exposed by webpack. You may separate files by filetype (i. e. put styles before scripts).

sokra avatar Dec 29 '16 10:12 sokra

@sokra Is there any reason not to add stats.entrypoints for webpack 1 ?

jantimon avatar Jan 08 '17 18:01 jantimon

Is this still being worked on ?

moimael avatar May 17 '17 19:05 moimael

The problem is:

TypeError: Cannot read property 'source' of undefined.

It occurs here.

Specifically:

  1. the asset is deleted: delete compilation.assets[outputName]
  2. and we try to call a method on a now undefined value: childCompilation.assets[outputName].source()

The problem was introduced quite a while ago: https://github.com/jantimon/html-webpack-plugin/commit/be966e70e093cab483a67017bec9e97f65c09c3d#diff-168726dbe96b3ce427e7fedce31bb0bcR195.

niieani avatar Jun 16 '17 13:06 niieani

Actually, scratch that. It's the childCompilation that doesn't have the asset, so while the error is the same, it's not caused by the delete that I've mentioned above. Still, it shouldn't be too hard to fix this, should it?

niieani avatar Jun 16 '17 13:06 niieani

This issue had no activity for at least half a year. It's subject to automatic issue closing if there is no activity in the next 15 days.

stale[bot] avatar May 30 '18 12:05 stale[bot]

Here, when changing some js file it realoads the old version

albertotorresfoltyn avatar Jul 03 '18 15:07 albertotorresfoltyn

is this fixed on master? or latest version?

sibelius avatar Jul 04 '18 12:07 sibelius

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock[bot] avatar Aug 03 '18 12:08 lock[bot]