DefinePlugin not working with destructure of multiple env vars
See original GitHub issueDo you want to request a feature or report a bug? Bug
What is the current behavior?
Using const { a, b } = process.env
results in a client-side exception, where both variables have been defined using DefinePlugin
.
Note: const { a } = process.env
works perfectly
If the current behavior is a bug, please provide the steps to reproduce.
Compile const { a, b } = process.env
with Babel and the DefinePlugin, and notice that code intended for the client contains reference to process.env
which does not exist in the browser environment, and throws exceptions
What is the expected behavior?
- Constants
a
andb
in the example above should be replaced with the values provided toDefinePlugin
. - No exceptions should be thrown when loading the bundle into a browser environment.
If this is a feature request, what is motivation or use case for changing the behavior?
Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.
Chrome 59 / node:v8.1.2 / yarn v0.24.6 / webpack v3
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:8 (5 by maintainers)
You could try this:
Thanks 😃