Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
esbuild-plugins-node-modules-polyfill
Advanced tools
Polyfills nodejs builtin modules and globals for the browser.
Polyfills nodejs builtin modules and globals for the browser.
node:
protocolbrowser
field in package.json
npm install --save-dev esbuild-plugins-node-modules-polyfill
import { nodeModulesPolyfillPlugin } from 'esbuild-plugins-node-modules-polyfill';
import { build } from 'esbuild';
build({
plugins: [nodeModulesPolyfillPlugin()],
});
import { nodeModulesPolyfillPlugin } from 'esbuild-plugins-node-modules-polyfill';
import { build } from 'esbuild';
build({
plugins: [
nodeModulesPolyfillPlugin({
globals: {
process: true,
Buffer: true,
},
}),
],
});
Note If you are utilizing the
modules
option, ensure that you include polyfills for the global modules you are using.
import { nodeModulesPolyfillPlugin } from 'esbuild-plugins-node-modules-polyfill';
import { build } from 'esbuild';
build({
plugins: [
nodeModulesPolyfillPlugin({
modules: ['crypto'],
}),
],
});
import { nodeModulesPolyfillPlugin } from 'esbuild-plugins-node-modules-polyfill';
import { build } from 'esbuild';
build({
plugins: [
nodeModulesPolyfillPlugin({
modules: {
crypto: true,
fs: false,
},
}),
],
});
import { nodeModulesPolyfillPlugin } from 'esbuild-plugins-node-modules-polyfill';
import { build } from 'esbuild';
build({
plugins: [
nodeModulesPolyfillPlugin({
modules: {
fs: 'empty',
crypto: true,
},
}),
],
});
import { nodeModulesPolyfillPlugin } from 'esbuild-plugins-node-modules-polyfill';
import { build } from 'esbuild';
build({
plugins: [
nodeModulesPolyfillPlugin({
fallback: 'empty',
}),
],
});
import { nodeModulesPolyfillPlugin } from 'esbuild-plugins-node-modules-polyfill';
import { build } from 'esbuild';
build({
plugins: [
nodeModulesPolyfillPlugin({
fallback: 'empty',
modules: {
crypto: true,
},
}),
],
});
Warning The
write
option inesbuild
must befalse
to support this.
import { nodeModulesPolyfillPlugin } from 'esbuild-plugins-node-modules-polyfill';
import { build } from 'esbuild';
const buildResult = await build({
write: false,
plugins: [
nodeModulesPolyfillPlugin({
modules: {
crypto: 'error',
path: true,
},
}),
],
});
Warning The
write
option inesbuild
must befalse
to support this.
import { nodeModulesPolyfillPlugin } from 'esbuild-plugins-node-modules-polyfill';
import { build } from 'esbuild';
const buildResult = await build({
write: false,
plugins: [
nodeModulesPolyfillPlugin({
fallback: 'error',
modules: {
path: true,
},
}),
],
});
Return an esbuild PartialMessage
object from the formatError
function to override any properties of the default error message.
Warning The
write
option inesbuild
must befalse
to support this.
import { nodeModulesPolyfillPlugin } from 'esbuild-plugins-node-modules-polyfill';
import { build } from 'esbuild';
const buildResult = await build({
write: false,
plugins: [
nodeModulesPolyfillPlugin({
fallback: 'error',
modules: {
path: true,
},
formatError({ moduleName, importer, polyfillExists }) {
return {
text: polyfillExists
? `Polyfill has not been configured for "${moduleName}", imported by "${importer}"`
: `Polyfill does not exist for "${moduleName}", imported by "${importer}"`,
};
},
}),
],
});
If you want to support me by donating, you can do so by using any of the following methods. Thank you very much in advance!
Thanks goes to these wonderful people:
FAQs
Polyfills nodejs builtin modules and globals for the browser.
The npm package esbuild-plugins-node-modules-polyfill receives a total of 319,588 weekly downloads. As such, esbuild-plugins-node-modules-polyfill popularity was classified as popular.
We found that esbuild-plugins-node-modules-polyfill demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.