Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,11 @@ var init = function(shareScope, initScope) {{
share_scope_map = runtime_template.render_runtime_globals(&RuntimeGlobals::SHARE_SCOPE_MAP),
share_scope = json_stringify_str(match &self.share_scope {
ShareScope::Single(s) => s.as_str(),
ShareScope::Multiple(scopes) if scopes.len() == 1 => scopes[0].as_str(),
ShareScope::Multiple(_) => {
panic!("ContainerEntryModule: enhanced=false only supports string share scope")
panic!(
"ContainerEntryModule: enhanced=false only supports string or single-item array share scope"
)
}
}),
initialize_sharing =
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
it("should support single-item shareScope array in non-enhanced container", async () => {
const container = __non_webpack_require__("./container-file.js");
expect(container).toBeTypeOf("object");
expect(container.get).toBeTypeOf("function");
const testFactory = await container.get("./test");
expect(testFactory).toBeTypeOf("function");
expect(testFactory()).toBe("test");
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const { ContainerPlugin } = require("@rspack/core").container;

/** @type {import("@rspack/core").Configuration} */
module.exports = {
output: {
pathinfo: true
},
plugins: [
new ContainerPlugin({
name: "container",
filename: "container-file.js",
library: {
type: "commonjs-module"
},
shareScope: ["default"],
exposes: {
"./test": "./test"
}
})
]
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = "test";
Loading