-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
defining process
as true
breaks usage of libraries looking for environment variables
#6763
Comments
I was just about to report the exact same issue. In my case our project used https://github.com/nygardk/react-share, which had This also appears to overwrite whatever was set previously as |
thats a good point that i forgot to address in my initial issue. i did attempt to use the define plugin to override what was set as |
Here's the workaround I put in place for now (requires full control mode): module.exports = ({ config, mode }) => {
const plugins = [
...config.plugins
// remove instances of DefinePlugin to work around:
// https://github.com/storybooks/storybook/issues/6763
.filter((plugin) => !plugin.definitions),
// replace the default DefinePlugin instance with a custom one that tries to
// preserve everything except for `process: true`
new webpack.DefinePlugin({
"process.env": {
NODE_ENV: JSON.stringify(mode.toLowerCase()),
NODE_PATH: JSON.stringify(""),
PUBLIC_URL: JSON.stringify("."),
},
NODE_ENV: JSON.stringify(mode.toLowerCase()),
}),
];
return {
...config,
plugins,
};
}; |
@libetl Didn't you run into this bug and fix it? Can you issue a small PR for that? |
Exactly this bug so I made a workaround in poc/addon-editor branch |
The above snippet looks good, I also suggest to leave a value for the |
@libetl Can you make a PR onto |
Will do |
pull request is now opened |
since i saw that this got merged, i decided to give it a try again and found that i was still presented with the same error. it took me a bit to realize that i needed to use the running with the
but the "Preview webpack config" (i didnt realize that two independent configs needed to be changed when i opened this issue) still shows a problematic config:
does this mean that both need this change applied? |
@travi You should be able to get this on the |
from what i can tell, the change is more necessary on the preview config than on the manager config. i was able to apply the workaround from above to get past it for now, but the change that was merged does not fully resolve the issue for me. |
@travi Thanks for the quick response. We'll try to get it taken care of soon. |
thank you 🙏 |
Fixed in #6946 Released in https://github.com/storybookjs/storybook/releases/tag/v5.1.0-rc.4 |
Describe the bug
process
is defined astrue
using the webpack define plugin.true
does not match the expectation thatprocess
is an object.this results in libraries, even when attempting to be defensive about the presence of
process
, attempting to perform object actions against a boolean and therefore throwing errors at runtime.the specific example that is giving me trouble is with the browser version of
debug
.To Reproduce
Steps to reproduce the behavior:
debug
into one of your storiesExpected behavior
process should either be left as undefined and expected to be added by projects that need it or at least defined using a shape that matches the expected contract. please also see this comment from a maintainer of debug about the contract of
process
error
the error thrown in the case of `debug`
Code snippets
https://github.com/visionmedia/debug/blob/5c7c61dc0df0db4eb5de25707d8cd1b9be1add4f/src/browser.js#L216
System:
v5.1.0-alpha.40
, but have confirmed that it still exists inv5.1.0-beta.0
Additional context
i did add a comment yesterday evening against the commit that appeared to add this definition. its it can be bad form to comment against closed issues, i figured a more formal issue could be better. please don't see the double filing as any additional pressure from me. i'm just trying to follow up to get you the info that aligns with your normal process.
The text was updated successfully, but these errors were encountered: