-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
Guidelines on implementing plugins? #470
Comments
Currently plugin system is not ready yet. I'm considering 1. Embed plugins in swc binaryThis make deploying plugins easier, and allow me maintaining plugins on swc update. Also, this option allows me to update plugins when types of ast node is changed. Note: I can write plugins. (It's an easy task to me) 2. dll / so basedSeems ideal option, but dependency hell might occur. 3. Custom binary built by user with additional transformIt means building a rust library / command line app which depends on swc. If you pick binary, deploying would not be that hard. See: https://github.com/izelnakri/mber-rust 4. IPC-based pluginprotobuf work in this way, and it allows writing plugin in any language. 5. js plugin interfaceI thought this is the best, but context switching and serializing native object is really slow. 6. DSLThere's some languages written in rust. 7. njs form nginxThis seems attractive, but some investigation is required. Which option do you prefer? Edit: typo |
Closing in favor of #471. |
@cyjake |
Awesome! I'll try implementing babel-plugin-import this week |
Hey @cyjake ! Are there any news about the plugin? :-) |
@matzeeable @kdy1 Probably a bit too late for this experiment since the js api will be deprecated in swc v2, anyway here it goes https://github.com/cyjake/swc-plugin-import/blob/master/src/import.ts#L32 How do I replace one import { debounce, throttle } from 'lodash'; should be replaced with, import debounce from 'lodash/debounce';
import throttle from 'lodash/throttle'; I think I'll give it a try no matter the stable API is in JavaScript or in Rust. Trying to replace babel with swc in my own bundler called Porter in the foreseeable month. |
js api may not be deprecated. If you are using rust, you can handle it in |
@kdy1 any example code of writing plugin in Rust? Need some template code to get started 😂 |
@cyjake I documented about it at https://docs.rs/swc/0.65.0/swc/#cutomizing |
If anyone is still looking for one, here is my implementation. swc-plugin-transform-import. |
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Need to port https://www.npmjs.com/package/babel-plugin-import
A simple regex replacer might suffice but I'd like to learn the recommended way to implement plugins for swc.
The text was updated successfully, but these errors were encountered: