jeudi 30 janvier 2020

How can i use a single namespace for multiple imported modules?

Is it possible to have a single namespace for multiple imported modules ?, i wanna do something like this:

import {moduleA, moduleB, moduleC} as ModuleManager from 'AllMyModules.js';

So i can avoid conflicts such as module and class function having the same name, for example :

moduleA = () => {
}

doSomething = () => {
   ModuleManager.moduleA();
   moduleA();
}  

Of course that is not all, giving the modules a namespace also improves readability and helps me know where a function or module is coming from and for what purpose.

Please note that i already know about:

import * as ModuleManager from 'AllMyModules.js'  

And this is not what i'm looking for !, i don't want ModuleManager to include everything.

Aucun commentaire:

Enregistrer un commentaire