@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 CHANGED
@@ -1,25 +1,33 @@
1
1
  # typescript-config
2
2
 
3
- Opinionated reusable Typescript configurations, assuming:
3
+ Opinionated reusable Typescript configurations. Out-of-the-box we assume:
4
4
 
5
- - A monorepo setup (\*)
6
- - Transpile with a bundler
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
- (\*) Use the `single-*.json` variants if you do **not** use a monorepo setup.
10
+ Of course, you can still choose to override any of the defaults in your own
11
+ config.
12
12
 
13
- All configurations have `incremental` set to `true`. For this reason I recommend
14
- adding the following script to your manifest based on `del-cli`:
13
+ ## Structure
15
14
 
16
- `"clean": "del dist tsconfig.tsbuildinfo"`
15
+ Configurations are organized based on their intended use:
17
16
 
18
- In my experience, it can happen that builds get stuck in limbo and you need to
19
- delete the `tsbuildinfo` file to get things going again.
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
- Source maps are not enabled, because we assume that your bundler will handle
22
- that.
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/single-react-library.json"
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
- - library
41
- - react-library
42
- - service
43
- - nextjs
44
- - single-library
45
- - single-react-library
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": "1.1.3",
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
- "base.json",
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,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/tsconfig",
3
- "display": "Base Configuration",
3
+ "display": "Base configuration",
4
4
  "compilerOptions": {
5
5
  /* Base Options: */
6
6
  "esModuleInterop": true,
@@ -1,13 +1,10 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/tsconfig",
3
- "display": "A Shared Library",
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,9 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "display": "Monorepo shared library",
4
+ "extends": "../library.json",
5
+ "compilerOptions": {
6
+ /* AND if you're building for a library in a monorepo: */
7
+ "composite": true
8
+ }
9
+ }
@@ -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,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/tsconfig",
3
- "display": "A Next.js App",
3
+ "display": "Next.js app",
4
4
  "extends": "./base.json",
5
5
  "compilerOptions": {
6
6
  "jsx": "preserve", // next does its own jsx transformation
@@ -1,16 +1,13 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/tsconfig",
3
- "display": "A React Component Library",
3
+ "display": "Standalone React component library",
4
4
  "extends": "./base.json",
5
5
  "compilerOptions": {
6
- "lib": ["dom", "dom.iterable", "es2023"],
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
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/tsconfig",
3
- "display": "A Backend Service",
3
+ "display": "Backend service",
4
4
  "extends": "./base.json",
5
5
  "compilerOptions": {}
6
6
  }
@@ -1,9 +0,0 @@
1
- {
2
- "$schema": "https://json.schemastore.org/tsconfig",
3
- "display": "A Single Shared Library",
4
- "extends": "./base.json",
5
- "compilerOptions": {
6
- /* AND if you're building for a library: */
7
- "declaration": true
8
- }
9
- }
@@ -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
- }