sapling/addons/vscode/CONTRIBUTING.md
Evan Krause 3097f75058 Don't include vscode webview source maps in production
Summary:
vscode webviews don't load external (.js.map) source maps automatically. So there's no real point in including source maps for the webview.

I added some instructions to the readme for how to manually use a source map.

We can produce source maps for dev builds so we can do this manual process. But in production, we can just use a dev build to get the source map, instead of having the user have a copy that they can't use.

Reviewed By: quark-zju

Differential Revision: D53146220

fbshipit-source-id: 92ba33afa8141d9dc1e2e9136df2894cb737f786
2024-01-29 09:28:03 -08:00

2.0 KiB

Sapling VS Code extension

This folder contains the VS Code extension, including Sapling SCM provider and embedded ISL.

Note: this file acts the techincal README for the vscode/ folder, while README.md is the user-facing description of the extension visible in the extension marketplace.

The vscode extension consists of two forms of javascript:

  • extension code, running in the vscode extension host process. This code uses the vscode API and acts like a node process.
  • (ISL) webview code, running in a vscode webview. This code cannot use the vscode API, and acts like its running in a browser.

The two are built separately, and communicate via message passing. Unlike web sl in isl-server/proxy, this does not use websockets but rather VS Code's own message passing system (which still works across remoting).

Building & Running

Build artifacts live in ./dist.

Development:

yarn watch-extension to compile extension code yarn watch-webview to compile webview code

Production:

yarn build-extension to build production extension code yarn build-webview to build production extension code

Dogfooding

You can use a development build of the vscode extension by symlinking into this folder, since package.json points to dist/:

ln -s ./vscode ~/.vscode/extensions/meta.sapling-scm-100.0.0-dev

Debugging

VS Code Webview source maps don't load automatically, since we produce separate .js.map files instead of inline source maps. The VS Code webview resource system doesn't seem to load these correctly.

To get source maps in the webview, you need to load them manually:

  • Open ISL in vscode
  • Open the developer tools from the Help menu
  • Go to the "console" tab
  • Change "top" to the "pending-frame" that corresponds to ISL
  • open webview.js in the "sources" tab. (e.g. from a stack trace)
  • right click on the file, choose "Add source map..."
  • enter the full URL to the .map file: file:///path/to/addons/vscode/dist/webview/webview.js.map

Enjoy your proper stack traces, files, breakpoints!