mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 16:15:41 +01:00
Use the global monaco only in the AMD case (see microsoft/monaco-editor#1974)
This commit is contained in:
parent
1af07d9cdb
commit
d7cc098c48
80 changed files with 347 additions and 387 deletions
|
|
@ -22,45 +22,60 @@ const BUNDLED_FILE_HEADER = [
|
|||
].join('\n');
|
||||
|
||||
bundleOne('monaco.contribution');
|
||||
glob(
|
||||
'release/dev/*/*.contribution.js',
|
||||
{ cwd: path.dirname(__dirname) },
|
||||
function (err, files) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
return;
|
||||
}
|
||||
files.forEach(function (file) {
|
||||
file = file.replace(/\.contribution\.js$/, '');
|
||||
file = file.replace(/release[/\\]dev[/\\]/, '');
|
||||
bundleOne(file);
|
||||
});
|
||||
glob('out/amd/*/*.contribution.js', { cwd: path.dirname(__dirname) }, function (
|
||||
err,
|
||||
files
|
||||
) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
return;
|
||||
}
|
||||
);
|
||||
files.forEach(function (file) {
|
||||
file = file.replace(/\.contribution\.js$/, '');
|
||||
file = file.replace(/out[/\\]amd[/\\]/, '');
|
||||
bundleOne(file, ['vs/basic-languages/monaco.contribution']);
|
||||
});
|
||||
});
|
||||
|
||||
function bundleOne(moduleId, exclude) {
|
||||
requirejs.optimize(
|
||||
{
|
||||
baseUrl: 'release/dev/',
|
||||
baseUrl: 'out/amd/',
|
||||
name: 'vs/basic-languages/' + moduleId,
|
||||
out: 'release/min/' + moduleId + '.js',
|
||||
out: 'release/dev/' + moduleId + '.js',
|
||||
exclude: exclude,
|
||||
paths: {
|
||||
'vs/basic-languages': REPO_ROOT + '/release/dev'
|
||||
'vs/basic-languages': REPO_ROOT + '/out/amd',
|
||||
'vs/basic-languages/fillers/monaco-editor-core':
|
||||
REPO_ROOT + '/out/amd/fillers/monaco-editor-core-amd'
|
||||
},
|
||||
optimize: 'none'
|
||||
},
|
||||
function (buildResponse) {
|
||||
const filePath = path.join(
|
||||
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(filePath).toString();
|
||||
const fileContents = fs.readFileSync(devFilePath).toString();
|
||||
console.log();
|
||||
console.log(`Minifying ${filePath}...`);
|
||||
const result = terser.minify(fileContents);
|
||||
console.log(`Done.`);
|
||||
fs.writeFileSync(filePath, BUNDLED_FILE_HEADER + result.code);
|
||||
console.log(`Minifying ${devFilePath}...`);
|
||||
const result = await terser.minify(fileContents, {
|
||||
output: {
|
||||
comments: 'some'
|
||||
}
|
||||
});
|
||||
console.log(`Done minifying ${devFilePath}.`);
|
||||
try {
|
||||
fs.mkdirSync(path.join(REPO_ROOT, 'release/min'));
|
||||
} catch (err) {}
|
||||
try {
|
||||
fs.mkdirSync(path.dirname(minFilePath));
|
||||
} catch (err) {}
|
||||
fs.writeFileSync(minFilePath, BUNDLED_FILE_HEADER + result.code);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue