Skip to content

Commit edeaa3f

Browse files
committed
refactor: deprecate ngcc util via globalSetup
1 parent 180883c commit edeaa3f

File tree

2 files changed

+21
-18
lines changed

2 files changed

+21
-18
lines changed

src/utils/ngcc-jest-processor.ts

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,18 @@ function findAngularCompilerCliVersion(): string {
3939
const nodeModuleDirPath = findNodeModulesDirectory();
4040

4141
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) {
4354
process.stdout.write('\nngcc-jest-processor: running ngcc\n');
4455

4556
const ngccBaseArgs = [
@@ -72,21 +83,13 @@ export const runNgccJestProcessor = (tsconfigPath: string | undefined): void =>
7283

7384
throw new Error(`${errorMessage} NGCC failed ${errorMessage ? ', see above' : ''}.`);
7485
}
75-
} else {
76-
const ngCompilerCliVersion = findAngularCompilerCliVersion();
77-
const [ngMajorVersion] = ngCompilerCliVersion.split('.');
7886

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;
9188
}
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+
);
9295
};

website/docs/guides/angular-ivy.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ id: angular-ivy
33
title: Angular Ivy
44
---
55

6-
:::important
6+
:::warning
77

8-
This step is **OPTIONAL**
8+
This guide is now **DEPRECATED** and will be removed in the next major release together with the below APIs.
99

1010
:::
1111

0 commit comments

Comments
 (0)