Socket
Socket
Sign inDemoInstall

tsconfck

Package Overview
Dependencies
3
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    tsconfck

A utility to work with tsconfig.json without typescript


Version published
Weekly downloads
1.9M
decreased by-15.91%
Maintainers
1
Install size
107 kB
Created
Weekly downloads
 

Package description

What is tsconfck?

The tsconfck package is a utility for TypeScript configuration management. It helps in resolving and loading TypeScript configuration files (tsconfig.json) by handling inheritance and references within these configurations. This is particularly useful in complex projects where tsconfig settings are split across multiple files or extended from other configurations.

What are tsconfck's main functionalities?

Load and resolve tsconfig.json

This feature allows loading a tsconfig.json file, resolving all its extends and references to provide a final resolved configuration object. It handles the asynchronous nature of file reading and parsing, providing a promise-based API.

const { loadTsconfig } = require('tsconfck');

loadTsconfig('path/to/tsconfig.json').then(tsconfig => {
  console.log(tsconfig);
}).catch(error => {
  console.error(error);
});

Other packages similar to tsconfck

Readme

Source

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

  • find closest tsconfig.json
  • convert tsconfig.json to actual json and parse it
  • resolve "extends"
  • optional findNative and parseNative to use official typescript api

Usage

without typescript installed

import { parse } from 'tsconfck';
const {
	filename, // full path to found tsconfig
	tsconfig, // tsconfig object including merged values from extended configs
	extended // separate unmerged results of all tsconfig files
} = await parse('foo/bar.ts');

with typescript

import { parseNative } from 'tsconfck';
const {
	filename, // full path to found tsconfig
	tsconfig, // tsconfig object including merged values from extended configs
	result // output of ts.parseJsonConfigFileContent
} = 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;
};
  • changelog

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

Keywords

FAQs

Last updated on 26 Aug 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc