mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 02:58:56 +01:00
Fixes treeshaking on windows (#272899)
This commit is contained in:
committed by
GitHub
parent
e5e1fca76c
commit
5e18e088a9
@@ -5,9 +5,14 @@
|
||||
|
||||
import ts from 'typescript';
|
||||
import fs from 'node:fs';
|
||||
import { normalize } from 'node:path';
|
||||
|
||||
export type IFileMap = Map</*fileName*/ string, string>;
|
||||
|
||||
function normalizePath(filePath: string): string {
|
||||
return normalize(filePath);
|
||||
}
|
||||
|
||||
/**
|
||||
* A TypeScript language service host
|
||||
*/
|
||||
@@ -36,6 +41,8 @@ export class TypeScriptLanguageServiceHost implements ts.LanguageServiceHost {
|
||||
return '1';
|
||||
}
|
||||
getScriptSnapshot(fileName: string): ts.IScriptSnapshot {
|
||||
fileName = normalizePath(fileName);
|
||||
|
||||
if (this.topLevelFiles.has(fileName)) {
|
||||
return this.ts.ScriptSnapshot.fromString(this.topLevelFiles.get(fileName)!);
|
||||
} else {
|
||||
@@ -52,12 +59,16 @@ export class TypeScriptLanguageServiceHost implements ts.LanguageServiceHost {
|
||||
return this.ts.getDefaultLibFilePath(options);
|
||||
}
|
||||
readFile(path: string, encoding?: string): string | undefined {
|
||||
path = normalizePath(path);
|
||||
|
||||
if (this.topLevelFiles.get(path)) {
|
||||
return this.topLevelFiles.get(path);
|
||||
}
|
||||
return ts.sys.readFile(path, encoding);
|
||||
}
|
||||
fileExists(path: string): boolean {
|
||||
path = normalizePath(path);
|
||||
|
||||
if (this.topLevelFiles.has(path)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user