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);
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);
1 Reply
lisekilis
lisekilisOP6mo ago
it probbably doesn't keep the modules when building the worker how can I make sure that they are included?

Did you find this page helpful?