Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

cosmiconfig-typescript-loader

Codex-13.6mMIT6.1.0TypeScript support: included

TypeScript loader for cosmiconfig

cosmiconfig, typescript

readme

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

Synchronously loading

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:

  • #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""

changelog

Changelog

All notable changes to this project will be documented in this file. Dates are displayed in UTC.

Generated by auto-changelog.

6.0.0

  • chore(deps): lock file maintenance #151
  • chore(deps): update all non-major dependencies #150
  • Upgrade to Jiti 2 #149
  • chore(deps): update dependency eslint to v9 #134
  • Migrate to pnpm and asdf-vm #148
  • cicd: Use pnpm and asdf-vm 22fc584
  • fix: missed npx commands, moved to pnpm exec 0056629
  • chore(deps): update remaining eslint packages e56943e

5.1.0

19 October 2024

  • chore(deps): lock file maintenance #138
  • build(deps-dev): bump braces from 3.0.2 to 3.0.3 #135
  • chore(deps): update dependency eslint-config-airbnb-typescript to v18 #128
  • chore(deps): update codecov/codecov-action action to v4 #126
  • chore(deps): update all non-major dependencies #125
  • build(deps-dev): bump ip from 1.1.8 to 1.1.9 #124
  • chore(deps): update actions/setup-node action to v4 #117
  • build(deps-dev): bump @babel/traverse from 7.23.0 to 7.23.2 #115
  • chore(deps): update actions/checkout action to v4 #114
  • chore(deps): update all non-major dependencies #108
  • chore(deps): update dependency prettier to v3 #110
  • chore(deps): update dependency release-it to v17 018f59d
  • chore(deps): update dependency @typescript-eslint/eslint-plugin to v6 4b609ec
  • chore(deps): update dependency @typescript-eslint/eslint-plugin to v7 50d8917

5.0.0

25 July 2023

  • Add ESM support and change to jiti #106
  • feat(jiti): Move away from ts-node, use jiti 56f9e65
  • feat(esm): Generate esm sources and support import c879324
  • feat(esm): Require cosmiconfig 8 and node 16 ca6e2da

4.4.0

25 July 2023

  • chore(deps): update all non-major dependencies #107
  • build(deps-dev): bump word-wrap from 1.2.3 to 1.2.4 #104
  • build(deps): bump vm2 from 3.9.17 to 3.9.18 #94
  • build(deps): bump vm2 from 3.9.16 to 3.9.17 #92
  • build(deps): bump vm2 from 3.9.15 to 3.9.16 #91
  • build(deps): bump vm2 from 3.9.14 to 3.9.15 #90
  • Revert to jest #83
  • build(deps): bump cacheable-request from 10.2.5 to 10.2.7 #81
  • chore(deps): lock file maintenance #72
  • chore(deps): update vitest monorepo to ^0.28.0 #71
  • test: rever to jest to test cjs/require things 26e9bf4
  • chore(deps): update dependency esbuild to ^0.17.0 7a951f4
  • test: use @swc instead of ts-jest 8058bac

4.3.0

11 December 2022

  • chore(deps): lock file maintenance #58
  • chore(deps): bump root dependencies in package. 6e18a83
  • chore(deps): update dependency esbuild to ^0.16.0 82da489
  • chore(deps): update vitest monorepo to ^0.25.0 37a3004

4.2.0

31 October 2022

  • test: convert tests to use vitest. c70ee5e
  • chore(deps): lock file maintenance ff0bc14
  • chore(deps): lock file maintenance 0249b27

4.1.1

28 September 2022

  • build(deps): bump vm2 from 3.9.9 to 3.9.11 #49
  • renovate: enable automerge 92b87a9
  • Release 4.1.1 6cff60a
  • cicd: set minor as default release. 5d9559a

4.1.0

15 September 2022

  • chore(deps): update jest monorepo to v29 (major) #48
  • Configure Renovate #44
  • build(deps-dev): bump eslint from 8.22.0 to 8.23.0 #40
  • chore(deps): bump dependencies. b19da1a
  • chore(deps): update jest monorepo to v29 a8e1d57
  • cicd: use renovate instead of dependabot. c7ca9dc

4.0.0

26 August 2022

  • replace default export with a named export #37
  • test: Add simple pass log, handle the unhandled rejection case. d855daa
  • proof that exports are broken 8a57e3e
  • docs: Rearrange, the old package notice can slowly move on. 242d85f

