fix(compiler): properly work on windows
Verified manually on a windows surface tablet. Fixes #19492
This commit is contained in:
parent
0833b59aab
commit
696af79dc7
|
@ -108,7 +108,8 @@ export class TsCompilerAotCompilerTypeCheckHostAdapter extends
|
|||
private resolveModuleName(moduleName: string, containingFile: string): ts.ResolvedModule
|
||||
|undefined {
|
||||
const rm = ts.resolveModuleName(
|
||||
moduleName, containingFile, this.options, this, this.moduleResolutionCache)
|
||||
moduleName, containingFile.replace(/\\/g, '/'), this.options, this,
|
||||
this.moduleResolutionCache)
|
||||
.resolvedModule;
|
||||
if (rm && this.isSourceFile(rm.resolvedFileName)) {
|
||||
// Case: generateCodeForLibraries = true and moduleName is
|
||||
|
|
|
@ -41,16 +41,18 @@ describe('NgCompilerHost', () => {
|
|||
basePath: '/tmp',
|
||||
moduleResolution: ts.ModuleResolutionKind.NodeJs,
|
||||
},
|
||||
rootNames = ['/tmp/index.ts'],
|
||||
ngHost = createNgHost({files}),
|
||||
librarySummaries = [],
|
||||
}: {
|
||||
files?: Directory,
|
||||
options?: CompilerOptions,
|
||||
rootNames?: string[],
|
||||
ngHost?: CompilerHost,
|
||||
librarySummaries?: LibrarySummary[]
|
||||
} = {}) {
|
||||
return new TsCompilerAotCompilerTypeCheckHostAdapter(
|
||||
['/tmp/index.ts'], options, ngHost, new MetadataCollector(), codeGenerator,
|
||||
rootNames, options, ngHost, new MetadataCollector(), codeGenerator,
|
||||
new Map(librarySummaries.map(entry => [entry.fileName, entry] as[string, LibrarySummary])));
|
||||
}
|
||||
|
||||
|
@ -143,6 +145,15 @@ describe('NgCompilerHost', () => {
|
|||
const host = createHost({ngHost});
|
||||
expect(host.moduleNameToFileName('a', 'b')).toBe('someResult');
|
||||
});
|
||||
|
||||
it('should work well with windows paths', () => {
|
||||
const host = createHost({
|
||||
rootNames: ['\\tmp\\index.ts'],
|
||||
options: {basePath: '\\tmp'},
|
||||
files: {'tmp': {'node_modules': {'@core': {'index.d.ts': dummyModule}}}}
|
||||
});
|
||||
expect(host.moduleNameToFileName('@core/index')).toBe('/tmp/node_modules/@core/index.d.ts');
|
||||
});
|
||||
});
|
||||
|
||||
describe('resourceNameToFileName', () => {
|
||||
|
|
Loading…
Reference in New Issue