I have a common exported property, route, in all of my imported modules, which I would like to access dynamically, but cannot decide how to iterate over the list of imported modules. It can be done?
import User from '/components/user.js';
import Document from '/components/document.js';
var routes = [];
[array of imported modules].forEach(m => routes.push(m.route));
UPDATE:
So far I have tried the following and cannot find a list of modules on any of them
console.log(User.constructor);
console.log(Reflect.ownKeys(this));
console.log(Reflect.ownKeys(User));
Where should I look?
source
share