mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 23:13:02 +01:00
Simplify import typescript script
This commit is contained in:
parent
151b807fee
commit
a7f23c2eba
2 changed files with 59 additions and 197 deletions
|
|
@ -106,20 +106,6 @@ function importLibs() {
|
||||||
return fs.readFileSync(srcPath).toString();
|
return fs.readFileSync(srcPath).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
var dtsFiles = fs.readdirSync(TYPESCRIPT_LIB_SOURCE).filter(f => f.includes("lib."));
|
|
||||||
|
|
||||||
var result = [];
|
|
||||||
while (dtsFiles.length > 0) {
|
|
||||||
var name = dtsFiles.shift();
|
|
||||||
var output = readLibFile(name);
|
|
||||||
result.push({
|
|
||||||
name: name.replace(/\./g, '_') + "_dts",
|
|
||||||
filepath: name,
|
|
||||||
deps: [],
|
|
||||||
output: '"' + escapeText(output) + '"'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
var strResult = `/*---------------------------------------------------------------------------------------------
|
var strResult = `/*---------------------------------------------------------------------------------------------
|
||||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
|
|
@ -130,28 +116,12 @@ ${generatedNote}
|
||||||
export const libFileMap: Record<string, string> = {}
|
export const libFileMap: Record<string, string> = {}
|
||||||
`
|
`
|
||||||
;
|
;
|
||||||
// Do a topological sort
|
|
||||||
while (result.length > 0) {
|
|
||||||
for (let i = result.length - 1; i >= 0; i--) {
|
|
||||||
if (result[i].deps.length === 0) {
|
|
||||||
// emit this node
|
|
||||||
strResult += `\nexport const ${result[i].name}: string = ${result[i].output};\n`;
|
|
||||||
strResult += `\libFileMap['${result[i].filepath}'] = ${result[i].name};\n`;
|
|
||||||
// mark dep as resolved
|
|
||||||
for (let j = 0; j < result.length; j++) {
|
|
||||||
for (let k = 0; k < result[j].deps.length; k++) {
|
|
||||||
if (result[j].deps[k] === result[i].name) {
|
|
||||||
result[j].deps.splice(k, 1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove from result
|
var dtsFiles = fs.readdirSync(TYPESCRIPT_LIB_SOURCE).filter(f => f.includes("lib."));
|
||||||
result.splice(i, 1);
|
while (dtsFiles.length > 0) {
|
||||||
break;
|
var name = dtsFiles.shift();
|
||||||
}
|
var output = readLibFile(name);
|
||||||
}
|
strResult += `libFileMap['${name}'] = "${escapeText(output)}";\n`;
|
||||||
}
|
}
|
||||||
|
|
||||||
var dstPath = path.join(TYPESCRIPT_LIB_DESTINATION, 'lib.ts');
|
var dstPath = path.join(TYPESCRIPT_LIB_DESTINATION, 'lib.ts');
|
||||||
|
|
|
||||||
216
src/lib/lib.ts
216
src/lib/lib.ts
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue