reactive/
├── src/ # TypeScript/JavaScript source files
│ ├── server/ # Extension backend
│ │ ├── extension.ts # Extension entry point
│ │ └── parser.ts # Parser implementation
│ ├── webview/ # React-based webview
│ │ ├── App.jsx # Main webview component
│ │ └── ... # Other React components
│ └── types.ts # Type definitions
├── dist/ # Compiled distribution files
├── out/ # Compiled output
└── test/ # Test files
The extension consists of two main parts:
- Backend (
src/server/
): Handles VS Code integration - Webview (
src/webview/
): Provides the UI
- Work in
src/server/extension.ts
for VS Code API integration - Implement parsing logic in
src/server/parser.ts
- Use VS Code Extension API for:
- Command registration
- TreeView providers
- Webview communication
- Workspace file handling
- React components in
src/webview/
- Use VS Code webview API for:
- Message passing
- Theme integration
- State management
# Install dependencies
npm install
# Watch mode for development
npm run watch
# Build extension
npm run build
# Package extension
npm run package
- Write tests in
src/test/suite/
- Run tests with:
npm run test
- Test categories:
- Extension tests (
extension.test.ts
) - Parser tests (
parser.test.ts
) - Component tests (
*.test.ts
)
- Extension tests (
- Press F5 in VS Code to launch extension development host
- Use Debug Console for logs
- Set breakpoints in TypeScript files
- Use VS Code's Developer Tools for webview debugging
-
Use VS Code API properly:
// Good vscode.window.createWebviewPanel(...) // Avoid document.createElement(...)
-
Handle disposables:
class MyExtension { private disposables: vscode.Disposable[] = []; activate() { this.disposables.push( vscode.commands.registerCommand(...) ); } deactivate() { this.disposables.forEach(d => d.dispose()); } }
-
Use VS Code's message passing:
// In webview vscode.postMessage({ type: 'update', data: {...} }); // In extension panel.webview.onDidReceiveMessage(message => {...});
-
Follow VS Code's theme:
/* Use VS Code's theme variables */ color: var(--vscode-editor-foreground); background: var(--vscode-editor-background);
- Lazy load webview content
- Use proper activation events
- Minimize extension size
- Cache parsed results
- Webview content security policy
- Extension context disposal
- Resource loading in webviews
- Extension activation events
- Update
package.json
metadata - Test in clean environment
- Create changelog entry
- Package extension:
vsce package
- Publish:
vsce publish