Scaffold the VS Code extension #1

Open
opened 2026-10-19 02:05:56 -07:00 by justine · 0 comments
Owner

Goal

Scaffold accompany as a TypeScript VS Code extension that builds, launches in an Extension Development Host, runs tests, and packages to a .vsix.

Decision needed

How to create the files:

Option What it means
yo code Run npx --package yo --package generator-code -- yo code, pick New Extension (TypeScript), esbuild, npm. Fast; generator output is then trimmed to match our conventions.
By hand Write each file in a pairing session so every line is reviewed as it lands.

What yo is

yo is the command-line tool of Yeoman, a general project scaffolder. On its own it creates nothing: it runs "generators", npm packages that each know how to create one kind of project. It asks a few questions, then writes the files.

The generator for VS Code extensions is generator-code, maintained by Microsoft. yo code runs it. It creates package.json (the extension manifest), src/extension.ts with a sample command, tsconfig.json, the bundler config, a test setup, and .vscode/launch.json and tasks.json for F5 debugging.

The npx --package yo --package generator-code -- yo code form runs both packages once without installing them globally. After scaffolding, neither stays in the project: they are not dependencies of the extension.

Setup, per the official docs

Area Practice Source
Language TypeScript, entry point src/extension.ts Your First Extension
Bundling esbuild bundles to one file, dist/extension.js, format: 'cjs', platform: 'node', external: ['vscode']; minify and drop sourcemaps only with --production Bundling Extensions
Type checking esbuild strips types without checking them, so tsc --noEmit runs beside it (check-types, watch:tsc) Bundling Extensions
Scripts compile, check-types, watch (esbuild and tsc in parallel), package, vscode:prepublish -> npm run package Bundling Extensions
Activation Activate only when needed. Since 1.74, commands, views, languages, customEditors, and authentication contributions infer their activation events; set engines.vscode to ^1.74.0 or newer Activation Events, 1.74 notes
Tests @vscode/test-cli and @vscode/test-electron, .vscode-test.mjs config, "test": "vscode-test"; Mocha runs inside a real VS Code; --coverage supported Testing Extensions
Packaging @vscode/vsce: vsce package builds the .vsix; .vscodeignore keeps sources out of it Publishing Extensions
UI Follow the UX guidelines; limit notifications, one at a time, with a "Do not show again" option UX Guidelines

Done when

  • npm run compile type-checks and bundles with no errors
  • F5 opens an Extension Development Host with the extension active
  • npm test runs at least one test through vscode-test and passes
  • npx vsce package produces a .vsix that contains dist/ and no src/

Reference docs indexed in mcp-docs

Already indexed: vscode extension api, esbuild, google-typescript-style, oxlint, vitest.
Queued on 2026-10-19: mocha, typescript, @vscode/test-cli, @vscode/test-electron, @vscode/vsce, generator-code.

## Goal Scaffold `accompany` as a TypeScript VS Code extension that builds, launches in an Extension Development Host, runs tests, and packages to a `.vsix`. ## Decision needed How to create the files: | Option | What it means | |---|---| | `yo code` | Run `npx --package yo --package generator-code -- yo code`, pick New Extension (TypeScript), esbuild, npm. Fast; generator output is then trimmed to match our conventions. | | By hand | Write each file in a pairing session so every line is reviewed as it lands. | ### What `yo` is `yo` is the command-line tool of [Yeoman](https://yeoman.io/), a general project scaffolder. On its own it creates nothing: it runs "generators", npm packages that each know how to create one kind of project. It asks a few questions, then writes the files. The generator for VS Code extensions is [`generator-code`](https://github.com/microsoft/vscode-generator-code), maintained by Microsoft. `yo code` runs it. It creates `package.json` (the extension manifest), `src/extension.ts` with a sample command, `tsconfig.json`, the bundler config, a test setup, and `.vscode/launch.json` and `tasks.json` for F5 debugging. The `npx --package yo --package generator-code -- yo code` form runs both packages once without installing them globally. After scaffolding, neither stays in the project: they are not dependencies of the extension. ## Setup, per the official docs | Area | Practice | Source | |---|---|---| | Language | TypeScript, entry point `src/extension.ts` | [Your First Extension](https://code.visualstudio.com/api/get-started/your-first-extension) | | Bundling | esbuild bundles to one file, `dist/extension.js`, `format: 'cjs'`, `platform: 'node'`, `external: ['vscode']`; minify and drop sourcemaps only with `--production` | [Bundling Extensions](https://code.visualstudio.com/api/working-with-extensions/bundling-extension) | | Type checking | esbuild strips types without checking them, so `tsc --noEmit` runs beside it (`check-types`, `watch:tsc`) | Bundling Extensions | | Scripts | `compile`, `check-types`, `watch` (esbuild and tsc in parallel), `package`, `vscode:prepublish` -> `npm run package` | Bundling Extensions | | Activation | Activate only when needed. Since 1.74, `commands`, `views`, `languages`, `customEditors`, and `authentication` contributions infer their activation events; set `engines.vscode` to `^1.74.0` or newer | [Activation Events](https://code.visualstudio.com/api/references/activation-events), [1.74 notes](https://code.visualstudio.com/updates/v1_74) | | Tests | `@vscode/test-cli` and `@vscode/test-electron`, `.vscode-test.mjs` config, `"test": "vscode-test"`; Mocha runs inside a real VS Code; `--coverage` supported | [Testing Extensions](https://code.visualstudio.com/api/working-with-extensions/testing-extension) | | Packaging | `@vscode/vsce`: `vsce package` builds the `.vsix`; `.vscodeignore` keeps sources out of it | [Publishing Extensions](https://code.visualstudio.com/api/working-with-extensions/publishing-extension) | | UI | Follow the UX guidelines; limit notifications, one at a time, with a "Do not show again" option | [UX Guidelines](https://code.visualstudio.com/api/ux-guidelines/overview) | ## Done when - [ ] `npm run compile` type-checks and bundles with no errors - [ ] F5 opens an Extension Development Host with the extension active - [ ] `npm test` runs at least one test through `vscode-test` and passes - [ ] `npx vsce package` produces a `.vsix` that contains `dist/` and no `src/` ## Reference docs indexed in mcp-docs Already indexed: `vscode extension api`, `esbuild`, `google-typescript-style`, `oxlint`, `vitest`. Queued on 2026-10-19: `mocha`, `typescript`, `@vscode/test-cli`, `@vscode/test-electron`, `@vscode/vsce`, `generator-code`.
Sign in to join this conversation.
No labels
enhancement
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
justine/accompany#1
No description provided.