maximegris / angular-electron

Ultra-fast bootstrapping with Angular and Electron :speedboat:
https://www.maximegris.fr/angular-electron/
MIT License
5.67k stars 1.37k forks source link

Angular web worker configuration bug. Cannot find name... #578

Closed nikhilnxvverma1 closed 3 years ago

nikhilnxvverma1 commented 3 years ago

For the last 3 days I have been pulling my hair to get a basic angular web worker to work.

ng generate web-worker my-web-worker

When I do that, angular does its job of generating and updating some configuration files. Upon setting up all the other scaffolding code to basically fire up the web worker, my entire console is filled up with errors like:

Cannot find name HTMLSpanElement Cannot find name HTMLCanvas etc, etc...

Now I am not using any DOM API in my ("hello worldish") web worker obviously but all my html component code automatically gets bundled in with the web worker code suggestively spitting the above errors.

After many failed attempts I noticed that the root tsconfig.json file (from which tsconfig.worker.json inherits), actually hosts all the files from the start "files": [ "src/main.ts", "src/polyfills.ts" ], "include": [ "src/**/*.d.ts" ], "exclude":[ "node_modules ]

A general angular project, usually has these critical file handling configurations listed under tsconfig.app.json which also inherits root tsconfig.json. I shifted the above snippet there and adjusted for relative file paths and then the error were gone.

I hope anyone who runs into this issue doesn't have to spend all that much time on it. I wish ng g web-worker just worked in the first place for me.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Rajdeep97 commented 3 years ago

not fixed

Rajdeep97 commented 3 years ago

@nikhilnxvverma1 : Can you please elaborate with some pictures.... Feels like it will help a lot of people

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

nikhilnxvverma1 commented 3 years ago

@Rajdeep97 you probably wont run into this problem until you are using web workers. Are you using web workers and if so did the above fix not work for you?

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

TheMikeSanto commented 2 years ago

Not fixed