How to migrate a large app to Vue 3

How to migrate a large app to Vue 3

Vue Mastery

1 год назад

26,294 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@luismauricio6225
@luismauricio6225 - 13.06.2023 05:47

Imagine if the website I deployed 10 years ago stopped working because browsers dropped support for certain features. Fortunately, this isn't the case for any websites regardless of when they were deployed. It's disappointing that Vue isn't written in such away that's always backwards compatible. No one wants that extra work to migrate to a newer version 🙄

Ответить
@JP-hb4mv
@JP-hb4mv - 06.06.2023 01:36

The change is so big that I am considering a rewrite in React. The frontend churn is too much

Ответить
@probarsukov
@probarsukov - 10.08.2022 15:01

Also for us the i18n story was quite painful and of course Vuetify is a big mess. I do not know what is really worth it sometimes from my experience, just rewrite everything to React or migrate to Vue 3 ;)

Ответить
@Sivaprabu
@Sivaprabu - 06.08.2022 10:46

Where did they officially announce that vue2 support stopped?

Ответить
@ahmedjaouadi6095
@ahmedjaouadi6095 - 05.08.2022 14:57

I upgraded three vue2 projects, One of them had around 1800 components. also the upgrade included migrating to vite + using script setup + defineProps with Typescript.
After these intense experiences, I have to say there is no shortcut to do it, how I prefer doing it:
1- Start by droping webpack & configure vite build & hmr. Save this progress in a separate branch & create a new branch from this one to do the component upgrade in it.
2- Update vue packages, delete the components folder and start pulling the components file by file & upgrade them. (Better to start with your style-guide components like inputs/selects.. because they don't depend on other components and build your way up till you finish your first page then you can test it. If you are using vue router, just comment out all the routes and uncomment once your page is ready.
3- keep doing this until you finish all the pages. On your way to the last page, you will find yourself not just refactoring to vue3 but you are also extracting re-used functionalities into separate files, (autocomplete.ts, dragFile.ts..) and end up writing less code.
4- Update your testing tool config and make sure all your unit tests are green. Migrating to Vitest can be tackeled alone afterwards.

From Dev experience point of view, I think this way is the best as you easily track your progress, apply best practices and you can split the work in the team (each individual can select a set of components and start working with it and then they communicate what they did to the rest of the team in the end of each day).

It took one month (1800 components 8h/day 5d/week) and a half to get everything runing & start bug hunting. So its kinda of time-consuming + it will block new features.

Ответить
@_the_one_1
@_the_one_1 - 05.08.2022 12:42

With all due to respect, but I don't think this is the right way. In this way you will endup having the latest version of Vue 3 but not using Vue 3 as it should!

You will endup using Vuex which is not the recommended library. Pinia it is.

You will endup with Options API syntax. If you read through the docs you will see that Options API is discouraged. Script setup is the new way.

You will endup using Webpack and miss the DX of Vite but also the whole community behind it like Vitest, Auto-import-components, VueUse, Cypress Component Testing etc. Those can be added with Webpack but in my experience with Webpack all these are buggy whereas with Vite it just works.

In general, you will end up with using Vue 3 but still everything looking Vue 2-ish. Since Vite and Vue 3 the way we write apps has changed for the better (Pinia, Tailwind, Vite, Vitest, Historie, Cypress etc) and if you still use the old technologies then guess what. You will stay behind and then you will have to re-write everything in order to catch up. So it will be like 2 or 3 times migration.

Sorry for saying that but to me it doesn't sound like the right way of doing things. Personally I would prefer a re-write of the application. If might sound scary but it's actually not and companies should accept and understand innovation and go all-in to re-write. Vue 3 and script setup came because Evan You is always pro-innovation.

Ответить
@ColinRichardson
@ColinRichardson - 04.08.2022 19:39

Seems this didn't matter. This had zero information about vue-property-decorator and was actually a small app.

We should have documented our change. 2100 Vue components, with 230,000 lines of code changed.

Ответить
@ColinRichardson
@ColinRichardson - 04.08.2022 09:51

A little late for this I am afraid.. Guess what we just finished doing? and I mean "just".. We been rewriting for 3 months. We are in the "Linting is getting OUT OF MEMORY" phase of the migration. So we can run the app in dev, but not been able to build yet. Sad times..

Ответить