diff --git a/packages/compiler-cli/ngcc/main-ngcc.ts b/packages/compiler-cli/ngcc/main-ngcc.ts index b4ec014e37..e47904e58d 100644 --- a/packages/compiler-cli/ngcc/main-ngcc.ts +++ b/packages/compiler-cli/ngcc/main-ngcc.ts @@ -6,9 +6,9 @@ * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ -import * as path from 'canonical-path'; import * as yargs from 'yargs'; +import {AbsoluteFsPath} from '../src/ngtsc/path'; import {mainNgcc} from './src/main'; import {ConsoleLogger, LogLevel} from './src/logging/console_logger'; @@ -56,7 +56,7 @@ if (require.main === module) { 'The formats option (-f/--formats) has been removed. Consider the properties option (-p/--properties) instead.'); process.exit(1); } - const baseSourcePath = path.resolve(options['s'] || './node_modules'); + const baseSourcePath = AbsoluteFsPath.resolve(options['s'] || './node_modules'); const propertiesToConsider: string[] = options['p']; const targetEntryPointPath = options['t'] ? options['t'] : undefined; const compileAllFormats = !options['first-only']; diff --git a/packages/compiler-cli/ngcc/src/analysis/decoration_analyzer.ts b/packages/compiler-cli/ngcc/src/analysis/decoration_analyzer.ts index b69cb2eeab..1a24bfab42 100644 --- a/packages/compiler-cli/ngcc/src/analysis/decoration_analyzer.ts +++ b/packages/compiler-cli/ngcc/src/analysis/decoration_analyzer.ts @@ -6,7 +6,6 @@ * found in the LICENSE file at https://angular.io/license */ import {ConstantPool} from '@angular/compiler'; -import * as path from 'path'; import * as ts from 'typescript'; import {BaseDefDecoratorHandler, ComponentDecoratorHandler, DirectiveDecoratorHandler, InjectableDecoratorHandler, NgModuleDecoratorHandler, PipeDecoratorHandler, ReferencesRegistry, ResourceLoader} from '../../../src/ngtsc/annotations'; @@ -57,7 +56,7 @@ class NgccResourceLoader implements ResourceLoader { preload(): undefined|Promise { throw new Error('Not implemented.'); } load(url: string): string { return this.fs.readFile(AbsoluteFsPath.resolve(url)); } resolve(url: string, containingFile: string): string { - return path.resolve(path.dirname(containingFile), url); + return AbsoluteFsPath.resolve(AbsoluteFsPath.dirname(AbsoluteFsPath.from(containingFile)), url); } } diff --git a/packages/compiler-cli/ngcc/src/dependencies/dependency_resolver.ts b/packages/compiler-cli/ngcc/src/dependencies/dependency_resolver.ts index e289b5aabb..f05424c7f0 100644 --- a/packages/compiler-cli/ngcc/src/dependencies/dependency_resolver.ts +++ b/packages/compiler-cli/ngcc/src/dependencies/dependency_resolver.ts @@ -7,7 +7,6 @@ */ import {DepGraph} from 'dependency-graph'; -import {resolve} from 'path'; import {AbsoluteFsPath} from '../../../src/ngtsc/path'; import {Logger} from '../logging/logger'; @@ -171,7 +170,7 @@ function getEntryPointPath(entryPoint: EntryPoint): AbsoluteFsPath { if (format === 'esm2015' || format === 'esm5') { const formatPath = entryPoint.packageJson[property] !; - return AbsoluteFsPath.from(resolve(entryPoint.path, formatPath)); + return AbsoluteFsPath.resolve(entryPoint.path, formatPath); } } throw new Error(`There is no format with import statements in '${entryPoint.path}' entry-point.`); diff --git a/packages/compiler-cli/ngcc/test/integration/ngcc_spec.ts b/packages/compiler-cli/ngcc/test/integration/ngcc_spec.ts index f84dd23684..b6a54aaa2c 100644 --- a/packages/compiler-cli/ngcc/test/integration/ngcc_spec.ts +++ b/packages/compiler-cli/ngcc/test/integration/ngcc_spec.ts @@ -9,7 +9,6 @@ import {AbsoluteFsPath} from '@angular/compiler-cli/src/ngtsc/path'; import {existsSync, readFileSync, readdirSync, statSync, writeFileSync} from 'fs'; import * as mockFs from 'mock-fs'; -import {join} from 'path'; import {getAngularPackagesFromRunfiles, resolveNpmTreeArtifact} from '../../../test/runfile_helpers'; import {NodeJSFileSystem} from '../../src/file_system/node_js_file_system'; @@ -142,8 +141,8 @@ describe('ngcc main()', () => { function markPropertiesAsProcessed(packagePath: string, properties: EntryPointJsonProperty[]) { - const basePath = '/node_modules'; - const targetPackageJsonPath = _(join(basePath, packagePath, 'package.json')); + const basePath = _('/node_modules'); + const targetPackageJsonPath = AbsoluteFsPath.join(basePath, packagePath, 'package.json'); const targetPackage = loadPackage(packagePath); const fs = new NodeJSFileSystem(); markAsProcessed(fs, targetPackage, targetPackageJsonPath, 'typings'); @@ -386,7 +385,7 @@ function loadDirectory(directoryPath: string): Directory { const directory: Directory = {}; readdirSync(directoryPath).forEach(item => { - const itemPath = join(directoryPath, item); + const itemPath = AbsoluteFsPath.resolve(directoryPath, item); if (statSync(itemPath).isDirectory()) { directory[item] = loadDirectory(itemPath); } else {