当前位置:网站首页>我开发了一个利用 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,回复「加群」,加入「英文技术翻译互助群」,我们加入一起充电英语
边栏推荐
- Moment.js common methods
- 拓扑排序的两种方法 --- dfs+Kahn
- 【云原生】3.3 Kubernetes 中间件部署实战
- 第三方库-store
- Foreign trade website optimization - foreign trade website optimization tutorial - foreign trade website optimization software
- shell之条件语句(test、if、case)
- 英语翻译软件-批量自动免费翻译软件支持三方接口翻译
- DirectExchange switch simple introduction demo
- 外贸网站优化-外贸网站优化教程-外贸网站优化软件
- 机器学习反向传播的一些推导公式
猜你喜欢

毫米波技术基础

Analysis of the principle and implementation of waterfall flow layout

tidyverse笔记——dplyr包

DirectExchange switch simple introduction demo

Postgresql source code learning (33) - transaction log ⑨ - see the overall process of log writing from the insert record

Run the NPM will pop up to ask "how are you going to open this file?"

【Go报错】go go.mod file not found in current directory or any parent directory 错误解决

【 TA - frost Wolf _may - "one hundred plan" 】 art 2.3 hard surface

浅析瀑布流布局原理及实现方式

【云原生】-Docker安装部署分布式数据库 OceanBase
随机推荐
【Go】Go 语言切片(Slice)
安装gstreamer开发依赖库到项目sysroot目录
搭建zabbix监控及邮件报警(超详细教学)
项目 - 如何根据最近30天、最近14天、最近7天、最近24小时、自定义时间范围查询MySQL中的数据?
Analysis of pseudo-classes and pseudo-elements
gstreamer的caps event和new_segment event
uni-app生命周期
DDL+DML+DQL
MySQL的触发器
postgresql源码学习(34)—— 事务日志⑩ - 全页写机制
【 TA - frost Wolf _may - "one hundred plan" 】 art 2.3 hard surface
服务器和客户端信息的获取
Database Principles Homework 3 — JMU
那些破釜沉舟入局Web3.0的互联网精英都怎么样了?
nohup原理
Zero-Shot Learning & Domain-aware Visual Bias Eliminating for Generalized Zero-Shot Learning
TypeScript进阶
深度解析 z-index
Detailed explanation of js prototype
树状数组(单点修改区间查询和区间修改单点查询)