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

A WebWorker declared in a dependency is not correctly bundled #26991

Closed
andsouto opened this issue Jan 29, 2024 · 1 comment
Closed

A WebWorker declared in a dependency is not correctly bundled #26991

andsouto opened this issue Jan 29, 2024 · 1 comment

Comments

@andsouto
Copy link

Command

build

Description

If a library that uses a Web Worker is used, the angular bundle generation is not including the worker file.

I made a mimimal reproduction case here: https://github.com/andsouto/angular-webworker-example

That project just imports in main.component.ts the next function from a dependency:

export function launchWorker() {
    console.warn('Example of creating a webworker in a dependency');
    const worker = new Worker(new URL('./x.worker', import.meta.url), {type: 'module'});
    worker.postMessage('foo');
}

If that code is included in the app itself it works as expected but when it is declared in a dependency it fails.

Afaik, in the dev server is not working because vite does not support this yet. More info including workarounds in this issue: vitejs/vite#11672

But my main concern here is the production build because I suspect that is a problem in the angular build system itself and I wasn't able to find any workaround for this.

Describe the solution you'd like

Correctly bundle Web Workers declared in a dependency.

Describe alternatives you've considered

No response

@alan-agius4
Copy link
Collaborator

Thanks for reporting this issue. Luckily, it has already been fixed in one of the recent releases. Please update to the most recent version to resolve the problem.

If the problem persists in your application after upgrading, please open a new issue, provide a simple repository reproducing the problem, and describe the difference between the expected and current behavior. You can use ng new repro-app to create a new project where you reproduce the problem.

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

No branches or pull requests

2 participants