Skip to content

Commit 73a0f8b

Browse files
authored
[FIX] versionInfoGenerator: fix hasOwnPreload flag (#591)
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. restructure component object such that hasOwnPreload comes as first property
1 parent 42f6474 commit 73a0f8b

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

lib/processors/versionInfoGenerator.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,11 @@ const getManifestHints = (dependencyInfo, dependencyInfoMap) => {
254254

255255
/**
256256
* Common type for Library and Component
257-
* embeds and bundled components makes only sense for library
257+
* embeds and bundled components make only sense for library
258258
*
259259
* @typedef {object} ArtifactInfo
260260
* @property {string} componentName The library name, e.g. "lib.x"
261-
* @property {Set<string>} bundledComponents The embedded components which have a embeddedBy reference to the library
261+
* @property {Set<string>} bundledComponents The embedded components which have an embeddedBy reference to the library
262262
* @property {DependencyInfo} dependencyInfo The dependency info object
263263
* @property {ArtifactInfo[]} embeds The embedded artifact infos
264264
*/
@@ -423,18 +423,19 @@ module.exports = async function({options}) {
423423
let components;
424424
artifactInfos.forEach((artifactInfo) => {
425425
artifactInfo.embeds.forEach((embeddedArtifactInfo) => {
426-
const componentObject = {
427-
library: artifactInfo.componentName
428-
};
426+
const componentObject = {};
427+
const bundledComponents = artifactInfo.bundledComponents;
429428
const componentName = embeddedArtifactInfo.componentName;
429+
if (!bundledComponents.has(componentName)) {
430+
componentObject.hasOwnPreload = true;
431+
}
432+
componentObject.library = artifactInfo.componentName;
433+
430434
const manifestHints = getManifestHints(embeddedArtifactInfo.dependencyInfo, dependencyInfoMap);
431435
if (manifestHints) {
432436
componentObject.manifestHints = manifestHints;
433437
}
434-
const bundledComponents = artifactInfo.bundledComponents;
435-
if (bundledComponents.has(componentName)) {
436-
componentObject.hasOwnPreload = true;
437-
}
438+
438439
components = components || {};
439440
components[componentName] = componentObject;
440441
});

test/lib/processors/versionInfoGenerator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ test.serial("versionInfoGenerator library infos with embeds", async (t) => {
284284
],
285285
"components": {
286286
"lib.a.sub": {
287+
"hasOwnPreload": true,
287288
"library": "lib.a"
288289
}
289290
}
@@ -439,7 +440,6 @@ test.serial("versionInfoGenerator library infos with embeds and embeddedBy (hasO
439440
],
440441
"components": {
441442
"lib.a.sub": {
442-
"hasOwnPreload": true,
443443
"library": "lib.a"
444444
}
445445
}

test/lib/tasks/generateVersionInfo.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,7 @@ test.serial("integration: Library with dependencies and subcomponent complex sce
726726
}],
727727
"components": {
728728
"lib.a.sub.fold": {
729+
"hasOwnPreload": true,
729730
"library": "lib.a",
730731
"manifestHints": {
731732
"dependencies": {
@@ -863,6 +864,7 @@ test.serial("integration: Library with dependencies and subcomponent bigger scen
863864
}],
864865
"components": {
865866
"lib.a.sub.fold": {
867+
"hasOwnPreload": true,
866868
"library": "lib.a",
867869
"manifestHints": {
868870
"dependencies": {
@@ -917,7 +919,6 @@ test.serial("integration: Library without dependencies and embeds and embeddedBy
917919
}],
918920
"components": {
919921
"lib.a.sub.fold": {
920-
"hasOwnPreload": true,
921922
"library": "lib.a"
922923
}
923924
},
@@ -964,6 +965,7 @@ test.serial("integration: Library without dependencies and embeddedBy undefined"
964965
}],
965966
"components": {
966967
"lib.a.sub.fold": {
968+
"hasOwnPreload": true,
967969
"library": "lib.a"
968970
}
969971
},
@@ -1014,6 +1016,7 @@ test.serial("integration: Library without dependencies and embeddedBy not a stri
10141016
}],
10151017
"components": {
10161018
"lib.a.sub.fold": {
1019+
"hasOwnPreload": true,
10171020
"library": "lib.a"
10181021
}
10191022
},
@@ -1065,6 +1068,7 @@ test.serial("integration: Library without dependencies and embeddedBy empty stri
10651068
}],
10661069
"components": {
10671070
"lib.a.sub.fold": {
1071+
"hasOwnPreload": true,
10681072
"library": "lib.a"
10691073
}
10701074
},
@@ -1116,6 +1120,7 @@ test.serial("integration: Library without dependencies and embeddedBy path not c
11161120
}],
11171121
"components": {
11181122
"lib.a.sub.fold": {
1123+
"hasOwnPreload": true,
11191124
"library": "lib.a"
11201125
}
11211126
},

0 commit comments

Comments
 (0)