@petbee/tsconfig 1.0.4 → 3.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,21 +1,97 @@
1
1
  # `@petbee/tsconfig`
2
2
 
3
- This is default `tsconfig.json` that should be used by all Petbee projects.
3
+ This is the default `tsconfig.json` that should be used by all Petbee projects.
4
+
5
+ ## Features (v3.0.0)
6
+
7
+ - ✅ **TypeScript 5.9+** - Modern TypeScript support
8
+ - ✅ **ES2022+ Target** - Modern JavaScript features
9
+ - ✅ **Modern Module Resolution** - `bundler` for web apps, `NodeNext` for Node.js
10
+ - ✅ **Strict Type Safety** - Including `noUncheckedIndexedAccess` for safer array access
11
+ - ✅ **Verbatim Module Syntax** - Better ESM compatibility
12
+ - ✅ **React 17+ JSX** - New JSX transform (`react-jsx`)
4
13
 
5
14
  ## Install
6
15
 
7
16
  ```bash
8
- yarn add -D @petbee/tsconfig
17
+ yarn add -D @petbee/tsconfig typescript
9
18
  ```
10
19
 
20
+ ## Module Resolution Guide
21
+
22
+ This package provides different configs optimized for different project types:
23
+
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
28
+
11
29
  ## Usage
12
30
 
13
- ### NestJS Project
31
+ ### React Project
32
+
33
+ #### React Application Project
14
34
 
15
35
  To start, create a `tsconfig.json` in the root of your project.
16
36
 
17
37
  A typical setup where the application sit in `[project root]/app` folder is as follow:
18
38
 
39
+ ```json
40
+ {
41
+ "extends": "@petbee/tsconfig/react/application.json",
42
+ "compilerOptions": {
43
+ "baseUrl": ".",
44
+ "rootDir": ".",
45
+ "paths": { "*": ["*", "app/*"] }
46
+ },
47
+ "include": ["./app/**/*", "./client/**/*", "./server/**/*", "./tests/**/*"]
48
+ }
49
+ ```
50
+
51
+ #### React Library Project
52
+
53
+ Similarly for a react 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.
54
+
55
+ ```json
56
+ {
57
+ "extends": "@petbee/tsconfig/react/library.json",
58
+ "compilerOptions": {
59
+ "baseUrl": "./src",
60
+ "rootDir": "."
61
+ },
62
+ "include": ["./src/**/*"]
63
+ }
64
+ ```
65
+
66
+ #### Project that run in the browser
67
+
68
+ A configuration file is provided that includes styles setup and modern React JSX transform.
69
+
70
+ **Note:** This config uses `"jsx": "react-jsx"` (the new JSX transform from React 17+), which means you don't need to import React in every file that uses JSX.
71
+
72
+ ```json
73
+ {
74
+ "extends": "@petbee/tsconfig/react/dom.json",
75
+ "compilerOptions": {
76
+ "baseUrl": ".",
77
+ "rootDir": "."
78
+ }
79
+ }
80
+ ```
81
+
82
+ The React DOM config includes type definitions for:
83
+
84
+ - Image imports (`.svg`, `.png`, `.jpg`, etc.)
85
+ - Style imports (`.css`, `.scss`, `.module.css`, etc.)
86
+
87
+ ### NestJS Project
88
+
89
+ To start, create a `tsconfig.json` in the root of your project.
90
+
91
+ **Note:** The NestJS config uses CommonJS module system (`"module": "commonjs"`) and Node.js module resolution, which is optimal for NestJS applications.
92
+
93
+ A typical setup where the application sit in `[project root]/src` folder is as follow:
94
+
19
95
  ```json
20
96
  {
21
97
  "extends": "@petbee/tsconfig/nestjs.json",
@@ -26,13 +102,61 @@ A typical setup where the application sit in `[project root]/app` folder is as f
26
102
  }
27
103
  ```
28
104
 
