andywer / threads-plugin

📦 Makes your threads.js code build with webpack out of the box.
Apache License 2.0
28 stars 6 forks source link

Does not work with require #40

Closed AllanOricil closed 3 years ago

AllanOricil commented 3 years ago

For some reason when I change from import to require, I get this warning and the worker file is not emitted in my dist. If I use import, then my code breaks, but the file is emitted. How can I fix it?

image

When using Import

image

andywer commented 3 years ago

Hey @AllanOricil. Yeah, this is as intended. There is unfortunately no easy way around that right now.

Background: ES imports/exports are easy to parse, require() call assignments are not. Especially when Babel compiles it, it produces a bit of a hard-to-trace-back mess in the code.

AllanOricil commented 3 years ago

@andywer ok. It is better if you add on the README "It does not work with common js (require)"