@@ -35,27 +35,29 @@ function loadMicroAppConfig(id, [ rootPath, originalMicPath ]) {
3535 microConfig [ symbols . KEY ] = id ;
3636 microConfig [ symbols . ORIGINAL_ROOT ] = originalMicPath ;
3737 const _microAppConfig = new MicroAppConfig ( microConfig ) ;
38- configCache [ name ] = _microAppConfig ;
3938 return _microAppConfig ;
4039 }
4140 return null ;
4241}
4342
4443function requireMicro ( id , changeRootPath , scope = '' ) {
4544 const { ROOT , SCOPE_NAME , NODE_MODULES_NAME } = CONSTANTS ;
46- const name = `${ SCOPE_NAME } /${ id } ` ;
47- if ( configCache [ name ] ) {
48- return configCache [ name ] ;
45+ if ( configCache [ id ] ) {
46+ return configCache [ id ] ;
4947 }
5048 let result = null ;
5149 // 兼容 id
5250 let originalMicPath = path . resolve ( ROOT , NODE_MODULES_NAME , scope , id ) ;
5351 const ps = _ . isFunction ( changeRootPath ) && changeRootPath ( id , originalMicPath ) || [ originalMicPath , originalMicPath ] ;
5452 result = loadMicroAppConfig ( id , ps ) ;
5553 if ( ! result ) {
54+ const name = `${ SCOPE_NAME } /${ id } ` ;
5655 originalMicPath = path . resolve ( ROOT , NODE_MODULES_NAME , scope , name ) ;
5756 const ps = _ . isFunction ( changeRootPath ) && changeRootPath ( id , originalMicPath ) || [ originalMicPath , originalMicPath ] ;
58- result = loadMicroAppConfig ( id , ps ) ;
57+ result = loadMicroAppConfig ( name , ps ) ;
58+ }
59+ if ( result ) { // cache
60+ configCache [ id ] = result ;
5961 }
6062 return result ;
6163}
0 commit comments