当前位置:网站首页>我开发了一个利用 Bun 执行 .ts / .js 文件的 VS Code 插件
我开发了一个利用 Bun 执行 .ts / .js 文件的 VS Code 插件
2022-07-31 05:56:00 【Pandy : )】
在 《 还在用 Node.js 吗?试试 Bun.js 》 文章中,看到了一个更快、更强的 JavaScript 运行时的出现,在使用 Bun 过程中,确实感受到了 Bun 运行快速方便,不过每次都从终端执行 bun run xxx.ts 确实有点蠢,刚好一直想尝试 VS Code 插件开发,那就 Action!
- 全局安装创建 VS Code 插件脚手架:
npm install -g yo generator-code
- 执行初始化项目命令:
yo code
* ~ yo code
_-----_ ╭──────────────────────────╮
| | │ Welcome to the Visual │
|--(o)--| │ Studio Code Extension │
`---------´ │ generator! │ ( _´U`_ ) ╰──────────────────────────╯
/___A___\ /
| ~ |
__'.___.'__
´ ` |° ´ Y `
? What type of extension do you want to create? New Extension (TypeScript)
? What's the name of your extension? xxx ? What's the identifier of your extension? xxx
? What's the description of your extension? xxx
? Initialize a git repository? Yes
? Bundle the source code with webpack? Yes
? Which package manager to use? npm
按
Fn5进行调试,VS Code 会自动打开一个新窗口用于调试。在新窗口
Cmd + Shift + P打开Command Palette,输入hello找到Hello World命令并执行它:

可以看到右下角输出了信息:

运行成功 🥳
接下来来了解一下 VS Code 插件。
Vscode 插件有三大核心要素:
- Activation Events:激活事件,在插件被激活后触发事件。
- Contribution Points:投放点,在 package.json 中静态声明去扩展 VS Code 的插件清单。
- VS Code API:插件用到的 API。
VS Code 插件实现机制:

总体来说,VS Code 插件实现机制不算复杂,想要深度开发,那需要熟悉官网和 API 调用。
目前个人开发的 Bun 插件已经发布到 MarketPlace,可以下载体验一下。

安装之后,在任意一个 .ts 或者 .js 文件,在 command palette 执行 Bun Run 命令:


REFERENCE
[1] https://code.visualstudio.com/api
我是 Pandy,一个喜欢英语的程序猿
关注公众号 Yopth,回复「加群」,加入「英文技术翻译互助群」,我们加入一起充电英语
边栏推荐
猜你喜欢

Some derivation formulas for machine learning backpropagation

Explain the example + detail the difference between @Resource and @Autowired annotations (the most complete in the entire network)

深度解析 z-index

单点登录 思维导图

postgresql源码学习(34)—— 事务日志⑩ - 全页写机制

Analysis of the implementation principle and detailed knowledge of v-model syntactic sugar and how to make the components you develop support v-model

Core Tower Electronics won the championship in the Wuhu Division of the 11th China Innovation and Entrepreneurship Competition

浅析v-model语法糖的实现原理与细节知识及如何让你开发的组件支持v-model

运行 npm 会弹出询问 “你要如何打开这个文件?“

03-SDRAM:写操作(突发)
随机推荐
Difficulty comparison between high concurrency and multithreading (easy to confuse)
In-depth analysis of z-index
使用powerDesigner反向工程生成Entity
拉格朗日插值及其应用
360推送-360推送工具-360批量推送工具
Zotero | Zotero translator插件更新 | 解决百度学术文献无法获取问题
事务的四大特性
机器学习反向传播的一些推导公式
浅析伪类和伪元素
《白帽子说Web安全》思维导图
DirectExchange交换机简单入门demo
什么是浮动?什么是文档流?清除浮动的几种方式及原理?什么是BFC,如何触发BFC,BFC的作用
03-SDRAM:写操作(突发)
安装gstreamer开发依赖库到项目sysroot目录
Automatic translation software - batch batch automatic translation software recommendation
【Go】Go 语言切片(Slice)
Obtaining server and client information
【Star项目】小帽飞机大战(七)
【C语言项目合集】这十个入门必备练手项目,让C语言对你来说不再难学!
PCB抄板