Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
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.
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);
});
tsconfig-paths is a package that helps in resolving and loading paths from tsconfig.json files for module resolution. Unlike tsconfck, which focuses more broadly on configuration loading and resolution, tsconfig-paths specifically targets path resolution to aid in module loading in non-TypeScript environments.
tsconfig-loader provides functionality to load tsconfig.json files without resolving the entire configuration. It's simpler than tsconfck as it does not handle the resolution of 'extends' or other complex configurations, focusing instead on direct loading of configurations as they are defined.
A utility to find and parse tsconfig files without depending on typescript
Because no simple official api exists and tsconfig.json isn't actual json.
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 that contributed to tsconfig
solution, // solution result if tsconfig is part of a solution
referenced // referenced tsconfig results if tsconfig is a solution
} = await parse('foo/bar.ts');
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
solution, // solution result if tsconfig is part of a solution
referenced // referenced tsconfig results if tsconfig is a solution
} = await parseNative('foo/bar.ts');
see API-DOCS
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;
};
A simple cli wrapper is included, you can use it like this
# prints /path/to/tsconfig.json on stdout
tsconfck find src/index.ts
# print content of ParseResult.tsconfig on stdout
tsconfck parse src/index.ts
# print to file
tsconfck parse src/index.ts > output.json
# print content of ParseResult on stdout
tsconfck parse-result src/index.ts
# print to file
tsconfck parse-result src/index.ts > output.json
# print usage
tsconfck -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
# install dependencies
pnpm install
# run tests
pnpm test
#run tests in watch mode (doesn't require dev in parallel)
pnpm test:watch
FAQs
A utility to work with tsconfig.json without typescript
The npm package tsconfck receives a total of 1,721,362 weekly downloads. As such, tsconfck popularity was classified as popular.
We found that tsconfck demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.