You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+50-51Lines changed: 50 additions & 51 deletions
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,7 @@ Inspired by [react-codemod](https://github.com/reactjs/react-codemod).
24
24
-[x] Basic testing setup and a dummy CLI
25
25
-[x] Support applying`jscodeshift` codemods to`.vue` files
26
26
-[x] Provide a programmatic interface for usage in`vue-cli-plugin-vue-next`
27
-
-[ ] (WIP) Set up tests
27
+
-[x] Set up tests
28
28
-[ ] (WIP) Implement the transformations described below for migration usage
29
29
-[ ] Built-in transformations need to support TypeScript
30
30
-[ ] Built-in transformations need to support module systems other than ES module, and those without modules
@@ -44,43 +44,41 @@ The migration path (to be integrated in a new version of [`vue-migration-helper`
44
44
5. Make sure to use the compat build of vue@3
45
45
6. Serve the app in development mode, fix the runtime deprecation warnings
46
46
47
-
>Note: even though most of the migration process can be automated, please be aware there might still be subtle differences between Vue 3 and Vue 2 runtime. Please double check before deploying your Vue 3 app into production.
47
+
>Note: even though most of the migration process can be automated, please be aware there might still be subtle differences between Vue 3 and Vue 2 runtime, and the codemods may have uncovered edge cases. Please double check before deploying your Vue 3 app into production.
| 🔵| needs to or can be implemented in the compat runtime|
57
55
58
56
####Fixable in ESLint
59
57
60
-
-🟢[RFC05: Replace`v-bind`'s`.sync` with a`v-model` argument](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0005-replace-v-bind-sync-with-v-model-argument.md)
58
+
-[RFC05: Replace`v-bind`'s`.sync` with a`v-model` argument](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0005-replace-v-bind-sync-with-v-model-argument.md)
61
59
- Can be detected and fixed by the[`vue/no-deprecated-v-bind-sync`](https://eslint.vuejs.org/rules/no-deprecated-v-bind-sync.html) ESLint rule
62
-
-🟢[RFC14: Remove`keyCode` support in`v-on`](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0014-drop-keycode-support.md)
60
+
-[RFC14: Remove`keyCode` support in`v-on`](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0014-drop-keycode-support.md)
63
61
- Can be detected and fixed by the[`vue/no-deprecated-v-on-number-modifiers`](https://eslint.vuejs.org/rules/no-deprecated-v-on-number-modifiers.html) ESLint rule
64
62
-`config.keyCode` can be supported in the compat build. It is also detectable with the[`vue/no-deprecated-vue-config-keycodes`](https://eslint.vuejs.org/rules/no-deprecated-vue-config-keycodes.html) ESLint rule
- Can be detected and fixed by the[`vue/no-shared-component-data`](https://eslint.vuejs.org/rules/no-shared-component-data.html) and the[`vue/no-deprecated-data-object-declaration`](https://eslint.vuejs.org/rules/no-deprecated-data-object-declaration.html) ESLint rules
67
65
68
66
####Codemods
69
67
70
-
-🟢[RFC01: New slot syntax](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0001-new-slot-syntax.md) and[RFC06: Slots unification](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0006-slots-unification.md)
71
-
-🟢Can be detected and partially fixed by the[`vue/no-deprecated-slot-attribute`](https://eslint.vuejs.org/rules/no-deprecated-slot-attribute.html) and[`vue/no-deprecated-slot-scope-attribute`](https://eslint.vuejs.org/rules/no-deprecated-slot-scope-attribute.html)
72
-
-🟢During the transition period, with the 2 ESLint rules enabled, it will warn users when they use`this.$slots`, recommending`this.$scopedSlots` as a replacement
73
-
-🟢When upgrading to Vue 3, replace all`.$scopedSlots` occurrences with`.$slots` (should pass the abovementioned ESLint checks before running this codemod) (implemented as`scoped-slots-to-slots`)
74
-
-🟠[RFC04: Global API treeshaking](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0004-global-api-treeshaking.md) &[RFC09: Global mounting/configuration API change](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0009-global-api-change.md)
68
+
-[RFC01: New slot syntax](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0001-new-slot-syntax.md) and[RFC06: Slots unification](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0006-slots-unification.md)
69
+
- Can be detected and partially fixed by the[`vue/no-deprecated-slot-attribute`](https://eslint.vuejs.org/rules/no-deprecated-slot-attribute.html) and[`vue/no-deprecated-slot-scope-attribute`](https://eslint.vuejs.org/rules/no-deprecated-slot-scope-attribute.html)
70
+
- During the transition period, with the 2 ESLint rules enabled, it will warn users when they use`this.$slots`, recommending`this.$scopedSlots` as a replacement
71
+
- When upgrading to Vue 3, replace all`.$scopedSlots` occurrences with`.$slots` (should pass the abovementioned ESLint checks before running this codemod) (implemented as`scoped-slots-to-slots`)
72
+
-[RFC04: Global API treeshaking](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0004-global-api-treeshaking.md) &[RFC09: Global mounting/configuration API change](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0009-global-api-change.md)
75
73
-**implemented as`new-global-api`**
76
-
-🟢`import Vue from 'vue'` ->`import * as Vue from 'vue'` (implemented as`vue-as-namespace-import`)
-🔵 Some global APIs now can only be used on the app instances, while it's possible to support the legacy usage in a compat build, we will provide a codemod to help migration. (`global-to-per-app-api`)
74
+
-`import Vue from 'vue'` ->`import * as Vue from 'vue'` (implemented as`vue-as-namespace-import`)
-🔴 Some global APIs now can only be used on the app instances, while it's possible to support the legacy usage in a compat build, we will provide a codemod to help migration. (`global-to-per-app-api`)
84
82
-`Vue.config`,`Vue.use`,`Vue.mixin`,`Vue.component`,`Vue.directive`, etc ->`app.**` (It's possible to provide a runtime compatibility layer for single-root apps)
2. If there's exactly one entry file and one root instance, but several other files are also using`Vue.*`, then transform the entry file to export the root instance, import it in other files and transform them with the imported root instance;
92
90
3. If there are more than one entry file or root instances, then the user needs to manually export the root instances, re-apply this codemod to those non-entry files with an argument designating the root instance.
93
91
- 🔵 Detect and warn on`optionMergeStrategies` behavior change
94
-
-🟠[RFC07: Functional and async components API change](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0007-functional-async-api-change.md)
92
+
-[RFC07: Functional and async components API change](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0007-functional-async-api-change.md)
95
93
- 🔵 a compatibility mode can be provided for functional components for one-at-a-time migration
96
-
-🟢Can be detected by the[`vue/no-deprecated-functional-template`](https://eslint.vuejs.org/rules/no-deprecated-functional-template.html) ESLint rule
94
+
- Can be detected by the[`vue/no-deprecated-functional-template`](https://eslint.vuejs.org/rules/no-deprecated-functional-template.html) ESLint rule
97
95
- 🔴 SFCs using`<template functional>` should be converted to normal SFCs
98
-
-🟠[RFC08: Render function API change](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0008-render-function-api-change.md)
99
-
-🟢Template users won't be affected
100
-
-🟠JSX plugin will be rewritten to cover most use cases (work-in-progress, available athttps://github.com/vueComponent/jsx/)
96
+
-[RFC08: Render function API change](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0008-render-function-api-change.md)
97
+
- Template users won't be affected
98
+
- JSX plugin will be rewritten to cover most use cases (work-in-progress, available athttps://github.com/vueComponent/jsx/)
101
99
- 🔴 For Users who manually write render functions using`h`
102
100
- 🔵 It's possible to provide a compat plugin that patches render functions and make them expose a 2.x compatible arguments, and can be turned off in each component for a one-at-a-time migration process.
103
101
- 🔴 It's also possible to provide a codemod that auto-converts`h` calls to use the new VNode data format, since the mapping is pretty mechanical.
104
102
- 🔴 Functional components using context will likely have to be manually migrated, but a similar adaptor can be provided.
105
-
-🟠[RFC12: Custom directive API change](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0012-custom-directive-api-change.md)
106
-
-🟢`bind` ->`beforeMount`
107
-
-🟢`inserted` ->`mounted`
108
-
-🟢remove`update` hook and insert a comment to note the user about the change
109
-
-🟢`componentUpdated` ->`updated`
110
-
-🟢`unbind` ->`unmounted`
103
+
-[RFC12: Custom directive API change](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0012-custom-directive-api-change.md)
104
+
-`bind` ->`beforeMount`
105
+
-`inserted` ->`mounted`
106
+
- remove`update` hook and insert a comment to note the user about the change
107
+
-`componentUpdated` ->`updated`
108
+
-`unbind` ->`unmounted`
111
109
- 🔴 VNode interface change (a runtime compat plugin is also possible, see the notes for RFC08)
- Can be detected by the[`vue/no-deprecated-inline-template`](https://eslint.vuejs.org/rules/no-deprecated-inline-template.html) ESLint rule
117
115
- 🔴 Possible alternatives are addressed[in the RFC](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0016-remove-inline-templates.md#adoption-strategy)
- Can be detected by the[`vue/no-reserved-component-names`](https://eslint.vuejs.org/rules/no-reserved-component-names.html) ESLint rule
120
118
- 🔴 A codemod can be implemented to rename all`<Teleport>` components to some other name like`<TeleportComp>`.
121
119
- 🔴[RFC26: New async component API](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0026-async-component-api.md)
122
120
- 🔵 In the compat build, it is possible to check the return value of functional components and warn legacy async components usage. This should cover all Promise-based use cases.
- There could be potential naming conflicts with existing component-level`emits` options, so we need to scan and warn on such usages
129
127
- To better utilize the new`emits` option, we can provide a codemod that automatically scans all instances of`$emit` calls in a component and generate the`emits` option
130
-
-🟢[Vuex 3.x to 4](https://github.com/vuejs/vuex/tree/4.0)
128
+
-[Vuex 3.x to 4](https://github.com/vuejs/vuex/tree/4.0)
131
129
-**implemented as in combination of`new-global-api` and`vuex-v4`**
132
-
-🟢`Vue.use(Vuex)` &`new Vue({ store })` ->`app.use(store)`
133
-
-🟢`new Store()` ->`createStore()`
134
-
-🟠[Vue Router 3.x to 4](https://github.com/vuejs/vue-router-next)
130
+
-`Vue.use(Vuex)` &`new Vue({ store })` ->`app.use(store)`
131
+
-`new Store()` ->`createStore()`
132
+
-[Vue Router 3.x to 4](https://github.com/vuejs/vue-router-next)
135
133
-**implemented as in combination of`new-global-api` and`vue-router-v4`**
- Subtle differences between`@vue/composition-api` and the Vue 3 implementation are listed in the[`@vue/composition-api` README](https://github.com/vuejs/composition-api#limitations)
154
153
155
154
####RFCs that May Need Amendments to Simplify the Migration
156
155
@@ -168,7 +167,7 @@ These features are only deprecated but still supported in the compatiblity build
168
167
There will be runtime warnings and ESLint rules to detect their usages.
169
168
Some of them can be automatically migrated with the help of codemods.
- Can be detected by the[`vue/no-deprecated-filter`](https://eslint.vuejs.org/rules/no-deprecated-filter.html) ESLint rule
173
172
- 🔴[RFC18: Transition class name adjustments](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0018-transition-class-change.md)
174
173
- For`<transition>` components with custom`enter-class` or`leave-class`:
@@ -177,17 +176,17 @@ Some of them can be automatically migrated with the help of codemods.
177
176
- Otherwise, there are two possible solutions:
178
177
- Change every`.v-enter` and`.v-leave` selector in the stylesheets to`.v-enter-from` and`.v-leave-from`
179
178
- Or, attach`enter-from-class="v-enter v-enter-from" leave-from-class="v-leave v-leave-from"` to these`<transition>` components. Users can delete these attributes after they updated the corresponding stylesheets
180
-
-🟠[RFC20: Events API Change](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0020-events-api-change.md)
181
-
-🟢Can be detected by the[`vue/no-deprecated-events-api`](https://eslint.vuejs.org/rules/no-deprecated-events-api.html) ESLint rule
179
+
-[RFC20: Events API Change](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0020-events-api-change.md)
180
+
- Can be detected by the[`vue/no-deprecated-events-api`](https://eslint.vuejs.org/rules/no-deprecated-events-api.html) ESLint rule
182
181
- 🔴 A codemod can be implemented to use other libraries like[tiny-emitter](https://github.com/scottcorgan/tiny-emitter) for the events API
-🟢The[`vue/no-deprecated-html-element-is`](https://eslint.vuejs.org/rules/no-deprecated-html-element-is.html) ESLint rule can be used to detect usage for`is` usage on built-in HTML tags.
189
+
- The[`vue/no-deprecated-html-element-is`](https://eslint.vuejs.org/rules/no-deprecated-html-element-is.html) ESLint rule can be used to detect usage for`is` usage on built-in HTML tags.