Vue Migration (Vue 2 -> Vue 3) #2597
Labels
d.hard
dependencies
Pull requests that update a dependency file
pr.CodeMaintenance 🛠
DevOps, refactoring, etc
Any related issues?
#2084 Vue Migration Investigation
Others:
Vue Migration Vue 2 to Vue 3
MarkBind (v5.5.3) is currently using Vue 2. Vue2 has reached EOL, (end-2023) and will not receive any type of support. Packages supporting Vue2 used may not be maintained by extension. This limits the extensibility and maintainability of MarkBind, especially the vue-components package. (UI Library Package).
Vue3 has TypeScript support, noticeable performance improvements and more responsive application. Also has smaller bundle size. Do note that Vue 3 does not support IE13 (internet explorer). Note that the migration is a time intensive process with codebase understanding required. Currently, MarkBind Vue components are authored in the Vue Options API style. While migrating to Vue 3, we should continue to use this API style. Future work can consider cost benefit of switching to using Composition API.
Breaking changes to expect include: breaking Vue framework API changes, different dependencies used for Vue 2 vs Vue 3, SSR.
Intricate understanding of both Vue 2, Vue 3, low-level dependency APIs and MarkBind (in particular with regards to SSR, Hydrating, Bundling) is needed to conduct this. Some relevant links to understanding / reviewing the PR:
Additionally, here are some relevant documentation of the codebase I have written and compiled to speed up the understanding process for purpose of peer development/review.
Work To-Do
Compilation and SSR of Vue (Core):
Page/PageVueServerRenderer.ts
needs to be updatedcompileVuePageAndCreateScript
method which compiles page into Vue Application to get the render function must be updated. For Vue 3, the way the render function is created and consumed is different. Do this without disabling SSR.renderVuePage
: Method that Renders Vue page app into html string (Vue SSR). Ensure that it works during migration process. Updated to use@vue/server-render
package for Vue3Webpack bundling (Core-Web)
Core-Web
library needs to be updatedcore-web/src/index.js
setup() process. Ensure setup functions for mounting Vue apps are not affected. Updated to use new Vueapp instance
setup API.vue-loader
packageVueCommonAppFactory.js
.The appFactory helps create the Vue app instances needed for each page, to set up the necessary configurations. Configure it if necessary for Vue 3, and adapt if needed for compatibility with Vue3 componentsVue Components SFCs
Vue-Components Library needs to be updated
Note: Vue 2 Options API -> Vue 3 Options API should not have too many changes. Should be the most straightforward process. However, a lot of dependencies have to be updated such as
floating vue
, etc.Vue Testing
Update all testing packages and dependencies
Plugins:
Update necessary plugins (change in Vue directive API)
dataTable
plugin as Vue Directive used.Mermaid
plugins as Vue Directive used.Relevant Changelog Vue2 to Vue3: (FYI)
new Vue()
createApp()
Object.defineProperty
Proxy
<teleport>
supportcreateApp
call creates completely isolated app instance with its own config and global properties. Due to differences, the Vue instance is setup differently.new Vue
to createSSRApp(): case study here on using render functioncompileVuePageAndCreateScript
)vue-server-renderer
is for Vue 2.0. Corresponding functionality for Vue 3 is in@vue/server-renderer
, which is actually a dependency of the mainvue
package.FAQ
We can use a migration build (Vue 2.7) that allows both Vue 2 & 3 code in a single codebase. Once done, migrate over to Vue 3. However, I faced some issues with getting
@vue/compat
to work.Some other sources:
Describe alternatives you've considered
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: