website/docs/en/plugins/rspack/circular-check-rspack-plugin.mdx
import { ApiMeta } from '@components/ApiMeta.tsx';
<ApiMeta specific={['Rspack']} />
Reports circular import dependencies as compilation warnings by default. This is the recommended replacement for the deprecated CircularDependencyRspackPlugin.
new rspack.CircularCheckRspackPlugin(options);
Ignore specific warnings: when CircularCheckRspackPlugin reports warnings, you can use ignoreWarnings to suppress specific circular dependency diagnostics.
import { rspack } from '@rspack/core';
export default {
entry: './src/index.js',
plugins: [new rspack.CircularCheckRspackPlugin()],
ignoreWarnings: [
{
message: /Circular dependency detected:[\s\S]*src\/legacy\//,
},
],
};
ignoreWarnings only suppresses warnings. If failOnError is true, use exclude or onDetected to control reporting instead.
RegExpundefinedIf any path in a detected cycle matches exclude, that cycle will not be reported.
RegExpundefinedWhen include is provided, only cycles with at least one matching path will be reported.
booleanfalseWhen true, detected cycles will generate Error level diagnostics rather than Warnings.
We recommend using the default value with ignoreWarnings to ignore specific warnings.
(args: { module: Module; paths: string[]; compilation: Compilation }) => voidundefinedCalled once for each detected circular dependency. Using this option disables the default behavior of adding diagnostics to the compilation.
paths contains the readable unique module identifiers in the detected cycle path.
import { rspack } from '@rspack/core';
export default {
entry: './src/index.js',
plugins: [
new rspack.CircularCheckRspackPlugin({
onDetected({ paths, compilation }) {
compilation.warnings.push(
new Error(`Circular dependency detected: ${paths.join(' -> ')}`),
);
},
}),
],
};