Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
tsconfig-resolver
Advanced tools
[![GitHub Actions Build Status](https://github.com/ifiokjr/tsconfig-resolver/workflows/Node%20CI/badge.svg)](https://github.com/ifiokjr/tsconfig-resolver/actions?query=workflow%3A%22Node+CI%22) [![Version][version]][npm] [![Weekly Downloads][downloads-bad
A tool for loading the nearest tsconfig file in the same way the TypeScript compiler does. It walks up the directory tree until it finds the first matching tsconfig.json
file.
tsconfig-resolver
is designed to be used inside your node project.
First, install the plugin and it's peer dependencies:
npm install --save tsconfig-resolver
or
yarn add tsconfig-resolver
The following will load the first tsconfig.json
file working upwards from the process.cwd()
of the running node process.
import { tsconfigResolver } from 'tsconfig-resolver';
const result = tsconfigResolver();
// without type narrowing
console.log(result?.config);
// with type narrowing
if (result.exists) {
console.log(result.config);
}
Configuration options can also be passed into the export function.
import { tsconfigResolver, CacheStrategy } from 'tsconfig-resolver';
import { join } from 'path';
const result = tsconfig({
cwd: join(__dirname, 'src'),
fileName: 'tsconfig.prod.json',
cacheStrategy: CacheStrategy.Directory,
});
tsconfigResolver
import { tsconfigResolver } from 'tsconfig-resolver';
Property | Type | Default | Description |
---|---|---|---|
cwd | string | process.cwd() | The directory to start searching from |
fileName | string | 'tsconfig.json' | Set the file name of the config file to search for. |
cacheStrategy | string | CacheStrategy.Never | Set the caching strategy that will be used when searching for a file that's already been found. See |
CacheStrategy
import { CacheStrategy } from 'tsconfig-resolver';
Provides the available caching strategies that can be used.
Sometimes you'll want to run this module several times during runtime but it can be slow and expensive walk up the file tree for the tsconfig value every time.
To help prevent unnecessary lookups there are custom caching strategies available.
CacheStrategy.Never
- Caching never happens and the returned value is always recalculatedCacheStrategy.Always
- The first time the tsconfigResolver
method is run it will save a cached value (by fileName
) which will be returned every time after that. This value will always be the same.CacheStrategy.Directory
- The cache will be used when the same directory (and fileName
) is being searched.clearCache
Clears the cache.
import { tsconfigResolver, clearCache } from 'tsconfig-resolver';
const result = tsconfigResolver();
// Now clear the cache.
clearCache();
Dive into the codebase with Gitpod.
This project uses SemVer for versioning. For the versions available, see the tags on this repository.
This project is licensed under the MIT License - see the LICENSE file for details
FAQs
Walk up the tree to resolve `tsconfig.json` configuration objects.
The npm package tsconfig-resolver receives a total of 12,642 weekly downloads. As such, tsconfig-resolver popularity was classified as popular.
We found that tsconfig-resolver demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.