@petbee/tsconfig 3.0.0 → 3.0.2

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
@@ -19,32 +19,35 @@ yarn add -D @petbee/tsconfig typescript
19
19
 
20
20
  ## Module Resolution Guide
21
21
 
22
- This package provides different configs optimized for different project types:
23
22
 
24
- - **`base.json`** - For bundled web apps (Vite, Webpack) - Uses `"moduleResolution": "bundler"`
25
- - **`node/base.json`** - For Node.js ESM projects - Uses `"moduleResolution": "NodeNext"`
26
- - **`nestjs.json`** - For NestJS projects - Uses `"moduleResolution": "node"` (CommonJS)
27
- - **`react/*`** - For React projects - Uses modern JSX transform
23
+ This package provides entry-point configs for each framework, making it easy to extend the right config for your project:
24
+
25
+ - **`base.json`** Safe, strict defaults for all projects (modern web, library, etc.)
26
+ - **`react.json`** For React projects (extends `react/dom.json`)
27
+ - **`node.json`** – For Node.js ESM projects (extends `node/base.json`)
28
+ - **`nestjs.json`** – For NestJS projects (extends `nestjs/base.json`)
29
+ - **`nextjs.json`** – For Next.js projects (extends `nextjs/base.json`)
30
+ - **`node/commonjs.json`** – For legacy Node.js CommonJS projects
31
+
32
+ You can also extend the more granular configs in each framework folder if you need a specific variant (e.g., `react/library.json`, `node/library.json`).
28
33
 
29
34
  ## Usage
30
35
 
31
36
  ### React Project
32
37
 
33
- #### React Application Project
34
38
 
35
- To start, create a `tsconfig.json` in the root of your project.
39
+ #### React Project
36
40
 
37
- A typical setup where the application sit in `[project root]/app` folder is as follow:
41
+ To start, create a `tsconfig.json` in the root of your project:
38
42
 
39
43
  ```json
40
44
  {
41
- "extends": "@petbee/tsconfig/react/application.json",
45
+ "extends": "@petbee/tsconfig/react.json",
42
46
  "compilerOptions": {
43
47
  "baseUrl": ".",
44
- "rootDir": ".",
45
- "paths": { "*": ["*", "app/*"] }
48
+ "rootDir": "."
46
49
  },
47
- "include": ["./app/**/*", "./client/**/*", "./server/**/*", "./tests/**/*"]
50
+ "include": ["./src/**/*"]
48
51
  }
49
52
  ```
50
53
 
@@ -106,15 +109,14 @@ A typical setup where the application sit in `[project root]/src` folder is as f
106
109
 
107
110
  **Note:** The Node.js config uses modern ESM module resolution (`"moduleResolution": "NodeNext"`). This is optimal for Node.js 18+ with native ESM support. If you're using CommonJS, consider using the NestJS config instead.
108
111
 
109
- #### Node Application Project
110
112
 
111
- To start, create a `tsconfig.json` in the root of your project.
113
+ #### Node.js Project (ESM)
112
114
 
113
- A typical setup where the application sit in `[project root]/src` folder is as follow:
115
+ To start, create a `tsconfig.json` in the root of your project:
114
116
 
115
117
  ```json
116
118
  {
117
- "extends": "@petbee/tsconfig/node/base.json",
119
+ "extends": "@petbee/tsconfig/node.json",
118
120
  "compilerOptions": {
119
121
  "baseUrl": "./",
120
122
  "outDir": "./dist"
@@ -130,29 +132,25 @@ A typical setup where the application sit in `[project root]/src` folder is as f
130
132
  }
131
133
  ```
132
134
 
133
- #### Node Library Project
134
135
 
135
- Similarly for a node library project. Create a `tsconfig.json` in the root of your project with a setup below assuming the library code sit in `[project root]/src` folder.
136
+ #### Node.js Project (CommonJS)
137
+
138
+ For legacy Node.js projects using CommonJS, extend the CommonJS config:
136
139
 
137
140
  ```json
138
141
  {
139
- "extends": "@petbee/tsconfig/node/library.json",
142
+ "extends": "@petbee/tsconfig/node/commonjs.json",
140
143
  "compilerOptions": {
141
- "baseUrl": "./src",
142
- "rootDir": "."
143
- },
144
- "include": ["./src/**/*"]
144
+ "baseUrl": "./",
145
+ "outDir": "./dist"
146
+ }
145
147
  }
146
148
  ```
147
149
 
148
- ### All Other Project
149
-
150
- A base configuration file is also provided if the above does not fit your need.
151
150
 
152
- **Note:** The base config uses `"moduleResolution": "bundler"`, which is optimal for projects using modern bundlers (Vite, Webpack 5+, esbuild, etc.). If you need different module resolution:
151
+ ### Custom/Advanced Usage
153
152
 
154
- - For Node.js ESM: use `node/base.json`
155
- - For CommonJS: use `nestjs.json` or override with `"moduleResolution": "node"`
153
+ If you need more control, you can extend any of the granular configs in the framework folders (e.g., `react/library.json`, `node/library.json`, etc.) or the base config directly:
156
154
 
157
155
  ```json
158
156
  {
@@ -164,6 +162,23 @@ A base configuration file is also provided if the above does not fit your need.
164
162
  }
165
163
  ```
