mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 15:05:39 +01:00
Use the global monaco only in the AMD case (see microsoft/monaco-editor#1974)
This commit is contained in:
parent
ff1c7a5a5c
commit
5db3946e4a
15 changed files with 305 additions and 249 deletions
|
|
@ -21,7 +21,7 @@ const BUNDLED_FILE_HEADER = [
|
|||
].join('\n');
|
||||
|
||||
bundleOne('monaco.contribution');
|
||||
bundleOne('cssMode');
|
||||
bundleOne('cssMode', ['vs/language/css/monaco.contribution']);
|
||||
bundleOne('cssWorker');
|
||||
|
||||
function bundleOne(moduleId, exclude) {
|
||||
|
|
@ -31,7 +31,9 @@ function bundleOne(moduleId, exclude) {
|
|||
out: 'release/dev/' + moduleId + '.js',
|
||||
exclude: exclude,
|
||||
paths: {
|
||||
'vs/language/css': REPO_ROOT + '/out/amd'
|
||||
'vs/language/css': REPO_ROOT + '/out/amd',
|
||||
'vs/language/css/fillers/monaco-editor-core':
|
||||
REPO_ROOT + '/out/amd/fillers/monaco-editor-core-amd'
|
||||
},
|
||||
optimize: 'none',
|
||||
packages: [{
|
||||
|
|
@ -55,18 +57,18 @@ function bundleOne(moduleId, exclude) {
|
|||
location: path.join(REPO_ROOT, '/out/amd/fillers'),
|
||||
main: 'vscode-nls'
|
||||
}]
|
||||
}, function (buildResponse) {
|
||||
}, async function (buildResponse) {
|
||||
const devFilePath = path.join(REPO_ROOT, 'release/dev/' + moduleId + '.js');
|
||||
const minFilePath = path.join(REPO_ROOT, 'release/min/' + moduleId + '.js');
|
||||
const fileContents = fs.readFileSync(devFilePath).toString();
|
||||
console.log();
|
||||
console.log(`Minifying ${devFilePath}...`);
|
||||
const result = Terser.minify(fileContents, {
|
||||
const result = await Terser.minify(fileContents, {
|
||||
output: {
|
||||
comments: 'some'
|
||||
}
|
||||
});
|
||||
console.log(`Done.`);
|
||||
console.log(`Done minifying ${devFilePath}.`);
|
||||
try { fs.mkdirSync(path.join(REPO_ROOT, 'release/min')) } catch (err) { }
|
||||
fs.writeFileSync(minFilePath, BUNDLED_FILE_HEADER + result.code);
|
||||
})
|
||||
|
|
|
|||
38
scripts/dts.js
Normal file
38
scripts/dts.js
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* 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.`,
|
||||
` *--------------------------------------------------------------------------------------------*/`,
|
||||
``,
|
||||
`/// <reference path="node_modules/monaco-editor-core/monaco.d.ts" />`,
|
||||
``,
|
||||
`declare namespace monaco.languages.css {`
|
||||
];
|
||||
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'));
|
||||
Loading…
Add table
Add a link
Reference in a new issue