Use the global monaco only in the AMD case (see https://github.com/microsoft/monaco-editor/issues/1974)

This commit is contained in:
Alex Dima 2020-09-07 12:24:21 +02:00
parent 47ee25bf88
commit 28d4512f33
No known key found for this signature in database
GPG key ID: 6E58D7B045760DA0
17 changed files with 321 additions and 235 deletions

37
scripts/dts.js Normal file
View file

@ -0,0 +1,37 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
const path = require('path');
const fs = require('fs');
const REPO_ROOT = path.join(__dirname, '../');
const SRC_PATH = path.join(REPO_ROOT, 'out/amd/monaco.contribution.d.ts');
const DST_PATH = path.join(REPO_ROOT, 'monaco.d.ts');
const lines = fs.readFileSync(SRC_PATH).toString().split(/\r\n|\r|\n/);
let result = [
`/*---------------------------------------------------------------------------------------------`,
` * Copyright (c) Microsoft Corporation. All rights reserved.`,
` * Licensed under the MIT License. See License.txt in the project root for license information.`,
` *--------------------------------------------------------------------------------------------*/`,
``,
`declare namespace monaco.languages.json {`,
``
];
for (let line of lines) {
if (/^import/.test(line)) {
continue;
}
line = line.replace(/ /g, '\t');
line = line.replace(/export declare/g, 'export');
if (line.length > 0) {
line = `\t${line}`;
}
result.push(line);
}
result.push(`}`);
result.push(``);
fs.writeFileSync(DST_PATH, result.join('\n'));