@@ -35,6 +35,7 @@ var compilerSources = [
35
35
"types.ts" ,
36
36
"scanner.ts" ,
37
37
"parser.ts" ,
38
+ "utilities.ts" ,
38
39
"binder.ts" ,
39
40
"checker.ts" ,
40
41
"emitter.ts" ,
@@ -47,26 +48,53 @@ var compilerSources = [
47
48
48
49
var servicesSources = [
49
50
"core.ts" ,
51
+ "sys.ts" ,
50
52
"types.ts" ,
51
53
"scanner.ts" ,
52
54
"parser.ts" ,
55
+ "utilities.ts" ,
53
56
"binder.ts" ,
54
57
"checker.ts" ,
55
- "emitter.ts"
58
+ "emitter.ts" ,
59
+ "diagnosticInformationMap.generated.ts"
56
60
] . map ( function ( f ) {
57
61
return path . join ( compilerDirectory , f ) ;
58
62
} ) . concat ( [
59
63
"breakpoints.ts" ,
64
+ "navigationBar.ts" ,
65
+ "outliningElementsCollector.ts" ,
60
66
"services.ts" ,
61
67
"shims.ts" ,
62
68
"signatureHelp.ts" ,
63
69
"utilities.ts" ,
64
- "navigationBar.ts" ,
65
- "outliningElementsCollector.ts"
70
+ "formatting/formatting.ts" ,
71
+ "formatting/formattingContext.ts" ,
72
+ "formatting/formattingRequestKind.ts" ,
73
+ "formatting/formattingScanner.ts" ,
74
+ "formatting/references.ts" ,
75
+ "formatting/rule.ts" ,
76
+ "formatting/ruleAction.ts" ,
77
+ "formatting/ruleDescriptor.ts" ,
78
+ "formatting/ruleFlag.ts" ,
79
+ "formatting/ruleOperation.ts" ,
80
+ "formatting/ruleOperationContext.ts" ,
81
+ "formatting/rules.ts" ,
82
+ "formatting/rulesMap.ts" ,
83
+ "formatting/rulesProvider.ts" ,
84
+ "formatting/smartIndenter.ts" ,
85
+ "formatting/tokenRange.ts"
66
86
] . map ( function ( f ) {
67
87
return path . join ( servicesDirectory , f ) ;
68
88
} ) ) ;
69
89
90
+ var definitionsRoots = [
91
+ "compiler/types.d.ts" ,
92
+ "compiler/scanner.d.ts" ,
93
+ "compiler/parser.d.ts" ,
94
+ "compiler/checker.d.ts" ,
95
+ "services/services.d.ts" ,
96
+ ] ;
97
+
70
98
var harnessSources = [
71
99
"harness.ts" ,
72
100
"sourceMapRecorder.ts" ,
@@ -148,25 +176,48 @@ var compilerFilename = "tsc.js";
148
176
* @param prefixes: a list of files to prepend to the target file
149
177
* @param useBuiltCompiler: true to use the built compiler, false to use the LKG
150
178
* @param noOutFile: true to compile without using --out
179
+ * @param generateDeclarations: true to compile using --declaration
180
+ * @param outDir: true to compile using --outDir
181
+ * @param keepComments: false to compile using --removeComments
182
+ * @param callback: a function to execute after the compilation process ends
151
183
*/
152
- function compileFile ( outFile , sources , prereqs , prefixes , useBuiltCompiler , noOutFile , generateDeclarations , callback ) {
184
+ function compileFile ( outFile , sources , prereqs , prefixes , useBuiltCompiler , noOutFile , generateDeclarations , outDir , keepComments , noResolve , callback ) {
153
185
file ( outFile , prereqs , function ( ) {
154
186
var dir = useBuiltCompiler ? builtLocalDirectory : LKGDirectory ;
155
- var options = "-removeComments --module commonjs -noImplicitAny " ;
187
+ var options = "--module commonjs -noImplicitAny" ;
188
+
189
+ if ( ! keepComments ) {
190
+ options += " -removeComments" ;
191
+ }
192
+
156
193
if ( generateDeclarations ) {
157
- options += "--declaration " ;
194
+ options += " --declaration" ;
158
195
}
159
196
160
197
if ( useDebugMode ) {
161
- options += "--preserveConstEnums " ;
198
+ options += " --preserveConstEnums" ;
199
+ }
200
+
201
+ if ( outDir ) {
202
+ options += " --outDir " + outDir ;
203
+ }
204
+
205
+ if ( ! noOutFile ) {
206
+ options += " --out " + outFile ;
207
+ }
208
+
209
+ if ( noResolve ) {
210
+ options += " --noResolve" ;
162
211
}
163
212
164
- var cmd = host + " " + dir + compilerFilename + " " + options + " " ;
165
- cmd = cmd + sources . join ( " " ) + ( ! noOutFile ? " -out " + outFile : "" ) ;
166
213
if ( useDebugMode ) {
167
- cmd = cmd + " -sourcemap -mapRoot file:///" + path . resolve ( path . dirname ( outFile ) ) ;
214
+ options += " -sourcemap -mapRoot file:///" + path . resolve ( path . dirname ( outFile ) ) ;
168
215
}
216
+
217
+ var cmd = host + " " + dir + compilerFilename + " " + options + " " ;
218
+ cmd = cmd + sources . join ( " " ) ;
169
219
console . log ( cmd + "\n" ) ;
220
+
170
221
var ex = jake . createExec ( [ cmd ] ) ;
171
222
// Add listeners for output and error
172
223
ex . addListener ( "stdout" , function ( output ) {
@@ -259,24 +310,38 @@ var tscFile = path.join(builtLocalDirectory, compilerFilename);
259
310
compileFile ( tscFile , compilerSources , [ builtLocalDirectory , copyright ] . concat ( compilerSources ) , [ copyright ] , /*useBuiltCompiler:*/ false ) ;
260
311
261
312
var servicesFile = path . join ( builtLocalDirectory , "typescriptServices.js" ) ;
262
- var servicesDefinitionsFile = path . join ( builtLocalDirectory , "typescriptServices.d.ts" ) ;
313
+ compileFile ( servicesFile , servicesSources , [ builtLocalDirectory , copyright ] . concat ( servicesSources ) , [ copyright ] , /*useBuiltCompiler*/ true ) ;
263
314
264
- compileFile ( servicesFile ,
265
- servicesSources ,
266
- [ builtLocalDirectory , copyright ] . concat ( servicesSources ) ,
267
- [ copyright ] ,
315
+ var nodeDefinitionsFile = path . join ( builtLocalDirectory , "typescript.d.ts" ) ;
316
+ var standaloneDefinitionsFile = path . join ( builtLocalDirectory , "typescriptServices.d.ts" ) ;
317
+ var tempDirPath = path . join ( builtLocalDirectory , "temptempdir" ) ;
318
+ compileFile ( nodeDefinitionsFile , servicesSources , [ builtLocalDirectory , copyright ] . concat ( servicesSources ) ,
319
+ /*prefixes*/ undefined ,
268
320
/*useBuiltCompiler*/ true ,
269
- /*noOutFile*/ false ,
321
+ /*noOutFile*/ true ,
270
322
/*generateDeclarations*/ true ,
271
- /*callback*/ fixDeclarationFile ) ;
272
-
273
- function fixDeclarationFile ( ) {
274
- fs . appendFileSync ( servicesDefinitionsFile , os . EOL + "export = ts;" )
275
- }
323
+ /*outDir*/ tempDirPath ,
324
+ /*keepComments*/ true ,
325
+ /*noResolve*/ true ,
326
+ /*callback*/ function ( ) {
327
+ concatenateFiles ( standaloneDefinitionsFile , definitionsRoots . map ( function ( f ) {
328
+ return path . join ( tempDirPath , f ) ;
329
+ } ) ) ;
330
+ prependFile ( copyright , standaloneDefinitionsFile ) ;
331
+
332
+ // Create the node definition file by replacing 'ts' module with '"typescript"' as a module.
333
+ jake . cpR ( standaloneDefinitionsFile , nodeDefinitionsFile , { silent : true } ) ;
334
+ var definitionFileContents = fs . readFileSync ( nodeDefinitionsFile ) . toString ( ) ;
335
+ definitionFileContents = definitionFileContents . replace ( / d e c l a r e m o d u l e t s / g, 'declare module "typescript"' ) ;
336
+ fs . writeFileSync ( nodeDefinitionsFile , definitionFileContents ) ;
337
+
338
+ // Delete the temp dir
339
+ jake . rmRf ( tempDirPath , { silent : true } ) ;
340
+ } ) ;
276
341
277
342
// Local target to build the compiler and services
278
343
desc ( "Builds the full compiler and services" ) ;
279
- task ( "local" , [ "generate-diagnostics" , "lib" , tscFile , servicesFile ] ) ;
344
+ task ( "local" , [ "generate-diagnostics" , "lib" , tscFile , servicesFile , nodeDefinitionsFile ] ) ;
280
345
281
346
// Local target to build the compiler and services
282
347
desc ( "Sets release mode flag" ) ;
@@ -327,7 +392,7 @@ task("generate-spec", [specMd])
327
392
// Makes a new LKG. This target does not build anything, but errors if not all the outputs are present in the built/local directory
328
393
desc ( "Makes a new LKG out of the built js files" ) ;
329
394
task ( "LKG" , [ "clean" , "release" , "local" ] . concat ( libraryTargets ) , function ( ) {
330
- var expectedFiles = [ tscFile , servicesFile , servicesDefinitionsFile ] . concat ( libraryTargets ) ;
395
+ var expectedFiles = [ tscFile , servicesFile , nodeDefinitionsFile , standaloneDefinitionsFile ] . concat ( libraryTargets ) ;
331
396
var missingFiles = expectedFiles . filter ( function ( f ) {
332
397
return ! fs . existsSync ( f ) ;
333
398
} ) ;
0 commit comments