davidmyersdev / vite-plugin-node-polyfills

A Vite plugin to polyfill Node's Core Modules for browser environments.
MIT License
301 stars 22 forks source link

If I define --mode on the cmdline I get 'ReferenceError: Buffer is not defined' #46

Closed MikeMitterer closed 1 year ago

MikeMitterer commented 1 year ago

Any ideas? If I run vite without --mode it works. The thing is I have .env.live where I store "Live-spcific" vars...

[Update] I think it's this line: https://github.com/davidmyersdev/vite-plugin-node-polyfills/blob/main/src/index.ts#L183C45-L183C47

Other modes beside 'development' should not break your nice lib... https://vitejs.dev/guide/env-and-mode.html

davidmyersdev commented 1 year ago

Hey there, @MikeMitterer. 👋 That absolutely makes sense, and it looks like I can rely on env.command to determine whether it's running in "dev" or "build" mode. Thanks for bringing this to my attention!

davidmyersdev commented 1 year ago

This has been released in v0.15.0.

MikeMitterer commented 1 year ago

@davidmyersdev Very cool + Thanks!