Re: [w3c/FileAPI] Support `Response` in `URL.createObjectURL` (#97)

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