Skip to content
This repository has been archived by the owner on Sep 1, 2024. It is now read-only.

browserify doesn't replace NODE_ENV #267

Open
dwelle opened this issue Apr 5, 2019 · 4 comments
Open

browserify doesn't replace NODE_ENV #267

dwelle opened this issue Apr 5, 2019 · 4 comments

Comments

@dwelle
Copy link

dwelle commented Apr 5, 2019

Unless I misunderstand, resulting bundle from browserify still contains some process.env.NODE_ENV references because the prop-types package depends on a another package that does not specify browserify.transform in its package.json. In particular, the react-is package (haven't checked if there are others).

npx browserify -r prop-types | grep NODE_ENV

The browserify.transform is a non-global transform, thus it doesn't transform dependencies.

@ljharb
Copy link
Contributor

ljharb commented Apr 6, 2019

This is true; it's pretty important to apply envify at the app level. I'm not sure how else to address this issue.

The only other dep is object-assign and there shouldn't be anything env-specific in there.

@dwelle
Copy link
Author

dwelle commented Apr 6, 2019

Yea, one way is for the user to run custom global transform like:

stream.transform(envify(), { global: true })

which is something the envify docs don't even mention (probably because transforming node_modules is not recommended, but necessary in this case).

Other solution is to go through all deps that react owns (such as react-is) and add the transform into package.json same as other react libs already do. But problem are deps that react doesn't own :/.

EDIT: closed by mistake -- keep/close as you will

@dwelle dwelle closed this as completed Apr 6, 2019
@dwelle dwelle reopened this Apr 6, 2019
@ljharb
Copy link
Contributor

ljharb commented Apr 6, 2019

Typically bundles are where the distinction matters, and bundlers do typically replace it in the entire bundle - it's not much of a problem for node.

Perhaps you could file an issue on the react repo for react-is, and then this one can be closed?

@oliviertassinari
Copy link

It feels like removing the dependency on loose-envify would make sense. Referencing: facebook/react#27748 where this is discussed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants