Optimize how external libs are handled and allow for custom languages:

* Adding/removing extra libs does not trigger a full worker refresh
* Manual control over when the extra libs are sent to the worker
* Adding a new lib with the same name replaces it inplace
Also included, the capability to define custom languages
This commit is contained in:
placatus 2019-02-06 00:50:50 +02:00
parent 505232c7c8
commit e39fa719bc
7 changed files with 167 additions and 59 deletions

View file

@ -29,6 +29,8 @@ bundleOne('monaco.contribution');
bundleOne('tsMode');
bundleOne('tsWorker');
updateImports('monaco.contribution');
function bundleOne(moduleId, exclude) {
requirejs.optimize({
baseUrl: 'release/dev/',
@ -36,7 +38,8 @@ function bundleOne(moduleId, exclude) {
out: 'release/min/' + moduleId + '.js',
exclude: exclude,
paths: {
'vs/language/typescript': REPO_ROOT + '/release/dev'
'vs/language/typescript': REPO_ROOT + '/release/dev',
'vs/basic-languages': REPO_ROOT + '/node_modules/monaco-languages/release/dev'
},
optimize: 'none'
}, function(buildResponse) {
@ -53,3 +56,11 @@ function bundleOne(moduleId, exclude) {
fs.writeFileSync(filePath, BUNDLED_FILE_HEADER + result.code);
})
}
function updateImports(moduleId) {
console.log(`ESM: updating relative imports paths for ${moduleId}...`);
const filePath = path.join(REPO_ROOT, 'release/esm/' + moduleId + '.js');
var fileContents = fs.readFileSync(filePath).toString();
fileContents = fileContents.replace(/vs\/basic-languages\//g, "../../basic-languages/");
fs.writeFileSync(filePath, fileContents);
}