allow custom recma plugins before `recmaJsxBuild`
See original GitHub issueInitial checklist
- I read the support docs
- I read the contributing guide
- I agree to follow the code of conduct
- I searched issues and couldn’t find anything (or linked relevant results below)
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
before recmaJsxBuild
(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
before recmaJsxBuild
as well, since recmaJsxBuild
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 ?
Issue Analytics
- State:
- Created a year ago
- Comments:5 (5 by maintainers)
Top GitHub Comments
Makes sense, thank you!
In my current recma plugin, it is optional.
If you enable the import, it imports the wrapper component for you, but if you disable it, you can either import manually, or use component prop/MDXProvider for it.
The end use is to upgrade my MDXP package for writing slides in mdx, and for that scenario I want the automatic import ! 😃
Something like
{remark,rehype}-mdx-{deck,whatever-you-like}
. See https://mdxjs.com/docs/extending-mdx/#list-of-plugins for existing and inspirational plugins. And add yours there when it’s ready.Cool idea! Perhaps that solves https://github.com/mdx-js/mdx/issues/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?