33 * Licensed under the MIT License. See License.txt in the project root for license information.
44 *--------------------------------------------------------------------------------------------*/
55
6- var path = require ( 'path' ) ;
7- var gulp = require ( 'gulp' ) ;
8- var sourcemaps = require ( 'gulp-sourcemaps' ) ;
9- var filter = require ( 'gulp-filter' ) ;
10- var minifyCSS = require ( 'gulp-cssnano' ) ;
11- var uglify = require ( 'gulp-uglify' ) ;
12- var es = require ( 'event-stream' ) ;
13- var concat = require ( 'gulp-concat' ) ;
14- var File = require ( 'vinyl' ) ;
15- var bundle = require ( './lib/bundle' ) ;
16- var util = require ( './lib/util' ) ;
17- var i18n = require ( './lib/i18n' ) ;
18- var gulpUtil = require ( 'gulp-util' ) ;
6+ 'use strict' ;
7+
8+ const path = require ( 'path' ) ;
9+ const gulp = require ( 'gulp' ) ;
10+ const sourcemaps = require ( 'gulp-sourcemaps' ) ;
11+ const filter = require ( 'gulp-filter' ) ;
12+ const minifyCSS = require ( 'gulp-cssnano' ) ;
13+ const uglify = require ( 'gulp-uglify' ) ;
14+ const es = require ( 'event-stream' ) ;
15+ const concat = require ( 'gulp-concat' ) ;
16+ const File = require ( 'vinyl' ) ;
17+ const bundle = require ( './lib/bundle' ) ;
18+ const util = require ( './lib/util' ) ;
19+ const i18n = require ( './lib/i18n' ) ;
20+ const gulpUtil = require ( 'gulp-util' ) ;
1921
2022function log ( prefix , message ) {
2123 gulpUtil . log ( gulpUtil . colors . cyan ( '[' + prefix + ']' ) , message ) ;
2224}
2325
24- var root = path . dirname ( __dirname ) ;
25- var commit = util . getVersion ( root ) ;
26+ const root = path . dirname ( __dirname ) ;
27+ const commit = util . getVersion ( root ) ;
2628
2729exports . loaderConfig = function ( emptyPaths ) {
28- var result = {
30+ const result = {
2931 paths : {
3032 'vs' : 'out-build/vs' ,
3133 'vscode' : 'empty:'
3234 } ,
33- nodeModules : emptyPaths || [ ] ,
35+ nodeModules : emptyPaths || [ ]
3436 } ;
3537
3638 result [ 'vs/css' ] = { inlineResources : true } ;
3739
3840 return result ;
3941} ;
4042
41- var IS_OUR_COPYRIGHT_REGEXP = / C o p y r i g h t \( C \) M i c r o s o f t C o r p o r a t i o n / i;
43+ const IS_OUR_COPYRIGHT_REGEXP = / C o p y r i g h t \( C \) M i c r o s o f t C o r p o r a t i o n / i;
4244
4345function loader ( bundledFileHeader ) {
44- var isFirst = true ;
46+ let isFirst = true ;
4547 return gulp . src ( [
4648 'out-build/vs/loader.js' ,
4749 'out-build/vs/css.js' ,
48- 'out-build/vs/nls.js' ,
50+ 'out-build/vs/nls.js'
4951 ] , { base : 'out-build' } )
5052 . pipe ( es . through ( function ( data ) {
5153 if ( isFirst ) {
@@ -69,13 +71,13 @@ function loader(bundledFileHeader) {
6971}
7072
7173function toConcatStream ( bundledFileHeader , sources , dest ) {
72- var useSourcemaps = / \. j s $ / . test ( dest ) && ! / \. n l s \. j s $ / . test ( dest ) ;
74+ const useSourcemaps = / \. j s $ / . test ( dest ) && ! / \. n l s \. j s $ / . test ( dest ) ;
7375
7476 // If a bundle ends up including in any of the sources our copyright, then
7577 // insert a fake source at the beginning of each bundle with our copyright
76- var containsOurCopyright = false ;
77- for ( var i = 0 , len = sources . length ; i < len ; i ++ ) {
78- var fileContents = sources [ i ] . contents ;
78+ let containsOurCopyright = false ;
79+ for ( let i = 0 , len = sources . length ; i < len ; i ++ ) {
80+ const fileContents = sources [ i ] . contents ;
7981 if ( IS_OUR_COPYRIGHT_REGEXP . test ( fileContents ) ) {
8082 containsOurCopyright = true ;
8183 break ;
@@ -89,9 +91,9 @@ function toConcatStream(bundledFileHeader, sources, dest) {
8991 } ) ;
9092 }
9193
92- var treatedSources = sources . map ( function ( source ) {
93- var root = source . path ? path . dirname ( __dirname ) . replace ( / \\ / g, '/' ) : '' ;
94- var base = source . path ? root + '/out-build' : '' ;
94+ const treatedSources = sources . map ( function ( source ) {
95+ const root = source . path ? path . dirname ( __dirname ) . replace ( / \\ / g, '/' ) : '' ;
96+ const base = source . path ? root + '/out-build' : '' ;
9597
9698 return new File ( {
9799 path : source . path ? root + '/' + source . path . replace ( / \\ / g, '/' ) : 'fake' ,
@@ -122,26 +124,25 @@ function toBundleStream(bundledFileHeader, bundles) {
122124 * - out (out folder name)
123125 */
124126exports . optimizeTask = function ( opts ) {
125- var entryPoints = opts . entryPoints ;
126- var otherSources = opts . otherSources ;
127- var resources = opts . resources ;
128- var loaderConfig = opts . loaderConfig ;
129- var bundledFileHeader = opts . header ;
130- var out = opts . out ;
127+ const entryPoints = opts . entryPoints ;
128+ const otherSources = opts . otherSources ;
129+ const resources = opts . resources ;
130+ const loaderConfig = opts . loaderConfig ;
131+ const bundledFileHeader = opts . header ;
132+ const out = opts . out ;
131133
132134 return function ( ) {
133- var bundlesStream = es . through ( ) ; // this stream will contain the bundled files
134- var resourcesStream = es . through ( ) ; // this stream will contain the resources
135- var bundleInfoStream = es . through ( ) ; // this stream will contain bundleInfo.json
135+ const bundlesStream = es . through ( ) ; // this stream will contain the bundled files
136+ const resourcesStream = es . through ( ) ; // this stream will contain the resources
137+ const bundleInfoStream = es . through ( ) ; // this stream will contain bundleInfo.json
136138
137139 bundle . bundle ( entryPoints , loaderConfig , function ( err , result ) {
138140 if ( err ) { return bundlesStream . emit ( 'error' , JSON . stringify ( err ) ) ; }
139141
140142 toBundleStream ( bundledFileHeader , result . files ) . pipe ( bundlesStream ) ;
141143
142144 // Remove css inlined resources
143- var filteredResources = [ ] ;
144- filteredResources = filteredResources . concat ( resources ) ;
145+ const filteredResources = resources . slice ( ) ;
145146 result . cssInlinedResources . forEach ( function ( resource ) {
146147 if ( process . env [ 'VSCODE_BUILD_VERBOSE' ] ) {
147148 log ( 'optimizer' , 'excluding inlined: ' + resource ) ;
@@ -150,7 +151,7 @@ exports.optimizeTask = function(opts) {
150151 } ) ;
151152 gulp . src ( filteredResources , { base : 'out-build' } ) . pipe ( resourcesStream ) ;
152153
153- var bundleInfoArray = [ ] ;
154+ const bundleInfoArray = [ ] ;
154155 if ( opts . bundleInfo ) {
155156 bundleInfoArray . push ( new File ( {
156157 path : 'bundleInfo.json' ,
@@ -161,8 +162,8 @@ exports.optimizeTask = function(opts) {
161162 es . readArray ( bundleInfoArray ) . pipe ( bundleInfoStream ) ;
162163 } ) ;
163164
164- var otherSourcesStream = es . through ( ) ;
165- var otherSourcesStreamArr = [ ] ;
165+ const otherSourcesStream = es . through ( ) ;
166+ const otherSourcesStreamArr = [ ] ;
166167
167168 gulp . src ( otherSources , { base : 'out-build' } )
168169 . pipe ( es . through ( function ( data ) {
@@ -175,7 +176,7 @@ exports.optimizeTask = function(opts) {
175176 }
176177 } ) ) ;
177178
178- var result = es . merge (
179+ const result = es . merge (
179180 loader ( bundledFileHeader ) ,
180181 bundlesStream ,
181182 otherSourcesStream ,
@@ -197,25 +198,23 @@ exports.optimizeTask = function(opts) {
197198} ;
198199
199200/**
200- * wrap around uglify and allow the preserveComments function
201- * to have a file "context" to include our copyright only once per file
201+ * Wrap around uglify and allow the preserveComments function
202+ * to have a file "context" to include our copyright only once per file.
202203 */
203204function uglifyWithCopyrights ( ) {
204- var currentFileHasOurCopyright = false ;
205+ let currentFileHasOurCopyright = false ;
205206
206- var onNewFile = function ( ) {
207- currentFileHasOurCopyright = false ;
208- } ;
207+ const onNewFile = ( ) => currentFileHasOurCopyright = false ;
209208
210- var preserveComments = function ( node , comment ) {
211- var text = comment . value ;
212- var type = comment . type ;
209+ const preserveComments = function ( node , comment ) {
210+ const text = comment . value ;
211+ const type = comment . type ;
213212
214213 if ( / @ m i n i f i e r _ d o _ n o t _ p r e s e r v e / . test ( text ) ) {
215214 return false ;
216215 }
217216
218- var isOurCopyright = IS_OUR_COPYRIGHT_REGEXP . test ( text ) ;
217+ const isOurCopyright = IS_OUR_COPYRIGHT_REGEXP . test ( text ) ;
219218
220219 if ( isOurCopyright ) {
221220 if ( currentFileHasOurCopyright ) {
@@ -234,26 +233,25 @@ function uglifyWithCopyrights() {
234233 return false ;
235234 } ;
236235
237- var uglifyStream = uglify ( { preserveComments : preserveComments } ) ;
236+ const uglifyStream = uglify ( { preserveComments } ) ;
238237
239- return es . through ( function write ( data ) {
240- var _this = this ;
238+ return es . through ( function ( data ) {
239+ const _this = this ;
241240
242241 onNewFile ( ) ;
243242
244243 uglifyStream . once ( 'data' , function ( data ) {
245244 _this . emit ( 'data' , data ) ;
246245 } )
247246 uglifyStream . write ( data ) ;
248- } , function end ( ) {
249- this . emit ( 'end' )
250- } ) ;
247+ } ,
248+ function ( ) { this . emit ( 'end' ) ; } ) ;
251249}
252250
253251exports . minifyTask = function ( src , addSourceMapsComment ) {
254252 return function ( ) {
255- var jsFilter = filter ( '**/*.js' , { restore : true } ) ;
256- var cssFilter = filter ( '**/*.css' , { restore : true } ) ;
253+ const jsFilter = filter ( '**/*.js' , { restore : true } ) ;
254+ const cssFilter = filter ( '**/*.css' , { restore : true } ) ;
257255
258256 return gulp . src ( [ src + '/**' , '!' + src + '/**/*.map' ] )
259257 . pipe ( jsFilter )
0 commit comments