Don't split an exported class when renaming an inner binding (#8051)
This commit is contained in:
parent
106907e605
commit
3c46e75b8f
5
packages/babel-plugin-proposal-class-properties/test/fixtures/regression/7951/input.mjs
vendored
Normal file
5
packages/babel-plugin-proposal-class-properties/test/fixtures/regression/7951/input.mjs
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
export class Foo extends Bar {
|
||||
static foo = {};
|
||||
|
||||
test = args;
|
||||
}
|
||||
3
packages/babel-plugin-proposal-class-properties/test/fixtures/regression/7951/options.json
vendored
Normal file
3
packages/babel-plugin-proposal-class-properties/test/fixtures/regression/7951/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": ["external-helpers", "proposal-class-properties"]
|
||||
}
|
||||
9
packages/babel-plugin-proposal-class-properties/test/fixtures/regression/7951/output.mjs
vendored
Normal file
9
packages/babel-plugin-proposal-class-properties/test/fixtures/regression/7951/output.mjs
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
export class Foo extends Bar {
|
||||
constructor(..._args) {
|
||||
var _temp;
|
||||
|
||||
return _temp = super(..._args), babelHelpers.defineProperty(this, "test", args), _temp;
|
||||
}
|
||||
|
||||
}
|
||||
babelHelpers.defineProperty(Foo, "foo", {});
|
||||
@ -108,7 +108,12 @@ export default class Renamer {
|
||||
path.isClassExpression(),
|
||||
);
|
||||
if (parentDeclar) {
|
||||
this.maybeConvertFromExportDeclaration(parentDeclar);
|
||||
const bindingIds = parentDeclar.getBindingIdentifiers();
|
||||
if (bindingIds[oldName] === binding.identifier) {
|
||||
// When we are renaming an exported identifier, we need to ensure that
|
||||
// the exported binding keeps the old name.
|
||||
this.maybeConvertFromExportDeclaration(parentDeclar);
|
||||
}
|
||||
}
|
||||
|
||||
scope.traverse(block || scope.block, renameVisitor, this);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user