mirror of
https://github.com/Microsoft/vscode
synced 2024-08-25 03:56:03 +00:00
update uglify. bubble errors. scoped eslint
This commit is contained in:
parent
72ef20b5b3
commit
de7267dc4e
|
@ -18,6 +18,8 @@ const bundle = require('./lib/bundle');
|
|||
const util = require('./lib/util');
|
||||
const i18n = require('./lib/i18n');
|
||||
const gulpUtil = require('gulp-util');
|
||||
const flatmap = require('gulp-flatmap');
|
||||
const pump = require('pump');
|
||||
|
||||
function log(prefix, message) {
|
||||
gulpUtil.log(gulpUtil.colors.cyan('[' + prefix + ']'), message);
|
||||
|
@ -210,11 +212,7 @@ exports.optimizeTask = function(opts) {
|
|||
* to have a file "context" to include our copyright only once per file.
|
||||
*/
|
||||
function uglifyWithCopyrights() {
|
||||
let currentFileHasOurCopyright = false;
|
||||
|
||||
const onNewFile = () => currentFileHasOurCopyright = false;
|
||||
|
||||
const preserveComments = function(node, comment) {
|
||||
const preserveComments = f => (node, comment) => {
|
||||
const text = comment.value;
|
||||
const type = comment.type;
|
||||
|
||||
|
@ -225,10 +223,10 @@ function uglifyWithCopyrights() {
|
|||
const isOurCopyright = IS_OUR_COPYRIGHT_REGEXP.test(text);
|
||||
|
||||
if (isOurCopyright) {
|
||||
if (currentFileHasOurCopyright) {
|
||||
if (f.__hasOurCopyright) {
|
||||
return false;
|
||||
}
|
||||
currentFileHasOurCopyright = true;
|
||||
f.__hasOurCopyright = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -241,37 +239,45 @@ function uglifyWithCopyrights() {
|
|||
return false;
|
||||
};
|
||||
|
||||
const uglifyStream = uglify({ preserveComments });
|
||||
const input = es.through();
|
||||
const output = input
|
||||
.pipe(flatmap((stream, f) => {
|
||||
return stream
|
||||
.pipe(uglify({ preserveComments: preserveComments(f) }));
|
||||
}));
|
||||
|
||||
return es.through(function (data) {
|
||||
onNewFile();
|
||||
uglifyStream.once('data', data => this.emit('data', data));
|
||||
uglifyStream.write(data);
|
||||
},
|
||||
function () { this.emit('end'); });
|
||||
return es.duplex(input, output);
|
||||
}
|
||||
|
||||
exports.minifyTask = function (src, sourceMapBaseUrl) {
|
||||
const sourceMappingURL = sourceMapBaseUrl && (f => `${ sourceMapBaseUrl }/${ f.relative }.map`);
|
||||
|
||||
return function() {
|
||||
return cb => {
|
||||
const jsFilter = filter('**/*.js', { restore: true });
|
||||
const cssFilter = filter('**/*.css', { restore: true });
|
||||
|
||||
return gulp.src([src + '/**', '!' + src + '/**/*.map'])
|
||||
.pipe(jsFilter)
|
||||
.pipe(sourcemaps.init({ loadMaps: true }))
|
||||
.pipe(uglifyWithCopyrights())
|
||||
.pipe(jsFilter.restore)
|
||||
.pipe(cssFilter)
|
||||
.pipe(minifyCSS({ reduceIdents: false }))
|
||||
.pipe(cssFilter.restore)
|
||||
.pipe(sourcemaps.write('./', {
|
||||
pump(
|
||||
gulp.src([src + '/**', '!' + src + '/**/*.map']),
|
||||
jsFilter,
|
||||
sourcemaps.init({ loadMaps: true }),
|
||||
uglifyWithCopyrights(),
|
||||
jsFilter.restore,
|
||||
cssFilter,
|
||||
minifyCSS({ reduceIdents: false }),
|
||||
cssFilter.restore,
|
||||
sourcemaps.write('./', {
|
||||
sourceMappingURL,
|
||||
sourceRoot: null,
|
||||
includeContent: true,
|
||||
addComment: true
|
||||
}))
|
||||
.pipe(gulp.dest(src + '-min'));
|
||||
}),
|
||||
gulp.dest(src + '-min')
|
||||
, err => {
|
||||
if (err instanceof uglify.GulpUglifyError) {
|
||||
console.error(`Uglify error in '${ err.cause && err.cause.filename }'`);
|
||||
}
|
||||
|
||||
cb(err);
|
||||
});
|
||||
};
|
||||
};
|
|
@ -57,6 +57,7 @@
|
|||
"gulp-concat": "^2.6.0",
|
||||
"gulp-cssnano": "^2.1.0",
|
||||
"gulp-filter": "^3.0.0",
|
||||
"gulp-flatmap": "^1.0.0",
|
||||
"gulp-json-editor": "^2.2.1",
|
||||
"gulp-mocha": "^2.1.3",
|
||||
"gulp-remote-src": "^0.4.0",
|
||||
|
@ -66,7 +67,7 @@
|
|||
"gulp-sourcemaps": "^1.6.0",
|
||||
"gulp-tsb": "^1.10.1",
|
||||
"gulp-tslint": "^4.3.0",
|
||||
"gulp-uglify": "^1.4.1",
|
||||
"gulp-uglify": "^2.0.0",
|
||||
"gulp-util": "^3.0.6",
|
||||
"gulp-vinyl-zip": "^1.2.2",
|
||||
"innosetup-compiler": "^5.5.60",
|
||||
|
@ -80,6 +81,7 @@
|
|||
"mocha": "^2.2.5",
|
||||
"object-assign": "^4.0.1",
|
||||
"optimist": "0.3.5",
|
||||
"pump": "^1.0.1",
|
||||
"queue": "3.0.6",
|
||||
"remap-istanbul": "^0.6.4",
|
||||
"rimraf": "^2.2.8",
|
||||
|
|
14
src/.eslintrc
Normal file
14
src/.eslintrc
Normal file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"env": {
|
||||
"node": true,
|
||||
"es6": false
|
||||
},
|
||||
"rules": {
|
||||
"no-console": 0,
|
||||
"no-cond-assign": 0,
|
||||
"no-unused-vars": 1,
|
||||
"no-extra-semi": "warn",
|
||||
"semi": "warn"
|
||||
},
|
||||
"extends": "eslint:recommended"
|
||||
}
|
14
src/main.js
14
src/main.js
|
@ -3,6 +3,8 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
// Perf measurements
|
||||
global.vscodeStart = Date.now();
|
||||
|
||||
|
@ -69,7 +71,7 @@ function getNLSConfiguration() {
|
|||
// the locale we receive from the user or OS.
|
||||
locale = locale ? locale.toLowerCase() : locale;
|
||||
if (locale === 'pseudo') {
|
||||
return { locale: locale, availableLanguages: {}, pseudo: true }
|
||||
return { locale: locale, availableLanguages: {}, pseudo: true };
|
||||
}
|
||||
var initialLocale = locale;
|
||||
if (process.env['VSCODE_DEV']) {
|
||||
|
@ -132,15 +134,17 @@ app.on('open-file', function (event, path) {
|
|||
global.macOpenFiles.push(path);
|
||||
});
|
||||
|
||||
const openUrls = [];
|
||||
const onOpenUrl = (event, url) => {
|
||||
var openUrls = [];
|
||||
var onOpenUrl = function (event, url) {
|
||||
event.preventDefault();
|
||||
openUrls.push(url);
|
||||
};
|
||||
|
||||
app.on('will-finish-launching', () => app.on('open-url', onOpenUrl));
|
||||
app.on('will-finish-launching', function () {
|
||||
app.on('open-url', onOpenUrl);
|
||||
});
|
||||
|
||||
global.getOpenUrls = () => {
|
||||
global.getOpenUrls = function () {
|
||||
app.removeListener('open-url', onOpenUrl);
|
||||
return openUrls;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue