Open
Description
Bug report
- [x ] I confirm this is a bug with Supabase, not with my own application.
- [ x] I confirm I have searched the Docs, GitHub Discussions, and Discord.
Describe the bug
It`s not possible to import typescrpit code as a string dynamically
To Reproduce
Add the following code to any of the examples:
async function importjs(js: string, filename = "importedjs") {
const dataUri =
"data:text/typescript;charset=utf-8," +
encodeURIComponent(js) +
`//# sourceURL=${filename}.ts;`;
const r = await import(/* @vite-ignore */ dataUri);
return r;
}
const r = await importjs(`export default (arg1:any) => {return 'hello world '+arg1}`)
console.log(r.default("test")) // EXPECTED: hello world test
The worker will error complaining about typescript sintax
{
"error": "Unexpected token ':' at data:text/typescript;charset=utf-8,export%20default%20(arg1%3Aany)%20%3D%3E%20%7Breturn%20'hello%20world%20'%2Barg1%7D//#%20sourceURL=importedjs.ts;:1:21"
}
Expected behavior
Typescript code should work
System information
- OS: Windows WSL 2, Oracle Linux