Open littleprincewdk opened 1 year ago
Currently no but I definitely want to add such an API
I also need such a feature, is there any progress on this issue now?
To support StyleX, this feature is also required.
This is not strictly limited to the plugin, since transform
interface itself does not have any extension point other than codes and its source map. So hypothetically, this would be swc/core's feature for the any internal transform chain to return arbitrary data.
I am aware there are few plugins trying to do this, even including my work around coverage plugins but I am also not entirely convinced what interface would be best for the plugin & custom transforms. Specifically, unlike what babel does we can't allow duck-typeable object or functions from wasm to be bubbled up into js runtime, so either it could be very rough (stringified json type) or having another way to provide type-safe way with serialization. For my workaround in coverage plugin I ended up to use comment to include realizable object and to parse.
Side note, I've been tinkering around stylex and this is not the bigger blocker probably, like it have a custom forked version of babel/evaluate and also invoking stylex/shared runtime codes in the transform phase, which is much challenging to solve in swc as it doesn't have same evaluatable environments.
TL:DR I'm open to see RFCs on this topic can solve ergonomics + performances.
Describe the feature
I want to collect dependencies while transforming js to es5,with babel,i can write a plugin or just parse-traverse-transform,but with swc i will get error: