Eventually, the only issue was that the Vite configuration section I added was in the wrong place.
So now I had at lib vite.config:
rollupOptions: {
external: ['react', 'react-dom'],
}
and in app layer vite.config:
resolve: {
dedupe: ['react', 'react-dom', '@emotion/react', '@emotion/styled', '@mui/material', '@mui/system'],
},
That's a working configuration for me