Use single object spread call in loose mode (#11520)

This commit is contained in:
Justin Ridgewell
2020-05-08 07:07:59 -04:00
committed by GitHub
parent b8a6145e50
commit a080a1d345
32 changed files with 383 additions and 15 deletions

View File

@@ -579,6 +579,16 @@ export default declare((api, opts) => {
return;
}
// In loose mode, we don't want to make multiple calls. We're assuming
// that the spread objects either don't use getters, or that the
// getters are pure and don't depend on the order of evaluation.
if (loose) {
if (hadProps) {
exp.arguments.push(obj);
}
return;
}
exp = t.callExpression(t.cloneNode(helper), [
exp,
// If we have static props, we need to insert an empty object