jeffijoe / awilix

Extremely powerful Inversion of Control (IoC) container for Node.JS
MIT License
3.58k stars 135 forks source link

loadModules now working with native modules #217

Closed slavb18 closed 3 years ago

slavb18 commented 3 years ago

Trying to use loadModues with node v14.15.0 I have Application class:

import awilix from 'awilix';
import TestLogic from './core/TestLogic';

export default class Application {
  constructor() {
    this.container = awilix.createContainer();
    const opts = {
      formatName: 'camelCase',
      esModules: true
    };
    this.container.loadModules(['src/core/**/*.js'], opts);
    // this.container.register('testLogic', awilix.asClass(TestLogic));
  }
}

this.container.loadModules registers zero modules, see example project structure https://github.com/iconicompany/awilixexample

to reproduce error run test with npm run test

jeffijoe commented 3 years ago

You need to await loadModules when using esm

slavb18 commented 3 years ago

thank you Jeff!