mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 09:08:48 +01:00
tweaks, add the stream to the bundle step
This commit is contained in:
@@ -115,7 +115,7 @@ function fromLocal(extensionPath, sourceMappingURLBase) {
|
|||||||
filesStream.pipe(result);
|
filesStream.pipe(result);
|
||||||
}
|
}
|
||||||
}).catch(function (err) { return result.emit('error', err); });
|
}).catch(function (err) { return result.emit('error', err); });
|
||||||
return stats_1.createStatsStream(path.basename(extensionPath), result, true);
|
return result.pipe(stats_1.createStatsStream(path.basename(extensionPath), true));
|
||||||
}
|
}
|
||||||
exports.fromLocal = fromLocal;
|
exports.fromLocal = fromLocal;
|
||||||
function error(err) {
|
function error(err) {
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ export function fromLocal(extensionPath: string, sourceMappingURLBase?: string):
|
|||||||
|
|
||||||
}).catch(err => result.emit('error', err));
|
}).catch(err => result.emit('error', err));
|
||||||
|
|
||||||
return createStatsStream(path.basename(extensionPath), result, true);
|
return result.pipe(createStatsStream(path.basename(extensionPath), true));
|
||||||
}
|
}
|
||||||
|
|
||||||
function error(err: any): Stream {
|
function error(err: any): Stream {
|
||||||
|
|||||||
+12
-10
@@ -4,23 +4,24 @@
|
|||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
'use strict';
|
'use strict';
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
var path = require("path");
|
var es = require("event-stream");
|
||||||
var gulp = require("gulp");
|
var gulp = require("gulp");
|
||||||
var sourcemaps = require("gulp-sourcemaps");
|
var concat = require("gulp-concat");
|
||||||
var filter = require("gulp-filter");
|
|
||||||
var minifyCSS = require("gulp-cssnano");
|
var minifyCSS = require("gulp-cssnano");
|
||||||
|
var filter = require("gulp-filter");
|
||||||
|
var flatmap = require("gulp-flatmap");
|
||||||
|
var sourcemaps = require("gulp-sourcemaps");
|
||||||
var uglify = require("gulp-uglify");
|
var uglify = require("gulp-uglify");
|
||||||
var composer = require("gulp-uglify/composer");
|
var composer = require("gulp-uglify/composer");
|
||||||
|
var gulpUtil = require("gulp-util");
|
||||||
|
var path = require("path");
|
||||||
|
var pump = require("pump");
|
||||||
var uglifyes = require("uglify-es");
|
var uglifyes = require("uglify-es");
|
||||||
var es = require("event-stream");
|
|
||||||
var concat = require("gulp-concat");
|
|
||||||
var VinylFile = require("vinyl");
|
var VinylFile = require("vinyl");
|
||||||
var bundle = require("./bundle");
|
var bundle = require("./bundle");
|
||||||
var util = require("./util");
|
|
||||||
var gulpUtil = require("gulp-util");
|
|
||||||
var flatmap = require("gulp-flatmap");
|
|
||||||
var pump = require("pump");
|
|
||||||
var i18n_1 = require("./i18n");
|
var i18n_1 = require("./i18n");
|
||||||
|
var stats_1 = require("./stats");
|
||||||
|
var util = require("./util");
|
||||||
var REPO_ROOT_PATH = path.join(__dirname, '../..');
|
var REPO_ROOT_PATH = path.join(__dirname, '../..');
|
||||||
function log(prefix, message) {
|
function log(prefix, message) {
|
||||||
gulpUtil.log(gulpUtil.colors.cyan('[' + prefix + ']'), message);
|
gulpUtil.log(gulpUtil.colors.cyan('[' + prefix + ']'), message);
|
||||||
@@ -101,7 +102,8 @@ function toConcatStream(src, bundledFileHeader, sources, dest) {
|
|||||||
});
|
});
|
||||||
return es.readArray(treatedSources)
|
return es.readArray(treatedSources)
|
||||||
.pipe(useSourcemaps ? util.loadSourcemaps() : es.through())
|
.pipe(useSourcemaps ? util.loadSourcemaps() : es.through())
|
||||||
.pipe(concat(dest));
|
.pipe(concat(dest))
|
||||||
|
.pipe(stats_1.createStatsStream(dest, true));
|
||||||
}
|
}
|
||||||
function toBundleStream(src, bundledFileHeader, bundles) {
|
function toBundleStream(src, bundledFileHeader, bundles) {
|
||||||
return es.merge(bundles.map(function (bundle) {
|
return es.merge(bundles.map(function (bundle) {
|
||||||
|
|||||||
+15
-13
@@ -5,24 +5,25 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import * as path from 'path';
|
import * as es from 'event-stream';
|
||||||
import * as gulp from 'gulp';
|
import * as gulp from 'gulp';
|
||||||
import * as sourcemaps from 'gulp-sourcemaps';
|
import * as concat from 'gulp-concat';
|
||||||
import * as filter from 'gulp-filter';
|
|
||||||
import * as minifyCSS from 'gulp-cssnano';
|
import * as minifyCSS from 'gulp-cssnano';
|
||||||
|
import * as filter from 'gulp-filter';
|
||||||
|
import * as flatmap from 'gulp-flatmap';
|
||||||
|
import * as sourcemaps from 'gulp-sourcemaps';
|
||||||
import * as uglify from 'gulp-uglify';
|
import * as uglify from 'gulp-uglify';
|
||||||
import * as composer from 'gulp-uglify/composer';
|
import * as composer from 'gulp-uglify/composer';
|
||||||
import * as uglifyes from 'uglify-es';
|
|
||||||
import * as es from 'event-stream';
|
|
||||||
import * as concat from 'gulp-concat';
|
|
||||||
import * as VinylFile from 'vinyl';
|
|
||||||
import * as bundle from './bundle';
|
|
||||||
import * as util from './util';
|
|
||||||
import * as gulpUtil from 'gulp-util';
|
import * as gulpUtil from 'gulp-util';
|
||||||
import * as flatmap from 'gulp-flatmap';
|
import * as path from 'path';
|
||||||
import * as pump from 'pump';
|
import * as pump from 'pump';
|
||||||
import * as sm from 'source-map';
|
import * as sm from 'source-map';
|
||||||
import { processNlsFiles, Language } from './i18n';
|
import * as uglifyes from 'uglify-es';
|
||||||
|
import * as VinylFile from 'vinyl';
|
||||||
|
import * as bundle from './bundle';
|
||||||
|
import { Language, processNlsFiles } from './i18n';
|
||||||
|
import { createStatsStream } from './stats';
|
||||||
|
import * as util from './util';
|
||||||
|
|
||||||
const REPO_ROOT_PATH = path.join(__dirname, '../..');
|
const REPO_ROOT_PATH = path.join(__dirname, '../..');
|
||||||
|
|
||||||
@@ -121,10 +122,11 @@ function toConcatStream(src: string, bundledFileHeader: string, sources: bundle.
|
|||||||
|
|
||||||
return es.readArray(treatedSources)
|
return es.readArray(treatedSources)
|
||||||
.pipe(useSourcemaps ? util.loadSourcemaps() : es.through())
|
.pipe(useSourcemaps ? util.loadSourcemaps() : es.through())
|
||||||
.pipe(concat(dest));
|
.pipe(concat(dest))
|
||||||
|
.pipe(createStatsStream(dest, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
function toBundleStream(src:string, bundledFileHeader: string, bundles: bundle.IConcatFile[]): NodeJS.ReadWriteStream {
|
function toBundleStream(src: string, bundledFileHeader: string, bundles: bundle.IConcatFile[]): NodeJS.ReadWriteStream {
|
||||||
return es.merge(bundles.map(function (bundle) {
|
return es.merge(bundles.map(function (bundle) {
|
||||||
return toConcatStream(src, bundledFileHeader, bundle.sources, bundle.dest);
|
return toConcatStream(src, bundledFileHeader, bundle.sources, bundle.dest);
|
||||||
}));
|
}));
|
||||||
|
|||||||
+20
-10
@@ -18,27 +18,37 @@ var Entry = /** @class */ (function () {
|
|||||||
return Entry;
|
return Entry;
|
||||||
}());
|
}());
|
||||||
var _entries = new Map();
|
var _entries = new Map();
|
||||||
function createStatsStream(group, stream, log) {
|
function createStatsStream(group, log) {
|
||||||
var entry = new Entry(group, 0, 0);
|
var entry = new Entry(group, 0, 0);
|
||||||
_entries.set(entry.name, entry);
|
_entries.set(entry.name, entry);
|
||||||
return stream.pipe(es.through(function (data) {
|
return es.through(function (data) {
|
||||||
var file = data;
|
var file = data;
|
||||||
if (typeof file.path === 'string') {
|
if (typeof file.path === 'string') {
|
||||||
entry.totalCount += 1;
|
entry.totalCount += 1;
|
||||||
if (typeof file.stat === 'object' && typeof file.stat.size === 'number') {
|
if (Buffer.isBuffer(file.contents)) {
|
||||||
|
entry.totalSize += file.contents.length;
|
||||||
|
}
|
||||||
|
else if (file.stat && typeof file.stat.size === 'number') {
|
||||||
entry.totalSize += file.stat.size;
|
entry.totalSize += file.stat.size;
|
||||||
// } else {
|
}
|
||||||
// console.warn(`${file.path} looks like a file but has no stat`);
|
else {
|
||||||
|
// funky file...
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.emit('data', data);
|
this.emit('data', data);
|
||||||
}, function () {
|
}, function () {
|
||||||
if (log) {
|
if (log) {
|
||||||
var count = entry.totalCount < 100
|
if (entry.totalCount === 1) {
|
||||||
? util.colors.green(entry.totalCount.toString())
|
util.log("Stats for '" + util.colors.grey(entry.name) + "': " + Math.round(entry.totalSize / 1204) + "KB");
|
||||||
: util.colors.red(entry.totalCount.toString());
|
}
|
||||||
util.log("Stats for " + group + ": " + count + " files with approx. " + Math.round(entry.totalSize / 1204) + "KB");
|
else {
|
||||||
|
var count = entry.totalCount < 100
|
||||||
|
? util.colors.green(entry.totalCount.toString())
|
||||||
|
: util.colors.red(entry.totalCount.toString());
|
||||||
|
util.log("Stats for '" + util.colors.grey(entry.name) + "': " + count + " files, " + Math.round(entry.totalSize / 1204) + "KB");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}));
|
this.emit('end');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
exports.createStatsStream = createStatsStream;
|
exports.createStatsStream = createStatsStream;
|
||||||
|
|||||||
+20
-12
@@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
import * as es from 'event-stream';
|
import * as es from 'event-stream';
|
||||||
import * as util from 'gulp-util';
|
import * as util from 'gulp-util';
|
||||||
import { Stream } from 'stream';
|
|
||||||
import * as File from 'vinyl';
|
import * as File from 'vinyl';
|
||||||
|
|
||||||
class Entry {
|
class Entry {
|
||||||
@@ -20,29 +19,38 @@ class Entry {
|
|||||||
|
|
||||||
const _entries = new Map<string, Entry>();
|
const _entries = new Map<string, Entry>();
|
||||||
|
|
||||||
export function createStatsStream(group: string, stream: Stream, log?: boolean): Stream {
|
export function createStatsStream(group: string, log?: boolean): es.ThroughStream {
|
||||||
|
|
||||||
const entry = new Entry(group, 0, 0);
|
const entry = new Entry(group, 0, 0);
|
||||||
_entries.set(entry.name, entry);
|
_entries.set(entry.name, entry);
|
||||||
|
|
||||||
return stream.pipe(es.through(function (data) {
|
return es.through(function (data) {
|
||||||
let file = data as File;
|
let file = data as File;
|
||||||
if (typeof file.path === 'string') {
|
if (typeof file.path === 'string') {
|
||||||
entry.totalCount += 1;
|
entry.totalCount += 1;
|
||||||
if (typeof file.stat === 'object' && typeof file.stat.size === 'number') {
|
if (Buffer.isBuffer(file.contents)) {
|
||||||
|
entry.totalSize += file.contents.length;
|
||||||
|
} else if (file.stat && typeof file.stat.size === 'number') {
|
||||||
entry.totalSize += file.stat.size;
|
entry.totalSize += file.stat.size;
|
||||||
// } else {
|
} else {
|
||||||
// console.warn(`${file.path} looks like a file but has no stat`);
|
// funky file...
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.emit('data', data);
|
this.emit('data', data);
|
||||||
}, () => {
|
}, function () {
|
||||||
if (log) {
|
if (log) {
|
||||||
let count = entry.totalCount < 100
|
if (entry.totalCount === 1) {
|
||||||
? util.colors.green(entry.totalCount.toString())
|
util.log(`Stats for '${util.colors.grey(entry.name)}': ${Math.round(entry.totalSize / 1204)}KB`);
|
||||||
: util.colors.red(entry.totalCount.toString());
|
|
||||||
|
|
||||||
util.log(`Stats for ${group}: ${count} files with approx. ${Math.round(entry.totalSize / 1204)}KB`);
|
} else {
|
||||||
|
let count = entry.totalCount < 100
|
||||||
|
? util.colors.green(entry.totalCount.toString())
|
||||||
|
: util.colors.red(entry.totalCount.toString());
|
||||||
|
|
||||||
|
util.log(`Stats for '${util.colors.grey(entry.name)}': ${count} files, ${Math.round(entry.totalSize / 1204)}KB`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}));
|
|
||||||
|
this.emit('end');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user