Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
cosmiconfig-typescript-loader
Advanced tools
The cosmiconfig-typescript-loader package is designed to enable the loading of TypeScript files by cosmiconfig, a library used for finding and loading configuration files for Node.js projects. This loader allows cosmiconfig to read and parse configurations written in TypeScript, providing a seamless integration for projects that prefer TypeScript for configuration.
Loading TypeScript configuration files
This feature allows cosmiconfig to load and parse TypeScript files as configuration files. The code sample demonstrates how to configure cosmiconfig to use the cosmiconfig-typescript-loader for '.ts' files, enabling the loading of TypeScript configurations.
const { cosmiconfig } = require('cosmiconfig');
const { cosmiconfigTypescriptLoader } = require('cosmiconfig-typescript-loader');
const explorer = cosmiconfig('yourModuleName', {
searchPlaces: ['config.ts', 'otherConfig.ts'],
loaders: {
'.ts': cosmiconfigTypescriptLoader
}
});
explorer.search().then((result) => {
console.log(result.config);
});
ts-node is a TypeScript execution engine and REPL for Node.js. It allows Node.js to execute TypeScript directly without precompilation. While ts-node is not specifically a configuration loader, it enables the execution of TypeScript files, which can indirectly support loading configurations written in TypeScript. Compared to cosmiconfig-typescript-loader, ts-node offers a broader scope of functionality beyond just configuration loading.
typescript-json-schema generates JSON schemas from TypeScript types. This tool is useful for validating configuration objects against a schema defined in TypeScript. While it does not load configuration files directly, it complements the process by ensuring that loaded configurations adhere to a predefined schema. Compared to cosmiconfig-typescript-loader, typescript-json-schema focuses on validation rather than loading.
⚙️🚀 TypeScript config file support for cosmiconfig
Simply add TypeScriptLoader
to the list of loaders for the .ts
file type, and await
loading:
import { cosmiconfig } from "cosmiconfig";
import { TypeScriptLoader } from "cosmiconfig-typescript-loader";
const moduleName = "module";
const explorer = cosmiconfig("test", {
searchPlaces: [
"package.json",
`.${moduleName}rc`,
`.${moduleName}rc.json`,
`.${moduleName}rc.yaml`,
`.${moduleName}rc.yml`,
`.${moduleName}rc.js`,
`.${moduleName}rc.ts`,
`.${moduleName}rc.cjs`,
`${moduleName}.config.js`,
`${moduleName}.config.ts`,
`${moduleName}.config.cjs`,
],
loaders: {
".ts": TypeScriptLoader(),
},
});
const cfg = await explorer.load("./");
Or more simply if you only support loading of a TypeScript based configuration file:
import { cosmiconfig } from "cosmiconfig";
import { TypeScriptLoader } from "cosmiconfig-typescript-loader";
const moduleName = "module";
const explorer = cosmiconfig("test", {
loaders: {
".ts": TypeScriptLoader(),
},
});
const cfg = await explorer.load("./amazing.config.ts");
With the release of Jiti 2, the synchronous loader has now been deprecated. It can still be used by using the TypeScriptLoaderSync
export:
import { cosmiconfig } from "cosmiconfig";
import { TypeScriptLoaderSync } from "cosmiconfig-typescript-loader";
const moduleName = "module";
const explorer = cosmiconfig("test", {
loaders: {
".ts": TypeScriptLoaderSync(),
},
});
const cfg = explorer.load("./amazing.config.ts");
@endemolshinegroup/cosmiconfig-typescript-loader
This package serves as a drop in replacement for @endemolshinegroup/cosmiconfig-typescript-loader
. At the time of publishing this, endemolshinegroup
is not maintaining the original package. I can only assume this is to do with the fact that Endemol Shine Group was purchased and absorbed by another business. This discontinuation of development efforts towards the original package left any open issues and pull requests unresolved.
This new package resolves the following original issues:
#151
#150
#149
#134
#148
22fc584
0056629
e56943e
FAQs
TypeScript loader for cosmiconfig
The npm package cosmiconfig-typescript-loader receives a total of 3,720,008 weekly downloads. As such, cosmiconfig-typescript-loader popularity was classified as popular.
We found that cosmiconfig-typescript-loader demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.