Skip to content

Richienb/node-polyfill-webpack-plugin

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
June 25, 2022 01:53
March 28, 2021 14:41
October 13, 2020 18:44
October 13, 2020 18:44
October 13, 2020 18:44
June 25, 2022 02:21
July 30, 2022 19:58
June 25, 2022 02:21
June 25, 2022 02:21
July 30, 2022 20:02
June 25, 2022 15:31
June 25, 2022 02:21

node-polyfill-webpack-plugin

Polyfill Node.js core modules in Webpack.

This module is only needed for Webpack 5+.

Install

npm install node-polyfill-webpack-plugin

Usage

Add the following to your webpack.config.js:

const NodePolyfillPlugin = require('node-polyfill-webpack-plugin');

module.exports = {
	// Other rules...
	plugins: [
		new NodePolyfillPlugin()
	]
};

API

new NodePolyfillPlugin(options?)

options

Type: object

excludeAliases and includeAliases are mutually exclusive.

excludeAliases

By default, the modules that were polyfilled in Webpack 4 are mirrored over. However, if you don't want a module like console to be polyfilled you can specify alises to be skipped here.

const NodePolyfillPlugin = require('node-polyfill-webpack-plugin');

module.exports = {
	// Other rules...
	plugins: [
		new NodePolyfillPlugin({
			excludeAliases: ['console']
		})
	]
};

includeAliases

Alternatively, you can choose to only include certain aliases. For example, you can only have console polyfilled.

const NodePolyfillPlugin = require('node-polyfill-webpack-plugin');

module.exports = {
	// Other rules...
	plugins: [
		new NodePolyfillPlugin({
			includeAliases: ['console']
		})
	]
};

Aliases

Globals

  • Buffer
  • console
  • process

Modules

  • assert
  • buffer
  • console
  • constants
  • crypto
  • domain
  • events
  • http
  • https
  • os
  • path
  • punycode
  • process
  • querystring
  • stream
  • _stream_duplex
  • _stream_passthrough
  • _stream_readable
  • _stream_transform
  • _stream_writable
  • string_decoder
  • sys
  • timers
  • tty
  • url
  • util
  • vm
  • zlib