Skip to content
Permalink
Browse files
Handle out-of-order binding of identifiers to improve tree-shaking (#…
  • Loading branch information
lukastaegert committed Apr 10, 2019
1 parent 479bf73 commit c3d73ffa23138c219d91d62822d65da16ed733ea
@@ -86,6 +86,7 @@ export default class Identifier extends NodeBase implements PatternNode {
recursionTracker: ImmutableEntityPathTracker,
origin: DeoptimizableEntity
): LiteralValueOrUnknown {
if (!this.bound) this.bind();
if (this.variable !== null) {
return this.variable.getLiteralValueAtPath(path, recursionTracker, origin);
}
@@ -97,6 +98,7 @@ export default class Identifier extends NodeBase implements PatternNode {
recursionTracker: ImmutableEntityPathTracker,
origin: DeoptimizableEntity
) {
if (!this.bound) this.bind();
if (this.variable !== null) {
return this.variable.getReturnExpressionWhenCalledAtPath(path, recursionTracker, origin);
}
@@ -0,0 +1,3 @@
module.exports = {
description: 'Simplifies conditionals in return expression'
};
@@ -0,0 +1,14 @@
const test = () => {
console.log(foo());
console.log(bar());
};

const foo = () => {
return A;
};

const bar = () => {
return A;
};

export { test };
@@ -0,0 +1,16 @@
export const test = () => {
console.log(foo());
console.log(bar());
};

const foo = () => {
return BUILD ? A : B;
};

const bar = () => {
return getBuild() ? A : B;
};

const getBuild = () => BUILD;

const BUILD = true;

0 comments on commit c3d73ff

Please sign in to comment.