Skip to content

Commit

Permalink
refactor: deprecate ngcc util via globalSetup
Browse files Browse the repository at this point in the history
  • Loading branch information
ahnpnl committed Dec 31, 2024
1 parent 180883c commit edeaa3f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
35 changes: 19 additions & 16 deletions src/utils/ngcc-jest-processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,18 @@ function findAngularCompilerCliVersion(): string {
const nodeModuleDirPath = findNodeModulesDirectory();

export const runNgccJestProcessor = (tsconfigPath: string | undefined): void => {
if (nodeModuleDirPath) {
const ngCompilerCliVersion = findAngularCompilerCliVersion();
const [ngMajorVersion] = ngCompilerCliVersion.split('.');
if (parseInt(ngMajorVersion, 10) >= 16) {
console.warn(`
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'.
Tip: To avoid this message you can remove 'jest-preset-angular/global-setup' from your jest config
`);

return;
}

if (ngccPath && nodeModuleDirPath) {
process.stdout.write('\nngcc-jest-processor: running ngcc\n');

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

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

if (parseInt(ngMajorVersion, 10) < 16) {
console.log(
`Warning: Could not locate '@angular/compiler-cli' to run 'ngcc' automatically.` +
`Please make sure you are running 'ngcc-jest-processor.js' from root level of your project.` +
`'ngcc' must be run before running Jest`,
);
} else {
console.log(`@angular/compiler-cli@${ngCompilerCliVersion} detected. Skipping 'ngcc'`);
console.log(
`Tip: To avoid this message you can remove 'jest-preset-angular/global-setup' from your jest config`,
);
}
return;
}

console.warn(
`Warning: Could not locate '@angular/compiler-cli' to run 'ngcc' automatically.` +
`Please make sure you are running 'ngcc-jest-processor.js' from root level of your project.` +
`'ngcc' must be run before running Jest`,
);
};
4 changes: 2 additions & 2 deletions website/docs/guides/angular-ivy.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ id: angular-ivy
title: Angular Ivy
---

:::important
:::warning

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

:::

Expand Down

0 comments on commit edeaa3f

Please sign in to comment.