Mdx: Using mdx without React

Created on 22 Jun 2018  路  5Comments  路  Source: mdx-js/mdx

./node_modules/@mdx-js/tag/dist/mdx-tag.js
  0:0  error  Module not found: Error: Can't resolve 'react' in
              '/Users/fl-macbook-retina/Dropbox/Projects/node_js_server/node_modules/@mdx-js/tag/dist'

I wanna use Mdx for a project where I'm not using React but something similar. In my Webpack config I've configured babel the following way to not transform Jsx into React.createElement but into just dom. Can I get MDX to threat Jsx the same way?

{
        loader: 'babel-loader',
        options: {
                presets: ['env', 'react'],
                plugins: [
                        ["transform-react-jsx", {
                                "pragma": "dom" // default pragma is React.createElement
                        }]
                ]
        }
},

Seems like it's not currently possible?

I believe it would be if one could make the following line a configuration option:
https://github.com/mdx-js/mdx/blob/master/packages/loader/index.js#L10

馃拵 v1 馃挰 typdiscussion

Most helpful comment

Facing the same issue, I'm trying to use mdx with Hyperapp.

All 5 comments

Right, I'm open to a pull request making it an options. Regarding @mdx/tag, that's something you'll have to implement yourself if you're not using React.

Facing the same issue, I'm trying to use mdx with Hyperapp.

This should now work with v1 alpha since it uses a custom pragma-based approach.

So how do I change the Pragma?

So how do I change the Pragma?

create a .babelrc file with the following configuration (in the case of Hyperapp which is using h)

{
    "presets": [
        "@babel/env",
        "@babel/react"
    ],
    "plugins": [
        [
            "transform-react-jsx",
            {
                "pragma": "h" // default pragma is React.createElement
            }
        ]
    ]
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

mAAdhaTTah picture mAAdhaTTah  路  4Comments

johno picture johno  路  3Comments

silvenon picture silvenon  路  4Comments

codebender828 picture codebender828  路  4Comments

MatthewCaseres picture MatthewCaseres  路  4Comments