mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-26 13:19:42 +00:00
Fixes #21892: Do not read .d.ts files from disk when generating monaco.d.ts
This commit is contained in:
@@ -31,18 +31,16 @@ function moduleIdToPath(out:string, moduleId:string): string {
|
||||
}
|
||||
|
||||
let SOURCE_FILE_MAP: {[moduleId:string]:ts.SourceFile;} = {};
|
||||
function getSourceFile(out:string, moduleId:string): ts.SourceFile {
|
||||
function getSourceFile(out:string, inputFiles: { [file: string]: string; }, moduleId:string): ts.SourceFile {
|
||||
if (!SOURCE_FILE_MAP[moduleId]) {
|
||||
let filePath = moduleIdToPath(out, moduleId);
|
||||
let filePath = path.normalize(moduleIdToPath(out, moduleId));
|
||||
|
||||
let fileContents: string;
|
||||
try {
|
||||
fileContents = fs.readFileSync(filePath).toString();
|
||||
} catch (err) {
|
||||
logErr('CANNOT FIND FILE ' + filePath);
|
||||
if (!inputFiles.hasOwnProperty(filePath)) {
|
||||
logErr('CANNOT FIND FILE ' + filePath + '. YOU MIGHT NEED TO RESTART gulp');
|
||||
return null;
|
||||
}
|
||||
|
||||
let fileContents = inputFiles[filePath];
|
||||
let sourceFile = ts.createSourceFile(filePath, fileContents, ts.ScriptTarget.ES5);
|
||||
|
||||
SOURCE_FILE_MAP[moduleId] = sourceFile;
|
||||
@@ -262,7 +260,7 @@ function createReplacer(data:string): (str:string)=>string {
|
||||
};
|
||||
}
|
||||
|
||||
function generateDeclarationFile(out:string, recipe:string): string {
|
||||
function generateDeclarationFile(out: string, inputFiles: { [file: string]: string; }, recipe:string): string {
|
||||
let lines = recipe.split(/\r\n|\n|\r/);
|
||||
let result = [];
|
||||
|
||||
@@ -273,7 +271,7 @@ function generateDeclarationFile(out:string, recipe:string): string {
|
||||
if (m1) {
|
||||
CURRENT_PROCESSING_RULE = line;
|
||||
let moduleId = m1[1];
|
||||
let sourceFile = getSourceFile(out, moduleId);
|
||||
let sourceFile = getSourceFile(out, inputFiles, moduleId);
|
||||
if (!sourceFile) {
|
||||
return;
|
||||
}
|
||||
@@ -300,7 +298,7 @@ function generateDeclarationFile(out:string, recipe:string): string {
|
||||
if (m2) {
|
||||
CURRENT_PROCESSING_RULE = line;
|
||||
let moduleId = m2[1];
|
||||
let sourceFile = getSourceFile(out, moduleId);
|
||||
let sourceFile = getSourceFile(out, inputFiles, moduleId);
|
||||
if (!sourceFile) {
|
||||
return;
|
||||
}
|
||||
@@ -383,12 +381,12 @@ export interface IMonacoDeclarationResult {
|
||||
isTheSame: boolean;
|
||||
}
|
||||
|
||||
export function run(out:string): IMonacoDeclarationResult {
|
||||
export function run(out: string, inputFiles: { [file: string]: string; }): IMonacoDeclarationResult {
|
||||
log('Starting monaco.d.ts generation');
|
||||
SOURCE_FILE_MAP = {};
|
||||
|
||||
let recipe = fs.readFileSync(RECIPE_PATH).toString();
|
||||
let result = generateDeclarationFile(out, recipe);
|
||||
let result = generateDeclarationFile(out, inputFiles, recipe);
|
||||
|
||||
let currentContent = fs.readFileSync(DECLARATION_PATH).toString();
|
||||
log('Finished monaco.d.ts generation');
|
||||
|
||||
Reference in New Issue
Block a user