You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(compiler-cli): show a more specific error for Ivy NgModules (#41534) (#41598)
When an Ivy NgModule is imported into a View Engine build, it doesn't have
metadata.json files that describe it as an NgModule, so it appears to VE
builds as a plain, undecorated class. The error message shown in this
situation generic and confusing, since it recommends adding an @NgModule
annotation to a class from a library.
This commit adds special detection into the View Engine compiler to give a
more specific error message when an Ivy NgModule is imported.
PR Close#41534
PR Close#41598
messageText: `The NgModule '${ngModuleErrorData.className}' in '${
1058
+
ngModuleErrorData
1059
+
.fileName}' is imported by this compilation, but appears to be part of a library compiled for Angular Ivy. This may occur because:
1060
+
1061
+
1) the library was processed with 'ngcc'. Removing and reinstalling node_modules may fix this problem.
1062
+
1063
+
2) the library was published for Angular Ivy and v12+ applications only. Check its peer dependencies carefully and ensure that you're using a compatible version of Angular.
1064
+
1065
+
See https://angular.io/errors/NG6999 for more information.
1066
+
`,
1067
+
category: ts.DiagnosticCategory.Error,
1068
+
code: DEFAULT_ERROR_CODE,
1069
+
source: SOURCE,
1070
+
}];
1071
+
}
1072
+
}
1073
+
1047
1074
// Produce a Diagnostic anyway since we know for sure `error` is a SyntaxError
1048
1075
return[{
1049
1076
messageText: error.message,
@@ -1052,3 +1079,38 @@ function syntaxErrorToDiagnostics(error: Error): Diagnostic[] {
0 commit comments