Importing pubsub-peer-discovery in a electron project : ERR_PACKAGE_PATH_NOT_EXPORTED

Is it possible to use libp2p in a electron project ? (Electron:16.0.7, Node:16.17.0)
I am trying to create a libp2p network using the main.js process (to be not limited by a web only network).

But as soon as I add
import { PubSubPeerDiscovery } from '@libp2p/pubsub-peer-discovery'
I have a ERR_PACKAGE_PATH_NOT_EXPORTED error, which is the same error as if require is used. The same error occurs with @libp2p/webrtc-star-signalling-server which is also ESM only.

To reproduce it, I’ve asked also in Quasar discussions as this may come from the Quasar/Electron setup.

I have tried a lot of setup, as explained here for example, but nothing works, so I wonder if this is even possible.

If it may help others, it looks like the solution is to do dynamic import :
const { PubSubPeerDiscovery } = await import('@libp2p/pubsub-peer-discovery');