Unfortunately, my search for a solution to this issue across the internet has been fruitless.
I am currently working on an Aurelia application that is built using TypeScript
, Aurelia CLI
, and RequireJS
. The project structure looks like this:
|data
|-MyService.ts
|workers
|-SomeWorker.ts/js
There is a package called aurelia-pal-worker
, however it lacks comprehensive documentation and detailed examples.
Methods I've experimented with so far
Typed-Web-Workers
, which proved to be restrictive- Created a
SomeWorker
.js file and integrated Browserify as an additional build step in the aurelia_project.
The Browserify approach functions well when external libraries like RxJs
are required. However, it fails when attempting to require("../data/MyService.ts")
. To make this work, I would need to replace the entire build process with one that runs the whole Aurelia project through Browserify with the tsify plugin.
It appears that I have three potential solutions:
- Find a successful example of compiling a TypeScript file into a web worker and utilizing
aurelia-pal-worker
for importing dependencies. - Utilize
TypedWorker
and place resource-intensive functions into a thread like:new TypedWoker(expensiveFuncFromService, handleOutput)
- Compile
MyService.ts
into separate JS files (rather than bundling them) and require them in this manner:
require("/scripts/MyService.js")
The latter two options do not seem particularly appealing to me, but they should be relatively simple to execute. Any guidance or examples would be greatly appreciated!
PS: For those unfamiliar with Aurelia: It utilizes a gulp pipeline behind the scenes.