How to use the builtin-modules.includes 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 egoist / import-http / lib / utils.js View on Github external
exports.resolveURL = (issuer, id) => {
  if (/^\./.test(id)) {
    // Relative file
    // Excluded something like ./node_modules/webpack/buildin/global.js
    if (!/node_modules/.test(id)) {
      id = url.resolve(issuer, id)
    }
  } else if (!builtinModules.includes(id)) {
    // Propably an npm package
    id = `https://unpkg.com/${id}`
  }
  return id
}
github egoist / bili / src / plugins / node-resolve.ts View on Github external
async resolveId(importee: string, importer?: string) {
      const id = await plugin.resolveId(
        importee,
        importer || `${options.rootDir}/__no_importer__.js`
      )

      if (typeof id === 'string') {
        // Exclude built-in modules
        if (builtinModules.includes(id)) {
          return false
        }

        // If we don't intend to bundle node_modules
        // Mark it as external
        if (/node_modules/.test(id)) {
          if (!options.bundleNodeModules) {
            return false
          }
          if (Array.isArray(options.bundleNodeModules)) {
            const shouldBundle = options.bundleNodeModules.some(name =>
              id.includes(`/node_modules/${name}/`)
            )
            if (!shouldBundle) {
              return false
            }
github brodybits / prettierx / scripts / build / rollup-plugins / native-shims.js View on Github external
resolveId(importee) {
      if (importee.startsWith(PREFIX)) {
        return importee;
      }

      if (/\0/.test(importee) || !builtins.includes(importee)) {
        return null;
      }

      const shim = path.resolve(dir, importee + ".js");
      if (fs.existsSync(shim)) {
        return shim;
      }
      return PREFIX + importee;
    },
github SonarSource / SonarJS / eslint-bridge / src / rules / no-implicit-dependencies.ts View on Github external
context: Rule.RuleContext,
) {
  const moduleName = module.value;
  if (typeof moduleName !== "string") {
    return;
  }

  const ts = require("typescript");
  if (ts.isExternalModuleNameRelative(moduleName)) {
    return;
  }

  const packageName = getPackageName(moduleName);
  if (
    !whitelist.includes(packageName) &&
    !builtins.includes(packageName) &&
    !dependencies.has(packageName)
  ) {
    context.report({
      message: "Either remove this import or add it as a dependency.",
      loc,
    });
  }
}

builtin-modules

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

MIT
Latest version published 18 days ago

Package Health Score

77 / 100
Full package analysis