@codecompose/typescript-config 2.2.0-1 → 2.2.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 +12 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
Opinionated and reusable Typescript configurations, geared towards modern build tooling in both monorepos and single repositories.
|
|
4
4
|
|
|
5
|
-
- Only use Typescript for type-checking
|
|
6
|
-
- Use your bundler to output code,
|
|
7
|
-
- Use strict settings,
|
|
5
|
+
- Only use the Typescript compiler for type-checking (*)
|
|
6
|
+
- Use your bundler to output code, sourcemaps, and type declarations where needed.
|
|
7
|
+
- Use strict settings, including `noUncheckedIndexedAccess` and `erasableSyntaxOnly`.
|
|
8
8
|
- Assume `src` and `dist` directories
|
|
9
9
|
- Use of `~/` or `@/` as path alias for `src`
|
|
10
10
|
- Leverages TS 5.5 feature `${configDir}` to remove all client configuration.
|
|
11
11
|
|
|
12
|
+
(*) Project references / shared monorepo packages also emit code.
|
|
12
13
|
|
|
13
14
|
To use this successfully, you would need a modern bundler like [tsdown](https://tsdown.dev/). You can check out the [mono-ts](https://github.com/0x80/mono-ts) boilerplate for a working example of a modern monorepo setup with tsdown.
|
|
14
15
|
|
|
@@ -25,7 +26,7 @@ To use this successfully, you would need a modern bundler like [tsdown](https://
|
|
|
25
26
|
}
|
|
26
27
|
```
|
|
27
28
|
|
|
28
|
-
Often no
|
|
29
|
+
Often, no configuration is needed apart from `extends`.
|
|
29
30
|
|
|
30
31
|
## Available Configurations
|
|
31
32
|
|
|
@@ -35,21 +36,21 @@ Often no other configuration is needed besides extends.
|
|
|
35
36
|
- `react-library` - Standalone React component libraries (not part of a monorepo)
|
|
36
37
|
- `shared-react-library` - Shared React component libraries in a monorepo
|
|
37
38
|
- `nextjs` - Next.js applications
|
|
38
|
-
- `service` - A backend service like
|
|
39
|
+
- `service` - A backend service like an API server or cloud function
|
|
39
40
|
|
|
40
41
|
|
|
41
42
|
For other project types, like a CLI or E2E app, you can use the `base` configuration.
|
|
42
43
|
|
|
43
44
|
## Assuming Bundler Output
|
|
44
45
|
|
|
45
|
-
|
|
46
|
+
Outputs like sourcemaps and type declarations are disabled because it is assumed that your bundler will handle that.
|
|
46
47
|
|
|
47
48
|
|
|
48
49
|
## Incremental Builds
|
|
49
50
|
|
|
50
51
|
All configurations have `incremental` set to `true`. In my experience, it can
|
|
51
|
-
happen that builds get stuck in limbo and you need to delete the
|
|
52
|
-
`tsconfig.tsbuildinfo` file to get things going again. For this reason I
|
|
52
|
+
happen that builds get stuck in limbo, and you need to delete the
|
|
53
|
+
`tsconfig.tsbuildinfo` file to get things going again. For this reason, I
|
|
53
54
|
recommend adding the following script to your manifest based on `del-cli`:
|
|
54
55
|
|
|
55
56
|
`"clean": "del-cli dist tsconfig.tsbuildinfo"`
|
|
@@ -66,13 +67,13 @@ If you prefer to work without project references, you should set your bundler to
|
|
|
66
67
|
|
|
67
68
|
## Publishing to NPM
|
|
68
69
|
|
|
69
|
-
If you publish your package, it is recommended to include the Typescript source and type declaration maps. This allows the consumer to jump straight to the
|
|
70
|
+
If you publish your package, it is recommended to include the Typescript source and type declaration maps. This allows the consumer to jump straight to the source code, which is great for overall readability and learning.
|
|
70
71
|
|
|
71
72
|
To export source files next to your dist output, you define the `files` field in your package.json as `["src", "dist"]`.
|
|
72
73
|
|
|
73
74
|
## Caveats
|
|
74
75
|
|
|
75
|
-
Older tooling might not correctly interpret the use of `${configDir}
|
|
76
|
+
Older tooling might not correctly interpret the use of `${configDir}`, which this package uses extensively, and was only introduced in TS v5.5.
|
|
76
77
|
|
|
77
|
-
Next.js v15
|
|
78
|
+
Next.js v15 requires you to explicitly configure "includes". If you give it just "src" it will inject its own types on startup. I assume this will improve in the future.
|
|
78
79
|
|