new CircularDependencyPlugin({
// exclude detection of files based on a RegExp
exclude: /a\.js|node_modules/,
// `onStart` is called before the cycle detection starts
onStart() {
console.log('start detecting webpack modules cycles');
},
// `onDetected` is called for each module that is cyclical
onDetected({ paths, compilation }) {
// `paths` will be an Array of the relative module paths that make up the cycle
// `module` will be the module record generated by webpack that caused the cycle
compilation.errors.push(new Error(paths.join(' -> ')));
},
// `onEnd` is called before the cycle detection ends
onEnd() {
console.log('end detecting webpack modules cycles');
},
}),
Reference