(
{ token, dynamicMetadata, type }: ModuleFactory,
scope: ModuleScope,
)
| 161 | } |
| 162 | |
| 163 | private async setModule( |
| 164 | { token, dynamicMetadata, type }: ModuleFactory, |
| 165 | scope: ModuleScope, |
| 166 | ): Promise<Module> { |
| 167 | const moduleRef = new Module(type, this); |
| 168 | moduleRef.token = token; |
| 169 | moduleRef.initOnPreview = this.shouldInitOnPreview(type); |
| 170 | this.modules.set(token, moduleRef); |
| 171 | |
| 172 | const updatedScope = ([] as ModuleScope).concat(scope, type); |
| 173 | await this.addDynamicMetadata(token, dynamicMetadata!, updatedScope); |
| 174 | |
| 175 | if (this.isGlobalModule(type, dynamicMetadata)) { |
| 176 | moduleRef.isGlobal = true; |
| 177 | |
| 178 | // Set global module distance to MAX_VALUE to ensure their lifecycle hooks |
| 179 | // are always executed first (when initializing the application) |
| 180 | moduleRef.distance = Number.MAX_VALUE; |
| 181 | this.addGlobalModule(moduleRef); |
| 182 | } |
| 183 | |
| 184 | return moduleRef; |
| 185 | } |
| 186 | |
| 187 | public async addDynamicMetadata( |
| 188 | token: string, |
no test coverage detected