<h2 dir="auto">Bug Report</h2>
<p dir="auto"><strong>Current Behavior</strong><br>
When <code class="notranslate">export * from</code> and named <code class="notranslate">export</code> statements in the same file both export a value with the same name a runtime error is thrown.</p>
<p dir="auto">This happens because Babel adds a getter to the <code class="notranslate">exports</code> variable when transpiling <code class="notranslate">export * from</code> but doesn't add a setter. The <code class="notranslate">export</code> statement simply assigns the property on <code class="notranslate">exports</code>. This is an error in strict mode, and would not overwrite the value even if it wasn't in strict mode.</p>
<p dir="auto"><strong>Input Code</strong></p>
<ul dir="auto">
<li><a href="https://babeljs.io/repl/#?babili=false&amp;browsers=&amp;build=&amp;builtIns=false&amp;spec=false&amp;loose=false&amp;code_lz=KYDwDg9gTgLgBAKjgMyhAtnA5AOgPQCeWA3HHnnAAYE4BWAzpXKJLPVQIaUBQL08AYwgA7evA5wAvNhAkyFADwBaZlDRQgA&amp;debug=false&amp;forceAllTransforms=false&amp;shippedProposals=false&amp;circleciRepo=&amp;evaluate=false&amp;fileSize=false&amp;sourceType=module&amp;lineWrap=true&amp;presets=env&amp;prettier=false&amp;targets=&amp;version=6.26.0&amp;envVersion=1.6.2" rel="nofollow">REPL link</a></li>
</ul>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// x.js
export * from './y';
export const a = 'x'; // &lt;- throws error (but should export `a` as `'x'`)

// y.js
export const a = 'y';"><pre class="notranslate"><span class="pl-c">// x.js</span>
<span class="pl-k">export</span> <span class="pl-c1">*</span> <span class="pl-k">from</span> <span class="pl-s">'./y'</span><span class="pl-kos">;</span>
<span class="pl-k">export</span> <span class="pl-k">const</span> <span class="pl-s1">a</span> <span class="pl-c1">=</span> <span class="pl-s">'x'</span><span class="pl-kos">;</span> <span class="pl-c">// &lt;- throws error (but should export `a` as `'x'`)</span>

<span class="pl-c">// y.js</span>
<span class="pl-k">export</span> <span class="pl-k">const</span> <span class="pl-s1">a</span> <span class="pl-c1">=</span> <span class="pl-s">'y'</span><span class="pl-kos">;</span></pre></div>
<p dir="auto"><strong>Expected behavior/code</strong><br>
The local export should be exported instead of the star export with no error being thrown.</p>
<p dir="auto">ECMA spec: <a href="http://www.ecma-international.org/ecma-262/6.0/#sec-getexportednames" rel="nofollow">http://www.ecma-international.org/ecma-262/6.0/#sec-getexportednames</a></p>
<p dir="auto">Similar older issue: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="175599305" data-permission-text="Title is private" data-url="https://github.com/babel/babel/issues/3986" data-hovercard-type="issue" data-hovercard-url="/babel/babel/issues/3986/hovercard" href="https://github.com/babel/babel/issues/3986">#3986</a></p>
<p dir="auto"><strong>Environment</strong></p>
<ul dir="auto">
<li>Babel version(s): v6.x (probably affects v7.x too)</li>
</ul>
<p dir="auto"><strong>Possible Solution</strong><br>
Add a setter which removes the property descriptor and overwrites the value.</p>
<p dir="auto">I think the helper comes from here:<br>
<a href="https://github.com/babel/babel/blob/master/packages/babel-helper-module-transforms/src/index.js#L246">https://github.com/babel/babel/blob/master/packages/babel-helper-module-transforms/src/index.js#L246</a><br>
<a href="https://github.com/babel/babel/blob/6.x/packages/babel-plugin-transform-es2015-modules-commonjs/src/index.js#L37">https://github.com/babel/babel/blob/6.x/packages/babel-plugin-transform-es2015-modules-commonjs/src/index.js#L37</a></p>
<p dir="auto">`node server.js<br>
/Users/z/project/webpack_babel7/reducers/index.js:1<br>
(function (exports, require, module, __filename, __dirname) { import { combineReducers } from 'redux';<br>
^^^^^^</p>
<p dir="auto">SyntaxError: Unexpected token import<br>
at createScript (vm.js:80:10)<br>
at Object.runInThisContext (vm.js:139:10)<br>
at Module._compile (module.js:616:28)<br>
at Module._compile (/Users/z/project/webpack_babel7/_server/node_modules/pirates/lib/index.js:83:24)<br>
at Module._extensions..js (module.js:663:10)<br>
at Object.newLoader [as .js] (/Users/z/project/webpack_babel7/_server/node_modules/pirates/lib/index.js:88:7)<br>
at Module.load (module.js:565:32)<br>
at tryModuleLoad (module.js:505:12)<br>
at Function.Module._load (module.js:497:3)<br>
at Module.require (module.js:596:17)`</p>
<p dir="auto"><a href="https://github.com/againksy/webpack4-serverside-react16/tree/babel7">https://github.com/againksy/webpack4-serverside-react16/tree/babel7</a><br>
branch babel7<br>
everything set as in tutorials</p>