Skip to content

Commit

Permalink
fix(@ngtools/webpack): update supported compiler-cli supported version
Browse files Browse the repository at this point in the history
`@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
  • Loading branch information
Alan Agius authored and alexeagle committed May 30, 2019
1 parent c04f7ab commit 8233935
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 22 deletions.
27 changes: 8 additions & 19 deletions packages/ngtools/webpack/src/angular_compiler_plugin.ts
Expand Up @@ -151,7 +151,7 @@ export class AngularCompilerPlugin {
}

static isSupported() {
return VERSION && parseInt(VERSION.major) >= 5;
return VERSION && parseInt(VERSION.major) >= 8;
}

private _setupOptions(options: AngularCompilerPluginOptions) {
Expand Down Expand Up @@ -659,24 +659,13 @@ export class AngularCompilerPlugin {

let ngccProcessor: NgccProcessor | undefined;
if (this._compilerOptions.enableIvy) {
let ngcc: typeof import('@angular/compiler-cli/ngcc') | undefined;
try {
// this is done for the sole reason that @ngtools/webpack
// support versions of Angular that don't have NGCC API
ngcc = require('@angular/compiler-cli/ngcc');
} catch {
}

if (ngcc) {
ngccProcessor = new NgccProcessor(
ngcc,
this._mainFields,
compilerWithFileSystems.inputFileSystem,
this._warnings,
this._errors,
this._basePath,
);
}
ngccProcessor = new NgccProcessor(
this._mainFields,
compilerWithFileSystems.inputFileSystem,
this._warnings,
this._errors,
this._basePath,
);
}

// Create the webpack compiler host.
Expand Down
5 changes: 2 additions & 3 deletions packages/ngtools/webpack/src/ngcc_processor.ts
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/

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

constructor(
private readonly ngcc: typeof import('@angular/compiler-cli/ngcc'),
private readonly propertiesToConsider: string[],
private readonly inputFileSystem: InputFileSystem,
private readonly compilationWarnings: (Error | string)[],
Expand Down Expand Up @@ -63,7 +62,7 @@ export class NgccProcessor {

const timeLabel = `NgccProcessor.processModule.ngcc.process+${moduleName}`;
time(timeLabel);
this.ngcc.process({
mainNgcc({
basePath: this._nodeModulesDirectory,
targetEntryPointPath: path.dirname(packageJsonPath),
propertiesToConsider: this.propertiesToConsider,
Expand Down

0 comments on commit 8233935

Please sign in to comment.