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
|
private resolveModuleName(moduleName: string, containingFile: string): ts.ResolvedModule
|
||||||
|undefined {
|
|undefined {
|
||||||
const rm = ts.resolveModuleName(
|
const rm = ts.resolveModuleName(
|
||||||
moduleName, containingFile, this.options, this, this.moduleResolutionCache)
|
moduleName, containingFile.replace(/\\/g, '/'), this.options, this,
|
||||||
|
this.moduleResolutionCache)
|
||||||
.resolvedModule;
|
.resolvedModule;
|
||||||
if (rm && this.isSourceFile(rm.resolvedFileName)) {
|
if (rm && this.isSourceFile(rm.resolvedFileName)) {
|
||||||
// Case: generateCodeForLibraries = true and moduleName is
|
// Case: generateCodeForLibraries = true and moduleName is
|
||||||
|
|
|
@ -41,16 +41,18 @@ describe('NgCompilerHost', () => {
|
||||||
basePath: '/tmp',
|
basePath: '/tmp',
|
||||||
moduleResolution: ts.ModuleResolutionKind.NodeJs,
|
moduleResolution: ts.ModuleResolutionKind.NodeJs,
|
||||||
},
|
},
|
||||||
|
rootNames = ['/tmp/index.ts'],
|
||||||
ngHost = createNgHost({files}),
|
ngHost = createNgHost({files}),
|
||||||
librarySummaries = [],
|
librarySummaries = [],
|
||||||
}: {
|
}: {
|
||||||
files?: Directory,
|
files?: Directory,
|
||||||
options?: CompilerOptions,
|
options?: CompilerOptions,
|
||||||
|
rootNames?: string[],
|
||||||
ngHost?: CompilerHost,
|
ngHost?: CompilerHost,
|
||||||
librarySummaries?: LibrarySummary[]
|
librarySummaries?: LibrarySummary[]
|
||||||
} = {}) {
|
} = {}) {
|
||||||
return new TsCompilerAotCompilerTypeCheckHostAdapter(
|
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])));
|
new Map(librarySummaries.map(entry => [entry.fileName, entry] as[string, LibrarySummary])));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,6 +145,15 @@ describe('NgCompilerHost', () => {
|
||||||
const host = createHost({ngHost});
|
const host = createHost({ngHost});
|
||||||
expect(host.moduleNameToFileName('a', 'b')).toBe('someResult');
|
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', () => {
|
describe('resourceNameToFileName', () => {
|
||||||
|
|
Loading…
Reference in New Issue