Skip to content

Commit e026bd5

Browse files
authored
Merge pull request #1054 from Patternslib/jquery-globally
fix(Build): Register jQuery globally.
2 parents 8f49053 + e72f41a commit e026bd5

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,11 @@ import "../webpack/module_federation";
33
// The next import needs to be kept with parentheses, otherwise we get this error:
44
// "Shared module is not available for eager consumption."
55
import("./patterns");
6+
7+
// Register jQuery gloablly as soon as this script is executed.
8+
async function register_global_libraries() {
9+
const jquery = (await import("jquery")).default;
10+
window.jQuery = jquery;
11+
window.$ = jquery;
12+
}
13+
register_global_libraries();

webpack/webpack.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ module.exports = () => {
3535
name: "patternslib",
3636
remote_entry: config.entry["bundle.min"],
3737
dependencies: package_json.dependencies,
38+
shared: {
39+
jquery: {
40+
singleton: true,
41+
requiredVersion: package_json.dependencies["jquery"],
42+
eager: true,
43+
},
44+
},
3845
})
3946
);
4047

0 commit comments

Comments
 (0)