Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
@rsbuild/plugin-node-polyfill
Advanced tools
@rsbuild/plugin-node-polyfill is a Rsbuild plugin to do something.
@rsbuild/plugin-node-polyfill is a Rsbuild plugin to do something.
Install:
npm add @rsbuild/plugin-node-polyfill -D
Add plugin to your rsbuild.config.ts
:
// rsbuild.config.ts
import { pluginNodePolyfill } from "@rsbuild/plugin-node-polyfill";
export default {
plugins: [pluginNodePolyfill()],
};
Buffer
process
When you use the above global variables in your code, the corresponding polyfill will be automatically injected.
For instance, the following code would inject the Buffer
polyfill:
const bufferData = Buffer.from("abc");
You can disable this behavior through the globals
option of the plugin:
pluginNodePolyfill({
globals: {
Buffer: false,
process: false,
},
});
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
When the above module is referenced in code via import / require syntax, the corresponding polyfill will be injected.
import { Buffer } from "buffer";
const bufferData = Buffer.from("abc");
child_process
cluster
dgram
dns
fs
module
net
readline
repl
tls
Currently there is no polyfill for the above modules on the browser side, so when you import the above modules, it will automatically fallback to an empty object.
import fs from "fs";
console.log(fs); // -> {}
Used to specify whether to inject polyfills for global variables.
type Globals = {
process?: boolean;
Buffer?: boolean;
};
const defaultGlobals = {
Buffer: true,
process: true,
};
Whether to polyfill Node.js builtin modules starting with node:
.
boolean
true
For example, if you disable protocolImports
, modules such as node:path
, node:http
, etc. will not be polyfilled.
pluginNodePolyfill({
protocolImports: false,
});
MIT.
FAQs
An Rsbuild plugin to automatically inject polyfills for [Node.js builtin modules](https://nodejs.org/api/modules.html#built-in-modules) into the browser side.
The npm package @rsbuild/plugin-node-polyfill receives a total of 12,882 weekly downloads. As such, @rsbuild/plugin-node-polyfill popularity was classified as popular.
We found that @rsbuild/plugin-node-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.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.