baconjs/bacon.js — pull request #349 by zoomzoom83 (2014-03-20 07:34:30+00:00)
Title: Do AMD detection first to work around conflict with AngularMocks

AngularMocks is very naughty and defines a global function named "module". (https://github.com/angular/angular.js/blob/master/src/ngMock/angular-mocks.js#L2021)

This conflicts with BaconJS's module loader detection, and tricks Bacon into thinking it's running inside a CommonJS context.

This makes it impossible to run unit tests in an AngularJS application when using Bacon.

This affects Bacon.Model as well.

The workaround is to detect AMD (RequireJS) modules first before looking for the existence of `module` on the global scope.

There are probably better solutions to this.