foxhound87 / rfx-stack

RFX Stack - Universal App
MIT License
419 stars 42 forks source link

mobx-react-form "constructor.name" is mangled by uglify. [use --keep-fnames] #31

Closed richieio closed 7 years ago

richieio commented 7 years ago

Hi Claudio,

Thank you so much for the great rfx-stack and mobx-react-form. I follow and use it a lot.

I've been struggling with this strange issue though. When I set a value of a form field manually, it works in development but not in production environment.

For instance, in the AuthFormLogin.jsx file if I add a button

` <button type="button" className="btn" onClick={() => form.update({ email: 'test' })}

Test button`

I should be able to set the form field value.

This works in development web:dev, but not in production web:prod. Same with form.$field.set('value'). Any idea?

Thank you much appreciated.

foxhound87 commented 7 years ago

Hi @richattack

I made some tests and it is a minification issue.

For now remove -p for the build:client:web script and the UglifyJsPlugin into the webpack/config.client.build.js.

I will find a solution asap.

foxhound87 commented 7 years ago

Now should work.

I introduced keep_fnames for the uglify mangle.

This because I'm using .constructor.name to check the name of the Field Class into the mobx-react-form package, which is mangled by uglify.

Please let me know if it's all ok now.

richieio commented 7 years ago

Thanks so much Claudio!!! Everything is OK.

foxhound87 commented 7 years ago

You are welcome! Thanks to you for your contribution, I didn't found this issue before you do. This fix has fixed the umd build too.