Closed ScriptedAlchemy closed 4 years ago
This is interesting. I like it. But we would like to make this be as smart by default as possible. So in this plugin we would probably do something like this behind the scenes:
const { ModuleFederationPlugin } = require("webpack").container;
const packageJson = require("./package.json");
const exclude = ["babel", "plugin", "preset", "webpack", "loader", "serve"];
const ignoreVersion = ["react", "react-dom"];
const shared = AutomaticVendorFederation({
exclude,
ignoreVersion,
packageJson,
shareFrom: ["dependencies", "peerDependencies"],
ignorePatchVersion: true,
})
and expose API to modify it.
I agree totally, this would be an okay boilerplate if you need something more robust haha.
Feel free to PR the project if you have any improvements in mind. I’ve also used this inside other plugins which has been handy so some of my plugins import this utility and apply it to MF under the hood as well with different configs. Definitely would like a smarter implementation
Actually we just merged this and way more into master. We now support remotes sharing code between other remotes. And we support full semver enforcement like npm. No need to use the plugin. We also fixed sharing with dynamic remotes. So it’s a one liner. And we added share groups so you can selectively share groups of code with other remotes.
Closing since we have merged AVF style semver into v5
Your glob routes look pretty good, but something like this might help. I can also modify as required. https://github.com/module-federation/automatic-vendor-sharing