Added AMD/CommonJS support
Created by: pherrymason
Hello, I have an almost ready modification to add support for both AMD and CommonJS modules, but before doing the pull request I want to know if this is a desired change by bootstrap maintainers.
I just implemented the schema seen here https://github.com/umdjs/umd/blob/master/jqueryPluginCommonjs.js, which is almost identically to what @liamks posted in #534, but with the difference this supports CommonJS too.
I have tested it with a CommonJS environment (webpack) and under classical plain globals, however I'm not pretty sure how to write the AMD part (I'm a CommonJS guy) where the transition plugin is used, specifically how to add the transition plugin as a dependency.
What about this?
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery', './transition.js'], factory)
} else if (typeof exports === 'object') {
var jQuery = require('jquery')
require('./transition.js')
factory(jQuery)
} else {
factory(this.jQuery)
}
}(function ($) {