Export all named exports again, as module.default, unless a default is defined.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
src
test
.DS_Store
.babelrc
.codeclimate.yml
.eslintignore
.eslintrc.json
.gitignore
.npmignore
.travis.yml
LICENSE
README.md
changelog.js
package.json

README.md

babel-plugin-export-default-module-exports

Installation

npm install babel-plugin-export-default-module-exports --save-dev

Why?

I want to be able to import Name from 'module'; Name.method() as well as import {action} from 'module'; action().

Normally you would do this by ending 'module' with export default module.exports.

This plugin adds that line automatically, to any module with named exports, which doesn't already have an explicit export default

// index.js
export const entry 'foo'

into

// index.js
export const entry 'foo'
export default {
  entry,
}

Usage

Install this plugin from npm:

npm install babel-plugin-export-default-module-exports --save-dev

Write the name to babelrc. It works with preset-es2015 to output CommonJS code:

{
  "presets": ["es2015"],
  "plugins": [
    "export-default-module-exports"
  ]
}

It also works with transform-es2015-modules-umd plugin to output UMD code: (It is a must to place UMD plugin after this plugin.)

{
  "presets": ["es2015"],
  "plugins": [
    "export-default-module-exports",
    "transform-es2015-modules-umd"
  ]
}

License

MIT