<p dir="auto">When you're passing multiple files/globs to babel that will be built into a single file, is it possible to eliminate duplicate file paths in the resulting build rather than duplicating the contents?</p>
<p dir="auto">I'm trying to influence the ordering of some files where the order is important, so I have a command that looks like this:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="babel -s -c false --out-file tmp/built.js --ignore *.spec.js src/module.js &quot;src/**/*.js&quot;"><pre class="notranslate"><span class="pl-s1">babel</span> <span class="pl-c1">-</span><span class="pl-s1">s</span> <span class="pl-c1">-</span><span class="pl-s1">c</span> <span class="pl-c1">false</span> <span class="pl-c1">--</span><span class="pl-s1">out</span><span class="pl-c1">-</span><span class="pl-s1">file</span> <span class="pl-s1">tmp</span><span class="pl-c1">/</span><span class="pl-s1">built</span><span class="pl-kos">.</span><span class="pl-c1">js</span> <span class="pl-c1">--</span><span class="pl-s1">ignore</span> <span class="pl-c1">*</span><span class="pl-kos">.</span><span class="pl-c1">spec</span><span class="pl-kos">.</span><span class="pl-c1">js</span> <span class="pl-s1">src</span><span class="pl-c1">/</span><span class="pl-smi">module</span><span class="pl-kos">.</span><span class="pl-c1">js</span> <span class="pl-s">"src/**/*.js"</span></pre></div>
<p dir="auto">At the moment, <code class="notranslate">module.js</code> would be included as the first file, then duplicated again when the second glob matches it.  Ideally, the file would only be included the first time it was encountered.</p>
<p dir="auto"><strong>Bug:</strong> If in your build script, you have <code class="notranslate">--copy-files</code> passed, files that are ignored in .babelrc files will be copied over, instead of being ignored.</p>
<h3 dir="auto">Input Code</h3>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="babel src --out-dir lib --copy-files"><pre class="notranslate"><span class="pl-s1">babel</span> <span class="pl-s1">src</span> <span class="pl-c1">--</span><span class="pl-s1">out</span><span class="pl-c1">-</span><span class="pl-s1">dir</span> <span class="pl-s1">lib</span> <span class="pl-c1">--</span><span class="pl-s1">copy</span><span class="pl-c1">-</span><span class="pl-s1">files</span></pre></div>
<h3 dir="auto">Babel Configuration (.babelrc, package.json, cli command)</h3>

<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{
  &quot;presets&quot;: [
    &quot;es2015&quot;,
    &quot;stage-1&quot;,
    &quot;react&quot;
  ],
  &quot;ignore&quot;: [
    &quot;**__mocks__/*.js&quot;
  ]
}"><pre class="notranslate"><span class="pl-kos">{</span>
  <span class="pl-s">"presets"</span>: <span class="pl-kos">[</span>
    <span class="pl-s">"es2015"</span><span class="pl-kos">,</span>
    <span class="pl-s">"stage-1"</span><span class="pl-kos">,</span>
    <span class="pl-s">"react"</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">"**__mocks__/*.js"</span>
  <span class="pl-kos">]</span>
<span class="pl-kos">}</span></pre></div>
<h3 dir="auto">Expected Behavior</h3>
<p dir="auto">Babel should not copy files that are explicitly ignored in <code class="notranslate">.babelrc</code> configuration. In this case, babel should not transpile or copy Jest mocks.</p>
<h3 dir="auto">Current Behavior</h3>
<p dir="auto">Babel copies files that are ignored are explicitly <code class="notranslate">.babelrc</code>.</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&gt; npm run build 
&gt; babel src --out-dir lib --copy-files
  src/api/__mocks__/index.js -&gt; lib/api/__mocks__/index.js
  src/api/endpoints.js -&gt; lib/api/endpoints.js"><pre class="notranslate"><span class="pl-k">&gt;</span> npm run build 
<span class="pl-k">&gt;</span> babel src --out-dir lib --copy-files
  src/api/__mocks__/index.js -<span class="pl-k">&gt;</span> lib/api/__mocks__/index.js
  src/api/endpoints.js -<span class="pl-k">&gt;</span> lib/api/endpoints.js</pre></div>
<p dir="auto">If you pass an <code class="notranslate">--ignore</code> flag (with the same blob) <em>after</em> the <code class="notranslate">--copy-files</code> flag, it will behave as expected.</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&gt; npm run build;
&gt; babel src --out-dir lib --copy-files --ignore **__mocks__/*.js
  src/api/endpoints.js -&gt; lib/api/endpoints.js
  (output does not include ignored directories)"><pre class="notranslate"><span class="pl-k">&gt;</span> npm run build<span class="pl-k">;</span>
<span class="pl-k">&gt;</span> babel src --out-dir lib --copy-files --ignore <span class="pl-k">**</span>__mocks__/<span class="pl-k">*</span>.js
  src/api/endpoints.js -<span class="pl-k">&gt;</span> lib/api/endpoints.js
  (output does not include ignored directories)</pre></div>
<h3 dir="auto">Context</h3>
<p dir="auto">This issue comes up when you work with Jest manual mocks inside of your source directory. Jest warns that you have duplicate <strong>mocks</strong> directories.</p>
<table role="table">
<thead>
<tr>
<th>software</th>
<th>version(s)</th>
</tr>
</thead>
<tbody>
<tr>
<td>Babel</td>
<td>6.26.0</td>
</tr>
<tr>
<td>node</td>
<td>6.9.2</td>
</tr>
<tr>
<td>npm</td>
<td>5.4.0</td>
</tr>
<tr>
<td>Operating System</td>
<td>OSX El Capitan</td>
</tr>
</tbody>
</table>