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

deps: replace is-core-module with node builtin #224

Merged
merged 2 commits into from
Jun 25, 2024

Conversation

SuperchupuDev
Copy link
Contributor

@SuperchupuDev SuperchupuDev commented Jun 23, 2024

This PR replaces usage of is-core-module with node's built-in module.builtinModules, which was added in node 9.3.0, 8.10.0, and 6.13.0. My plan was to use module.isBuiltin but that would be a breaking change as it got added in node 16.17.0 and 18.6.0. Maybe once older node versions get dropped :P. This makes normalize-package-data use 3 less dependencies, bringing down the total count to 8. The only difference this could have is that builtinModules do not include node: builtins, but it doesn't affect this library as names prefixed by node: already throw as they are not valid names.

Packages such as is-core-module's dependencies are only there for support with ancient node versions (>=0.4) and as such have many polyfills, including one that literally emulates hasOwnProperty, and overall end up cluttering the whole javascript ecosystem. Since this package includes an engines field of ^16.14.0 || >=18.0.0, there's no real reason in using it over a built-in. is-core-module in particular does have its own use case (checking the list of built-ins of a certain node version other than the current one), but its use in this library can be replicated by module.builtinModules

References

https://nodejs.org/api/module.html#modulebuiltinmodules

@SuperchupuDev SuperchupuDev requested a review from a team as a code owner June 23, 2024 13:52
@jozefizso
Copy link

This is a great change to switch to native code available in the Node.

lib/fixer.js Outdated Show resolved Hide resolved
@wraithgar
Copy link
Member

The only difference this could have is that builtinModules do not include node: builtins, but it doesn't affect this library as names prefixed by node: already throw as they are not valid names.

Yep, this comes after we've validated that : isn't present in the name. This reality was one of the reasons the node: prefix was able to even happen.

This looks good. If you don't mind can you change your require to use the node: prefix?

Co-authored-by: Gar <wraithgar@github.com>
@wraithgar wraithgar merged commit 43bab20 into npm:main Jun 25, 2024
23 checks passed
@SuperchupuDev SuperchupuDev deleted the deps/remove-some-deps branch June 25, 2024 16:40
@github-actions github-actions bot mentioned this pull request Jun 25, 2024
wraithgar pushed a commit that referenced this pull request Jun 25, 2024
🤖 I have created a release *beep* *boop*
---


##
[6.0.2](v6.0.1...v6.0.2)
(2024-06-25)

### Dependencies

*
[`43bab20`](43bab20)
[#224](#224) replace
`is-core-module` with node builtin (#224) (@SuperchupuDev, @wraithgar)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.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