Skip to content

Commit

Permalink
fix: don't ignore the tsconfig file name in project paths or path pat…
Browse files Browse the repository at this point in the history
…terns

`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)
  • Loading branch information
line0 committed Jul 6, 2022
1 parent 2ec7aaf commit 59f1033
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
Resolver,
ResolverFactory,
} from 'enhanced-resolve'
import { createPathsMatcher, getTsconfig } from 'get-tsconfig'
import { createPathsMatcher, getTsconfig, parseTsconfig } from 'get-tsconfig'
import isCore from 'is-core-module'
import isGlob from 'is-glob'
import { createSyncFn } from 'synckit'
Expand Down Expand Up @@ -350,7 +350,10 @@ function initMappers(options: TsResolverOptions) {
]

mappers = projectPaths.map(projectPath => {
const tsconfigResult = getTsconfig(projectPath)
const tsconfigResult =
fs.existsSync(projectPath) && fs.statSync(projectPath).isFile()
? { path: projectPath, config: parseTsconfig(projectPath) }
: getTsconfig(projectPath)
return tsconfigResult && createPathsMatcher(tsconfigResult)
})

Expand Down

0 comments on commit 59f1033

Please sign in to comment.