Skip to content

fix: offer the NativeScript debugger without a launch.json - #304

Open
NathanWalker wants to merge 2 commits into
masterfrom
fix/debugger-discovery
Open

NathanWalker wants to merge 2 commits into
masterfrom
fix/debugger-discovery

Conversation

@NathanWalker

@NathanWalker NathanWalker commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Problem

In a NativeScript project with no launch.json, Run and Debug did nothing useful:

  • The nativescript debugger only declared javascript and typescript in languages. VS Code's debugger picker lists the debuggers that handle the active editor's language, so with a .tsx file open NativeScript wasn't offered, and the picker suggested installing a TypeScript JSX extension instead. .jsx, .vue, and .svelte had the same problem.
  • No DebugConfigurationProvider was registered. Nothing listed NativeScript configurations without a launch.json, and nothing resolved the empty configuration VS Code sends when you press F5 without one.
  • The extension activated only on onDebugResolve:nativescript, so it stayed unloaded until a NativeScript configuration already existed.

Change

  • contributes.debuggers[0].languages and contributes.breakpoints add javascriptreact, typescriptreact, vue, svelte, and tsrx (Octane; the id registered by the TSRX extension).
  • DynamicConfigurationProvider (Dynamic trigger) lists Launch on iOS / Launch on Android for NativeScript workspaces; iOS is listed only on macOS. Workspaces are detected by nativescript.config.*, nsconfig.json, or an @nativescript/core dependency. The entries show up in the Run and Debug dropdown, and as "More NativeScript options…" in the picker.
  • ConfigurationResolver turns an empty configuration (F5 with no launch.json) into a launch configuration. It asks for the platform, or picks Android directly when that's the only option; dismissing the pick cancels the launch. Configurations from launch.json pass through unchanged.
  • It deliberately has no provideDebugConfigurations, so a new launch.json is still seeded from the six initialConfigurations in package.json.
  • Adds onDebugDynamicConfigurations:nativescript to activationEvents.

Verification

  • Unit tests for both providers and isNativeScriptProject; the full suite, typecheck, lint, and format pass.
  • Packaged with vsce. The VSIX contains the provider, the new activation event, and the new languages.

Merging with #303

Merging this alongside #303 conflicts only in the projectInfo.test.ts imports; keep both sides. Whichever lands second should also have isNativeScriptProject reuse #303's hasDependency helper.

The debugger only declared javascript and typescript, so VS Code left it out
of the debugger picker for .tsx/.jsx/.vue/.svelte files, and nothing resolved
a configuration when debugging started without a launch.json.

Declare those languages for the debugger and breakpoints, list "Launch on
iOS/Android" as dynamic configurations for NativeScript workspaces, and ask
for the platform when F5 starts with an empty configuration.

@edusperoni edusperoni left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. The empty-configuration check matches the VS Code sample, returning undefined from the platform pick correctly cancels the launch, iOS is only offered on macOS (where IosProject can run), and leaving out provideDebugConfigurations keeps the full initialConfigurations for new launch.json files.

Non-blocking notes:

  • Picker scope: declaring javascriptreact / typescriptreact / vue / svelte also puts "NativeScript" in the F5 debugger picker for any React/Vue/Svelte web project (already the case for plain JS/TS). A follow-up could add a when clause on the debugger, backed by a context key set on workspaceContains: activation for NativeScript config files.
  • Monorepos: detection and the generated appRoot: ${workspaceFolder} assume the app is at the workspace root. In Nx the config lives in apps/<app>/, while the root package.json usually has @nativescript/core, so the dynamic entries appear but point at the wrong root. Not a blocker; Nx users can keep a custom-command launch.json.
  • tsrx: I couldn't confirm that language id independently; an unknown id is harmless, just flagging it.

As noted in the description: after #303 lands, rebase and have isNativeScriptProject reuse its hasDependency (the only conflict is the test imports).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants