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

Plugin causes webpack to throw on incremental compile (webpack 5 - watch mode) #1316

Closed
fuzing opened this issue Dec 5, 2019 · 3 comments
Closed

Comments

@fuzing
Copy link

fuzing commented Dec 5, 2019

Expected behaviour

Should compile cleanly

Current behaviour

Plugin causes webpack (5) to throw/crash on incremental compile while in watch mode. Initial compile seems to run fine, but update to source code that results in attempt to incrementally recompile causes the following error:

TypeError: Cannot read property 'get' of undefined
    at /home/someone/project/node_modules/html-webpack-plugin/lib/compiler.js:341:38
    at Array.some (<anonymous>)
    at isChildCompilerCacheOutdated (/home/someone/project/node_modules/html-webpack-plugin/lib/compiler.js:340:59)
    at Object.hasOutDatedTemplateCache (/home/someone/project/node_modules/html-webpack-plugin/lib/compiler.js:321:16)
    at /home/someone/project/node_modules/html-webpack-plugin/index.js:135:25
    at Hook.eval [as call] (eval at create (/home/someone/project/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:5:1)
    at Compiler.newCompilation (/home/someone/project/node_modules/webpack/lib/Compiler.js:857:30)
    at /home/someone/project/node_modules/webpack/lib/Compiler.js:898:29
    at Hook.eval [as callAsync] (eval at create (/home/someone/project/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:4:1)
    at Compiler.compile (/home/someone/project/node_modules/webpack/lib/Compiler.js:893:28)
    at /home/someone/project/node_modules/webpack/lib/Watching.js:111:19
    at Hook.eval [as callAsync] (eval at create (/home/someone/project/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:4:1)
    at /home/someone/project/node_modules/webpack/lib/Watching.js:65:33
    at /home/someone/project/node_modules/webpack/lib/HookWebpackError.js:69:3
    at Hook.eval [as callAsync] (eval at create (/home/someone/project/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:4:1)
    at Cache.endIdle (/home/someone/project/node_modules/webpack/lib/Cache.js:140:22)
    at Watching._go (/home/someone/project/node_modules/webpack/lib/Watching.js:63:23)
    at Watching._invalidate (/home/someone/project/node_modules/webpack/lib/Watching.js:238:9)
    at /home/someone/project/node_modules/webpack/lib/Watching.js:202:11
    at Watchpack.<anonymous> (/home/someone/project/node_modules/webpack/lib/node/NodeWatchFileSystem.js:85:4)
    at Object.onceWrapper (events.js:300:26)
    at Watchpack.emit (events.js:210:5)
    at Watchpack._onTimeout (/home/someone/projectg/node_modules/webpack/node_modules/watchpack/lib/watchpack.js:297:8)
    at listOnTimeout (internal/timers.js:531:17)
    at processTimers (internal/timers.js:475:7)

Environment

Tell us which operating system you are using, as well as which versions of Node.js, npm, webpack, and html-webpack-plugin. Run the following to get it quickly:
node v13.2.0
ubuntu 18.04
npm 6.13.1
webpack 5.0.0-beta.7
html-webpack-plugin 4.0.0-beta.11

Config

const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const appRoot = require('app-root-path');

// place where our views will go
const VIEWS_DEST_DIR = appRoot + '/dist/backend/views';

// place where our Handlebars view root is
const HANDLEBARS_VIEWS = appRoot + '/src/backend/views';

module.exports = {

  mode: 'development',

  entry: {app: './src/frontend/entrypoint/app.js'},

  output: {
    path: appRoot + '/dist/frontend-serve',
    publicPath: '/',
    filename: '[name].js',
  },


  resolve: {
    modules: [`${appRoot}/src`, 'node_modules'],

    extensions: ['.mjs', '.js', '.jsx'],

  },

  module: {
    rules: [
      // .mjs needed for https://github.com/graphql/graphql-js/issues/1272
      {
        test: /\.mjs$/,
        include: /node_modules/,
        type: 'javascript/auto'
      },
      // All files with a '.js' or '.jsx' extension will be handled by 'babel-loader'
      {
        test: /\.jsx?$/,
        exclude: [/node_modules/],
        use: {
          loader: 'babel-loader',
          options: {
            presets: [
              ['@babel/preset-env', {
                targets: {"browsers": ["last 2 versions"]},
                modules: false,         // don't let the "env" preset mess with module imports (tree-shaking)
              },
              ],
              '@babel/preset-react', '@babel/preset-flow'
            ],

  
            plugins: [
              "babel-plugin-styled-components",
              [
                "@babel/plugin-transform-runtime",
                {
                  "helpers": true,
                  "regenerator": true,
                  "useESModules": false,
                }
              ],
              ["@babel/plugin-proposal-class-properties", {"loose": false}],
            ],
          }
        }
      },

      {
        test: /\.html$/,
        use: {
          loader: 'html-loader'
        }
      },

      {
        test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)$/,
        use: {
          loader: 'file-loader?name=assets/[name].[ext]'
        }
      },

      {
        test: /\.css$/,
          use: [
            MiniCssExtractPlugin.loader,
            "css-loader",
          ],
      },

      {
        test: /\.(sass|scss)$/,
        use: [
          MiniCssExtractPlugin.loader,
          'css-loader', 'sass-loader',
        ],
      },
    ]
  },

  plugins: [
    //
    // our app's page
    //
    new HtmlWebpackPlugin({
      template: 'src/backend/views/pages/app.hbs',
      filename: `${VIEWS_DEST_DIR}/app.hbs`,
    }),

    // in production we cache-bust
    new MiniCssExtractPlugin({ filename: '[name].css' }),

  ],

};
@vankop
Copy link

vankop commented Dec 6, 2019

Same issue webpack-contrib/stylelint-webpack-plugin#187

New API for watching files: webpack/webpack#9679

@kenotron
Copy link

Seems very much like the same thing as #1292

@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

4 participants