105
+ ### NodeJS Project
106
+
107
+ **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
+
109
+ #### Node Application Project
110
+
111
+ To start, create a `tsconfig.json` in the root of your project.
112
+
113
+ A typical setup where the application sit in `[project root]/src` folder is as follow:
114
+
115
+ ```json
116
+ {
117
+ "extends": "@petbee/tsconfig/node/base.json",
118
+ "compilerOptions": {
119
+ "baseUrl": "./",
120
+ "outDir": "./dist"
121
+ }
122
+ }
123
+ ```
124
+
125
+ **For ESM projects**, ensure your `package.json` has:
126
+
127
+ ```json
128
+ {
129
+ "type": "module"
130
+ }
131
+ ```
132
+
133
+ #### Node Library Project
134
+
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
+
137
+ ```json
138
+ {
139
+ "extends": "@petbee/tsconfig/node/library.json",
140
+ "compilerOptions": {
141
+ "baseUrl": "./src",
142
+ "rootDir": "."
143
+ },
144
+ "include": ["./src/**/*"]
145
+ }
146
+ ```
147
+
29
148
  ### All Other Project
30
149
 
31
150
  A base configuration file is also provided if the above does not fit your need.
32
151
 
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:
153
+
154
+ - For Node.js ESM: use `node/base.json`
155
+ - For CommonJS: use `nestjs.json` or override with `"moduleResolution": "node"`
156
+
33
157
  ```json
34
158
  {
35
- "extends": "@petbee/tsconfig",
159
+ "extends": "@petbee/tsconfig/base.json",
36
160
  "compilerOptions": {
37
161
  "baseUrl": ".",
38
162
  "rootDir": "."
@@ -50,7 +174,7 @@ eg.
50
174
 
51
175
  ```json
52
176
  {
53
- "extends": "@petbee/tsconfig",
177
+ "extends": "@petbee/tsconfig/base.json",
54
178
  "compilerOptions": {
55
179
  "baseUrl": ".",
56
180
  "rootDir": ".",
package/base.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "compileOnSave": false,
3
+ "compilerOptions": {
4
+ "target": "ES2022",
5
+ "lib": ["ES2023", "DOM"],
6
+ "module": "ESNext",
7
+ "moduleResolution": "bundler",
8
+ "esModuleInterop": true,
9
+ "isolatedModules": true,
10
+ "verbatimModuleSyntax": true,
11
+ "experimentalDecorators": true,
12
+ "noImplicitAny": true,
13
+ "noImplicitReturns": true,
14
+ "noImplicitThis": true,
15
+ "noUnusedLocals": true,
16
+ "noUnusedParameters": true,
17
+ "noUncheckedIndexedAccess": true,
18
+ "allowUnusedLabels": false,
19
+ "allowUnreachableCode": false,
20
+ "resolveJsonModule": true,
21
+ "skipLibCheck": true,
22
+ "strict": true,
23
+ "strictFunctionTypes": true,
24
+ "strictNullChecks": true,
25
+ "forceConsistentCasingInFileNames": true
26
+ }
27
+ }
package/nestjs.json CHANGED
@@ -1,17 +1,21 @@
1
1
  {
2
2
  "compilerOptions": {
3
+ "target": "ES2022",
4
+ "lib": ["ES2023"],
3
5
  "module": "commonjs",
6
+ "moduleResolution": "node",
4
7
  "declaration": true,
5
8
  "removeComments": true,
6
9
  "emitDecoratorMetadata": true,
7
10
  "experimentalDecorators": true,
8
11
  "allowSyntheticDefaultImports": true,
9
- "target": "ES2019",
10
12
  "sourceMap": true,
11
13
  "outDir": "./dist",
12
14
  "baseUrl": "./",
13
15
  "incremental": true,
14
16
  "skipLibCheck": true,
15
- "esModuleInterop": true
17
+ "esModuleInterop": true,
18
+ "forceConsistentCasingInFileNames": true,
19
+ "strict": true
16
20
  }
17
21
  }
package/node/base.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "compileOnSave": false,
3
+ "compilerOptions": {
4
+ "target": "ES2022",
5
+ "lib": ["ES2023"],
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
21
+ }
22
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "./base.json",
3
+ "compilerOptions": {
4
+ "declaration": true,
5
+ "declarationMap": true,
6
+ "noEmit": false,
7
+ "noEmitHelpers": true
8
+ }
9
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@petbee/tsconfig",
3
- "version": "1.0.4",
3
+ "version": "3.0.0",
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": "6d0700f54e3e0066c16afbef99920922b326da9e"
18
+ "gitHead": "e78d31f90c9546fa3b7e1959902bc6d703956349"
19
19
  }
