@@ -35,6 +35,7 @@ var compilerSources = [
3535 "types.ts" ,
3636 "scanner.ts" ,
3737 "parser.ts" ,
38+ "utilities.ts" ,
3839 "binder.ts" ,
3940 "checker.ts" ,
4041 "emitter.ts" ,
@@ -47,26 +48,53 @@ var compilerSources = [
4748
4849var servicesSources = [
4950 "core.ts" ,
51+ "sys.ts" ,
5052 "types.ts" ,
5153 "scanner.ts" ,
5254 "parser.ts" ,
55+ "utilities.ts" ,
5356 "binder.ts" ,
5457 "checker.ts" ,
55- "emitter.ts"
58+ "emitter.ts" ,
59+ "diagnosticInformationMap.generated.ts"
5660] . map ( function ( f ) {
5761 return path . join ( compilerDirectory , f ) ;
5862} ) . concat ( [
5963 "breakpoints.ts" ,
64+ "navigationBar.ts" ,
65+ "outliningElementsCollector.ts" ,
6066 "services.ts" ,
6167 "shims.ts" ,
6268 "signatureHelp.ts" ,
6369 "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"
6686] . map ( function ( f ) {
6787 return path . join ( servicesDirectory , f ) ;
6888} ) ) ;
6989
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+
7098var harnessSources = [
7199 "harness.ts" ,
72100 "sourceMapRecorder.ts" ,
@@ -149,25 +177,48 @@ var compilerFilename = "tsc.js";
149177 * @param prefixes: a list of files to prepend to the target file
150178 * @param useBuiltCompiler: true to use the built compiler, false to use the LKG
151179 * @param noOutFile: true to compile without using --out
180+ * @param generateDeclarations: true to compile using --declaration
181+ * @param outDir: true to compile using --outDir
182+ * @param keepComments: false to compile using --removeComments
183+ * @param callback: a function to execute after the compilation process ends
152184 */
153- function compileFile ( outFile , sources , prereqs , prefixes , useBuiltCompiler , noOutFile , generateDeclarations , callback ) {
185+ function compileFile ( outFile , sources , prereqs , prefixes , useBuiltCompiler , noOutFile , generateDeclarations , outDir , keepComments , noResolve , callback ) {
154186 file ( outFile , prereqs , function ( ) {
155187 var dir = useBuiltCompiler ? builtLocalDirectory : LKGDirectory ;
156- var options = "-removeComments --module commonjs -noImplicitAny " ;
188+ var options = "--module commonjs -noImplicitAny" ;
189+
190+ if ( ! keepComments ) {
191+ options += " -removeComments" ;
192+ }
193+
157194 if ( generateDeclarations ) {
158- options += "--declaration " ;
195+ options += " --declaration" ;
159196 }
160197
161198 if ( useDebugMode ) {
162- options += "--preserveConstEnums " ;
199+ options += " --preserveConstEnums" ;
200+ }
201+
202+ if ( outDir ) {
203+ options += " --outDir " + outDir ;
204+ }
205+
206+ if ( ! noOutFile ) {
207+ options += " --out " + outFile ;
208+ }
209+
210+ if ( noResolve ) {
211+ options += " --noResolve" ;
163212 }
164213
165- var cmd = host + " " + dir + compilerFilename + " " + options + " " ;
166- cmd = cmd + sources . join ( " " ) + ( ! noOutFile ? " -out " + outFile : "" ) ;
167214 if ( useDebugMode ) {
168- cmd = cmd + " -sourcemap -mapRoot file:///" + path . resolve ( path . dirname ( outFile ) ) ;
215+ options += " -sourcemap -mapRoot file:///" + path . resolve ( path . dirname ( outFile ) ) ;
169216 }
217+
218+ var cmd = host + " " + dir + compilerFilename + " " + options + " " ;
219+ cmd = cmd + sources . join ( " " ) ;
170220 console . log ( cmd + "\n" ) ;
221+
171222 var ex = jake . createExec ( [ cmd ] ) ;
172223 // Add listeners for output and error
173224 ex . addListener ( "stdout" , function ( output ) {
@@ -260,24 +311,38 @@ var tscFile = path.join(builtLocalDirectory, compilerFilename);
260311compileFile ( tscFile , compilerSources , [ builtLocalDirectory , copyright ] . concat ( compilerSources ) , [ copyright ] , /*useBuiltCompiler:*/ false ) ;
261312
262313var servicesFile = path . join ( builtLocalDirectory , "typescriptServices.js" ) ;
263- var servicesDefinitionsFile = path . join ( builtLocalDirectory , "typescriptServices.d.ts" ) ;
314+ compileFile ( servicesFile , servicesSources , [ builtLocalDirectory , copyright ] . concat ( servicesSources ) , [ copyright ] , /*useBuiltCompiler*/ true ) ;
264315
265- compileFile ( servicesFile ,
266- servicesSources ,
267- [ builtLocalDirectory , copyright ] . concat ( servicesSources ) ,
268- [ copyright ] ,
316+ var nodeDefinitionsFile = path . join ( builtLocalDirectory , "typescript.d.ts" ) ;
317+ var standaloneDefinitionsFile = path . join ( builtLocalDirectory , "typescriptServices.d.ts" ) ;
318+ var tempDirPath = path . join ( builtLocalDirectory , "temptempdir" ) ;
319+ compileFile ( nodeDefinitionsFile , servicesSources , [ builtLocalDirectory , copyright ] . concat ( servicesSources ) ,
320+ /*prefixes*/ undefined ,
269321 /*useBuiltCompiler*/ true ,
270- /*noOutFile*/ false ,
322+ /*noOutFile*/ true ,
271323 /*generateDeclarations*/ true ,
272- /*callback*/ fixDeclarationFile ) ;
273-
274- function fixDeclarationFile ( ) {
275- fs . appendFileSync ( servicesDefinitionsFile , os . EOL + "export = ts;" )
276- }
324+ /*outDir*/ tempDirPath ,
325+ /*keepComments*/ true ,
326+ /*noResolve*/ true ,
327+ /*callback*/ function ( ) {
328+ concatenateFiles ( standaloneDefinitionsFile , definitionsRoots . map ( function ( f ) {
329+ return path . join ( tempDirPath , f ) ;
330+ } ) ) ;
331+ prependFile ( copyright , standaloneDefinitionsFile ) ;
332+
333+ // Create the node definition file by replacing 'ts' module with '"typescript"' as a module.
334+ jake . cpR ( standaloneDefinitionsFile , nodeDefinitionsFile , { silent : true } ) ;
335+ var definitionFileContents = fs . readFileSync ( nodeDefinitionsFile ) . toString ( ) ;
336+ definitionFileContents = definitionFileContents . replace ( / d e c l a r e m o d u l e t s / g, 'declare module "typescript"' ) ;
337+ fs . writeFileSync ( nodeDefinitionsFile , definitionFileContents ) ;
338+
339+ // Delete the temp dir
340+ jake . rmRf ( tempDirPath , { silent : true } ) ;
341+ } ) ;
277342
278343// Local target to build the compiler and services
279344desc ( "Builds the full compiler and services" ) ;
280- task ( "local" , [ "generate-diagnostics" , "lib" , tscFile , servicesFile ] ) ;
345+ task ( "local" , [ "generate-diagnostics" , "lib" , tscFile , servicesFile , nodeDefinitionsFile ] ) ;
281346
282347// Local target to build the compiler and services
283348desc ( "Sets release mode flag" ) ;
@@ -328,7 +393,7 @@ task("generate-spec", [specMd])
328393// Makes a new LKG. This target does not build anything, but errors if not all the outputs are present in the built/local directory
329394desc ( "Makes a new LKG out of the built js files" ) ;
330395task ( "LKG" , [ "clean" , "release" , "local" ] . concat ( libraryTargets ) , function ( ) {
331- var expectedFiles = [ tscFile , servicesFile , servicesDefinitionsFile ] . concat ( libraryTargets ) ;
396+ var expectedFiles = [ tscFile , servicesFile , nodeDefinitionsFile , standaloneDefinitionsFile ] . concat ( libraryTargets ) ;
332397 var missingFiles = expectedFiles . filter ( function ( f ) {
333398 return ! fs . existsSync ( f ) ;
334399 } ) ;
0 commit comments