Skip to content

Commit

Permalink
feat(booter): support loading ESM modules
Browse files Browse the repository at this point in the history
BREAKING CHANGE: `loadClassesFromFiles` now returns a `Promise`

Signed-off-by: Rifa Achrinza <[email protected]>
  • Loading branch information
achrinza committed Nov 16, 2024
1 parent d6b5183 commit 8874c12
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/boot/src/booters/booter-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ export function isClass(target: any): target is Constructor<any> {
* @param projectRootDir - The project root directory
* @returns An array of Class constructors from a file
*/
export function loadClassesFromFiles(
export async function loadClassesFromFiles(
files: string[],
projectRootDir: string,
): Constructor<{}>[] {
): Promise<Constructor<{}>[]> {
const classes: Constructor<{}>[] = [];
for (const file of files) {
debug('Loading artifact file %j', path.relative(projectRootDir, file));
const moduleObj = require(file);
const moduleObj = await import(file);
for (const k in moduleObj) {
const exported = moduleObj[k];
if (isClass(exported)) {
Expand Down

0 comments on commit 8874c12

Please sign in to comment.