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
[parcel 2, regression] parcel optimizes away parentheses and makes valid code invalid / makes terser fail #5759
Comments
A bug in astring: davidbonnet/astring#435 |
Thanks @mischnic. I checked that it wasn't babel but didn't think of astring. |
Would it be a good idea to add a test case for it anyways so someone notices if it breaks again? |
astring itself has tests here: https://github.com/davidbonnet/astring/tree/master/src/tests But after fixing it in astring, we should add a test here as well: https://github.com/parcel-bundler/parcel/blob/v2/packages/shared/babel-ast-utils/test/fixtures/await.js |
Clearly overlooked the precedence of await and yield operators four years ago 🤦♂️: davidbonnet/astring@a7b3dd2 In case you're using Edit: The precedence of |
@davidbonnet Thank you for the quick fix and release! |
First fix introduced a regression regarding the |
Thanks a lot guys for the quick fixes! Hope the PR makes it into the next nightly. |
🐛 bug report
I am lacking words for this issue as I don't know what the features are called. But basically code where the result of an assignment to a variable is
await
ed is correctly built inparcel@2.0.0-nightly.511
but breaks shortly thereafter and is broken in the newest version.🎛 Configuration (.babelrc, package.json, cli command)
Please checked attached .zip file, run
npm install
and thennpm run build
🤔 Expected Behavior
the code should transpile to this or similar, like it does in version 511:
😯 Current Behavior
Parcel removes parantheses around the definition of the variable, breaking the code:
When running parcel with
--no-optimize
it successfully builds to this:But that code is illegal and throws
Uncaught SyntaxError: invalid assignment left-hand side
when being executed.💁 Possible Solution
Revert back to what the old version did which is preserving the parantheses and not breaking the code.
🔦 Context
I moved all my css imports to use
bundle-text
after I got to know this workaround which makes the css minified. When building all my scripts again to check the transpiled code for unminified css one project failed to build. I investigated and opened this bug report.💻 Code Sample
parcel-parantheses-bug.zip
This is the line it can't deal with:
return await (obj.promise = (await fetch("/")).text())
🌍 Your Environment
The text was updated successfully, but these errors were encountered: