recma-attach-exports

0.0.1 • Public • Published

recma-attach-exports

recma plugin to attach named exports to the default export

Installation

npm install recma-attach-exports
import { compile } from '@mdx-js/mdx'
import { recmaAttachExports } from 'recma-attach-exports'

let mdx = `export const meta = { title: 'Hello world' }`

await compile(mdx, {
  recmaPlugins: [recmaAttachExports],
})

Example transformation based on the above snippet:

  /*@jsxRuntime automatic @jsxImportSource react*/
  import {Fragment as _Fragment, jsx as _jsx} from "react/jsx-runtime";
- export const meta = {
+ const meta = {
    title: 'Hello world'
  };
  function _createMdxContent(props) {
    return _jsx(_Fragment, {});
  }
  function MDXContent(props = {}) {
    const {wrapper: MDXLayout} = props.components || ({});
    return MDXLayout ? _jsx(MDXLayout, Object.assign({}, props, {
      children: _jsx(_createMdxContent, props)
    })) : _createMdxContent(props);
  }
  export default MDXContent;
+ MDXContent.meta = meta;

Options

exclude

Default: []

A list of named exports to exclude from transformation, e.g. ['getStaticProps']

Readme

Keywords

Package Sidebar

Install

npm i recma-attach-exports

Weekly Downloads

19

Version

0.0.1

License

MIT

Unpacked Size

7.76 kB

Total Files

4

Last publish

Collaborators

  • bradlc