babel-plugin-export-toplevel

raw JSON →
1.0.0 verified Sat Apr 25 auth: no javascript

A Babel plugin that automatically exports all top-level declarations (e.g., const, function, class) from a module. At version 1.0.0, it is a stable, single-purpose utility primarily used in testing to expose internal functions or variables for unit tests without modifying production exports. It only affects development builds and has no runtime dependencies. Unlike other export injection plugins, it specifically targets top-level names and preserves existing exports.

error SyntaxError: .../node_modules/babel-plugin-export-toplevel/lib/index.js: Unexpected token
cause The plugin is configured without Babel (e.g., using Node require) instead of being used as a Babel plugin.
fix
Use the plugin in Babel's .babelrc or babel.config.js, not via direct require in runtime code.
error Babel configuration error: .babelrc contains unknown plugin: babel-plugin-export-toplevel
cause Plugin not installed in node_modules.
fix
Run 'npm install --save-dev babel-plugin-export-toplevel'.
gotcha Plugin only works in Babel 6/7; ensure Babel version compatibility.
fix Use Babel 6 or 7.
gotcha Top-level names that are already exported (either individually or via export {}) are not duplicated.
fix No action needed; plugin skips already-exported names.
gotcha Does not export names from import statements (e.g., import { foo } from 'bar'; foo is not exported).
fix Manually re-export imported names if needed.
npm install babel-plugin-export-toplevel
yarn add babel-plugin-export-toplevel
pnpm add babel-plugin-export-toplevel