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

Else without braces and spaces gets concatenated to function names #3419

Closed
CadenP opened this issue Mar 4, 2020 · 1 comment · Fixed by #3421
Closed

Else without braces and spaces gets concatenated to function names #3419

CadenP opened this issue Mar 4, 2020 · 1 comment · Fixed by #3421

Comments

@CadenP
Copy link

CadenP commented Mar 4, 2020

Expected Behavior

else and following function name should be separated by a space.

Actual Behavior

else is combined with the function name.

Context

This is found in the npm history module in file history.js of the v5 beta (in the installed module; I can't find it on GitHub). As such, I cannot modify it on my own. The file looks to have been previously minimized, and is valid until Rollup is run on it in my project.

The code as it appears is as follows (edited for brevity):

if(null!=e){/* ... */}else"production"!==process.env.NODE_ENV?x(!1,"You are trying to block a POP navigation ..."):void 0;else u("POP")

My config uses @rollup/plugin-replace to replace process.env.NODE_ENV with, in this case, a non-"production" string, which then results in the following code after Rollup completes:

if(null!=e){/* ... */}elsex$2(!1,"You are trying to block a POP navigation ...");else u("POP");

The resulting error is Uncaught SyntaxError: Unexpected token 'else', which is pointing to the else u("POP"); part of the code, since the previous else was converted to elsex$2.

@lukastaegert
Copy link
Member

Thanks for spotting this, fix at #3421.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants