Skip to content
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

Errors after changing the source code with webpack 5.0.0-beta.0 #1292

Closed
anatoliikarpiuk opened this issue Oct 18, 2019 · 3 comments
Closed

Comments

@anatoliikarpiuk
Copy link

anatoliikarpiuk commented Oct 18, 2019

Crashes after changing the source code. Cannot read property get of undefined
66913430-4989db80-f01d-11e9-8344-a187fa6cb89e

Node.js v12.12.0
win32 10.0.18362
npm 6.10.3
webpack 5.0.0-beta.0
html-webpack-plugin 4.0.0-beta.8
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");

module.exports = {
  entry: "./src/index.js",
  output: {
    path: path.join(__dirname, "/dist"),
    filename: "bundle.js"
  },
  module: {
    rules: [{
      test: /\.jsx?$/,
      exclude: /node_modules/,
      use: {
        loader: "babel-loader"
      },
    }]
  },
  plugins: [
    new HtmlWebpackPlugin({
      template: "./src/index.html"
    })
  ],
  devServer: {
    progress: true
  },
};
@kenotron
Copy link

kenotron commented Dec 21, 2019

#1129 has a workaround here by @jwarkentin:

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 patch-package NPM module and set the postinstall script as instructed. Then, create a directory named "patches" and a file named something like "html-webpack-plugin+4.0.0-beta.8.patch" with the following contents:

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 npx patch-package and it will at least stop the build from crashing and seems to allow proper hot reloading when I edit things so far.

@kenotron
Copy link

kenotron commented Dec 21, 2019

Another workaround patch from #1129 by @PutziSan:

I had patched my packages already, but it's more quick-and-dirty:
This change-comparison reflects the changes I've made locally, so everything is working fine with Webpack 5 again. I didn't really understand the previous caching algorithm and adapted it in the easiest way for me, that's certainly not right for all cases and needs to be looked at again. Also, it doesn't fit perfectly yet, because the first time you render it, it also returns that the cache is invalid.
Unfortunately, I don't have time to understand or improve it any further. But if someone wants a (not perfect) solution with Webpack 5 for now, he can use my changes as a patch.
[edit: added some code, that I forgot to commit]

@jantimon
Copy link
Owner

Duplicate of #1129

@jantimon jantimon marked this as a duplicate of #1129 Mar 24, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Apr 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants