Do workers support dynamic module imports?

I'm trying to import modules dynamically. Is this supported with workers?

// Function to dynamically load database modules based on provider short names
async function loadDatabaseModule(shortName: string): Promise<IDatabaseOperations | null> {
try {
const module = await import(./providers/${shortName.toLowerCase()});
return module.default as IDatabaseOperations;

Here is the error I get:
"logs": [
{
"message": [
"Failed to load module for d1:",
"Error: No such module "providers/d1"."
],
"level": "error",
"timestamp": 1713577569672
}
Was this page helpful?