Replies: 2 comments 8 replies
-
For context: our original process.env polyfill did do a simple find-replace on certain values, but we got a ton of bugs reported where find-replace just didn't cut it and ended up breaking code that would otherwise work. For that reason, we moved to a more powerful Now that we have that working, I actually agree that a much simpler For (2), can you share an example of a module checking for If we could add back the simple |
Beta Was this translation helpful? Give feedback.
-
Yep, I saw the simple find-replace in the code history. I was actually thinking of doing something a bit more sophisticated by walking the AST like the current And yeah, now that I think about it more I guess the modules I've seen check for |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently, Snowpack will include a (basic) polyfill for Node's
process
module if it detects any reference to a globalprocess
identifier. However:process.env
so they don't need a full polyfill, and for references toprocess.env.NODE_ENV
would actually benefit from having the value inlined (for optimization).process
to decide whether to run Node-specific or browser-specific code, and having a polyfill will confuse them into a sub-optimal path at best and outright break them at worst.I still think that the polyfill is a reasonable default but I believe we should be able to turn it off. I'd like to propose a new
installOptions.polyfillProcess
option with allowed values"basic"
(the current polyfill),"env"
(inlining of values frominstallOptions.env
only), and"none"
(ignore any references toprocess
).What do you think?
Beta Was this translation helpful? Give feedback.
All reactions