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

fix: node ignores #1716

Merged
merged 1 commit into from
Dec 6, 2024
Merged

Conversation

akitaSummer
Copy link
Contributor

@akitaSummer akitaSummer commented Dec 6, 2024

In Node.js 23, node:sqlite is built-in, but when using require('sqlite') alone, it should refer to the community package. Considering this scenario, all require statements starting with node: should be treated as using Node's built-in modules.

https://nodejs.org/docs/latest/api/sqlite.html

Summary by CodeRabbit

  • 新功能
    • 在配置中添加了对以“node:”开头的内置 Node.js 模块的忽略规则,增强了对 Node 平台的支持。

Copy link
Contributor

coderabbitai bot commented Dec 6, 2024

Warning

Rate limit exceeded

@akitaSummer has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 4 minutes and 53 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between c592309 and 23e8fa8.

Walkthrough

此拉取请求对 crates/mako/src/features/node.rs 中的 Node 结构体的 modify_config 方法进行了修改。新增一行代码将正则表达式模式附加到 config.ignores 列表中,专门针对以 "node:" 开头的内置 Node.js 模块。此更改增强了现有逻辑,明确处理这些特定模块,同时保持了方法的整体结构和条件逻辑。

Changes

文件路径 更改摘要
crates/mako/src/features/node.rs 修改 modify_config 方法,新增一行将以 "node:" 开头的内置模块添加到 config.ignores 列表中。

Possibly related PRs

Suggested reviewers

  • stormslowly

Poem

在兔子洞里我欢跳,
新的代码如春风到。
忽略模块加新规,
Node.js 里更轻巧。
代码变更真美妙,
兔子乐在编程道。 🐇✨


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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

Walkthrough

This pull request addresses an issue in Node.js 23 where node:sqlite is a built-in module, but require('sqlite') should refer to the community package. The change ensures that all require statements starting with node: are treated as using Node's built-in modules.

Changes

File Summary
crates/mako/src/features/node.rs Added logic to treat require statements starting with node: as built-in Node.js modules by updating the ignore configuration.

Copy link
Contributor

@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

🧹 Outside diff range and nitpick comments (1)
crates/mako/src/features/node.rs (1)

27-30: 代码实现正确,建议补充注释说明

代码变更正确解决了 Node.js 23 内置模块的解析问题。建议在注释中详细说明为什么需要两个独立的 ignore 模式:

  1. 第一个模式用于匹配已知的内置模块(无论是否带有 "node:" 前缀)
  2. 第二个模式用于匹配所有以 "node:" 开头的模块(包括未来可能新增的内置模块)

建议添加如下注释:

 // If it starts with "node:", they are all built-in node modules.
+// 这个模式用于处理所有以 "node:" 开头的模块,包括现有和未来的内置模块
+// 上面的模式用于向后兼容不带 "node:" 前缀的内置模块调用
 config.ignores.push(format!(
     "^(node:)(/.+|$)",
 ));
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 7c508d2 and 45b1a3c.

📒 Files selected for processing (1)
  • crates/mako/src/features/node.rs (1 hunks)

@akitaSummer akitaSummer force-pushed the fix/node_modules_list branch from 45b1a3c to c592309 Compare December 6, 2024 03:50
@akitaSummer akitaSummer force-pushed the fix/node_modules_list branch from c592309 to 23e8fa8 Compare December 6, 2024 03:59
Copy link

codecov bot commented Dec 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 54.91%. Comparing base (ea532ba) to head (23e8fa8).
Report is 4 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1716   +/-   ##
=======================================
  Coverage   54.91%   54.91%           
=======================================
  Files         178      178           
  Lines       17840    17841    +1     
=======================================
+ Hits         9797     9798    +1     
  Misses       8043     8043           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@xusd320 xusd320 merged commit 5ee1c16 into umijs:master Dec 6, 2024
21 checks passed
@fengmk2
Copy link

fengmk2 commented Dec 9, 2024

求发个版本

@sorrycc
Copy link
Member

sorrycc commented Dec 11, 2024

This solution hides problems, such as the fact that this error is not reported at compile time when require('node:foo').

@sorrycc
Copy link
Member

sorrycc commented Dec 11, 2024

And, no testcases added.

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.

4 participants