@jmlweb/tsconfig-react 1.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.
Files changed (3) hide show
  1. package/README.md +229 -0
  2. package/package.json +41 -0
  3. package/tsconfig.json +11 -0
package/README.md ADDED
@@ -0,0 +1,229 @@
1
+ # @jmlweb/tsconfig-react
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@jmlweb/tsconfig-react)](https://www.npmjs.com/package/@jmlweb/tsconfig-react)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
5
+ [![Node.js](https://img.shields.io/badge/Node.js-%3E%3D18.0.0-339933.svg)](https://nodejs.org/)
6
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.0%2B-3178C6.svg)](https://www.typescriptlang.org/)
7
+ [![React](https://img.shields.io/badge/React-17%2B-61DAFB.svg)](https://react.dev/)
8
+
9
+ > TypeScript configuration for React libraries. Extends `@jmlweb/tsconfig-base` with JSX support, DOM types, and bundler-optimized module resolution.
10
+
11
+ ## ✨ Features
12
+
13
+ - 🔒 **Strict Type Checking**: Inherits all strict TypeScript rules from base config
14
+ - ⚛️ **JSX Support**: Modern JSX transform (React 17+) with `react-jsx`
15
+ - 🌐 **DOM Types**: Includes DOM and DOM.Iterable libs for browser APIs
16
+ - 📦 **Bundler Resolution**: Optimized `moduleResolution: "bundler"` for modern build tools
17
+ - 🎯 **Modern Modules**: Uses ESNext modules for optimal bundling
18
+ - 🚀 **Extensible**: Extends base config, easy to customize
19
+
20
+ ## 📦 Installation
21
+
22
+ ```bash
23
+ npm install --save-dev @jmlweb/tsconfig-react typescript @jmlweb/tsconfig-base
24
+ ```
25
+
26
+ ## 🚀 Quick Start
27
+
28
+ Create a `tsconfig.json` file in your project root:
29
+
30
+ ```json
31
+ {
32
+ "extends": "@jmlweb/tsconfig-react",
33
+ "compilerOptions": {
34
+ "outDir": "./dist"
35
+ },
36
+ "include": ["src"],
37
+ "exclude": ["node_modules", "dist"]
38
+ }
39
+ ```
40
+
41
+ ## 💡 Examples
42
+
43
+ ### Basic Setup
44
+
45
+ ```json
46
+ {
47
+ "extends": "@jmlweb/tsconfig-react",
48
+ "include": ["src"],
49
+ "exclude": ["node_modules", "dist"]
50
+ }
51
+ ```
52
+
53
+ ### With Custom Output Directory
54
+
55
+ ```json
56
+ {
57
+ "extends": "@jmlweb/tsconfig-react",
58
+ "compilerOptions": {
59
+ "outDir": "./dist",
60
+ "rootDir": "./src"
61
+ },
62
+ "include": ["src"],
63
+ "exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.test.tsx"]
64
+ }
65
+ ```
66
+
67
+ ### With Additional Compiler Options
68
+
69
+ ```json
70
+ {
71
+ "extends": "@jmlweb/tsconfig-react",
72
+ "compilerOptions": {
73
+ "outDir": "./dist",
74
+ "declaration": true,
75
+ "declarationMap": true,
76
+ "sourceMap": true
77
+ },
78
+ "include": ["src"],
79
+ "exclude": ["node_modules", "dist"]
80
+ }
81
+ ```
82
+
83
+ ### For React Library with Path Mapping
84
+
85
+ ```json
86
+ {
87
+ "extends": "@jmlweb/tsconfig-react",
88
+ "compilerOptions": {
89
+ "outDir": "./dist",
90
+ "baseUrl": ".",
91
+ "paths": {
92
+ "@/*": ["./src/*"]
93
+ }
94
+ },
95
+ "include": ["src"],
96
+ "exclude": ["node_modules", "dist"]
97
+ }
98
+ ```
99
+
100
+ ## 📋 Configuration Details
101
+
102
+ ### What's Included
103
+
104
+ This configuration extends `@jmlweb/tsconfig-base` and adds:
105
+
106
+ - ✅ **JSX Support**: `jsx: "react-jsx"` for modern React JSX transform
107
+ - ✅ **DOM Types**: Includes `DOM` and `DOM.Iterable` libs
108
+ - ✅ **Bundler Resolution**: `moduleResolution: "bundler"` for modern build tools
109
+ - ✅ **ESNext Modules**: `module: "ESNext"` for optimal bundling
110
+ - ✅ **All Base Config**: Inherits strict type checking and best practices
111
+
112
+ ### JSX Transform
113
+
114
+ Uses the modern `react-jsx` transform (React 17+), which means:
115
+
116
+ - ✅ No need to import React in every file
117
+ - ✅ Automatic JSX runtime handling
118
+ - ✅ Smaller bundle sizes
119
+ - ✅ Better performance
120
+
121
+ **Example:**
122
+
123
+ ```typescript
124
+ // No React import needed!
125
+ export function Button() {
126
+ return <button>Click me</button>;
127
+ }
128
+ ```
129
+
130
+ ### Module Resolution
131
+
132
+ Uses `bundler` resolution, which is optimized for:
133
+
134
+ - ✅ Vite
135
+ - ✅ Webpack 5+
136
+ - ✅ Rollup
137
+ - ✅ esbuild
138
+ - ✅ Other modern bundlers
139
+
140
+ This allows for better tree-shaking and modern module features.
141
+
142
+ ## 🎯 When to Use
143
+
144
+ Use this configuration when you want:
145
+
146
+ - ✅ React library development
147
+ - ✅ React component libraries
148
+ - ✅ React applications with TypeScript
149
+ - ✅ Modern JSX transform support
150
+ - ✅ Strict type checking for React code
151
+ - ✅ DOM API type support
152
+
153
+ **For non-React TypeScript projects**, use [`@jmlweb/tsconfig-base`](../tsconfig-base) instead.
154
+
155
+ **For internal tooling projects**, use [`@jmlweb/tsconfig-internal`](../tsconfig-internal) instead.
156
+
157
+ ## 🔧 Extending the Configuration
158
+
159
+ You can extend or override the configuration for your specific needs:
160
+
161
+ ```json
162
+ {
163
+ "extends": "@jmlweb/tsconfig-react",
164
+ "compilerOptions": {
165
+ "outDir": "./dist",
166
+ "jsx": "react-jsxdev", // For development builds
167
+ "paths": {
168
+ "@/*": ["./src/*"]
169
+ }
170
+ },
171
+ "include": ["src"],
172
+ "exclude": ["node_modules", "dist"]
173
+ }
174
+ ```
175
+
176
+ ## 📝 Usage with Build Tools
177
+
178
+ ### Vite
179
+
180
+ ```typescript
181
+ // vite.config.ts
182
+ import { defineConfig } from 'vite';
183
+ import react from '@vitejs/plugin-react';
184
+
185
+ export default defineConfig({
186
+ plugins: [react()],
187
+ });
188
+ ```
189
+
190
+ ### Webpack
191
+
192
+ ```typescript
193
+ // webpack.config.ts
194
+ import type { Configuration } from 'webpack';
195
+
196
+ const config: Configuration = {
197
+ module: {
198
+ rules: [
199
+ {
200
+ test: /\.tsx?$/,
201
+ use: 'ts-loader',
202
+ },
203
+ ],
204
+ },
205
+ };
206
+ ```
207
+
208
+ ## 📋 Requirements
209
+
210
+ - **Node.js** >= 18.0.0
211
+ - **TypeScript** >= 5.0.0
212
+ - **React** >= 17.0.0 (for JSX runtime support)
213
+
214
+ ## 📦 Peer Dependencies
215
+
216
+ This package requires the following peer dependencies:
217
+
218
+ - `typescript` (>= 5.0.0)
219
+ - `@jmlweb/tsconfig-base` (^1.0.0)
220
+
221
+ ## 🔗 Related Packages
222
+
223
+ - [`@jmlweb/tsconfig-base`](../tsconfig-base) - Base TypeScript configuration (extended by this package)
224
+ - [`@jmlweb/eslint-config-react`](../eslint-config-react) - ESLint configuration for React libraries
225
+ - [`@jmlweb/prettier-config-base`](../prettier-config-base) - Prettier config for consistent formatting
226
+
227
+ ## 📄 License
228
+
229
+ MIT
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@jmlweb/tsconfig-react",
3
+ "version": "1.0.0",
4
+ "description": "TypeScript configuration for React libraries with JSX support and modern defaults",
5
+ "main": "tsconfig.json",
6
+ "exports": {
7
+ ".": "./tsconfig.json"
8
+ },
9
+ "files": [
10
+ "tsconfig.json",
11
+ "README.md"
12
+ ],
13
+ "keywords": [
14
+ "tsconfig",
15
+ "typescript",
16
+ "config",
17
+ "react",
18
+ "jsx",
19
+ "strict",
20
+ "type-checking"
21
+ ],
22
+ "author": "jmlweb",
23
+ "license": "MIT",
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "https://github.com/jmlweb/tooling.git"
27
+ },
28
+ "bugs": {
29
+ "url": "https://github.com/jmlweb/tooling/issues"
30
+ },
31
+ "homepage": "https://github.com/jmlweb/tooling/tree/main/packages/tsconfig-react#readme",
32
+ "engines": {
33
+ "node": ">=18.0.0"
34
+ },
35
+ "publishConfig": {
36
+ "access": "public"
37
+ },
38
+ "peerDependencies": {
39
+ "@jmlweb/tsconfig-base": "^1.0.0"
40
+ }
41
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "display": "@jmlweb/tsconfig-react",
4
+ "extends": "@jmlweb/tsconfig-base",
5
+ "compilerOptions": {
6
+ "jsx": "react-jsx",
7
+ "module": "ESNext",
8
+ "moduleResolution": "bundler",
9
+ "lib": ["ES2022", "DOM", "DOM.Iterable"]
10
+ }
11
+ }