Skip to content

Instantly share code, notes, and snippets.

@vsimko
Created October 4, 2019 18:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vsimko/fd3c22dfbfb860440df2f5fb91c972f7 to your computer and use it in GitHub Desktop.
Save vsimko/fd3c22dfbfb860440df2f5fb91c972f7 to your computer and use it in GitHub Desktop.
// from https://2ality.com/2019/10/eval-via-import.html
function esm(templateStrings, ...substitutions) {
let js = templateStrings.raw[0];
for (let i=0; i<substitutions.length; i++) {
js += substitutions[i] + templateStrings.raw[i+1];
}
return 'data:text/javascript;base64,' + btoa(js);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment