Get module objects use vite or webpack.
npm install @jswork/scan-modules
import { scanVite, scanWebpack } from '@jswork/scan-modules';
// when vite
const moduleFiles = import.meta.glob('./shared/stores/**/*.ts', { eager: true });
const stores = scanVite(moduleFiles, { modules: '/stores/' });
// when webpack
const context = require.context('./shared/stores/modules', true, /\.ts$/);
const stores = scanWebpack(context, { modules: '/modules/' });
// result
const reuslt = {
"user": 'any',
"subChild2": 'any',
"subCtrl": 'any',
};
Code released under the MIT license.