tsx icon indicating copy to clipboard operation
tsx copied to clipboard

tsx issue with nyc instumented files:

Open derdeka opened this issue 9 months ago • 0 comments

Acknowledgements

  • [x] I read the documentation and searched existing issues to avoid duplicates
  • [x] I understand this is a bug tracker and anything other than a proven bug will be closed
  • [x] I understand this is a free project and relies on community contributions
  • [x] I read and understood the Contribution guide

Minimal reproduction URL

https://stackblitz.com/edit/node-r2m8mrnc?file=package.json

Problem & expected behavior (under 200 words)

  • What happened

    When using nyc and tsx the instumented files cause an error: Cannot read properties of undefined (reading 'startsWith').

    I think this line is causing the issue, as modules don't always have an id: https://github.com/privatenumber/tsx/blob/28a3e7d2b8fd72b683aab8a98dd1fcee4624e4cb/src/cjs/api/module-extensions.ts#L107

  • How to repoduce

    Use stackblitz or manual steps:

    npm init -y
    npm i [email protected] [email protected] --save-dev --save-exact
    echo "node-options=--import=tsx" > .npmrc
    echo "{\"all\": true, \"sourceMap\": true, \"instrument\": true}" > .nycrc.json
    echo "console.log('hello world')" > dummy.js
    npx nyc node dummy.js
    
  • Screenshots Image Image

Bugs are expected to be fixed by those affected by it

  • [x] I'm interested in working on this issue

Compensating engineering work will speed up resolution and support the project

  • [ ] I'm willing to offer $10 for financial support

derdeka avatar Feb 12 '25 17:02 derdeka