提交 de7267dc 编写于 作者: J Joao Moreno

update uglify. bubble errors. scoped eslint

上级 72ef20b5
...@@ -18,6 +18,8 @@ const bundle = require('./lib/bundle'); ...@@ -18,6 +18,8 @@ const bundle = require('./lib/bundle');
const util = require('./lib/util'); const util = require('./lib/util');
const i18n = require('./lib/i18n'); const i18n = require('./lib/i18n');
const gulpUtil = require('gulp-util'); const gulpUtil = require('gulp-util');
const flatmap = require('gulp-flatmap');
const pump = require('pump');
function log(prefix, message) { function log(prefix, message) {
gulpUtil.log(gulpUtil.colors.cyan('[' + prefix + ']'), message); gulpUtil.log(gulpUtil.colors.cyan('[' + prefix + ']'), message);
...@@ -210,11 +212,7 @@ exports.optimizeTask = function(opts) { ...@@ -210,11 +212,7 @@ exports.optimizeTask = function(opts) {
* to have a file "context" to include our copyright only once per file. * to have a file "context" to include our copyright only once per file.
*/ */
function uglifyWithCopyrights() { function uglifyWithCopyrights() {
let currentFileHasOurCopyright = false; const preserveComments = f => (node, comment) => {
const onNewFile = () => currentFileHasOurCopyright = false;
const preserveComments = function(node, comment) {
const text = comment.value; const text = comment.value;
const type = comment.type; const type = comment.type;
...@@ -225,10 +223,10 @@ function uglifyWithCopyrights() { ...@@ -225,10 +223,10 @@ function uglifyWithCopyrights() {
const isOurCopyright = IS_OUR_COPYRIGHT_REGEXP.test(text); const isOurCopyright = IS_OUR_COPYRIGHT_REGEXP.test(text);
if (isOurCopyright) { if (isOurCopyright) {
if (currentFileHasOurCopyright) { if (f.__hasOurCopyright) {
return false; return false;
} }
currentFileHasOurCopyright = true; f.__hasOurCopyright = true;
return true; return true;
} }
...@@ -241,37 +239,45 @@ function uglifyWithCopyrights() { ...@@ -241,37 +239,45 @@ function uglifyWithCopyrights() {
return false; 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) { return es.duplex(input, output);
onNewFile();
uglifyStream.once('data', data => this.emit('data', data));
uglifyStream.write(data);
},
function () { this.emit('end'); });
} }
exports.minifyTask = function (src, sourceMapBaseUrl) { exports.minifyTask = function (src, sourceMapBaseUrl) {
const sourceMappingURL = sourceMapBaseUrl && (f => `${ sourceMapBaseUrl }/${ f.relative }.map`); const sourceMappingURL = sourceMapBaseUrl && (f => `${ sourceMapBaseUrl }/${ f.relative }.map`);
return function() { return cb => {
const jsFilter = filter('**/*.js', { restore: true }); const jsFilter = filter('**/*.js', { restore: true });
const cssFilter = filter('**/*.css', { restore: true }); const cssFilter = filter('**/*.css', { restore: true });
return gulp.src([src + '/**', '!' + src + '/**/*.map']) pump(
.pipe(jsFilter) gulp.src([src + '/**', '!' + src + '/**/*.map']),
.pipe(sourcemaps.init({ loadMaps: true })) jsFilter,
.pipe(uglifyWithCopyrights()) sourcemaps.init({ loadMaps: true }),
.pipe(jsFilter.restore) uglifyWithCopyrights(),
.pipe(cssFilter) jsFilter.restore,
.pipe(minifyCSS({ reduceIdents: false })) cssFilter,
.pipe(cssFilter.restore) minifyCSS({ reduceIdents: false }),
.pipe(sourcemaps.write('./', { cssFilter.restore,
sourcemaps.write('./', {
sourceMappingURL, sourceMappingURL,
sourceRoot: null, sourceRoot: null,
includeContent: true, includeContent: true,
addComment: 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);
});
}; };
}; };
\ No newline at end of file
{
"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"
}
\ No newline at end of file
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
'use strict';
// Perf measurements // Perf measurements
global.vscodeStart = Date.now(); global.vscodeStart = Date.now();
...@@ -69,7 +71,7 @@ function getNLSConfiguration() { ...@@ -69,7 +71,7 @@ function getNLSConfiguration() {
// the locale we receive from the user or OS. // the locale we receive from the user or OS.
locale = locale ? locale.toLowerCase() : locale; locale = locale ? locale.toLowerCase() : locale;
if (locale === 'pseudo') { if (locale === 'pseudo') {
return { locale: locale, availableLanguages: {}, pseudo: true } return { locale: locale, availableLanguages: {}, pseudo: true };
} }
var initialLocale = locale; var initialLocale = locale;
if (process.env['VSCODE_DEV']) { if (process.env['VSCODE_DEV']) {
...@@ -132,15 +134,17 @@ app.on('open-file', function (event, path) { ...@@ -132,15 +134,17 @@ app.on('open-file', function (event, path) {
global.macOpenFiles.push(path); global.macOpenFiles.push(path);
}); });
const openUrls = []; var openUrls = [];
const onOpenUrl = (event, url) => { var onOpenUrl = function (event, url) {
event.preventDefault(); event.preventDefault();
openUrls.push(url); 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); app.removeListener('open-url', onOpenUrl);
return openUrls; return openUrls;
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册