Skip to content

Commit 26bff6e

Browse files
authored
feat(runtime): add mf_module_id to remote to add module debugging information (#2561)
1 parent 83382e4 commit 26bff6e

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

.changeset/sharp-toys-smile.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@module-federation/runtime': patch
3+
---
4+
5+
feat: add mf_module_id to remote to add module debugging information

packages/runtime/src/module/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class Module {
6363
}
6464

6565
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
66-
async get(expose: string, options?: { loadFactory?: boolean }) {
66+
async get(id: string, expose: string, options?: { loadFactory?: boolean }) {
6767
const { loadFactory = true } = options || { loadFactory: true };
6868

6969
// Get remoteEntry.js
@@ -127,6 +127,12 @@ class Module {
127127
}
128128
const exposeContent = await moduleFactory();
129129

130+
// This parameter is used for bridge debugging
131+
Object.defineProperty(exposeContent, Symbol.for('mf_module_id'), {
132+
value: id,
133+
enumerable: false,
134+
});
135+
130136
return exposeContent;
131137
}
132138
}

packages/runtime/src/remote/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ export class RemoteHandler {
156156
id,
157157
});
158158
const { pkgNameOrAlias, remote, expose, id: idRes } = remoteMatchInfo;
159-
const moduleOrFactory = (await module.get(expose, options)) as T;
159+
const moduleOrFactory = (await module.get(idRes, expose, options)) as T;
160160

161161
const moduleWrapper = await this.hooks.lifecycle.onLoad.emit({
162162
id: idRes,

0 commit comments

Comments
 (0)