VSCode 上的 pwa-node 类型启动配置是什么?

What is the pwa-node type launch configuration on VSCode?

我注意到 VSCode 为 npm 调试(通过 NPM 启动)生成的默认启动配置默认将配置类型设置为“pwa-node”。

添加“通过 NPM 启动”配置:

生成的配置类型:

我搜索了一下,但没有找到它的含义(也许与 Progressive Web Apps 相关?)。

有谁知道“pwa-node”的含义以及为什么是“pwa-node”而不是“node”?

pwa- 前缀 is/was 是一种针对 VS Code new JavaScript debugger, which at the time was named vscode-pwa.

的方法

https://github.com/microsoft/vscode-js-debug/pull/32

Talking with Kai and Rob, something we want to do is make the PWA extension a drop-in replacement for the existing two Chrome and Node debug extensions. Therefore we want to have the PWA extension be able to read and support the existing configuration settings, and be invoked by launching the chrome and node types. More work, coming soon in a followup PR, will be needed to actually deal with these settings.

This also moved the build to a Gulp system, supporting NLS and matching the existing extensions. Part of the build is the ability to have the types and commands be prefixed with pwa-: running gulp will generate an extension that registers types pwa-node and pwa-chrome, while gulp --drop-in will remove these prefixes. This lets us develop and debug the extension using the existing packages, until such time as we want to start dogfooding it.

他们还在这里讨论了如何使用定位机制:https://github.com/microsoft/vscode/issues/85984

type 属性

type 属性指定用于此启动配置的调试器类型。每个安装的调试扩展都会引入一个类型:例如 built-in Node 调试器的 node,或 PHP 和 Go 扩展的 phpgo


type : pwa-node

Javascript 调试器是一个 built-in 扩展,用于在 VS 代码中进行调试。此扩展在最新版本的 VS 代码中默认安装和启用。 "type": "pwa-node" 来自预览版 Javascript Debugger (Nightly)。 pwa- 前缀用于区分应该使用哪个调试器。

当您在创建 launch.json 文件时单击下拉菜单中的 Node.js(Preview) 而不是 Node.js 时,"type": "pwa-node" 将添加到您的 launch.json侧边栏的调试部分。

如果您打开 VS 代码的 defaultSettings.json,您可以看到预览版的设置(已启用),它们如下所示:

"debug.javascript.usePreview": true,
"debug.javascript.usePreviewAutoAttach": true,

如果您想使用此调试器扩展的夜间版本,您需要禁用 built-in 调试器并从市场安装夜间版本。为此,请按照下列步骤操作:

  1. 打开扩展视图并搜索 @builtin @id:ms-vscode.js-debug
  2. 右键单击并禁用扩展程序。
  3. 现在输入以下内容搜索夜间扩展:@id:ms-vscode.js-debug-nightly
  4. 点击安装并重启 VS code。

现在您可以使用 JavaScript 调试器(每晚)调试 Typescript 和 Javascript 代码。

如果您收到 debug type 'pwa-node' is not supported 错误,请从 settings.json 中删除以下设置:

"debug.node.useV3": true,
"debug.chrome.useV3": true

type : node

如果您想要以前的行为,即 "type": "node",请在从调试创建 launch.json 文件时单击下拉菜单中的 Node.js 而不是 Node.js(Preview)侧边栏的一部分。您也可以在 launch.json 中手动输入 "type": "node" 而不是从菜单中输入,这不会有任何区别。

如果您对 Javascript 调试器的夜间版本进行了上述更改,您应该撤消它们以使 built-in Javascript 调试器正常工作。