提交 5b06b196 编写于 作者: J Johannes Rieken

add support to snapshot the loader and its plugins, #28492

上级 76b37f8e
......@@ -31,6 +31,8 @@ const shrinkwrap = require('../npm-shrinkwrap.json');
const crypto = require('crypto');
const i18n = require('./lib/i18n');
const glob = require('glob');
const os = require('os');
const cp = require('child_process');
const productDependencies = Object.keys(product.dependencies || {});
const dependencies = Object.keys(shrinkwrap.dependencies)
......@@ -369,6 +371,53 @@ gulp.task('vscode-linux-ia32-min', ['minify-vscode', 'clean-vscode-linux-ia32'],
gulp.task('vscode-linux-x64-min', ['minify-vscode', 'clean-vscode-linux-x64'], packageTask('linux', 'x64', { minified: true }));
gulp.task('vscode-linux-arm-min', ['minify-vscode', 'clean-vscode-linux-arm'], packageTask('linux', 'arm', { minified: true }));
// --- v8 snapshots ---
function snapshotTask(platform, arch) {
const destination = path.join(path.dirname(root), 'VSCode') + (platform ? '-' + platform : '') + (arch ? '-' + arch : '');
const command = path.join(process.cwd(), 'node_modules/.bin/mksnapshot');
let startupBlobFilepath;
if (platform === 'darwin') {
startupBlobFilepath = path.join(destination, 'Code - OSS.app/Contents/Frameworks/Electron Framework.framework/Resources/snapshot_blob.bin')
} else if (platform === 'windows') {
startupBlobFilepath = path.join(destination, 'snapshot_blob.bin')
// TODO
return () => { };
} else if (platform === 'linux') {
// TODO
return () => { };
}
return () => {
const inputFile = fs.readFileSync(path.join(destination, 'Code - OSS.app/Contents/Resources/app/out/vs/loader.js'));
const wrappedInputFile = `
var Monaco_Loader_Init;
(function() {
var doNotInitLoader = true;
${inputFile.toString()};
Monaco_Loader_Init = function() {
AMDLoader.init();
CSSLoaderPlugin.init();
NLSLoaderPlugin.init();
return define;
}
})();
`;
const wrappedInputFilepath = path.join(os.tmpdir(), 'wrapped-loader.js');
console.log(wrappedInputFilepath);
fs.writeFileSync(wrappedInputFilepath, wrappedInputFile);
cp.execFileSync(command, [wrappedInputFilepath, `--startup_blob`, startupBlobFilepath]);
}
}
gulp.task('vscode-darwin-snapshots', ['vscode-darwin'], snapshotTask('darwin', undefined));
// Transifex Localizations
const vscodeLanguages = [
'zh-hans',
......
......@@ -59,6 +59,7 @@
"cson-parser": "^1.3.3",
"debounce": "^1.0.0",
"documentdb": "^1.5.1",
"electron-mksnapshot": "1.6.0",
"eslint": "^3.4.0",
"event-stream": "^3.1.7",
"express": "^4.13.1",
......@@ -127,4 +128,4 @@
"windows-mutex": "^0.2.0",
"fsevents": "0.3.8"
}
}
\ No newline at end of file
}
......@@ -12,7 +12,7 @@ if (window.location.search.indexOf('prof-startup') >= 0) {
profiler.startProfiling('renderer', true);
}
/*global window,document,define*/
/*global window,document,define,Monaco_Loader_Init*/
const startTimer = require('../../../base/node/startupTimers').startTimer;
const path = require('path');
......@@ -157,10 +157,7 @@ function main() {
// Load the loader and start loading the workbench
const rootUrl = uriFromPath(configuration.appRoot) + '/out';
// In the bundled version the nls plugin is packaged with the loader so the NLS Plugins
// loads as soon as the loader loads. To be able to have pseudo translation
const loaderTimer = startTimer('load:loader');
createScript(rootUrl + '/vs/loader.js', function () {
function onLoader() {
define('fs', ['original-fs'], function (originalFS) { return originalFS; }); // replace the patched electron fs with the original node fs for all AMD code
loaderTimer.stop();
......@@ -211,7 +208,19 @@ function main() {
});
});
});
});
}
// In the bundled version the nls plugin is packaged with the loader so the NLS Plugins
// loads as soon as the loader loads. To be able to have pseudo translation
const loaderTimer = startTimer('load:loader');
if (typeof Monaco_Loader_Init === 'function') {
//eslint-disable-next-line no-global-assign
define = Monaco_Loader_Init();
onLoader();
} else {
createScript(rootUrl + '/vs/loader.js', onLoader);
}
}
main();
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册