Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught ReferenceError: _helper_class__WEBPACK_IMPORTED_MODULE_0__ is not defined #4

Open
jacopolanzoni-pq opened this issue Feb 4, 2019 · 0 comments

Comments

@jacopolanzoni-pq
Copy link

jacopolanzoni-pq commented Feb 4, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant