swc/crates/swc_ecma_minifier/tests/fixture/issues/5846/input.js
Donny/강동윤 a5f7b6946f
fix(es/minifier): Don't replace parameters of IIFE if it's recursive (#5852)
**Description:**

While investigating, I found that problem is not the analysis of recursive functions. Instead, it was a problem with the IIFE evaluator, which replaces parameters even if it's recursive.

**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/5846
2022-09-14 05:02:14 +00:00

44 lines
1.0 KiB
JavaScript

function processNode(
node,
index,
parent,
pathNodes
) {
const children = node ? node[mergeChildrenPropName] : dataNodes;
const pos = node ? getPosition(parent.pos, index) : '0';
const connectNodes = node ? [...pathNodes, node] : [];
// Process node if is not root
if (node) {
const key = syntheticGetKey(node, pos);
const data = {
node,
index,
pos,
key,
parentPos: parent.node ? parent.pos : null,
level: parent.level + 1,
nodes: connectNodes,
};
callback(data);
}
// Process children node
if (children) {
children.forEach((subNode, subIndex) => {
processNode(
subNode,
subIndex,
{
node,
pos,
level: parent ? parent.level + 1 : -1,
},
connectNodes,
);
});
}
}
processNode(null);