How to use the builtin-modules.filter function in builtin-modules

To help you get started, we’ve selected a few builtin-modules examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pastelsky / package-build-stats / src / utils / common.utils.js View on Github external
function getExternals(packageName, installPath) {
  const packageJSONPath = path.join(
    installPath,
    'node_modules',
    packageName,
    'package.json'
  )
  const packageJSON = require(packageJSONPath)
  const dependencies = Object.keys(packageJSON.dependencies || {})
  const peerDependencies = Object.keys(packageJSON.peerDependencies || {})

  // All packages with name same as a built-in node module, but
  // haven't explicitly been added as an npm dependency are externals
  const builtInExternals = builtInModules.filter(mod => !dependencies.includes(mod))
  return {
    externalPackages: peerDependencies,
    externalBuiltIns: builtInExternals
  }
}

builtin-modules

A static list of the Node.js builtin modules from the latest Node.js version

MIT
Latest version published 25 days ago

Package Health Score

77 / 100
Full package analysis