babel-plugin-export-toplevel

A babel plugin that automatically exports all top-level names

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
babel-plugin-export-toplevel
001.0.05 years ago5 years agoMinified + gzip package size for babel-plugin-export-toplevel in KB

Readme

babel-plugin-export-toplevel
A simple transform to automatically export all top-level names.
This is mostly useful for testing purposes, so you can have access to these names in testing while not exporting them in other environments.

Effect

Transforms
const hiddenFunction = () => {};
const publicFunction = () => {};

export default publicFunction;

to something akin to
const hiddenFunction = () => {};
const publicFunction = () => {};

export default publicFunction;
export { publicFunction, hiddenFunction };

Install

npm i --save-dev babel-plugin-export-toplevel

Usage

.babelrc
{
  "plugins": ["export-toplevel"]
}