-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: Cannot read property 'get' of undefined when used with webpack 5 #1129
Comments
Thanks that was already mentioned here. I don't understand completely why and how the filestamps api changed. Could anyone please provide some insides or pull request to make html-webpack-plugin compatible with webpack 5? Can anyone please give me some hints how and why the timestamps api changed? I am using it here to find out wether the html template has to be recompiled. For webpack 4 it just loops over all compilation file dependency timestamps. |
here are another error we are getting on webpack 5
you can run it here entria/entria-fullstack#46 it is using 3.2.0 |
|
Thanks for the feedback 👍 |
Although It works on the first build, as you save a file and it is on watch mode, we get the same error, more details here: entria/entria-fullstack#46 (comment) running |
Oh sorry you are right - its a breaking change of webpack 5. webpack/webpack#8537 (comment)
Maybe @sokra can help us here. |
friendly ping @sokra |
There is a new API in
|
This is the first time I see the Will Is a snapshot automatically created for every compilation or for every compiler? |
@sokra do you have any thoughts on @jantimon's question #1129 (comment)? edit: I see some of the same question also asked in webpack/webpack#8982 |
@sokra added webpack/webpack#8982 to the "probably" list: lets see if this moves to yes in the next weeks. |
Hi, no matter if |
@PutziSan that's correct do you want to start and send a pull request? |
I had patched my packages already, but it's more quick-and-dirty: |
@PutziSan wow cool thanks a lot I'll take a look at it! 💯 |
Does anyone make it work with webpack 5?) |
The above patch appears to work for me still for Webpack 5.0,0-beta0 |
If anyone is looking for a quick solution, I can't vouch for the correctness of this but it seems to work for me. Install the diff --git a/node_modules/html-webpack-plugin/lib/compiler.js b/node_modules/html-webpack-plugin/lib/compiler.js
index 8960360..2f431d7 100644
--- a/node_modules/html-webpack-plugin/lib/compiler.js
+++ b/node_modules/html-webpack-plugin/lib/compiler.js
@@ -336,9 +336,9 @@ function isChildCompilerCacheOutdated (mainCompilation, childCompiler) {
return false;
}
// Check if any dependent file was changed after the last compilation
- const fileTimestamps = mainCompilation.fileTimestamps;
+ const fileTimestamps = mainCompilation.fileSystemInfo._fileTimestamps;
const isCacheOutOfDate = childCompiler.fileDependencies.some((fileDependency) => {
- const timestamp = fileTimestamps.get(fileDependency);
+ const timestamp = fileTimestamps.get(fileDependency).timestamp;
// If the timestamp is not known the file is new
// If the timestamp is larger then the file has changed
// Otherwise the file is still the same Run |
Hey team, so I did the patch locally and it worked for me but I'm not checking in my node_module into my repo so I have to re-apply every time I deploy to a new env. There has to be a better way than this while we're waiting for a solution to get pushed. I'm newish to node/npm. I suppose I could maintain my own repo of http_webpack_plugin and install that but is that the best way to go? |
u can use
|
For anyone interested in an even quicker and dirtier foolproof patch, here's what I'm doing now:
diff --git a/node_modules/html-webpack-plugin/lib/compiler.js b/node_modules/html-webpack-plugin/lib/compiler.js
index a13abf3..011294d 100644
--- a/node_modules/html-webpack-plugin/lib/compiler.js
+++ b/node_modules/html-webpack-plugin/lib/compiler.js
@@ -335,6 +335,7 @@ function isChildCompilerCacheOutdated (mainCompilation, childCompiler) {
if (!childCompiler.compilationStartedTimestamp) {
return false;
}
+ return true;
// Check if any dependent file was changed after the last compilation
const fileTimestamps = mainCompilation.fileTimestamps;
const isCacheOutOfDate = childCompiler.fileDependencies.some((fileDependency) => {
@elchicofrommo I added the step-by-step here for your benefit. Hope it helps! |
Has anyone already tried to use the new |
even in
` is there any timeline to fix this bug. i am using |
I think it might be possible to do some conditionals with webpack.version to make PutziSan‘s changes backward compatible. |
I forked this repo and cherry picked PutziSan’s changes, working on fixing tests so they pass on webpack5. If I get it fixed I will release a scoped package until changes can be incorporated in master. |
@fivethreeo if we have a working solution I would love to release it as I am happy to publish it as alpha if anyone has time to develop a solution based on the new |
I got all tests but two to work in webpack5 with snapshot solution. But testing is a bit cumbersome since the webpack recompilation simulator does not currently support webpack5. Should the next release be backward compatible? |
A alpha release sounds great 😀 |
I'm new to webpack and open source contributing. I'd love to help out. Where do I find the api specs? Also I've been looking around this repo for the tests but i'm not seeing them. Its probably something obvious I'm just overlooking. Any pointers? |
They are in spec/ |
@jantimon are you still working on that alpha? It might be a nice intermediary until a final solution can be completed. |
@elchicofrommo https://github.com/fivethreeo/html-webpack-plugin/tree/webpack5-dev just a testing dep needs to be updated first |
Wow @fivethreeo that looks amazing 👍👍 |
But regarding backward compatibility. Just keep both solutions until we deprecate webpack4? |
What about having two |
Yes, that might be the best solution.
…On Thu, 2 Apr 2020 at 18:18, Jan Nicklas ***@***.***> wrote:
What about having two compiler.js files? One for webpack 4 and one for
webpack 5?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1129 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAADGXAJOUBPKQW4OIEQJ3RKS3DRANCNFSM4GMAANFA>
.
--
Øyvind Saltvik
|
Added some feedback to your pr here: #1390 |
Typescript did not like two webpack versions. |
I think we need to do paralell releases with typescript. Unless there is a way to do dynamic typedef imports. |
Fixed in html-webpack-plugin 4.1.0 |
Expected behaviour
TypeError should not be thrown
Current behaviour
TypeError is thrown
Environment
I have webpack@5.0.0-alpha.1
Sorry I don't have a minimal webpack.config.js
The text was updated successfully, but these errors were encountered: