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

[@rollup/plugin-node-resolve] error detecte if a string matches the name of a Node.js builtin module #1120

Closed
dixdiydiz opened this issue Feb 26, 2022 · 2 comments

Comments

@dixdiydiz
Copy link

  • Rollup Plugin Name: @rollup/plugin-node-resolve
  • Rollup Plugin Version: 13.1.3

Expected Behavior

'fs/promises' can be deleted as builtin module

Actual Behavior

(!) Unresolved dependencies
https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency
fs/promises (imported by xxx.ts)

Additional Information

const importeeIsBuiltin = builtins.has(importee);

is-builtin-module lib: https://github.com/sindresorhus/is-builtin-module
isBuiltinModule('fs/promises');
//=> true

isBuiltinModule('node:fs/promises');
//=> true

@lukastaegert
Copy link
Member

Good catch! Would you be willing to contribute a PR to replace builtin-modules with is-builtin-module?

isker pushed a commit to isker/plugins that referenced this issue Mar 2, 2022
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

isker commented Mar 2, 2022

I have just coincidentally had the same problem and opened a PR to fix: #1124

isker added a commit to isker/plugins that referenced this issue Mar 2, 2022
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.
@stale stale bot added the x⁷ ⋅ stale label May 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants