forked from HaxeFoundation/haxe
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
@:shallowExpose works very similarly to @:expose, but instead of exposing on the window object (or export for nodejs), the class or static field is instead exposed only to the surrounding scope of the js_modern generated Haxe closure. These are different things, when the Haxe generated code is used as one part of a larger JS project with where in my particular use-case; all JS code (including haxe generated code) is compiled into a single optimised and minified JS file wrapped in a large closure, in this case I do not wish the Haxe types to be exposed to window, but only to this large closure containing the other JS code using the Haxe types, the @:shallowExpose permits that. Example: @:shallowExpose class A {} @:shallowExpose class B {} @:shallowExpose("x.y.D") class D {} @:shallowExpose("x.C") class C {} class E { @:shallowExpose static function e() {} } Generates: var $__hx_shallows = {E:{},x:{y:{}}}; (function () { "use strict"; var A = $__hx_shallows.A = function() { }; var B = $__hx_shallows.B = function() { }; var D = $__hx_shallows.x.y.D = function() { }; var C = $__hx_shallows.x.C = function() { }; var E = function() { }; E.e = $__hx_shallows.E.e = function() { }; ... })(); var E = {}; var x = {y:{}}; var A = $__hx_shallows.A; var B = $__hx_shallows.B; x.y.D = $__hx_shallows.x.y.D; x.C = $__hx_shallows.x.C; E.e = $__hx_shallows.E.e;
- Loading branch information
Showing
3 changed files
with
80 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters