This is a fork of the NextJS SSG transform Babel plugin that reverses the logic and allows extracting a specific export and its dependencies.
Install
yarn add babel-plugin-extract-export
Example
const babel = require('@babel/core')
const syntaxTypeScript = require('@babel/plugin-syntax-typescript')
const extractExport = require('babel-plugin-extract-export')
const jsx = `
import { Image } from 'system'
export const Avatar = () => <Image />
type SystemProps = { as: any }
type BoxProps = { children: any } & SystemProps
export const Box = (props: BoxProps) => <div {...props} />
`
const result = babel.transform(jsx, {
configFile: false,
plugins: [
[syntaxTypeScript, { isTSX: true }],
[extractExport, { exportName: 'Avatar' }],
],
})
Development
yarn install && yarn test