Skip to content

Commit f48530c

Browse files
committed
fix: ensure that pure esm modules without main can be imported (close #239)
1 parent d1faa4e commit f48530c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/iles/src/node/plugin/utils.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,12 @@ export async function tryInstallModule (name: string) {
4141
}
4242

4343
export async function importLibrary<T> (pkgName: string) {
44-
const pkgPath = await tryInstallModule(pkgName)
45-
return await importModule(pkgPath)
44+
try {
45+
const pkgPath = await tryInstallModule(pkgName)
46+
return await importModule(pkgPath)
47+
} catch (error) {
48+
return await importModule(pkgName)
49+
}
4650
}
4751

4852
async function withSpinner<T> (message: string, fn: () => Promise<T>) {

0 commit comments

Comments
 (0)