4.1.0 • Published 5 months ago

node-polyfill-webpack-plugin v4.1.0

Weekly downloads
3,775
License
MIT
Repository
github
Last release
5 months ago

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(),
	],
};

console, process, and most deprecated/internal Node.js core modules are not polyfilled by default. If you still need to polyfill them, you can use the additionalAliases option:

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

module.exports = {
	// Other rules...
	plugins: [
		new NodePolyfillPlugin({
			additionalAliases: ['process', 'punycode'],
		}),
	],
};

The fs module resolves to nothing because its functionality cannot replicated in the browser.

API

new NodePolyfillPlugin(options?)

options

Type: object

onlyAliases is mutually exclusive with excludeAliases and additionalAliases.

excludeAliases

If you don't want a module to be polyfilled, you can specify aliases to be skipped here.

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

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

additionalAliases

Alternatively, you can choose to add certain aliases to the list of polyfilled modules. For example, you can choose to polyfill console.

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

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

onlyAliases

You can also choose to only include certain aliases, ignoring the defaults. For example, you can have only console polyfilled.

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

module.exports = {
	// Other rules...
	plugins: [
		new NodePolyfillPlugin({
			onlyAliases: ['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
@bsolution/fast@corabank/ibanking@pandev/docusaurus-plugin-panw@felvin-search-apps/async-api-validatoreventsource-ts@kurtzgmbh/front-react-appvisvamarbundles-esmuser-wxfstdh-web-ui@everything-registry/sub-chunk-2308@subwallet_connect/ledgerpolkadot@nimeshjohri/webplayer-sdkimo-clientcesium-serialization-plugintassanyi_reacttailwind-runtime-jitwix-deputy-jswhfd-mappingwallet-dappwalletconnect-sdkvue-micro-appweb3bruhwenke-devwp5-cra-polyfillws-strapi-forkwhisper-providerxgy-ant-uixiang-webpackwwm-mqtt-clientxh-minio-uploadstac-componenttest-sdk-v2test-sub-sdk-v2th-miniovobi_libvcmqj-newelectron-react-creator-test@ctsx/webpack@collaboware/react-scripts@cyber-chimera/spa-build-tools@cpfe/vue-cli@botonic/dxdofloepm_npm_solutionjcc_walletjinghuan-clijoplin-plugin-ai-summarizationjsc3d11keyrunnerkeyrunner-cli-testkarma-webpack-bundlekeplergl-jupyterlatejs-appholohubstuyutils.jssoulswap-open-sdksqlite-remote-dbsurvaii-session-streamtxgw-docusaurus-theme-openapi-docstypedcssx-webpack-plugintkmap_ol_cstime-analyzertheme-openapi-writedocstls-toolkittm-build@arcana/scw@ancademy/vse-cli@bcapps/libback@blockfrost/docusaurus-theme-openapi-docs@bn-digital/webpack@bobaboard/ui-components@celljs/cli-service@chrissong/simo-core@chaoswise/scaffold@_koi/sdk@designsystemsinternational/mechanic@dengwenlong/dwl-core@digicommerce/cms-admin@control.n/commonyapi-to-typescript-cliyy12312clizenduty-react-scripts5vue2-amis-reportsvue3-miniowar-handlerunicore-sdkvali-webpackv3-prettyzjjk-miniozjp-filemanager2@felvin-search/cli@felvin-community/async-api-validator@grexie/pages-builder@hello-label/common-libs@fnya/crawler-for-slack@hernas/docusaurus-theme-openapi-docs@huiweitech/matrix-admin@hyext/builder-beyond@gen-io/gen-sdk
4.1.0

5 months ago

4.0.0

12 months ago

3.0.0

1 year ago

2.0.1

3 years ago

2.0.0

3 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.1

4 years ago

1.1.2

4 years ago

1.1.0

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

5 years ago