-
Notifications
You must be signed in to change notification settings - Fork 12k
Console error "providers is not defined" when built in production mode #18149
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
Comments
Hi @bbarry, Thanks for the report! I'm sorry to have to ask for this, but I wasn't able to reproduce this problem locally and so I need you to provide a small reproduction with instructions that demonstrates the problem, either in the form of a StackBlitz project or a Github repo. |
I was able to reproduce and investigation leads to a limitation in the CLI's ability to detect which imports can be elided. The issue here is that the Angular compiler emits the This change allows it to work correctly: switch (node.kind) {
case ts.SyntaxKind.Identifier:
symbol = typeChecker.getSymbolAtLocation(node);
const parent = node.parent;
+ if (parent && ts.isShorthandPropertyAssignment(parent)) {
+ const shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(parent);
+ if (shorthandSymbol) {
+ usedSymbols.add(shorthandSymbol);
+ }
+ }
break;
case ts.SyntaxKind.ExportSpecifier:
symbol = typeChecker.getExportSpecifierLocalTargetSymbol(node as ts.ExportSpecifier);
break;
case ts.SyntaxKind.ShorthandPropertyAssignment:
symbol = typeChecker.getShorthandAssignmentValueSymbol(node);
break;
} Note that the case it has for |
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. |
…handPropertyAssignment NGTSC, will transform `ShorthandPropertyAssignment` to `PropertyAssignment`, with this change we handle such cases and retain the import which previously was dropped. Closes angular#18149 and closes angular#17347
🐞 bug report
Affected Package
I suspect this is an issue in the angular compiler, not 100% sure though, could be the `NgModule` attribute in @angular/core?Is this a regression?
I don't know, my internet is too slow to try and make a full reproduction against an older version.Description
In my application I have a file `app.providers.ts` which has:my
app.module.ts
(lines removed):Using
ng serve
the site runs fine in development. Usingng build --aot --prod --subresource-integrity
the errorproviders is not defined
appears in my dev console when browsing the site.I am able to work around the issue by changing the
imports,
andproviders,
lines above to:🔥 Exception or Error
(after modifying production config to enable source map)
after fixing only the providers line
🌍 Your Environment
Angular Version:
The text was updated successfully, but these errors were encountered: