<p dir="auto">After upgrading to babel 7, the command to transpile a directory, that worked well in the same project with Babel 6 is failing with a <code class="notranslate">Maximum call stack size exceeded</code> after transpiling <strong>369 files</strong>.</p>
<p dir="auto">The command executed is:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="babel --copy-files --ignore '**/__tests__/*.js,node_modules' --out-dir ./functions ./modules"><pre class="notranslate"><code class="notranslate">babel --copy-files --ignore '**/__tests__/*.js,node_modules' --out-dir ./functions ./modules
</code></pre></div>
<p dir="auto">When executed on a subset of the the folder, it works well. It seems to be an issue with the number of files being transpiled.</p>
<h3 dir="auto">Stack trace</h3>
<p dir="auto">(The stack trace changes with the number of files being transpilled).</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="RangeError: Maximum call stack size exceeded
    at normalizeStringPosix (path.js:78:30)
    at Object.normalize (path.js:1193:12)
    at Object.join (path.js:1228:18)
    at getDest (&lt;project&gt;/node_modules/@babel/cli/lib/babel/dir.js:57:26)
    at &lt;project&gt;/node_modules/@babel/cli/lib/babel/dir.js:70:20
    at write (&lt;project&gt;/node_modules/@babel/cli/lib/babel/dir.js:30:14)
    at handleFile (&lt;project&gt;/node_modules/@babel/cli/lib/babel/dir.js:66:5)
    at sequentialHandleFile (&lt;project&gt;/node_modules/@babel/cli/lib/babel/dir.js:89:5)
    at &lt;project&gt;/node_modules/@babel/cli/lib/babel/dir.js:94:9
    at &lt;project&gt;/node_modules/@babel/cli/lib/babel/dir.js:75:14"><pre class="notranslate"><code class="notranslate">RangeError: Maximum call stack size exceeded
    at normalizeStringPosix (path.js:78:30)
    at Object.normalize (path.js:1193:12)
    at Object.join (path.js:1228:18)
    at getDest (&lt;project&gt;/node_modules/@babel/cli/lib/babel/dir.js:57:26)
    at &lt;project&gt;/node_modules/@babel/cli/lib/babel/dir.js:70:20
    at write (&lt;project&gt;/node_modules/@babel/cli/lib/babel/dir.js:30:14)
    at handleFile (&lt;project&gt;/node_modules/@babel/cli/lib/babel/dir.js:66:5)
    at sequentialHandleFile (&lt;project&gt;/node_modules/@babel/cli/lib/babel/dir.js:89:5)
    at &lt;project&gt;/node_modules/@babel/cli/lib/babel/dir.js:94:9
    at &lt;project&gt;/node_modules/@babel/cli/lib/babel/dir.js:75:14
