xolvio / storybook-webpack-federation-plugin

Exposes all the components in your Storybook as Webpack 5 federated components.
MIT License
57 stars 5 forks source link

Might consider a variant of AutomaticVendorFederation #15

Closed ScriptedAlchemy closed 4 years ago

ScriptedAlchemy commented 4 years ago

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

lgandecki commented 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.

ScriptedAlchemy commented 4 years ago

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

ScriptedAlchemy commented 4 years ago

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.

https://youtu.be/9F7GoDMrzeQ

ScriptedAlchemy commented 4 years ago

Closing since we have merged AVF style semver into v5