You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Module Federation allows sharing of dependencies between bundles.
14
14
Each bundle includes the whole set of dependencies.
15
-
However, if multiple bundles have the same dependencies they are loaded only once.
15
+
However, if multiple bundles have the same dependencies, then they are loaded only once.
16
16
17
-
For example, if bundle A and B both depend on jQuery and bundle A has already loaded it, bundle B can just reuse the already loaded jQuery file.
17
+
For example, if bundle A and B both depend on jQuery and bundle A has already loaded it, then bundle B can just reuse the already loaded jQuery file.
18
18
But if only bundle B is loaded, it uses its own bundled version of the jQuery library.
19
19
20
20
There is a host bundle, as in the fictional example above, our bundle A.
@@ -26,42 +26,43 @@ Webpack's documentation on [Module Federation](https://webpack.js.org/concepts/m
26
26
```
27
27
28
28
29
-
## Using module federation
29
+
## Use module federation
30
30
31
-
The following instructions are for you if you created an add-on with a Mockup pattern and you want to include the respective JavaScript code in your theme code.
32
-
Starting with the webpack configuration that you get when creating a Barceloneta theme package via [plonecli][1], add the following:
31
+
If you created an add-on with a Mockup pattern, and you want to include the respective JavaScript code in your theme code, then the following instructions are for you.
33
32
34
-
Create a new entry point `index.js` which only imports the normal entry point.
33
+
Starting with the webpack configuration that you get when creating a Barceloneta theme package via [`plonecli`](https://pypi.org/project/plonecli/), add the following.
34
+
35
+
Create a new entry point {file}`index.js` which only imports the normal entry point.
35
36
36
37
```js
37
38
import("./patterns");
38
39
```
39
40
40
-
Next add the module federation plugin in `webpack.config.js`.
41
+
Next add the module federation plugin in {file}`webpack.config.js`.
41
42
There is a configuration factory `mf_config` which you can use for that.
@@ -79,26 +80,20 @@ Below this line add the following:
79
80
```
80
81
81
82
Replace the name `myaddon` with your add-on bundle's unique name.
82
-
Replace the filename `myaddon-remote.min.js` with the file name you want to use for your remote bundle.
83
-
Finally replace `myaddon.min` with the corresponding key in `config.entry` that points to your `index.js`.
83
+
Replace the file name {file}`myaddon-remote.min.js` with the file name you want to use for your remote bundle.
84
+
Finally replace `myaddon.min` with the corresponding key in `config.entry` that points to your {file}`index.js`.
84
85
85
-
For a full but simple example, see the Patterns generator [pat-PATTERN-TEMPLATE][2] or any other Pattern add-on in the [patternslib GitHub organization](https://github.com/patternslib/).
86
-
For a complex example with Mockup integration see [plone.app.mosaic][3] and [Mockup][4] itself.
86
+
For a full and basic example, see the Patterns generator [pat-PATTERN-TEMPLATE](https://github.com/Patternslib/pat-PATTERN_TEMPLATE/blob/master/webpack.config.js) or any other Pattern add-on in the [patternslib GitHub organization](https://github.com/patternslib/).
87
+
For a complex example with Mockup integration see [`plone.app.mosaic`](https://github.com/plone/plone.app.mosaic/blob/master/webpack.config.js) and [Mockup](https://github.com/plone/mockup/blob/master/webpack.config.js) itself.
## Special case: global modules `jQuery` and `Bootstrap`
94
91
95
-
In order to preserve compatibility with older add-ons and JavaScript implementations,
96
-
the modules `jQuery` and `Bootstrap` are stored in the global `window` namespace.
97
-
So constructs like the following are still working:
92
+
To preserve compatibility with older add-ons and JavaScript implementations, the modules `jQuery` and `Bootstrap` are stored in the global `window` namespace.
0 commit comments