|
| 1 | +# `@vsce/create` |
| 2 | + |
| 3 | +> 🦕 The **Deno-native** scaffolding tool for modern, dual-runtime VS Code extensions |
| 4 | +
|
| 5 | +[](https://jsr.io/@vsce) |
| 6 | +[](https://jsr.io/@vsce/create) |
| 7 | +[](https://jsr.io/@vsce/create/score) |
| 8 | +[](https://github.com/cursor-ide/vsce-create/actions/workflows/update.yml) |
| 9 | +[](https://github.com/cursor-ide/vsce-create/commits/main) |
| 10 | +[](./LICENSE) |
| 11 | + |
| 12 | +`@vsce/create` bootstraps **Deno-first**, **web-compatible** VS Code extensions in seconds. Each project it generates is ready to build with [`@vsce/bundler`](https://jsr.io/@vsce/bundler) and ships with type-safe VS Code APIs via [`@typed/vscode`](https://jsr.io/@typed/vscode). |
| 13 | + |
| 14 | +> **Heads-up!** `@vsce/create` is the low-level *scaffolding engine* used internally by [`@vsce/cli`](https://jsr.io/@vsce/cli) — our all-in-one, fully-featured development suite. If you want the entire toolchain (project generation, dev server, bundling, testing, publishing) in one command, install **`@vsce/cli`** instead. |
| 15 | +
|
| 16 | +--- |
| 17 | + |
| 18 | +## ✨ Features |
| 19 | + |
| 20 | +| Category | Details | |
| 21 | +|----------|---------| |
| 22 | +| 🦕 **Deno-Native** | No Node.js toolchain required—scaffolds projects you can run & build with Deno only. | |
| 23 | +| 🌐 **Dual Runtime** | Templates target both Desktop and Web extension hosts out-of-the-box (`extensionKind: ["workspace", "web"]`). | |
| 24 | +| 🏗️ **Rich Templates** | `basic`, `treeview`, `webview`, and `language-server` templates plus shared utilities. | |
| 25 | +| 📦 **Bundler-Ready** | Generates a `scripts/build.ts` that calls `@vsce/bundler` for a single-file, web-safe bundle. | |
| 26 | +| 🔧 **VS Code Tasks** | Emits `.vscode/tasks.json` & `.vscode/launch.json` for one-click build, test & debug. | |
| 27 | +| ✅ **Strict Types** | Uses `@typed/vscode` definitions with full TypeScript `--strict` compliance. | |
| 28 | + |
| 29 | +--- |
| 30 | + |
| 31 | +## 📥 Installation |
| 32 | + |
| 33 | +```bash |
| 34 | +# Add to your Deno project (recommended) |
| 35 | +deno add @vsce/create |
| 36 | +``` |
| 37 | + |
| 38 | +or run directly without installation: |
| 39 | + |
| 40 | +```bash |
| 41 | +deno run -A jsr:@vsce/create@latest init my-extension |
| 42 | +``` |
| 43 | + |
| 44 | +> `@vsce/create` targets **Deno ≥1.44** and **VS Code ≥1.90**. |
| 45 | +
|
| 46 | +--- |
| 47 | + |
| 48 | +## 🚀 Quick Start |
| 49 | + |
| 50 | +```bash |
| 51 | +# Scaffold a Tree View extension |
| 52 | +deno run -A jsr:@vsce/create init my-treeview --template treeview |
| 53 | +cd my-treeview |
| 54 | + |
| 55 | +# Build the extension (outputs dist/extension.js) |
| 56 | +deno task build |
| 57 | + |
| 58 | +# Test everything |
| 59 | +deno task test |
| 60 | +``` |
| 61 | + |
| 62 | +Resulting structure (example `treeview`): |
| 63 | + |
| 64 | +```text |
| 65 | + my-treeview/ |
| 66 | +├── README.md # template-specific doc |
| 67 | +├── deno.json # import map + tasks + lint/fmt |
| 68 | +├── jsr.json # JSR package meta |
| 69 | +├── package.json # VS Code extension manifest |
| 70 | +├── scripts/ |
| 71 | +│ └── build.ts # calls @vsce/bundler |
| 72 | +├── src/ |
| 73 | +│ └── extension.ts # your entry point |
| 74 | +└── .vscode/ |
| 75 | + ├── extensions.json # recommended VS Code extensions |
| 76 | + ├── tasks.json # build / test tasks |
| 77 | + └── launch.json # debug configuration |
| 78 | +``` |
| 79 | + |
| 80 | +--- |
| 81 | + |
| 82 | +## 🗂️ Available Templates |
| 83 | + |
| 84 | +| Template | Description | |
| 85 | +|----------|-------------| |
| 86 | +| `basic` | Minimal “Hello World” command—perfect seed for small utilities. | |
| 87 | +| `treeview` | Demonstrates `TreeDataProvider`, custom view registration and refresh command. | |
| 88 | +| `webview` | Shows how to create a Webview panel with static HTML content. | |
| 89 | +| `language-server` | Runs a minimal language server in a Web Worker using `vscode-languageclient/browser`. | |
| 90 | + |
| 91 | +--- |
| 92 | + |
| 93 | +## 🔄 Development Workflow |
| 94 | + |
| 95 | +1. **Start coding** inside `src/extension.ts` (or additional modules). |
| 96 | + VS Code + the [Deno extension](https://marketplace.visualstudio.com/items?itemName=denoland.vscode-deno) give you instant type-checking and IntelliSense. |
| 97 | +2. **Press `F5`** to run the *Run Extension* launch target (uses Deno to execute `scripts/build.ts`). |
| 98 | +3. **Run tests** with `deno task test` (generated for you). |
| 99 | + All templates include example tests you can extend. |
| 100 | +4. **Bundle** with `deno task build` for production. The output `dist/extension.js` works for both desktop and web versions of VS Code. |
| 101 | + |
| 102 | +--- |
| 103 | + |
| 104 | +### Web Extension Support |
| 105 | + |
| 106 | +#### Why Web Extensions? |
| 107 | + |
| 108 | +This package is optimized for the **VSCode Web Extensions** runtime as our **pragmatic path to bringing VSCode extension development to Deno**. While our ideal would be full parity with the Node.js extension development environment, the web extension runtime represents the best available approach given current VSCode architecture limitations. |
| 109 | + |
| 110 | +**The Reality:** |
| 111 | + |
| 112 | +- 🎯 **Goal**: Enable Deno-native VSCode extension development |
| 113 | +- ⚠️ **Challenge**: VSCode's extension host is deeply integrated with Node.js |
| 114 | +- ✅ **Solution**: Leverage the web extension runtime for Deno compatibility |
| 115 | +- 🪄 **Future**: Working toward fuller Node.js runtime parity as the ecosystem evolves |
| 116 | + |
| 117 | +#### Universal Compatibility |
| 118 | + |
| 119 | +The web extension runtime enables you to create extensions that run **everywhere** - both desktop VSCode and web-based environments (vscode.dev, github.dev, GitHub Codespaces): |
| 120 | + |
| 121 | +```typescript |
| 122 | +import * as vscode from "@typed/vscode"; |
| 123 | + |
| 124 | +// Web extensions run on BOTH desktop and web VSCode |
| 125 | +export function activate(context: vscode.ExtensionContext): void { |
| 126 | + // Full VSCode API support: TreeView, Commands, Language Features, etc. |
| 127 | + const provider = new MyTreeDataProvider(); |
| 128 | + vscode.window.createTreeView('myView', { treeDataProvider: provider }); |
| 129 | + |
| 130 | + // Limitation: Node.js APIs are not available (browser sandbox restrictions) |
| 131 | + // However, we can use Deno's web API's as a drop-in replacement for some Node.js APIs |
| 132 | + // The extension works identically on desktop and web! |
| 133 | +} |
| 134 | +``` |
| 135 | + |
| 136 | +**Key Benefits:** |
| 137 | + |
| 138 | +- ✅ **Universal compatibility** - One extension runs on desktop AND web VSCode |
| 139 | +- ✅ **Full VSCode API access** - Commands, UI, language features, etc. |
| 140 | +- ✅ **Modern deployment** - Works in vscode.dev, github.dev, Codespaces |
| 141 | +- ⚠️ **Browser limitations** - No Node.js/filesystem APIs (applies to web runtime only) |
| 142 | + |
| 143 | +## 🚧 Deno VSCode Extension Ecosystem (WIP) 🚧 |
| 144 | + |
| 145 | +`@typed/vscode` is part of a complete ecosystem for Deno-based VSCode extension development. Explore these complementary packages: |
| 146 | + |
| 147 | +### 🛠️ Development Tools |
| 148 | + |
| 149 | +**[@vsce/cli](https://jsr.io/@vsce/cli)** - Command-line tools for Deno VSCode extensions |
| 150 | + |
| 151 | +```bash |
| 152 | +deno add @vsce/cli |
| 153 | +``` |
| 154 | + |
| 155 | +- Project scaffolding and templates |
| 156 | +- Development server with hot reload |
| 157 | +- Build and packaging utilities |
| 158 | +- Extension testing and validation |
| 159 | + |
| 160 | +**[@vsce/create](https://jsr.io/@vsce/create)** - Project generator for new extensions |
| 161 | + |
| 162 | +```bash |
| 163 | +deno add @vsce/create |
| 164 | +``` |
| 165 | + |
| 166 | +- Interactive project setup |
| 167 | +- Multiple template options (basic, language server, tree view, etc.) |
| 168 | +- Deno-optimized project structure |
| 169 | +- Best practices and conventions built-in |
| 170 | + |
| 171 | +### 🔧 Build and Bundle |
| 172 | + |
| 173 | +**[@vsce/bundler](https://jsr.io/@vsce/bundler)** - Web extension bundler for Deno |
| 174 | + |
| 175 | +```bash |
| 176 | +deno add @vsce/bundler |
| 177 | +``` |
| 178 | + |
| 179 | +- Bundle Deno code for VSCode web extensions |
| 180 | +- Tree shaking and optimization |
| 181 | +- Source map support |
| 182 | +- Multi-target builds (desktop + web) |
| 183 | + |
| 184 | +### 🧪 Testing Framework |
| 185 | + |
| 186 | +**[@vsce/testing](https://jsr.io/@vsce/testing)** - Testing utilities for VSCode extensions |
| 187 | + |
| 188 | +```bash |
| 189 | +deno add @vsce/testing |
| 190 | +``` |
| 191 | + |
| 192 | +- Mock VSCode APIs for unit testing |
| 193 | +- Extension host simulation |
| 194 | +- Language server testing utilities |
| 195 | +- TreeView and UI component testing |
| 196 | + |
| 197 | +### 📚 Complete Example |
| 198 | + |
| 199 | +```typescript |
| 200 | +// extension.ts - Built with the full @vsce ecosystem |
| 201 | +import * as vscode from "@typed/vscode"; |
| 202 | +import { createLanguageServer } from "@vsce/cli"; |
| 203 | +import { MockExtensionContext } from "@vsce/testing"; |
| 204 | + |
| 205 | +export async function activate(context: vscode.ExtensionContext): Promise<void> { |
| 206 | + // Full ecosystem integration example |
| 207 | + const server = await createLanguageServer({ |
| 208 | + name: 'my-language-server', |
| 209 | + languages: ['typescript', 'javascript'] |
| 210 | + }); |
| 211 | + |
| 212 | + context.subscriptions.push( |
| 213 | + vscode.languages.registerHoverProvider(['typescript'], server), |
| 214 | + vscode.languages.registerCompletionItemProvider(['typescript'], server) |
| 215 | + ); |
| 216 | +} |
| 217 | +``` |
| 218 | + |
| 219 | +## Runtime Compatibility |
| 220 | + |
| 221 | +| Environment | Support | Notes | |
| 222 | +|-------------|---------|-------| |
| 223 | +| **VSCode Desktop** | ✅ Full | All APIs available | |
| 224 | +| **VSCode Web** | ✅ Most APIs | No Node.js/filesystem APIs | |
| 225 | +| **Deno Runtime** | ✅ Type-checking | For development and testing | |
| 226 | +| **GitHub Codespaces** | ✅ Full | Web + server APIs | |
| 227 | +| **vscode.dev** | ✅ Web APIs | Browser-based development | |
| 228 | + |
| 229 | +--- |
| 230 | + |
| 231 | +## 📚 Docs & Resources |
| 232 | + |
| 233 | +- VS Code Extension API: <https://code.visualstudio.com/api> |
| 234 | +- VS Code Web Extensions Guide: <https://code.visualstudio.com/api/extension-guides/web-extensions> |
| 235 | +- Deno Runtime Documentation: <https://docs.deno.com> |
| 236 | +- JSR Package Registry: <https://jsr.io> |
| 237 | + |
| 238 | +--- |
| 239 | + |
| 240 | +## License |
| 241 | + |
| 242 | +MIT License - see [LICENSE](./LICENSE) for details. |
| 243 | + |
| 244 | +--- |
| 245 | + |
| 246 | +**Happy coding with Deno + VSCode! 🦕⚡** |
| 247 | + |
| 248 | +*Part of the [@vsce ecosystem](https://jsr.io/@vsce) for Deno-based VSCode extension development.* |
0 commit comments