Skip to content

ng build doesn't create worker file #21431

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

Closed
a1exymoroz opened this issue Jul 27, 2021 · 9 comments
Closed

ng build doesn't create worker file #21431

a1exymoroz opened this issue Jul 27, 2021 · 9 comments
Labels
needs: repro steps We cannot reproduce the issue with the information given

Comments

@a1exymoroz
Copy link

a1exymoroz commented Jul 27, 2021

Hi,

I have a problem with a web worker. I started updating the app from version 9 to version 12. I have updated the file where the worker was declared,

Angular 9
new worker ('./ worker / db-worker.worker', {type: 'module'});

Angular 12 after ng update
new worker (new url ('./ worker / db-worker.worker', import.meta.url), {type: 'module'});

Now when I run ng build, a separate file for worker is created, as it actually was before (only with a different name, well, that's another question).

Now there is localhost in the beginning, but I don't need it.
But if you remove import.meta.url, then the file won't be built.

How to build the working file without import.meta.url(localhost)?

Angular CLI: 12.1.3
Node: 14.15.0
Package Manager: npm 6.14.8
OS: win32 x64

Angular: 12.1.3
... animations, cdk, cli, common, compiler, compiler-cli, core
... elements, forms, language-service, localize
... platform-browser, platform-browser-dynamic, router

Package Version

@angular-devkit/architect 0.1201.3
@angular-devkit/build-angular 12.1.3
@angular-devkit/core 12.1.3
@angular-devkit/schematics 12.1.3
@schematics/angular 12.1.3
rxjs 6.5.5
typescript 4.3.5

@clydin
Copy link
Member

clydin commented Jul 28, 2021

Can you provide an example of what you are describing in regards to "localhost in the beginning"?
A minimal reproduction would also be helpful in further diagnosing the issue.

@clydin clydin added the needs: repro steps We cannot reproduce the issue with the information given label Jul 28, 2021
@a1exymoroz
Copy link
Author

a1exymoroz commented Jul 28, 2021

We have 2 projects. First is main project, second is a part of the main project. And second project builds via ngx-build-plus as angular elements.
So second project has worker file. When I run ng build and a worker file is created. Then we move the worker file to the main project. Before everything was ok, but now I have this

image

@alan-agius4
Copy link
Collaborator

alan-agius4 commented Jul 28, 2021

I suspect this is related to #21432 (comment), can you confirm that you are using deployUrl?

@a1exymoroz
Copy link
Author

a1exymoroz commented Jul 28, 2021

I suspect this is related to #21432 (comment), can you confirm that you are using deployUrl?

image

I don't use deployUrl, I just run ng build

@alan-agius4
Copy link
Collaborator

Can you please provide the fullest of options of the build target? In the screenshot above you only provided a sub-set of options.

if you are indeed not using deployUrl, we’d require a minimal reproduction.

You can read here why this is needed. A good way to make a minimal repro is to create a new app via ng new repro-app and adding the minimum possible code to show the problem. Then you can push this repository to github and link it here.

@a1exymoroz
Copy link
Author

Ok, I'll create the repo. But maybe you don't understand me(
My questions:
Why don't I have a worker file in my dist folder, if I delete import.meta.url?
How does angular 12 build a file with web worker?
image

@clydin
Copy link
Member

clydin commented Jul 28, 2021

That code structure is required by Webpack to process WebWorkers. For additional information, please see https://webpack.js.org/guides/web-workers/

@a1exymoroz
Copy link
Author

That code structure is required by Webpack to process WebWorkers. For additional information, please see https://webpack.js.org/guides/web-workers/

Thanks)
If I want to work with web workers, I have to set import.meta.url.
If I won't set import.meta.url, I don't have a file in a dist folder.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs: repro steps We cannot reproduce the issue with the information given
Projects
None yet
Development

No branches or pull requests

3 participants