title: Babel plugins run order
body: <p>TL;DR: Is there a way how to specify the order in which the Babel plugins are supposed to be run? How does Babel determine this order? Is there any spec how this works apart from diving into Babel sources?</p>
  <p>I'm developing my own Babel plugin. I noticed, that when I run it, my plugin is run before other es2015 plugins. For example having code such as:</p>
  <pre><code>const a = () =&gt; 1
  </code></pre>
  <p>and visitor such as:</p>
  <pre><code>visitor: {
    ArrowFunctionExpression(path) {
      console.log('ArrowFunction')
    },
    FunctionExpression(path) {
      console.log('Function')
    },
  }
  </code></pre>
  <p>my plugin observes ArrowFunction (and not Function). I played with the order in which the plugins are listed in Babel configuration, but that didn't change anything:</p>
  <pre><code>plugins: ['path_to_myplugin', 'transform-es2015-arrow-functions'],
  plugins: ['transform-es2015-arrow-functions', 'path_to_myplugin'],
  </code></pre>
  <p>OTOH, this looks like the order DOES somehow matter:</p>
  <p><a href="https://phabricator.babeljs.io/T6719" rel="nofollow noreferrer">https://phabricator.babeljs.io/T6719</a></p>
  <p>---- EDIT ----</p>
  <p>I found out that if I write my visitor as follows:</p>
  <pre><code>  ArrowFunctionExpression: {
      enter(path) {
        console.log('ArrowFunction')
      }
    },
    FunctionExpression: {
      exit(path) {
        console.log('Function')
      }
    },
  </code></pre>
  <p>both functions are called. So it looks like the order of execution is: myplugin_enter -&gt; other_plugin -&gt; myplugin_exit. In other words, myplugin seems to be before other_plugin in some internal pipeline. The main question however stays the same - the order of plugins in the pipeline should be determined &amp; configurable somehow.</p>