Skip to content

Commit b92194b

Browse files
committed
feat(wip): preliminary support for vue-router 4 & vuex 4
1 parent 136d5c9 commit b92194b

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

generator/index.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,49 @@ module.exports = (api) => {
1313
prune: true
1414
})
1515

16+
if (api.hasPlugin('vuex') || api.generator.pkg.dependencies['vuex']) {
17+
api.extendPackage({
18+
dependencies: {
19+
vuex: '^4.0.0-alpha.1'
20+
}
21+
})
22+
23+
api.exitLog('Installed vuex 4.0.')
24+
api.exitLog('Codemod not yet implemented, please follow the documentation at https://github.com/vuejs/vuex/tree/4.0')
25+
26+
// Codemod TODOs:
27+
// * Remove `Vue.use(Vuex)`
28+
// * `new Vue({ store })` -> `app.use(store)`
29+
// * optional: `new Vuex.Store({})` -> `createStore({})`
30+
}
31+
32+
if (api.hasPlugin('router') || api.generator.pkg.dependencies['router']) {
33+
api.extendPackage({
34+
dependencies: {
35+
'vue-router': '^4.0.0-alpha.3'
36+
}
37+
})
38+
39+
api.exitLog('Installed vue-router 4.0.')
40+
api.exitLog('Codemod not yet implemented, please follow the documentation at https://github.com/vuejs/vue-router-next')
41+
42+
// Codemod TODOs:
43+
// * Remove `Vue.use(VueRouter)`
44+
// * `new VueRouter({})` -> `createRouter({})`
45+
// * `mode`:
46+
// * `mode: 'history'` -> `history: createWebHistory()`
47+
// * `mode: 'hash'` -> `history: createWebHashHistory()`
48+
// * `mode: 'abstract'` -> `history: createMemoryHistory()`
49+
// * `new Vue({ router })` -> `app.use(router)`
50+
// * Async component syntax migration as described in RFC0007
51+
// * Create the corresponding imports
52+
// * Remove unused imports (use ESLint for this task)
53+
54+
// Others:
55+
// * Catch all routes (`/*`) must now be defined using a parameter with a custom regex: `/:catchAll(.*)`
56+
// * `keep-alive` is not yet supported
57+
// * Partial support of per-component navigation guards. No `beforeRouteEnter`
58+
}
59+
1660
api.transformScript(api.entryFile, require('./codemods/rfc09-global-api'))
1761
}

0 commit comments

Comments
 (0)