Skip to content

Commit 8233935

Browse files
Alan Agiusalexeagle
authored andcommitted
fix(@ngtools/webpack): update supported compiler-cli supported version
`@ngtools/webpack` only supports compiler version 8 as per the peerDependency. The fixes the `isSupported` version static and also removes code that was to support prior versions of compiler-cli
1 parent c04f7ab commit 8233935

File tree

2 files changed

+10
-22
lines changed

2 files changed

+10
-22
lines changed

packages/ngtools/webpack/src/angular_compiler_plugin.ts

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ export class AngularCompilerPlugin {
151151
}
152152

153153
static isSupported() {
154-
return VERSION && parseInt(VERSION.major) >= 5;
154+
return VERSION && parseInt(VERSION.major) >= 8;
155155
}
156156

157157
private _setupOptions(options: AngularCompilerPluginOptions) {
@@ -659,24 +659,13 @@ export class AngularCompilerPlugin {
659659

660660
let ngccProcessor: NgccProcessor | undefined;
661661
if (this._compilerOptions.enableIvy) {
662-
let ngcc: typeof import('@angular/compiler-cli/ngcc') | undefined;
663-
try {
664-
// this is done for the sole reason that @ngtools/webpack
665-
// support versions of Angular that don't have NGCC API
666-
ngcc = require('@angular/compiler-cli/ngcc');
667-
} catch {
668-
}
669-
670-
if (ngcc) {
671-
ngccProcessor = new NgccProcessor(
672-
ngcc,
673-
this._mainFields,
674-
compilerWithFileSystems.inputFileSystem,
675-
this._warnings,
676-
this._errors,
677-
this._basePath,
678-
);
679-
}
662+
ngccProcessor = new NgccProcessor(
663+
this._mainFields,
664+
compilerWithFileSystems.inputFileSystem,
665+
this._warnings,
666+
this._errors,
667+
this._basePath,
668+
);
680669
}
681670

682671
// Create the webpack compiler host.

packages/ngtools/webpack/src/ngcc_processor.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import { Logger } from '@angular/compiler-cli/ngcc';
9+
import { Logger, process as mainNgcc } from '@angular/compiler-cli/ngcc';
1010
import { existsSync } from 'fs';
1111
import * as path from 'path';
1212
import * as ts from 'typescript';
@@ -29,7 +29,6 @@ export class NgccProcessor {
2929
private _nodeModulesDirectory: string;
3030

3131
constructor(
32-
private readonly ngcc: typeof import('@angular/compiler-cli/ngcc'),
3332
private readonly propertiesToConsider: string[],
3433
private readonly inputFileSystem: InputFileSystem,
3534
private readonly compilationWarnings: (Error | string)[],
@@ -63,7 +62,7 @@ export class NgccProcessor {
6362

6463
const timeLabel = `NgccProcessor.processModule.ngcc.process+${moduleName}`;
6564
time(timeLabel);
66-
this.ngcc.process({
65+
mainNgcc({
6766
basePath: this._nodeModulesDirectory,
6867
targetEntryPointPath: path.dirname(packageJsonPath),
6968
propertiesToConsider: this.propertiesToConsider,

0 commit comments

Comments
 (0)