修改import流程,增加unimport功能,修改package.json中依赖关系的保存方式 #20
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
ecomfe/edp#341
思路大概是这样的
把旧的包的依赖关系的存储方式,改为在package.json中只保存直接依赖的包
也就是说如果import er 而er会依赖eoo 等等,在package.json中只保存er的依赖关系 不保存eoo
在unimport时,首先找到所有的包,以及package.json中的直接依赖的包,这样可以构建一个依赖树,和一个所有包的引用计数表。
然后在移除时,从完整的依赖树中拿到要移除的包的依赖树,去遍历这棵树,每遍历到一个包,引用计数表中的这个包的引用计数减一,如果为0则删掉这个包。
移除包时只对直接依赖的包做确认,用户确认就移除。
就是说如果unimport er 会提示是否移除er 而不会提示是否移除eoo
命令:edp unimport pkg1 pkg2 --force
--force表示不用确认直接移除
整理了import package流程
ecomfe/edp#332