Skip to content
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

Move to Vue 3 #526

Closed
wants to merge 58 commits into from
Closed

Move to Vue 3 #526

wants to merge 58 commits into from

Conversation

matthew-white
Copy link
Member

@matthew-white matthew-white commented Jan 18, 2022

In this PR, we migrate from Vue 2 to Vue 3. There are some big changes (for example, no more Vuex store!), but most components and tests saw only small changes.

For the record, the order of commits here does not reflect the actual order of my work: I have tried to group the commits thematically. Each commit should reflect a single change, but many changes were needed to move to Vue 3, so tests don't start passing until the final commits. I have tried to organize the commits so that it will be easier for us to look back on these changes. However, the end result was my first priority, and there are places where changes have ended up in the wrong commit. (I will note these as I notice them.) I force-push below, but I didn't overwrite a commit once it was reviewed.

The commits are organized along the following broad changes:

  • Standalone changes to Vue Test Utils: e947239...d1ef21f
  • Standalone changes related to Vue and Vue 3: d1ef21f...7f8b98c, 98de278...c1d3381
  • Standalone changes to the router: 7f8b98c...98de278
  • Standalone changes to Vue I18n
  • Replace globals with factories (including the router and Vue I18n)
    • This involves the introduction of a container concept. One nice thing about the container is that it makes it easier to mock certain behavior.
    • 25b3ff6 reworks some things related to Vue Test Utils and Vue 3, including how plugins are set up in testing.
    • See also the next set of commits, which likewise add factories.
  • Replace the Vuex store (mostly with the Vue 3 reactivity API)
    • This reduces boilerplate and gives us more flexibility. In particular, I think how requestData is organized is much clearer now.
    • Some Vuex-inspired practices remain. For the most part, data cannot be mutated directly: a method must be called. (The simple unsavedChanges object might be the only exception.) requestData can be configured to log all changes in order to facilitate debugging.
    • One unexpected outcome of this is that there are now many fewer differences between sending a request using requestData and sending a request using useRequests()/mixinRequests. Both now use the new generic request() function.
    • Another nice outcome is that we no longer need a specialized reconcileData mechanism: we can simply use the reactivity API.
  • Add composables or other alternatives to select mixins so that components using the Composition API can access that functionality
    • There are also now no mixin factories: mixins are always simple objects. If reusable behavior requires arguments, that is a strong sign that the Composition API is called for.
  • Use the Composition API in select components

There are other one-off changes below, but the ones above are probably the most important.

https://v3.vuejs.org/guide/migration/vnode-lifecycle-events.html

We still need to account for hook:beforeDestroy events, which we will do
later.
@matthew-white matthew-white requested a review from ktuite January 18, 2022 17:40
Copy link
Member Author

@matthew-white matthew-white left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notes from review through 427f100

src/components/async-route.vue Show resolved Hide resolved
This was linked to issues Jan 19, 2022
@matthew-white matthew-white linked an issue Jan 24, 2022 that may be closed by this pull request
@matthew-white matthew-white mentioned this pull request Feb 19, 2022
@matthew-white matthew-white mentioned this pull request Mar 18, 2022
@matthew-white
Copy link
Member Author

matthew-white commented Apr 20, 2022

I've been able to extract many of these commits into separate PRs compatible with our Vue 2 codebase. I'm continuing to do so, and once that's done, I'll create a new PR with the smaller set of commits that absolutely won't work in Vue 2. I don't think it makes sense to reuse this PR for that smaller set of commits, so I'll go ahead and close this PR.

I'm putting together a summary of all the PRs related to Vue 3 in #565, and once that's done, that'll be the best place to go to understand the different aspects of the move to Vue 3. I'm also going to go ahead and map each commit here to the PR or commit it was ultimately moved to. That's mostly useful just as a way to plan for the PRs to come: again, to learn about how the migration actually unfolded, see #565. If I remember correctly, @ktuite and I reviewed through 4f16351.

Hash Message Destination
7814c4c Replace propsData with props for Vue Test Utils 210abcd, eaa85f8
fcc27b0 Make changes now that Vue Test Utils findAll() returns different type 16c9488
d1ef21f Update link to Vue Test Utils #580
c1d7e8e Remove Vue.config.productionTip e398833
29ac549 Remove $set() 8875394
fffb9c8 Use markRaw() for select data properties 4354afb
d1d2852 Replace $listeners with $attrs c5d3481
5aff7e3 Replace "destroy" with "unmount" 9131c43
5e8a4c0 Make changes related to v-model 20b95c1
330c708 Add emits option to components #579
7f8b98c Update how app is initialized 2584d59
e090a33 Update how router is initialized 600e557, d793bb9
afb4ce3 Account for removal of standalone * from route path pattern 72db00e
427f100 Simplify navigation guards 292adae
48f8be8 Simplify access to route meta fields dce08dd
4ddc6c4 Account for changed return value of router.resolve() 4174371
301156a Account for changed type of router.currentRoute 124844a
2a8299f Remove currentRoute from store a25e243
98de278 Remove anyNavigationConfirmed from store 8633b02
ecf8fe5 Use markRaw() in SubmissionFieldDropdown 4354afb
c1d3381 Temporarily remove password strength meter #586
1f33273 Update how Vue I18n is initialized 8bbb596
4f16351 Account for changes to translation component #575
  (end of commits reviewed in this PR)
8713a6f Do more to account for i18n special characters
32711ab Remove unneeded method from ComponentInterpolationNode
5a55d00 Make small changes to Translations.prototype.toJSON()
acba324 Update Vue CLI options for Vue I18n 2b767be
25b3ff6 Add factory for router 6fbfe04, #576, 57f669c, 46516ec, 7c650e5, e6b4fa0, 6b7c9fa
1f2b8fb Move alert out of store 2befb91
a9a9c84 Move config out of store 057d342, #578
bb0fe73 Move sendInitialRequests out of store 4fd529d
2ff7773 Move unsavedChanges out of store #583
8c1cd2e Remove unneeded presenters 1df526f
8159dd1 Move files related to request module
d661f89 Move request data out of store 2240c7c, 1ab9cb4 (partly)
97db863 Refactor UserList and ProjectUserList
9cbda91 Add factory for i18n 9c9d01a, #566 (specifically some of the changes to formatDate()), 359a8c6, 546a823, e1d986b, 943aa70
a796f63 Add missing file header #562
edb678b Move $tcn() to global mixin 6fbfe04
f0314f4 Rename parameter of $tcn() #568
6c3b98b Consolidate Mocha hooks 11ec50f
faf86eb Move logger into container 3544f45, 49751ff
86ef123 Use consistent methods to log errors #571
d23423f Move http into container d0291bb, a01049c, 42c2975
bd22b20 Update unit tests related to requests
e2be7a6 Split up setup.js, moving style imports into separate file 93b5272
7b50764 Move select mixins to src/reusables 155dfc2 (partly)
151523b Add object to manage modal data
9d2bd5c Add useCallWait() composable in addition to mixin f972092
90bc354 Rename routes mixin and add composable
85f79cc Add useRequests() composable in addition to mixin
21a62b0 Add useTabs() composable in addition to mixin
7b1f446 Rename remaining mixins d428a9a, #591 (partly)
591a7e2 Use Composition API in App component 0517a83, f972092, f910526
22dbc72 Use Composition API for components that use reconcileData 792ae75, 4bc30f9 (partly)
9a4e2c3 Use provide/inject with SubmissionList
e6c29b4 Update linter for Vue 3 745bace
ab4f113 Update .gitignore to match latest version of Vue CLI #564

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant