storybookjs / mdx2-csf

MDX to CSF compiler using MDXv2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for custom pragma

daniel-ac-martin opened this issue · comments

I'm trying to migrate to this package and away from using mdx-loader (v1) with createDocsCompiler.

My repo uses a custom pragma for React so that JSX elements are compiled to h(Component, props) rather than React.createElement(Component, props). With the previous set-up this was fine as long as I used my babel loader after mds-loader.

However that is not the case with this package. The culprit seems to be the DEFAULT_RENDERER that is defined in loader.js.

I'd suggest that the loader take some new options to allow configuration of this. It should be possible to mirror mdx-loader. i.e:

  • options.pragma (default: React.createElement)
  • options.pragmaImportSource (default: react)

(Aside, does allowing the configuration of the source have any value?)

See: https://mdxjs.com/packages/mdx/#optionspragma

@shilman: Any thoughts on this?

Sorry for the slow reply. That sounds likely a reasonable feature request. Any chance you can create a PR for this?

@shilman: I've already raised #10.
(But it looks like you've seen that now. :-) )