</code></pre></div>
<h3 dir="auto">Babel Configuration</h3>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{
    &quot;presets&quot;: [
        [&quot;@babel/env&quot;, {
            &quot;targets&quot;: {
                &quot;node&quot;: &quot;6.11.5&quot;
            }
        }],
        &quot;@babel/flow&quot;,
        &quot;@babel/react&quot;
    ],
    &quot;plugins&quot;: [
        &quot;@babel/plugin-proposal-object-rest-spread&quot;,
        &quot;@babel/plugin-proposal-class-properties&quot;,
        &quot;transform-decorators&quot;,
        [ &quot;module-resolver&quot;, {
            &quot;alias&quot;: {
                &quot;@gitbook&quot;: &quot;./modules&quot;,
                &quot;aphrodite&quot;: &quot;aphrodite/no-important&quot;
            },
            &quot;cwd&quot;: &quot;babelrc&quot;
        }]
    ],
    &quot;ignore&quot;: [
        &quot;modules/node_modules/**/*&quot;,
        &quot;modules/styleguide/icons/*.js&quot;
    ]
}"><pre class="notranslate"><span class="pl-kos">{</span>
    <span class="pl-s">"presets"</span>: <span class="pl-kos">[</span>
        <span class="pl-kos">[</span><span class="pl-s">"@babel/env"</span><span class="pl-kos">,</span> <span class="pl-kos">{</span>
            <span class="pl-s">"targets"</span>: <span class="pl-kos">{</span>
                <span class="pl-s">"node"</span>: <span class="pl-s">"6.11.5"</span>
            <span class="pl-kos">}</span>
        <span class="pl-kos">}</span><span class="pl-kos">]</span><span class="pl-kos">,</span>
        <span class="pl-s">"@babel/flow"</span><span class="pl-kos">,</span>
        <span class="pl-s">"@babel/react"</span>
    <span class="pl-kos">]</span><span class="pl-kos">,</span>
    <span class="pl-s">"plugins"</span>: <span class="pl-kos">[</span>
        <span class="pl-s">"@babel/plugin-proposal-object-rest-spread"</span><span class="pl-kos">,</span>
        <span class="pl-s">"@babel/plugin-proposal-class-properties"</span><span class="pl-kos">,</span>
        <span class="pl-s">"transform-decorators"</span><span class="pl-kos">,</span>
        <span class="pl-kos">[</span> <span class="pl-s">"module-resolver"</span><span class="pl-kos">,</span> <span class="pl-kos">{</span>
            <span class="pl-s">"alias"</span>: <span class="pl-kos">{</span>
                <span class="pl-s">"@gitbook"</span>: <span class="pl-s">"./modules"</span><span class="pl-kos">,</span>
                <span class="pl-s">"aphrodite"</span>: <span class="pl-s">"aphrodite/no-important"</span>
            <span class="pl-kos">}</span><span class="pl-kos">,</span>
            <span class="pl-s">"cwd"</span>: <span class="pl-s">"babelrc"</span>
        <span class="pl-kos">}</span><span class="pl-kos">]</span>
    <span class="pl-kos">]</span><span class="pl-kos">,</span>
    <span class="pl-s">"ignore"</span>: <span class="pl-kos">[</span>
        <span class="pl-s">"modules/node_modules/**/*"</span><span class="pl-kos">,</span>
        <span class="pl-s">"modules/styleguide/icons/*.js"</span>
    <span class="pl-kos">]</span>
<span class="pl-kos">}</span></pre></div>
<h3 dir="auto">Babel/Babylon Configuration (.babelrc, package.json, cli command)</h3>

<p dir="auto">.babelrc</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{
  &quot;presets&quot;: [
    [&quot;@babel/env&quot;, {
      &quot;targets&quot;: { &quot;node&quot;: &quot;6.11.5&quot; }
    }]
  ],
  &quot;plugins&quot;: [&quot;@babel/plugin-proposal-object-rest-spread&quot;]
}"><pre class="notranslate"><span class="pl-kos">{</span>
  <span class="pl-s">"presets"</span>: <span class="pl-kos">[</span>
    <span class="pl-kos">[</span><span class="pl-s">"@babel/env"</span><span class="pl-kos">,</span> <span class="pl-kos">{</span>
      <span class="pl-s">"targets"</span>: <span class="pl-kos">{</span> <span class="pl-s">"node"</span>: <span class="pl-s">"6.11.5"</span> <span class="pl-kos">}</span>
    <span class="pl-kos">}</span><span class="pl-kos">]</span>
  <span class="pl-kos">]</span><span class="pl-kos">,</span>
  <span class="pl-s">"plugins"</span>: <span class="pl-kos">[</span><span class="pl-s">"@babel/plugin-proposal-object-rest-spread"</span><span class="pl-kos">]</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">CLI Command</p>
