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 enums parameters generation to make it compatible with advanced JS minification tools #11328

Conversation

RealyUniqueName
Copy link
Member

@RealyUniqueName RealyUniqueName commented Oct 9, 2023

Fixes #11327
Sample enum:

enum Sample {
  ConstructorName(paramName:String);
}

This PR changes enum constructor generation from

ConstructorName: ($_=function(paramName) { return {_hx_index:0,paramName:paramName,__enum__:"Sample",toString:$estr}; },$_._hx_name="ConstructorName",$_.__params__ = ["paramName"],$_)

to

ConstructorName: ($_=function(paramName) { return {_hx_index:0,paramName:paramName,__enum__:"Sample",toString:$estr,__params__:function(){ return [this.paramName];}}; },$_._hx_name="ConstructorName",$_)

to avoid usage of stringified parameters names.

@RealyUniqueName
Copy link
Member Author

There's no test in this PR because current version of UTest doesn't work for minified JS too (working on it).

@Simn Simn merged commit f47841d into HaxeFoundation:development Oct 9, 2023
61 checks passed
@Simn
Copy link
Member

Simn commented Oct 9, 2023

Thanks!

@skial skial mentioned this pull request Oct 11, 2023
1 task
0b1kn00b pushed a commit to 0b1kn00b/haxe that referenced this pull request Jan 25, 2024
…ced JS minification tools (HaxeFoundation#11328)

* [js] don't use enum parameters names in the generated code

* cleanup

---------

Co-authored-by: a.v.kuzmenko <a.v.kuzmenko@nexters.com>
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.

[js] Enums don't survive advanced minification
2 participants