-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
allow custom recma plugins before recmaJsxBuild
#2076
Comments
There’s only one other recma plugin I’m aware of (recma-nextjs-static-props) but JSX isn’t involved with its transforms. I do recognize this problem when I initially tried to implement #2045 as an external recma plugin, but it became part of core (work in progress). It would be nice to be able to transform JSX using recma plugins knowing it always works regardless of further JSX transformation. |
I mostly disagree. recma plugins are meant to work on any javascript. Like babel plugins. E.g.: minify code. There are many options that do different things. And there are many ways to write content that result in different things. That could all theoretically change the content you work on and how things are structured. Perhaps you don't need to change javascript. But work on remark/rehype. All of this is hard to help with without knowing what you want to accomplish though |
Hmm, you are probably right about this one. I am creating a very simply plugin that splits MDX on a specific component and then wraps the resulting chunks in another component (eg. splitting on @wooorm, is there a naming convention for remark/rehype plugins, that specifically target MDX stuff ? |
Something like Cool idea! Perhaps that solves #454. Does your plugin really need to import things? MDX already has several ways of passing and importing components: could you let users do that and benefit from the existing passing methods? |
Makes sense, thank you!
In my current recma plugin, it is optional. |
Initial checklist
Problem
I am developing a custom Recma plugin.
My issue is that during development, I usually compiled my mdx with
jsx: true
, because that makes it easier to look at the output and debug the process. However, I was (stupidly) unaware that the resulting AST is completely different, depending on this setting.While I will probably rework my plugin to work with
jsx: false
, this does seem to complicate things for plugin developers.Should a plugin work in both cases (basically needing to build 2 plugins and decide which one to use at runtime) ?
Solution
I think that this issue could be resolved by using the
recmaplugins
beforerecmaJsxBuild
(code), that way any plugin works regardless of whether the output should be jsx or not.However, this means that the plugins also get used before
recmaStringify
(not entirely sure what it does).I gues it might be a possibility to use
recmaStringify
beforerecmaJsxBuild
as well, sincerecmaJsxBuild
is currently not always used ?I understand this change is probably not something you can quickly commit to, as existing plugins need to be adapted as well and this would thus need a discussion with the plugin authors ?
As far as I am aware, the only plugins for recma are those by @remcohaszing, but I might be mistaken ?
The text was updated successfully, but these errors were encountered: