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

Open
andsouto opened this issue Jan 29, 2024 · 0 comments
Open

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

andsouto opened this issue Jan 29, 2024 · 0 comments

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

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