-
Notifications
You must be signed in to change notification settings - Fork 25
/
adhoc.js
31 lines (25 loc) · 974 Bytes
/
adhoc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* global URL:true */
var URL = require("mini-url");
var QS = require("qs");
var a = document.createElement("a");
var packageLocation;
var moduleId;
if (window.location.search) {
var query = QS.parse(window.location.search.slice(1));
var packageLocation = query['package-location'];
var moduleId = query['module-id'];
document.querySelector("[name=package-location]").value = packageLocation;
document.querySelector("[name=module-id]").value = moduleId;
run(packageLocation, moduleId);
}
function run(packageLocation, moduleId) {
packageLocation = URL.resolve(window.location, packageLocation);
moduleId = moduleId || "";
console.log("Require:", "package:", JSON.stringify(packageLocation), "id:", JSON.stringify(moduleId));
require.loadPackage(packageLocation)
.invoke("async", moduleId)
.then(function (exports) {
console.log("Exports:", exports);
console.log("Packages:", require.packages);
});
}