polyfill old AMD's define
Change-Id: Id04331b264672ef5d767ee2e1e1dd908a1c36e24 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/339516 Reviewed-by: James Butters <jbutters@instructure.com> Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> QA-Review: Aaron Shafovaloff <ashafovaloff@instructure.com> Product-Review: Aaron Shafovaloff <ashafovaloff@instructure.com>
This commit is contained in:
parent
a5e72500be
commit
df916f7ddb
|
@ -11,6 +11,33 @@
|
|||
import HandlebarsExports from 'handlebars/runtime.js'
|
||||
import jQuery from 'jquery'
|
||||
|
||||
/* begin define / AMD polyfill */
|
||||
var registry = {};
|
||||
|
||||
const define = function(name, deps, callback) {
|
||||
if (typeof name !== 'string') {
|
||||
throw new Error('Module name must be a string');
|
||||
}
|
||||
if (!Array.isArray(deps)) {
|
||||
throw new Error('Dependencies must be an array');
|
||||
}
|
||||
if (typeof callback !== 'function') {
|
||||
throw new Error('Module factory must be a function');
|
||||
}
|
||||
|
||||
registry[name] = callback.apply(null, deps.map(function(dep) {
|
||||
if (registry[dep]) {
|
||||
return registry[dep];
|
||||
} else {
|
||||
throw new Error('Module ' + dep + ' not found');
|
||||
}
|
||||
}));
|
||||
};
|
||||
|
||||
// Mark this 'define' function as AMD compliant
|
||||
define.amd = {};
|
||||
/* end define / AMD polyfill */
|
||||
|
||||
const Handlebars = HandlebarsExports.default;
|
||||
const Ember = window.Ember = {};
|
||||
const MetamorphENV = Ember.MetamorphENV = {};
|
||||
|
|
Loading…
Reference in New Issue