Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi! Was going to write this as a comment but I thought a functional PR would be a nicer way to make a proposal.
A cleaned up version of this could resolve #943 in a way that didn't involve either inflating microbundle's size or completely rewriting the whole library around SWC.
Basically, it looks for the
@swc/core
dependency, and if it's found, assumes that the user wants to useswc
instead of babel or typescript. But@swc/core
isn't a dependency of microbundle. Which means most users can just continue using microbundle as is and not be affected. People who want to try microbundle out with SWC just have to install@swc/core
which has the nice properties of being natural and intuitive for people who do want to use SWC, and unusual for anyone else.It does add
rollup-plugin-swc3
as a proper dependency of microbundle, because that's just a small javascript module, and it seems like the sort of thing microbundle should save users from having to worry about (whether they should userollup-plugin-swc
,rollup-plugin-swc2
orrollup-plugin-swc3
, and how to configure the chosen package).I tried on a small typescript project with no dependencies, with an output of about 4kb. With swc it took about 6s, without it took 21s (and using
--compress false
, timings were 3s vs 19s , see point 4 below).Some things that should be addressed before this PoC were to be shippable (I didn't attempt to do this because I am not very knowledgeable about microbundle, babel, or SWC):
@swc/core
installed for unrelated reasons to opt out (e.g.--swc false
)target: 'es2018'
fairly arbitrarily. It should also respect any existing swc config detected, if present.src/index.js
to make the diff easy to ready, but probably some refactoring should be done@swc/core
apeerDependency
withpeerDependenciesMeta.optional = true
If this goes well and people start using it, after a few months of the community helping flush out any issues, maybe something like the solution suggested by @developit in #943 (comment) could be done with SWC. But the advantage of doing this way first is that we could likely do exactly the same thing with rollup-plugin-esbuild, and effectively support users with both. The community seems pretty evenly split between the two, and they're both an order of magnitude faster than typescript or babel.