166
164
 
165
+ ### TypeScript Configuration Notes
166
+
167
+ #### Plugins
168
+
169
+ - If you override the `plugins` array in your project’s tsconfig.json, **always include** the Next.js plugin for Next.js projects:
170
+ ```json
171
+ "plugins": [
172
+ { "name": "next" }
173
+ ]
174
+ ```
175
+ - Omitting the Next.js plugin may cause type-checking and IDE features to break.
176
+
177
+ #### Include/Exclude
178
+
179
+ - If you set your own `include` or `exclude` arrays, they will completely replace those from the base config.
180
+ - Use the recommended patterns from the base config unless you have a specific need.
181
+
167
182
  ## Common Got Ya
168
183
 
169
184
  #### Type Checking does not honour `skipLibCheck: true` setting
@@ -0,0 +1,18 @@
1
+ {
2
+ "extends": "../base.json",
3
+ "compilerOptions": {
4
+ "module": "commonjs",
5
+ "moduleResolution": "node",
6
+ "declaration": true,
7
+ "removeComments": true,
8
+ "emitDecoratorMetadata": true,
9
+ "experimentalDecorators": true,
10
+ "allowSyntheticDefaultImports": true,
11
+ "sourceMap": true,
12
+ "outDir": "./dist",
13
+ "baseUrl": "./",
14
+ "incremental": true,
15
+ "strictPropertyInitialization": false
16
+ },
17
+ "exclude": ["node_modules", "dist"]
18
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "./base.json",
3
+ "exclude": ["node_modules", "dist", "test", "**/*spec.ts", "dangerfile.ts", "prisma"],
4
+ "compilerOptions": {
5
+ "strictNullChecks": true,
6
+ "incremental": false,
7
+ "composite": false
8
+ }
9
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "./base.json",
3
+ "exclude": ["node_modules", "dist", "test", "**/*spec.ts", "@generated", "prisma"],
4
+ "compilerOptions": {
5
+ "strictNullChecks": true
6
+ }
7
+ }
package/nestjs.json CHANGED
@@ -1,21 +1,3 @@
1
1
  {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "lib": ["ES2023"],
5
- "module": "commonjs",
6
- "moduleResolution": "node",
7
- "declaration": true,
8
- "removeComments": true,
9
- "emitDecoratorMetadata": true,
10
- "experimentalDecorators": true,
11
- "allowSyntheticDefaultImports": true,
12
- "sourceMap": true,
13
- "outDir": "./dist",
14
- "baseUrl": "./",
15
- "incremental": true,
16
- "skipLibCheck": true,
17
- "esModuleInterop": true,
18
- "forceConsistentCasingInFileNames": true,
19
- "strict": true
20
- }
2
+ "extends": "./nestjs/base.json"
21
3
  }
@@ -0,0 +1,24 @@
1
+ {
2
+ "extends": "../base.json",
3
+ "compilerOptions": {
4
+ "target": "ES2020",
5
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
6
+ "plugins": [
7
+ {
8
+ "name": "next"
9
+ }
10
+ ],
11
+ "jsx": "preserve",
12
+ "allowJs": true,
13
+ "noEmit": true,
14
+ "incremental": true,
15
+ "removeComments": false,
16
+ "importHelpers": true,
17
+ "downlevelIteration": true,
18
+ "skipDefaultLibCheck": true,
19
+ "useDefineForClassFields": true,
20
+ "verbatimModuleSyntax": false,
21
+ "experimentalDecorators": false,
22
+ "emitDecoratorMetadata": false
23
+ }
24
+ }
package/nextjs.json ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": "./nextjs/base.json"
3
+ }
package/node/base.json CHANGED
@@ -1,22 +1,9 @@
1
1
  {
2
- "compileOnSave": false,
2
+ "extends": "../base.json",
3
3
  "compilerOptions": {
4
4
  "target": "ES2022",
5
5
  "lib": ["ES2023"],
6
6
  "module": "NodeNext",
7
- "moduleResolution": "NodeNext",
8
- "esModuleInterop": true,
9
- "isolatedModules": true,
10
- "verbatimModuleSyntax": true,
11
- "experimentalDecorators": true,
12
- "noUnusedLocals": true,
13
- "noUnusedParameters": true,
14
- "noUncheckedIndexedAccess": true,
15
- "allowUnusedLabels": false,
16
- "allowUnreachableCode": false,
17
- "resolveJsonModule": true,
18
- "skipLibCheck": true,
19
- "strict": true,
20
- "forceConsistentCasingInFileNames": true
7
+ "moduleResolution": "NodeNext"
21
8
  }
22
9
  }
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "./base.json",
3
+ "compilerOptions": {
4
+ "module": "CommonJS",
5
+ "moduleResolution": "node"
6
+ }
7
+ }
package/node.json ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": "./node/base.json"
3
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@petbee/tsconfig",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -15,5 +15,5 @@
15
15
  "peerDependencies": {
16
16
  "typescript": "^3 || ^4 || ^5"
17
17
  },
18
- "gitHead": "e78d31f90c9546fa3b7e1959902bc6d703956349"
18
+ "gitHead": "abe6270b98022de98e790e3c06e568d5334845e1"
19
19
  }
package/react.json ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": "./react/dom.json"
3
+ }