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:
Aaron Shafovaloff 2024-02-01 06:49:35 -07:00
parent a5e72500be
commit df916f7ddb
1 changed files with 27 additions and 0 deletions

View File

@ -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 = {};