Skip to content

Commit 6fd7bb3

Browse files
committed
Workaround boolean flags not available in TS 2.0
microsoft/TypeScript#11798
1 parent a4736e1 commit 6fd7bb3

File tree

2 files changed

+31
-11
lines changed

2 files changed

+31
-11
lines changed

lib/compiler.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,12 @@ function runTypeScriptCompiler(logger, projectDir, options) {
3030

3131
if (!options.release) {
3232
// For debugging in Chrome DevTools
33-
nodeArgs.push(
34-
'--sourceMap', 'false',
35-
'--inlineSourceMap', 'true',
36-
'--inlineSources', 'true'
37-
);
33+
nodeArgs.push('--inlineSourceMap', '--inlineSources');
3834
}
3935

36+
logger.trace(process.execPath, nodeArgs.join(' '));
4037
var tsc = spawn(process.execPath, nodeArgs);
38+
4139
var isResolved = false;
4240
tsc.stdout.on('data', function(data) {
4341
var stringData = data.toString();

postinstall.js

+28-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ var path = require('path');
66

77
var projectDir = hook.findProjectDir();
88
if (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,27 @@ function createReferenceFile() {
2025
}
2126
}
2227

23-
function createTsconfig() {
24-
var tsconfigPath = path.join(projectDir, 'tsconfig.json');
28+
function migrateTsconfig(tsconfigPath) {
29+
try {
30+
var existingConfigContents = fs.readFileSync(tsconfigPath);
31+
var existingConfig = JSON.parse(existingConfigContents);
32+
} catch (e) {
33+
console.error("Invalid " + tsconfigPath + ": " + e);
34+
return;
35+
}
36+
37+
if (existingConfig["compilerOptions"]) {
38+
if ("sourceMap" in existingConfig["compilerOptions"]) {
39+
delete existingConfig["compilerOptions"]["sourceMap"];
40+
console.warn("> Deleted \"compilerOptions.sourceMap\" setting in \"" + tsconfigPath + "\".");
41+
console.warn("> Inline source maps will be used when building in Debug configuration from now on.");
42+
}
43+
}
44+
45+
fs.writeFileSync(tsconfigPath, JSON.stringify(existingConfig, null, 4));
46+
}
47+
48+
function createTsconfig(tsconfigPath) {
2549
var tsconfig = {};
2650

2751
tsconfig.compilerOptions = {
@@ -35,9 +59,7 @@ function createTsconfig() {
3559

3660
tsconfig.exclude = ['node_modules', 'platforms', "**/*.aot.ts"];
3761

38-
if (!fs.existsSync(tsconfigPath)) {
39-
fs.appendFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 4));
40-
}
62+
fs.writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 4));
4163
}
4264

4365
function getProjectTypeScriptVersion() {

0 commit comments

Comments
 (0)