API to collect Extra Data from Wasm plugins and custom transforms
Describe the feature
I think it is worth the effort. I'll work on this.
It will return the collect Extra Data emitted by custom plugins and Wasm plugins as an array or a hashmap, to the caller.
Additional context
No response
cc @dferber90 for visibility
Would this make it possible to use an SWC plugin to extract metadata about a file? If so that would be incredibly useful.
To give one concrete example:
We're currently using @swc/plugin-formatjs as part of our internationalization system. The SWC plugin injects message ids and drops message descriptions during transpilation from TS -> JS. We end up having to re-process each TS file a second time to extract metadata about the messages in the file for translation. Unfortunately this uses @formatjs/ts-transformer under the hood which is significantly slower and potentially even inconsistent with @swc/plugin-formatjs.
I would love to be able to do this second pass using SWC + @swc/plugin-formatjs. Or even better to get rid of the second pass entirely and somehow output extracted metadata alongside the transpiled JS (maybe tangentially related to https://github.com/swc-project/swc/discussions/4997?)
Yeah it would be possible but actually this is already possible using file system
Do wasm plugins already have enough information/access to write a file that's a sibling to the transpilation output file? Ie something like foo.ts -> foo.js + foo.js.meta.json? I've poked around a little but haven't been able to find the output file location from the plugin. Sorry for getting a little off topic from the original issue 😬
IIRC /cwd would work. Can you confirm, @kwonoj ?
Yes, cwd mount is still supported.
Ie something like foo.ts -> foo.js + foo.js.meta.json
Given swc transform can run parallel and does not have shared context in between each transform, there is no way to collect whole transforms meta.
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.