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

super(...args) from transpilation not sourcemapped #9742

Closed
eps1lon opened this issue Nov 18, 2024 · 0 comments · Fixed by #9745
Closed

super(...args) from transpilation not sourcemapped #9742

eps1lon opened this issue Nov 18, 2024 · 0 comments · Fixed by #9745
Assignees
Labels
Milestone

Comments

@eps1lon
Copy link

eps1lon commented Nov 18, 2024

Describe the bug

When SWC adds a super(...args) call, it doesn't sourcemap it back to original code. Since super(...args) could throw, resulting stacks would not be sourcemapped fully.

Input code

class Parent {
    constructor() {
        throw new Error('foo')
    }
}

class Child extends Parent {
  handleScroll = () => {}
}

new Child()

Config

{
  "jsc": {
    "parser": {
      "syntax": "ecmascript",
      "jsx": false
    },
    "loose": true,
    "minify": {
      "compress": false,
      "mangle": false
    }
  },
  "module": {
    "type": "es6"
  },
  "minify": false,
  "isModule": true,
  "env": {
    "targets": "node >= 8"
  }
}

Playground link (or link to the minimal reproduction)

https://play.swc.rs/?version=1.9.2&code=H4sIAAAAAAAAA1WMQQqEMAxF9z1FdtpD6GZwL8wJSpqhAyGBNIOCeHdrcTNv%2BT%2FvIadaYU1G4nAEaKBKdfuhq43x2W68mG4gtMFi1r7hozrEfp%2FhDAF76lW%2BnIF2J8l%2F4ZIkM73RlBkmaOlphqObd7N7Y7wAs2IpXpAAAAA%3D&config=H4sIAAAAAAAAA1WOTQ7CIBBG95yCzNq1MSZ6Aw9B6LSh4S8MNZKmdy9FwLqb%2BR7z%2BFbGOcwk4c7XPObFi0AY%2Bp4TSjaKT04ApREkg%2FIRLo3OdKBRaMISbV8C2jnCTGJYsEZGWTWms1o64wMSNUO3GmEnjf9iVuVg3LAUWCvH5LHUoyv8HrXPuhgUvdplawVo3yeRCBPGow1YNyB%2FPvitGNm2A%2FOWcNspAQAA

SWC Info output

No response

Expected behavior

Transpiled code produces stacks that can be sourcemapped to the original stack:

Uncaught Error: foo
    at constructor (class-frame-without-super:3:15)
    at new Child (class-frame-without-super:7:1)
    at class-frame-without-super:11:1

The super(...args) call should be sourcemapped to right before the class keyword in class Child extends Parent {}

Actual behavior

Transpiled code produces stacks that are not sourcemapped

Version

1.9.2

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

2 participants