@@ -6,7 +6,12 @@ var path = require('path');
66
77var projectDir = hook . findProjectDir ( ) ;
88if ( projectDir ) {
9- createTsconfig ( ) ;
9+ var tsconfigPath = path . join ( projectDir , 'tsconfig.json' ) ;
10+ if ( fs . existsSync ( tsconfigPath ) ) {
11+ migrateTsconfig ( tsconfigPath ) ;
12+ } else {
13+ createTsconfig ( tsconfigPath ) ;
14+ }
1015 createReferenceFile ( ) ;
1116 installTypescript ( ) ;
1217}
@@ -20,8 +25,29 @@ function createReferenceFile() {
2025 }
2126}
2227
23- function createTsconfig ( ) {
24- var tsconfigPath = path . join ( projectDir , 'tsconfig.json' ) ;
28+ function migrateTsconfig ( tsconfigPath ) {
29+ var displaybleTsconfigPath = path . relative ( projectDir , tsconfigPath ) ;
30+
31+ try {
32+ var existingConfigContents = fs . readFileSync ( tsconfigPath ) ;
33+ var existingConfig = JSON . parse ( existingConfigContents ) ;
34+ } catch ( e ) {
35+ console . error ( "Invalid " + displaybleTsconfigPath + ": " + e ) ;
36+ return ;
37+ }
38+
39+ if ( existingConfig [ "compilerOptions" ] ) {
40+ if ( "sourceMap" in existingConfig [ "compilerOptions" ] ) {
41+ delete existingConfig [ "compilerOptions" ] [ "sourceMap" ] ;
42+ console . warn ( "> Deleted \"compilerOptions.sourceMap\" setting in \"" + displaybleTsconfigPath + "\"." ) ;
43+ console . warn ( "> Inline source maps will be used when building in Debug configuration from now on." ) ;
44+ }
45+ }
46+
47+ fs . writeFileSync ( tsconfigPath , JSON . stringify ( existingConfig , null , 4 ) ) ;
48+ }
49+
50+ function createTsconfig ( tsconfigPath ) {
2551 var tsconfig = { } ;
2652
2753 tsconfig . compilerOptions = {
@@ -35,9 +61,7 @@ function createTsconfig() {
3561
3662 tsconfig . exclude = [ 'node_modules' , 'platforms' , "**/*.aot.ts" ] ;
3763
38- if ( ! fs . existsSync ( tsconfigPath ) ) {
39- fs . appendFileSync ( tsconfigPath , JSON . stringify ( tsconfig , null , 4 ) ) ;
40- }
64+ fs . writeFileSync ( tsconfigPath , JSON . stringify ( tsconfig , null , 4 ) ) ;
4165}
4266
4367function getProjectTypeScriptVersion ( ) {
0 commit comments