How to use the builtin-modules.forEach 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 / webpack.config.js View on Github external
function makeWebpackConfig({ entry, externals }) {
  const externalsRegex = makeExternalsRegex(externals.externalPackages)
  const isExternalRequest = (request) => {
    const isPeerDep = externals.externalPackages.length ? externalsRegex.test(request) : false
    const isBuiltIn = externals.externalBuiltIns.includes(request)
    return isPeerDep || isBuiltIn
  }

  debug('external packages %o', externalsRegex)

  const builtInNode = {}
  builtinModules.forEach(mod => {
    builtInNode[mod] = 'empty'
  })

  builtInNode['setImmediate'] = false
  builtInNode['console'] = false
  builtInNode['process'] = false
  builtInNode['Buffer'] = false

  return {
    entry: entry,
    mode: 'production',
    // bail: true,
    optimization: {
      namedChunks: true,
      runtimeChunk: { name: 'runtime' },
      splitChunks: {
github nikersify / jay / source / util.ts View on Github external
export const addBuiltinsToObject = (o: LooseObject): void =>
	builtinModules.forEach(m =>
		Object.defineProperty(o, m, {
			configurable: true,
			// Keeping it non-enumerable so as to not pollute the output from
			// running `global` in the repl, which would in turn actually
			// trigger the getter, rendering this whole mechanism useless.
			enumerable: false,
			get() {
				// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
				const required = require(m)

				delete o[m]
				Object.defineProperty(o, m, {
					configurable: true,
					enumerable: false,
					writable: true,
					value: required

builtin-modules

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

MIT
Latest version published 6 months ago

Package Health Score

76 / 100
Full package analysis