Skip to content

Commit

Permalink
ignoring packed scripts...
Browse files Browse the repository at this point in the history
  • Loading branch information
ackava committed Feb 10, 2024
1 parent 9f0615b commit 55c0f51
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
(function () {
(() => {

let script = document.currentScript;
let src = script.src;
let index = src.lastIndexOf("/");
src = src.substring(0, index);

function loadScript(url) {
const loadScript = (url) => {
return new Promise((resolve, reject) => {
var script = document.createElement("script");
script.type = "text/javascript";
Expand All @@ -28,9 +28,9 @@
};
document.body.appendChild(s);
});
}
};

function loadPackage() {
const loadPackage = () => {

let package = script.getAttribute("data-package");
let packageRoot = script.getAttribute("data-package-root");
Expand All @@ -49,17 +49,15 @@

const packed = JSON.parse(script.getAttribute("data-packed") ?? "true");
const min = JSON.parse(script.getAttribute("data-min") ?? "true");

const viewUrl = `${packageRoot}/${view}${packed ? ".pack" : ""}${min ? ".min" : ""}.js`;
const viewName = view.startsWith("@") ? view : `${package}/${view}`;

loadScript(viewUrl).then(() => {
const init = () => {
function empty () {
return function () {
return null
}
}

AmdLoader.moduleProgress = empty;
function done () {
const we = document.getElementById("webAtomsLoader");
Expand All @@ -80,9 +78,16 @@
}
}
UMD.loadView(viewName, 0).then(done);
});
}

}
if (!packed) {
init();
return;
}

const viewUrl = `${packageRoot}/${view}${packed ? ".pack" : ""}${min ? ".min" : ""}.js`;
loadScript(viewUrl).then(init);
};

loadPackage();
})();

0 comments on commit 55c0f51

Please sign in to comment.