<h1 dir="auto">Bug report</h1>
<p dir="auto">[Note: unclear to me whether this issue comes from Webpack, Babel, or the combination of the two, <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/Timer/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/Timer">@Timer</a> suggested bringing this here]</p>
<p dir="auto"><strong>What is the current behavior?</strong></p>
<p dir="auto">Bundling an ES6 module using the rest/spread syntax somewhere in the file works, but if the same file uses a CommonJS format instead, it throws a bundling error unrelated to the syntax.</p>
<p dir="auto"><strong>Steps to reproduce.</strong></p>
<ol dir="auto">
<li>
<p dir="auto">Create a vanilla create-react-app app with react-scripts@2.1.2.</p>
</li>
<li>
<p dir="auto">Create two files: <code class="notranslate">src/es6.js</code> and <code class="notranslate">src/cjs.js</code>.</p>
</li>
</ol>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// es6.js
export default ({ foo, ...rest }) =&gt; true;

// cjs.js
module.exports = ({ foo, ...rest }) =&gt; true;"><pre class="notranslate"><span class="pl-c">// es6.js</span>
<span class="pl-k">export</span> <span class="pl-k">default</span> <span class="pl-kos">(</span><span class="pl-kos">{</span> foo<span class="pl-kos">,</span> ...<span class="pl-s1">rest</span> <span class="pl-kos">}</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-c1">true</span><span class="pl-kos">;</span>

<span class="pl-c">// cjs.js</span>
<span class="pl-smi">module</span><span class="pl-kos">.</span><span class="pl-en">exports</span> <span class="pl-c1">=</span> <span class="pl-kos">(</span><span class="pl-kos">{</span> foo<span class="pl-kos">,</span> ...<span class="pl-s1">rest</span> <span class="pl-kos">}</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-c1">true</span><span class="pl-kos">;</span></pre></div>
<ol start="3" dir="auto">
<li>
<p dir="auto">Run <code class="notranslate">npm start</code> or <code class="notranslate">yarn start</code>.</p>
</li>
<li>
<p dir="auto">Import both of them into App.js, one at a time:</p>
</li>
</ol>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import es6 from &quot;./es6.js&quot;;
// then
import cjs from &quot;./cjs.js&quot;;"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">es6</span> <span class="pl-k">from</span> <span class="pl-s">"./es6.js"</span><span class="pl-kos">;</span>
<span class="pl-c">// then</span>
<span class="pl-k">import</span> <span class="pl-s1">cjs</span> <span class="pl-k">from</span> <span class="pl-s">"./cjs.js"</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">A full repro is here: <a href="https://github.com/veltman/webpack-babel-bug-repro">https://github.com/veltman/webpack-babel-bug-repro</a></p>
<p dir="auto"><strong>What is the expected behavior?</strong></p>
<p dir="auto">Importing either file should bundle successfully. Instead, importing the ES6 module works, but importing the CJS version throws one of two errors during bundling, depending on whether it's the first attempt to build or a subsequent attempt:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="Attempted import error: './cjs.js' does not contain a default export (imported as 'cjs').

or

TypeError: Cannot assign to read only property 'exports' of object '#&lt;Object&gt;'"><pre class="notranslate"><span class="pl-v">Attempted</span> <span class="pl-s1">import</span> error: <span class="pl-s">'./cjs.js'</span> <span class="pl-s1">does</span> <span class="pl-s1">not</span> <span class="pl-s1">contain</span> <span class="pl-s1">a</span> <span class="pl-k">default</span> <span class="pl-en">export</span> <span class="pl-kos">(</span><span class="pl-s1">imported</span> <span class="pl-s1">as</span> <span class="pl-s">'cjs'</span><span class="pl-kos">)</span><span class="pl-kos">.</span>

<span class="pl-c1">or</span>

TypeError: <span class="pl-v">Cannot</span> <span class="pl-s1">assign</span> <span class="pl-s1">to</span> <span class="pl-s1">read</span> <span class="pl-s1">only</span> <span class="pl-s1">property</span> <span class="pl-s">'exports'</span> <span class="pl-s1">of</span> <span class="pl-s1">object</span> <span class="pl-s">'#&lt;Object&gt;'</span></pre></div>
<p dir="auto">This appears to be specific to the language features being used. If I replace the rest/spread with plain destructuring (<code class="notranslate">({ foo, bar }) =&gt; true</code>), both files work, they're transpiled and bundled without an error.</p>
<p dir="auto">webpack version:  4.19.1<br>
Node.js version: 10.13.0<br>
Operating System: OS X<br>
Additional tools: react-scripts</p>
<h1 dir="auto">Bug report</h1>




<p dir="auto"><strong>What is the current behavior?</strong><br>
Currently it is not possible to consume federated module inside of web worker.</p>
<p dir="auto"><strong>If the current behavior is a bug, please provide the steps to reproduce.</strong><br>
Try to import federated module inside of web worker script.<br>
Theres a repo with reproduced issue.<br>
<a href="https://github.com/grzesiek-ds/webpack-mf-workers">https://github.com/grzesiek-ds/webpack-mf-workers</a></p>






<p dir="auto"><strong>What is the expected behavior?</strong><br>
It should be possible to import federated module inside of web worker script.</p>


<p dir="auto"><strong>Other relevant information:</strong><br>
webpack version: <code class="notranslate">5.74.0</code> (also applies to <code class="notranslate">5.75.0</code>)</p>
<p dir="auto">It seems that this might be the same issue as in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1346882319" data-permission-text="Title is private" data-url="https://github.com/webpack/webpack/issues/16173" data-hovercard-type="issue" data-hovercard-url="/webpack/webpack/issues/16173/hovercard" href="https://github.com/webpack/webpack/issues/16173">#16173</a>, although I'm not sure.<br>
I've tried to include <a href="https://github.com/webpack/webpack/issues/16173#issuecomment-1226431857" data-hovercard-type="issue" data-hovercard-url="/webpack/webpack/issues/16173/hovercard">mentioned plugin</a> in host application webpack config, but it gave no effect.</p>
<p dir="auto"><a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/edusperoni/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/edusperoni">@edusperoni</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/ScriptedAlchemy/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/ScriptedAlchemy">@ScriptedAlchemy</a> if You have any additional information, or possible fix/workaround, please share.</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/95348943/212143083-9caf4c08-98e3-40e2-82c8-0f6e418b3908.png"><img src="https://user-images.githubusercontent.com/95348943/212143083-9caf4c08-98e3-40e2-82c8-0f6e418b3908.png" alt="image" style="max-width: 100%;"></a></p>