diff options
author | Florian Dold <florian.dold@gmail.com> | 2018-09-20 02:56:13 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2018-09-20 02:56:13 +0200 |
commit | bbff7403fbf46f9ad92240ac213df8d30ef31b64 (patch) | |
tree | c58400ec5124da1c7d56b01aea83309f80a56c3b /node_modules/babel-plugin-transform-es2015-modules-commonjs | |
parent | 003fb34971cf63466184351b4db5f7c67df4f444 (diff) |
update packages
Diffstat (limited to 'node_modules/babel-plugin-transform-es2015-modules-commonjs')
4 files changed, 19 insertions, 11 deletions
diff --git a/node_modules/babel-plugin-transform-es2015-modules-commonjs/.npmignore b/node_modules/babel-plugin-transform-es2015-modules-commonjs/.npmignore deleted file mode 100644 index 31852902b..000000000 --- a/node_modules/babel-plugin-transform-es2015-modules-commonjs/.npmignore +++ /dev/null @@ -1,4 +0,0 @@ -node_modules -*.log -src -test diff --git a/node_modules/babel-plugin-transform-es2015-modules-commonjs/README.md b/node_modules/babel-plugin-transform-es2015-modules-commonjs/README.md index bdad88967..c553eeef8 100644 --- a/node_modules/babel-plugin-transform-es2015-modules-commonjs/README.md +++ b/node_modules/babel-plugin-transform-es2015-modules-commonjs/README.md @@ -1,6 +1,14 @@ # babel-plugin-transform-es2015-modules-commonjs > This plugin transforms ES2015 modules to [CommonJS](http://wiki.commonjs.org/wiki/Modules/1.1). +> +> #### Babel 6 Changes +> +> Babel 6 changed some behavior by not doing `module.exports = exports['default']` anymore in the modules transforms. +> +> There are some caveats, but you can use [babel-plugin-add-module-exports](https://www.npmjs.com/package/babel-plugin-add-module-exports), so that updating to Babel 6 isn't a breaking change since users that don't use ES modules don't have to do `require("your-module").default`. +> +> However, it may not match how Node eventually implements ES modules natively given the [the current proposal](https://github.com/nodejs/node-eps/blob/master/002-es-modules.md#46-es-consuming-commonjs). ## Example diff --git a/node_modules/babel-plugin-transform-es2015-modules-commonjs/lib/index.js b/node_modules/babel-plugin-transform-es2015-modules-commonjs/lib/index.js index 2fcce5090..04f017474 100644 --- a/node_modules/babel-plugin-transform-es2015-modules-commonjs/lib/index.js +++ b/node_modules/babel-plugin-transform-es2015-modules-commonjs/lib/index.js @@ -29,15 +29,19 @@ exports.default = function () { if (this.scope.getBinding(name) !== path.scope.getBinding(name)) return; + var replacement = t.cloneDeep(remap); + + replacement.loc = path.node.loc; + if (path.parentPath.isCallExpression({ callee: path.node })) { - path.replaceWith(t.sequenceExpression([t.numericLiteral(0), remap])); - } else if (path.isJSXIdentifier() && t.isMemberExpression(remap)) { - var object = remap.object, - property = remap.property; + path.replaceWith(t.sequenceExpression([t.numericLiteral(0), replacement])); + } else if (path.isJSXIdentifier() && t.isMemberExpression(replacement)) { + var object = replacement.object, + property = replacement.property; path.replaceWith(t.JSXMemberExpression(t.JSXIdentifier(object.name), t.JSXIdentifier(property.name))); } else { - path.replaceWith(remap); + path.replaceWith(replacement); } this.requeueInParent(path); }, @@ -515,7 +519,7 @@ exports.default = function () { topNodes.push(_varDecl); } } - remaps[_specifier.local.name] = t.memberExpression(target, t.cloneWithoutLoc(_specifier.imported)); + remaps[_specifier.local.name] = t.memberExpression(t.cloneWithoutLoc(target), t.cloneWithoutLoc(_specifier.imported)); } } } else { diff --git a/node_modules/babel-plugin-transform-es2015-modules-commonjs/package.json b/node_modules/babel-plugin-transform-es2015-modules-commonjs/package.json index ddd7fb71e..9472d047a 100644 --- a/node_modules/babel-plugin-transform-es2015-modules-commonjs/package.json +++ b/node_modules/babel-plugin-transform-es2015-modules-commonjs/package.json @@ -1,6 +1,6 @@ { "name": "babel-plugin-transform-es2015-modules-commonjs", - "version": "6.26.0", + "version": "6.26.2", "description": "This plugin transforms ES2015 modules to CommonJS", "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-es2015-modules-commonjs", "license": "MIT", |