Alt warnings in production mode
Hi, I use alt with react and webpack's uglifyjs plugin. After creating minified version of browserified js bundle, alt prints warnings in chrome's console:
ReferenceError: A store named e already exists, double check your store names or pass in your own custom identifier for each store(…)
Is it possible to not show warnings/errors when NODE_ENV is set to production, just like React has it now?
Many thanks.
babel-plugin-dev-expression strips warnings, but it's not going to do anything for actual errors. Errors are errors, after all.
It's possible yeah. I think if we move to npm package warn we get that for free.
I'm thinking about stripping only warnings. babel-plugin-dev-expression does what React has implemented in their code, so it checks if process.env.NODE_ENV !== 'production', then shows warnings.
Do you think it's better to use babel-plugin-dev-expression for it or you could do similarly to React?
Thanks.
doesn't the package warning do this?
I mean if you could wrap your Alt warning messages in condition so they wouldn't be shown if NODE_ENV is set to production.
warning doesn't log in production, but you need the Babel hook to strip out the calls and messages from production builds entirely.
What Babel hook should I use then? I though that if I set NODE_ENV to production with webpack.DefinePlugin, I won't have any warnings visible.
babel-plugin-dev-expression, like I mentioned, but the library should be running that Babel transform, not you.
I installed babel-plugin-dev-expression (have it in devDependencies in package.json) and added .babelrc file:
{
"stage": 0,
"plugins": [
"dev-expression"
]
}
Could you tell me what I'm doing wrong (I still have warnings)?
Thanks.
It's not you, it's alt.
I think it is not a good idea to hide warning/error, it's better to solve them.
alt store names are inferred from the store class name. Here, you 'uglifies' your js, that means that the class name could be change by the uglify tool. That way, you could have many stores with the same name and i think it is not a good idea…
When you create your store you can simply name it, makes it disappear this warning. (Something like export default alt.createStore(TheStoreClass, 'the_store');)
@fraisse is correct. Provide a unique store name in the createStore method. Or, specify a static displayName in the store class, e.g. static displayName = 'the_store'.