icambron / twix.js

:hourglass::left_right_arrow: A date range plugin for moment.js
https://isaaccambron.com/twix.js/
MIT License
379 stars 54 forks source link

Adding explicit AMD module check #100

Closed fernando-berrios closed 7 years ago

icambron commented 7 years ago

I think you can ignore the CI failure; looks like I need to make some changes to Travis.

But can you explain what problem this PR fixes? I take it your environment has define defined as a global but it isn't AMD?

fernando-berrios commented 7 years ago

Sorta, we ran into an issue when using the Microsoft Bing Maps V8 library. For some reason they are defining an AMD-incompatible module loader and setting it to the global define variable when the library is loaded synchronously.

The rest of our code was not using any module system at all, so this threw us for a loop.

I looked into it and it seems that the general recommend approach is to check for an amd property inside of define (see https://github.com/umdjs/umd/blob/master/templates/amdWeb.js)

icambron commented 7 years ago

Cool, thanks!