0

I am updating to webpack@4.23, I ran in to this compilation error of TypeError: chunk.isInitial() is not a function in one of my custom webpack plugins, may be we need to update some syntax but basically what I want to know is how to debug webpack plugins because i might run to some other compilation error most definitely :D

Here is snippet of plugin

const asyncLib = require('async');
// Plugin starts here
class CustomPluginName {
  constructor(options) {
    this.options = options;
  }

  apply(compiler) {
    compiler.plugin('emit', (compilation, callback) => {
      ////// doing something
      asyncLib.forEach(compilation.chunks, (chunk, chnkCallback) => {
        if (!chunk.isInitial()) { // error occuring here
          chnkCallback();
          return;
        }
        // rest of code
      });
    });
  }
}
Shravya
  • 116
  • 1
  • 4
  • we can always use try catch block and get errors printed using `compilation.errors.push` but is this the only way? – Shravya Oct 30 '18 at 20:42
  • I found answer to the compilation error after digging in to `lib/Chunk.js` file in webpack repo, apparently we need to use `isOnlyInitial` instead – Shravya Oct 30 '18 at 20:46

0 Answers0