How to share functionality between plugins?

I now did it via local npm packages.
I added all shared components to a local npm package and import it locally in every plugin like this:

"dependencies": {
    "sharedplugincomponents": "file:../sharedPluginComponents",
    "sharedpluginutils": "file:../sharedPluginUtils"
},