tsconfck
A utility to find and parse tsconfig files without depending on typescript
Why
Because no simple official api exists and tsconfig.json isn't actual json.
Features
Usage
without typescript installed
import { parse } from 'tsconfck';
const {
filename,
tsconfig,
extended
} = await parse('foo/bar.ts');
with typescript
import { parseNative } from 'tsconfck';
const {
filename,
tsconfig,
result
} = await parseNative('foo/bar.ts');
Advanced
caching
You should cache results to avoid reparsing if you process multiple ts files that share few tsconfig files
import { find, parse } from 'tsconfck';
const cache = new Map();
const cachedParse = async (filename) => {
const tsconfigFile = find(filename);
if (cache.has(tsconfigFile)) {
return cache.get(tsconfigFile);
}
const parseResult = parse(tsconfigFile);
cache.put(tsconfigFile, parseResult);
return parseResult;
};
Links
Develop
This repo uses
In addition to default commit-msg prefixes you can use 'wip: ' for commit messages in branches.
PRs are going to be squash-merged
# install dependencies
pnpm install
# run tests
pnpm test
#run tests in watch mode (doesn't require dev in parallel)
pnpm test:watch