8000 fix: use typescript api to parse tsconfig.json · fuse-box/fuse-box@4236a32 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Jun 20, 2023. It is now read-only.

Commit 4236a32

Browse files
vemoonchanged
authored andcommitted
fix: use typescript api to parse tsconfig.json
1 parent 3ecd5a4 commit 4236a32

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/core/TypescriptConfig.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { ensureUserPath, findFileBackwards } from "../Utils";
44
import { ScriptTarget } from "./File";
55
import * as fs from "fs";
66
import { Config } from "../Config";
7-
import * as json from 'comment-json';
7+
import * as ts from "typescript";
88

99
const CACHED: { [path: string]: any } = {};
1010

@@ -85,9 +85,14 @@ export class TypescriptConfig {
8585
}
8686
}
8787
if (configFile) {
88-
this.context.log.echoInfo(`Typescript config file: ${configFile.replace(this.context.appRoot, "")}`);
88+
const configFileRelPath = configFile.replace(this.context.appRoot, "");
89+
this.context.log.echoInfo(`Typescript config file: ${configFileRelPath}`);
8990
configFileFound = true;
90-
config = json.parse(fs.readFileSync(configFile).toString());
91+
const res = ts.readConfigFile(configFile, (p) => fs.readFileSync(p).toString());
92+
config = res.config;
93+
if (res.error) {
94+
this.context.log.echoError(`Errors in ${configFileRelPath}`);
95+
}
9196
}
9297

9398

0 commit comments

Comments
 (0)
0