1. node-polyfill-webpack-plugin
Polyfill Node.js core modules in Webpack.
node-polyfill-webpack-plugin
Package: node-polyfill-webpack-plugin
Created by: Richienb
Last modified: Wed, 06 Dec 2023 14:35:31 GMT
Version: 3.0.0
License: MIT
Downloads: 5,194,423
Repository: https://github.com/Richienb/node-polyfill-webpack-plugin

Install

npm install node-polyfill-webpack-plugin
yarn add node-polyfill-webpack-plugin

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

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code