dependency-parse-plugin
Advanced tools
Comparing version 0.0.6 to 0.0.7
14
index.js
@@ -26,2 +26,5 @@ let PluginTitle = 'DependencyParsePlugin'; | ||
// 循环依赖 | ||
circyleDeps = []; | ||
options = { | ||
@@ -46,3 +49,3 @@ includes: [], | ||
parseOneFileAllDependency = (filePath) => { | ||
const dfs = (filePath) => { | ||
const dfs = (filePath, importPaths = [filePath]) => { | ||
const temp = this.directDeps[filePath] || []; | ||
@@ -52,6 +55,11 @@ const deps = []; | ||
temp.forEach((_) => { | ||
// 循环依赖 | ||
if (importPaths.includes(_) ) { | ||
this.circyleDeps.push([...importPaths, _]); | ||
return; | ||
} | ||
if (this.allDeps[_]) { | ||
deps.push(...this.allDeps[_]); | ||
} else { | ||
deps.push(...dfs(_)); | ||
deps.push(...dfs(_, [...importPaths, _])); | ||
} | ||
@@ -209,6 +217,6 @@ }); | ||
} | ||
// 执行完-清空数据 | ||
this.allDeps = {}; | ||
this.directDeps = {}; | ||
this.circyleDeps = {}; | ||
}); | ||
@@ -215,0 +223,0 @@ } |
{ | ||
"name": "dependency-parse-plugin", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "Detect dependencies of each file in modules compiled with Webpack", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
283766
194