We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2d6c2a6 commit ddfd578Copy full SHA for ddfd578
src/optimizer/index.js
@@ -53,10 +53,15 @@ module.exports = {
53
const transformer = optimizationTransforms[transformName];
54
55
let newResult = transform.transform(ast, transformer);
56
- if (newResult.toString().length <= result.toString().length) {
57
- result = newResult;
+
+ if (newResult.toString() !== result.toString()) {
58
+ if (newResult.toString().length <= result.toString().length) {
59
+ result = newResult;
60
+ } else {
61
+ // Result has changed but is not shorter: restore ast to its previous state.
62
+ ast = clone(result.getAST());
63
+ }
64
}
- ast = clone(result.getAST());
65
});
66
67
} while (result.toString() !== prevResult);
0 commit comments