-
-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
There are native Node.js alternatives to the is-builtin-module package for checking built-in modules
Node.js (since 16.x)
For determining if a module is built-in or not, you can use isBuiltin:
import { isBuiltin } from 'node:module' // [!code ++]
import isBuiltinModule from 'is-builtin-module' // [!code --]
isBuiltin('fs') // true [!code ++]
isBuiltinModule('fs') // true [!code --]Node.js 6.x to 15.x
Before Node.js 16.x, isBuiltin was not available, so you need to implement your own check using builtinModules:
import { builtinModules } from 'node:module' // [!code ++]
import isBuiltinModule from 'is-builtin-module' // [!code --]
function isBuiltin(moduleName) { // [!code ++]
const name = moduleName.startsWith('node:') // [!code ++]
? moduleName.slice(5) // [!code ++]
: moduleName // [!code ++]
return builtinModules.includes(name) // [!code ++]
} // [!code ++]
isBuiltin('fs') // true [!code ++]
isBuiltinModule('fs') // true [!code --]npx github:Fuzzyma/e18e-tools is-builtin-module -n 100 -q -o md -U https://npm.devminer.xyz/registry| # | Downloads | Traffic | Version | Package | PR |
|---|---|---|---|---|---|
| 1 | 17.59M | 30.63 GB | ^5.0.0 | eslint-plugin-unicorn | |
| 2 | 827.27k | 1.44 GB | ^3.2.1 | serverless-webpack | serverless-heaven/serverless-webpack#2308 |
| 3 | 629.51k | 1.10 GB | ^2.0.0 | @dependabot/yarn-lib | |
| 4 | 226.37k | 394.11 MB | ^3.0.0 | import-sort |
npx github:Fuzzyma/e18e-tools is-builtin-module -n 100 -q -o md -D -U https://npm.devminer.xyz/registry| # | Downloads | Traffic | Version | Package | PR |
|---|---|---|---|---|---|
| 1 | 16.19M | 28.18 GB | @supabase/node-fetch | #145 | |
| 2 | 10.05M | 17.49 GB | node-fetch-h2 | #145 | |
| 3 | 7.16M | 12.46 GB | mapbox-gl | mapbox/mapbox-gl-js@0e3c67d | |
| 4 | 3.12M | 5.44 GB | maplibre-gl | ||
| 5 | 2.06M | 3.59 GB | node-fetch-npm | #145 | |
| 7 | 953.87k | 1.66 GB | @plotly/mapbox-gl | #233 |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels