folke / esbuild-runner

⚡️ Super-fast on-the-fly transpilation of modern JS, TypeScript and JSX using esbuild
https://www.npmjs.com/package/esbuild-runner
Apache License 2.0
712 stars 24 forks source link

paths in `Error.stack` "multiply" ...? #55

Open mindplay-dk opened 2 years ago

mindplay-dk commented 2 years ago

I tried switching from ts-node to esbuild-runner, as you can see here.

In this project, and I obtain paths from Error.stack, very simply, as you can see here:

        const location = new Error().stack!
          .split("\n")[2]
          .replace(/^\s+at /, "");

For some reason, the paths in stack-traces appear to... multiply?

For example, if you run npm run test, you'll see test output like this:

  × [equal] it produces the expected test results
  └ /home/mindplay/workspace/funky-test/test/test/test.ts:76:10

That path is /home/mindplay/workspace/funky-test/test/test.ts:76:10, so there's a /test too many in there.

As there is test coverage for that fact, you will see failing tests as well:

   ×          "location": "/home/mindplay/workspace/funky-test/test/test/cases.ts:9:6",
   √          "location": "/home/mindplay/workspace/funky-test/test/cases.ts:9:6",

Something appears to be not right with the run-time path resolution of this loader?