Set AMD global before module definition
Merge pull request #1590 from ichernev/early-amd-global

Set AMD global before module definition