Skip to content

feat!: migrate debugger to js-debug and modernize tooling - #301

Merged
edusperoni merged 7 commits into
masterfrom
fix/restarts-etc
Nov 9, 2026
Merged

edusperoni merged 7 commits into
masterfrom
fix/restarts-etc

Conversation

@edusperoni

Copy link
Copy Markdown
Contributor

Summary

Modernizes the extension around VS Code's built-in JavaScript debugger and fixes debug session lifecycle issues (restarts, stops, leaked ns processes).

Debugger

  • Replaces vscode-chrome-debug-core with an inline debug adapter that runs ns debug and attaches a js-debug (pwa-node) child session over the CLI's debug port.
  • Reattaches automatically when the app restarts after a file change, and waits up to 60s for the app to come back after its socket drops.
  • Each session owns its ns process. Stopping during the build or the iOS team picker no longer leaks it, the Run command no longer kills a debug session's CLI, and Restart waits for the old CLI to exit.
  • Children are detached with a DAP disconnect sent straight to js-debug. vscode.debug.stopDebugging(child) is routed to the parent for lifecycleManagedByParent children, so calling it ended the whole session.
  • The debug adapter is registered before the CLI check, so a missing or outdated CLI is reported as an error instead of an unknown debug type.

Source maps

  • Maps load from anywhere by default (resolveSourceMapLocations: null): inline data:, device file:// paths, and nsruntime:// URLs that newer runtimes serve through Network.loadNetworkResource.
  • Fallback overrides map device paths (/app/... on iOS, /data/*/files/app/... on Android) to the local platforms/ copy, for older runtimes.
  • webpack overrides are unchanged. The user's webpack.config.js is evaluated in a separate process, and only when it sets devtoolNamespace/library.

Vite

  • Vite projects debug with --no-hmr, because HMR serves app code without source maps. Pass --hmr in tnsArgs to opt out.
  • launchTests is refused for Vitest projects, since the CLI doesn't support debugging them.
  • HMR and Vitest debugging need upstream changes first.

Settings / manifest

  • New launch attributes: address, resolveSourceMapLocations, skipFiles, smartStep, trace.
  • Removed the unused tnsOutput and noDebug. diagnosticLogging is deprecated in favor of trace.
  • New nativescript.nsPath setting. nativescript.tnsPath is deprecated but still honored when nsPath isn't set.
  • Requires VS Code 1.109+ and NativeScript CLI 8.0+.

Analytics

  • universal-analytics (shut down) is replaced with the GA4 Measurement Protocol, the same approach as the CLI.
  • Release builds only send analytics when GA_MEASUREMENT_ID/GA_API_SECRET are set at packaging time, and only if the user opted in and VS Code telemetry is on. Without them nothing is sent, which matches the current published extension.

Tooling

  • TypeScript 6.0, ESLint (flat config + typescript-eslint), Prettier checks.
  • Vitest replaces mocha/sinon: 160 tests.
  • Dropped tslint, lodash, uuid, cpx, proxyquire, strip-json-comments.
  • GitHub Actions CI replaces Travis: lint, format check, typecheck, test, then package and upload the .vsix as an artifact. Actions are pinned to commit SHAs.

Not done yet

  • Version bump and final CHANGELOG (currently "Unreleased").

Testing

Unit tests, lint, typecheck and vsce package pass locally. Not yet tested on a device or simulator. Before merging:

  • Launch + attach on iOS simulator and device
  • Launch + attach on Android emulator and device
  • Reattach after a file change (watch) on both platforms
  • Breakpoints bind with: inline webpack maps, nsruntime:// maps (new runtimes), file:// device maps (older runtimes), a Vite project
  • Stop / Restart from the toolbar leave no ns process or orphaned js-debug session behind

Inline debug adapter starts ns debug, reads the debug port from CLI output and
attaches VS Code's built-in JavaScript debugger (pwa-node) over WebSocket.
DebugManager reattaches the child session on LiveSync restarts.

Also: engine ^1.109, strict TS targeting es2022, prettier, nsPath setting,
modern launch/tasks configs.
…me and Vite

Debugging
- Each debug session owns its ns process; the Run command no longer kills it.
- Stopping during the build or iOS team picker no longer leaks the ns process.
- Child js-debug sessions are matched via a parent id in their config instead of
  activeDebugSession; orphaned children started after a stop are stopped.
- Wait up to 60s for the app to reconnect after a LiveSync restart drops the socket.
- Fail the session with an error when the initial attach fails.
- Register the debug adapter before checking the CLI; CLI check is async and
  honors nativescript.nsPath.
- Remove supportsRestartRequest so Restart relaunches the session.
- Source maps: allow any map location (inline, device file://, nsruntime://) and
  add fallbacks mapping device paths to the local platforms/ copy.
- Read webpack output settings out of process, only when customized.
- Vite: debug with --no-hmr; refuse launchTests for Vitest projects.

Manifest
- Debugger schema: add address, resolveSourceMapLocations, skipFiles,
  smartStep, trace; drop tnsOutput/noDebug; use ${workspaceFolder}.
- @types/vscode pinned to engines (~1.109); min CLI 8.0.0.

Analytics
- Replace universal-analytics with the GA4 Measurement Protocol (same approach
  as the CLI); config injected at package time; respects VS Code telemetry.

Tooling
- TypeScript 6.0, ESLint flat config with typescript-eslint, Vitest replacing
  mocha/sinon, prettier checks; drop tslint, lodash, uuid, cpx, proxyquire.
- GitHub Actions CI: lint, format, typecheck, test, package and upload the vsix.
…Path

- Children are started with lifecycleManagedByParent, so
  vscode.debug.stopDebugging(child) is routed to the NativeScript parent and
  ended the whole session (e.g. replacing the child on a LiveSync restart) while
  never stopping the child itself. Detach children with a DAP disconnect sent
  straight to js-debug instead.
- Wait for the ns process to exit (SIGKILL after 5s) before answering
  terminate/disconnect and before reporting self-termination, so Restart can't
  overlap the old CLI.
- Send TerminatedEvent at most once.
- Resolve the iOS team picker when dismissed instead of hanging the session.
- Android --debug-brk: don't announce a port that was never printed.
- Activation CLI check resolves a relative nsPath against the workspace.
- Keep nativescript.tnsPath as a deprecated fallback for nativescript.nsPath.
@edusperoni edusperoni changed the title Modernize the extension: js-debug debugger, fixed restarts, nsruntime/Vite source maps, new tooling feat!: migrate debugger to js-debug and modernize tooling Nov 6, 2026
- release-please keeps a release PR with the version bump and a CHANGELOG
  generated from conventional commits since 0.12.5; merging it tags the
  release and publishes the stable .vsix.
- Other pushes to master (and manual runs) publish a Marketplace pre-release
  numbered <major>.<minor>.<1000 + run>, plus a GitHub pre-release.
- Publishing uses Marketplace Trusted Publishing (vsce publish --oidc) from
  the `release` environment and stays off until ENABLE_RELEASE is true.
- Drop the hand-written Unreleased CHANGELOG section; document the process
  in RELEASING.md.
- Keep *.local.* and .env files out of the packaged extension.
- New launch attributes runtimeExecutable, runtimeArgs, cwd and env (js-debug
  naming). With runtimeExecutable set the command runs exactly as given, e.g.
  `npx nx debug my-app --platform=ios`; the extension adds no flags and only
  watches its output for the debug port. cwd and env also apply to plain ns.
- Without nativescript.nsPath, use node_modules/.bin/ns from the app or any
  parent folder before falling back to the global ns.
- Start commands in their own process group and signal the whole group, so
  Stop/Restart reach wrapped CLIs (npx -> nx -> ns -> bundler).
- Quote arguments for the shell, including zsh's leading `=`.
- Move the shared debug/attach command building into Project.
@edusperoni
edusperoni marked this pull request as ready for review November 9, 2026 17:15
@edusperoni
edusperoni merged commit 0ace863 into master Nov 9, 2026
1 check passed
edusperoni added a commit that referenced this pull request Nov 9, 2026
BREAKING CHANGE: requires VS Code 1.109+ and NativeScript CLI 8.0+; the tnsOutput and noDebug launch attributes were removed.
feat: reattach the debugger automatically when the app restarts
feat: load source maps from inline data:, the runtime's nsruntime:// scheme, or the local platforms/ copy
feat: support Vite projects (debug sessions run with --no-hmr)
feat: custom launch commands (runtimeExecutable, runtimeArgs, cwd, env)
feat: use a project-local ns CLI before the global one
feat: new launch attributes address, resolveSourceMapLocations, skipFiles, smartStep and trace
feat: nativescript.nsPath setting; tnsPath is deprecated
fix: no ns process is left running when a session stops during the build
fix: the Run command no longer kills a debug session's ns process
fix: Restart relaunches the session after the old CLI exits
fix: show an error instead of failing to activate without the CLI
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.

1 participant