@@ -103,25 +103,29 @@ export function installHook (target) {
103
103
getters : store . getters
104
104
}
105
105
// Dynamic modules
106
- hook . storeModules = [ ]
107
- const origRegister = store . registerModule . bind ( store )
108
- store . registerModule = ( path , module , options ) => {
109
- if ( typeof path === 'string' ) path = [ path ]
110
- hook . storeModules . push ( { path, module, options } )
111
- origRegister ( path , module , options )
112
- }
113
- const origUnregister = store . unregisterModule . bind ( store )
114
- store . unregisterModule = ( path ) => {
115
- if ( typeof path === 'string' ) path = [ path ]
116
- const key = path . join ( '/' )
117
- const index = hook . storeModules . findIndex ( m => m . path . join ( '/' ) === key )
118
- if ( index !== - 1 ) hook . storeModules . splice ( 0 , 1 )
119
- origUnregister ( path )
120
- }
121
- hook . flushStoreModules = ( ) => {
122
- store . registerModule = origRegister
123
- store . unregisterModule = origUnregister
124
- return hook . storeModules
106
+ if ( store . registerModule ) {
107
+ hook . storeModules = [ ]
108
+ const origRegister = store . registerModule . bind ( store )
109
+ store . registerModule = ( path , module , options ) => {
110
+ if ( typeof path === 'string' ) path = [ path ]
111
+ hook . storeModules . push ( { path, module, options } )
112
+ origRegister ( path , module , options )
113
+ }
114
+ const origUnregister = store . unregisterModule . bind ( store )
115
+ store . unregisterModule = ( path ) => {
116
+ if ( typeof path === 'string' ) path = [ path ]
117
+ const key = path . join ( '/' )
118
+ const index = hook . storeModules . findIndex ( m => m . path . join ( '/' ) === key )
119
+ if ( index !== - 1 ) hook . storeModules . splice ( 0 , 1 )
120
+ origUnregister ( path )
121
+ }
122
+ hook . flushStoreModules = ( ) => {
123
+ store . registerModule = origRegister
124
+ store . unregisterModule = origUnregister
125
+ return hook . storeModules
126
+ }
127
+ } else {
128
+ hook . flushStoreModules = ( ) => [ ]
125
129
}
126
130
} )
127
131
0 commit comments