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-resolve): support node: protocol #1124

Merged
merged 1 commit into from May 2, 2022

Conversation

isker
Copy link
Contributor

@isker isker commented Mar 2, 2022

Rollup Plugin Name: 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:

#1120

Description

Imports with the node: protocol are currently undetected by this plugin.

Switch to using is-builtin-module, which handles this protocol and also submodule imports like fs/promises. Functionality is otherwise identical.

I confirmed the added test fails without the other changes in this PR.

pnpm-lock.yaml Show resolved Hide resolved
Imports with the [`node:`
protocol](https://nodejs.org/api/esm.html#node-imports) are currently
undetected by this plugin.

Switch to using
[is-builtin-module](https://github.com/sindresorhus/is-builtin-module),
which handles this protocol and also submodule imports like
`fs/promises`.  Functionality is otherwise identical.

Resolves rollup#1120.
@isker
Copy link
Contributor Author

isker commented Mar 3, 2022

Apologies, but I changed the authorship on the commit and now CI needs a button press again.

@shellscape
Copy link
Collaborator

@guybedford I think this could use your input given that it's introducing resolution for a new (to rollup) protocol

Copy link
Contributor

@guybedford guybedford left a comment

Choose a reason for hiding this comment

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

Seems good. Note we should really just cut out the dependency and use something like:

function isBuiltinModule (name) {
  if (name.startsWith('node:')) name = name.slice(5);
  return require('module').builtinModules.includes(name);
}

@shellscape
Copy link
Collaborator

@isker what are your thoughts on that suggestion?

@isker
Copy link
Contributor Author

isker commented Apr 15, 2022

What are @lukastaegert’s thoughts? This solution was his suggestion: #1120 (comment).

@shellscape
Copy link
Collaborator

shellscape commented May 2, 2022

I took a look at the is-builtin-modules and builtin-modules deps (both sindre packages, both very small) and I don't see that there'd be a significant perf hit loading either in the global space. For now, I think we're safe to merge as-is. If we notice a performance issue or we get reports of per issues, an optimization would be to dynamically require/import that package in the future.

Since this does add new capability, I'm going to merge this as a new feat rather than fix.

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.

None yet

3 participants