title: How can I fix Webpack related error: Cannot assign to read only property 'exports' of object '#<Object>'?
body: <p>I'm using webpack, which, if I understand correctly, doesn't support native webworker syntax, so I'm trying to use the <code>worker-loader</code> npm module, but I'm getting a weird error. </p>
  
  <p>The module can be found <a href="https://github.com/webpack-contrib/worker-loader" rel="noreferrer">here</a>.</p>
  
  <p>My webpack config:</p>
  
  <pre><code>module.exports = {
      entry: "./app",
      output: {
          path: __dirname + "/build",
          filename: "bundle.js"
      },
      watch: true,
      module: {
          rules: [{
              test: /\.worker\.js$/,
              use: {
                  loader: 'worker-loader'
              }
          }]
      }
  }
  </code></pre>
  
  <p>My code triggering the error:</p>
  
  <pre><code>import Worker from '../workers/sim.js';
  
  class Synapse {
    // ...
  }
  
  module.exports = Synapse;
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>Cannot assign to read only property 'exports' of object '#&lt;Object&gt;'?
  </code></pre>
  
  <p>which points to <code>module.exports = Synapse</code></p>