Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatible with node-tap sourcemap support #37

Open
IlyaSemenov opened this issue Oct 13, 2021 · 0 comments
Open

Incompatible with node-tap sourcemap support #37

IlyaSemenov opened this issue Oct 13, 2021 · 0 comments

Comments

@IlyaSemenov
Copy link

IlyaSemenov commented Oct 13, 2021

Problem

When I use node-tap with esbuild-runner, it fails to parse source code and show proper line numbers. When I replace esbuild-runner with @swc-node/register, everything works fine.

I am not exactly sure it's esbuild-runner's problem, but I suspect so. I don't think node-tap has some inner hacks specifically tailored to @swc-node/register, it's more probable that esbuild-runner fails to emit the source map in the generally assumable way.

Example

Example source code:

import tap from "tap"

tap.same("a", "b")

Test with @swc-node/register

Everything works as expected, it shows source code fully:

yarn tap --node-arg '-r' --node-arg '@swc-node/register' test.ts

emits:

 FAIL  test.ts
 ✖ should be equivalent

  test.ts
  1 | import tap from "tap"
  2 |
> 3 | tap.same("a", "b")
    | ----^

  --- expected
  +++ actual
  @@ -1,1 +1,1 @@
  -"b"
  +"a"

Test with esbuild-register

It fails to parse sourcemap and show source code with proper line numbers:

yarn tap --node-arg '-r' --node-arg 'esbuild-register' test.ts

emits:

 FAIL  test.ts
 ✖ should be equivalent

  --- expected
  +++ actual
  @@ -1,1 +1,1 @@
  -"b"
  +"a"

  test: test.ts
  at:
    line: 20
    column: 20
    file: test.ts
  stack: |
    Object.<anonymous> (test.ts:20:20)
    Module.replacementCompile (node_modules/append-transform/index.js:60:13)
    Module._compile (node_modules/esbuild-register/dist/node.js:2258:26)
    module.exports (node_modules/default-require-extensions/js.js:7:9)
    node_modules/append-transform/index.js:64:4
    newLoader (node_modules/esbuild-register/dist/node.js:2262:9)
    Object.<anonymous> (node_modules/append-transform/index.js:64:4)

Reproduction repository

See https://github.com/IlyaSemenov/esbuild-runner-node-tap-repro for the complete repro.

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

No branches or pull requests

1 participant