question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature Request]: Use VueDemi to make lib compatible with Vue2 and Vue3

See original GitHub issue

Hey 👋

I’ve read the related issues (#136, #31 and so on) before and am aware that headlessui does not work for Vue 2 right now. While Vue 3 is out for a couple of months now and adoption rate is growing, several parts of the ecosystem are still catching up. Thus, it’d be amazing to have Vue 2 support. I know that supporting Vue 2 seems like a larger undertaking but from my understanding it is definitely doable via vue-demi, ideally without lots of changes.

Do you think it’d be interesting to take a look into vue-demi (or would you maybe consider a PR adding Vue 2 support with it)?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
adamwathancommented, Jan 2, 2021

It’s doable but definitely a lot of work because the VNode structure is different in 2 vs 3, and all of our components are written using raw VNode stuff, no templates or anything. We’d have to add a significant amount of conditional logic, which would add a lot to the bundle size.

There are also a bunch of limitations in the composition API plugin that you need if you want to support Vue 2, and I bet we would run into issues there:

https://github.com/vuejs/composition-api#limitations

Headless UI is still very early in development and I expect that by the time it’s closer to v1.0 Vue 3 will be much more mainstream than it is now compared to 2.0, so unfortunately I don’t think it’s a good use of our resources to develop or maintain a Vue 2 version right now. If someone in the community wanted to build a separate library that reimplements the components for Vue 2 that’s totally welcome of course though, it’s all MIT 👍🏻

1reaction
JessicaSachscommented, Oct 27, 2022

Hey @adamwathan, I came up with a workflow and toolchain to cross-compile SFCs to Vue 2.7 and Vue 3 for library authors. I’m going to be giving a talk about it in May and publicizing a template based on it. In short, it reduces the burden of maintenance significantly for library maintainers as linting rules, types, testing, and building all work and output two different packages: one for Vue 2.7 users and one for Vue 3+ users.

It uses symlinks and I’m able to build and maintain a component library that renders and uses <script setup> and all the other goodies without needing long-running feature branches, backports, or separate source code. You’re still bound by some runtime caveats (namely, reactivity).

Would you be interested in revisiting this? It looks like the ecosystem might be stuck on 2.x for a while and I don’t want to have to reimplement Headless UI at work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Build a universal Vue component library with Vue Demi
Learn how to use Vue Demi, a tool that allows developers to build universal libraries for Vue 2 and Vue 3 without the...
Read more >
Make Libraries Working with Vue 2 and 3
Try Vue Demi!
Read more >
Use Vue Demi to build a component library compatible with ...
Implementing two feature requests and bug fixes is not ideal at all. ... import { Vue2 } from 'vue-demi' // in Vue 3...
Read more >
How to create the library that works with Vue 2.7 and Vue 3 ...
Vite provides the functionality to actually run and compile Vue, ... may want to take advantage of vue-demi to ensure maximum compatibility.
Read more >
gvcl-demi - npm Package Health Analysis - Snyk
... library compatible with both Vue 2 & Vue 3 via `vue-demi` & vue's render function. ... Ensure you're using the healthiest npm...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found