-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Disable ES transforms (#602) (#622) #623
Conversation
Codecov Report
@@ Coverage Diff @@
## main #623 +/- ##
==========================================
+ Coverage 82.16% 82.18% +0.01%
==========================================
Files 56 56
Lines 5870 5876 +6
Branches 1324 1327 +3
==========================================
+ Hits 4823 4829 +6
Misses 763 763
Partials 284 284
Continue to review full report at Codecov.
|
Benchmark resultsBefore this PR: 324.7 thousand lines per second Measured change: 0.21% faster (0.77% slower to 1.35% faster) |
Oops, I missed |
Thanks! I'm on vacation without my computer for the next 5 days or so, but can take a closer look when I get back. You're right that it's a bit more involved than I was thinking, thanks for working through the details. A few initial thoughts:
|
@alangpierce you're right. I've reverted all changes in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! I'll merge this PR, but with a few follow-ups before releasing:
- The extra
await
is buggy, I believe. I can write a quick test for that and remove it in a follow-up PR. - The class transform should be disabled as well. Some of the details were discussed back in Add disableLegacyClassFieldSupport option #304 , the main challenge is that we still want to transform TypeScript constructor initializers. Hopefully it'll be reasonable to implement, but it does require some thinking about how to best modify
getClassInfo
and related code. - I can update the README to mention the new flag.
have you considered migrating to Yarn2?
Thanks for the suggestion, it has been on my radar, but I haven't prioritized it yet.
if (token.isAsyncOperation) { | ||
this.resultCode += "await "; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this await
code should actually be skipped altogether here.
It's for cases like a?.b(await f())
. Normally, the inner code is wrapped in an arrow function, but if it uses await
, then it needs to instead use an async arrow function and be wrapped in a different wrapper function _asyncOptionalChain
and the whole thing needs to have an await
at the front. If we're using native ?.
, then the extra await
isn't necessary (and could potentially cause problems).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I completely forgot to update README...
Regarding await
it seems you're right, I can't recall what use case I had for this.resultCode += "await "
.
But as all tests pass, so probably it's safe to go without it.
Thanks for your help, I will close #622 !
Follow-up to #623. With transforms disabled, we should just early return even in the async case.
Follow-up to #623. With transforms disabled, we should just early return even in the async case.
The idea of this PR is to allow to opt-out the transformations of "modern" ES features like optional chaining, numbers separators, etc.
Please check issues #602, #622 for more details.
I've tried to implement such a flag, as @alangpierce suggested in #602.
The implementation appeared bigger than I expected as I had to implement changes in 3 main modules:
RootTransformer
– omit unnecessary ES transformersHelperManager
– disable unused helpers emitting (reverted after finding in Disable ES transforms (#602) (#622) #623 (comment))TokenProcessor
– disable helpers insertion into a final code, e.g._optionalChain(...)
wrapper.All described scenarios were covered by test cases.
I can't say that this fix is the ideal solution, so please let me know you think we need to fix this in another way.
P.S. Small comment from contribution experience – have you considered migrating to Yarn2? :)