I have the following script which is attempted at exporting every single file from a particular folder, but I'm stucked at the export part of it.
Below is what I've attempted:
index.js
function exportAllFiles() {
fs.readdir(filesDir, (err, files) => {
if (err) {
console.log(err);
return;
}
files.forEach(async file => {
const module = await import(file);
//'export module.default' ;export statement is not working for me here, how can I make it work here?
});
})
}
exportAllFiles();
After importing each file as seen above I have no idea how to export it as the export statement doesn't seem to work for me in that block.
Any ideas would be really appreciated.
Thanks