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

es6 generation fails under certain conditions #2661

Open
ianharrigan opened this issue Sep 19, 2023 · 6 comments
Open

es6 generation fails under certain conditions #2661

ianharrigan opened this issue Sep 19, 2023 · 6 comments

Comments

@ianharrigan
Copy link

Im not sure if this is an openfl issue, or an haxe issue (or possibly both?), but the following minimal repro fails to run when using es6 generation and -final:

package;

class Main extends openfl.display.Sprite {
    public function new() {
        super();

        var something = new SomeSubClass();
        var x = SomeSubClass.FOO;
        trace(something, x);
    }
}

enum abstract ClassType<T:SomeClass>(String) to String from String {
}

class ClassTypeBuilder {
    public static function name<T:SomeClass>(name:String):ClassType<T> {
        return cast name;
    }
}

class SomeClass {
    public function new() {
    }
}

class SomeSubClass extends SomeClass {
    public static final FOO:ClassType<SomeSubClass> = ClassTypeBuilder.name("someSubClass"); 
}

fails with (at runtime):

Main.js:1320 Uncaught TypeError: tb.name is not a function
    at Main.js:1320:215
    at H.lime.$scripts.Main (Main.js:1342:11)
    at H.lime.embed (Main.js:1342:309)
    at (index):40:8

Must use -final and -D js-es=6 in order to trigger it

@joshtynjala
Copy link
Member

I can't reproduce if I convert it to pure Haxe with static function main() and -dce=full and -D js-es=6. I believe that OpenFL's -final flag uses -dce=full, but it also uses Closure Compiler to minify the code. I wonder if Closure is renaming or removing something that it shouldn't.

@ianharrigan
Copy link
Author

Yeah, i figured it would probably be down to something in the minification process, but I didnt / dont know enough about it to be sure. Didnt think to test in a pure haxe app either - my bad :)

@intoxopox
Copy link
Member

Any news on this?

@Dimensionscape
Copy link
Member

Dimensionscape commented May 2, 2024

I think Josh added Terser as an a new option in the minification pipeline

Any news on this?

@Dimensionscape
Copy link
Member

Dimensionscape commented May 2, 2024

Yes, he did, just to further verify this. You can try using lime build html5 -minify -terser if you have this issue and hopefully it with remedy the situation. Our bundled Closure Compiler version may be out of date. The -npx flag may also allow you to use the latest version instead.

@intoxopox
Copy link
Member

Sadly, that didn't work either. Same issue.

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

No branches or pull requests

4 participants