在视觉工作室代码扩展中捆绑与调试
我已经为VS代码写了一个扩展程序,现在正在为其创建一个软件包。
然后,建议将文件捆绑在一起,我用 eSbuild
来完成文件。包装有效,但它使我遇到了困境。在 package.json
中,我可以编写
"main": "./out/main.js",
可以让VS代码使用捆绑的代码;这会导致一个可用的软件包,但我无法调试代码。
或者我可以编写
"main": "./out/extension.js",
将VS代码定向到原始代码的内容;然后我可以调试,但我不会生成可用的软件包。
当然,我必须误解一些东西,但是这是什么?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
/abound.json中设置VS代码启动配置。
假设您的eSbuild命令包括
- sourcemap
以生成源地图,在.vscode .json,以便使用您的Esbuild Watch NPM脚本:Assuming your esbuild command includes
--sourcemap
to generate source maps, set up your VS Code launch configuration in .vscode/launch.json to use esbuild output:Then define your default build task in .vscode/tasks.json so that it uses your esbuild watch npm script:
更新
yo Code
并从中生成新扩展名。样本已经配置为捆绑文件,因此您无需自己做任何事情。但是,如果您想将Esbuild用于捆绑,那么您可能是一个人。去年已经提到了重建,但以后再也没有进步,
Update
yo code
and generate a new extension from it. The sample has already been configured to bundle the files so you don't need to do anything yourself.But if you want to use esbuild for bundling, then probably you are on your own. Moving to rebuild has been mentioned last year, but no progress ever after, https://github.com/microsoft/vscode/issues/115023#issuecomment-771692495
如果您在powershell终端中“ npm运行esbuild”,它将运行“ esbuild”脚本(我将其复制到package.json中。 /bundling-extension“ rel =“ nofollow noreferrer”> https://code.visalstudio.com/api/working-with-with-with-extensions/bundling-extension-extension-extension-extension )可能的。 (即使它正在运行
main.js。 。
我还没有对此进行过彻底的测试(我失去了这些东西,但我认为这可能会有所帮助。
If you "npm run esbuild" in a powershell terminal, it runs the "esbuild" script (which I copied into package.json from https://code.visualstudio.com/api/working-with-extensions/bundling-extension ) that uses --sourcemap, and that seems to make debugging possible. (You can use breakpoints in extension.ts even though it's running main.js.)
Then, you can replace the "watch" script names in tasks.json with "esbuild-watch", and it will automatically run esbuild when you make changes.
I haven't tested this thoroughly (I'm about as lost as you are with this stuff) but I thought this might help anyway.