From 5bd15bed1587630f075868d9c10e242d63d5447e Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Thu, 4 Mar 2021 15:41:39 +0100 Subject: [PATCH 1/3] [FIX] versionInfoGenerator: hasOwnPreload switched boolean hasOwnPreload is only true if the library has embeds field set in manifest and embedded manifest does not have a backlink (embeddedBy) to the library. --- lib/processors/versionInfoGenerator.js | 2 +- test/lib/processors/versionInfoGenerator.js | 2 +- test/lib/tasks/generateVersionInfo.js | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/processors/versionInfoGenerator.js b/lib/processors/versionInfoGenerator.js index 9cbd6c8fd..80ae563ba 100644 --- a/lib/processors/versionInfoGenerator.js +++ b/lib/processors/versionInfoGenerator.js @@ -432,7 +432,7 @@ module.exports = async function({options}) { componentObject.manifestHints = manifestHints; } const bundledComponents = artifactInfo.bundledComponents; - if (bundledComponents.has(componentName)) { + if (!bundledComponents.has(componentName)) { componentObject.hasOwnPreload = true; } components = components || {}; diff --git a/test/lib/processors/versionInfoGenerator.js b/test/lib/processors/versionInfoGenerator.js index a1981db40..4a9875a10 100644 --- a/test/lib/processors/versionInfoGenerator.js +++ b/test/lib/processors/versionInfoGenerator.js @@ -284,6 +284,7 @@ test.serial("versionInfoGenerator library infos with embeds", async (t) => { ], "components": { "lib.a.sub": { + "hasOwnPreload": true, "library": "lib.a" } } @@ -439,7 +440,6 @@ test.serial("versionInfoGenerator library infos with embeds and embeddedBy (hasO ], "components": { "lib.a.sub": { - "hasOwnPreload": true, "library": "lib.a" } } diff --git a/test/lib/tasks/generateVersionInfo.js b/test/lib/tasks/generateVersionInfo.js index 4d8984363..4952bf8b5 100644 --- a/test/lib/tasks/generateVersionInfo.js +++ b/test/lib/tasks/generateVersionInfo.js @@ -726,6 +726,7 @@ test.serial("integration: Library with dependencies and subcomponent complex sce }], "components": { "lib.a.sub.fold": { + "hasOwnPreload": true, "library": "lib.a", "manifestHints": { "dependencies": { @@ -863,6 +864,7 @@ test.serial("integration: Library with dependencies and subcomponent bigger scen }], "components": { "lib.a.sub.fold": { + "hasOwnPreload": true, "library": "lib.a", "manifestHints": { "dependencies": { @@ -917,7 +919,6 @@ test.serial("integration: Library without dependencies and embeds and embeddedBy }], "components": { "lib.a.sub.fold": { - "hasOwnPreload": true, "library": "lib.a" } }, @@ -964,6 +965,7 @@ test.serial("integration: Library without dependencies and embeddedBy undefined" }], "components": { "lib.a.sub.fold": { + "hasOwnPreload": true, "library": "lib.a" } }, @@ -1014,6 +1016,7 @@ test.serial("integration: Library without dependencies and embeddedBy not a stri }], "components": { "lib.a.sub.fold": { + "hasOwnPreload": true, "library": "lib.a" } }, @@ -1065,6 +1068,7 @@ test.serial("integration: Library without dependencies and embeddedBy empty stri }], "components": { "lib.a.sub.fold": { + "hasOwnPreload": true, "library": "lib.a" } }, @@ -1116,6 +1120,7 @@ test.serial("integration: Library without dependencies and embeddedBy path not c }], "components": { "lib.a.sub.fold": { + "hasOwnPreload": true, "library": "lib.a" } }, From 4c78eb5acc068f8aa80a8cbe5f8ad82282bc012c Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Thu, 4 Mar 2021 16:36:56 +0100 Subject: [PATCH 2/3] restructure component object such that hasOwnPreload comes as first property --- lib/processors/versionInfoGenerator.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/processors/versionInfoGenerator.js b/lib/processors/versionInfoGenerator.js index 80ae563ba..f2d6584df 100644 --- a/lib/processors/versionInfoGenerator.js +++ b/lib/processors/versionInfoGenerator.js @@ -423,18 +423,19 @@ module.exports = async function({options}) { let components; artifactInfos.forEach((artifactInfo) => { artifactInfo.embeds.forEach((embeddedArtifactInfo) => { - const componentObject = { - library: artifactInfo.componentName - }; + const componentObject = {}; + const bundledComponents = artifactInfo.bundledComponents; const componentName = embeddedArtifactInfo.componentName; + if (!bundledComponents.has(componentName)) { + componentObject.hasOwnPreload = true; + } + componentObject.library = artifactInfo.componentName; + const manifestHints = getManifestHints(embeddedArtifactInfo.dependencyInfo, dependencyInfoMap); if (manifestHints) { componentObject.manifestHints = manifestHints; } - const bundledComponents = artifactInfo.bundledComponents; - if (!bundledComponents.has(componentName)) { - componentObject.hasOwnPreload = true; - } + components = components || {}; components[componentName] = componentObject; }); From 8368d77781610e313f04c8667fbc8b643d2bd92a Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Thu, 4 Mar 2021 16:43:23 +0100 Subject: [PATCH 3/3] typos --- lib/processors/versionInfoGenerator.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/processors/versionInfoGenerator.js b/lib/processors/versionInfoGenerator.js index f2d6584df..ff41d9b60 100644 --- a/lib/processors/versionInfoGenerator.js +++ b/lib/processors/versionInfoGenerator.js @@ -254,11 +254,11 @@ const getManifestHints = (dependencyInfo, dependencyInfoMap) => { /** * Common type for Library and Component - * embeds and bundled components makes only sense for library + * embeds and bundled components make only sense for library * * @typedef {object} ArtifactInfo * @property {string} componentName The library name, e.g. "lib.x" - * @property {Set} bundledComponents The embedded components which have a embeddedBy reference to the library + * @property {Set} bundledComponents The embedded components which have an embeddedBy reference to the library * @property {DependencyInfo} dependencyInfo The dependency info object * @property {ArtifactInfo[]} embeds The embedded artifact infos */