Socket
Socket
Sign inDemoInstall

@nkalinov/mf-manifest-deployment-override

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @nkalinov/mf-manifest-deployment-override


Version published
Maintainers
1
Install size
499 kB
Created

Readme

Source

Module Federation Manifest Deployment Override Widget

Inspired by import-map-overrides, this browser widget will allow you to override remotes URLs dynamically during runtime.

This should be viewed as a developer experience enhancement and dev tool -- developers can develop and debug on deployed environments instead of having to boot up a local environment.

Overrides are stored in local storage.

alt text

Install

yarn add @nkalinov/mf-manifest-deployment-override

Usage

Call the override function before importing any of the MFEs with an array of your apps config.

// index.js
import setup from '@nkalinov/mf-manifest-deployment-override';

import('@nkalinov/mf-manifest-deployment-override')
  .then(module =>
    module.default([
        {
            name: 'app1',
            fileName: 'remoteEntry.js',
            port: 3001
        },
        {
            name: 'lib',
            fileName: 'remoteEntry.js',
            port: 3002
        },
    ])
  )
  .then(() => import('./bootstrap.js'));

This will append a div#mf-deployment-manifest-override element with the MFE button + the popup.

UI

  • Input placeholders hold the actual URL of the container. It could be different from your override value as the plugin might use a fallback URL.
  • After you modify a container URL hit Enter to refresh the page and see your changes applied.
  • ⛏ button is a shortcut to prefill the URL with //localhost:$port/$fileName
  • Reset will erase all override info from localStorage.

API

The default export is a function which takes 2 args:

export default (appsConfig: IMFEAppConfig[], config: {
    windowKey?: string;
} = {}) => void

appsConfig arg is an Array of IMFEAppConfig

type IMFEAppConfig = {
    name: string; // MFE key from the manifest file
    fileName: string; // Fallback remote entry filename (also used to construct localhost)
    port: number; // localhost port
};

config arg options:

  • windowKey - (optional) window (and localStorage) key that will be used to store the overrides. Default value is __webpack_mf_deployment_manifest__. If you're changing this make sure to match it with the plugin config.

FAQs

Last updated on 12 May 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc