Skip to content

Commit c254699

Browse files
Merge pull request #79 from sebastianwessel/codex/make-lib-compatible-with-vite
Doc: add hint for setup with Vite
2 parents d82040b + 1583910 commit c254699

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

website/docs/index.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,28 @@ Cloudflare workers have some limitations regarding bundling. The developers of t
105105

106106
This library will be aligned soon, to support cloudflare as well.
107107

108+
### Vite
109+
110+
When bundling for the browser with [Vite](https://vitejs.dev/), the `memfs` dependency requires polyfills for Node.js built-in modules. Install a Node polyfill plugin and prebundle `memfs`:
111+
112+
```ts
113+
import { defineConfig } from 'vite'
114+
import rollupNodePolyFill from 'rollup-plugin-polyfill-node'
115+
116+
export default defineConfig({
117+
plugins: [rollupNodePolyFill()],
118+
optimizeDeps: {
119+
include: ['memfs']
120+
},
121+
build: {
122+
rollupOptions: {
123+
plugins: [rollupNodePolyFill()]
124+
}
125+
}
126+
})
127+
```
128+
129+
108130
## Usage in Browser
109131

110132
Here is the most minimal example on how to use this library in the browser.

0 commit comments

Comments
 (0)