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

Add SWC Plugin #529

Closed
heygrady opened this issue Feb 24, 2020 · 14 comments
Closed

Add SWC Plugin #529

heygrady opened this issue Feb 24, 2020 · 14 comments

Comments

@heygrady
Copy link

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 (facebook/create-react-app#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.

  1. No support for babel-plugin-macros (which I could live without)
  2. 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).

@open-collective-bot
Copy link

Hey @heygrady 👋,
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 ❤️.

@heygrady
Copy link
Author

Cross linking: kentcdodds/babel-plugin-macros#144

@gregberge
Copy link
Owner

It looks great, any PR is welcome!

@theKashey
Copy link
Collaborator

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.

@stale
Copy link

stale bot commented Apr 24, 2020

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.

@stale stale bot added the wontfix label Apr 24, 2020
@stale stale bot closed this as completed May 1, 2020
@paul-vd
Copy link

paul-vd commented Oct 31, 2021

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 in rust, however, plugin system exposed in JS... so eventually swc 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.

@marwan38
Copy link

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.

@Perni1984
Copy link

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

@gregberge gregberge reopened this Dec 4, 2021
@stale stale bot removed the wontfix label Dec 4, 2021
@stale
Copy link

stale bot commented Apr 16, 2022

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.

@stale stale bot added the wontfix label Apr 16, 2022
@aplassen
Copy link

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).

@stale stale bot removed the wontfix label Apr 26, 2022
@theKashey
Copy link
Collaborator

That is a good option and actually can lead to a better visibility over bundle structure.

@stale
Copy link

stale bot commented Jul 10, 2022

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.

@ashsearle
Copy link

See swc-project/plugins#76

@theKashey
Copy link
Collaborator

And #909

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants