Skip to content

Commit bb83b3a

Browse files
committed
Update docs
1 parent 0b75b93 commit bb83b3a

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

.npmignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/.pnp.cjs
2+
/.pnp.loader.mjs
3+
/.vscode
4+
/.yarn
5+
/.yarnrc.yml
6+
/src
7+
/test
8+
/tsconfig.json
9+
/vite.config.ts

README.md

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
# vite-plugin-node-polyfills
22

3-
A Vite plugin to polyfill native Node modules for the browser
3+
A Vite plugin to polyfill Node's Core Modules for browser environments. Supports `node:` protocol imports.
4+
5+
### Why do I need this?
6+
7+
```
8+
Module "stream" has been externalized for browser compatibility. Cannot access "stream.Readable" in client code.
9+
```
10+
11+
Since browsers do not support Node's [Core Modules](https://nodejs.org/dist/latest-v16.x/docs/api/modules.html#core-modules), packages that use them must be polyfilled to function in browser environments. In an attempt to prevent runtime errors, Vite produces [errors](https://github.com/vitejs/vite/issues/9200) or [warnings](https://github.com/vitejs/vite/pull/9837) when your code references builtin modules such as `fs` or `path`.
412

513
## Getting Started
614

@@ -30,15 +38,3 @@ export default defineConfig({
3038
],
3139
})
3240
```
33-
34-
## Why?
35-
36-
The following error can occur when a package references a native Node module without providing a polyfill. See [this Vite issue](https://github.com/vitejs/vite/issues/9200) for more info.
37-
38-
```
39-
Module "stream" has been externalized for browser compatibility. Cannot access "stream.Readable" in client code.
40-
```
41-
42-
## Attribution
43-
44-
Special thanks to [@FbN](https://github.com/FbN) for putting together [this gist](https://gist.github.com/FbN/0e651105937c8000f10fefdf9ec9af3d).

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vite-plugin-node-polyfills",
3-
"description": "A Vite plugin to polyfill native Node modules for the browser",
3+
"description": "A Vite plugin to polyfill Node's Core Modules for browser environments.",
44
"version": "0.3.2",
55
"author": "David Myers <[email protected]>",
66
"funding": "https://github.com/sponsors/voracious",
@@ -12,6 +12,8 @@
1212
},
1313
"keywords": [
1414
"node",
15+
"node-core-modules",
16+
"node-stdlib",
1517
"polyfills",
1618
"vite",
1719
"vite-plugin"

0 commit comments

Comments
 (0)