Skip to content

feat(@ngtools/webpack): add path mappings resolution to NGCC #14721

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@
"typescript": "3.4.5"
},
"devDependencies": {
"@angular/compiler": "^8.0.0-beta.14",
"@angular/compiler-cli": "^8.0.0-beta.14",
"@angular/compiler": "~8.1.0-next.1",
"@angular/compiler-cli": "~8.1.0-next.1",
"@bazel/bazel": "0.24.1",
"@bazel/buildifier": "^0.22.0",
"@bazel/jasmine": "~0.26.0",
Expand Down
24 changes: 12 additions & 12 deletions packages/angular_devkit/build_angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,18 @@
"worker-plugin": "3.1.0"
},
"devDependencies": {
"@angular/animations": "^8.0.0-beta.14",
"@angular/cdk": "^7.3.4",
"@angular/common": "^8.0.0-beta.14",
"@angular/compiler": "^8.0.0-beta.14",
"@angular/compiler-cli": "^8.0.0-beta.14",
"@angular/core": "^8.0.0-beta.14",
"@angular/material": "^7.3.4",
"@angular/platform-browser": "^8.0.0-beta.14",
"@angular/platform-browser-dynamic": "^8.0.0-beta.14",
"@angular/platform-server": "^8.0.0-beta.14",
"@angular/router": "^8.0.0-beta.14",
"@angular/service-worker": "^8.0.0-beta.14",
"@angular/animations": "~8.1.0-next.1",
"@angular/cdk": "^8.0.0",
"@angular/common": "~8.1.0-next.1",
"@angular/compiler": "~8.1.0-next.1",
"@angular/compiler-cli": "~8.1.0-next.1",
"@angular/core": "~8.1.0-next.1",
"@angular/material": "^8.0.0",
"@angular/platform-browser": "~8.1.0-next.1",
"@angular/platform-browser-dynamic": "~8.1.0-next.1",
"@angular/platform-server": "~8.1.0-next.1",
"@angular/router": "~8.1.0-next.1",
"@angular/service-worker": "~8.1.0-next.1",
"codelyzer": "^5.0.0",
"bootstrap": "^4.0.0",
"font-awesome": "^4.7.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/angular_devkit/build_ng_packagr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"ng-packagr": "^4.0.0 || ^5.0.0"
},
"devDependencies": {
"@angular/compiler": "^8.0.0-beta.14",
"@angular/compiler-cli": "^8.0.0-beta.14",
"@angular/compiler": "~8.1.0-next.1",
"@angular/compiler-cli": "~8.1.0-next.1",
"@angular-devkit/core": "0.0.0",
"ng-packagr": "^5.1.0",
"tslib": "^1.9.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/ngtools/webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
"webpack": "^4.0.0"
},
"devDependencies": {
"@angular/compiler": "^8.0.0-beta.14",
"@angular/compiler-cli": "^8.0.0-beta.14",
"@angular/compiler": "~8.1.0-next.1",
"@angular/compiler-cli": "~8.1.0-next.1",
"typescript": "3.4.5",
"webpack": "4.33.0"
}
Expand Down
1 change: 1 addition & 0 deletions packages/ngtools/webpack/src/angular_compiler_plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,7 @@ export class AngularCompilerPlugin {
this._warnings,
this._errors,
this._basePath,
this._compilerOptions,
);
}

Expand Down
13 changes: 12 additions & 1 deletion packages/ngtools/webpack/src/ngcc_processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/

import { Logger, process as mainNgcc } from '@angular/compiler-cli/ngcc';
import { Logger, PathMappings, process as mainNgcc } from '@angular/compiler-cli/ngcc';
import { existsSync } from 'fs';
import * as path from 'path';
import * as ts from 'typescript';
Expand All @@ -27,16 +27,26 @@ export class NgccProcessor {
private _processedModules = new Set<string>();
private _logger: NgccLogger;
private _nodeModulesDirectory: string;
private _pathMappings: PathMappings | undefined;

constructor(
private readonly propertiesToConsider: string[],
private readonly inputFileSystem: InputFileSystem,
private readonly compilationWarnings: (Error | string)[],
private readonly compilationErrors: (Error | string)[],
private readonly basePath: string,
private readonly compilerOptions: ts.CompilerOptions,
) {
this._logger = new NgccLogger(this.compilationWarnings, this.compilationErrors);
this._nodeModulesDirectory = this.findNodeModulesDirectory(this.basePath);

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

processModule(
Expand Down Expand Up @@ -69,6 +79,7 @@ export class NgccProcessor {
compileAllFormats: false,
createNewEntryPointFormats: true,
logger: this._logger,
pathMappings: this._pathMappings,
});
timeEnd(timeLabel);

Expand Down
2 changes: 1 addition & 1 deletion packages/schematics/angular/utility/latest-versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

export const latestVersions = {
// These versions should be kept up to date with latest Angular peer dependencies.
Angular: '~8.0.0',
Angular: '~8.1.0-next.1',
RxJs: '~6.4.0',
ZoneJs: '~0.9.1',
TypeScript: '~3.4.3',
Expand Down
8 changes: 0 additions & 8 deletions tests/legacy-cli/e2e/tests/misc/module-resolution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,9 @@ import { appendToFile, createDir, moveFile, prependToFile } from '../../utils/fs
import { ng, silentNpm } from '../../utils/process';
import { updateJsonFile } from '../../utils/project';
import { expectToFail } from '../../utils/utils';
import { getGlobalVariable } from '../../utils/env';


export default async function () {
if (getGlobalVariable('argv')['ivy']) {
// todo: enable when NGCC supports this.
// this test is not yet supported under IVY because can only transform packages from a single basePaths.
// https://angular-team.atlassian.net/browse/FW-1204
return;
}

await updateJsonFile('tsconfig.json', tsconfig => {
tsconfig.compilerOptions.paths = {
'*': ['./node_modules/*'],
Expand Down
Loading