Dynamic import from R2

Hi there!

I’m trying to import a file that I have uploaded to R2 with the following code:

export function retrieveApp(appPath: string) {
  try {
    return import(appPath);
  } catch (err) {
    console.log("IMPORT ERROR", err);
    throw err;
  }
}

Where the appPath is basically a URL to a js module inside an R2 bucket.

But my problem is that the error is: Error: No such module “my-r2-url-goes-here”.

Is there any way to have it working? I’m sure the module is working fine, because if I run it locally in Deno it works perfectly. And I have tested the script many times and it has the exported method working fine from Vite build.