metro-transform-plugins
Advanced tools
Comparing version 0.76.2 to 0.76.3
{ | ||
"name": "metro-transform-plugins", | ||
"version": "0.76.2", | ||
"version": "0.76.3", | ||
"description": "🚇 Transform plugins for Metro.", | ||
@@ -27,3 +27,3 @@ "main": "src/index.js", | ||
"@babel/types": "^7.20.0", | ||
"metro": "0.76.2" | ||
"metro": "0.76.3" | ||
}, | ||
@@ -30,0 +30,0 @@ "engines": { |
@@ -64,39 +64,45 @@ /** | ||
}; | ||
const FunctionExpression = { | ||
exit(path, state) { | ||
const parentPath = path.parentPath; | ||
const parentNode = parentPath?.node; | ||
if (isVariableDeclarator(parentNode) && parentNode.id.name != null) { | ||
const binding = parentPath?.scope.getBinding(parentNode.id.name); | ||
if (binding && !binding.referenced) { | ||
const FunctionExpression = | ||
// $FlowFixMe[incompatible-type] | ||
{ | ||
exit(path, state) { | ||
const parentPath = path.parentPath; | ||
const parentNode = parentPath?.node; | ||
if (isVariableDeclarator(parentNode) && parentNode.id.name != null) { | ||
const binding = parentPath?.scope.getBinding(parentNode.id.name); | ||
if (binding && !binding.referenced) { | ||
state.stripped = true; | ||
parentPath?.remove(); | ||
} | ||
} | ||
}, | ||
}; | ||
const Conditional = | ||
// $FlowFixMe[incompatible-type] | ||
{ | ||
exit(path, state) { | ||
const node = path.node; | ||
const result = evaluate(path.get("test")); | ||
if (result.confident) { | ||
state.stripped = true; | ||
parentPath?.remove(); | ||
if (result.value || node.alternate) { | ||
// $FlowFixMe Flow error uncovered by typing Babel more strictly | ||
path.replaceWith(result.value ? node.consequent : node.alternate); | ||
} else if (!result.value) { | ||
path.remove(); | ||
} | ||
} | ||
} | ||
}, | ||
}; | ||
const Conditional = { | ||
exit(path, state) { | ||
const node = path.node; | ||
const result = evaluate(path.get("test")); | ||
if (result.confident) { | ||
state.stripped = true; | ||
if (result.value || node.alternate) { | ||
// $FlowFixMe Flow error uncovered by typing Babel more strictly | ||
path.replaceWith(result.value ? node.consequent : node.alternate); | ||
} else if (!result.value) { | ||
path.remove(); | ||
}, | ||
}; | ||
const Expression = | ||
// $FlowFixMe[incompatible-type] | ||
{ | ||
exit(path) { | ||
const result = evaluate(path); | ||
if (result.confident) { | ||
path.replaceWith(t.valueToNode(result.value)); | ||
path.skip(); | ||
} | ||
} | ||
}, | ||
}; | ||
const Expression = { | ||
exit(path) { | ||
const result = evaluate(path); | ||
if (result.confident) { | ||
path.replaceWith(t.valueToNode(result.value)); | ||
path.skip(); | ||
} | ||
}, | ||
}; | ||
}, | ||
}; | ||
const LogicalExpression = { | ||
@@ -131,2 +137,3 @@ exit(path) { | ||
ConditionalExpression: Conditional, | ||
// $FlowFixMe[incompatible-call] | ||
FunctionDeclaration, | ||
@@ -154,2 +161,3 @@ FunctionExpression, | ||
BinaryExpression: Expression, | ||
// $FlowFixMe[incompatible-type] | ||
LogicalExpression, | ||
@@ -156,0 +164,0 @@ Program: { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
74307
1099