Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/metal-berries-boil.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@virtual-live-lab/tsconfig": patch
---

Add Cloudflare Workers preset
31 changes: 24 additions & 7 deletions packages/tsconfig/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ TypeScript configuration for Virtual Live Lab.

- `astro`: Configuration for Astro.
- `base`: Basic configuration.
- `hono`: Configuration for Hono.
- `cloudflare-workers`: Configuration for Cloudflare Workers.
- `hono`: Configuration for Hono. Automatically extends `cloudflare-workers`.
- `library`: Configuration for library.
- `nextjs`: Configuration for Next.js.
- `react`: Configuration for React.
Expand All @@ -22,10 +23,10 @@ TypeScript configuration for Virtual Live Lab.
## Installation

```bash
npm install @virtual-live-lab/tsconfig --save-dev
npm install typescript @virtual-live-lab/tsconfig --save-dev
```

### Use presets except Astro
### Use Normal presets

```json
// tsconfig.json
Expand All @@ -38,11 +39,11 @@ npm install @virtual-live-lab/tsconfig --save-dev

### Use Astro preset

> [!TIP]
> TypeScript Plugin is required to worker properly outside of VSCode.

```bash
npm install prettier \
@virtual-live-lab/tsconfig \
typescript \
@astrojs/ts-plugin \
npm install @astrojs/ts-plugin \
--save-dev
```

Expand All @@ -55,6 +56,22 @@ npm install prettier \
}
```

### Use Cloudflare Workers preset

```bash
npm install @cloudflare/workers-types \
--save-dev
```

```json
// tsconfig.json
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@virtual-live-lab/tsconfig/cloudflare-workers",
// your configuration
}
```

## License

[MIT](https://choosealicense.com/licenses/mit/)
12 changes: 12 additions & 0 deletions packages/tsconfig/cloudflare-workers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"display": "Cloudflare Workers",
"extends": "./base.json",
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "Bundler",
"lib": ["ESNext"],
"types": ["@cloudflare/workers-types"]
}
}
9 changes: 2 additions & 7 deletions packages/tsconfig/hono.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"display": "Hono",
"extends": "./base.json",
"extends": "./cloudflare-workers.json",
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "Bundler",
"jsx": "react-jsx",
"jsxImportSource": "hono/jsx",
"lib": ["ESNext"],
"types": ["@cloudflare/workers-types"]
"jsxImportSource": "hono/jsx"
}
}
8 changes: 8 additions & 0 deletions packages/tsconfig/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
"files": [
"*.json"
],
"peerDependencies": {
"@cloudflare/workers-types": "^4.20240419.0"
},
"peerDependenciesMeta": {
"@cloudflare/workers-types": {
"optional": true
}
},
"devDependencies": {
"@cloudflare/workers-types": "^4.20240419.0"
},
Expand Down