vitest icon indicating copy to clipboard operation
vitest copied to clipboard

Unable to debug a dependency that contains only typescript source files

Open josh-burton opened this issue 1 year ago • 6 comments

Describe the bug

I have a few internal dependencies that only contain typescript source files - no compiled javascript.

Until this point I've been using jest, and compilation and debugging these files has worked fine.

When migrating to vitest, compilation works, but I'm unable to set break points within these files.

Is there any config required to allow debugging the typescript source?

Reproduction

A nodejs typescript project compiling a published typescript package, built with tsc --noEmit.

A debug breakpoint set within the published typescript package is not hit.

System Info

IDE: Intellij IDEA

  System:
    OS: macOS 14.5
    CPU: (10) arm64 Apple M1 Pro
    Memory: 130.06 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.18.0 - ~/.nvm/versions/node/v18.18.0/bin/node
    Yarn: 1.22.22 - /opt/homebrew/bin/yarn
    npm: 9.8.1 - ~/.nvm/versions/node/v18.18.0/bin/npm
    pnpm: 8.4.0 - ~/Library/pnpm/pnpm
  Browsers:
    Chrome: 126.0.6478.185
    Safari: 17.5
  npmPackages:
    vite: ^5.3.4 => 5.3.4 
    vitest: ^2.0.4 => 2.0.4

Used Package Manager

npm

Validations

josh-burton avatar Jul 28 '24 23:07 josh-burton

Hello @josh-burton. Please provide a minimal reproduction using a GitHub repository or StackBlitz (you can also use examples). Issues marked with needs reproduction will be closed if they have no activity within 3 days.

github-actions[bot] avatar Jul 30 '24 19:07 github-actions[bot]

I'm unsure how to create a reproducible sample using stackblitz as I would need to publish another package to demonstrate that debugging does not work.

Is there a way to replicate publishing a package without actually publishing a package to npm?

josh-burton avatar Aug 01 '24 03:08 josh-burton

You can also create

a minimal reproduction using a GitHub repository

and there have manually created node_modules which contains the package that demonstrates the issue. It doesn't have to be published package, just create it under node_modules and commit the changes to git remote.

AriPerkkio avatar Aug 01 '24 04:08 AriPerkkio

You can also create

a minimal reproduction using a GitHub repository

and there have manually created node_modules which contains the package that demonstrates the issue. It doesn't have to be published package, just create it under node_modules and commit the changes to git remote.

ok thanks :) I'll do that.

josh-burton avatar Aug 01 '24 04:08 josh-burton

@AriPerkkio I've created a reproducible sample here: https://github.com/josh-burton/vitest-debugging-bug

Are you able to reopen the issue?

The sample project has:

  • a package called my_dependency inside of node_modules
  • a test called index.test.ts

If a breakpoint is set inside index.test.ts, it is hit when debugging: Screenshot 2024-08-06 at 9 15 49 AM

If a breakpoint is set inside of node_modules/my_dependency/src/repository/my_repository, it is never hit when debugging:

Screenshot 2024-08-06 at 9 16 44 AM

Some notes:

  • the issue only happens in IntelliJ. VS Code is able to debug fine.
  • I've noticed that if I use npx link with the dependency (which symlinks the dependency into node_modules), I'm able to debug fine.

josh-burton avatar Aug 05 '24 21:08 josh-burton

I've also filed a Youtrack issue for IntelliJ: https://youtrack.jetbrains.com/issue/IDEA-357178/vitest-unable-to-hit-debug-breakpoint-inside-a-nodemodules-dependency

josh-burton avatar Aug 05 '24 21:08 josh-burton