From 1f32a8a22260f138d58a73e909029f295c5afb28 Mon Sep 17 00:00:00 2001 From: ScriptedAlchemy Date: Fri, 12 Jun 2020 16:19:51 -0700 Subject: [PATCH 1/2] fix: no remote entry emitted causes failures in validation --- dashboard-fe/README.md | 3 +-- dashboard-plugin/README.md | 8 +++----- dashboard-plugin/helpers/index.js | 23 +++++++++++++---------- 3 files changed, 17 insertions(+), 17 deletions(-) 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"); } From 0619636f5d470d5f91dc442ddb226a4aec5206fa Mon Sep 17 00:00:00 2001 From: ScriptedAlchemy Date: Fri, 12 Jun 2020 16:21:37 -0700 Subject: [PATCH 2/2] fix: no remote entry emitted causes failures in validation --- .changeset/angry-hairs-remember.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/angry-hairs-remember.md 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