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(node-resolve): allow preferBuiltins to be a function #1694

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

younggglcy
Copy link
Contributor

@younggglcy younggglcy commented Mar 17, 2024

Rollup Plugin Name: @rollup/plugin-node-resolve

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes (bugfixes and features will not be merged without tests)
  • no

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

If yes, then include "BREAKING CHANGES:" in the first commit message body, followed by a description of what is breaking.

List any relevant issue numbers: resolves #1655

Description

I think #1665 proposes a nice feature that gives preferBuiltins a more fine-grained control, so I'm trying to resolve this a little inactive issue.

This PR only makes node-resolve accept a function parameter to preferBuiltins to introduce as little as possible without changing the existing API.

#1665 also proposes that it should match the behavior of the external rollup configuration. But I think in most cases, we only need to mark some modules as non-builtins, e.g., deprecated modules like punycode. And this is somehow contrary to the behavior of the external.

Is accepting a function enough or should we add some extra configs? I'm willing to contribute if we need to make more changes.

@@ -30,13 +30,12 @@ test('handles importing builtins', async (t) => {
});

test('warning when preferring a builtin module, no explicit configuration', async (t) => {
let warning = null;
Copy link
Collaborator

Choose a reason for hiding this comment

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

we always prefer adding another test instead of modifying an existing test. What was the reason that this test was modified?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because I added new warning message after the original here.
So this test is modified to let the warnings match exactly.

@younggglcy younggglcy force-pushed the feat/node_resolve_prefer_bulitins branch from 9eaa425 to 7e12e8c Compare June 6, 2024 11:30
@younggglcy younggglcy requested a review from tada5hi as a code owner June 6, 2024 11:30
@younggglcy younggglcy force-pushed the feat/node_resolve_prefer_bulitins branch from 7e12e8c to 9eaa425 Compare June 6, 2024 11:36
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.

node-resolve: allow more granular config of preferBuiltins
2 participants