dominikg / tsconfck

A utility to find and parse tsconfig files without depending on typescript
Other
290 stars 14 forks source link

[Feature Request] Add a few API for `eslint-import-resolver-typescript` and `eslint-plugin-import-x` to migrate to `tsconfck` #183

Open SukkaW opened 1 month ago

SukkaW commented 1 month ago

Describe the feature

I recently became the co-maintainer of the eslint-import-resolver-typescript and the eslint-plugin-import-x projects, and I am working on replacing get-tsconfig w/ tsconfck. I have faced a few difficulties in implementing that because of the lack of the following features:

A Usecase

ESLint rules are synchronous, so we need a synchronous API to get the tsconfig file.

We also need a resolver that implements a module resolver interface that implements the TypeScript resolving algorithm (https://github.com/microsoft/TypeScript/blob/3ccbe804f850f40d228d3c875be952d94d39aa1d/src/compiler/moduleNameResolver.ts#L2465):

Alternatives

I could use libraries like synckit to force convert async API to sync, but it is less ideal.

As for the matcher/resolver, I could copy codes from vite-tsconfig-paths, which IMHO is also not ideal.

Additional context

dominikg commented 1 month ago

from your requirements it reads like get-tsconfig is a pretty good fit. What makes you consider tsconfck as a replacement?

see https://github.com/dominikg/tsconfck/issues/31 and https://github.com/dominikg/tsconfck/discussions/18 for previous discussions around sync apis.

SukkaW commented 1 month ago

from your requirements it reads like get-tsconfig is a pretty good fit. What makes you consider tsconfck as a replacement?

Mostly the sheer difficulties of contributing to get-tsconfig. I've tried to add ${configDir} support for get-tsconfig, but I can't even get its existing test cases to pass after upgrading to TypeScript 5.5. On the other hand, tsconfck already has full ${configDir} support.

dominikg commented 1 month ago

it might still be easier to add support for that in get-tsconfig (a little surprised it isn't supported yet) than bringing sync support to tsconfck.

There is an old branch linked in the Discussion above but from what i remember it wasn't easy to have a single codebase that supports sync and async. And it probably got worse since then because of the changes around the cache.

Happy to look into contributions that add sync support, but afraid that would require a major refactor to ensure keeping it lean and without duplicated logic.

For the features around implementing a resolver or paths matcher, it is more difficult to justify adding them to tsconfck. I think they would better live in separate packages and shared between get-tsconfig, vite-tsconfig-paths etc.

tsconfck focus is

A utility to find and parse tsconfig files without depending on typescript

what to do with the output is out of it's scope.