Skip to content

Commit

Permalink
feat: impl import module with interop
Browse files Browse the repository at this point in the history
  • Loading branch information
yarastqt committed Apr 21, 2020
1 parent af24c07 commit 9ddf78a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/core/import-module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* Import module with esm interop.
*
* @param path Module path.
* @return Promise with data.
*/
export async function importModule<T>(path: string): Promise<T> {
const maybeModule = await import(path)
return maybeModule.default || maybeModule
}

0 comments on commit 9ddf78a

Please sign in to comment.