Skip to content

【开源自荐】deno 实现的 nrm,每次切换源都在 100ms 内,速度超级快 #3111

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

Closed
markthree opened this issue May 10, 2023 · 0 comments
Labels

Comments

@markthree
Copy link

markthree commented May 10, 2023

仓库 📦

github.com/markthree/dnrm


动机 👀

我在日常的项目管理需要频繁地切换 npm 的镜像源。

nrmbug 很多,速度很慢,并且已经不维护了;新一点的 nnrmmini-nrm 也基本都需要 2s 以上的切换时间。

这在需要频繁的切换镜像源的场景下,体验非常糟糕。

所以有了 dnrm,一个 deno 实现的 nrm,每次切换源都在 100ms 内,速度超级快,开发体验拉满 😁


优化原理 🙌

  1. deno 的冷启动比 node 更快
  2. 针对 registry 配置使用正则快速获取和替换配置,不使用任何耗时的解析器,不需要序列化和反序列化
  3. 直接针对配置文件进行配置替换,而不是调用子进程执行 npm config set registry=...,因为 npm 内部分支太多,这是卡的主要原因
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants