Open jacopolanzoni-pq opened 5 years ago
I am working on an Angular 6 app, and I am trying to use a web worker Worker (via ngx-web-worker) to perform some complex and CPU-expensive operations. I have the following service:
Worker
ngx-web-worker
import { MY_SCRIPT } from './my-script.script'; import { WebWorkerService } from 'ngx-web-worker'; @Injectable({ providedIn: 'root', }) export class MyService { constructor(private webworkerService: WebWorkerService) { this.webworkerService.run(MY_SCRIPT).then((data) => { console.log(data); }, (error) => { console.error(error); }); } }
where my-script.script.ts contains the following:
my-script.script.ts
import { HelperClass } from './helper.class'; export const MY_SCRIPT = () => { const helperClass: HelperClass = new HelperClass(); helperClass.doExpensiveComputation(); };
and helper.class.ts contains the following:
helper.class.ts
export class HelperClass { doExpensiveComputation() { // do some complex and expensive computation } }
The class HelperClass is not imported in any Angular module. The app builds fine, but at runtime I get an error with the following message:
HelperClass
Uncaught ReferenceError: _helper_class__WEBPACK_IMPORTED_MODULE_0__ is not defined
How can I give webpack the information it needs?
https://stackoverflow.com/questions/54519923/how-can-webpack-serve-files-to-a-web-worker-in-an-angular-6-app
I am working on an Angular 6 app, and I am trying to use a web worker
Worker
(viangx-web-worker
) to perform some complex and CPU-expensive operations. I have the following service:where
my-script.script.ts
contains the following:and
helper.class.ts
contains the following:The class
HelperClass
is not imported in any Angular module. The app builds fine, but at runtime I get an error with the following message:How can I give webpack the information it needs?
https://stackoverflow.com/questions/54519923/how-can-webpack-serve-files-to-a-web-worker-in-an-angular-6-app