Registry /
testing / babel-plugin-export-toplevel
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
plugin
✓ module.exports = { plugins: ['export-toplevel'] }
✗ import plugin from 'babel-plugin-export-toplevel'
Used as a Babel plugin reference in .babelrc or babel.config.js, not imported directly.
default
✓ {
"plugins": ["export-toplevel"]
}
✗ {
"plugins": ["babel-plugin-export-toplevel"]
}
In .babelrc, use the short name 'export-toplevel' without the babel-plugin- prefix (Babel resolves it automatically).
module.exports
✓
✗ const { exportToplevel } = require('babel-plugin-export-toplevel')
If using programmatic API, assign the plugin directly; no named export exists.
Install the plugin, configure in .babelrc, and see automatic export of top-level names for testing.
// Install: npm i --save-dev babel-plugin-export-toplevel
// .babelrc
{
"plugins": ["export-toplevel"]
}
// Example input: src/example.js
const hiddenFunction = () => {};
const publicFunction = () => {};
export default publicFunction;
// Output: automatically adds exports for hiddenFunction
// Equivalent to:
export default publicFunction;
export { hiddenFunction, publicFunction };
Errors
Common errors & fixes
SyntaxError: .../node_modules/babel-plugin-export-toplevel/lib/index.js: Unexpected token
The plugin is configured without Babel (e.g., using Node require) instead of being used as a Babel plugin.
fixUse the plugin in Babel's .babelrc or babel.config.js, not via direct require in runtime code.
Babel configuration error: .babelrc contains unknown plugin: babel-plugin-export-toplevel
Plugin not installed in node_modules.
fixRun 'npm install --save-dev babel-plugin-export-toplevel'.
Audit
Dependencies
No dependency data recorded yet.