@@ -2,7 +2,7 @@ import { createUnplugin } from 'unplugin'
2
2
import { createRoutesContext } from './core/context'
3
3
import {
4
4
MODULE_ROUTES_PATH ,
5
- MODULE_VUE_ROUTER ,
5
+ MODULE_VUE_ROUTER_AUTO ,
6
6
getVirtualId as _getVirtualId ,
7
7
asVirtualId as _asVirtualId ,
8
8
routeBlockQueryRE ,
@@ -64,21 +64,24 @@ export default createUnplugin<Options | undefined>((opt = {}, _meta) => {
64
64
enforce : 'pre' ,
65
65
66
66
resolveId ( id ) {
67
- if ( id === MODULE_ROUTES_PATH ) {
67
+ if (
68
+ // vue-router/auto-routes
69
+ id === MODULE_ROUTES_PATH ||
70
+ // NOTE: it wasn't possible to override or add new exports to vue-router
71
+ // so we need to override it with a different package name
72
+ id === MODULE_VUE_ROUTER_AUTO
73
+ ) {
68
74
// virtual module
69
75
return asVirtualId ( id )
70
76
}
71
- // NOTE: it wasn't possible to override or add new exports to vue-router
72
- // so we need to override it with a different package name
73
- if ( id === MODULE_VUE_ROUTER ) {
74
- return asVirtualId ( id )
75
- }
76
77
77
78
// this allows us to skip the route block module as a whole since we already parse it
78
79
if ( routeBlockQueryRE . test ( id ) ) {
79
80
return ROUTE_BLOCK_ID
80
81
}
81
- return undefined // ok TS...
82
+
83
+ // nothing to do, just for TS
84
+ return
82
85
} ,
83
86
84
87
buildStart ( ) {
@@ -106,12 +109,14 @@ export default createUnplugin<Options | undefined>((opt = {}, _meta) => {
106
109
if ( id === ROUTE_BLOCK_ID ) return true
107
110
const resolvedId = getVirtualId ( id )
108
111
return (
109
- resolvedId === MODULE_ROUTES_PATH || resolvedId === MODULE_VUE_ROUTER
112
+ resolvedId === MODULE_ROUTES_PATH ||
113
+ resolvedId === MODULE_VUE_ROUTER_AUTO
110
114
)
111
115
} ,
112
116
113
117
load ( id ) {
114
118
// remove the <route> block as it's parsed by the plugin
119
+ // stub it with an empty module
115
120
if ( id === ROUTE_BLOCK_ID ) {
116
121
return {
117
122
code : `export default {}` ,
@@ -130,7 +135,7 @@ export default createUnplugin<Options | undefined>((opt = {}, _meta) => {
130
135
}
131
136
132
137
// vue-router/auto
133
- if ( resolvedId === MODULE_VUE_ROUTER ) {
138
+ if ( resolvedId === MODULE_VUE_ROUTER_AUTO ) {
134
139
return ctx . generateVueRouterProxy ( )
135
140
}
136
141
0 commit comments