{"bugs":{"url":"https://github.com/59naga/babel-plugin-add-module-exports/issues"},"dist":{"shasum":"1c1befee12f4b5f62fe641716caff01ec4d2e3ec","tarball":"https://registry.npmjs.org/babel-plugin-add-module-exports/-/babel-plugin-add-module-exports-0.3.2.tgz","fileCount":4,"integrity":"sha512-UnRwsVGXN0nTo0cqRHtauSal4e/Y1jaFuqLXH6i/46aPoHcyorgl6/Noy5IsWS/6TzX9mC0LYQbXrFoLxfpsWw==","signatures":[{"sig":"MEYCIQDcUVKeKAOJmVqDbyeIwGDROTf3TTRGfw6R8Sf7gbp84AIhAOaVblZv4jFK30pia6Sr8+BE3nenxppTI8fqD/+J3jyg","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":17965},"main":"lib","name":"babel-plugin-add-module-exports","_from":".","files":["lib"],"author":{"name":"59naga","email":"i59naga@icloud.com"},"readme":"babel-plugin-add-module-exports\n---\n\n<p align=\"right\">\n  <a href=\"https://npmjs.org/package/babel-plugin-add-module-exports\">\n    <img src=\"https://img.shields.io/npm/v/babel-plugin-add-module-exports.svg?style=flat-square\">\n  </a>\n  <a href=\"https://travis-ci.org/59naga/babel-plugin-add-module-exports\">\n    <img src=\"http://img.shields.io/travis/59naga/babel-plugin-add-module-exports.svg?style=flat-square\">\n  </a>\n</p>\n\nWhy?\n---\n\nBabel@6 doesn't export default `module.exports` any more - [T2212 *Kill CommonJS default export behavior*](https://phabricator.babeljs.io/T2212).\n\nBabel@6 transforms the following file\n\n```js\nexport default 'foo'\n```\n\ninto\n\n```js\n'use strict';\nObject.defineProperty(exports, \"__esModule\", {\n  value: true\n});\nexports.default = 'foo';\n```\n\nTherefore, it is a need to use the ugly `.default` in node.js.\n\n```js\nrequire('./bundle.js') // { default: 'foo' }\nrequire('./bundle.js').default // 'foo'\n```\n\nThis plugin follows the babel@5 behavior - add the `module.exports` if **only** the `export default` declaration exists.\n\n```js\n'use strict';\nObject.defineProperty(exports, \"__esModule\", {\n  value: true\n});\nexports.default = 'foo';\nmodule.exports = exports['default'];\n```\n\nTherefore, our old codes still work fine - the `.default` goes away. :wink:\n\n```js\nrequire('./bundle.js') // foo\n```\n\nUsage\n---\n\nInstall this plugin from npm:\n\n```bash\nnpm install babel-plugin-add-module-exports@next --save-dev\n# or\nyarn add -D babel-plugin-add-module-exports@next\n```\n\nWrite the name to [babelrc](https://babeljs.io/docs/usage/babelrc/). It works with [preset-env](http://babeljs.io/docs/en/babel-preset-env/) to output CommonJS code:\n\n```json\n{\n  \"presets\": [\"env\"],\n  \"plugins\": [\n    \"add-module-exports\"\n  ]\n}\n```\n\n### v0.3.0\n\n**However, the plugin doesn't change the pure-esmodule**.\nthis plugin makes changes only when exists `exports.default` (in other words, using [commonjs](https://babeljs.io/docs/en/babel-plugin-transform-es2015-modules-commonjs/)).\n\n```json\n{\n  \"presets\": [[\"env\", {\"modules\": false}]],\n  \"plugins\": [\n    \"add-module-exports\"\n  ]\n}\n```\n\ninto\n\n```js\nexport default 'foo'\n```\n\n`0.3.0` Currently support is `commonjs` and `umd`.\nDoesn't support `amd`, `systemjs` modules(don't use. there are no plans to support at the moment).\n\nOptions\n---\n\n## `addDefaultProperty`\n\nIf you're exporting an object and wish to maintain compatibility with code using the `require('./bundle.js').default` syntax, you can optionally enable the `addDefaultProperty` option as follows:\n\n```json\n{\n  \"presets\": [\"env\"],\n  \"plugins\": [\n    [\"add-module-exports\", {\n      \"addDefaultProperty\": true\n    }]\n  ]\n}\n```\nThis will cause a second line of code to be added which aliases the `default` name to the exported object like so:\n```js\nmodule.exports = exports['default'];\nmodule.exports.default = exports['default']\n```\n\nLicense\n---\n[MIT](http://59naga.mit-license.org/)\n","_shasum":"1c1befee12f4b5f62fe641716caff01ec4d2e3ec","gitHead":"b7d8f6234535b9a72cbdf3bdf3905960bc6f3b46","license":"MIT","scripts":{"lint":"eslint src test","test":"mocha --require babel-register","build":"babel src --out-dir lib --source-maps","start":"mocha --require babel-register --watch","postversion":"git push --follow-tags && conventional-github-releaser -p angular -r 0"},"_npmUser":{"name":"59naga","email":"i59naga@icloud.com"},"homepage":"https://github.com/59naga/babel-plugin-add-module-exports#readme","keywords":["babel-plugin","module.exports"],"repository":{"url":"git+https://github.com/59naga/babel-plugin-add-module-exports.git","type":"git"},"_npmVersion":"3.10.10","description":"Fix babel/babel#2212","directories":{},"maintainers":[{"name":"59naga","email":"i59naga@icloud.com"},{"name":"lijunle","email":"lijunle@gmail.com"}],"_nodeVersion":"10.6.0","dependencies":{"chokidar":"^2.0.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"mocha":"^5.2.0","eslint":"^5.1.0","prettier":"^1.13.7","babel-cli":"^6.26.0","babel-core":"^6.26.3","babel-types":"^6.26.0","babel-eslint":"^8.2.6","power-assert":"^1.6.0","babel-template":"^6.26.0","babel-preset-env":"^1.7.0","babel-preset-react":"^6.24.1","eslint-plugin-node":"^6.0.1","babel-plugin-rewire":"^1.1.0","eslint-plugin-import":"^2.13.0","eslint-plugin-promise":"^3.8.0","eslint-config-prettier":"^2.9.0","eslint-config-standard":"^11.0.0","eslint-plugin-prettier":"^2.6.2","eslint-plugin-standard":"^3.1.0","babel-preset-power-assert":"^2.0.0","conventional-github-releaser":"^3.1.2","babel-plugin-transform-export-extensions":"^6.22.0"},"optionalDependencies":{"chokidar":"^2.0.4"},"_npmOperationalInternal":{"tmp":"tmp/babel-plugin-add-module-exports_0.3.2_1531729810079_0.4944075504400116","host":"s3://npm-registry-packages"},"_id":"babel-plugin-add-module-exports@0.3.2","version":"0.3.2"}