Socket
Socket
Sign inDemoInstall

cosmiconfig-typescript-loader

Package Overview
Dependencies
2
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

cosmiconfig-typescript-loader


Version published
Maintainers
1
Install size
2.71 MB
Created

Package description

What is cosmiconfig-typescript-loader?

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.

What are cosmiconfig-typescript-loader's main functionalities?

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);
});

Other packages similar to cosmiconfig-typescript-loader

Changelog

Source

2.0.2

22 June 2022

  • build(deps-dev): bump @typescript-eslint/eslint-plugin from 5.26.0 to 5.27.0 #26
  • chore: bump dependencies 960e54b
  • build(deps-dev): bump @typescript-eslint/eslint-plugin 1703811
  • Release 2.0.2 431cf71

Readme

Source

cosmiconfig-typescript-loader

⚙️🚀 TypeScript config file support for cosmiconfig

build codecov npm

@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:

  • #134: "Doesn't work with Cosmiconfig sync API"
  • #147: "doesn't provide typescript, requested by ts-node"
  • #155: "Misleading TypeScriptCompileError when user's tsconfig.json "module" is set to "es2015""

Usage

Simply add TypeScriptLoader to the list of loaders for the .ts file type:

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 = 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 = explorer.load("./amazing.config.ts");

Keywords

FAQs

Last updated on 22 Jun 2022

Did you know?

Socket

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