-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
feat(plugin-legacy): Add experimental option to use swc. #4105
Conversation
Thanks for the PR @umidbekk, this is an interesting alternative! We'll discuss this with the team. My personal take is that we could first try to have this approach as a separate |
Hello @umidbekk, we discussed this proposal with the team and we think this approach is worth exploring. The only issue apart from polishing this solution is that for the moment we should keep both babel and swc (in case people want to keep using the babel based alternative due to maturity and stability), and introducing this dependency could be heavy for people not using it. |
Hi @patak-js thank for the review! I also hate the idea of installing optional packages (especially with giant binaries), and I agree that using separate package is the best way to approach. One think that stops me now is vite_skip_esbuild flag. But I have an idea how to handle that - add use esbuild plugin that will transform But there another problem I see with plugin-legacy - it has two purposes:
Maybe using separate plugin to generate polyfill bundle was the better approach. But again, Also, I don't even use polyfill bundle myself, and use I guess it's better to start with the minimal working approach, and start adding things on demand. I will close this, and start working on the esbuild plugin proposal for the |
Sounds good. Since it will be your plugin, I think you should design it as you see fit. The idea of keeping the API as close as possible was to enable an easy transition in the future if we go that road. But it would be a new mayor version and the API can be changed if there are good reasons.
Thanks again and please share your work later on https://chat.vitejs.dev! |
Should we somehow promote it especially on https://github.com/vitejs/awesome-vite? |
Let's wait to see how the plugin evolves and is being used, for sure it should be listed there. I think there isn't any concept of that in awesome-vite, to me a link from the readme of plugin-legacy is good here (and maybe a note in the production section of the docs). |
As this PR is now closed, I have ported it with the latest plugin-legacy and released the package |
Description
swc
usageAdditional context
Cons:
Visitor
class from@swc/core/visitor
, since it was breaking output code in weird ways, and I din't want to waste time on investigationinputSourceMap
does not workVisitor
api is very limited (not to mention is buggy as I've pointed before) and better to be avoided (missingsuper
call can break whole traverse chain)Pros:
Maybe changing direction, and instead of transforming the final chunk it would be better to run swc in
transformation
hook, and get rid of custom plugins. But it will require a lot of internal changes, and better to be extracted as an external plugin.What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).