chore: comments and types

This commit is contained in:
Igor Randjelovic
2021-11-21 18:46:48 +01:00
parent 6cf9cd9554
commit 805490677c

View File

@ -1,4 +1,9 @@
export function dynamicImportLoaderFactory() {
type ModuleLoader = (id: string) => Promise<any>;
/**
* @internal
*/
function dynamicImportLoaderFactory(): ModuleLoader | null {
let importESM;
try {
@ -10,6 +15,13 @@ export function dynamicImportLoaderFactory() {
return importESM;
}
/**
* Utility to interop with both cjs and esm modules, using require() before
* falling back to import() in case the target is an esm module.
*
* @param module String
* @returns
*/
export async function tryRequireThenImport(module: string) {
let result;