Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/module-federation/automatic-vendor-federation
Utility to enable automatic vendor sharing within bundles using Module Federation
https://github.com/module-federation/automatic-vendor-federation
federation module share vendor
Last synced: 2 months ago
JSON representation
Utility to enable automatic vendor sharing within bundles using Module Federation
- Host: GitHub
- URL: https://github.com/module-federation/automatic-vendor-federation
- Owner: module-federation
- License: mit
- Created: 2020-05-14T20:19:55.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-03-24T07:05:29.000Z (10 months ago)
- Last Synced: 2024-10-29T14:22:22.933Z (3 months ago)
- Topics: federation, module, share, vendor
- Language: JavaScript
- Size: 132 KB
- Stars: 74
- Watchers: 3
- Forks: 7
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# automatic-vendor-federation
Utility to enable automatic vendor sharing within bundles using Module Federation
## This tool will be part of Webpack 5 core: https://github.com/webpack/webpack/pull/10960
# Check out our book
| | We will be actively updating this book over the next year as we learn more about best practices and what issues people are running into with Module Federation, as well as with every release of Webpack as it moves towards a release candidate and release. So with your one purchase you are buying a whole year of updates. |
|------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|# Install
```shell script
yarn add @module-federation/automatic-vendor-sharing -D
```# Usage
There are a few arguments you can pass to the utility.
* `exclude` : allows you to filter out any packages including part of the string.
* `packageJson` : pass your apps `package.json`: eg: `require("./package.json");`
* `ignoreVersion`: you can ignore versions on some shared packages. This utility supports versioned dependencies, which is a problem when using React as there can only be one version on the page
* `ignorePatchVersion` : ignore patch numbers and share dependencies based on a minor version matching. lodash-4.11 instead of lodash-4.11.7
* `shareFrom`: choose where in package.json the utility should share from. `['dependencies','peerDependencies']`/ (default: `dependencies`)```js
const AutomaticVendorFederation = require("@module-federation/automatic-vendor-federation");
const { ModuleFederationPlugin } = require("webpack").container;
const packageJson = require("./package.json");
const exclude = ["babel", "plugin", "preset", "webpack", "loader", "serve"];
const ignoreVersion = ["react", "react-dom"];module.export = {
//... rest of your config
plugins: [
new ModuleFederationPlugin({
name: "app2",
library: { type: "var", name: "app2" },
filename: "remoteEntry.js",
remotes: {
app1: "app1",
},
exposes: {
Button: "./src/Button",
},
shared: AutomaticVendorFederation({
exclude,
ignoreVersion,
packageJson,
shareFrom: ["dependencies", "peerDependencies"],
ignorePatchVersion: true,
}),
}),
],
};
```