Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support dependencies tree #287

Merged
merged 3 commits into from
Dec 24, 2018
Merged

feat: support dependencies tree #287

merged 3 commits into from
Dec 24, 2018

Conversation

dead-horse
Copy link
Member

  1. 通过 --save-dependencies-tree 开启依赖树生成,生成的依赖树位于 node_modules/.dependencies_tree.json
  2. 通过 --dependencies-tree=.dependencies_tree.json 来指定从生成的依赖树恢复

注意:只会保存 npm resolve 的依赖树,从远程地址或者 git 仓库拉下来的没有 semver,也不会保存下来,生成的依赖树文件在 1~5MB 左右,所以生成保存后打包时要清理掉。

/cc @coolme200

@dead-horse
Copy link
Member Author

生成的依赖树长这样: https://github.com/cnpm/npminstall/pull/287/files#diff-5dfb1861470b074a897f48b8ceebe59d

@welladamm 其实 npminstall 在安装的时候就保留好信息了,你看看这份数据是否可以替换掉 @ali/deps-tree 的生成?后面我们也只需要生成一份了。

@codecov
Copy link

codecov bot commented Dec 22, 2018

Codecov Report

Merging #287 into master will decrease coverage by 0.05%.
The diff coverage is 96.77%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #287      +/-   ##
==========================================
- Coverage    92.9%   92.84%   -0.06%     
==========================================
  Files          27       27              
  Lines        1916     1943      +27     
  Branches      325      329       +4     
==========================================
+ Hits         1780     1804      +24     
- Misses        136      139       +3
Impacted Files Coverage Δ
lib/format_install_options.js 100% <100%> (ø) ⬆️
lib/local_install.js 98.18% <100%> (+0.1%) ⬆️
lib/download/npm.js 86.86% <100%> (ø) ⬆️
lib/install.js 97.92% <100%> (+0.01%) ⬆️
bin/install.js 90% <87.5%> (-0.12%) ⬇️
lib/utils.js 90.63% <0%> (-0.67%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a31b19c...fbb7e02. Read the comment docs.


const cache = {};
for (const key in options.cache) {
if (!key.match(/^npm:resolve:version:/)) continue;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

key startsWith 会更快吧

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

恩,之前不记得 node 4 支不支持了。

把这些缓存单独放到 cache.dependenciesTree 上了,更合理一点。

@fengmk2
Copy link
Member

fengmk2 commented Dec 22, 2018

@coolme200 用来解决快速修复问题的迭代?不重新安装依赖?

@dead-horse
Copy link
Member Author

closes #286

@dead-horse
Copy link
Member Author

@fengmk2 还有异步构建 source map 的场景也需要复原 node_modules

@coolme200
Copy link

@coolme200 用来解决快速修复问题的迭代?不重新安装依赖?

@coolme200
Copy link

+1

@dead-horse dead-horse merged commit d029138 into master Dec 24, 2018
@dead-horse dead-horse deleted the dependencies-tree branch December 24, 2018 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants