Skip to content

Commit b180c91

Browse files
authored
Tidy up module-federation.md, prepare for final review and merge
1 parent aeedd85 commit b180c91

File tree

1 file changed

+21
-26
lines changed

1 file changed

+21
-26
lines changed

docs/classic-ui/module-federation.md

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@ html_meta:
33
"description": "How to use Module Federation in Mockup and add-on bundles."
44
"property=og:description": "How to use Module Federation in Mockup and add-on bundles."
55
"property=og:title": "Module Federation in Mockup"
6-
"keywords": "Plone, Classic UI, classic-ui, Mockup, mockup, Module Federation, Webpack, JavaScript"
6+
"keywords": "Plone, Classic UI, classic-ui, Mockup, mockup, module federation, webpack, JavaScript"
77
---
88

99
(classic-ui-module-federation-in-mockup-label)=
1010

11-
# Module Federation in Mockup
11+
# Module federation in Mockup
1212

1313
Module Federation allows sharing of dependencies between bundles.
1414
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.
1616

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.
1818
But if only bundle B is loaded, it uses its own bundled version of the jQuery library.
1919

2020
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
2626
```
2727

2828

29-
## Using module federation
29+
## Use module federation
3030

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.
3332

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.
3536

3637
```js
3738
import("./patterns");
3839
```
3940

40-
Next add the module federation plugin in `webpack.config.js`.
41+
Next add the module federation plugin in {file}`webpack.config.js`.
4142
There is a configuration factory `mf_config` which you can use for that.
42-
Add the following line near the top of the file:
43+
Add the following line near the top of the file.
4344

4445
```js
4546
const mf_config = require("@patternslib/dev/webpack/webpack.mf");
4647
```
4748

4849
Import all the dependencies you want to share.
49-
Potentially these are the ones from Patternslib, Mockup and your own dependencies.
50-
You can just add the Patternslib and Mockup dependencies, even if you are not using them.
50+
Potentially these are the ones from Patternslib, Mockup, and your own dependencies.
51+
You can add the Patternslib and Mockup dependencies, even if you are not using them.
5152

5253
```js
5354
const package_json = require("./package.json");
5455
const package_json_mockup = require("@plone/mockup/package.json");
5556
const package_json_patternslib = require("@patternslib/patternslib/package.json");
5657
```
5758

58-
Then find the following line:
59+
Then find the following line.
5960

6061
```js
6162
config = patternslib_config(env, argv, config, ["@plone/mockup"]);
6263
```
6364

64-
Below this line add the following:
65+
Below this line add the following.
6566

6667
```js
6768
config.plugins.push(
@@ -79,26 +80,20 @@ Below this line add the following:
7980
```
8081

8182
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`.
8485

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.
8788

88-
[1]: https://pypi.org/project/plonecli/
89-
[2]: https://github.com/Patternslib/pat-PATTERN_TEMPLATE/blob/master/webpack.config.js
90-
[3]: https://github.com/plone/plone.app.mosaic/blob/master/webpack.config.js
91-
[4]: https://github.com/plone/mockup/blob/master/webpack.config.js
9289

9390
## Special case: global modules `jQuery` and `Bootstrap`
9491

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.
93+
Constructs like the following still work:
9894

9995
```js
10096
(function($) {
10197
// JS code which uses $
10298
})(jQuery);
10399
```
104-

0 commit comments

Comments
 (0)