Cloudflare DevelopersCD
Cloudflare Developers8mo ago
2 replies
lisekilis

lazy loaded modules in worker

I'm trying to lazy load some modules and it says that they are not found with the error No such module "ping.js"
commandName = interaction.data.name;
try {
    modulePath = `./${commandName}.ts`;
    commandModule = await import(modulePath);
} catch {
    modulePath = `./${commandName}.js`;
    commandModule = await import(modulePath);
}
if (!commandModule.execute) throw new Error('Command not found');
return await executeCommandModule(commandModule as ChatInputCommand, interaction, env, ctx);
Was this page helpful?