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: specify a particular Node.js version using pnpm #1677

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

gweesin
Copy link
Contributor

@gweesin gweesin commented Jun 15, 2024

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

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?

  • Yes
  • No

Other information

Also you can use this config to reproduce #1676 before update source code.

Summary by CodeRabbit

  • Chores
    • Updated Node.js version to 18.19.1 in .npmrc for improved compatibility and performance.

Copy link

coderabbitai bot commented Jun 15, 2024

Walkthrough

The .npmrc file has been updated to include the use-node-version=18.19.1 configuration. This change ensures that the specific Node.js version 18.19.1 is used across the project, which could aid in maintaining consistency and avoiding compatibility issues related to different Node.js versions.

Changes

Files Summary
.npmrc Added use-node-version=18.19.1 setting.

Poem

In the code garden where nodes do play, 🌱
A new version blossoms, 18.19.1 today! 🌼
With harmony in scripts, they all now say,
"Consistency is here, let's code away!" 💻✍️


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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

[e2e-test-warn]
The component to be tested is missing.

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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 5e02624 and 9b3b704.

Files selected for processing (1)
  • .npmrc (1 hunks)
Files skipped from review due to trivial changes (1)
  • .npmrc

enable-pre-post-scripts=true
use-node-version=18.19.1
Copy link
Member

@zzcr zzcr Jul 26, 2024

Choose a reason for hiding this comment

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

你好,这个如果配置死了18.19.1,会让版本不匹配的用户重新下载nodejs,这样做不是很好哈吗,在内部下载会超时,但是还是感谢你的贡献哈

Copy link
Contributor Author

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 的镜像

Copy link
Member

Choose a reason for hiding this comment

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

我的理解是给用户相应的提示即可,不能迫使用户区下载nodejs,可以在package.json中指定下nodejs的最低版本的

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. 这里的用户指的是开发 tiny-vue 的开发者 —— 面对源码
  2. 在 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 版本。

Copy link
Contributor Author

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,达到基本跟环境隔离的效果~

Copy link
Member

Choose a reason for hiding this comment

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

@gweesin 有可能会出现一个问题,就是开发者没有搭梯子的话,执行 pnpm i 会报错。
image

Copy link
Contributor Author

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 指定淘宝镜像

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants