Skip to content

Sourcemaps are broken for @swc-node/register/esm #719

Description

@jwalton

index.ts:

function main() {

    // Some whitespace for swc to optimize away...


    console.log('hello world');
    throw new Error('foo');
}

main()

@swc-node/register gives us sourcemap support:

$ node -r @swc-node/register ./index.ts
hello world
/Users/jwalton/t/index.ts:4
    throw new Error('foo');
    ^

Error: foo
    at main (/Users/jwalton/t/index.ts:7:11)

But @swc-node/register/esm does not:

node --loader @swc-node/register/esm ./index.ts
(node:81567) ExperimentalWarning: Custom ESM Loaders is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
hello world
file:///Users/jwalton/t/index.ts.mjs:3
    throw new Error('foo');
          ^

Error: foo
    at main (file:///Users/jwalton/t/index.ts.mjs:3:11)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions