@jmlweb/tsconfig-react 1.0.4 → 1.0.5
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/CHANGELOG.md +8 -0
- package/README.md +33 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
## 📦 Installation
|
|
21
21
|
|
|
22
22
|
```bash
|
|
23
|
-
|
|
23
|
+
pnpm add -D @jmlweb/tsconfig-react typescript @jmlweb/tsconfig-base
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
> 💡 **Upgrading from a previous version?** See the [Migration Guide](#-migration-guide) for breaking changes and upgrade instructions.
|
|
@@ -99,6 +99,38 @@ Create a `tsconfig.json` file in your project root:
|
|
|
99
99
|
}
|
|
100
100
|
```
|
|
101
101
|
|
|
102
|
+
## 🤔 Why Use This?
|
|
103
|
+
|
|
104
|
+
> **Philosophy**: React development should leverage modern JSX transforms and bundler optimizations for the best developer experience and runtime performance.
|
|
105
|
+
|
|
106
|
+
This package provides a TypeScript configuration specifically optimized for React library and application development. It extends the strict base configuration while adding React-specific settings that work seamlessly with modern build tools and the latest React features.
|
|
107
|
+
|
|
108
|
+
### Design Decisions
|
|
109
|
+
|
|
110
|
+
**Modern JSX Transform (`jsx: "react-jsx"`)**: Uses the new JSX runtime from React 17+
|
|
111
|
+
|
|
112
|
+
- **Why**: Eliminates the need to import React in every file, reduces bundle size, and improves build performance. The automatic JSX runtime is the recommended approach for all modern React projects
|
|
113
|
+
- **Trade-off**: Requires React 17+ (which is several years old at this point). Older projects need to upgrade
|
|
114
|
+
- **When to override**: Only if you're stuck on React 16 or need the classic `React.createElement` transform for legacy compatibility
|
|
115
|
+
|
|
116
|
+
**Bundler Module Resolution (`moduleResolution: "bundler"`)**: Optimized for modern build tools
|
|
117
|
+
|
|
118
|
+
- **Why**: Modern bundlers like Vite, Webpack 5+, and esbuild benefit from bundler resolution, which enables better tree-shaking and handles modern module features. This matches how your build tool actually resolves modules
|
|
119
|
+
- **Trade-off**: Not suitable for direct Node.js execution without a build step. But React projects always use bundlers anyway
|
|
120
|
+
- **When to override**: Never for React libraries - this is the optimal choice. Use `@jmlweb/tsconfig-node` for Node.js projects instead
|
|
121
|
+
|
|
122
|
+
**DOM Type Definitions (`lib: ["ES2022", "DOM", "DOM.Iterable"]`)**: Includes browser APIs
|
|
123
|
+
|
|
124
|
+
- **Why**: React components interact with the DOM. Including DOM types prevents type errors when using `window`, `document`, event handlers, and other browser APIs that are fundamental to React development
|
|
125
|
+
- **Trade-off**: Includes types you won't use in server-side code. But React Server Components and SSR still need DOM types for shared components
|
|
126
|
+
- **When to override**: For purely server-side React code (rare). But even Next.js server components often need DOM types for shared code
|
|
127
|
+
|
|
128
|
+
**ESNext Modules (`module: "ESNext"`)**: Modern module syntax for optimal bundling
|
|
129
|
+
|
|
130
|
+
- **Why**: Bundlers work best with ESNext modules. They can perform advanced optimizations like scope hoisting and dead code elimination. Your bundler transpiles to the target environment anyway
|
|
131
|
+
- **Trade-off**: Can't run the TypeScript output directly in Node.js without a bundler. But React projects always use bundlers
|
|
132
|
+
- **When to override**: Never for React projects - let your bundler handle the final module format
|
|
133
|
+
|
|
102
134
|
## 📋 Configuration Details
|
|
103
135
|
|
|
104
136
|
### What's Included
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jmlweb/tsconfig-react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "TypeScript configuration for React libraries with JSX support and modern defaults",
|
|
5
5
|
"main": "tsconfig.json",
|
|
6
6
|
"exports": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"@jmlweb/tsconfig-base": "1.0.
|
|
38
|
+
"@jmlweb/tsconfig-base": "1.0.4"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {}
|
|
41
41
|
}
|