Skip to content

Commit b505deb

Browse files
authored
fix: rename usePlugins to prevent swc react-refresh from throwing errors when replacing variables (#1880)
1 parent 21fcb2f commit b505deb

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

.changeset/honest-peas-dress.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+
fix: rename usePlugins to prevent swc react-refresh from throwing errors when replacing variables

packages/runtime/src/utils/hooks/pluginSystem.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class PluginSystem<T extends Record<string, any>> {
1717
this.lifecycleKeys = Object.keys(lifecycle);
1818
}
1919

20-
usePlugin(plugin: Plugin<T>): void {
20+
applyPlugin(plugin: Plugin<T>): void {
2121
assert(isPlainObject(plugin), 'Plugin configuration is invalid.');
2222
// The plugin's name is mandatory and must be unique
2323
const pluginName = plugin.name;
@@ -67,7 +67,7 @@ export class PluginSystem<T extends Record<string, any>> {
6767
!this.registerPlugins[pluginName],
6868
`The plugin "${pluginName}" has a conflict and cannot be inherited.`,
6969
);
70-
this.usePlugin(registerPlugins[pluginName]);
70+
this.applyPlugin(registerPlugins[pluginName]);
7171
});
7272
}
7373
}

packages/runtime/src/utils/plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export function registerPlugins(
2424
if (plugins && plugins.length > 0) {
2525
plugins.forEach((plugin) => {
2626
hookInstances.forEach((hookInstance) => {
27-
hookInstance.usePlugin(plugin);
27+
hookInstance.applyPlugin(plugin);
2828
});
2929
});
3030
}

0 commit comments

Comments
 (0)