-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Fix __importDefault when used on typescript libraries #51474
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
Conversation
@typescript-bot pack this |
Heya @jakebailey, I've started to run the tarball bundle task on this PR at d25da73. You can monitor the build here. |
Hey @jakebailey, I've packed this into an installable tgz. You can install it for testing by referencing it in your
and then running There is also a playground for this build and an npm module you can use via |
This does fix the issue, but, I'm not 100% sure this is good or not. |
Not sure if this is any help, but esbuild mention this in their docs |
Yeah, I've seen that, and https://github.com/evanw/bundler-esm-cjs-tests. Unfortunately it seems like in addition to this other stuff, tslib / TS's helpers are another aspect that need to be considered, so I don't know if I can extract a decision out of that. I'll just have to test a bunch of cases, I guess. |
A table of behaviors, where
Without hacking things to drop |
Maybe @weswigham or @rbuckton have some insight here? (See also the issue in question, #51473.) |
I'm not a huge fan - we tell people not to do this all the time. Since we only want this for compat, I imagine manipulating the marker may be better. Which, on that note, can't we make the marker not be emitted by using |
I haven't found a way yet. esbuild's Also, I guess I can just hack it... |
Wait, I'm wrong, |
Hm, but that only helps the bundler. It breaks everything else :( |
Wot? It's definitely a runtime feature we transpile to |
With a hack in place to drop this helper:
So, that restores the status quo. See also evanw/esbuild#1971 but this does seem to be exactly the thing the esbuild docs refer to. I was unable to get the suggestions there to work; neither |
Huh, you're right. I must have tested and gotten an error for this a while ago and then assumed it was because |
Okay, changed to
So, this makes us match old TS when bundled, which was the goal. |
I can't read. It's fine. |
This should be final now, if you wanted to take another look. I plan to add smoke tests for this to #51464. |
Fixes #51473