title: workerize-loader failed to work after compiling (react typescript)
body: <p>I created a rust-wasm module and use workerize-loader to load it:</p>
  
  <pre><code>export const getQRCode = async (
    arg: string,
    width: number,
    height: number
  ) =&gt; {
    const { qrcode } = await import('uranus-qrcode');
    return qrcode(arg, width, height);
  };
  </code></pre>
  
  <p>and then I use the worker as such:</p>
  
  <pre><code>// @ts-ignore
  // eslint-disable-next-line import/no-webpack-loader-syntax
  import qrCodeWorker from 'workerize-loader!workers/qrCodeWorker';
  
  ...
    const workerizeQRLoader = async () =&gt; {
      try {
        const instance = qrCodeWorker();
        const qr = await instance.getQRCode(href, 150, 150);
        setQRCode({
          __html: qr
        });
      } catch (e) {
        console.warn(e);
      }
    };
  ...
    useEffect(() =&gt; {
      workerizeQRLoader();
      // qrLoader();
    // eslint-disable-next-line react-hooks/exhaustive-deps
    }, []);
  ...
  </code></pre>
  
  <p>The above works in dev mode, but after compiling it says:</p>
  
  <pre><code>TypeError: a.getQRCode is not a function
      at 8.a2ac9b2e.chunk.js:1
      at l (0.69608c56.chunk.js:2)
      at Generator._invoke (0.69608c56.chunk.js:2)
      at Generator.forEach.e.&lt;computed&gt; [as next] (0.69608c56.chunk.js:2)
      at r (0.69608c56.chunk.js:2)
      at s (0.69608c56.chunk.js:2)
      at 0.69608c56.chunk.js:2
      at new Promise (&lt;anonymous&gt;)
      at 0.69608c56.chunk.js:2
      at 8.a2ac9b2e.chunk.js:1
  </code></pre>
  
  <p>If I import the rust-wasm module directly into the main thread it works:</p>
  
  <pre><code>...
    const qrLoader = async () =&gt; {
      const { qrcode: render } = await import('uranus-qrcode');
      const qr = await render(href, 150, 150);
      setQRCode({
        __html: qr
      });
    };
    useEffect(() =&gt; {
      // workerizeQRLoader();
      qrLoader();
    // eslint-disable-next-line react-hooks/exhaustive-deps
    }, []);
  ...
  </code></pre>
  
  <p>Basically I try to get React (Webpack &amp; TypeScript flavor) to load WebAssembly modules (aka wasm, created via Rust-Wasmbindgen) through web workers.  I've tried workerize-loader + wasm-loader, and it works pretty well in the dev mode but once it is compiled, the prototype will not be added to the worker (suspecting it's a bug in workerize-loader because all workerized modules behave the same). I also tried to work with worker-loader + comlink, but the worker-loader doesn't seem to work with wasm-loader (would not be able to import wasm into the worker). The only way to get this to work is to load wasm into the main thread via wasm-loader and just give up the multi-threads setup which is basically a shame...so does anyone have successfully use a WebAssembly module loaded through a web worker in a React TypeScript project? What's your setup?</p>
  
  <p>I also created a starter project: <a href="https://github.com/aeroxy/react-typescript-webassembly-starter.git" rel="nofollow noreferrer">https://github.com/aeroxy/react-typescript-webassembly-starter.git</a></p>
  
  <p>You can checkout the "workerize" branch and see how it works in dev mode but after compiling, it throws "not a function" error.</p>