Skip to content

Commit

Permalink
fix: do not mark _defineProperty as pure in build output
Browse files Browse the repository at this point in the history
Fixes #29145
  • Loading branch information
jsaguet committed Jan 5, 2025
1 parent c40d726 commit bac5d43
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ export default function (): PluginObj {
return;
}

// Do not annotate _defineProperty function as it is not pure.
if (callee.isIdentifier() && callee.node.name === '_defineProperty') {
return;
}

annotateAsPure(path);
},
NewExpression(path) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,18 @@ describe('pure-toplevel-functions Babel plugin', () => {
`),
);

it(
'does not annotate _defineProperty function',
testCaseNoChange(`
class LanguageState {}
_defineProperty(
LanguageState,
'property',
'value'
);
`),
);

it(
'does not annotate object literal methods',
testCaseNoChange(`
Expand Down

0 comments on commit bac5d43

Please sign in to comment.