browserify / commonjs-assert

Node.js's require('assert') for all engines
MIT License
293 stars 57 forks source link

Can't find variable: process #56

Closed rubber-duck-software closed 1 year ago

rubber-duck-software commented 1 year ago

process is generally not defined in the browser environment. Before accessing properties on the process, we should verify process is defined

ljharb commented 1 year ago

This is a node module. process always exists.

However, if it's not, your bundler might be broken.

DetachHead commented 1 year ago

isn't this package supposed to support browsers? image

ljharb commented 1 year ago

@DetachHead yes, it does - the way all node modules properly support browsers is by working with the original node module bundler, browserify, and any other non-broken node module bundler.

Broken node module bundlers aren't the concern of package authors.

DetachHead commented 1 year ago

i'm using vite, which doen't add process by default and i think many other build tools behave the same. imo if a package is targeting browsers it shouldn't assume the bundler will always take care of missing node globals

ljharb commented 1 year ago

That means vite is broken. Node packages that target browsers have always assumed that, and as such, that assumption is correct.