Skip to content

Commit c56d639

Browse files
committed
Add basic documentation
1 parent c564d96 commit c56d639

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

README.md

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# cosmiconfig-typescript-loader
2+
3+
> ⚙️🚀 TypeScript config file support for cosmiconfig
4+
5+
## `@endemolshinegroup/cosmiconfig-typescript-loader`
6+
7+
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](https://en.wikipedia.org/wiki/Endemol_Shine_Group#Sale_to_Banijay). This discontinuation of development efforts towards the original package left any open issues and pull requests unresolved.
8+
9+
This new package resolves the following original issues:
10+
11+
- [`#134`](https://github.com/EndemolShineGroup/cosmiconfig-typescript-loader/issues/134): "Doesn't work with Cosmiconfig sync API"
12+
- [`#147`](https://github.com/EndemolShineGroup/cosmiconfig-typescript-loader/issues/147): "doesn't provide typescript, requested by ts-node"
13+
- [`#155`](https://github.com/EndemolShineGroup/cosmiconfig-typescript-loader/issues/155): "Misleading TypeScriptCompileError when user's tsconfig.json "module" is set to "es2015""
14+
15+
## Usage
16+
17+
Simply add `TypeScriptLoader` to the list of loaders for the `.ts` file type:
18+
19+
```ts
20+
import { cosmiconfig } from "cosmiconfig";
21+
import TypeScriptLoader from "cosmiconfig-typescript-loader";
22+
23+
const moduleName = "module";
24+
const explorer = cosmiconfig("test", {
25+
searchPlaces: [
26+
"package.json",
27+
`.${moduleName}rc`,
28+
`.${moduleName}rc.json`,
29+
`.${moduleName}rc.yaml`,
30+
`.${moduleName}rc.yml`,
31+
`.${moduleName}rc.js`,
32+
`.${moduleName}rc.ts`,
33+
`.${moduleName}rc.cjs`,
34+
`${moduleName}.config.js`,
35+
`${moduleName}.config.ts`,
36+
`${moduleName}.config.cjs`,
37+
],
38+
loaders: {
39+
".ts": TypeScriptLoader(),
40+
},
41+
});
42+
43+
const cfg = explorer.load("./");
44+
```
45+
46+
Or more simply if you only support loading of a TypeScript based configuration file:
47+
48+
```ts
49+
import { cosmiconfig } from "cosmiconfig";
50+
import TypeScriptLoader from "cosmiconfig-typescript-loader";
51+
52+
const moduleName = "module";
53+
const explorer = cosmiconfig("test", {
54+
loaders: {
55+
".ts": TypeScriptLoader(),
56+
},
57+
});
58+
59+
const cfg = explorer.load("./amazing.config.ts");
60+
```

0 commit comments

Comments
 (0)