@@ -0,0 +1,6 @@
1
+ {
2
+ "extends": "./dom.json",
3
+ "compilerOptions": {
4
+ "noEmit": true
5
+ }
6
+ }
@@ -0,0 +1,39 @@
1
+ declare module '*.svg' {
2
+ const content: string
3
+ export default content
4
+ }
5
+
6
+ declare module '*.png' {
7
+ const content: string
8
+ export default content
9
+ }
10
+
11
+ declare module '*.jpg' {
12
+ const content: string
13
+ export default content
14
+ }
15
+
16
+ declare module '*.jpeg' {
17
+ const content: string
18
+ export default content
19
+ }
20
+
21
+ declare module '*.gif' {
22
+ const content: string
23
+ export default content
24
+ }
25
+
26
+ declare module '*.webp' {
27
+ const content: string
28
+ export default content
29
+ }
30
+
31
+ declare module '*.ico' {
32
+ const content: string
33
+ export default content
34
+ }
35
+
36
+ declare module '*.bmp' {
37
+ const content: string
38
+ export default content
39
+ }
@@ -0,0 +1,39 @@
1
+ declare module '*.css' {
2
+ const content: { [className: string]: string }
3
+ export default content
4
+ }
5
+
6
+ declare module '*.scss' {
7
+ const content: { [className: string]: string }
8
+ export default content
9
+ }
10
+
11
+ declare module '*.sass' {
12
+ const content: { [className: string]: string }
13
+ export default content
14
+ }
15
+
16
+ declare module '*.less' {
17
+ const content: { [className: string]: string }
18
+ export default content
19
+ }
20
+
21
+ declare module '*.module.css' {
22
+ const content: { [className: string]: string }
23
+ export default content
24
+ }
25
+
26
+ declare module '*.module.scss' {
27
+ const content: { [className: string]: string }
28
+ export default content
29
+ }
30
+
31
+ declare module '*.module.sass' {
32
+ const content: { [className: string]: string }
33
+ export default content
34
+ }
35
+
36
+ declare module '*.module.less' {
37
+ const content: { [className: string]: string }
38
+ export default content
39
+ }
package/react/dom.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "../base.json",
3
+ "compilerOptions": {
4
+ "jsx": "react-jsx",
5
+ "lib": ["ES2023", "DOM", "DOM.Iterable"],
6
+ "module": "ESNext",
7
+ "target": "ES2022"
8
+ },
9
+ "files": ["./definitions/images.d.ts", "./definitions/styles.d.ts"]
10
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "./dom.json",
3
+ "compilerOptions": {
4
+ "declaration": true,
5
+ "declarationMap": true,
6
+ "noEmit": false,
7
+ "noEmitHelpers": true
8
+ }
9
+ }
package/tsconfig.json DELETED
@@ -1,26 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "alwaysStrict": true,
4
- "allowSyntheticDefaultImports": true,
5
- "esModuleInterop": true,
6
- "jsx": "react",
7
- "lib": ["es2017", "dom", "es2018.promise", "esnext.asynciterable", "es2019", "es2020", "esnext"],
8
- "module": "esnext",
9
- "moduleResolution": "node",
10
- "noImplicitAny": true,
11
- "noImplicitReturns": true,
12
- "noImplicitThis": true,
13
- "noUnusedLocals": true,
14
- "noUnusedParameters": true,
15
- "skipLibCheck": true,
16
- "sourceMap": true,
17
- "strictFunctionTypes": true,
18
- "strictNullChecks": true,
19
- "strictPropertyInitialization": true,
20
- "target": "es2020",
21
- "forceConsistentCasingInFileNames": true
22
- },
23
- "typeAcquisition": {
24
- "enable": true
25
- }
26
- }