<p dir="auto"><code class="notranslate">babel 'functions/src' --out-dir 'functions/bundle' --copy-files --ignore 'functions/src/node_modules' </code></p>
<h3 dir="auto">Expected Behavior</h3>
<p dir="auto">After executing this command, resulting files were correctly copied at functions/bundle folder using beta.37</p>
<h3 dir="auto">Current Behavior</h3>
<p dir="auto">With beta.38 and beta.39, following error arises after processing last file</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="RangeError: Maximum call stack size exceeded
    at /Users/karlas/myapp/node_modules/@babel/cli/lib/babel/dir.js:71:56
    at write (/Users/karlas/myapp/node_modules/@babel/cli/lib/babel/dir.js:30:14)
    at handleFile (/Users/karlas/myapp/node_modules/@babel/cli/lib/babel/dir.js:66:5)
    at sequentialHandleFile (/Users/karlas/myapp/node_modules/@babel/cli/lib/babel/dir.js:89:5)
    at /Users/karlas/myapp/node_modules/@babel/cli/lib/babel/dir.js:94:9
    at /Users/karlas/myapp/node_modules/@babel/cli/lib/babel/dir.js:75:14
    at write (/Users/karlas/myapp/node_modules/@babel/cli/lib/babel/dir.js:30:14)
    at handleFile (/Users/karlas/myapp/node_modules/@babel/cli/lib/babel/dir.js:66:5)
    at sequentialHandleFile (/Users/karlas/myapp/node_modules/@babel/cli/lib/babel/dir.js:89:5)
    at /Users/karlas/myapp/node_modules/@babel/cli/lib/babel/dir.js:94:9"><pre class="notranslate"><code class="notranslate">RangeError: Maximum call stack size exceeded
    at /Users/karlas/myapp/node_modules/@babel/cli/lib/babel/dir.js:71:56
    at write (/Users/karlas/myapp/node_modules/@babel/cli/lib/babel/dir.js:30:14)
    at handleFile (/Users/karlas/myapp/node_modules/@babel/cli/lib/babel/dir.js:66:5)
    at sequentialHandleFile (/Users/karlas/myapp/node_modules/@babel/cli/lib/babel/dir.js:89:5)
    at /Users/karlas/myapp/node_modules/@babel/cli/lib/babel/dir.js:94:9
    at /Users/karlas/myapp/node_modules/@babel/cli/lib/babel/dir.js:75:14
    at write (/Users/karlas/myapp/node_modules/@babel/cli/lib/babel/dir.js:30:14)
    at handleFile (/Users/karlas/myapp/node_modules/@babel/cli/lib/babel/dir.js:66:5)
    at sequentialHandleFile (/Users/karlas/myapp/node_modules/@babel/cli/lib/babel/dir.js:89:5)
    at /Users/karlas/myapp/node_modules/@babel/cli/lib/babel/dir.js:94:9
</code></pre></div>
<h3 dir="auto">Possible Solution</h3>
<p dir="auto">Check <a class="commit-link" href="https://github.com/babel/babel/commit/26e4911eb22a75f6581febe0cedc245a683c55cb#diff-f93fbf6dce06b5cbf6cc65f5f7dac101"><tt>26e4911</tt>#diff-f93fbf6dce06b5cbf6cc65f5f7dac101</a></p>
<p dir="auto">This is the last commit where this dir.js file was modified. Tags are beta.38 and beta.39 (the affected versions)</p>
<h3 dir="auto">Context</h3>
<p dir="auto">Just transpiling about 20 files to be used on Firebase Functions</p>
<h3 dir="auto">Your Environment</h3>

<table role="table">
<thead>
<tr>
<th>software</th>
<th>version(s)</th>
</tr>
</thead>
<tbody>
<tr>
<td>Babel</td>
<td>7.0.0-beta.39</td>
</tr>
<tr>
<td>node</td>
<td>8.9.3</td>
</tr>
<tr>
<td>npm</td>
<td>5.5.1</td>
</tr>
<tr>
<td>yarn</td>
<td>1.3.2</td>
</tr>
<tr>
<td>Operating System</td>
<td>macOS High Sierra</td>
</tr>
</tbody>
</table>