@codecompose/typescript-config 1.1.3 → 2.0.0
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 +69 -19
- package/package.json +13 -9
- package/{base.json → src/base.json} +1 -1
- package/{library.json → src/library.json} +1 -4
- package/src/monorepo/library.json +9 -0
- package/src/monorepo/react-library.json +10 -0
- package/{nextjs.json → src/nextjs.json} +1 -1
- package/{react-library.json → src/react-library.json} +2 -5
- package/{service.json → src/service.json} +1 -1
- package/single-library.json +0 -9
- package/single-react-library.json +0 -12
package/README.md
CHANGED
|
@@ -1,25 +1,33 @@
|
|
|
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
|
-
|
|
14
|
-
adding the following script to your manifest based on `del-cli`:
|
|
13
|
+
## Structure
|
|
15
14
|
|
|
16
|
-
|
|
15
|
+
Configurations are organized based on their intended use:
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
- **Root configurations**: For stand-alone projects or general use
|
|
18
|
+
- **Monorepo configurations**: Under the `/monorepo` path for monorepo-specific
|
|
19
|
+
setups
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
## Warning
|
|
22
|
+
|
|
23
|
+
At the time of writing, not all tooling correctly interprets the use of
|
|
24
|
+
`${configDir}` introduced in TS v5.5 that this package depends on.
|
|
25
|
+
|
|
26
|
+
- Next.js will require you to explicitly defined "includes". Give it "src" and
|
|
27
|
+
it will inject its types on startup.
|
|
28
|
+
- TSUP will not understand the tsconfig if you ask it to generate type
|
|
29
|
+
definitions. I use tsc to generate the types, as demonstrated in
|
|
30
|
+
[mono-ts](https://github.com/0x80/mono-ts).
|
|
23
31
|
|
|
24
32
|
## Install
|
|
25
33
|
|
|
@@ -29,17 +37,59 @@ that.
|
|
|
29
37
|
|
|
30
38
|
## Usage
|
|
31
39
|
|
|
40
|
+
For non-monorepo projects:
|
|
41
|
+
|
|
32
42
|
```json
|
|
33
43
|
{
|
|
34
|
-
"extends": "@codecompose/typescript-config/
|
|
44
|
+
"extends": "@codecompose/typescript-config/library"
|
|
35
45
|
}
|
|
36
46
|
```
|
|
37
47
|
|
|
48
|
+
For monorepo projects:
|
|
49
|
+
|
|
50
|
+
```json
|
|
51
|
+
{
|
|
52
|
+
"extends": "@codecompose/typescript-config/monorepo/library"
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Note: The `.json` extension is no longer needed in imports.
|
|
57
|
+
|
|
38
58
|
## Available Configurations
|
|
39
59
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
-
|
|
43
|
-
|
|
44
|
-
-
|
|
45
|
-
|
|
60
|
+
### Base Configuration
|
|
61
|
+
|
|
62
|
+
- `base` - Base configuration with common settings
|
|
63
|
+
|
|
64
|
+
### Stand-alone Configurations
|
|
65
|
+
|
|
66
|
+
- `library` - For general libraries
|
|
67
|
+
- `react-library` - For React component libraries
|
|
68
|
+
- `nextjs` - For Next.js applications
|
|
69
|
+
- `service` - For a backend service like and API server or cloud function
|
|
70
|
+
|
|
71
|
+
### Monorepo Configurations
|
|
72
|
+
|
|
73
|
+
When using a monorepo, the packages that other packages depend on should use the
|
|
74
|
+
enhanced variant.
|
|
75
|
+
|
|
76
|
+
- `monorepo/library` - For shared libraries in a monorepo
|
|
77
|
+
- `monorepo/react-library` - For shared React component libraries in a monorepo
|
|
78
|
+
|
|
79
|
+
The `nextjs` and `service` configs are compatible with both monorepo and
|
|
80
|
+
non-monorepo.
|
|
81
|
+
|
|
82
|
+
For other project types, like a CLI or E2E app, you can probably just use the
|
|
83
|
+
`base` configuration.
|
|
84
|
+
|
|
85
|
+
## Assumptions and Recommendations
|
|
86
|
+
|
|
87
|
+
Source maps are not enabled, because we assume that your bundler will handle
|
|
88
|
+
that.
|
|
89
|
+
|
|
90
|
+
All configurations have `incremental` set to `true`. In my experience, it can
|
|
91
|
+
happen that builds get stuck in limbo and you need to delete the
|
|
92
|
+
`tsconfig.tsbuildinfo` file to get things going again. For this reason I
|
|
93
|
+
recommend adding the following script to your manifest based on `del-cli`:
|
|
94
|
+
|
|
95
|
+
`"clean": "del-cli dist tsconfig.tsbuildinfo"`
|
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.0",
|
|
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
|
+
"./monorepo/library": "./src/monorepo/library.json",
|
|
32
|
+
"./monorepo/react-library": "./src/monorepo/react-library.json"
|
|
33
|
+
},
|
|
30
34
|
"devDependencies": {
|
|
31
35
|
"eslint": "^8.57.0",
|
|
32
36
|
"prettier": "^3.3.3",
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
-
"display": "
|
|
3
|
+
"display": "Standalone shared library",
|
|
4
4
|
"extends": "./base.json",
|
|
5
5
|
"compilerOptions": {
|
|
6
6
|
/* AND if you're building for a library: */
|
|
7
7
|
"declaration": true,
|
|
8
|
-
|
|
9
|
-
/* AND if you're building for a library in a monorepo: */
|
|
10
|
-
"composite": true,
|
|
11
8
|
"declarationMap": true
|
|
12
9
|
}
|
|
13
10
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"display": "Monorepo 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
|
+
}
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
-
"display": "
|
|
3
|
+
"display": "Standalone React component library",
|
|
4
4
|
"extends": "./base.json",
|
|
5
5
|
"compilerOptions": {
|
|
6
|
-
"lib": ["dom", "dom.iterable", "
|
|
6
|
+
"lib": ["dom", "dom.iterable", "esnext"],
|
|
7
7
|
"jsx": "react-jsx",
|
|
8
8
|
|
|
9
9
|
/* AND if you're building for a library: */
|
|
10
10
|
"declaration": true,
|
|
11
|
-
|
|
12
|
-
/* AND if you're building for a library in a monorepo: */
|
|
13
|
-
"composite": true,
|
|
14
11
|
"declarationMap": true
|
|
15
12
|
}
|
|
16
13
|
}
|
package/single-library.json
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
-
"display": "A Single React Component Library",
|
|
4
|
-
"extends": "./base.json",
|
|
5
|
-
"compilerOptions": {
|
|
6
|
-
"lib": ["dom", "dom.iterable", "es2023"],
|
|
7
|
-
"jsx": "react-jsx",
|
|
8
|
-
|
|
9
|
-
/* AND if you're building for a library: */
|
|
10
|
-
"declaration": true
|
|
11
|
-
}
|
|
12
|
-
}
|