Webpack 5 documentation mentions that worker-loader is not needed anymore, and it seems easy for javascript files. However, I am using Typescript, and I'm not able to get my worker.js output file working properly. When I launch load the webworker with const worker = new Worker(workerPath);, I get
Uncaught SyntaxError: Cannot use import statement outside a module
Note: my workerPath is "dist/app.worker.js" and this file exists, but it sadly contains either import or require statements, which don't work in the browser. I think need to bundle these together, but I'm not sure how. Currently, it contains the following code, and I hoped that auth.ts will be bundled in:
import Auth from "./auth";