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

[js] Fix type names in debugger #10894

Merged
merged 1 commit into from
Mar 8, 2023
Merged

Conversation

kLabz
Copy link
Contributor

@kLabz kLabz commented Dec 19, 2022

Previous behavior

When compiling with -D js-classic and using (chrome/vscode/nwjs) javascript debugger, when $hxClasses are generated (this behavior can be forced with -dce no for example) we end up with weird type names in debugger:

2022-12-19-09:25-12-525120366

This is because javascript debugger trips on this expression while generating a function name:

var foo_bar_Foo = $hxClasses["foo.bar.Foo"] = function() {

When also using -D js-unflatten, we get an even worse variant:

2022-12-19-09:24-14-532933343

This is because javascript debugger trips on this expression while generating a function name:

foo.bar.Foo = $hxClasses["foo.bar.Foo"] = function() {

Proposed solution

In order to avoid js debugger messing up function (and so types) names, and since support for displayName has been removed, we need to clean up that function declaration and move the $hxClasses / $hx_exports to after the function declaration. Since that leads to a bit bigger output, I only enabled this behavior when in debug mode.

2022-12-19-09:24-36-790044728

foo.bar.Foo = function() {
  // ...
};
$hxClasses["foo.bar.Foo"] = foo.bar.Foo;

@skial skial mentioned this pull request Jan 4, 2023
1 task
@sebthom
Copy link
Contributor

sebthom commented Feb 28, 2023

That is cool stuff. @Simn do you have any objections to merge this?

@Simn
Copy link
Member

Simn commented Feb 28, 2023

Looks good to me!

@kLabz kLabz merged commit 6b63b4c into development Mar 8, 2023
@kLabz kLabz mentioned this pull request Apr 1, 2023
@kLabz kLabz deleted the fix/js-debugger-type-names branch July 10, 2023 09:33
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

Successfully merging this pull request may close these issues.

3 participants