Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-add-module-exports

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-add-module-exports - npm Package Compare versions

Comparing version 0.0.0 to 0.0.1

2

lib/index.js

@@ -11,3 +11,3 @@ // Dependencies

var topNodes= []
topNodes.push(babelTemplate('module.exports = exports.default;')())
topNodes.push(babelTemplate('module.exports = Object.assign(exports.default,exports);')())

@@ -14,0 +14,0 @@ path.pushContainer('body',topNodes)

{
"name": "babel-plugin-add-module-exports",
"version": "0.0.0",
"version": "0.0.1",
"description": "Fix babel/babel#2212",

@@ -5,0 +5,0 @@

@@ -20,3 +20,5 @@ BabelPlugin `Add module.exports` [![NPM version][npm-image]][npm] [![Build Status][travis-image]][travis] [![Coverage Status][cover-image]][cover] [![Climate Status][climate-image]][climate]

// index.js
export default 'foo'
let foo= 'bar'
export default 'baz'
export {foo}
```

@@ -35,3 +37,5 @@

# });
# exports.default = 'foo';
# var foo = 'bar';
# exports.default = 'baz';
# exports.foo = foo;
```

@@ -42,11 +46,11 @@

```js
require('./bundle.js') // { default: 'foo' }
require('./bundle.js').default // 'foo'
require('./bundle.js') // { default: 'baz', foo: 'bar' }
require('./bundle.js').default // 'baz'
```
This plugin add the `module.exports` to EOF.
The `babel-plugin-add-module-exports` add the `module.exports` to EOF.
```bash
npm install babel-plugin-add-module-exports --save-dev
babel index.js --presets es2015 --plugins babel-plugin-add-module-exports > bundle.js
babel index.js --presets es2015 --plugins add-module-exports > bundle.js
# 'use strict';

@@ -57,4 +61,6 @@ #

# });
# exports.default = 'foo';
# module.exports = exports.default;
# var foo = 'bar';
# exports.default = 'baz';
# exports.foo = foo;
# module.exports = Object.assign(exports.default, exports);
```

@@ -65,5 +71,29 @@

```js
require('./bundle.js') // 'foo'
require('./bundle.js') // { [String: 'baz'] default: 'baz', foo: 'bar' }
require('./bundle.js')+'' // baz
```
Can polyfill the `Object.assign`?
---
See also [babel-plugin-transform-object-assign](https://github.com/babel/babel/tree/development/packages/babel-plugin-transform-object-assign).
example:
```bash
npm install babel-plugin-transform-object-assign --save-dev
babel index.js --presets es2015 --plugins add-module-exports,transform-object-assign > bundle.js
# 'use strict';
#
# var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
#
# Object.defineProperty(exports, "__esModule", {
# value: true
# });
# var foo = 'bar';
# exports.default = 'baz';
# exports.foo = foo;
# module.exports = _extends(exports.default, exports);
```
License

@@ -70,0 +100,0 @@ ---

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc