<blockquote>
<p dir="auto">Issue originally made by John (jan.dolezal71)</p>
</blockquote>
<h3 dir="auto">Bug information</h3>
<ul dir="auto">
<li><strong>Babel version:</strong> 6.4.0</li>
<li><strong>Node version:</strong> 4.2.0</li>
<li><strong>npm version:</strong> 2.14.15</li>
</ul>
<h3 dir="auto">Options</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="{
  &quot;presets&quot;: [ &quot;es2015&quot;, &quot;stage-0&quot; ]
}"><pre class="notranslate"><code class="notranslate">{
  "presets": [ "es2015", "stage-0" ]
}
</code></pre></div>
<h3 dir="auto">Input code</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="class Tester {
  foo () {
    const foo = 'hi';

    return foo;
  }
}"><pre class="notranslate"><code class="notranslate">class Tester {
  foo () {
    const foo = 'hi';

    return foo;
  }
}
</code></pre></div>
<h3 dir="auto">Description</h3>
<p dir="auto">Hi,</p>
<p dir="auto">i upgraded babel to version 6 (from 5) and after editing .babelrc, im getting error these codes:</p>
<p dir="auto">With let:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Duplicate declaration &quot;foo&quot; while parsing file"><pre class="notranslate"><code class="notranslate">Duplicate declaration "foo" while parsing file
</code></pre></div>
<p dir="auto">or with const:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&quot;foo&quot; is read-only (This is an error on an internal node. Probably an internal error. Location has been estimated.) while parsing file:"><pre class="notranslate"><code class="notranslate">"foo" is read-only (This is an error on an internal node. Probably an internal error. Location has been estimated.) while parsing file:
</code></pre></div>
<p dir="auto">babel-core, babel-preset-es2015, babel-preset-stage-0  installed</p>
<p dir="auto">Im attaching test code, same error.</p>
<p dir="auto">thanks in advance,<br>
John.</p>
<p dir="auto">Feature request</p>

<h3 dir="auto">Current Behavior</h3>
<p dir="auto">Currently the following block:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="render`
    &lt;div&gt;
      &lt;h1&gt;Hello, world!&lt;/h1&gt;
      &lt;h2&gt;It is ${new Date().toLocaleTimeString()}.&lt;/h2&gt;
    &lt;/div&gt;
  `;"><pre class="notranslate"><span class="pl-en">render</span><span class="pl-s">`</span>
<span class="pl-s">    &lt;div&gt;</span>
<span class="pl-s">      &lt;h1&gt;Hello, world!&lt;/h1&gt;</span>
<span class="pl-s">      &lt;h2&gt;It is <span class="pl-s1"><span class="pl-kos">${</span><span class="pl-k">new</span> <span class="pl-v">Date</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">toLocaleTimeString</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">}</span></span>.&lt;/h2&gt;</span>
<span class="pl-s">    &lt;/div&gt;</span>
<span class="pl-s">  `</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">will result into:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&quot;use strict&quot;;

var _templateObject = _taggedTemplateLiteral(
  [&quot;\n    &lt;div&gt;\n      &lt;h1&gt;Hello, world!&lt;/h1&gt;\n      &lt;h2&gt;It is &quot;, &quot;.&lt;/h2&gt;\n    &lt;/div&gt;\n  &quot;],
  [&quot;\n    &lt;div&gt;\n      &lt;h1&gt;Hello, world!&lt;/h1&gt;\n      &lt;h2&gt;It is &quot;, &quot;.&lt;/h2&gt;\n    &lt;/div&gt;\n  &quot;]
);

function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }

render(_templateObject, new Date().toLocaleTimeString());"><pre class="notranslate"><span class="pl-s">"use strict"</span><span class="pl-kos">;</span>

<span class="pl-k">var</span> <span class="pl-s1">_templateObject</span> <span class="pl-c1">=</span> <span class="pl-en">_taggedTemplateLiteral</span><span class="pl-kos">(</span>
  <span class="pl-kos">[</span><span class="pl-s">"\n    &lt;div&gt;\n      &lt;h1&gt;Hello, world!&lt;/h1&gt;\n      &lt;h2&gt;It is "</span><span class="pl-kos">,</span> <span class="pl-s">".&lt;/h2&gt;\n    &lt;/div&gt;\n  "</span><span class="pl-kos">]</span><span class="pl-kos">,</span>
  <span class="pl-kos">[</span><span class="pl-s">"\n    &lt;div&gt;\n      &lt;h1&gt;Hello, world!&lt;/h1&gt;\n      &lt;h2&gt;It is "</span><span class="pl-kos">,</span> <span class="pl-s">".&lt;/h2&gt;\n    &lt;/div&gt;\n  "</span><span class="pl-kos">]</span>
<span class="pl-kos">)</span><span class="pl-kos">;</span>

<span class="pl-k">function</span> <span class="pl-en">_taggedTemplateLiteral</span><span class="pl-kos">(</span><span class="pl-s1">strings</span><span class="pl-kos">,</span> <span class="pl-s1">raw</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-k">return</span> <span class="pl-v">Object</span><span class="pl-kos">.</span><span class="pl-en">freeze</span><span class="pl-kos">(</span><span class="pl-v">Object</span><span class="pl-kos">.</span><span class="pl-en">defineProperties</span><span class="pl-kos">(</span><span class="pl-s1">strings</span><span class="pl-kos">,</span> <span class="pl-kos">{</span> <span class="pl-c1">raw</span>: <span class="pl-kos">{</span> <span class="pl-c1">value</span>: <span class="pl-v">Object</span><span class="pl-kos">.</span><span class="pl-en">freeze</span><span class="pl-kos">(</span><span class="pl-s1">raw</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-kos">;</span> <span class="pl-kos">}</span>

<span class="pl-en">render</span><span class="pl-kos">(</span><span class="pl-s1">_templateObject</span><span class="pl-kos">,</span> <span class="pl-k">new</span> <span class="pl-v">Date</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">toLocaleTimeString</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">Clearly this is not ideal, as it is not only longer, but also contains unwanted characters, which make the bundle little tiny bit heavier.</p>
<h3 dir="auto">Possible Solution</h3>
<p dir="auto">Allow dev to optionally pass in <code class="notranslate">html</code> together with <code class="notranslate">loose</code> / <code class="notranslate">spec</code>. From the <a href="/babel/babel/blob/7.0/packages/babel-plugin-transform-es2015-template-literals/src/index.js#L38">following line</a>:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="strings.push(value);"><pre class="notranslate"><span class="pl-s1">strings</span><span class="pl-kos">.</span><span class="pl-en">push</span><span class="pl-kos">(</span><span class="pl-s1">value</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">Can it be changed to:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="strings.push(value.replace(/\r\n\t/g, ''));"><pre class="notranslate"><span class="pl-s1">strings</span><span class="pl-kos">.</span><span class="pl-en">push</span><span class="pl-kos">(</span><span class="pl-s1">value</span><span class="pl-kos">.</span><span class="pl-en">replace</span><span class="pl-kos">(</span><span class="pl-pds"><span class="pl-c1">/</span><span class="pl-cce">\r</span><span class="pl-cce">\n</span><span class="pl-cce">\t</span><span class="pl-c1">/</span>g</span><span class="pl-kos">,</span> <span class="pl-s">''</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">when <code class="notranslate">html</code> === true ?</p>
<table role="table">
<thead>
<tr>
<th>software</th>
<th>version(s)</th>
</tr>
</thead>
<tbody>
<tr>
<td>Babel</td>
<td>latest</td>
</tr>
</tbody>
</table>