-
Notifications
You must be signed in to change notification settings - Fork 266
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: specify a particular Node.js version using pnpm #1677
base: dev
Are you sure you want to change the base?
Conversation
WalkthroughThe Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
[e2e-test-warn] The title of the Pull request should look like "fix(vue-renderless): [action-menu, alert] fix xxx bug". Please make sure you've read our contributing guide |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enable-pre-post-scripts=true | ||
use-node-version=18.19.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
你好,这个如果配置死了18.19.1,会让版本不匹配的用户重新下载nodejs,这样做不是很好哈吗,在内部下载会超时,但是还是感谢你的贡献哈
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这样做相当于以项目级别指定node版本,可以防止不同贡献者因为开发环境的node不同导致贡献仓库时有相关问题。
内部下载超时一般可以通过设置镜像解决,类似在 .npmrc 中添加指定淘宝镜像
node-mirror:release=https://npmmirror.com/mirrors/node/
我看华为云也有相关node生态的镜像,类似 cypress 的镜像
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我的理解是给用户相应的提示即可,不能迫使用户区下载nodejs,可以在package.json中指定下nodejs的最低版本的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 这里的用户指的是开发 tiny-vue 的开发者 —— 面对源码
- 在 package.json 下指定 node.js 最低版本对应的作用域是 开发 tiny-vue 的开发者 U 使用 tiny-vue 组件库的用户(面对产物)
也就是说,这两者的作用域可以不同,比如说开发 tiny-vue 组件库统一使用 latest 版本,只要打出来的包兼容 node 12,使用 tiny-vue 组件库的用户使用 node 12 也可以正常运行。
相对应的,如果开发 tiny-vue 的开发者使用的是 node 12 而不是 latest,那么在运行 tiny-vue 源码时,自动下载源码所需的 node 版本理论上更合适,省去主动切换 node 版本。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
也就是说对于 tiny-vue 的开发者,把 node 环境也当做了依赖的一环,做到像安装 package.json 声明的依赖一样。
类似像 https://github.com/antfu/eslint-config/blob/c22689f8fc38f7c7a0e53b9fed7f359f36e5c7e4/package.json#L5
使用 corepack 并且指定 packageManager,还可以把包管理器当做依赖的一环,这样当 pnpm 和 node 版本都不同时,通过 corepack 自动安装项目所需 pnpm,通过 pnpm 自动安装项目所需 node,达到基本跟环境隔离的效果~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gweesin 有可能会出现一个问题,就是开发者没有搭梯子的话,执行 pnpm i
会报错。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个是的,国内的话需要配置一次环境变量 COREPACK_NPM_REGISTRY=https://registry.npmmirror.com 指定淘宝镜像
PR
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
using engines attr in package.json to specify expected node version
PR Number: #1676
What is the new behavior?
using
use-node-version=18.19.1
in .npmrc to specify expected node version, promise everyone using the same node version to contribute this repo.Does this PR introduce a breaking change?
Other information
Also you can use this config to reproduce #1676 before update source code.
Summary by CodeRabbit
.npmrc
for improved compatibility and performance.