Package Exports
- dynamic-container-path-webpack-plugin
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (dynamic-container-path-webpack-plugin) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
dynamic-container-path-webpack-plugin
A
publicPath
mutator webpack plugin for module federation.
About plugin
Change publicPath
at run time rather than build time for dynamic module federated containers.
This should be used in conjunction with module federation's exposed methods for initializing remote containers dynamically instead of using the remotes
parameter for static paths.
Install
npm install dynamic-container-path-webpack-plugin
Usage
Click here for a full example (Work-in-progress).
Module Federated Host example:
webpack.config.js
const { ModuleFederationPlugin } = require("webpack").container;
const DynamicContainerPathPlugin = require('dynamic-container-path-webpack-plugin');
const setPublicPath = require('./public-path');
module.exports = {
entry: {
...
host: ["./app.js"],
},
output: {
...
// this will be changed later by 'DynamicContainerPathPlugin' at runtime
publicPath: "/",
},
// ...
plugins: [
// ...
new ModuleFederationPlugin({
...
}),
new DynamicContainerPathPlugin({
iife: setPublicPath,
entry: 'host',
}),
// ...
],
// ...
};
public-path.js
module.exports = (function(entry) {
...
return publicPath;
});
Options
iife
- Type:
function
An immediately invoked function expression to get publicPath
at runtime.
entry
- Type:
string
The entry point name of the application.
Contributing
Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.
License
MIT