Gathering detailed insights and metrics for @artursapek/vite-plugin-node-polyfills
Gathering detailed insights and metrics for @artursapek/vite-plugin-node-polyfills
A Vite plugin to polyfill Node's Core Modules for browser environments.
npm install @artursapek/vite-plugin-node-polyfills
Typescript
Module System
Node Version
NPM Version
59.3
Supply Chain
88.4
Quality
77
Maintenance
50
Vulnerability
97.9
License
TypeScript (96.19%)
HTML (3.08%)
JavaScript (0.72%)
Verify real, reachable, and deliverable emails with instant MX records, SMTP checks, and disposable email detection.
Total Downloads
1,059
Last Day
8
Last Week
12
Last Month
26
Last Year
1,059
MIT License
337 Stars
131 Commits
27 Forks
3 Watchers
5 Branches
11 Contributors
Updated on Mar 13, 2025
Minified
Minified + Gzipped
Latest Version
0.17.5
Package Id
@artursapek/vite-plugin-node-polyfills@0.17.5
Unpacked Size
567.25 kB
Size
116.83 kB
File Count
31
NPM Version
10.4.0
Node Version
21.4.0
Published on
May 08, 2024
Cumulative downloads
Total Downloads
Last Day
0%
8
Compared to previous day
Last Week
500%
12
Compared to previous week
Last Month
-39.5%
26
Compared to previous month
Last Year
0%
1,059
Compared to previous year
A Vite plugin to polyfill Node's Core Modules for browser environments. Supports node:
protocol imports.
Module "stream" has been externalized for browser compatibility. Cannot access "stream.Readable" in client code.
Since browsers do not support Node's Core Modules, packages that use them must be polyfilled to function in browser environments. In an attempt to prevent runtime errors, Vite produces errors or warnings when your code references builtin modules such as fs
or path
.
Install the package as a dev dependency.
1# npm 2npm install --save-dev vite-plugin-node-polyfills 3 4# pnpm 5pnpm install --save-dev vite-plugin-node-polyfills 6 7# yarn 8yarn add --dev vite-plugin-node-polyfills
Add the plugin to your vite.config.ts
file.
1import { defineConfig } from 'vite' 2import { nodePolyfills } from 'vite-plugin-node-polyfills' 3 4// https://vitejs.dev/config/ 5export default defineConfig({ 6 plugins: [ 7 nodePolyfills(), 8 ], 9})
The following options are available to customize it for your needs.
1import { defineConfig } from 'vite'
2import { nodePolyfills } from 'vite-plugin-node-polyfills'
3
4// https://vitejs.dev/config/
5export default defineConfig({
6 plugins: [
7 nodePolyfills({
8 // To add only specific polyfills, add them here. If no option is passed, adds all polyfills
9 include: ['path'],
10 // To exclude specific polyfills, add them to this list. Note: if include is provided, this has no effect
11 exclude: [
12 'http', // Excludes the polyfill for `http` and `node:http`.
13 ],
14 // Whether to polyfill specific globals.
15 globals: {
16 Buffer: true, // can also be 'build', 'dev', or false
17 global: true,
18 process: true,
19 },
20 // Override the default polyfills for specific modules.
21 overrides: {
22 // Since `fs` is not supported in browsers, we can use the `memfs` package to polyfill it.
23 fs: 'memfs',
24 },
25 // Whether to polyfill `node:` protocol imports.
26 protocolImports: true,
27 }),
28 ],
29})
1[ 2 '_stream_duplex', 3 '_stream_passthrough', 4 '_stream_readable', 5 '_stream_transform', 6 '_stream_writable', 7 'assert', 8 'buffer', 9 'child_process', 10 'cluster', 11 'console', 12 'constants', 13 'crypto', 14 'dgram', 15 'dns', 16 'domain', 17 'events', 18 'fs', 19 'http', 20 'http2', 21 'https', 22 'module', 23 'net', 24 'os', 25 'path', 26 'process', 27 'punycode', 28 'querystring', 29 'readline', 30 'repl', 31 'stream', 32 'string_decoder', 33 'sys', 34 'timers', 35 'timers/promises', 36 'tls', 37 'tty', 38 'url', 39 'util', 40 'vm', 41 'zlib', 42]
No vulnerabilities found.
No security vulnerabilities found.