This Babel plugin restores the pre-Babel 6 behavior where a default export is also assigned to `module.exports`, allowing `require()` to return the default value directly without the `.default` property. Version 1.0.4 is the latest stable release, with no active development. It works only with CommonJS/UMD module output (requires `modules` to be set to `'commonjs'` or `'umd'`). Unlike alternatives, it only adds `module.exports` when there is a single default export, preserving named exports.
npm install babel-plugin-add-module-exportsVerified import paths — ran on the pinned version, not inferred.
Shows Babel configuration and expected transformation of a default export to also set module.exports.
Set `modules` option in preset-env to 'commonjs' or 'umd'.
If you have named exports, this plugin will not change module.exports. Use other approaches or restructure exports.
Switch to using `@babel/plugin-transform-modules-commonjs` with `loose: true` which achieves similar behavior.
Ensure the default export is not an object with its own 'default' property, or avoid addDefaultProperty.
Run `npm install babel-plugin-add-module-exports --save-dev` or `yarn add -D babel-plugin-add-module-exports`.
Ensure you are using Babel 6 or 7. For Babel 7, use preset-env as @babel/preset-env.
Set `modules: 'commonjs'` in @babel/preset-env options.
Ensure the file has a single `export default` statement.
No dependency data recorded yet.