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
Why does mobx force a production build in browser mode? #2296
Comments
I can't say why is there such a configuration, but generally, it's better if you can reproduce the issue in development. I can see it's originating from mobx/src/v4/core/derivation.ts Line 147 in 582a516
|
Thanks for your response. I understand why this particular error was thrown - I was mutating the state outside an action while enforcing actions. My concern is that this is a development server, and because it's forcing the .min version in browser mode, I'm getting obfuscated errors. This took me a frustratingly long time to track down because while I'm familiar with react, I've only used redux for state management before, so I'm not yet familiar enough with mobx to be able to look at this cryptic error and immediately see what is happening. It's especially frustrating because the error thrown by the development build makes it crystal clear what is happening. We're introducing react and mobx to a large legacy codebase with quite a few devs who are unfamiliar with both react and this style of state management. I am looking for the rationale behind this so I can figure out if I can solve this with a different config, if this is a bug that I can submit a PR for, or if this is something we're going to have to live with - which may change the calculus on which state management package we end up going with. Building in browser mode is necessary because other packages require it to build correctly for the browser. |
Ah, now I see what you mean and turns out it was actually me who did that change. I simply did not realize that field is used in development too. This is often confusing as there is no official specification on most of these fields and it depends on bundler which one it will use. In @mrtnbroder I see you were original author of that |
I am having the same issue as well (getting obfuscated errors in development environment with NODE_ENV set to "development") |
I think we can simply drop that field. IIRC it is mostly used in case your library has some different behavior in node vs browsers, but that is something we don't do. PR welcome! |
Hello! We came across an issue today with a development build providing obfuscated errors, and I'm hoping someone can provide some clarity as to why this is happening. We did confirm that the environment variable is appropriately set to "development", and our other packages (react, et. al.) are building correctly in development mode.
We've actually tracked the issue to this entry in
package.json
, which is forcing mobx to always use the minified file in browser mode:Which renders these lines in the entry point moot, as it replaces the
mobx.js
in the else block withmobx.min.js
:Can anyone help?
The text was updated successfully, but these errors were encountered: