When used in Node (eg with Next.JS), unnecessarily overwrites `process` object
Closed this issue · 3 comments
Most polyfills don't mutate the object when it isn't needed, but this one seems to do so.
Context in this thread: openai/openai-node#226
Observed behavior when using this library in Node 18 with NextJS:
Object.prototype.toString.call(process) === '[object Object]'
Expected behavior:
Object.prototype.toString.call(process) === '[object process]'
The observed behavior is correct in a non-node context, like the browser; please don't change it for that. However, if used in Node, I would expect this library to not mutate process
.
I believe this is user error though, because one should not use polyfills if you're running on a Node environment, right?
The code that calls this library may not know whether or not it's being used in a Node context.
For example, they may be compiling the same slug to be deployed to both Node and non-Node contexts.
In my experience, it's common/expected/desired behavior for importing a polyfill to be a no-op when it's not needed (eg, importing this library when you're already in Node).
Does that make sense?
I suppose so, yeah!