-
-
Notifications
You must be signed in to change notification settings - Fork 535
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
[simplebar-vue] another attempt to deliver the promised vue2 and 3 cross compatibilty #630
[simplebar-vue] another attempt to deliver the promised vue2 and 3 cross compatibilty #630
Conversation
This was based on master, do note that there was prior (failed) work at building a cross compatible version that was reverted and this had to be brought into this commit (conditional test-utils, swap-vue, etc) --- Using a SFC to create cross-compatible component lead us to unwanted bundle results when building the library. Apparently the template compiler used was the one for vue3. Manually changing rollup plugin vue compiler option to explicitly use other vue-template-compiler version did not change the results and even if did, we would need to compile 3 different versions and somewhat do a postinstall script that point consumers to the right one. Not sure how to do that so went with another approach. The alternative implemented was to convert the component into a pure render function, middleware to adjust arguments to vue2 and 3 signatures. This way there's no transformation when bundling, only minification and transpiling (babel) making output could work as expected even with a slight decrease on readability for maintainers.
- set simplebar-vue dependecy pointing to the local path so that it install the latest version after run build the command. Running yarn add simplbear-vue --force after a new build updates the dependency.
Alternatively, would it be simpler to just leave a raw |
Assuming that consumers are using some bundling system, yes that would work. But consumers that drop a |
Hi @renatodeleao and thanks for your hard work on this!
when loading the page. Is it working for you or I'm missing something? |
@Grsmto Nope, but I'm going to re-test and clear the cache on each test to be 100% sure. Did you get the in a specific version? |
@renatodeleao one thing I noticed is that testing from /examples is not totally "real world" testing because the /examples folder will fallback to the yarn workspace root
Also I usually test with |
@Grsmto I've retested it, and yes I also usually go with These were my actual QA tests, fully manual mode on:
I felt really dumb while doing this, but I'm questioning my sanity so 🤷 Another thing that I did was re-test all these steps above and check if
But again, please only ship this if you can 100% run this on your end. |
@Grsmto yeah i can see your point now, all vue2 demos are using |
I'll do isolated apps testing with |
I'll get back to it later. This needs more investigation, hold it for a little longer. |
@Grsmto here's how I've test it out for real:
Issues found
Give it a spin yourself and let me know how you want to proceed! |
@renatodeleao ok that seems like a painful process to test...
Can't we add it as a new dependency? |
@renatodeleao I released it as |
Great @Grsmto, yeah it's a safe move! There should be easier ways to test it, but I've run out of budget for this month, so I can't really investigate it ATM.
We can, but |
TL;DR
The previous implementations
1.7.0/1.7.1
had to be reverted because the bundled output was not cross-compatible as it just worked onvue@3
.vue@2
andvue@3
use different SFC (.vue
) compilers and have fundamental differences, sorollup-plugin-vue
was basically outputtingvue@3
only code. The alternative I choose was to remove the compilation step from the equation by using plain a plain render function for the component template, which gave full control of the output without any compilation step (besides js minification/transpilling).Details
[email protected]
, exclusively using options API is mandatory<template>
block into a render function. Ugly, but effective. Unit testing snapshots ensure that I didn't make any mistake.vue-demi
isVue3
flag is used to conditionally middleware this code appropriately1.7.2
I had to bring it back, please look at fix(vue) make compatible with vue 2 & 3 #609 for implementation details. It's mostly related with isomorphic testing and addition of the props API to complement the data-attributes one.package.json
, it requires you tobuild
the package before using the demos. Since we're lerna is not managing demos, I usually deletenode_modules
on each example after building just to make sure it is using the latest version and not some cached one.Alternatives
There isn't a standard art in authoring isomorphic vue components — note that component UI is a different category from composables/hooks and directives which are fairly easy to write in a cross-compatible way. This comment does summarize the feeling in trying to do so: vueuse/vue-demi#154 (comment). The alternatives fit into 3 categories:
postinstall
script to switch the correct version for consumer — I would go for this one if had experience in doing it, but I don't. Original reference and example repoLessons learned
Component
vue libraries is probably a mistake. Just because it's possible it does not mean you should do it.simplear-vue
wrapper is one of the simplest component wrappers you can build and yet I had a lot of trouble making sure it worked correctly on every version. Note that a lot of the complexity comes from supporting <[email protected]. Just supporting the latest 2.7 minor and 3.x would be far easier than this, and to be honest is probably a safe bet for a next minor release as vue 2.x is EOL next year and I'm there's not many people on2.5.x
out there.Final thoughts
simplebar@6
, it's probably a good opportunity forsimplebar-vue@2
that only supportsvue@3
.Footnotes
https://v3-migration.vuejs.org/breaking-changes/render-function-api.html ↩