2.8.0-beta.8 • Published 5 months ago

@module-federation/dashboard-plugin v2.8.0-beta.8

Weekly downloads
725
License
Apache-2.0
Repository
github
Last release
5 months ago

Module Federation Dashboard Plugin

This Webpack plugin extracts data from the Webpack build, and in particular a build that uses the ModuleFederationPlugin, and posts it to the dashboard.

Installation

> yarn add @module-federation/dashboard-plugin -D

Usage

const DashboardPlugin = require("@module-federation/dashboard-plugin");
plugins: [
  ...new DashboardPlugin({
    dashboardURL: "https://api.medusa.codes/update?token=writeToken"
  })
];

This will post the ModuleFederationPlugin metrics to the update endpoint at https://api.medusa.codes/update?token=writeToken.

In order to send data to Medusa, you need to create a write token. It can be configured here: https://www.medusa.codes/settings

There are also other options:

KeyDescription
dashboardURLThe URL of the dashboard endpoint.
metadataAny additional metadata you want to apply to this application for use in the dashboard.
filenameThe file path where the dashboard data.
standaloneFor use without ModuleFederationPlugin
versionStrategyrequire('package.json').version OR "gitSha" OR "buildHash"
packageJsonPathcustom path to package.json file, helpful if you get a topLevelPackage.dependencies error

Metadata

Metadata is optional and is specified as an object.

plugins: [
  ...new DashboardPlugin({
    dashboardURL: "https://api.medusa.codes/update?token=writeToken",
    metadata: {
     // baseurl is needed in order for medusa to know where to find the remoteEntry.js file
      baseUrl: 'http://localhost:3001/assets/',
      source: {
        url: "http://github.com/myorg/myproject/tree/master"
      },
      remote: "http://localhost:8081/remoteEntry.js"
    }
  })
];

versionStrategy

There are a few build-in options for versioning automatically We Support gitSha, buildHash, <custom string>

gitSha uses the git commit hash as the version specifier (default) buildHash uses the webpacks unique build hash generated for each compile as the specifier custom some other form of version specification youd like, such as require("package.json").version

You must ensure that this value is unique per release sent to medusa as this is how version pining works

You can add whatever keys you want to metadata, but there are some keys that the Dashboard will look for and which result in a better experience.

KeyDescription
source.urlThe base URL of your source in a source code control system.
remoteThe URL for the remote entry.

Standalone Mode

This is useful when Module Federation is not used, options can be passed that are usually inferred from Module Federation Options

  • name: the name of the app, must be unique

Next.js

Next requires its own specific integration due to how Module Federation works on this platform.

const { withMedusa } = require("@module-federation/dashboard-plugin");
const withPlugins = require("next-compose-plugins");
const { withFederatedSidecar } = require("@module-federation/nextjs-ssr");

module.exports = withPlugins(
  [
    withFederatedSidecar(
      {
        name,
        filename: "static/chunks/remoteEntry.js",
        exposes,
        remotes,
        shared: {
          lodash: {
            import: "lodash",
            requiredVersion: require("lodash").version,
            singleton: true
          },
          chakra: {
            shareKey: "@chakra-ui/react",
            import: "@chakra-ui/react"
          },
          "use-sse": {
            singleton: true,
            requiredVersion: false
          }
        }
      },
      {
        experiments: {
          flushChunks: true,
          hot: true
        }
      }
    ),
    withMedusa({
      name: "home",

      publishVersion: require("./package.json").version,
      filename: "dashboard.json",
      dashboardURL: `https://api.medusa.codes/update?token=${process.env.DASHBOARD_WRITE_TOKEN}`,
      metadata: {
        clientUrl: "https://localhost:3000",
        baseUrl: process.env.VERCEL_URL
          ? "https://" + process.env.VERCEL_URL
          : "http://localhost:3001",
        source: {
          url:
            "https://github.com/module-federation/federation-dashboard/tree/master/dashboard-example/home"
        },
        remote: process.env.VERCEL_URL
          ? "https://" + process.env.VERCEL_URL + "/remoteEntry.js"
          : "http://localhost:3001/remoteEntry.js"
      }
    })
  ],
  nextConfig
);
2.8.0-beta.8

5 months ago

2.8.0-beta.7

6 months ago

2.7.4

8 months ago

2.7.3

10 months ago

2.7.5

8 months ago

2.8.0-beta.6

1 year ago

2.8.0-beta.5

1 year ago

2.8.0-beta.4

1 year ago

2.8.0-beta.3

1 year ago

2.8.0-beta.2

1 year ago

2.8.0-beta.1

1 year ago

2.7.2

1 year ago

2.7.1

1 year ago

2.7.0

1 year ago

2.6.5

2 years ago

2.5.0

2 years ago

2.4.0

2 years ago

2.3.1

2 years ago

2.6.1

2 years ago

2.6.0

2 years ago

2.6.3

2 years ago

2.6.2

2 years ago

2.6.4

2 years ago

2.3.0

3 years ago

2.2.0

3 years ago

2.1.2

3 years ago

2.1.1

3 years ago

2.1.0

3 years ago

2.0.0

3 years ago

2.0.0-beta.6

4 years ago

2.0.0-beta.5

4 years ago

2.0.0-beta.4

4 years ago

2.0.0-beta.3

4 years ago

2.0.0-beta.2

4 years ago

2.0.0-beta.1

4 years ago

2.0.0-beta.0

4 years ago

1.1.0

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.2.0

4 years ago

0.1.1

4 years ago