-
-
Notifications
You must be signed in to change notification settings - Fork 199
Open
Labels
Description
I work on Symfony 5, from "node side" I have a main javascirpt "main.js" and, in the same directory, a directory called "modules" that contains some javascript Script (they are Class).
From the "main,js" I instantiate manually all the modules class like this :
import {Module1} from "./modules/Module1";
import {Module2} from "./modules/Module2";
// ...
import {Module2} from "./modules/ModuleN";
function loadModules(){
return [
new module1(),
new module2(),
// ...
new moduleN(),
];
}
Now I'm looking for instantiate automatically all modules files.
So I must get all files names in the directory 'modules' and do something like this :
function loadModules(){
const fs = require('fs');
fs.readdir('./modules', function (files){
files.forEach(function(file){
// ...
});
});
}
But when I use the readdir method of "fs", I get this error in front side : fs.readdir is not a function
I followed this solution webpack-contrib/css-loader#447 (comment) , but I keep the same error message
Any help is welcome :)