jasononeil / webpack-haxe-loader

Webpack loader for the Haxe programming language.
MIT License
38 stars 11 forks source link

Cannot reference Main module in bundles since 0.7.4 #34

Closed kLabz closed 6 years ago

kLabz commented 6 years ago

I have a regression since haxe-loader 0.7.4 (worked fine up to 0.7.3), but I'm not sure if it's from modular or haxe-loader.

I cannot reference Main module in bundles any more since 0.7.4. Common modules work fine, but not main which gets compiles as:

var Main, X = $s.a /*, etc.*/;

A "minimal" (not so minimal since I wanted to check if it was about shared modules or just Main) example to reproduce:

Main.hx

package;

class Main {
    public static var test:String = "test";

    public static function main() {
        Webpack.load(Bundle1).then(function(_) {
            new Bundle1();
        });

        Webpack.load(Bundle2).then(function(_) {
            new Bundle2();
        });
    }
}

Common.hx

package;

class Common {
    public static var test:String = "test";
}

Bundle1.hx

package;

class Bundle1 {
    public function new() {
        trace('New Bundle1');
        trace(Common.test);
    }
}

Bundle2.hx

package;

class Bundle2 {
    public function new() {
        trace('New Bundle2');
        trace(Main.test); // Will fail at runtime, Main is undefined
        trace(Common.test);
    }
}
elsassph commented 6 years ago

Yes this is a regression in Modular - entry point(s) can't be shared with sub modules.