Hi. I followed the instruction for the Typescript WebWorker integration for Webpack here: GitHub - webpack-contrib/worker-loader: A webpack loader that registers a script as a Web Worker
Even when my IDE is able to resolve it, my Aurelia application is not able to load the module.
Module worker-loader.d.ts
declare module "worker-loader!*" {
// You need to change `Worker`, if you specified a different value for the `workerType` option
class WebpackWorker extends Worker {
constructor();
}
// Uncomment this if you set the `esModule` option to `false`
// export = WebpackWorker;
export default WebpackWorker;
}
My main.ts
import Worker from "worker-loader!./worker";
export function configure(aurelia: Aurelia) {
const worker = new Worker();
worker.postMessage({ a: 1 });
worker.onmessage = (event) => {};
worker.addEventListener("message", (event) => {});
The error message:
ERROR in ./src/main.ts
Module not found: Error: Can't resolve './worker' in 'C:\Users\xxx\IdeaProjects\webapp\src'
@ ./src/main.ts 3:0-44 5:23-29
@ ./node_modules/aurelia-webpack-plugin/runtime/empty-entry.js
@ multi aurelia-webpack-plugin/runtime/empty-entry aurelia-webpack-plugin/runtime/pal-loader-entry aurelia-bootstrapper
Here is a working example: GitHub - JamesLMilner/webpack-tsc-worker: An example of using Workers built with TypeScript and Webpack (but without Aurelia)