Skip to content

Uncaught ReferenceError: _helper_class__WEBPACK_IMPORTED_MODULE_0__ is not defined #4

@jacopolanzoni-pq

Description

@jacopolanzoni-pq

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:

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:

import { HelperClass } from './helper.class';

export const MY_SCRIPT = () => {

  const helperClass: HelperClass = new HelperClass();
  helperClass.doExpensiveComputation();

};

and helper.class.ts contains the following:

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:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions