Skip to content

Commit

Permalink
fix: pass tsconfig path to ngcc
Browse files Browse the repository at this point in the history
The NgccProcessor now passes the tsconfig path to ngcc
rather than the `paths` property, since ngcc is able to read
the paths from the tsconfig directly.
  • Loading branch information
petebacondarwin authored and alan-agius4 committed Jul 15, 2020
1 parent c29d184 commit fd18984
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
4 changes: 3 additions & 1 deletion src/lib/ng-package/entry-point/compile-ngc.transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ export const compileNgcTransform: Transform = transformFromPromise(async graph =
const { basePath, cssUrl, styleIncludePaths } = entryPoint.data.entryPoint;
const stylesheetProcessor = new StylesheetProcessor(basePath, cssUrl, styleIncludePaths);

const ngccProcessor = tsConfig.options.enableIvy ? new NgccProcessor(tsConfig.options, entryPoints) : undefined;
const ngccProcessor = tsConfig.options.enableIvy
? new NgccProcessor(tsConfig.project, tsConfig.options, entryPoints)
: undefined;

await compileSourceFiles(
graph,
Expand Down
20 changes: 8 additions & 12 deletions src/lib/ngc/ngcc-processor.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Logger, PathMappings, process as mainNgcc, LogLevel } from '@angular/compiler-cli/ngcc';
import { Logger, process as mainNgcc, LogLevel } from '@angular/compiler-cli/ngcc';
import { existsSync, constants, accessSync } from 'fs';
import * as path from 'path';
import * as ts from 'typescript';
Expand All @@ -10,21 +10,17 @@ export class NgccProcessor {
private _processedModules = new Set<string>();
private _logger: NgccLogger;
private _nodeModulesDirectory: string;
private _pathMappings: PathMappings | undefined;
private _entryPointsUrl: string[];

constructor(private readonly compilerOptions: ts.CompilerOptions, private readonly entryPoints: EntryPointNode[]) {
constructor(
private projectPath: string,
private readonly compilerOptions: ts.CompilerOptions,
private readonly entryPoints: EntryPointNode[],
) {
this._entryPointsUrl = this.entryPoints.map(({ url }) => ngUrl(url));

const { baseUrl, paths } = this.compilerOptions;
const { baseUrl } = this.compilerOptions;
this._nodeModulesDirectory = this.findNodeModulesDirectory(baseUrl);

if (baseUrl && paths) {
this._pathMappings = {
baseUrl,
paths,
};
}
}

processModule(moduleName: string, resolvedModule: ts.ResolvedModule | ts.ResolvedTypeReferenceDirective): void {
Expand Down Expand Up @@ -65,7 +61,7 @@ export class NgccProcessor {
propertiesToConsider: ['es2015', 'browser', 'module', 'main'],
createNewEntryPointFormats: true,
logger: this._logger,
pathMappings: this._pathMappings,
tsConfigPath: this.projectPath,
});

this._processedModules.add(moduleName);
Expand Down

0 comments on commit fd18984

Please sign in to comment.