Nuxt/scripts/builtins.js
Pooya Parsa 9c1e0d1743 feat: migrate nuxt into monorepo (#4051)
Co-authored-by: Clark Du <clark.duxin@gmail.com>
Co-authored-by: Pooya Parsa <pooya@pi0.ir>
2018-10-18 00:58:25 +03:30

23 lines
565 B
JavaScript

/*
** Core logic from https://github.com/sindresorhus/builtin-modules
** Many thanks to @sindresorhus
*/
import Module from 'module'
const blacklist = [
'sys'
]
export const builtins = (Module.builtinModules || Object.keys(process.binding('natives')))
.filter(x => !/^_|^(internal|v8|node-inspect)\/|\//.test(x) && !blacklist.includes(x))
.sort()
let builtinsObj = null
const convertToObj = () => builtins.reduce((obj, builtin) => {
obj[builtin] = true
return obj
}, (builtinsObj = {}))
export const builtinsMap = () => builtinsObj || convertToObj()