Export components from module
How can I export components from module?
For example, if I don't want to autoimport specific component or if consumer wants to import component explicitly.
I managed to find a way to export like this:
src/runtime/components/index.ts
export { default as Foo } from './foo.vue'
package.json
...
"exports": {
...
"./components": {
"types": "./dist/runtime/components/index.d.ts",
"import": "./dist/runtime/components/index.js"
}
},
But when I import Foo from my package, although its seems to work, the component has type any.
You can check details of my setup in this repo
I have also had issues with this. I couldn't export any single functions / components without using the addImport / addComponent helpers.
Is this something that addComponent (or addComposable) could be extended to support? My rough idea is that using one of these helpers would configure the autoimport as well as adding an export. (Maybe the root, or maybe package/components?)
That way module authors can easily support both autoimport and explicit importing applications and there will be common patterns across nuxt modules. Does that make any sense?