addons/vscode/CONTRIBUTING.mdblame
View source
b69ab311# Sapling VS Code extension
b69ab312
b69ab313This folder contains the VS Code extension,
b69ab314including the Sapling SCM provider and embedded ISL.
b69ab315
b69ab316> NOTE: This file acts as the technical `README` for the `vscode/` folder,
b69ab317> while `README.md` is the user-facing description of the extension visible in the extension marketplace.
b69ab318
b69ab319The VS Code extension consists of two forms of JavaScript:
b69ab3110
b69ab3111- Extension code, running in the VS Code extension host process.
b69ab3112 This code uses the VS Code API and acts like a node process.
b69ab3113- Webview code (of ISL), running in a VS Code webview.
b69ab3114 This code cannot use the VS Code API, and acts like it's running in a browser.
b69ab3115
b69ab3116The two are built separately, and communicate via message passing.
b69ab3117Unlike web `sl` in `isl-server/proxy`, this does not use WebSockets
b69ab3118but rather VS Code's own message passing system (which still works across remote connections).
b69ab3119
b69ab3120## Building & Running
b69ab3121
b69ab3122Build artifacts live in `./dist`.
b69ab3123
b69ab3124**Development**
b69ab3125
b69ab3126- `yarn watch-extension` to compile extension code
b69ab3127- `yarn watch-webview` to compile webview code
b69ab3128
b69ab3129**Production**
b69ab3130
b69ab3131- `yarn build-extension` to build production extension code
b69ab3132- `yarn build-webview` to build production webview code
b69ab3133
b69ab3134**Dogfooding**
b69ab3135
b69ab3136You can use a development build of the VS Code extension by symlinking into this folder,
b69ab3137since `package.json` points to `dist/`:
b69ab3138
b69ab3139```sh
b69ab3140ln -s ./vscode ~/.vscode/extensions/meta.sapling-scm-100.0.0-dev
b69ab3141```
b69ab3142
b69ab3143**Debugging**
b69ab3144
b69ab3145VS Code webview source maps don't load automatically, since we produce separate `.js.map` files
b69ab3146instead of inline source maps. The VS Code webview resource system doesn't seem to load these correctly.
b69ab3147
b69ab3148To get source maps in the webview, you need to load them manually:
b69ab3149
b69ab31501. Open ISL in VS Code
b69ab31512. Open the developer tools from the Help menu
b69ab31523. Go to the "console" tab
b69ab31534. Change "top" to the "pending-frame" that corresponds to ISL
b69ab31545. Open `webview.js` in the "sources" tab (e.g. from a stack trace)
b69ab31556. Right-click on the file, choose "Add source map..."
b69ab31567. Enter the full URL to the `.map` file: `file:///path/to/addons/vscode/dist/webview/webview.js.map`
b69ab3157
b69ab3158Enjoy your proper stack traces, files, and breakpoints! :D