ChuHoMan/vue-demi-component-template

Documentation is not clear

Closed this issue · 1 comments

First of all, I really like the innovation and the approach,
I cloned the boilerplate to implement Vue3 components and use them in Vue2.7,
I was not able to import the Vue2.7 generated component in my Vue2.7 host application as the package.json is exporting the vue3 that is not rendering on Vue2.7.
So I had to change the export manually in the package.json to make it happen, and then it works,
I could not see any guidance in the documentation,
Maybe it was not clear to me.
Also it was not mentioning that we have to use install function to register the component.
This is my fix:

"exports": {
		".": {
			"types": "./dist/v3/index.d.ts",
			"import": "./dist/v3/index.es.js",
			"require": "./dist/v3/index.cjs.js"
		},
		"./vue2": {
			"types": "./dist/v2.7/index.d.ts",
			"import": "./dist/v2.7/index.es.js",
			"require": "./dist/v2.7/index.cjs.js"
		}
	},

and in Vue2 application

import {TemplateComponent} from "vue-demi-template-component/vue2"
TemplateComponent.install(Vue);

I'm sorry I just saw your comment now. The exports field in the package.json is automatically detected and updated through the postinstall script, so all you need to do is run pnpm install to correctly determine the Vue version currently in use.