@jmlweb/tsconfig-astro 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 +236 -0
  2. package/package.json +43 -0
  3. package/tsconfig.json +11 -0
package/README.md ADDED
@@ -0,0 +1,236 @@
1
+ # @jmlweb/tsconfig-astro
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@jmlweb/tsconfig-astro)](https://www.npmjs.com/package/@jmlweb/tsconfig-astro)
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
+ [![Astro](https://img.shields.io/badge/Astro-4%2B-FF5D01.svg)](https://astro.build/)
8
+
9
+ > TypeScript configuration for Astro projects. Extends `@jmlweb/tsconfig-base` with JSX support (preserve mode), 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**: JSX preserve mode for Astro's component system
15
+ - 🌐 **DOM Types**: Includes DOM and DOM.Iterable libs for browser APIs
16
+ - 📦 **Bundler Resolution**: Optimized `moduleResolution: "bundler"` for Astro's build system
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-astro typescript astro @jmlweb/tsconfig-base
24
+ ```
25
+
26
+ ## 🚀 Quick Start
27
+
28
+ Create a `tsconfig.json` file in your Astro project root:
29
+
30
+ ```json
31
+ {
32
+ "extends": "@jmlweb/tsconfig-astro",
33
+ "include": ["src"],
34
+ "exclude": ["node_modules", "dist"]
35
+ }
36
+ ```
37
+
38
+ ## 💡 Examples
39
+
40
+ ### Basic Astro Setup
41
+
42
+ ```json
43
+ {
44
+ "extends": "@jmlweb/tsconfig-astro",
45
+ "include": ["src"],
46
+ "exclude": ["node_modules", "dist"]
47
+ }
48
+ ```
49
+
50
+ ### With Custom Output Directory
51
+
52
+ ```json
53
+ {
54
+ "extends": "@jmlweb/tsconfig-astro",
55
+ "compilerOptions": {
56
+ "outDir": "./dist",
57
+ "rootDir": "./src"
58
+ },
59
+ "include": ["src"],
60
+ "exclude": ["node_modules", "dist"]
61
+ }
62
+ ```
63
+
64
+ ### With Path Mapping
65
+
66
+ ```json
67
+ {
68
+ "extends": "@jmlweb/tsconfig-astro",
69
+ "compilerOptions": {
70
+ "baseUrl": ".",
71
+ "paths": {
72
+ "@/*": ["./src/*"],
73
+ "@/components/*": ["./src/components/*"]
74
+ }
75
+ },
76
+ "include": ["src"],
77
+ "exclude": ["node_modules", "dist"]
78
+ }
79
+ ```
80
+
81
+ ### With Additional Compiler Options
82
+
83
+ ```json
84
+ {
85
+ "extends": "@jmlweb/tsconfig-astro",
86
+ "compilerOptions": {
87
+ "outDir": "./dist",
88
+ "noEmit": true
89
+ },
90
+ "include": ["src"],
91
+ "exclude": ["node_modules", "dist"]
92
+ }
93
+ ```
94
+
95
+ ## 📋 Configuration Details
96
+
97
+ ### What's Included
98
+
99
+ This configuration extends `@jmlweb/tsconfig-base` and adds:
100
+
101
+ - ✅ **JSX Support**: `jsx: "preserve"` for Astro's component system (Astro handles JSX transformation)
102
+ - ✅ **DOM Types**: Includes `DOM` and `DOM.Iterable` libs
103
+ - ✅ **Bundler Resolution**: `moduleResolution: "bundler"` optimized for Astro's Vite-based build system
104
+ - ✅ **ESNext Modules**: `module: "ESNext"` for optimal bundling
105
+ - ✅ **All Base Config**: Inherits strict type checking and best practices
106
+
107
+ ### JSX Preserve Mode
108
+
109
+ Uses `jsx: "preserve"` mode, which means:
110
+
111
+ - ✅ TypeScript preserves JSX syntax as-is
112
+ - ✅ Astro handles JSX transformation during build
113
+ - ✅ Works seamlessly with Astro components (`.astro` files)
114
+ - ✅ Supports JSX in `.tsx` files when using Astro's component islands
115
+
116
+ **Example:**
117
+
118
+ ```typescript
119
+ // src/components/Counter.tsx
120
+ export function Counter() {
121
+ return <button>Click me</button>;
122
+ }
123
+ ```
124
+
125
+ ### Module Resolution
126
+
127
+ Uses `bundler` resolution, which is optimized for:
128
+
129
+ - ✅ Astro's Vite-based build system
130
+ - ✅ Modern bundlers (Vite, esbuild, Rollup)
131
+ - ✅ Better tree-shaking and modern module features
132
+ - ✅ Optimal performance with Astro's build pipeline
133
+
134
+ ## 🎯 When to Use
135
+
136
+ Use this configuration when you want:
137
+
138
+ - ✅ Astro project development
139
+ - ✅ TypeScript support in Astro components
140
+ - ✅ JSX support in Astro component islands
141
+ - ✅ Strict type checking for Astro code
142
+ - ✅ DOM API type support
143
+ - ✅ Modern bundler-optimized configuration
144
+
145
+ **For React projects**, use [`@jmlweb/tsconfig-react`](../tsconfig-react) instead.
146
+
147
+ **For Next.js projects**, use [`@jmlweb/tsconfig-nextjs`](../tsconfig-nextjs) instead.
148
+
149
+ **For non-React TypeScript projects**, use [`@jmlweb/tsconfig-base`](../tsconfig-base) instead.
150
+
151
+ ## 🔧 Extending the Configuration
152
+
153
+ You can extend or override the configuration for your specific needs:
154
+
155
+ ```json
156
+ {
157
+ "extends": "@jmlweb/tsconfig-astro",
158
+ "compilerOptions": {
159
+ "baseUrl": ".",
160
+ "paths": {
161
+ "@/*": ["./src/*"],
162
+ "@/components/*": ["./src/components/*"],
163
+ "@/layouts/*": ["./src/layouts/*"]
164
+ },
165
+ "noEmit": true
166
+ },
167
+ "include": ["src"],
168
+ "exclude": ["node_modules", "dist"]
169
+ }
170
+ ```
171
+
172
+ ### Astro-specific Options
173
+
174
+ Astro projects typically set `noEmit: true` since Astro handles the build process:
175
+
176
+ ```json
177
+ {
178
+ "extends": "@jmlweb/tsconfig-astro",
179
+ "compilerOptions": {
180
+ "noEmit": true
181
+ },
182
+ "include": ["src"],
183
+ "exclude": ["node_modules", "dist"]
184
+ }
185
+ ```
186
+
187
+ ## 📝 Usage with Scripts
188
+
189
+ TypeScript compilation is typically handled by Astro's build system. For type checking:
190
+
191
+ ```json
192
+ {
193
+ "scripts": {
194
+ "typecheck": "tsc --noEmit",
195
+ "build": "astro build",
196
+ "dev": "astro dev"
197
+ }
198
+ }
199
+ ```
200
+
201
+ ### Usage with Astro
202
+
203
+ Astro automatically uses your `tsconfig.json` for type checking. Your Astro config doesn't need TypeScript-specific settings:
204
+
205
+ ```typescript
206
+ // astro.config.mjs
207
+ import { defineConfig } from 'astro/config';
208
+
209
+ export default defineConfig({
210
+ // Astro config...
211
+ });
212
+ ```
213
+
214
+ ## 📋 Requirements
215
+
216
+ - **Node.js** >= 18.0.0
217
+ - **TypeScript** >= 5.0.0
218
+ - **Astro** >= 4.0.0
219
+
220
+ ## 📦 Peer Dependencies
221
+
222
+ This package requires the following peer dependencies:
223
+
224
+ - `typescript` (>= 5.0.0)
225
+ - `astro` (>= 4.0.0)
226
+ - `@jmlweb/tsconfig-base` (^1.0.1)
227
+
228
+ ## 🔗 Related Packages
229
+
230
+ - [`@jmlweb/tsconfig-base`](../tsconfig-base) - Base TypeScript configuration (extended by this package)
231
+ - [`@jmlweb/eslint-config-base`](../eslint-config-base) - ESLint configuration for TypeScript projects
232
+ - [`@jmlweb/prettier-config-base`](../prettier-config-base) - Prettier config for consistent formatting
233
+
234
+ ## 📄 License
235
+
236
+ MIT
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@jmlweb/tsconfig-astro",
3
+ "version": "1.0.0",
4
+ "description": "TypeScript configuration for Astro projects 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
+ "CHANGELOG.md"
13
+ ],
14
+ "keywords": [
15
+ "config",
16
+ "astro",
17
+ "jsx",
18
+ "strict",
19
+ "tsconfig",
20
+ "type-checking",
21
+ "typescript"
22
+ ],
23
+ "author": "jmlweb",
24
+ "license": "MIT",
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "https://github.com/jmlweb/tooling.git"
28
+ },
29
+ "bugs": "https://github.com/jmlweb/tooling/issues",
30
+ "homepage": "https://github.com/jmlweb/tooling/tree/main/packages/tsconfig-astro#readme",
31
+ "engines": {
32
+ "node": ">=18.0.0"
33
+ },
34
+ "publishConfig": {
35
+ "access": "public"
36
+ },
37
+ "peerDependencies": {
38
+ "@jmlweb/tsconfig-base": "^1.0.1",
39
+ "astro": ">=4.0.0",
40
+ "typescript": ">=5.0.0"
41
+ },
42
+ "scripts": {}
43
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "display": "@jmlweb/tsconfig-astro",
4
+ "extends": "@jmlweb/tsconfig-base",
5
+ "compilerOptions": {
6
+ "jsx": "preserve",
7
+ "module": "ESNext",
8
+ "moduleResolution": "bundler",
9
+ "lib": ["ES2022", "DOM", "DOM.Iterable"]
10
+ }
11
+ }