当前位置:网站首页>我开发了一个利用 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,回复「加群」,加入「英文技术翻译互助群」,我们加入一起充电英语
边栏推荐
- 如何在uni-app中选择一个合适的UI组件库
- 搭建zabbix监控及邮件报警(超详细教学)
- 接口报错no message avaliable
- Explain the example + detail the difference between @Resource and @Autowired annotations (the most complete in the entire network)
- tidyverse笔记——管道函数
- 单点登录 思维导图
- DDL+DML+DQL
- Analysis of the principle and implementation of waterfall flow layout
- 第十七章:回溯探求指定入口的马步遍历,贪心无回溯探求马步遍历,递归探求nxm棋盘带障碍马步遍历
- 【编程题】【Scratch三级】2022.03 冬天下雪了
猜你喜欢
postgresql源码学习(34)—— 事务日志⑩ - 全页写机制
DirectExchange switch simple introduction demo
零样本学习&Domain-aware Visual Bias Eliminating for Generalized Zero-Shot Learning
Obtaining server and client information
How to use repeating-linear-gradient
数据库概论 - MySQL的简单介绍
数据库原理作业2 — JMU
【Go语言刷题篇】Go完结篇函数、结构体、接口、错误入门学习
《白帽子说Web安全》思维导图
Redux state management
随机推荐
快速傅里叶变换(FFT)
codec2 BlockPool:unreadable libraries
SQLite数据库连接字符串
uni-app生命周期
2.(1)栈的链式存储、链栈的操作(图解、注释、代码)
【Star项目】小帽飞机大战(八)
MySQL笔记下
【解决】npm ERR A complete log of this run can be found in npm ERR
单点登录 思维导图
In-depth analysis of z-index
Moment.js common methods
TypeScript进阶
接口报错no message avaliable
浅析重复线性渐变repeating-linear-gradient如何使用
Automatic translation software - batch batch automatic translation software recommendation
Analysis of the principle and implementation of waterfall flow layout
360推送-360推送工具-360批量推送工具
线程唤醒机制
CHI论文阅读(1)EmoGlass: an End-to-End AI-Enabled Wearable Platform for Enhancing Self-Awareness of Emoti
iOS大厂面试查漏补缺