cosmiconfig-typescript-loader
TypeScript icon, indicating that this package has built-in type declarations

5.0.0 • Public • Published

cosmiconfig-typescript-loader

⚙️🚀 TypeScript config file support for cosmiconfig

build codecov npm

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

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

Readme

Keywords

Package Sidebar

Install

npm i cosmiconfig-typescript-loader

Weekly Downloads

3,479,074

Version

5.0.0

License

MIT

Unpacked Size

12.6 kB

Total Files

12

Last publish

Collaborators

  • codex-