@rm30/tsconfig 0.1.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 +93 -0
- package/base.json +20 -0
- package/expo.json +12 -0
- package/next.json +22 -0
- package/node-lib.json +16 -0
- package/package.json +23 -0
package/README.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# @rm30/tsconfig
|
|
2
|
+
|
|
3
|
+
Shared TypeScript configurations. Four, matching the four shapes of code in the workspace.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
pnpm add -D @rm30/tsconfig
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
**Declare it in every package that extends it**, not only at the monorepo root. Root-only
|
|
10
|
+
works today because both Expo monorepos set `nodeLinker: hoisted`, which flattens
|
|
11
|
+
`node_modules` so a nested package resolves upward into it. A project on pnpm's default
|
|
12
|
+
strict linker would not, and a package should declare what it uses regardless.
|
|
13
|
+
|
|
14
|
+
| Config | For |
|
|
15
|
+
|---|---|
|
|
16
|
+
| `@rm30/tsconfig/base.json` | Everything else builds on this. Strictness and interop only — no emit decisions, no JSX. |
|
|
17
|
+
| `@rm30/tsconfig/next.json` | A Next.js app. |
|
|
18
|
+
| `@rm30/tsconfig/expo.json` | An Expo app — see the note below, it is used differently. |
|
|
19
|
+
| `@rm30/tsconfig/node-lib.json` | A Node package that emits declarations (Firebase functions, a published lib). |
|
|
20
|
+
|
|
21
|
+
## `include`, `exclude` and `paths` stay in the project
|
|
22
|
+
|
|
23
|
+
None of these configs set `include` or `exclude`, and that is not an oversight.
|
|
24
|
+
TypeScript resolves relative paths **against the config file they are written in**, so an
|
|
25
|
+
`include: ["src"]` shipped from here would resolve inside
|
|
26
|
+
`node_modules/@rm30/tsconfig/` and match nothing. The same goes for `paths`, which points
|
|
27
|
+
at the project's own directories anyway.
|
|
28
|
+
|
|
29
|
+
So every project declares its own file set:
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
{
|
|
33
|
+
"extends": "@rm30/tsconfig/next.json",
|
|
34
|
+
"compilerOptions": {
|
|
35
|
+
"paths": { "@/*": ["./src/*"] }
|
|
36
|
+
},
|
|
37
|
+
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
|
38
|
+
"exclude": ["node_modules"]
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Expo app
|
|
43
|
+
|
|
44
|
+
Expo ships its own base, and it is not optional — it carries the React Native type
|
|
45
|
+
resolution. So an Expo app extends **both**, ours last:
|
|
46
|
+
|
|
47
|
+
```json
|
|
48
|
+
{
|
|
49
|
+
"extends": ["expo/tsconfig.base", "@rm30/tsconfig/expo.json"],
|
|
50
|
+
"compilerOptions": {
|
|
51
|
+
"paths": { "@/*": ["./src/*"] }
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Array `extends` needs TypeScript 5.0+; later entries win.
|
|
57
|
+
|
|
58
|
+
`expo.json` deliberately does **not** extend `base.json`. It would have to reach
|
|
59
|
+
`expo/tsconfig.base` from inside `node_modules/@rm30/tsconfig/`, where pnpm's symlinked
|
|
60
|
+
store gives it no view of the consuming project's `expo` — so the extend would resolve in
|
|
61
|
+
development and break for anyone else. Composing the two in the project keeps resolution
|
|
62
|
+
where the packages actually are.
|
|
63
|
+
|
|
64
|
+
## Node library
|
|
65
|
+
|
|
66
|
+
```json
|
|
67
|
+
{
|
|
68
|
+
"extends": "@rm30/tsconfig/node-lib.json",
|
|
69
|
+
"compilerOptions": {
|
|
70
|
+
"outDir": "lib",
|
|
71
|
+
"rootDir": "src"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
`outDir` and `rootDir` stay local — they are layout, not policy.
|
|
77
|
+
|
|
78
|
+
Note that most internal packages should **not** use this. A package consumed only inside
|
|
79
|
+
its own monorepo should be source-direct: `main` and `types` pointing at `src/index.ts`,
|
|
80
|
+
no build step at all. Metro, Next and tsup all read TypeScript from source, so compiling
|
|
81
|
+
buys nothing and costs a build that CI must run before anything type-checks. `node-lib` is
|
|
82
|
+
for the cases that genuinely emit — Firebase functions, or a package published to npm.
|
|
83
|
+
|
|
84
|
+
## What base sets
|
|
85
|
+
|
|
86
|
+
`target`/`lib` ES2022, `module` ESNext, `moduleResolution` bundler, `strict`,
|
|
87
|
+
`isolatedModules`, `esModuleInterop`, `allowSyntheticDefaultImports`, `resolveJsonModule`,
|
|
88
|
+
`forceConsistentCasingInFileNames`, `skipLibCheck`.
|
|
89
|
+
|
|
90
|
+
`moduleResolution: bundler` is deliberate. The old `node` (node10) mode is deprecated as
|
|
91
|
+
of TypeScript 6 and errors without an `ignoreDeprecations` escape hatch, and every RM30
|
|
92
|
+
package is either bundled or consumed by a bundler, so `bundler` is simply the accurate
|
|
93
|
+
description.
|
package/base.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"display": "RM30 base",
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"target": "ES2022",
|
|
6
|
+
"lib": [
|
|
7
|
+
"ES2022"
|
|
8
|
+
],
|
|
9
|
+
"module": "ESNext",
|
|
10
|
+
"moduleResolution": "bundler",
|
|
11
|
+
"strict": true,
|
|
12
|
+
"forceConsistentCasingInFileNames": true,
|
|
13
|
+
"isolatedModules": true,
|
|
14
|
+
"esModuleInterop": true,
|
|
15
|
+
"allowSyntheticDefaultImports": true,
|
|
16
|
+
"resolveJsonModule": true,
|
|
17
|
+
"skipLibCheck": true,
|
|
18
|
+
"skipDefaultLibCheck": true
|
|
19
|
+
}
|
|
20
|
+
}
|
package/expo.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"display": "RM30 Expo app",
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"strict": true,
|
|
6
|
+
"forceConsistentCasingInFileNames": true,
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"allowSyntheticDefaultImports": true,
|
|
9
|
+
"resolveJsonModule": true,
|
|
10
|
+
"skipLibCheck": true
|
|
11
|
+
}
|
|
12
|
+
}
|
package/next.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"display": "RM30 Next.js app",
|
|
4
|
+
"extends": "./base.json",
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"target": "ES2017",
|
|
7
|
+
"lib": [
|
|
8
|
+
"dom",
|
|
9
|
+
"dom.iterable",
|
|
10
|
+
"esnext"
|
|
11
|
+
],
|
|
12
|
+
"jsx": "preserve",
|
|
13
|
+
"allowJs": true,
|
|
14
|
+
"noEmit": true,
|
|
15
|
+
"incremental": true,
|
|
16
|
+
"plugins": [
|
|
17
|
+
{
|
|
18
|
+
"name": "next"
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
}
|
|
22
|
+
}
|
package/node-lib.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"display": "RM30 Node library (emits)",
|
|
4
|
+
"extends": "./base.json",
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"module": "nodenext",
|
|
7
|
+
"moduleResolution": "nodenext",
|
|
8
|
+
"types": [
|
|
9
|
+
"node"
|
|
10
|
+
],
|
|
11
|
+
"declaration": true,
|
|
12
|
+
"declarationMap": true,
|
|
13
|
+
"sourceMap": true,
|
|
14
|
+
"noImplicitReturns": true
|
|
15
|
+
}
|
|
16
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rm30/tsconfig",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Shared RM30 TypeScript configurations — base, expo, next, node-lib.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Rafael Miziara",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/rafamiziara/cli.git",
|
|
10
|
+
"directory": "packages/tsconfig"
|
|
11
|
+
},
|
|
12
|
+
"keywords": ["tsconfig", "typescript"],
|
|
13
|
+
"exports": {
|
|
14
|
+
"./base.json": "./base.json",
|
|
15
|
+
"./expo.json": "./expo.json",
|
|
16
|
+
"./next.json": "./next.json",
|
|
17
|
+
"./node-lib.json": "./node-lib.json"
|
|
18
|
+
},
|
|
19
|
+
"files": ["base.json", "expo.json", "next.json", "node-lib.json", "README.md"],
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
}
|
|
23
|
+
}
|