-
-
Notifications
You must be signed in to change notification settings - Fork 148
Remove process/browser.js
#403
Comments
I'm currently facing the same issue |
@developit Thoughts? Seems like a simple fix. Also forgot this was still here I can take care of it but I don't have collab on this repo |
Just to document it here: |
This also affects people using the browser version of preact-compat, where |
🤔🤔🤔🤔🤔 What if we inverted the const DEV = typeof process !== 'undefined' && process.env && process.env.NODE_ENV!=='production' In browsers, it will fail at In bundlers, after replacing the development const DEV = typeof process !== 'undefined' && process.env && 'development'!=='production'
// true production const DEV = typeof process !== 'undefined' && process.env && 'production'!=='production'
// false |
Or, maybe, even shorter: const DEV = typeof process !== 'undefined' && process.env.NODE_ENV!=='production' |
In continuation of #285, I found that
preact-compat
was forcing Webpack to include aprocess
shim.I was able to remove it locally by changing:
to this:
I can open a PR for this if you don't see a problem with it? Everyone & their mother uses some kind of bundler now, and all bundlers have a
replaceText
orDefinePlugin
capability.For example, with webpack, I did this, the oldest trick in the book:
Before:
After:
Worth noting that the
DefinePlugin
trick does not work unless this change is made. This is because instances of'process'
are found, thus loading the polyfill.The text was updated successfully, but these errors were encountered: