Skip to content

[FIX] Bundling: Detect manifest.json dependency of Components / Libraries #924

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/lbt/analyzer/ComponentAnalyzer.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class ComponentAnalyzer {
try {
const manifestResource = await this._pool.findResource(manifestName).catch(() => null);
if ( manifestResource ) {
info.addDependency(manifestName);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to discuss whether the existence of a manifest.json should be the indicator or the manifest: json entry in the metadata or both.

  • If a manifest.json exists, manifest-first would work even if the component does not have the metadata entry
  • if the metadata entry exists, a manifest.json would be requested even if it doesn't exist

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. My idea was to always add the dependency because currently the manifest.json is always taken into account for dependency analysis.

I suggest to merge this change as-is and to follow-up on the ComponentAnalyzer as a whole, which also seems to lack detection of new features (e.g. in routing).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've created #954 which only covers libraries.

const fileContent = await manifestResource.buffer();
this._analyzeManifest( JSON.parse(fileContent.toString()), info );
} else {
Expand Down
17 changes: 17 additions & 0 deletions lib/lbt/resources/ResourcePool.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import SmartTemplateAnalyzer from "../analyzer/SmartTemplateAnalyzer.js";
import XMLCompositeAnalyzer from "../analyzer/XMLCompositeAnalyzer.js";
import JSModuleAnalyzer from "../analyzer/JSModuleAnalyzer.js";
import XMLTemplateAnalyzer from "../analyzer/XMLTemplateAnalyzer.js";
import analyzeLibraryJS from "../analyzer/analyzeLibraryJS.js";
import {getDependencyInfos} from "./LibraryFileAnalyzer.js";
import ModuleInfo from "./ModuleInfo.js";
import ResourceFilterList from "./ResourceFilterList.js";
Expand Down Expand Up @@ -95,6 +96,22 @@ async function determineDependencyInfo(resource, rawInfo, pool) {
new ComponentAnalyzer(pool).analyze(resource, info),
new SmartTemplateAnalyzer(pool).analyze(resource, info)
);
} else if ( /(?:^|\/)library\.js/.test(resource.name) ) {
promises.push(
(async () => {
const ui5Resource = resource.resource;
const libInfo = await analyzeLibraryJS(ui5Resource);
if (!libInfo) {
return;
}
const manifestName = resource.name.replace(/library\.js$/, "manifest.json");
const manifestResource = await pool.findResource(manifestName).catch(() => null);
if (!manifestResource) {
return;
}
info.addDependency(manifestName);
})()
)
}

await Promise.all(promises);
Expand Down