Skip to content

Commit

Permalink
[FIX] Bundling: Detect manifest.json dependency of libraries
Browse files Browse the repository at this point in the history
This solves the problem of missing manifest.json files of libraries in
bundles, such as sap-ui-custom.js (self-contained build).

It also eliminates the need to explicitly mention manifest.json files
of libraries to be included in custom bundles.
  • Loading branch information
matz3 committed Nov 17, 2023
1 parent f7b9f27 commit 6f9995f
Show file tree
Hide file tree
Showing 34 changed files with 289 additions and 35 deletions.
10 changes: 10 additions & 0 deletions lib/lbt/resources/ResourcePool.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@ 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 manifestName = resource.name.replace(/library\.js$/, "manifest.json");
const manifestResource = await pool.findResource(manifestName).catch(() => null);
if (manifestResource) {
info.addDependency(manifestName);
}
})()
);
}

await Promise.all(promises);
Expand Down
8 changes: 5 additions & 3 deletions lib/tasks/bundlers/generateLibraryPreload.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ function getDefaultLibraryPreloadFilters(namespace, excludes) {
}

function getBundleDefinition(namespace, excludes) {
// TODO: move to config of actual core project
// Note: This configuration is only used when no bundle definition in ui5.yaml exists (see "skipBundles" parameter)

// TODO: Remove this hardcoded bundle definition.
// sap.ui.core ui5.yaml contains a configuration since UI5 1.103.0 (specVersion 2.4)
// so this is still required to build UI5 versions <= 1.102.0.
if (namespace === "sap/ui/core") {
return {
name: `${namespace}/library-preload.js`,
Expand All @@ -51,8 +55,6 @@ function getBundleDefinition(namespace, excludes) {
filters: [
// Note: Don't pass configured preload excludes for sap.ui.core
// as they are already hardcoded below.
// In future the sap/ui/core/library-preload should be configured
// as a custom bundle in the ui5.yaml.
...getDefaultLibraryPreloadFilters(namespace),

`!${namespace}/cldr/`,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Some fancy copyright
*/

sap.ui.define([
"sap/ui/core/Lib",
"sap/ui/core/library"
], function (Library) {
"use strict";

return Library.init({
name: "library.d",
version: "1.0.0",
dependencies: [
"sap.ui.core"
],
types: [],
interfaces: [],
controls: [],
elements: [],
noLibraryCSS: true
});
});

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/*!
* Some fancy copyright
*/
(function() {

sap.ui.define(["./library"], (_library) => {
var someNonUglifiedVariable = "World";
console.log('Hello ' + someNonUglifiedVariable);
})();
});

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Some fancy copyright
*/

sap.ui.define([
"sap/ui/core/Lib",
"sap/ui/core/library"
], function (Library) {
"use strict";

return Library.init({
name: "library.d",
version: "1.0.0",
dependencies: [
"sap.ui.core"
],
types: [],
interfaces: [],
controls: [],
elements: [],
noLibraryCSS: true
});
});

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/*!
* Some fancy copyright
*/
(function() {

sap.ui.define(["./library"], (_library) => {
var someNonUglifiedVariable = "World";
console.log('Hello ' + someNonUglifiedVariable);
})();
});

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Some fancy copyright
*/

sap.ui.define([
"sap/ui/core/Lib",
"sap/ui/core/library"
], function (Library) {
"use strict";

return Library.init({
name: "library.d",
version: "1.0.0",
dependencies: [
"sap.ui.core"
],
types: [],
interfaces: [],
controls: [],
elements: [],
noLibraryCSS: true
});
});

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@
"libs": {}
},
"library": {
"i18n": false
"i18n": false,
"css": false,
"content": {
"controls": [],
"elements": [],
"types": [],
"interfaces": []
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/*!
* Some fancy copyright
*/
(function() {

sap.ui.define(["./library"], (_library) => {
var someNonUglifiedVariable = "World";
console.log('Hello ' + someNonUglifiedVariable);
})();
});

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* ${copyright}
*/

sap.ui.define([
"sap/ui/core/Lib",
"sap/ui/core/library"
], function (Library) {
"use strict";

return Library.init({
name: "library.d",
version: "${version}",
dependencies: [
"sap.ui.core"
],
types: [],
interfaces: [],
controls: [],
elements: [],
noLibraryCSS: true
});
});
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/*!
* ${copyright}
*/
(function() {

sap.ui.define(["./library"], (_library) => {
var someNonUglifiedVariable = "World";
console.log('Hello ' + someNonUglifiedVariable);
})();
});
Loading

0 comments on commit 6f9995f

Please sign in to comment.