-
-
Notifications
You must be signed in to change notification settings - Fork 38
Add support for plugins #149
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
Conversation
c383661 to
247a9df
Compare
9ef6c42 to
68246f5
Compare
alexeagle
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooh, that's interesting. Thanks for working on this! Let's see what they decide upstream about the resolution pathing.
|
This really nice. Thank you. My concern is the substitution of the user's configuration. It just feels wrong and complicates things. If you are already patching the cli, I would go a step further and introduce a new --plugin multi-option. This can be done during the initialization phase |
|
I agree that adding a CLI flag makes sense. It also may be better for upstream because they can punt on relative paths in the config. I came up with this design when I thought that it could work without modifying SWC at all 😅 |
|
I think by adding a new option you can also resolve the issue with the base path in swc-project/swc#6800. Providing a path using the --plugin option should work in the same way as providing a path using a --config option. |
bbe7e1d to
6905d77
Compare
|
Updated to use CLI arguments added in swc-project/swc#6811 Much better, thanks for the suggestion, @realtimetodie! |
|
swc-project/swc#6835 has now been merged, so as soon as a new version of SWC is released this PR should be ready to go. |
|
upstream cut the release, so I think this is unblocked now @titanous :) |
|
Indeed, the tests are now passing locally and this is ready for review. |
7b1f945 to
b132161
Compare
|
The added wasm file is 2MB which will severely bloat our download for users of the ruleset. Can we fetch it with |
|
Yes, we should not add binary files, wasm or not. Luckily, there is rules_rust which can be used to ceate a plugin with the wasm bindgen rules. https://bazelbuild.github.io/rules_rust/rust_wasm_bindgen.html Rust wasm bindgen is a Rust library and CLI tool that facilitates high-level interactions between wasm modules and JavaScript. This would also be a great example for users. |
c8735b8 to
fb14b53
Compare
|
PTAL |
|
PTAL |
alexeagle
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thank you!
| plugin_cache = [] | ||
| plugin_args = [] | ||
| if ctx.attr.plugins: | ||
| plugin_cache = [ctx.actions.declare_directory("{}_plugin_cache".format(ctx.label.name))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very creative :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ha, I was pretty proud of myself when I came up with that one
This PR implements all of the wiring necessary to use SWC plugins.
swc_pluginmacro/rule pair that creates a target with the necessary providers:DefaultInfopointing at a wasm file or an npm package containing a wasm file as themainentrypoint in thepackage.jsonSwcPluginConfigInfoholding the plugin configurationpluginsattr toswc_compileandswc, taking a list of plugin targets, along with helpers to inject the plugin config.