Skip to content

Commit

Permalink
[js] don't check for "window" for exports when -D nodejs
Browse files Browse the repository at this point in the history
  • Loading branch information
nadako committed Aug 12, 2015
1 parent 1f1089a commit 744b018
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions genjs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1254,6 +1254,8 @@ let generate com =
if has_feature ctx "Class" || has_feature ctx "Type.getClassName" then add_feature ctx "js.Boot.isClass";
if has_feature ctx "Enum" || has_feature ctx "Type.getEnumName" then add_feature ctx "js.Boot.isEnum";

let nodejs = Common.raw_defined com "nodejs" in

let exposed = List.concat (List.map (fun t ->
match t with
| TClassDecl c ->
Expand Down Expand Up @@ -1302,8 +1304,10 @@ let generate com =
let closureArgs = if (anyExposed && not (Common.defined com Define.ShallowExpose)) then
(
"$hx_exports",
(* TODO(bruno): Remove runtime branching when standard node haxelib is available *)
"typeof window != \"undefined\" ? window : exports"
if nodejs then
"exports"
else
"typeof window != \"undefined\" ? window : exports"
) :: closureArgs
else
closureArgs
Expand All @@ -1318,7 +1322,7 @@ let generate com =
closureArgs
in

if Common.raw_defined com "nodejs" then
if nodejs then
(* Add node globals to pseudo-keywords, so they are not shadowed by local vars *)
List.iter (fun s -> Hashtbl.replace kwds2 s ()) [ "global"; "process"; "__filename"; "__dirname"; "module" ];

Expand Down

0 comments on commit 744b018

Please sign in to comment.