Skip to content

Instantly share code, notes, and snippets.

@kLabz
Last active May 6, 2018 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kLabz/8e1dc356d30e1d7b0244f6b6d55d4f6a to your computer and use it in GitHub Desktop.
Save kLabz/8e1dc356d30e1d7b0244f6b6d55d4f6a to your computer and use it in GitHub Desktop.
Haxe modular regression

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.*/;

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);
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment