Skip to content

Incompatible with node-tap sourcemap support #37

Open
@IlyaSemenov

Description

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.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions