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

Support multiple SWC entries #177

Closed
hjoelh opened this issue Apr 10, 2022 · 5 comments
Closed

Support multiple SWC entries #177

hjoelh opened this issue Apr 10, 2022 · 5 comments
Labels
Feature Request Request for new feature or modification of existing one

Comments

@hjoelh
Copy link

hjoelh commented Apr 10, 2022

Question

Hey @wessberg, does the swc integration in this plugin support an array of options like this?
swc-project/swc#1877
https://swc.rs/docs/configuration/compilation#multiple-entries
Cannot seem to get it to work

Thank you

@wessberg wessberg added the Feature Request Request for new feature or modification of existing one label Apr 13, 2022
@wessberg
Copy link
Owner

It does not currently support that, no. Could you provide me an example of what you want to achieve with multiple configs, maybe simply your swc config? Then I'll have a better understanding of the use case. I'll mark this as a feature request.

@wessberg wessberg changed the title Does support an array of options for swc? Support multiple SWC entries Apr 13, 2022
@hjoelh
Copy link
Author

hjoelh commented Apr 13, 2022

Similar to swc-project/swc#1877
I believe you would need an array of options to allow swc to complile tsx and jsx?

@wessberg
Copy link
Owner

wessberg commented Apr 13, 2022

The original use case from that issue, as well as the tsx/jsx use case is not relevant in the context of rollup-plugin-ts, though, as the TypeScript-specific syntax is always stripped by the TypeScript Compiler APIs, which then leaves SWC with the responsibility of continuing on from there and lowering that to whatever ES version you're targeting.

In other words, there's no point in having something like "parser": "typescript anywhere in your swc config when you use rollup-plugin-ts, as the TypeScript-specific syntax is always gone at the point in the compilation process when swc takes over.

This FAQ entry from the README explains this in more details. It's about Babel, but the same principles apply for swc.

Still, I'll see if I can support this multi-entry SWC feature, but you should know that in your case you won't actually need it, as you can just leave out the TypeScript part of your swc config.

@hjoelh
Copy link
Author

hjoelh commented Jun 1, 2022

Thank you @wessberg. Does this still apply now with v3?

@wessberg
Copy link
Owner

wessberg commented Jun 7, 2022

In v3, this is now relevant, as swc is potentially used for stripping away TypeScript features as well.

I've looked into this issue and added support for multiple swc configs. However, the original issue you linked to isn't relevant here, as you can just use syntax: "typescript" in you swc config at all times, and it will be able to parse both .js and .ts files without problems, so long as you set allowJs: true in your tsconfig.json file!

I imagine there are tons of reasons why you may want to use multiple swc configs, however, and so I'm happy to support it. It will be available in the next release, which I'll release shortly.

@wessberg wessberg closed this as completed Jun 7, 2022
wessberg added a commit that referenced this issue Jun 7, 2022
…e importHelpers: true to avoid a potential tslib error when babel or swc is used for all types of syntax
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request Request for new feature or modification of existing one
Projects
None yet
Development

No branches or pull requests

2 participants