Skip to content

Commit

Permalink
fix(mf): init-sharing with empty config
Browse files Browse the repository at this point in the history
  • Loading branch information
ahabhgk committed May 6, 2024
1 parent 7c68f97 commit 7589b7e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
it("should have single runtime chunk", () => {
__webpack_init_sharing__("default");
expect(typeof __webpack_require__.I).toBe("function")
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const { ModuleFederationPluginV1: ModuleFederationPlugin } = require("@rspack/core").container;

/** @type {import("@rspack/core").Configuration} */
module.exports = {
plugins: [
new ModuleFederationPlugin({}),
]
};
2 changes: 2 additions & 0 deletions packages/rspack/src/container/ModuleFederationPluginV1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { SharePlugin, Shared } from "../sharing/SharePlugin";
import { isValidate } from "../util/validate";
import { ContainerPlugin, Exposes } from "./ContainerPlugin";
import { ContainerReferencePlugin, Remotes } from "./ContainerReferencePlugin";
import { ShareRuntimePlugin } from "../sharing/ShareRuntimePlugin";

export interface ModuleFederationPluginV1Options {
exposes?: Exposes;
Expand Down Expand Up @@ -43,6 +44,7 @@ export class ModuleFederationPluginV1 {
compiler.options.output.enabledLibraryTypes!.push(library.type);
}
compiler.hooks.afterPlugins.tap("ModuleFederationPlugin", () => {
new ShareRuntimePlugin(this._options.enhanced).apply(compiler);
if (
options.exposes &&
(Array.isArray(options.exposes)
Expand Down

0 comments on commit 7589b7e

Please sign in to comment.