Gathering detailed insights and metrics for @nanobundle/tsconfck
Gathering detailed insights and metrics for @nanobundle/tsconfck
Gathering detailed insights and metrics for @nanobundle/tsconfck
Gathering detailed insights and metrics for @nanobundle/tsconfck
A utility to find and parse tsconfig files without depending on typescript
npm install @nanobundle/tsconfck
Typescript
Module System
Min. Node Version
73.6
Supply Chain
99
Quality
75.1
Maintenance
100
Vulnerability
99.6
License
tsconfck@3.1.6
Updated on May 20, 2025
tsconfck@3.1.5
Updated on Feb 06, 2025
tsconfck@3.1.4
Updated on Oct 10, 2024
tsconfck@3.1.3
Updated on Aug 31, 2024
tsconfck@3.1.2
Updated on Aug 31, 2024
tsconfck@3.1.1
Updated on Jun 27, 2024
JavaScript (100%)
Total Downloads
515
Last Day
2
Last Week
4
Last Month
13
Last Year
113
NOASSERTION License
316 Stars
265 Commits
15 Forks
2 Watchers
6 Branches
11 Contributors
Updated on Aug 23, 2025
Latest Version
2.0.1-fix.73-2
Package Id
@nanobundle/tsconfck@2.0.1-fix.73-2
Unpacked Size
347.23 kB
Size
102.02 kB
File Count
23
Published on
Oct 10, 2023
Cumulative downloads
Total Downloads
Last Day
100%
2
Compared to previous day
Last Week
33.3%
4
Compared to previous week
Last Month
160%
13
Compared to previous month
Last Year
-41.8%
113
Compared to previous year
1
30
A utility to find and parse tsconfig files without depending on typescript
[!NOTE] This fork is intended to quickly deliver some patches that nanobundle relies on and no longer used.
Because no simple official api exists and tsconfig.json isn't actual json.
1npm install --save-dev tsconfck # or pnpm, yarn
1import { parse } from 'tsconfck'; 2const { 3 tsconfigFile, // full path to found tsconfig 4 tsconfig, // tsconfig object including merged values from extended configs 5 extended, // separate unmerged results of all tsconfig files that contributed to tsconfig 6 solution, // solution result if tsconfig is part of a solution 7 referenced // referenced tsconfig results if tsconfig is a solution 8} = await parse('foo/bar.ts');
1import { parseNative } from 'tsconfck'; 2const { 3 tsconfigFile, // full path to found tsconfig 4 tsconfig, // tsconfig object including merged values from extended configs, normalized 5 result, // output of ts.parseJsonConfigFileContent 6 solution, // solution result if tsconfig is part of a solution 7 referenced // referenced tsconfig results if tsconfig is a solution 8} = await parseNative('foo/bar.ts');
see API-DOCS
You can use a map to cache results and avoid reparsing if you process multiple ts files that share few tsconfig files
1import { parse } from 'tsconfck'; 2// 1. create cache instance 3const cache = new Map(); 4// 2. pass cache instance in options 5const fooResult = await parse('src/foo.ts', { cache }); 6// 3. profit (if they share the same tsconfig.json, it is not parsed again) 7const barResult = await parse('src/bar.ts', { cache });
You are responsible for clearing the cache if tsconfig files change on disk during its lifetime.
Always clear the whole cache if anything changes as objects in the cache can ref each other
Returned results are direct cache objects.
If you want to modify them, deep-clone first.
You can specify a root directory and provide a set of known tsconfig locations to improve performance in large projects
1import { parse, findAll } from 'tsconfck'; 2const root = '.'; 3const tsConfigPaths = new Set([ 4 ...(await findAll(root, { skip: (dir) => dir === 'node_modules' || dir === '.git' })) 5]); 6const cache = new Map(); 7const parseOptions = { cache, root, tsConfigPaths }; 8// these calls use minimal fs 9const fooResult = await parse('src/foo.ts', parseOptions); 10const barResult = await parse('src/bar.ts', parseOptions);
Using the root option can lead to errors if there is no tsconfig inside root.
You are responsible for updating tsConfigPaths if tsconfig files are added/removed on disk during its lifetime.
find and parse reject for all errors they encounter.
For parse, you can choose to resolve with an empty result instead if no tsconfig file was found
1import { parse } from 'tsconfck'; 2const result = await parse('some/path/without/tsconfig/foo.ts', { 3 resolveWithEmptyIfConfigNotFound: true 4}); 5// result = { tsconfigFile: 'no_tsconfig_file_found',tsconfig: {} }
1import type { TSConfig } from 'pkg-types';
Check out https://github.com/unjs/pkg-types
A simple cli wrapper is included, you can use it like this
1# prints /path/to/tsconfig.json on stdout 2tsconfck find src/index.ts
1# prints all tsconfig.json in dir on stdout 2tsconfck find-all src/
1# print content of ParseResult.tsconfig on stdout 2tsconfck parse src/index.ts 3 4# print to file 5tsconfck parse src/index.ts > output.json
1# print content of ParseResult on stdout 2tsconfck parse-result src/index.ts 3 4# print to file 5tsconfck parse-result src/index.ts > output.json
1# print usage 2tsconfck -h # or --help, -?, help
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
1# install dependencies 2pnpm install 3# run tests 4pnpm test 5#run tests in watch mode (doesn't require dev in parallel) 6pnpm test:watch
No vulnerabilities found.