Skip to content

Commit 43bab20

Browse files
deps: replace is-core-module with node builtin (#224)
<!-- What / Why --> <!-- Describe the request in detail. What it does and why it's being changed. --> 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 <!-- Examples: Related to #0 Depends on #0 Blocked by #0 Fixes #0 Closes #0 --> --------- Co-authored-by: Gar <[email protected]>
1 parent 335a295 commit 43bab20

2 files changed

Lines changed: 2 additions & 3 deletions

File tree

lib/fixer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ var isValidSemver = require('semver/functions/valid')
22
var cleanSemver = require('semver/functions/clean')
33
var validateLicense = require('validate-npm-package-license')
44
var hostedGitInfo = require('hosted-git-info')
5-
var isBuiltinModule = require('is-core-module')
5+
var moduleBuiltin = require('node:module')
66
var depTypes = ['dependencies', 'devDependencies', 'optionalDependencies']
77
var extractDescription = require('./extract_description')
88
var url = require('url')
@@ -231,7 +231,7 @@ module.exports = {
231231
data.name = data.name.trim()
232232
}
233233
ensureValidName(data.name, strict, options.allowLegacyCase)
234-
if (isBuiltinModule(data.name)) {
234+
if (moduleBuiltin.builtinModules.includes(data.name)) {
235235
this.warn('conflictingName', data.name)
236236
}
237237
},

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
},
2323
"dependencies": {
2424
"hosted-git-info": "^7.0.0",
25-
"is-core-module": "^2.8.1",
2625
"semver": "^7.3.5",
2726
"validate-npm-package-license": "^3.0.4"
2827
},

0 commit comments

Comments
 (0)