loadable-components
loadable-components copied to clipboard
Add SWC Plugin
https://swc-project.github.io/docs/usage-plugin
Proposal: create an @loadable/swc-plugin
that is similar to @loadable/babel-plugin
SWC is increasing in popularity. It is aiming to be a drop-in replacement for babel with some significant speed improvements. It already has a webpack loader.
There is some early interest in how it might integrate with create-react-app (https://github.com/facebook/create-react-app/issues/8060). Looking at which babel plugins create-react-app uses it seems like most of those things are supported by swc (with only a few exceptions).
Looking at my own projects, I see only a few things that are blocking me from switching to SWC.
- No support for
babel-plugin-macros
(which I could live without) - No support for
@loadable/babel-plugin
Generally everything else babel does for me is handled by swc preset-env (or isn't particularly vital to my projects).
Hey @heygrady :wave:, Thank you for opening an issue. We'll get back to you as soon as we can. Please, consider supporting us on Open Collective. We give a special attention to issues opened by backers. If you use Loadable at work, you can also ask your company to sponsor us :heart:.
Cross linking: https://github.com/kentcdodds/babel-plugin-macros/issues/144
It looks great, any PR is welcome!
Look like here is the documentation - https://swc-project.github.io/docs/usage-plugin
SWC
is written in rust
, however, plugin system exposed in JS... so eventually swc
would become a ~dragon~ babel it was created to kill.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Did anyone have a chance to look at this yet?
Look like here is the documentation - https://swc-project.github.io/docs/usage-plugin
SWC
is written inrust
, however, plugin system exposed in JS... so eventuallyswc
would become a ~dragon~ babel it was created to kill.
The plugin api's might be deprecated in the next versions of swc.
Warning: Passing the AST to the JS Plugin system is a performance bottleneck.
Therefore, we are concidering two approaches for the next SWC major version:
Creating a plugin system in Rust (#2337) Solve the bottleneck to keep a JS plugin system (#2175)
With that said, I believe the loadable plugin would be similar to the dynamic plugin from next.js.
We're in the same boat over here. I was looking at what would be needed to do this, but, I don't have enough knowledge with AST or the time available (unless I get granted time during work) to do this.
This is (AFAIK) the only thing that's stopping us from migrating over to SWC as well.
This is (AFAIK) the only thing that's stopping us from migrating over to SWC as well.
same here - updated links to Next.js implementation https://github.com/vercel/next.js/blob/canary/packages/next-swc/crates/core/src/next_dynamic.rs
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Perhaps a workaround could be to use babel only on the files containing @lodable() statements? For example by naming them something like MyComponent.loadable.tsx
(to make it easy to differenciate the babel-loader & swc-loader).
That is a good option and actually can lead to a better visibility over bundle structure.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
See https://github.com/swc-project/plugins/pull/76
And https://github.com/gregberge/loadable-components/issues/909