@codecompose/typescript-config 1.2.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -30
- package/package.json +13 -9
- package/{base.json → src/base.json} +1 -1
- package/{single-library.json → src/library.json} +1 -1
- package/{nextjs.json → src/nextjs.json} +1 -1
- package/{single-react-library.json → src/react-library.json} +1 -1
- package/{service.json → src/service.json} +1 -1
- package/{library.json → src/shared-library.json} +2 -6
- package/src/shared-react-library.json +10 -0
- package/react-library.json +0 -16
package/README.md
CHANGED
|
@@ -1,52 +1,62 @@
|
|
|
1
1
|
# typescript-config
|
|
2
2
|
|
|
3
|
-
Opinionated reusable Typescript configurations
|
|
3
|
+
Opinionated reusable Typescript configurations. Out-of-the-box we assume:
|
|
4
4
|
|
|
5
|
-
-
|
|
6
|
-
-
|
|
7
|
-
- Strict rules
|
|
5
|
+
- You transpile using a bundler
|
|
6
|
+
- You want strict rules
|
|
8
7
|
- Use of `src` and `dist` directories
|
|
9
8
|
- Use of `~/` as path alias for `src`
|
|
10
9
|
|
|
11
|
-
|
|
10
|
+
Of course, you can still choose to override any of the defaults in your own
|
|
11
|
+
config.
|
|
12
12
|
|
|
13
|
-
##
|
|
13
|
+
## Structure
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
config.
|
|
15
|
+
Configurations are organized based on their intended use:
|
|
17
16
|
|
|
18
|
-
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
definitions. I use tsc to generate the types, as demonstrated in
|
|
22
|
-
[mono-ts](https://github.com/0x80/mono-ts).
|
|
17
|
+
- **Root configurations**: For stand-alone projects or general use
|
|
18
|
+
- **Monorepo configurations**: Under the `/monorepo` path for monorepo-specific
|
|
19
|
+
setups
|
|
23
20
|
|
|
24
21
|
## Install
|
|
25
22
|
|
|
26
|
-
`
|
|
27
|
-
|
|
28
|
-
...or the equivalent for your package manager.
|
|
23
|
+
`npm i @codecompose/typescript-config -D`
|
|
29
24
|
|
|
30
25
|
## Usage
|
|
31
26
|
|
|
32
27
|
```json
|
|
33
28
|
{
|
|
34
|
-
"extends": "@codecompose/typescript-config/
|
|
29
|
+
"extends": "@codecompose/typescript-config/base"
|
|
35
30
|
}
|
|
36
31
|
```
|
|
37
32
|
|
|
38
33
|
## Available Configurations
|
|
39
34
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
-
|
|
43
|
-
|
|
44
|
-
-
|
|
45
|
-
|
|
46
|
-
-
|
|
35
|
+
### Base Configuration
|
|
36
|
+
|
|
37
|
+
- `base` - Base configuration with common settings
|
|
38
|
+
|
|
39
|
+
### Stand-alone Configurations
|
|
40
|
+
|
|
41
|
+
- `base` - For anything non-specific
|
|
42
|
+
- `library` - For general libraries
|
|
43
|
+
- `react-library` - For React component libraries
|
|
44
|
+
- `nextjs` - For Next.js applications
|
|
45
|
+
- `service` - For a backend service like and API server or cloud function
|
|
46
|
+
|
|
47
|
+
### Monorepo Configurations
|
|
47
48
|
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
When using a monorepo, the packages that other packages depend on should use the
|
|
50
|
+
"shared" variant.
|
|
51
|
+
|
|
52
|
+
- `shared-library` - For shared libraries in a monorepo
|
|
53
|
+
- `shared-react-library` - For shared React component libraries in a monorepo
|
|
54
|
+
|
|
55
|
+
The `nextjs` and `service` configs are compatible with both monorepo and
|
|
56
|
+
non-monorepo.
|
|
57
|
+
|
|
58
|
+
For other project types, like a CLI or E2E app, you can use the `base`
|
|
59
|
+
configuration.
|
|
50
60
|
|
|
51
61
|
## Assumptions and Recommendations
|
|
52
62
|
|
|
@@ -54,8 +64,19 @@ Source maps are not enabled, because we assume that your bundler will handle
|
|
|
54
64
|
that.
|
|
55
65
|
|
|
56
66
|
All configurations have `incremental` set to `true`. In my experience, it can
|
|
57
|
-
happen that builds get stuck in limbo and you need to delete the
|
|
58
|
-
file to get things going again. For this reason I
|
|
59
|
-
script to your manifest based on `del-cli`:
|
|
67
|
+
happen that builds get stuck in limbo and you need to delete the
|
|
68
|
+
`tsconfig.tsbuildinfo` file to get things going again. For this reason I
|
|
69
|
+
recommend adding the following script to your manifest based on `del-cli`:
|
|
70
|
+
|
|
71
|
+
`"clean": "del-cli dist tsconfig.tsbuildinfo"`
|
|
72
|
+
|
|
73
|
+
## Known Issues
|
|
74
|
+
|
|
75
|
+
At the time of writing, not all tooling correctly interprets the use of
|
|
76
|
+
`${configDir}` introduced in TS v5.5 that this package depends on.
|
|
60
77
|
|
|
61
|
-
|
|
78
|
+
- Next.js will require you to explicitly defined "includes". Give it "src" and
|
|
79
|
+
it will inject its types on startup.
|
|
80
|
+
- TSUP will not understand the tsconfig if you ask it to generate type
|
|
81
|
+
definitions. I use tsc to generate the types, as demonstrated in
|
|
82
|
+
[mono-ts](https://github.com/0x80/mono-ts).
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codecompose/typescript-config",
|
|
3
3
|
"description": "Opinionated reusable TypeScript configurations",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "2.0.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Thijs Koerselman",
|
|
7
7
|
"publishConfig": {
|
|
@@ -11,22 +11,26 @@
|
|
|
11
11
|
"typescript",
|
|
12
12
|
"config",
|
|
13
13
|
"configuration",
|
|
14
|
+
"monorepo",
|
|
14
15
|
"strict",
|
|
15
16
|
"reusable",
|
|
16
|
-
"base",
|
|
17
17
|
"nextjs",
|
|
18
|
+
"react",
|
|
18
19
|
"library",
|
|
19
20
|
"service"
|
|
20
21
|
],
|
|
21
22
|
"files": [
|
|
22
|
-
"
|
|
23
|
-
"library.json",
|
|
24
|
-
"nextjs.json",
|
|
25
|
-
"react-library.json",
|
|
26
|
-
"service.json",
|
|
27
|
-
"single-library.json",
|
|
28
|
-
"single-react-library.json"
|
|
23
|
+
"src"
|
|
29
24
|
],
|
|
25
|
+
"exports": {
|
|
26
|
+
"./base": "./src/base.json",
|
|
27
|
+
"./library": "./src/library.json",
|
|
28
|
+
"./nextjs": "./src/nextjs.json",
|
|
29
|
+
"./react-library": "./src/react-library.json",
|
|
30
|
+
"./service": "./src/service.json",
|
|
31
|
+
"./shared-library": "./src/shared-library.json",
|
|
32
|
+
"./shared-react-library": "./src/shared-react-library.json"
|
|
33
|
+
},
|
|
30
34
|
"devDependencies": {
|
|
31
35
|
"eslint": "^8.57.0",
|
|
32
36
|
"prettier": "^3.3.3",
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
-
"display": "
|
|
4
|
-
"extends": "./
|
|
3
|
+
"display": "Monorepo shared library",
|
|
4
|
+
"extends": "./library.json",
|
|
5
5
|
"compilerOptions": {
|
|
6
|
-
/* AND if you're building for a library: */
|
|
7
|
-
"declaration": true,
|
|
8
|
-
"declarationMap": true,
|
|
9
|
-
|
|
10
6
|
/* AND if you're building for a library in a monorepo: */
|
|
11
7
|
"composite": true
|
|
12
8
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"display": "Monorepo shared React component library",
|
|
4
|
+
"extends": "./react-library.json",
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
/* AND if you're building for a library in a monorepo: */
|
|
7
|
+
"composite": true,
|
|
8
|
+
"declarationMap": true
|
|
9
|
+
}
|
|
10
|
+
}
|
package/react-library.json
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
-
"display": "A React Component Library",
|
|
4
|
-
"extends": "./base.json",
|
|
5
|
-
"compilerOptions": {
|
|
6
|
-
"lib": ["dom", "dom.iterable", "esnext"],
|
|
7
|
-
"jsx": "react-jsx",
|
|
8
|
-
|
|
9
|
-
/* AND if you're building for a library: */
|
|
10
|
-
"declaration": true,
|
|
11
|
-
|
|
12
|
-
/* AND if you're building for a library in a monorepo: */
|
|
13
|
-
"composite": true,
|
|
14
|
-
"declarationMap": true
|
|
15
|
-
}
|
|
16
|
-
}
|