Is it possible for browser javascript to create a new JS-file programmatically and then import it?
Here is some code that I tried out but didn't work:
const file = new File([`export function main() {console.log("AAA")}; main();`], "transpiled.js", {
type: "text/javascript"
})
import("./transpiled.js") // this says: net::ERR_ABORTED 404 (Not Found)
import("transpiled.js") // this says: Uncaught (in promise) TypeError: Failed to resolve module specifier 'transpiled.js'
The task is to get AAA
as console output.