I can't figure out why the loadmodules function does not work? Tested on 2 different machines to rule out environment. Added snippet below and link to project on github for reproduction.
When I call the listModules function of Awilix it finds the functions fine, but not in the loadmodules function?
Trying to call resolve I get the error: "AwilixResolutionError: Could not resolve 'loginController'."
Please review snippet here
import { createContainer, asClass, asValue, asFunction, Lifetime, InjectionMode } from 'awilix';
import awilix from 'awilix';
import loginController from './controllers/loginController.js'
const listModules = awilix.listModules;
const container = createContainer();
function setup() {
const modulesToLoad = [
['controllers/**/*.js', Lifetime.SCOPED],
];
// This does not work
container.loadModules(modulesToLoad, {
formatName: 'camelCase',
resolverOptions: { register: asFunction },
esModules: true // Loading ES modules
});
// This works
// container.register({
// loginController: awilix.asFunction(loginController)
// })
console.log(listModules(modulesToLoad))
console.log(container.registrations)
container.resolve('loginController')
}
export {
container,
setup
};
Link for project to reproduce: https://github.com/simonbinbox/AwilixTest