babel-plugin-apply-mdx-type-prop
Apply the MDX type prop used in the MDX pragma
Last updated 5 years ago by johno .
MIT · Repository · Bugs · Original npm
$ cnpm install babel-plugin-apply-mdx-type-prop 
SYNC missed versions from official npm registry.

babel-plugin-apply-mdx-type-prop

Babel plugin that applies the mdxType prop which is used by the MDX pragma.

It also stores all components encountered as names in the plugin state.

Installation

yarn add babel-plugin-apply-mdx-type-prop

Usage

const babel = require('@babel/core')

const BabelPluginApplyMdxTypeProp = require('babel-plugin-apply-mdx-type-prop')

const jsx = `
export const Foo = () => (
  <div>
    <Button />
  </div>
)

export default () => (
  <>
    <h1>Hello!</h1>
    <TomatoBox />
  </>
)
`

const plugin = new BabelPluginApplyMdxTypeProp()

const result = babel.transform(jsx, {
  configFile: false,
  plugins: ['@babel/plugin-syntax-jsx', plugin.plugin]
})

console.log(result.code)
console.log(plugin.state.names)

Input

export const Foo = () => (
  <div>
    <Button />
  </div>
)

export default () => (
  <>
    <h1>Hello!</h1>
    <TomatoBox />
  </>
)

Output

export const Foo = () => (
  <div>
    <Button mdxType="Button" />
  </div>
)

export default () => (
  <>
    <h1>Hello!</h1>
    <TomatoBox mdxType="Button" />
  </>
)

License

MIT

Current Tags

  • 1.6.13-ci.1                                ...           ci (5 years ago)
  • 1.6.22                                ...           latest (5 years ago)
  • 2.0.0-next.8                                ...           next (5 years ago)

10 Versions

  • 2.0.0-next.8                                ...           5 years ago
  • 1.6.22                                ...           5 years ago
  • 1.6.15                                ...           5 years ago
  • 2.0.0-next.7                                ...           5 years ago
  • 1.6.13-ci.1                                ...           5 years ago
  • 1.6.16                                ...           5 years ago
  • 2.0.0-next.1                                ...           5 years ago
  • 1.5.8-ci.13                                ...           5 years ago
  • 1.6.5                                ...           5 years ago
  • 1.6.1                                ...           5 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2013 - present © cnpmjs.org