close

CircularCheckRspackPlugin

Rspack only

Detects circular dependencies with a lightweight implementation that runs directly on Rspack's module graph. Compared with the deprecated CircularDependencyRspackPlugin, this plugin intentionally supports fewer options so it can keep runtime overhead low in large projects and watch builds.

new rspack.CircularCheckRspackPlugin(options);

Example

rspack.config.mjs
import { rspack } from '@rspack/core';

export default {
  plugins: [
    new rspack.CircularCheckRspackPlugin({
      failOnError: true,
      exclude: /node_modules/,
    }),
  ],
};

Options

failOnError

  • Type: boolean
  • Default: false

When true, detected cycles emit Error diagnostics instead of Warning diagnostics.

exclude

  • Type: RegExp
  • Default: undefined

Cycles containing a module resource path that matches this pattern are ignored.

rspack.config.mjs
import { rspack } from '@rspack/core';

export default {
  plugins: [
    new rspack.CircularCheckRspackPlugin({
      exclude: /node_modules/,
    }),
  ],
};

Notes

CircularCheckRspackPlugin ignores dependency types that do not synchronously evaluate the target module during current module initialization, such as import(), import context dependencies, HMR accept/decline references, resolve/id-only references, and asset/CSS resource references.

For compatibility with ignoredConnections, onDetected, onIgnored, onStart, and onEnd, use the deprecated CircularDependencyRspackPlugin.