Skip to content

Commit 59f1033

Browse files
committed
fix: don't ignore the tsconfig file name in project paths or path patterns
`getTsConfig` treats every path as a directory and looks for a `tsconfig.json` in the closest parent directory this breaks any configuration that uses file names other than tsconfig.json, as is convention for [solution-style](https://devblogs.microsoft.com/typescript/announcing-typescript-3-9/#solution-style-tsconfig) tsconfigs, which is exacerbated by the lack of support for the `references` field (see import-js#94)
1 parent 2ec7aaf commit 59f1033

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/index.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
Resolver,
1010
ResolverFactory,
1111
} from 'enhanced-resolve'
12-
import { createPathsMatcher, getTsconfig } from 'get-tsconfig'
12+
import { createPathsMatcher, getTsconfig, parseTsconfig } from 'get-tsconfig'
1313
import isCore from 'is-core-module'
1414
import isGlob from 'is-glob'
1515
import { createSyncFn } from 'synckit'
@@ -350,7 +350,10 @@ function initMappers(options: TsResolverOptions) {
350350
]
351351

352352
mappers = projectPaths.map(projectPath => {
353-
const tsconfigResult = getTsconfig(projectPath)
353+
const tsconfigResult =
354+
fs.existsSync(projectPath) && fs.statSync(projectPath).isFile()
355+
? { path: projectPath, config: parseTsconfig(projectPath) }
356+
: getTsconfig(projectPath)
354357
return tsconfigResult && createPathsMatcher(tsconfigResult)
355358
})
356359

0 commit comments

Comments
 (0)