When I do import { foo } from 'NpmPackage';
it works
But when I try the below I get the error that Cannot find module 'NpmPackage'
async function tryImport(path) {
try {
return await import(path);
} catch (error) {
console.warn('doesnt work', error);
return {};
}
}
const { foo } = tryImport('NpmPackage');