diff --git a/packages/core/src/context/midwayContainer.ts b/packages/core/src/context/midwayContainer.ts index 67481ff778d1..5d6a433adb20 100644 --- a/packages/core/src/context/midwayContainer.ts +++ b/packages/core/src/context/midwayContainer.ts @@ -527,11 +527,19 @@ export class MidwayContainer // 如果是 main,则同步 alias 到所有的 namespace for (const value of this.configurationMap.values()) { if (value.namespace !== MAIN_MODULE_KEY) { - super.registerObject(value.namespace + ':' + identifier, target); + const key = + identifier.indexOf(value.namespace + ':') > -1 + ? identifier + : value.namespace + ':' + identifier; + super.registerObject(key, target); } } } else { - identifier = this.getCurrentNamespace() + ':' + identifier; + const key = + identifier.indexOf(this.getCurrentNamespace() + ':') > -1 + ? identifier + : this.getCurrentNamespace() + ':' + identifier; + identifier = key; } } return super.registerObject(identifier, target);