-
Notifications
You must be signed in to change notification settings - Fork 12k
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
Application builder doesn't tree shake non top-level variables #26776
Comments
@JeanMeche, indeed this is related to evanw/esbuild#639. This is not really actionable from our end since this is by esbuild design. The method however, can be updated to make it possible for the unused variable to be dropped when export function throwProviderNotFoundError(token: any, injectorName?: string): never {
if (ngDevMode) {
const injectorDetails = injectorName ? ` in ${injectorName}` : '';
throw new RuntimeError(
RuntimeErrorCode.PROVIDER_NOT_FOUND,
`No provider for ${stringifyForError(token)} found${injectorDetails}`);
} else {
throw new RuntimeError(RuntimeErrorCode.PROVIDER_NOT_FOUND);
}
} Which will result in the below, when export function throwProviderNotFoundError(r,o){
throw new RuntimeError(RuntimeErrorCode.PROVIDER_NOT_FOUND);
} |
Thx, this is what I afraid of. I have already a PR for this one but more generally this means that we'll need to evolve our coding practices. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Command
build
Description
While investigating prod builds I did notice, in some cases tree shaking is less efficient when using esbuild.
For example here:
https://github.com/angular/angular/blob/d315e2c4fa178dfbd41bc25259605bb999fa302e/packages/core/src/render3/errors_di.ts#L54-L57
The
injectorDetails
const remains in the final bundle while being unused.This issue does not occur when using the webpack/terser.
I believe this is related to evanw/esbuild#639.
Minimal Reproduction
ng new foobar
throwProviderNotFoundError
isn't removed by tree-shaking when using esbuild.Exception or Error
No response
Your Environment
Anything else relevant?
cc @AndrewKushnir
The text was updated successfully, but these errors were encountered: