Merge pull request #3433 from loganfsmyth/bail-out-rename
Only attempt to rename export declarations, not expressions - fixes T7215
This commit is contained in:
commit
2d0a007d14
5
packages/babel-core/test/fixtures/transformation/misc/T7215/actual.js
vendored
Normal file
5
packages/babel-core/test/fixtures/transformation/misc/T7215/actual.js
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
export default (onClick) => ({
|
||||||
|
onClick: function(){
|
||||||
|
onClick(text);
|
||||||
|
},
|
||||||
|
});
|
||||||
13
packages/babel-core/test/fixtures/transformation/misc/T7215/expected.js
vendored
Normal file
13
packages/babel-core/test/fixtures/transformation/misc/T7215/expected.js
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", {
|
||||||
|
value: true
|
||||||
|
});
|
||||||
|
|
||||||
|
exports.default = function (_onClick) {
|
||||||
|
return {
|
||||||
|
onClick: function onClick() {
|
||||||
|
_onClick(text);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
4
packages/babel-core/test/fixtures/transformation/misc/T7215/options.json
vendored
Normal file
4
packages/babel-core/test/fixtures/transformation/misc/T7215/options.json
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"presets": ["es2015"],
|
||||||
|
"plugins": ["external-helpers"]
|
||||||
|
}
|
||||||
@ -105,7 +105,7 @@ export default class Renamer {
|
|||||||
let { binding, oldName, newName } = this;
|
let { binding, oldName, newName } = this;
|
||||||
let { scope, path } = binding;
|
let { scope, path } = binding;
|
||||||
|
|
||||||
let parentDeclar = path.find((path) => path.isDeclaration() || path.isFunctionExpression());
|
let parentDeclar = path.find((path) => path.isDeclaration());
|
||||||
if (parentDeclar) {
|
if (parentDeclar) {
|
||||||
this.maybeConvertFromExportDeclaration(parentDeclar);
|
this.maybeConvertFromExportDeclaration(parentDeclar);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user