Skip to content

Commit

Permalink
Merge pull request #37 from hedgepigdaniel/5.0-async-deps
Browse files Browse the repository at this point in the history
Add option to allow cycles that include an asynchronous dependency
  • Loading branch information
aackerman committed Apr 27, 2018
2 parents b563ee1 + f381284 commit 2ea27ea
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ module.exports = {
exclude: /a\.js|node_modules/,
// add errors to webpack instead of warnings
failOnError: true,
// allow import cycles that include an asyncronous import,
// e.g. via import(/* webpackMode: "weak" */ './file.js')
allowAsyncCycles: false,
// set the current working directory for displaying module paths
cwd: process.cwd(),
})
Expand Down
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class CircularDependencyPlugin {
this.options = extend({
exclude: new RegExp('$^'),
failOnError: false,
allowAsyncCycles: false,
onDetected: false,
cwd: process.cwd()
}, options)
Expand Down Expand Up @@ -82,6 +83,8 @@ class CircularDependencyPlugin {
if (!depModule) { continue }
// ignore dependencies that don't have an associated resource
if (!depModule.resource) { continue }
// ignore dependencies that are resolved asynchronously
if (this.options.allowAsyncCycles && dependency.weak) { continue }

if (depModule.debugId in seenModules) {
if (depModule.debugId === initialModule.debugId) {
Expand Down

0 comments on commit 2ea27ea

Please sign in to comment.