@schirrel/module-federation-enhanced-plugin-helper

2.0.2 • Public • Published

Dynamic Load

Utilities for dynamic load content for remotes, if you need to pre initialize it (in case of offline PWA for example)

Install

npm i @schirrel/module-federation-enhanced-plugin-helper

Usage

import {
  loadRemoteAndModules,
  getModule,
} from "@schirrel/module-federation-enhanced-plugin-helper";

loadRemoteAndModules();

const module = getModule({ remote: "myApp", module: "./Component" });

Features

loadRemoteAndModules

This function load all needed and available for consumption, step:

  • Get remoteUrlMap to know remotes
  • Dynamic register by calling getModule
  • List all remotes available for consumption using moduleNameList for each remote
  • Load all modules for each remote
  • Return all modules the app-shell, root-remote.

The scenario where we built this uppon was a scenario where the app shell only have remotes that only exposes what it is needed here. In our screnario, we need to offline install a PWA and cache all features, include remotes. As many of then where being used im some sort of "lazy chunk load", "manualy" deal with ensure all ealy registration was being a pain.

With dynamicLoad we ensure all files needs for remotes are laoded and cached.

getModule

Load a module from a remote using low level API, once dynamic import impot() dont work with dynamic passed names, as can bee read about here

Readme

Keywords

none

Package Sidebar

Install

npm i @schirrel/module-federation-enhanced-plugin-helper

Weekly Downloads

4

Version

2.0.2

License

MIT

Unpacked Size

4.97 kB

Total Files

5

Last publish

Collaborators

  • schirrel