Skip to content

Commit 462555d

Browse files
committed
fix: tsconfig.json can have comments
Fixes #7.
1 parent 0955bb7 commit 462555d

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { join } from 'path';
22
import { Plugin } from 'rollup';
3-
import { CompilerOptions, findConfigFile, nodeModuleNameResolver, sys } from 'typescript';
3+
import { CompilerOptions, findConfigFile, nodeModuleNameResolver, parseConfigFileTextToJson, sys } from 'typescript';
44

55
export const typescriptPaths = ({
66
tsConfigPath = findConfigFile('./', sys.fileExists),
@@ -62,7 +62,7 @@ const getTsConfig = (configPath?: string): TsConfig => {
6262
return defaults;
6363
}
6464

65-
const config: Partial<TsConfig> = JSON.parse(configJson);
65+
const { config } = parseConfigFileTextToJson(configPath, configJson);
6666

6767
return { ...defaults, ...config };
6868
};

test/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
// comments should work
23
"compilerOptions": {
34
"baseUrl": "test",
45
"paths": {

0 commit comments

Comments
 (0)