@linaria/shaker
Advanced tools
Comparing version 3.0.0-beta.4 to 3.0.0-beta.5
@@ -6,2 +6,13 @@ # Change Log | ||
# [3.0.0-beta.5](https://github.com/callstack/linaria/compare/v3.0.0-beta.4...v3.0.0-beta.5) (2021-05-31) | ||
### Bug Fixes | ||
* **shaker:** typescript enums support ([#761](https://github.com/callstack/linaria/issues/761)) ([#764](https://github.com/callstack/linaria/issues/764)) ([6907e22](https://github.com/callstack/linaria/commit/6907e2280a2ab8ee014b5d02b1169714ccac9d66)) | ||
# [3.0.0-beta.4](https://github.com/callstack/linaria/compare/v3.0.0-beta.3...v3.0.0-beta.4) (2021-05-07) | ||
@@ -8,0 +19,0 @@ |
@@ -134,4 +134,4 @@ import { types as t } from '@babel/core'; | ||
if (parent && action !== 'ignore' && t.isDeclaration(node)) { | ||
// Declaration always depends on its scope | ||
if (parent && action !== 'ignore') { | ||
// Node always depends on its parent | ||
this.graph.addEdge(node, parent); | ||
@@ -138,0 +138,0 @@ } |
@@ -59,22 +59,2 @@ import { types as t } from '@babel/core'; | ||
/* | ||
* ExpressionStatement | ||
* This is one of the rare cases when a child defines a dependency on a parent. | ||
* Suppose we have a code like this: | ||
* const fn = () => { | ||
* let a = 2; | ||
* a *= 2; | ||
* return a; | ||
* }; | ||
* | ||
* `a *= 2` here is an ExpressionStatement node which contains an expression AssignmentExpression `a *= 2`. | ||
* The result of AssignmentExpression here depends on the fact of ExpressionStatement execution, | ||
* that's why we need to mark the statement as a dependency of the expression. | ||
* If we don't mark it, it will be cut as a useless statement. | ||
*/ | ||
ExpressionStatement(node) { | ||
this.baseVisit(node); | ||
this.graph.addEdge(node.expression, node); | ||
}, | ||
/* | ||
* FunctionDeclaration | FunctionExpression | ObjectMethod | ArrowFunctionExpression | ClassMethod | ClassPrivateMethod; | ||
@@ -93,10 +73,4 @@ * Functions can be either a statement or an expression. | ||
this.graph.addEdge(node, node.body); | ||
this.graph.addEdge(node.body, node); | ||
node.params.forEach(param => this.graph.addEdge(node.body, param)); | ||
if (t.isFunctionDeclaration(node) && node.id !== null) { | ||
// `id` is an identifier which depends on the function declaration | ||
this.graph.addEdge(node.id, node); | ||
} | ||
if (t.isFunctionExpression(node) && node.id !== null) { | ||
@@ -132,6 +106,2 @@ // keep function name in expressions like `const a = function a();` | ||
} | ||
node.body.forEach(exp => { | ||
this.graph.addEdge(exp, node); | ||
}); | ||
}, | ||
@@ -158,3 +128,2 @@ | ||
}); | ||
this.graph.addEdge(node.block, node); | ||
}, | ||
@@ -164,7 +133,2 @@ | ||
this.baseVisit(node); | ||
[node.consequent, node.alternate].forEach(statement => { | ||
if (statement) { | ||
this.graph.addEdge(statement, node); | ||
} | ||
}); | ||
this.graph.addEdge(node, node.consequent); | ||
@@ -182,3 +146,2 @@ this.graph.addEdge(node, node.test); | ||
this.baseVisit(node); | ||
this.graph.addEdge(node.body, node); | ||
this.graph.addEdge(node, node.test); | ||
@@ -204,7 +167,2 @@ }, | ||
this.baseVisit(node); | ||
if (node.body) { | ||
this.graph.addEdge(node.body, node); | ||
} | ||
[node.init, node.test, node.update, node.body].forEach(child => { | ||
@@ -225,3 +183,2 @@ if (child) { | ||
if (node.body) { | ||
this.graph.addEdge(node.body, node); | ||
this.graph.addEdge(node, node.body); | ||
@@ -295,3 +252,2 @@ this.graph.addEdge(node.body, node.left); | ||
this.baseVisit(node); | ||
this.graph.addEdge(node.object, node); | ||
@@ -323,10 +279,7 @@ if (t.isIdentifier(node.object) && t.isIdentifier(node.property)) { | ||
this.context.pop(); | ||
this.visit(node.right, node, 'right'); // THe value of an expression depends on the left part. | ||
this.visit(node.right, node, 'right'); // The value of an expression depends on the left part. | ||
this.graph.addEdge(node, node.left); // this.graph.addEdge(node, node.right); | ||
// The left part of an assignment depends on the right part. | ||
this.graph.addEdge(node, node.left); // The left part of an assignment depends on the right part. | ||
this.graph.addEdge(node.left, node.right); // At the same time, the left part doesn't make any sense without the whole expression. | ||
this.graph.addEdge(node.left, node); | ||
this.graph.addEdge(node.left, node.right); | ||
}, | ||
@@ -355,8 +308,5 @@ | ||
this.graph.addEdge(node.id, node.init); | ||
} // If we want to evaluate the value of a declared identifier, | ||
// we need to evaluate the whole expression. | ||
} // If a statement is required itself, an id is also required | ||
this.graph.addEdge(node.id, node); // If a statement is required itself, an id is also required | ||
this.graph.addEdge(node, node.id); | ||
@@ -363,0 +313,0 @@ }, |
@@ -151,4 +151,4 @@ "use strict"; | ||
if (parent && action !== 'ignore' && _core.types.isDeclaration(node)) { | ||
// Declaration always depends on its scope | ||
if (parent && action !== 'ignore') { | ||
// Node always depends on its parent | ||
this.graph.addEdge(node, parent); | ||
@@ -155,0 +155,0 @@ } |
@@ -70,22 +70,2 @@ "use strict"; | ||
/* | ||
* ExpressionStatement | ||
* This is one of the rare cases when a child defines a dependency on a parent. | ||
* Suppose we have a code like this: | ||
* const fn = () => { | ||
* let a = 2; | ||
* a *= 2; | ||
* return a; | ||
* }; | ||
* | ||
* `a *= 2` here is an ExpressionStatement node which contains an expression AssignmentExpression `a *= 2`. | ||
* The result of AssignmentExpression here depends on the fact of ExpressionStatement execution, | ||
* that's why we need to mark the statement as a dependency of the expression. | ||
* If we don't mark it, it will be cut as a useless statement. | ||
*/ | ||
ExpressionStatement(node) { | ||
this.baseVisit(node); | ||
this.graph.addEdge(node.expression, node); | ||
}, | ||
/* | ||
* FunctionDeclaration | FunctionExpression | ObjectMethod | ArrowFunctionExpression | ClassMethod | ClassPrivateMethod; | ||
@@ -104,10 +84,4 @@ * Functions can be either a statement or an expression. | ||
this.graph.addEdge(node, node.body); | ||
this.graph.addEdge(node.body, node); | ||
node.params.forEach(param => this.graph.addEdge(node.body, param)); | ||
if (_core.types.isFunctionDeclaration(node) && node.id !== null) { | ||
// `id` is an identifier which depends on the function declaration | ||
this.graph.addEdge(node.id, node); | ||
} | ||
if (_core.types.isFunctionExpression(node) && node.id !== null) { | ||
@@ -143,6 +117,2 @@ // keep function name in expressions like `const a = function a();` | ||
} | ||
node.body.forEach(exp => { | ||
this.graph.addEdge(exp, node); | ||
}); | ||
}, | ||
@@ -169,3 +139,2 @@ | ||
}); | ||
this.graph.addEdge(node.block, node); | ||
}, | ||
@@ -175,7 +144,2 @@ | ||
this.baseVisit(node); | ||
[node.consequent, node.alternate].forEach(statement => { | ||
if (statement) { | ||
this.graph.addEdge(statement, node); | ||
} | ||
}); | ||
this.graph.addEdge(node, node.consequent); | ||
@@ -193,3 +157,2 @@ this.graph.addEdge(node, node.test); | ||
this.baseVisit(node); | ||
this.graph.addEdge(node.body, node); | ||
this.graph.addEdge(node, node.test); | ||
@@ -215,7 +178,2 @@ }, | ||
this.baseVisit(node); | ||
if (node.body) { | ||
this.graph.addEdge(node.body, node); | ||
} | ||
[node.init, node.test, node.update, node.body].forEach(child => { | ||
@@ -236,3 +194,2 @@ if (child) { | ||
if (node.body) { | ||
this.graph.addEdge(node.body, node); | ||
this.graph.addEdge(node, node.body); | ||
@@ -306,3 +263,2 @@ this.graph.addEdge(node.body, node.left); | ||
this.baseVisit(node); | ||
this.graph.addEdge(node.object, node); | ||
@@ -334,10 +290,7 @@ if (_core.types.isIdentifier(node.object) && _core.types.isIdentifier(node.property)) { | ||
this.context.pop(); | ||
this.visit(node.right, node, 'right'); // THe value of an expression depends on the left part. | ||
this.visit(node.right, node, 'right'); // The value of an expression depends on the left part. | ||
this.graph.addEdge(node, node.left); // this.graph.addEdge(node, node.right); | ||
// The left part of an assignment depends on the right part. | ||
this.graph.addEdge(node, node.left); // The left part of an assignment depends on the right part. | ||
this.graph.addEdge(node.left, node.right); // At the same time, the left part doesn't make any sense without the whole expression. | ||
this.graph.addEdge(node.left, node); | ||
this.graph.addEdge(node.left, node.right); | ||
}, | ||
@@ -366,8 +319,5 @@ | ||
this.graph.addEdge(node.id, node.init); | ||
} // If we want to evaluate the value of a declared identifier, | ||
// we need to evaluate the whole expression. | ||
} // If a statement is required itself, an id is also required | ||
this.graph.addEdge(node.id, node); // If a statement is required itself, an id is also required | ||
this.graph.addEdge(node, node.id); | ||
@@ -374,0 +324,0 @@ }, |
{ | ||
"name": "@linaria/shaker", | ||
"version": "3.0.0-beta.4", | ||
"version": "3.0.0-beta.5", | ||
"publishConfig": { | ||
@@ -50,5 +50,5 @@ "access": "public" | ||
"@babel/preset-env": ">=7", | ||
"@linaria/babel-preset": "^3.0.0-beta.4", | ||
"@linaria/babel-preset": "^3.0.0-beta.5", | ||
"@linaria/logger": "^3.0.0-beta.3", | ||
"@linaria/preeval": "^3.0.0-beta.4", | ||
"@linaria/preeval": "^3.0.0-beta.5", | ||
"babel-plugin-transform-react-remove-prop-types": "^0.4.24" | ||
@@ -59,3 +59,3 @@ }, | ||
}, | ||
"gitHead": "20e1ba5f60d06b2399bd54d723be91364b8acea3" | ||
"gitHead": "b6df746490d681594198df3d3c1d096082d34466" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
268751
2141