1.6.22 • Published 3 years ago

babel-plugin-apply-mdx-type-prop v1.6.22

Weekly downloads
1,436,454
License
MIT
Repository
github
Last release
3 years ago

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

1.6.22

3 years ago

1.6.21

3 years ago

1.6.20

3 years ago

1.6.19

4 years ago

2.0.0-next.8

4 years ago

1.6.18

4 years ago

1.6.17

4 years ago

2.0.0-next.7

4 years ago

1.6.16

4 years ago

1.6.15

4 years ago

2.0.0-next.6

4 years ago

2.0.0-next.5

4 years ago

2.0.0-next.4

4 years ago

1.6.14

4 years ago

1.6.13-ci.1

4 years ago

1.6.12-ci.2

4 years ago

1.6.13

4 years ago

1.6.12

4 years ago

2.0.0-next.3

4 years ago

1.6.11

4 years ago

1.6.9

4 years ago

1.6.8

4 years ago

1.6.10

4 years ago

1.6.8-ci.4

4 years ago

1.6.7

4 years ago

1.6.6

4 years ago

1.6.5

4 years ago

2.0.0-next.1

4 years ago

1.6.4

4 years ago

2.0.0-next.0

4 years ago

1.6.3

4 years ago

1.6.2

4 years ago

1.6.1

4 years ago

1.6.0

4 years ago

1.5.9

4 years ago

1.5.8-ci.13

4 years ago

1.5.8

4 years ago

1.5.8-alpha.0

4 years ago

1.5.7

4 years ago

1.5.6

4 years ago

1.5.7-alpha.0

4 years ago

1.5.6-alpha.0

4 years ago

1.5.6-ci.0

4 years ago

1.5.5

4 years ago

1.5.4

4 years ago

1.5.3

4 years ago

1.5.2

4 years ago

1.5.1

5 years ago

1.5.0

5 years ago

1.4.5

5 years ago

1.4.4

5 years ago

1.4.3

5 years ago

1.4.2

5 years ago

1.4.1

5 years ago

1.4.0

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago