Can I prevent Babel from traversing code inserted by a plugin? : <p>I'm building a plugin that inserts <code>enterFunction()</code> in front of every existing function call by calling <code>path.insertBefore</code>. So my code is transformed from:</p>

<pre><code>myFunction();
</code></pre>

<p>To:</p>

<pre><code>enterFunction();
myFunction();
</code></pre>

<p>The problem is that when I insert the node Babel once again traverses the inserted node. Here's the logging output:</p>

<blockquote>
  <p>'CallExpression', 'myFunction'<br>
  'CallExpression', 'enterFunction'</p>
</blockquote>

<p>How can I prevent Babel from entering the <code>enterFunction</code> call expression and its children?</p>

<p>This is the code I'm currently using for my Babel plugin: </p>

<pre><code>function(babel) {
    return {
        visitor: {
            CallExpression: function(path) {
                console.log("CallExpression", path.node.callee.name)
                if (path.node.ignore) {
                    return;
                }
                path.node.ignore = true

                var enterCall = babel.types.callExpression(
                    babel.types.identifier("enterFunction"), []
                )
                enterCall.ignore = true;
                path.insertBefore(enterCall)
            }
        }
    }
}
</code></pre>
