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 - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

29

__tests__/index_test.js

@@ -69,2 +69,31 @@ var webpack = require('webpack');

});
it('can exclude cyclical deps from being output', (done) => {
var s = sandbox.stub(console, 'warn', console.warn);
var fs = new MemoryFS();
var c = webpack({
entry: path.join(__dirname, 'deps/d.js'),
output: { path: __dirname },
plugins: [
new CircularDependencyPlugin({
exclude: /f\.js/
})
]
});
c.outputFileSystem = fs;
c.run(function(err, stats){
if (err) {
assert(false, err);
done();
} else {
assert(s.getCall(0).args[0].match(/e\.js/));
assert(s.getCall(0).args[1].match(/cyclical/));
assert(s.getCall(1).args[0].match(/g\.js/));
assert(s.getCall(1).args[1].match(/cyclical/));
done();
}
});
});
});

11

index.js
var path = require('path');
var extend = require('util')._extend;
function CircularDependencyPlugin() {}
function CircularDependencyPlugin(options) {
this.options = extend({
exclude: new RegExp('$^')
}, options);
}

@@ -30,2 +35,4 @@ function isCyclic(initialModule) {

CircularDependencyPlugin.prototype.apply = function(compiler) {
var plugin = this;
compiler.plugin('done', function(stats){

@@ -35,3 +42,3 @@ var modules = stats.compilation.modules;

modules.forEach(function(module){
if (isCyclic(module)) {
if (isCyclic(module) && !plugin.options.exclude.test(module.resource)) {
var relativePathToModule = path.relative(process.cwd(), module.resource);

@@ -38,0 +45,0 @@ console.warn(relativePathToModule, 'contains cyclical dependency');

2

package.json

@@ -11,3 +11,3 @@ {

"description": "Detect modules with circular dependencies when bundling with webpack.",
"version": "1.0.2",
"version": "1.0.3",
"dependencies": {},

@@ -14,0 +14,0 @@ "scripts": {

@@ -11,5 +11,7 @@ ## circular-dependency-plugin

plugins: [
new CircularDependencyPlugin()
new CircularDependencyPlugin({
exclude: /a\.js/
})
]
}
```
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