@linaria/shaker
Advanced tools
Comparing version 3.0.0-beta.5 to 3.0.0-beta.7
@@ -6,2 +6,13 @@ # Change Log | ||
# [3.0.0-beta.7](https://github.com/callstack/linaria/compare/v3.0.0-beta.6...v3.0.0-beta.7) (2021-06-24) | ||
### Bug Fixes | ||
* **shaker:** fix undefined imports in some cases ([#333](https://github.com/callstack/linaria/issues/333), [#761](https://github.com/callstack/linaria/issues/761)) ([#787](https://github.com/callstack/linaria/issues/787)) ([e374072](https://github.com/callstack/linaria/commit/e3740727447b2867a2cfe40f763bc88e72eb2503)) | ||
# [3.0.0-beta.5](https://github.com/callstack/linaria/compare/v3.0.0-beta.4...v3.0.0-beta.5) (2021-05-31) | ||
@@ -8,0 +19,0 @@ |
@@ -87,3 +87,3 @@ import { types as t } from '@babel/core'; | ||
if (this.isExportsAssigment(node) && !this.isExportsAssigment(node.right) && !isVoid(node.right)) { | ||
if (t.isMemberExpression(node.left) && t.isIdentifier(node.left.property)) { | ||
if (t.isMemberExpression(node.left) && (t.isIdentifier(node.left.property) || t.isStringLiteral(node.left.property))) { | ||
if (t.isIdentifier(node.left.object) && node.left.object.name === 'module') { | ||
@@ -113,3 +113,5 @@ // It's a batch or default export | ||
} else { | ||
this.graph.addExport(node.left.property.name, node); | ||
// it can be either `exports.name` or `exports["name"]` | ||
const nameNode = node.left.property; | ||
this.graph.addExport(t.isStringLiteral(nameNode) ? nameNode.value : nameNode.name, node); | ||
} | ||
@@ -116,0 +118,0 @@ } |
@@ -74,3 +74,3 @@ import { types as t } from '@babel/core'; | ||
if (t.isFunctionExpression(node) && node.id !== null) { | ||
if (t.isFunctionExpression(node) && node.id !== null && node.id !== undefined) { | ||
// keep function name in expressions like `const a = function a();` | ||
@@ -77,0 +77,0 @@ this.graph.addEdge(node, node.id); |
@@ -1,2 +0,2 @@ | ||
export {}; | ||
//# sourceMappingURL=types.js.map |
@@ -56,5 +56,8 @@ import { types as t } from '@babel/core'; | ||
}; | ||
const isKeyOfVisitors = type => type in visitors; | ||
export function getVisitors(node) { | ||
const aliases = t.ALIAS_KEYS[node.type] || []; | ||
const aliasVisitors = aliases.map(type => visitors[type]).filter(i => i); | ||
const aliasVisitors = aliases.map(type => isKeyOfVisitors(type) ? visitors[type] : null).filter(i => i); | ||
return [...aliasVisitors, visitors[node.type]].filter(v => v); | ||
@@ -61,0 +64,0 @@ } |
@@ -102,3 +102,3 @@ "use strict"; | ||
if (this.isExportsAssigment(node) && !this.isExportsAssigment(node.right) && !isVoid(node.right)) { | ||
if (_core.types.isMemberExpression(node.left) && _core.types.isIdentifier(node.left.property)) { | ||
if (_core.types.isMemberExpression(node.left) && (_core.types.isIdentifier(node.left.property) || _core.types.isStringLiteral(node.left.property))) { | ||
if (_core.types.isIdentifier(node.left.object) && node.left.object.name === 'module') { | ||
@@ -128,3 +128,5 @@ // It's a batch or default export | ||
} else { | ||
this.graph.addExport(node.left.property.name, node); | ||
// it can be either `exports.name` or `exports["name"]` | ||
const nameNode = node.left.property; | ||
this.graph.addExport(_core.types.isStringLiteral(nameNode) ? nameNode.value : nameNode.name, node); | ||
} | ||
@@ -131,0 +133,0 @@ } |
@@ -85,3 +85,3 @@ "use strict"; | ||
if (_core.types.isFunctionExpression(node) && node.id !== null) { | ||
if (_core.types.isFunctionExpression(node) && node.id !== null && node.id !== undefined) { | ||
// keep function name in expressions like `const a = function a();` | ||
@@ -88,0 +88,0 @@ this.graph.addEdge(node, node.id); |
@@ -72,5 +72,7 @@ "use strict"; | ||
const isKeyOfVisitors = type => type in visitors; | ||
function getVisitors(node) { | ||
const aliases = _core.types.ALIAS_KEYS[node.type] || []; | ||
const aliasVisitors = aliases.map(type => visitors[type]).filter(i => i); | ||
const aliasVisitors = aliases.map(type => isKeyOfVisitors(type) ? visitors[type] : null).filter(i => i); | ||
return [...aliasVisitors, visitors[node.type]].filter(v => v); | ||
@@ -77,0 +79,0 @@ } |
{ | ||
"name": "@linaria/shaker", | ||
"version": "3.0.0-beta.5", | ||
"version": "3.0.0-beta.7", | ||
"publishConfig": { | ||
@@ -50,5 +50,5 @@ "access": "public" | ||
"@babel/preset-env": ">=7", | ||
"@linaria/babel-preset": "^3.0.0-beta.5", | ||
"@linaria/babel-preset": "^3.0.0-beta.7", | ||
"@linaria/logger": "^3.0.0-beta.3", | ||
"@linaria/preeval": "^3.0.0-beta.5", | ||
"@linaria/preeval": "^3.0.0-beta.7", | ||
"babel-plugin-transform-react-remove-prop-types": "^0.4.24" | ||
@@ -59,3 +59,3 @@ }, | ||
}, | ||
"gitHead": "b6df746490d681594198df3d3c1d096082d34466" | ||
"gitHead": "d4812e9a67841379a6553effbacbc0e387a616af" | ||
} |
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
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
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
271249
2148