babel-plugin-transform-export-function
A Babel transform that wraps the module code inside a function, that it exports.
const capitalize = ;const name = ; // Return written explicitely, but you could use// babel-plugin-transform-last-statement to// return it automaticallyreturn `<h1></h1>` { // Do something, but I'm unused}
Will become
const capitalize = ;const name = ; module { return `<h1></h1>`} { // Do something, but I'm unused}
TODO
- Basic implementation
- Only activate if there's no top
module.exports
call
Future
- Hoist imports via
require
, ignore dynamicrequire
- Ignore functions & classes in top-level
- Configure function arguments (default
data
) - Configure function name (default: anonymous)
- Named vs default export (default: default export)
- ES6 exports through option
- Automatic detection of ES6 vs CJS (existing
require
=> CJS, existingimport
orimport()
=> ES6)