@@ -39,7 +39,18 @@ function findAngularCompilerCliVersion(): string {
39
39
const nodeModuleDirPath = findNodeModulesDirectory ( ) ;
40
40
41
41
export const runNgccJestProcessor = ( tsconfigPath : string | undefined ) : void => {
42
- if ( nodeModuleDirPath ) {
42
+ const ngCompilerCliVersion = findAngularCompilerCliVersion ( ) ;
43
+ const [ ngMajorVersion ] = ngCompilerCliVersion . split ( '.' ) ;
44
+ if ( parseInt ( ngMajorVersion , 10 ) >= 16 ) {
45
+ console . warn ( `
46
+ Running 'ngcc' is not required for Angular 16+ projects. This 'ngcc-jest-processor' script will be removed in the next major version of 'jest-preset-angular'.
47
+ Tip: To avoid this message you can remove 'jest-preset-angular/global-setup' from your jest config
48
+ ` ) ;
49
+
50
+ return ;
51
+ }
52
+
53
+ if ( ngccPath && nodeModuleDirPath ) {
43
54
process . stdout . write ( '\nngcc-jest-processor: running ngcc\n' ) ;
44
55
45
56
const ngccBaseArgs = [
@@ -72,21 +83,13 @@ export const runNgccJestProcessor = (tsconfigPath: string | undefined): void =>
72
83
73
84
throw new Error ( `${ errorMessage } NGCC failed ${ errorMessage ? ', see above' : '' } .` ) ;
74
85
}
75
- } else {
76
- const ngCompilerCliVersion = findAngularCompilerCliVersion ( ) ;
77
- const [ ngMajorVersion ] = ngCompilerCliVersion . split ( '.' ) ;
78
86
79
- if ( parseInt ( ngMajorVersion , 10 ) < 16 ) {
80
- console . log (
81
- `Warning: Could not locate '@angular/compiler-cli' to run 'ngcc' automatically.` +
82
- `Please make sure you are running 'ngcc-jest-processor.js' from root level of your project.` +
83
- `'ngcc' must be run before running Jest` ,
84
- ) ;
85
- } else {
86
- console . log ( `@angular/compiler-cli@${ ngCompilerCliVersion } detected. Skipping 'ngcc'` ) ;
87
- console . log (
88
- `Tip: To avoid this message you can remove 'jest-preset-angular/global-setup' from your jest config` ,
89
- ) ;
90
- }
87
+ return ;
91
88
}
89
+
90
+ console . warn (
91
+ `Warning: Could not locate '@angular/compiler-cli' to run 'ngcc' automatically.` +
92
+ `Please make sure you are running 'ngcc-jest-processor.js' from root level of your project.` +
93
+ `'ngcc' must be run before running Jest` ,
94
+ ) ;
92
95
} ;
0 commit comments