bzm3r
bzm3r6mo ago

VS Code Extension API development with Deno as a runtime?

I'm dipping my toes into VS Code extension development. I only have Deno on my machine (for sanity), so the default template created by yo doesn't work out of the box. But I'd like to use it as a template to get going, and I'm wondering if I can have some help as I walk through this? Actually, is what I'm thinking of doing even possible/sensical?
4 Replies
bzm3r
bzm3r6mo ago
So here's the template generator: https://github.com/microsoft/vscode-generator-code/tree/main/generators/app I'm trying to figure out in particular where this node_modules directory is generated, which basically contains all the crap I would like to use through deno instead, i think but maybe that doesn't matter, because i can refer to a package inside there directly? so I tried that:
import * as vscode from "../../node_modules/@vscode";
import * as vscode from "../../node_modules/@vscode";
which results in the error:
Unable to load a local module: file:///home/bzm3r/personal/test-with-deno/node_modules/@vscode
Please check the file path. deno(no-local)
Unable to load a local module: file:///home/bzm3r/personal/test-with-deno/node_modules/@vscode
Please check the file path. deno(no-local)
So maybe tweaking the template itself is a bad idea, and I ought to be starting more "deno-native"? Actually, this might be relevant reading for me: https://docs.deno.com/runtime/manual/basics/import_maps okay, so running deno cache becomes relevant hmm, turns out yeoman just doesn't work under deno: https://github.com/denoland/deno/issues/19105 this is relevant: https://github.com/narumincho/vscode/tree/main
Deno AI Helper
Deno AI Helper6mo ago
I wasn't able to find the answer to your question in the official Deno documentation. However, I can provide some general insights based on your message. Visual Studio Code extensions are typically developed using Node.js because the VS Code extension API is designed to work with Node.js runtime. Since Deno is not directly compatible with Node.js APIs and modules, using Deno as a runtime for VS Code extension development might not be straightforward. The default template created by yo (Yeoman) for VS Code extensions is set up with the expectation that Node.js is available. It likely includes dependencies and scripts that rely on Node.js-specific features and npm packages, which are not directly compatible with Deno. While it is theoretically possible to create a VS Code extension using Deno, it would require significant effort to adapt the extension API to work with Deno's runtime. This might involve creating or finding equivalent Deno modules for the Node.js modules used by the extension API, and ensuring that the extension's code is compatible with Deno's security model and module resolution. Please note that this advice is not based on the Deno documentation, and I would advise you to double-check the accuracy of the advice given. If you are committed to using Deno for this project, you may need to explore the Deno community for any existing efforts or tools that could help bridge the gap between Deno and the VS Code extension API. Otherwise, it might be more practical to use Node.js for VS Code extension development, as it is the supported runtime for that environment.
Deno AI Helper
Deno AI Helper6mo ago
🦕💚 I'm glad I was able to help!
bzm3r
bzm3r6mo ago
yeah bobot, a bit too late, but basically and surprisingly on point https://zenn-dev.translate.goog/narumincho/articles/deno-vscode-extension?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=en-US&_x_tr_pto=wapp&_x_tr_hist=true TLDR: that person gives up near the end anyway, so yeah. just keep pnpm installed for now. can't go full deno