3.1.2

26 August 2022

  • build(deps-dev): bump eslint from 8.20.0 to 8.21.0 #35
  • build(deps): bump codecov/codecov-action from 2 to 3 #34
  • build(deps): bump actions/setup-node from 2 to 3 #33
  • build(deps): bump actions/checkout from 2 to 3 #32
  • chore: bump dependencies b0f4bc4
  • Release 3.1.2 9938cb4
  • cicd: add action checking to dependabot. 05ee156

3.1.1

29 July 2022

3.1.0

29 July 2022

  • build(deps): bump parse-url from 6.0.0 to 6.0.2 #31
  • build(deps-dev): bump eslint-plugin-prettier from 4.1.0 to 4.2.1 #30
  • build(deps-dev): bump @typescript-eslint/eslint-plugin from 5.29.0 to 5.30.0 #29
  • build(deps-dev): bump eslint-plugin-prettier from 4.0.0 to 4.1.0 #28
  • build(deps-dev): bump release-it from 15.1.0 to 15.1.1 #27
  • chore: bump dependencies e0d5b2d
  • build: Change to use esbuild. 7688e32
  • build(deps-dev): bump @typescript-eslint/eslint-plugin 482f333

3.0.0

26 June 2022

  • build: Emit both cjs and esm. c82787d
  • build: move ts-node to peer dependencies. 1c82fda
  • chore: Remove deprecated method. 079cf2b

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

2.0.1

28 May 2022

  • build(deps-dev): bump release-it from 14.14.2 to 15.0.0 #25
  • chore: bump dependencies a4e62ce
  • build: improve how the tsconfig is handled for builds to better handle test ts checking. 6bb8618
  • Release 2.0.1 a5d9bef

2.0.0

29 April 2022

  • Update loader.ts #24
  • chore: bump dependencies c049172
  • chore: Add tests to confirm the number of calls ro register f0e7dd0
  • Release 2.0.0 48db861

1.0.9

4 April 2022

1.0.8

4 April 2022

1.0.7

3 April 2022

  • build(deps): bump minimist from 1.2.5 to 1.2.6 #23
  • build(deps-dev): bump eslint from 8.10.0 to 8.12.0 #22
  • build(deps-dev): bump release-it from 14.12.5 to 14.14.0 #21
  • build(deps): bump ts-node from 10.6.0 to 10.7.0 #20
  • build(deps-dev): bump ts-jest from 27.1.3 to 27.1.4 #19
  • build(deps-dev): bump prettier from 2.6.1 to 2.6.2 #18
  • build(deps-dev): bump eslint-config-prettier from 8.4.0 to 8.5.0 #17
  • build(deps-dev): bump @typescript-eslint/eslint-plugin from 5.13.0 to 5.17.0 #16
  • build(deps-dev): bump prettier from 2.5.1 to 2.6.1 #15
  • build(deps-dev): bump eslint-config-airbnb-typescript from 16.1.0 to 16.2.0 #14
  • build(deps-dev): bump typescript from 4.6.2 to 4.6.3 #13
  • build(deps-dev): bump @typescript-eslint/eslint-plugin dba4512
  • Release 1.0.7 2e04338
  • build(deps-dev): bump eslint-config-airbnb-typescript a8b2134

1.0.6

1 March 2022

  • chore: bump dependencies 7810d0d
  • Release 1.0.6 2d2bc6f
  • repo: remove extraneous install of npm 8. 4ef1bd3

1.0.5

10 February 2022

1.0.4

24 January 2022

1.0.3

4 January 2022

1.0.2

22 December 2021

1.0.1

12 December 2021

1.0.0

30 November 2021

0.0.9

30 November 2021

  • Release 0.0.9 67ac475
  • fix: releases now use whole git history for changelog generation 66638c3

0.0.8

30 November 2021

  • Release 0.0.8 342a5ff
  • repo: Restore changelog and add repo details 8b8b051
  • ide: add recommended extensions list a22a6e8

0.0.7

30 November 2021

  • Release 0.0.7 a02f945
  • cicd: Perform codecov submission after release version bump 55cdfa5

0.0.6

30 November 2021

0.0.5

30 November 2021

0.0.4

30 November 2021

  • Enable testing, linting, style, on release. f74f985
  • Release 0.0.4 4d6b7d6
  • Configure release git user 5ddd76b

0.0.3

30 November 2021

0.0.2

30 November 2021