-
Notifications
You must be signed in to change notification settings - Fork 508
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
breaks are transpiled to return inside then #509
Comments
So, seems like this is due to rpetrich/babel-plugin-transform-async-to-promises#49. Can |
Thanks for tracking down the root cause @CyriacBr ! That certainly seems problematic 🙁 As far as I know, TSDX uses it because it is a syntax transform instead of a runtime polyfill, therefore no need to use There are some alternatives, like I'm not 100% sure if there's a way to disable it with a custom |
For now I'm going to override the rollup config and only use |
Ok sure, overriding Can also override I'm looking to add a Babel preset to help make customizing these types of things easier, #383 has some progress on that. |
Alright. For the time being I ended up forking TSDX and removed anything babel related. If anyone passing by and encountered the same issue, you can thing my fork here, and it's published. I'm fine with TS's runtime polyfill. TSDX has been my go-to initializer for many months now, thanks a lot for setting up that. |
Ok, I don't normally recommend forking and the other maintainers recommend using I'm also pretty sure this can be worked around with just a |
Yes, that's what I initially wanted to do, but then I realized I'd have to perform the same process for each new project. That'd defeat the process of using a initializer like TSDX. I wanted something that just works out of the box without me copy-pasting stuff from previous projects. |
Ah gotcha, that makes sense. Yea I can see why some workarounds can be annoying for people with multiple packages, though you might not need this everywhere. The other option is to create a shareable // tsdx.config.js
module.exports = require('@cyriacbr/tsdx-config-no-babel') Though if something like this is officially adopted (I'm planning on making an RFC soon), it would probably look more like a plugin than a shareable config: // tsdx.config.js
const noBabelPlugin = require('@cyriacbr/tsdx-plugin-no-babel')
module.exports = {
rollup (config) {
noBabelPlugin(config)
// ...
return config
}
} You can of course do either (or both) unofficially though.
Yea, unfortunately since it's upstream and hasn't been responded to in ~3 months it might take a while 😞 . In the meantime, your fork is likely to become out-of-sync, so it becomes a maintenance burden for you to update 😕 |
Looks like there was another incorrect transpilation brought up from this plugin: #423 / rpetrich/babel-plugin-transform-async-to-promises#53 . EDIT: Also seems like #190 is related. But that doesn't seem to error if it's used standalone Would probably be good to consider replacing this, especially since it hasn't been maintained the past few months (although regenerator maybe the only good alternative) 😕 |
Another comment on that issue revealing more broken code: rpetrich/babel-plugin-transform-async-to-promises#49 (comment). And still no response / maintenance. At this point, I think it would be optimal to switch to regenerator because at least the code it produces is actually correct and not broken in subtle, hard-to-detect ways. I'm also not sure really how much difference in weight it adds as a polyfill because |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Not to just add unnecessary noise, but this drove me crazy! I discovered even more broken examples where the emitted code would literally use things like One of the main reasons I'm writing this comment is so people who search something like Thank you @agilgur5 and @hb-seb for trying to resolve this! I hope it can be resolved soon. |
@allcontributors please add @CyriacBr for bug |
I've put up a pull request to add @CyriacBr! 🎉 |
|
Current Behavior
While working on my code I noticed a bug that led to my transpiled files and I saw that
tsdx
was incorrectly transforming mybreak
inside switch cases toreturn
.I thoughts that was rather odd so I created a sample project with the following code to pinpoint the issue:
When running
tsdx build
, this is what I get:As you can see, inside
test
,break
s insidethen
are transformed toreturn
s, which is NOT correct. Theconsole.log
line would never be reached.Expected behavior
break
s insidethen
should staybreak
s.Suggested solution(s)
No idea. The problem may come from babel or rollrup or one of their plugins.
Any idea what may cause the problem?
Your environment
The text was updated successfully, but these errors were encountered: