chore(deps): upgrade import-from-esm

This commit is contained in:
Joakim Carlstein 2023-12-08 13:09:56 +01:00
parent bc85211009
commit 8f7f9a71d0
3 changed files with 9 additions and 17 deletions

View file

@ -43,7 +43,7 @@
"@emigrate/tsconfig": "workspace:*"
},
"dependencies": {
"import-from-esm": "1.2.1"
"import-from-esm": "1.3.3"
},
"volta": {
"extends": "../../package.json"

View file

@ -167,17 +167,6 @@ const getOrLoad = async <T>(
return undefined;
};
const getImportFromEsm = async () => {
const importFromEsm = await import('import-from-esm');
// Because of "allowSyntheticDefaultImports" we need to do this ugly hack
if ((importFromEsm as any).default) {
return (importFromEsm as any).default as unknown as typeof importFromEsm;
}
return importFromEsm;
};
const loadPlugin = async <T extends PluginType>(type: T, plugin: string): Promise<PluginFromType<T> | undefined> => {
return load(
plugin,
@ -193,7 +182,7 @@ const load = async <T>(
prefixes: string[],
check: (value: unknown) => value is T,
): Promise<T | undefined> => {
const importFromEsm = await getImportFromEsm();
const { default: importFromEsm } = await import('import-from-esm');
const importsToTry = name.startsWith('.') ? [name] : [...prefixes.map((prefix) => `${prefix}${name}`), name];