Best way to publish single Vue component for Vue 2 & 3

I want to publish Vue 3 components to NPM, but have them compatible with Vue 2 as well.

I am thinking, that I want to:

  • write Vue 3 composition api vue components
  • transpile & bundle the components as JS files so they can be used in Vue 2 projects.
  • present the components as-is for Vue 3 projects.

I’m sure I can figure out a good rollup setup to transpile & bundle the components to JS files.

However, I wonder, if I support 2 in-points to my NPM package:

  • one to the transpiled component as JS file for Vue 2
  • one to the .vue file component as-is for Vue 3

How do I set up my package.json, or what instructions should I write how people should import my package component based on if their project is Vue 2 or 3?

Any advice much appreciated.