Skip to content
This repository has been archived by the owner on Dec 6, 2021. It is now read-only.

Fix issue with process object being clobbered #193

Merged
merged 6 commits into from
Jun 20, 2017
Merged

Fix issue with process object being clobbered #193

merged 6 commits into from
Jun 20, 2017

Conversation

zephraph
Copy link
Contributor

@zephraph zephraph commented Jun 19, 2017

This issue is similar to the one encountered in the below issue.

https://github.com/chentsulin/electron-react-boilerplate/pull/245/files

In my particular case I was depending on a package which was using readable-stream.

https://github.com/nodejs/readable-stream/blob/master/lib/_stream_writable.js#L53

In the above snippet, you can see process.browser and process.version. When you define process in an object as was done previously it'll actually clobber all the process object normalization that webpack does. This means that packages like readable-stream essentially become unusable.

@zephraph zephraph changed the title Fix issue with NODE_ENV not being output correctly in certain contexts Fix issue with process object being clobbered Jun 19, 2017
@egoist
Copy link
Owner

egoist commented Jun 20, 2017

there might be other properties besides NODE_ENV in env object

@zephraph
Copy link
Contributor Author

Good point. I backed it down to a level. I'm not sure what, if anything, webpack provides for process.env. This way you'll get whatever is configured with env but you won't overwrite the rest of what's in process.

@egoist egoist merged commit e658201 into egoist:master Jun 20, 2017
simon04 pushed a commit to webpack/webpack.js.org that referenced this pull request Jun 20, 2017
)

See these issues for references:

egoist/poi#193
https://github.com/chentsulin/electron-react-boilerplate/pull/245/files

Basically using something like the below example will break the process object compatibility that webpack includes. This just gives a warning about that. 

```javascript
new webpack.DefinePlugin({
   process: {
      env: {
         NODE_ENV: JSON.stringify('production')
      }
   }
})
```
@egoist
Copy link
Owner

egoist commented Sep 5, 2017

Ah overriding process.env still causes problem, the rest of process.env will be undefined... So I changed it again: db30e42

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

Successfully merging this pull request may close these issues.

2 participants