- From: guest271314 <notifications@github.com>
- Date: Mon, 19 Feb 2018 17:51:38 +0000 (UTC)
- To: w3c/FileAPI <FileAPI@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <w3c/FileAPI/issues/97/366764094@github.com>
Not following > 2 modules with the same source text it would collide. nor what the actual use case is. Do you mean something like ``` (async() => { const currentScript = document.currentScript; const requestModule = async({ url, dataURL = true }) => { let request, blob, reader, response; try { request = await fetch(url); blob = await request.blob(); console.log(blob, dataURL); reader = new FileReader(); response = new Promise((resolve, reject) => { reader.addEventListener("loadend", () => resolve(reader.result)); }); reader[dataURL ? "readAsDataURL" : "readAsText"](blob); } catch (err) { console.error(err); } return response; } let moduleNames = `abc, def`; // get module let moduleRequest = await requestModule({ url: "exports.js", dataURL: true }); // do stuff with `abc, def`; e.g., `console.log(abc, def)` let moduleBody = await requestModule({ url: "exportsBody.js", dataURL: false }); let scriptModule = `import {${moduleNames}} from "${moduleRequest}"; ${moduleBody}`; let script = document.createElement("script"); script.type = "module"; script.textContent = scriptModule; currentScript.insertAdjacentElement("afterend", script); })(); ``` -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/w3c/FileAPI/issues/97#issuecomment-366764094
Received on Monday, 19 February 2018 17:52:03 UTC