You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When env.targets targets an environment with support for class properties, SWC will still transpile in a constructor implementation.
This is problematic since throwing an error from the parent class constructor would create a stackframe that can't be fully sourcemapped since the super(...args) call in the generated code does not appear in the original code.
Alternatively, #9742 would fix the main motivation for this ticket.
will disable the problematic behavior. However, assumptions API is not well documented, and @magic-akari Do you think we should adjust the default value of assumptions based on the target.
kdy1
changed the title
loose transpiles class properties
Adjust default value of assumptions based on the target
Nov 20, 2024
kdy1
changed the title
Adjust default value of assumptions based on the target
Disable define/set issue transform for targets with native class properties support
Nov 20, 2024
The setPublicClassFields option (or the useDefineForClassFields setting in TypeScript, which controls the same functionality) is disabled by default, aligning with Babel's default configuration.
As for whether assumptions differ based on targets in loose mode, I don't have a clear idea, but we can look to Babel's implementation for guidance.
If we decide to proceed, we'll need to make adjustments in our code. Many of our transformation passes directly pass loose to adjust the output. We should first convert loose to assumptions options.
Describe the bug
When
env.targets
targets an environment with support for class properties, SWC will still transpile in aconstructor
implementation.This is problematic since throwing an error from the parent class constructor would create a stackframe that can't be fully sourcemapped since the
super(...args)
call in the generated code does not appear in the original code.Alternatively, #9742 would fix the main motivation for this ticket.
Input code
Config
Playground link (or link to the minimal reproduction)
https://play.swc.rs/?version=1.9.2&code=H4sIAAAAAAAAA0vOSSwuVnDLz1dIrShJzUspVnBKLFKo5lJQyEjMS8lJDU4uys%2FJUbBV0NBUsLVTqK7lqgUAn5sc8jMAAAA%3D&config=H4sIAAAAAAAAA1WOTQrDIBBG955CZl0K2ZRQaG%2FQQ4iZBEP8wTGlEnL3GBttupv5nvP8FsY5jCThzpc0psUJT%2BjrnhKKJohPSgClFiS9cgEuhY60o15MhDlavwQmawkTCX7GI9LKqD6e1dJq55GoGKpVCzNM%2BC9mhxy07eYMj8ohOsz16Aa%2FR%2BWzKgZFr3JZWgGa90kk%2FIBhbwPGdsifD96016bNVrZud4rKzC0BAAA%3D
SWC Info output
No response
Expected behavior
Input code is not modified.
Actual behavior
Transpiled code contains
super(...args)
call that can't be sourcemapped to original code due to #9742.Version
1.9.2
Additional context
No response
The text was updated successfully, but these errors were encountered: