A Babel plugin that extracts a specific ESM export and its dependencies from a file, based on a fork of NextJS's SSG transform plugin. Current version 0.1.0, single release. It operates by performing static analysis with Babel to remove unused exports and import statements, outputting only the targeted export and its prerequisites. Differentiates from tree-shaking tools by allowing per-export extraction at build time, useful for code splitting or dynamic imports. Note: The package has not been updated since initial release and may have limited compatibility with newer Babel versions.
npm install babel-plugin-extract-exportVerified import paths — ran on the pinned version, not inferred.
Shows how to use the plugin with Babel to extract a specific export (Avatar) and its dependencies from a source string.
Ensure Babel 7 compatibility; upgrade to future releases if available.
Consider using NextJS's SSG transform directly or a more maintained alternative like babel-plugin-transform-imports.
Use separate passes or a different plugin if you need to extract multiple exports.
Always include the syntax plugin with appropriate configuration for TSX files.
Run 'yarn add babel-plugin-extract-export' or 'npm install babel-plugin-extract-export'.
Use [[plugin, options]] syntax correctly: 'plugins: [[extractExport, { exportName: 'Avatar' }]]'.Ensure the file has an exported variable or function with the exact name given in exportName option.