Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

circular-dependency-plugin

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

circular-dependency-plugin

Detect modules with circular dependencies when bundling with webpack.

  • 2.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
773K
decreased by-13.7%
Maintainers
1
Weekly downloads
 
Created

What is circular-dependency-plugin?

The circular-dependency-plugin is an npm package used to detect circular dependencies in JavaScript projects. It is particularly useful in large codebases where circular dependencies can lead to difficult-to-debug issues and performance problems.

What are circular-dependency-plugin's main functionalities?

Basic Usage

This code demonstrates the basic usage of the circular-dependency-plugin in a webpack configuration. It shows how to exclude certain files, include specific directories, fail on error, and set the current working directory.

const CircularDependencyPlugin = require('circular-dependency-plugin');

module.exports = {
  // other webpack config
  plugins: [
    new CircularDependencyPlugin({
      // exclude detection of files based on a RegExp
      exclude: /a\.js|node_modules/,
      // include specific files based on a RegExp
      include: /dir/,
      // add errors to webpack instead of warnings
      failOnError: true,
      // allow import cycles that include an asyncronous import,
      allowAsyncCycles: false,
      // set the current working directory for displaying module paths
      cwd: process.cwd(),
    })
  ]
};

Custom Error Message

This code sample shows how to customize the error message when a circular dependency is detected. The onDetected callback allows you to push a custom error message to the compilation errors.

const CircularDependencyPlugin = require('circular-dependency-plugin');

module.exports = {
  // other webpack config
  plugins: [
    new CircularDependencyPlugin({
      onDetected({ module: webpackModuleRecord, paths, compilation }) {
        compilation.errors.push(new Error(paths.join(' -> ')));
      }
    })
  ]
};

Other packages similar to circular-dependency-plugin

FAQs

Package last updated on 04 Sep 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc