Unable to load module dynamically, if the module name is dynamic
Unanswered
Australian Freshwater Crocodile posted this in #help-forum
Australian Freshwater CrocodileOP
This works
but this does not :
Error:
This is being done as part of a RSC.
await import("src/records/flights/2020/20200915EDKBEDKB").then(mod => mod.flight);but this does not :
const readPromises = years.map((f) => fs.readdir(f, { withFileTypes: true }));
const flightPromises = (await Promise.all(readPromises))
.flat()
.filter((e) => e.isFile() && e.name.includes(".ts"))
.map((e) => `${e.path.replace("./", "")}/${e.name.replace(".ts", "")}`)
.map((e) => import(e).then((mod) => mod.flight));Error:
Error: Cannot find module 'src/records/flights/2020/20200915EDKBEDKB'This is being done as part of a RSC.
const StatsPage = async () => {
const { flightLog } = await getFlightLog();
return <></>
}
export default StatsPage;