You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What is the current behavior?
If I configure DefinePlugin with 'process.env': {...} format, some env variables which is not specified to the plugin is replaced with { /* full content of process.env I specified */ }.SOME_UNDEFINED_KEY, though the evaluated value is obviously undefined.
It'll affect bundle file size if I forget specifying some env variables, or if dependencies of my project use their custom env variables like SC_ATTR of styled-components.
I know 'process.env.SOME_ENV_VAR_NAME': ... format is recommended. But I sometimes use destructuring assignment with process.env and I don't want to give up doing that because of its convenience.
If the current behavior is a bug, please provide the steps to reproduce.
When defining values for process prefer 'process.env.NODE_ENV': JSON.stringify('production') over process: { env: { NODE_ENV: JSON.stringify('production') } }. Using the latter will overwrite the process object which can break compatibility with some modules that expect other values on the process object to be defined.
I know the note. But as I mentioned, I wanted to use destructuring assignment with process.env 😭 I hope there will be some update on #5392. Perhaps it'll help me.
change logic will break other cases
Anyway, this comment is enough for me to close this issue. Thank you for your support!
Bug report
What is the current behavior?
If I configure DefinePlugin with
'process.env': {...}
format, some env variables which is not specified to the plugin is replaced with{ /* full content of process.env I specified */ }.SOME_UNDEFINED_KEY
, though the evaluated value is obviouslyundefined
.It'll affect bundle file size if I forget specifying some env variables, or if dependencies of my project use their custom env variables like
SC_ATTR
ofstyled-components
.I know
'process.env.SOME_ENV_VAR_NAME': ...
format is recommended. But I sometimes use destructuring assignment withprocess.env
and I don't want to give up doing that because of its convenience.If the current behavior is a bug, please provide the steps to reproduce.
Here is the repo to reproduce the issue.
https://github.com/whatasoda/webpack-define-plugin-report
webpack.config.js
index.js
Then the output file is like:
What is the expected behavior?
I'm happy if the output file becomes the same as when I specify
undefined
toSERVER
, like:I saw a similar is reported at #10425, but it seems not to be fixed yet.
Thank you in advance.
Other relevant information:
webpack version: 5.15.0
Node.js version: 10.15.3
Operating System: macOS Catalina Version 10.15.7
Additional tools:
terser-webpack-plugin: 5.1.1
The text was updated successfully, but these errors were encountered: