diff --git a/.changeset/angry-hairs-remember.md b/.changeset/angry-hairs-remember.md new file mode 100644 index 00000000..67125048 --- /dev/null +++ b/.changeset/angry-hairs-remember.md @@ -0,0 +1,6 @@ +--- +"@module-federation/dashboard": minor +"@module-federation/dashboard-plugin": minor +--- + +Documentation Formatting and fixing a bug in the pluign that happens when no remoteEntry is emitted at all diff --git a/dashboard-fe/README.md b/dashboard-fe/README.md index c6ff9caf..03a0bc2d 100644 --- a/dashboard-fe/README.md +++ b/dashboard-fe/README.md @@ -39,8 +39,7 @@ Add the `DashboardPlugin` to the `plugins` array. ```js plugins: [ - ... - new DashboardPlugin({ + ...new DashboardPlugin({ dashboardURL: "http://localhost:3000/api/update", }), ]; diff --git a/dashboard-plugin/README.md b/dashboard-plugin/README.md index 2383eaae..392aa120 100644 --- a/dashboard-plugin/README.md +++ b/dashboard-plugin/README.md @@ -16,8 +16,7 @@ const DashboardPlugin = require("@module-federation/dashboard-plugin"); ```js plugins: [ - ... - new DashboardPlugin({ + ...new DashboardPlugin({ dashboardURL: "http://localhost:3000/api/update", }), ]; @@ -35,12 +34,11 @@ There are also other options: ## Metadata -Metadata is *optional* and is specified as an object. +Metadata is _optional_ and is specified as an object. ```js plugins: [ - ... - new DashboardPlugin({ + ...new DashboardPlugin({ dashboardURL: "http://localhost:3000/api/update", metadata: { source: { diff --git a/dashboard-plugin/helpers/index.js b/dashboard-plugin/helpers/index.js index 713ee736..6a866c22 100644 --- a/dashboard-plugin/helpers/index.js +++ b/dashboard-plugin/helpers/index.js @@ -11,22 +11,25 @@ function validateParams({ ); } - const hasLoc = objHasKeys(federationRemoteEntry, ["origins", "0", "loc"]); + const hasLoc = federationRemoteEntry + ? objHasKeys(federationRemoteEntry, ["origins", "0", "loc"]) + : federationRemoteEntry; + const hasDependencies = objHasKeys(topLevelPackage, ["dependencies"]); const hasDevDependencies = objHasKeys(topLevelPackage, ["devDependencies"]); const hasOptionalDependencies = objHasKeys(topLevelPackage, [ "optionalDependencies", ]); - - if ( - typeof hasLoc === "undefined" || - federationRemoteEntry.origins[0].loc === "" - ) { - throw new Error( - "federationRemoteEntry.origins[0].loc must be defined and have a value" - ); + if (federationRemoteEntry) { + if ( + typeof hasLoc === "undefined" || + federationRemoteEntry.origins[0].loc === "" + ) { + throw new Error( + "federationRemoteEntry.origins[0].loc must be defined and have a value" + ); + } } - if ((modules && !modules.length) || typeof modules === "undefined") { throw new Error("Modules must be defined and have length"); }