提交 646d0f9e 编写于 作者: J Joao Moreno

💚 fix linux build due to excessive output

上级 0b19861f
......@@ -202,8 +202,10 @@ function uglifyWithCopyrights() {
var input = es.through();
var output = input
.pipe(flatmap(function (stream, f) {
return stream
.pipe(uglify({ preserveComments: preserveComments(f) }));
return stream.pipe(uglify({
preserveComments: preserveComments(f),
warnings: false
}));
}));
return es.duplex(input, output);
}
......
......@@ -24,17 +24,17 @@ import * as sm from 'source-map';
const REPO_ROOT_PATH = path.join(__dirname, '../..');
function log(prefix:string, message:string): void {
function log(prefix: string, message: string): void {
gulpUtil.log(gulpUtil.colors.cyan('[' + prefix + ']'), message);
}
export function loaderConfig(emptyPaths:string[]) {
export function loaderConfig(emptyPaths: string[]) {
const result = {
paths: {
'vs': 'out-build/vs',
'vscode': 'empty:'
},
nodeModules: emptyPaths||[]
nodeModules: emptyPaths || []
};
result['vs/css'] = { inlineResources: true };
......@@ -48,7 +48,7 @@ declare class FileSourceMap extends VinylFile {
public sourceMap: sm.RawSourceMap;
}
function loader(bundledFileHeader:string, bundleLoader:boolean): NodeJS.ReadWriteStream {
function loader(bundledFileHeader: string, bundleLoader: boolean): NodeJS.ReadWriteStream {
let sources = [
'out-build/vs/loader.js'
];
......@@ -62,30 +62,30 @@ function loader(bundledFileHeader:string, bundleLoader:boolean): NodeJS.ReadWrit
let isFirst = true;
return (
gulp
.src(sources, { base: 'out-build' })
.pipe(es.through(function(data) {
if (isFirst) {
isFirst = false;
this.emit('data', new VinylFile({
path: 'fake',
base: '',
contents: new Buffer(bundledFileHeader)
}));
this.emit('data', data);
} else {
this.emit('data', data);
}
}))
.pipe(util.loadSourcemaps())
.pipe(concat('vs/loader.js'))
.pipe(es.mapSync<FileSourceMap,FileSourceMap>(function (f) {
f.sourceMap.sourceRoot = util.toFileUri(path.join(REPO_ROOT_PATH, 'src'));
return f;
}))
.src(sources, { base: 'out-build' })
.pipe(es.through(function (data) {
if (isFirst) {
isFirst = false;
this.emit('data', new VinylFile({
path: 'fake',
base: '',
contents: new Buffer(bundledFileHeader)
}));
this.emit('data', data);
} else {
this.emit('data', data);
}
}))
.pipe(util.loadSourcemaps())
.pipe(concat('vs/loader.js'))
.pipe(es.mapSync<FileSourceMap, FileSourceMap>(function (f) {
f.sourceMap.sourceRoot = util.toFileUri(path.join(REPO_ROOT_PATH, 'src'));
return f;
}))
);
}
function toConcatStream(bundledFileHeader:string, sources:bundle.IFile[], dest:string): NodeJS.ReadWriteStream {
function toConcatStream(bundledFileHeader: string, sources: bundle.IFile[], dest: string): NodeJS.ReadWriteStream {
const useSourcemaps = /\.js$/.test(dest) && !/\.nls\.js$/.test(dest);
// If a bundle ends up including in any of the sources our copyright, then
......@@ -106,7 +106,7 @@ function toConcatStream(bundledFileHeader:string, sources:bundle.IFile[], dest:s
});
}
const treatedSources = sources.map(function(source) {
const treatedSources = sources.map(function (source) {
const root = source.path ? REPO_ROOT_PATH.replace(/\\/g, '/') : '';
const base = source.path ? root + '/out-build' : '';
......@@ -122,8 +122,8 @@ function toConcatStream(bundledFileHeader:string, sources:bundle.IFile[], dest:s
.pipe(concat(dest));
}
function toBundleStream(bundledFileHeader:string, bundles:bundle.IConcatFile[]): NodeJS.ReadWriteStream {
return es.merge(bundles.map(function(bundle) {
function toBundleStream(bundledFileHeader: string, bundles: bundle.IConcatFile[]): NodeJS.ReadWriteStream {
return es.merge(bundles.map(function (bundle) {
return toConcatStream(bundledFileHeader, bundle.sources, bundle.dest);
}));
}
......@@ -159,7 +159,7 @@ export interface IOptimizeTaskOpts {
*/
out: string;
}
export function optimizeTask(opts:IOptimizeTaskOpts):()=>NodeJS.ReadWriteStream {
export function optimizeTask(opts: IOptimizeTaskOpts): () => NodeJS.ReadWriteStream {
const entryPoints = opts.entryPoints;
const otherSources = opts.otherSources;
const resources = opts.resources;
......@@ -168,19 +168,19 @@ export function optimizeTask(opts:IOptimizeTaskOpts):()=>NodeJS.ReadWriteStream
const bundleLoader = (typeof opts.bundleLoader === 'undefined' ? true : opts.bundleLoader);
const out = opts.out;
return function() {
return function () {
const bundlesStream = es.through(); // this stream will contain the bundled files
const resourcesStream = es.through(); // this stream will contain the resources
const bundleInfoStream = es.through(); // this stream will contain bundleInfo.json
bundle.bundle(entryPoints, loaderConfig, function(err, result) {
bundle.bundle(entryPoints, loaderConfig, function (err, result) {
if (err) { return bundlesStream.emit('error', JSON.stringify(err)); }
toBundleStream(bundledFileHeader, result.files).pipe(bundlesStream);
// Remove css inlined resources
const filteredResources = resources.slice();
result.cssInlinedResources.forEach(function(resource) {
result.cssInlinedResources.forEach(function (resource) {
if (process.env['VSCODE_BUILD_VERBOSE']) {
log('optimizer', 'excluding inlined: ' + resource);
}
......@@ -188,7 +188,7 @@ export function optimizeTask(opts:IOptimizeTaskOpts):()=>NodeJS.ReadWriteStream
});
gulp.src(filteredResources, { base: 'out-build' }).pipe(resourcesStream);
const bundleInfoArray:VinylFile[] = [];
const bundleInfoArray: VinylFile[] = [];
if (opts.bundleInfo) {
bundleInfoArray.push(new VinylFile({
path: 'bundleInfo.json',
......@@ -200,7 +200,7 @@ export function optimizeTask(opts:IOptimizeTaskOpts):()=>NodeJS.ReadWriteStream
});
const otherSourcesStream = es.through();
const otherSourcesStreamArr:NodeJS.ReadWriteStream[] = [];
const otherSourcesStreamArr: NodeJS.ReadWriteStream[] = [];
gulp.src(otherSources, { base: 'out-build' })
.pipe(es.through(function (data) {
......@@ -241,9 +241,9 @@ declare class FileWithCopyright extends VinylFile {
* Wrap around uglify and allow the preserveComments function
* to have a file "context" to include our copyright only once per file.
*/
function uglifyWithCopyrights():NodeJS.ReadWriteStream {
const preserveComments = (f:FileWithCopyright) => {
return (node, comment:{value:string;type:string;}) => {
function uglifyWithCopyrights(): NodeJS.ReadWriteStream {
const preserveComments = (f: FileWithCopyright) => {
return (node, comment: { value: string; type: string; }) => {
const text = comment.value;
const type = comment.type;
......@@ -274,15 +274,17 @@ function uglifyWithCopyrights():NodeJS.ReadWriteStream {
const input = es.through();
const output = input
.pipe(flatmap((stream, f) => {
return stream
.pipe(uglify({ preserveComments: preserveComments(<FileWithCopyright>f) }));
return stream.pipe(uglify({
preserveComments: preserveComments(<FileWithCopyright>f),
warnings: false
}));
}));
return es.duplex(input, output);
}
export function minifyTask(src:string, sourceMapBaseUrl:string):(cb:any)=>void {
const sourceMappingURL = sourceMapBaseUrl && (f => `${ sourceMapBaseUrl }/${ f.relative }.map`);
export function minifyTask(src: string, sourceMapBaseUrl: string): (cb: any) => void {
const sourceMappingURL = sourceMapBaseUrl && (f => `${sourceMapBaseUrl}/${f.relative}.map`);
return cb => {
const jsFilter = filter('**/*.js', { restore: true });
......@@ -304,12 +306,12 @@ export function minifyTask(src:string, sourceMapBaseUrl:string):(cb:any)=>void {
addComment: true
}),
gulp.dest(src + '-min')
, (err:any) => {
if (err instanceof uglify.GulpUglifyError) {
console.error(`Uglify error in '${ err.cause && err.cause.filename }'`);
}
, (err: any) => {
if (err instanceof uglify.GulpUglifyError) {
console.error(`Uglify error in '${err.cause && err.cause.filename}'`);
}
cb(err);
});
cb(err);
});
};
};
......@@ -29,7 +29,9 @@ declare module "gulp-uglify" {
* some - Preserve comments that start with a bang (!) or include a Closure Compiler directive (@preserve, @license, @cc_on)
* function - Specify your own comment preservation function. You will be passed the current node and the current comment and are expected to return either true or false.
*/
preserveComments?: string|((node: any, comment: UglifyJS.Tokenizer) => boolean);
preserveComments?: string | ((node: any, comment: UglifyJS.Tokenizer) => boolean);
warnings?: boolean;
}
class GulpUglifyError {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册