Skip to content
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

Production builds are broken if I don't put an eval ( '' ) in my code #196

Closed
fabiospampinato opened this issue Sep 5, 2018 · 3 comments

Comments

@fabiospampinato
Copy link
Contributor

fabiospampinato commented Sep 5, 2018

I've written a note taking app using this framework, and I've stumbled on a super weird bug: everything works fine during development, but when I build the app for production (npm run build:mac and open releases/mac/Noty.app) the textarea/editor of the app loses focus as soon as something is typed, so it's unusable.

At first I thought there was a bug in my code, but then I found the "fix":

  1. I wanted to put a debugger statement in the render method of my React app in order to check what was going on, but that didn't work on the production build, maybe it got stripped out, makes sense
  2. I put an eval ( 'debugger' ) there instead, and that worked, but now the bug doesn't manifest itself
  3. Just putting an eval ( '' ) here fixes the problem

My guess is that in your build toolchain there's some tool making a stupid optimization of that render method or something, which it can't do in the presence of an eval call because it's not sure if that optimization is safe to make. Just a guess.

Could you please take a look at this? I've wasted a bit of sanity trying to debug this, and the "fix" I found for it is super ugly.

@fabiospampinato
Copy link
Contributor Author

fabiospampinato commented Jan 20, 2019

This was actually a problem of the minifier, more specifically the keep_fnames option, which is set to false by default.

Maybe the default configuration should be safer than that.

@loopmode
Copy link
Collaborator

loopmode commented Jul 9, 2019

I agree that we should set keep_fnames to true.
We don't need to save bandwidth by mangling names, and obfuscating code for "protective measures" shouldn't be the scope here..

@loopmode
Copy link
Collaborator

loopmode commented Jul 9, 2019

Enable keep_fnames: #304

@develar develar closed this as completed in 5f0caa1 Jul 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants