Skip to content

Commit 8165545

Browse files
committed
more fixes and for latest webpack.mf.js and example references.
1 parent 7f7e706 commit 8165545

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

docs/classic-ui/module-federation.md

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,16 @@ Add the following line near the top of the file:
4444
const mf_config = require("@patternslib/dev/webpack/webpack.mf");
4545
```
4646

47+
Import all the dependencies you want to share.
48+
Potentially these are the ones from Patternslib, Mockup and your own dependencies.
49+
You can just add the Patternslib and Mockup dependencies, even if you are not using them.
50+
51+
```js
52+
const package_json = require("./package.json");
53+
const package_json_mockup = require("@plone/mockup/package.json");
54+
const package_json_patternslib = require("@patternslib/patternslib/package.json");
55+
```
56+
4757
Then find the following line:
4858

4959
```js
@@ -55,17 +65,29 @@ Below this line add the following:
5565
```js
5666
config.plugins.push(
5767
mf_config({
68+
name: "myaddon",
5869
filename: "myaddon-remote.min.js",
59-
package_json: package_json,
6070
remote_entry: config.entry["myaddon.min"],
71+
dependencies: {
72+
...package_json_patternslib.dependencies,
73+
...package_json_mockup.dependencies,
74+
...package_json.dependencies,
75+
},
6176
})
6277
);
6378
```
6479

65-
Replace `myaddon-remote.min.js` with the file name you want to use for your remote bundle.
66-
Replace `myaddon.min` with the corresponding key in `config.entry` that points to your `index.js`.
80+
Replace the name `myaddon` with your addon bundle's name (any unique name will do...),
81+
replace the filename `myaddon-remote.min.js` with the file name you want to use for your remote bundle,
82+
and replace `myaddon.min` with the corresponding key in `config.entry` that points to your `index.js`.
83+
84+
For a full but simple example, see the Patterns generator [pat-PATTERN-TEMPLATE][2] or any other Pattern addon in the patternslib GitHub organisation.
85+
For a complex example with Mockup integration see [plone.app.mosaic][3] and [Mockup][4] itself.
6786

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

7092
## Special case: global modules `jQuery` and `Bootstrap`
7193

0 commit comments

Comments
 (0)