Circular Dependency Plugin
Detect modules with circular dependencies when bundling with webpack.
Circular dependencies are often a necessity in complex software, the presence of a circular dependency doesn't always imply a bug, but in the case where you believe a bug exists, this module may help find it.
Basic Usage
let CircularDependencyPlugin = require('circular-dependency-plugin')
module.exports = {
entry: "./src/index",
plugins: [
new CircularDependencyPlugin({
exclude: /a\.js|node_modules/,
failOnError: true,
cwd: process.cwd(),
})
]
}
Advanced Usage
let CircularDependencyPlugin = require('circular-dependency-plugin')
module.exports = {
entry: "./src/index",
plugins: [
new CircularDependencyPlugin({
onDetected({ module: webpackModuleRecord, paths, compilation }) {
compilation.errors.push(new Error(paths.join(' -> ')))
}
})
]
}