@@ -24,24 +24,24 @@ const getDirSize = require("./scripts/build/getDirSize");
24
24
const project = require ( "./scripts/build/project" ) ;
25
25
const replace = require ( "./scripts/build/replace" ) ;
26
26
const convertConstEnums = require ( "./scripts/build/convertConstEnum" ) ;
27
- const makeLibraryTargets = require ( "./scripts/build/lib" ) ;
28
27
const needsUpdate = require ( "./scripts/build/needsUpdate" ) ;
29
28
const getDiffTool = require ( "./scripts/build/getDiffTool" ) ;
30
29
const baselineAccept = require ( "./scripts/build/baselineAccept" ) ;
31
30
const cmdLineOptions = require ( "./scripts/build/options" ) ;
32
31
const exec = require ( "./scripts/build/exec" ) ;
32
+ const _debugMode = require ( "./scripts/build/debugMode" ) ;
33
+ const { libraryTargets, generateLibs } = require ( "./scripts/build/lib" ) ;
33
34
const { runConsoleTests, cleanTestDirs, writeTestConfigFile, refBaseline, localBaseline, refRwcBaseline, localRwcBaseline } = require ( "./scripts/build/tests" ) ;
34
35
35
36
Error . stackTraceLimit = 1000 ;
36
37
37
38
// Constants
38
39
const host = cmdLineOptions . host ;
39
40
const copyright = "CopyrightNotice.txt" ;
40
- const libraryTargets = makeLibraryTargets ( [ copyright ] ) ;
41
41
42
- // Compile using the LKG compiler
43
42
project . addTypeScript ( "lkg" , "./lib/typescript.js" ) ;
44
- project . addTypeScript ( "default" , "lkg" ) ;
43
+ project . addTypeScript ( "built" , "./built/local/typescriptServices.js" ) ;
44
+ project . addTypeScript ( "default" , "lkg" ) ; // Compile using the LKG compiler by default
45
45
46
46
const scriptsProject = "scripts/tsconfig.json" ;
47
47
const configurePrereleaseJs = "scripts/configurePrerelease.js" ;
@@ -50,7 +50,7 @@ const generateLocalizedDiagnosticMessagesJs = "scripts/generateLocalizedDiagnost
50
50
const buildProtocolJs = "scripts/buildProtocol.js" ;
51
51
const produceLKGJs = "scripts/produceLKG.js" ;
52
52
const word2mdJs = "scripts/word2md.js" ;
53
- gulp . task ( "scripts" , /*help*/ false , [ project ( scriptsProject ) ] , undefined , {
53
+ gulp . task ( "scripts" , /*help*/ false , ( ) => project . compile ( scriptsProject ) , {
54
54
aliases : [
55
55
configurePrereleaseJs ,
56
56
processDiagnosticMessagesJs ,
@@ -60,7 +60,7 @@ gulp.task("scripts", /*help*/ false, [project(scriptsProject)], undefined, {
60
60
word2mdJs
61
61
]
62
62
} ) ;
63
- gulp . task ( "clean-scripts" , /*help*/ false , [ project . clean ( scriptsProject ) ] ) ;
63
+ gulp . task ( "clean-scripts" , /*help*/ false , ( ) => project . clean ( scriptsProject ) ) ;
64
64
65
65
// Nightly management tasks
66
66
gulp . task (
@@ -78,8 +78,8 @@ gulp.task(
78
78
79
79
const importDefinitelyTypedTestsProject = "scripts/importDefinitelyTypedTests/tsconfig.json" ;
80
80
const importDefinitelyTypedTestsJs = "scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.js" ;
81
- gulp . task ( importDefinitelyTypedTestsJs , /*help*/ false , [ project ( importDefinitelyTypedTestsProject ) ] ) ;
82
- gulp . task ( "clean:" + importDefinitelyTypedTestsJs , /*help*/ false , [ project . clean ( importDefinitelyTypedTestsProject ) ] ) ;
81
+ gulp . task ( importDefinitelyTypedTestsJs , /*help*/ false , ( ) => project . compile ( importDefinitelyTypedTestsProject ) ) ;
82
+ gulp . task ( "clean:" + importDefinitelyTypedTestsJs , /*help*/ false , ( ) => project . clean ( importDefinitelyTypedTestsProject ) ) ;
83
83
84
84
gulp . task (
85
85
"importDefinitelyTypedTests" ,
@@ -90,7 +90,7 @@ gulp.task(
90
90
gulp . task (
91
91
"lib" ,
92
92
"Builds the library targets" ,
93
- libraryTargets ) ;
93
+ ( ) => generateLibs ( [ copyright ] ) ) ;
94
94
95
95
// The generated diagnostics map; built for the compiler and for the "generate-diagnostics" task
96
96
const diagnosticInformationMapTs = "src/compiler/diagnosticInformationMap.generated.ts" ;
@@ -145,20 +145,18 @@ gulp.task(typescriptServicesProject, /*help*/ false, () => {
145
145
// NOTE: flatten services so that we can properly strip @internal
146
146
project . flatten ( "src/services/tsconfig.json" , typescriptServicesProject , {
147
147
compilerOptions : {
148
+ "removeComments" : true ,
148
149
"stripInternal" : true ,
149
150
"outFile" : "typescriptServices.js"
150
151
}
151
152
} ) ;
152
- } )
153
+ } ) ;
153
154
154
155
const typescriptServicesJs = "built/local/typescriptServices.js" ;
155
156
const typescriptServicesDts = "built/local/typescriptServices.d.ts" ;
156
- const typescriptServicesProjectTask = project . defer ( typescriptServicesProject , {
157
- dts : files => files . pipe ( convertConstEnums ( ) ) ,
158
- release : { compilerOptions : { removeComments : true } }
159
- } ) ;
160
-
161
- gulp . task ( typescriptServicesJs , /*help*/ false , [ "lib" , "generate-diagnostics" , typescriptServicesProject ] , typescriptServicesProjectTask , { aliases : [ typescriptServicesDts ] } ) ;
157
+ gulp . task ( typescriptServicesJs , /*help*/ false , [ "lib" , "generate-diagnostics" , typescriptServicesProject ] , ( ) =>
158
+ project . compile ( typescriptServicesProject , { dts : convertConstEnums ( ) } ) ,
159
+ { aliases : [ typescriptServicesDts ] } ) ;
162
160
163
161
const typescriptJs = "built/local/typescript.js" ;
164
162
gulp . task ( typescriptJs , /*help*/ false , [ typescriptServicesJs ] , ( ) =>
@@ -186,28 +184,25 @@ gulp.task(typescriptStandaloneDts, /*help*/ false, [typescriptServicesDts], () =
186
184
// build all 'typescriptServices'-related outputs
187
185
gulp . task ( "typescriptServices" , /*help*/ false , [ typescriptServicesJs , typescriptServicesDts , typescriptJs , typescriptDts , typescriptStandaloneDts ] ) ;
188
186
189
- // Add the "built" compiler with a dependency on the built version of the compiler.
190
- project . addTypeScript ( "built" , "./built/local/typescriptServices.js" , [ typescriptServicesJs ] ) ;
191
-
192
187
const tscProject = "src/tsc/tsconfig.json" ;
193
188
const tscJs = "built/local/tsc.js" ;
194
- gulp . task ( tscJs , /*help*/ false , [ project ( tscProject , { typescript : "built" , release : { compilerOptions : { removeComments : true } } } ) ] ) ;
189
+ gulp . task ( tscJs , /*help*/ false , [ typescriptServicesJs ] , ( ) => project . compile ( tscProject , { typescript : "built" } ) ) ;
195
190
196
191
const cancellationTokenProject = "src/cancellationToken/tsconfig.json" ;
197
192
const cancellationTokenJs = "built/local/cancellationToken.js" ;
198
- gulp . task ( cancellationTokenJs , /*help*/ false , [ project ( cancellationTokenProject , { typescript : "built" , release : { compilerOptions : { removeComments : true } } } ) ] ) ;
193
+ gulp . task ( cancellationTokenJs , /*help*/ false , [ typescriptServicesJs ] , ( ) => project . compile ( cancellationTokenProject , { typescript : "built" } ) ) ;
199
194
200
195
const typingsInstallerProject = "src/typingsInstaller/tsconfig.json" ;
201
196
const typingsInstallerJs = "built/local/typingsInstaller.js" ;
202
- gulp . task ( typingsInstallerJs , /*help*/ false , [ project ( typingsInstallerProject , { typescript : "built" , release : { compilerOptions : { removeComments : true } } } ) ] ) ;
197
+ gulp . task ( typingsInstallerJs , /*help*/ false , [ typescriptServicesJs ] , ( ) => project . compile ( typingsInstallerProject , { typescript : "built" } ) ) ;
203
198
204
199
const tsserverProject = "src/tsserver/tsconfig.json" ;
205
200
const tsserverJs = "built/local/tsserver.js" ;
206
- gulp . task ( tsserverJs , /*help*/ false , [ project ( tsserverProject , { typescript : "built" , release : { compilerOptions : { removeComments : true } } } ) ] ) ;
201
+ gulp . task ( tsserverJs , /*help*/ false , [ typescriptServicesJs ] , ( ) => project . compile ( tsserverProject , { typescript : "built" } ) ) ;
207
202
208
203
const watchGuardProject = "src/watchGuard/tsconfig.json" ;
209
204
const watchGuardJs = "built/local/watchGuard.js" ;
210
- gulp . task ( watchGuardJs , /*help*/ false , [ project ( watchGuardProject , { typescript : "built" , release : { compilerOptions : { removeComments : true } } } ) ] ) ;
205
+ gulp . task ( watchGuardJs , /*help*/ false , [ typescriptServicesJs ] , ( ) => project . compile ( watchGuardProject , { typescript : "built" } ) ) ;
211
206
212
207
const typesMapJson = "built/local/typesMap.json" ;
213
208
gulp . task ( typesMapJson , /*help*/ false , [ ] , ( ) =>
@@ -249,42 +244,43 @@ gulp.task(
249
244
"Generates a Markdown version of the Language Specification" ,
250
245
[ specMd ] ) ;
251
246
247
+ gulp . task ( "produce-LKG" , /*help*/ false , [ "scripts" , "local" , cancellationTokenJs , typingsInstallerJs , watchGuardJs ] , ( ) => {
248
+ const expectedFiles = [
249
+ tscJs ,
250
+ typescriptServicesJs ,
251
+ tsserverJs ,
252
+ typescriptJs ,
253
+ typescriptDts ,
254
+ typescriptServicesDts ,
255
+ tsserverlibraryDts ,
256
+ tsserverlibraryDts ,
257
+ typingsInstallerJs ,
258
+ cancellationTokenJs
259
+ ] . concat ( libraryTargets ) ;
260
+ const missingFiles = expectedFiles
261
+ . concat ( localizationTargets )
262
+ . filter ( f => ! fs . existsSync ( f ) ) ;
263
+ if ( missingFiles . length > 0 ) {
264
+ throw new Error ( "Cannot replace the LKG unless all built targets are present in directory 'built/local/'. The following files are missing:\n" + missingFiles . join ( "\n" ) ) ;
265
+ }
266
+ const sizeBefore = getDirSize ( "lib" ) ;
267
+ return exec ( host , [ produceLKGJs ] ) . then ( ( ) => {
268
+ const sizeAfter = getDirSize ( "lib" ) ;
269
+ if ( sizeAfter > ( sizeBefore * 1.10 ) ) {
270
+ throw new Error ( "The lib folder increased by 10% or more. This likely indicates a bug." ) ;
271
+ }
272
+ } ) ;
273
+ } ) ;
274
+
252
275
gulp . task (
253
276
"LKG" ,
254
277
"Makes a new LKG out of the built js files" ,
255
- ( ) => runSequence ( "clean-built" , "dontUseDebugMode" , [ "scripts" , "local" , cancellationTokenJs , typingsInstallerJs , watchGuardJs ] ,
256
- ( ) => {
257
- const expectedFiles = [
258
- tscJs ,
259
- typescriptServicesJs ,
260
- tsserverJs ,
261
- typescriptJs ,
262
- typescriptDts ,
263
- typescriptServicesDts ,
264
- tsserverlibraryDts ,
265
- tsserverlibraryDts ,
266
- typingsInstallerJs ,
267
- cancellationTokenJs
268
- ] . concat ( libraryTargets ) ;
269
- const missingFiles = expectedFiles
270
- . concat ( localizationTargets )
271
- . filter ( f => ! fs . existsSync ( f ) ) ;
272
- if ( missingFiles . length > 0 ) {
273
- throw new Error ( "Cannot replace the LKG unless all built targets are present in directory 'built/local/'. The following files are missing:\n" + missingFiles . join ( "\n" ) ) ;
274
- }
275
- const sizeBefore = getDirSize ( "lib" ) ;
276
- return exec ( host , [ produceLKGJs ] ) . then ( ( ) => {
277
- const sizeAfter = getDirSize ( "lib" ) ;
278
- if ( sizeAfter > ( sizeBefore * 1.10 ) ) {
279
- throw new Error ( "The lib folder increased by 10% or more. This likely indicates a bug." ) ;
280
- }
281
- } ) ;
282
- } ) ) ;
278
+ ( ) => runSequence ( "clean-built" , "dontUseDebugMode" , "produce-LKG" ) ) ;
283
279
284
280
// Task to build the tests infrastructure using the built compiler
285
281
const testRunnerProject = "src/testRunner/tsconfig.json" ;
286
282
const runJs = "built/local/run.js" ;
287
- gulp . task ( runJs , /*help*/ false , [ project ( testRunnerProject , { typescript : "built" , deps : [ tsserverlibraryDts ] } ) ] ) ;
283
+ gulp . task ( runJs , /*help*/ false , [ typescriptServicesJs , tsserverlibraryDts ] , ( ) => project . compile ( testRunnerProject , { typescript : "built" } ) ) ;
288
284
289
285
gulp . task (
290
286
"tests" ,
@@ -310,8 +306,8 @@ gulp.task(
310
306
311
307
const webTestServerProject = "tests/webTestServer.tsconfig.json" ;
312
308
const webTestServerJs = "tests/webTestServer.js" ;
313
- gulp . task ( webTestServerJs , /*help*/ false , [ project ( webTestServerProject , { typescript : "built" , release : { compilerOptions : { removeComments : true } } } ) ] )
314
- gulp . task ( "clean:" + webTestServerJs , /*help*/ false , [ project . clean ( webTestServerProject , { typescript : "built" } ) ] )
309
+ gulp . task ( webTestServerJs , /*help*/ false , [ typescriptServicesJs ] , ( ) => project . compile ( webTestServerProject , { typescript : "built" } ) ) ;
310
+ gulp . task ( "clean:" + webTestServerJs , /*help*/ false , ( ) => project . clean ( webTestServerProject ) ) ;
315
311
316
312
const bundlePath = path . resolve ( "built/local/bundle.js" ) ;
317
313
@@ -447,8 +443,8 @@ gulp.task(
447
443
// Webhost
448
444
const webtscProject = "tests/webhost/webtsc.tsconfig.json" ;
449
445
const webtscJs = "tests/webhost/webtsc.js" ;
450
- gulp . task ( webtscJs , /*help*/ false , [ project ( webtscProject , { typescript : "built" , release : { compilerOptions : { removeComments : true } } } ) ] ) ;
451
- gulp . task ( "clean:" + webtscJs , /*help*/ false , [ project . clean ( webtscProject , { typescript : "built" } ) ] ) ;
446
+ gulp . task ( webtscJs , /*help*/ false , [ typescriptServicesJs ] , ( ) => project . compile ( webtscProject , { typescript : "built" } ) ) ;
447
+ gulp . task ( "clean:" + webtscJs , /*help*/ false , ( ) => project . clean ( webtscProject ) ) ;
452
448
453
449
gulp . task ( "webhost" , "Builds the tsc web host" , [ webtscJs ] , ( ) =>
454
450
gulp . src ( "built/local/lib.d.ts" )
@@ -457,8 +453,8 @@ gulp.task("webhost", "Builds the tsc web host", [webtscJs], () =>
457
453
// Perf compiler
458
454
const perftscProject = "tests/perftsc.tsconfig.json" ;
459
455
const perftscJs = "built/local/perftsc.js" ;
460
- gulp . task ( perftscJs , /*help*/ false , [ project ( perftscProject , { typescript : "built" , release : { compilerOptions : { removeComments : true } } } ) ] ) ;
461
- gulp . task ( "clean:" + perftscJs , /*help*/ false , [ project . clean ( perftscProject , { typescript : "built" } ) ] ) ;
456
+ gulp . task ( perftscJs , /*help*/ false , [ typescriptServicesJs ] , ( ) => project . compile ( perftscProject , { typescript : "built" } ) ) ;
457
+ gulp . task ( "clean:" + perftscJs , /*help*/ false , ( ) => project . clean ( perftscProject ) ) ;
462
458
463
459
gulp . task (
464
460
"perftsc" ,
@@ -477,8 +473,8 @@ gulp.task(loggedIOJs, /*help*/ false, [], (done) => {
477
473
478
474
const instrumenterProject = "src/instrumenter/tsconfig.json" ;
479
475
const instrumenterJs = "built/local/instrumenter.js" ;
480
- gulp . task ( instrumenterJs , /*help*/ false , [ project ( instrumenterProject ) ] ) ;
481
- gulp . task ( "clean:" + instrumenterJs , /*help*/ false , [ project . clean ( instrumenterProject ) ] ) ;
476
+ gulp . task ( instrumenterJs , /*help*/ false , ( ) => project . compile ( instrumenterProject ) ) ;
477
+ gulp . task ( "clean:" + instrumenterJs , /*help*/ false , ( ) => project . clean ( instrumenterProject ) ) ;
482
478
483
479
gulp . task (
484
480
"tsc-instrumented" ,
@@ -497,9 +493,9 @@ gulp.task(
497
493
gulp . task (
498
494
"build-rules" ,
499
495
"Compiles tslint rules to js" ,
500
- [ project ( "scripts/tslint/tsconfig.json" ) ] ) ;
496
+ ( ) => project . compile ( "scripts/tslint/tsconfig.json" ) ) ;
501
497
502
- gulp . task ( "clean-rules" , /*help*/ false , [ project . clean ( "scripts/tslint/tsconfig.json" ) ] ) ;
498
+ gulp . task ( "clean-rules" , /*help*/ false , ( ) => project . clean ( "scripts/tslint/tsconfig.json" ) ) ;
503
499
504
500
gulp . task (
505
501
"lint" ,
0 commit comments