The Rollercoaster of Building a VSCode Extension – AMA
Some more learnings in writing our own VS Code extension
I’ve made VSCode extension for iOS development
VSCode Extensions
Videos
Hey everyone!
In the last several months, I built a VSCode extension, which you can check out right here. It's called Sherlock - i18n inspector and helps people do i18n/internationalization in their projects. It replaces the famous i18n-ally extension, which hasn't been updated in months and seems unmaintained.
This journey was packed with twists and turns, so I thought I'd drop some lessons learned and open up a discussion for anyone diving into similar projects.
First and foremost, the VSCode extension API is awesome. It was overall a breeze to work with, and the documentation is helpful. Also, if you jump into the vscode Issues on GitHub, they will answer. Huge +1.
But, there were also challenges, and I tried my best to summarize the main ones.
Going Functional: We decided to roll with functional programming. It made our code cleaner and more predictable but integrating with APIs not built for it was like fitting a square peg in a round hole (looking at you, `Tree View API`). It definitely made us think twice about how to handle external libraries without tossing our FP principles out the window.
WebView's: We leaned heavily on WebViews for the snazzy parts of the UI, and let me tell you, it's a wild ride :'). They're super powerful, but the communication setup between the extension and the WebView content is a delicate dance. We had to get really creative with message handling to keep things running smoothly. Also, it seems we are among the first to successfully ship lit Web Components into a WebView because I literally couldn't find anything regarding this topic.
Lifecycle: Keeping track of the extension's lifecycle was a kind of hard. Initializing, adapting to workspace changes, and shutting down without leaving a mess required more attention to detail than I anticipated. (for people not familiar, you basically need to register commands for your actions and a lot of other things).
It's like keeping plates spinning—drop one, and things get messy fast. We are still figuring things out on this end.
Testing: Setting up E2E tests? It took us several days. Trying to mimic real user interactions in a VSCode environment was tougher than expected. We mixed unit tests, integration tests, and a bunch of manual poking around to get it right.
Would love to hear from any of you who've tackled these challenges or are thinking about it. Got any stories or tips?
Disclaimer: This is not to blame anyone's work involved. We're happy to be involved in such a vibrant extension ecosystem & happy to contribute to it by sharing our experience.