-
-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
it's hard for developer to write a common component with vue-demi #153
Comments
I would suggest directly shipping SFC to npm and let userland plugin to compile it. |
Thanks for ur reply. |
Use unbuild for shipping the component directly |
Thanks! I will use it for my project. |
@wobsoriano any example? |
I have the same problem, I prefer to code in SFC syntax too I'm using
Compiled vue 2.6 vite-plugin-vue2:vue 2.7 @vitejs/plugin-vue2 :vue 3 @vitejs/plugin-vue: |
unbuild is good with |
have u find the way use |
Hi, Unfortunately no, I end up using for monorepo answer can be yes, but it questions the duty of vue-demi
|
Yeah, still I am same problem with the questioner, use |
this issue also related to this pull-request |
@Hisioni can you share your |
Of course, in this repository, still have question, i don't know how to config to generate d.ts on every vue version |
@Hisioni I have same issue too, I thought generating types only required once with Vue3 as main version in package.json
However, autocomplete props on component only pops up on Vue3 (using Volar) Found an example for handling type definitions separately 😨 also installed this package on Vue2 app autocomplete props are not showing only showed up on Vue3 an example that autocompletes props are showing up ctrl + space on Vue2.6 https://discord.com/channels/793943652350427136/1052340776186695751 |
You can refer to my project, I believe I have explored a relatively elegant solution. It allows you to use the |
For // global.d.ts or volar.d.ts
declare module '@vue/runtime-core' { // Vue 3
// declare module 'vue' { // Vue 2.7
// declare module '@vue/runtime-dom' { // Vue <= 2.6.14
export interface GlobalComponents {
GlobalComponent: typeof import('***')['GlobalComponent']
}
}
export {} or you can define preset/resolver for unplugin-vue-components in your package
// declaration: true
// dist/index.d.ts
import * as vue_demi from 'vue-demi';
declare const Component: vue_demi.DefineComponent<{...}>;
// custom index.d.ts
// dist/index.d.ts
// link to source file instead of generating d.ts file
export * from '../src/index' Warn the user to not use |
I've been trying to make universal components with Vue and using the hints from here I could make it work. The nice thing is that we don't need to write our template by manually calling the https://github.com/andresilva-cc/poc-vue-universal-component It is not fully polished, it probably lacks some features, but it's working. |
【description】:
I want to try create the same component for Vue2 & Vue3 in the same source code, so I find vue-demi. But.. I have seen some projects likes json-editor-vue. For compact Vue2 & Vue3, I found its source code write
render
options for 2 & 3. But i think it's hard for developer to code.I prefer to code in
template
in a sfc file. So i have some idea(We can smooth the difference withVue2
&Vue3
when we compile components). Can we write a component withsetup
&composition-api
in asfc
. And then when we compile the component, we can use a series of plugins forVue2
:unplugin-auto-import
,unplugin-vue2-script-setup
,vite-plugin-vue2
,[email protected]
, and plugins forVue3
:@vitejs/plugin-vue
.@antfu Maybe u have thought some idea before create this repo. So can u give me some advice or info?
The text was updated successfully, but these errors were encountered: