diff --git a/build/gulpfile.vscode.js b/build/gulpfile.vscode.js index ef1e701c18d004fc9f94513c90ef2583e076ffa0..625afbc8b5dc7007694612cd4d581e527c1cdfd6 100644 --- a/build/gulpfile.vscode.js +++ b/build/gulpfile.vscode.js @@ -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', diff --git a/package.json b/package.json index 9e926b9878c0f494337aef604c0d51e77358d5e2..4386a156994b57adee6d6cbb0414e370384258b3 100644 --- a/package.json +++ b/package.json @@ -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 +} diff --git a/src/vs/workbench/electron-browser/bootstrap/index.js b/src/vs/workbench/electron-browser/bootstrap/index.js index b3ed8729203a503818f36e47582ec40da6c156af..d79e86de78518379f3809e753eabf3705176b5f3 100644 --- a/src/vs/workbench/electron-browser/bootstrap/index.js +++ b/src/vs/workbench/electron-browser/bootstrap/index.js @@ -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();