Conditionally import plugin

I have a custom plugin that allows me to connect to my hardware
the packaging has a bug, with IOS Appstore asking for a file I don’t have for a 3rd party lib…

anyhow, I can conditionally compile without that lib function…

BUT I cannot conditionally import the plugin
trying

if(useEstimote)
   import { EstimotePlugin as EstimoteUWBPlugin  } from 'estimoteplugin4';
else
   const EstimotePlugin = ()=>{}

error

[vite:vue] [vue/compiler-sfc] 'import' and 'export' may only appear at the top level

any magic ???

Can’t you use a dynamic import? See import() - JavaScript | MDN.

thanks, wasnt aware of this. works

1 Like