diff --git a/lib/lbt/analyzer/JSModuleAnalyzer.js b/lib/lbt/analyzer/JSModuleAnalyzer.js
index 70e85f4eb..1ac1e6eab 100644
--- a/lib/lbt/analyzer/JSModuleAnalyzer.js
+++ b/lib/lbt/analyzer/JSModuleAnalyzer.js
@@ -212,6 +212,8 @@ const CALL_JQUERY_SAP_IS_DECLARED = [["jQuery", "$"], "sap", "isDeclared"];
const CALL_JQUERY_SAP_REQUIRE = [["jQuery", "$"], "sap", "require"];
const CALL_JQUERY_SAP_REGISTER_PRELOADED_MODULES = [["jQuery", "$"], "sap", "registerPreloadedModules"];
+const SPECIAL_AMD_DEPENDENCIES = ["require", "exports", "module"];
+
function isCallableExpression(node) {
return node.type == Syntax.FunctionExpression || node.type == Syntax.ArrowFunctionExpression;
}
@@ -534,6 +536,10 @@ class JSModuleAnalyzer {
// console.log(array);
array.forEach( (item) => {
if ( isString(item) ) {
+ // ignore special AMD dependencies (require, exports, module)
+ if ( SPECIAL_AMD_DEPENDENCIES.indexOf(item.value) >= 0 ) {
+ return;
+ }
let requiredModule;
if (name == null) {
requiredModule = ModuleName.fromRequireJSName( item.value );
diff --git a/lib/lbt/bundle/Builder.js b/lib/lbt/bundle/Builder.js
index 3d92f1035..2793d0ab3 100644
--- a/lib/lbt/bundle/Builder.js
+++ b/lib/lbt/bundle/Builder.js
@@ -50,6 +50,14 @@ const UI5BundleFormat = {
outW.writeln(`}});`);
},
+ beforeH2Preloads(outW) {
+ outW.writeln(`"unsupported"; /* Bundle format 'h2' not supported (requires ui5loader)`);
+ },
+
+ afterH2Preloads(outW) {
+ outW.writeln(`*/`);
+ },
+
requireSync(outW, moduleName) {
outW.writeln(`sap.ui.requireSync("${ModuleName.toRequireJSName(moduleName)}");`);
},
@@ -76,6 +84,14 @@ const EVOBundleFormat = {
outW.writeln(`);`);
},
+ beforeH2Preloads(outW) {
+ outW.writeln(`sap.ui.loader.config({depCacheUI5:{`);
+ },
+
+ afterH2Preloads(outW) {
+ outW.writeln(`}});`);
+ },
+
requireSync(outW, moduleName) {
outW.writeln(`sap.ui.requireSync("${ModuleName.toRequireJSName(moduleName)}");`);
},
@@ -205,6 +221,8 @@ class BundleBuilder {
return this.writeRaw(section);
case SectionType.Preload:
return this.writePreloadFunction(section);
+ case SectionType.DepCache:
+ return this.writeDepCache(section);
case SectionType.Require:
return this.writeRequires(section);
default:
@@ -481,6 +499,42 @@ class BundleBuilder {
});
}
+ async writeDepCache(section) {
+ const outW = this.outW;
+
+ outW.ensureNewLine();
+
+ const sequence = section.modules.slice();
+
+ if ( sequence.length > 0 ) {
+ this.targetBundleFormat.beforeH2Preloads(outW, section);
+ let i = 0;
+ for (let module of sequence) {
+ let resource = await this.pool.findResourceWithInfo(module);
+ if ( resource != null ) {
+ let deps = resource.info.dependencies.filter( (dep) =>
+ !resource.info.isConditionalDependency(dep) && !resource.info.isImplicitDependency(dep) );
+ if ( deps.length > 0 ) {
+ if ( i > 0 ) {
+ outW.writeln(",");
+ }
+ outW.write(`"${module}": [${deps.map((dep) => "\"" + dep + "\"").join(",")}]`);
+ i++;
+ } else {
+ log.verbose(" skipped %s, no dependencies", module);
+ }
+ } else {
+ log.error(" couldn't find %s", module);
+ }
+ }
+
+ if ( i > 0 ) {
+ outW.writeln();
+ }
+ this.targetBundleFormat.afterH2Preloads(outW, section);
+ }
+ }
+
writeRequires(section) {
this.outW.ensureNewLine();
section.modules.forEach( (module) => {
diff --git a/lib/lbt/bundle/BundleDefinition.js b/lib/lbt/bundle/BundleDefinition.js
index 1e7909dd9..260a2d214 100644
--- a/lib/lbt/bundle/BundleDefinition.js
+++ b/lib/lbt/bundle/BundleDefinition.js
@@ -17,6 +17,12 @@ const SectionType = {
*/
Preload: "preload",
+ /**
+ * Only the dependencies of the modules are stored as 'depCache' configuration.
+ * Requires UI5 Evolution runtime.
+ */
+ DepCache: "depcache",
+
/**
* For each module, a jQuery.sap.require call will be created.
* Usually used as the last section in a merged module to enforce loading and
diff --git a/lib/tasks/bundlers/generateComponentPreload.js b/lib/tasks/bundlers/generateComponentPreload.js
index dc16e91d4..9e61d5d0a 100644
--- a/lib/tasks/bundlers/generateComponentPreload.js
+++ b/lib/tasks/bundlers/generateComponentPreload.js
@@ -56,27 +56,59 @@ module.exports = function({workspace, dependencies, options}) {
}
});
- return moduleBundler({
- resources,
- options: {
- bundleDefinition: {
- name: `${namespace}/Component-preload.js`,
- defaultFileTypes: [".js", ".fragment.xml", ".view.xml", ".properties", ".json"],
- sections: [
- {
- mode: "preload",
- filters: filters,
- resolve: false,
- resolveConditional: false,
- renderer: false
- }
- ]
+ return Promise.all([
+ moduleBundler({
+ resources,
+ options: {
+ bundleDefinition: {
+ name: `${namespace}/Component-preload.js`,
+ defaultFileTypes: [".js", ".fragment.xml", ".view.xml", ".properties", ".json"],
+ sections: [
+ {
+ mode: "preload",
+ filters: filters,
+ resolve: false,
+ resolveConditional: false,
+ renderer: false
+ }
+ ]
+ }
}
- }
- });
+ }),
+ moduleBundler({
+ resources,
+ options: {
+ bundleDefinition: {
+ name: `${namespace}/Component-h2-preload.js`,
+ defaultFileTypes: [".js", ".fragment.xml", ".view.xml", ".properties", ".json"],
+ sections: [
+ {
+ mode: "preload",
+ filters: [
+ `${namespace}/library.js`,
+ `${namespace}/manifest.json`
+ ],
+ resolve: false,
+ resolveConditional: false,
+ renderer: false
+ },
+ {
+ mode: "depcache",
+ filters: filters,
+ resolve: false,
+ resolveConditional: false,
+ renderer: false
+ }
+ ]
+ }
+ }
+ })
+ ]);
}));
})
.then((processedResources) => {
+ return Array.prototype.concat.apply([], processedResources);
+ }).then((processedResources) => {
return Promise.all(processedResources.map((resource) => {
return workspace.write(resource[0]);
}));
diff --git a/lib/tasks/bundlers/generateLibraryPreload.js b/lib/tasks/bundlers/generateLibraryPreload.js
index 82b46d908..2ca4d374d 100644
--- a/lib/tasks/bundlers/generateLibraryPreload.js
+++ b/lib/tasks/bundlers/generateLibraryPreload.js
@@ -2,15 +2,17 @@ const log = require("@ui5/logger").getLogger("builder:tasks:bundlers:generateLib
const moduleBundler = require("../../processors/bundlers/moduleBundler");
const ReaderCollectionPrioritized = require("@ui5/fs").ReaderCollectionPrioritized;
-function getBundleDefinition(namespace) {
+function getBundleDefinition(namespace, h2) {
+ let h2infix = h2 ? "h2-" : "";
+ let bundleDef;
// TODO: move to config of actual core project
if (namespace === "sap/ui/core") {
- return {
- name: `${namespace}/library-preload.js`,
+ bundleDef = {
+ name: `${namespace}/library-${h2infix}preload.js`,
defaultFileTypes: [".js", ".fragment.xml", ".view.xml", ".properties", ".json"],
sections: [
{
- mode: "preload",
+ mode: h2 ? "depcache" : "preload",
filters: [
`${namespace}/`,
`!${namespace}/.library`,
@@ -41,27 +43,42 @@ function getBundleDefinition(namespace) {
}
]
};
+ } else {
+ bundleDef = {
+ name: `${namespace}/library-${h2infix}preload.js`,
+ defaultFileTypes: [".js", ".fragment.xml", ".view.xml", ".properties", ".json"],
+ sections: [
+ {
+ mode: h2 ? "depcache" : "preload",
+ filters: [
+ `${namespace}/`,
+ `!${namespace}/.library`,
+ `!${namespace}/themes/`,
+ `!${namespace}/messagebundle*`
+ ],
+ resolve: false,
+ resolveConditional: false,
+ renderer: true
+ }
+ ]
+ };
}
- return {
- name: `${namespace}/library-preload.js`,
- defaultFileTypes: [".js", ".fragment.xml", ".view.xml", ".properties", ".json"],
- sections: [
- {
- mode: "preload",
- filters: [
- `${namespace}/`,
- `!${namespace}/.library`,
- `!${namespace}/themes/`,
- `!${namespace}/messagebundle*`
- ],
- resolve: false,
- resolveConditional: false,
- renderer: true
- }
- ]
- };
+ if ( h2 ) {
+ bundleDef.sections.unshift({
+ mode: "preload",
+ filters: [
+ `${namespace}/library.js`,
+ `${namespace}/manifest.json`
+ ],
+ resolve: false,
+ resolveConditional: false,
+ renderer: false
+ });
+ }
+ return bundleDef;
}
+
/**
* Task for library bundling.
*
@@ -168,17 +185,30 @@ module.exports = function({workspace, dependencies, options}) {
const libraryNamespaceMatch = libraryIndicatorPath.match(libraryNamespacePattern);
if (libraryNamespaceMatch && libraryNamespaceMatch[1]) {
const libraryNamespace = libraryNamespaceMatch[1];
- return moduleBundler({
- options: {
- bundleDefinition: getBundleDefinition(libraryNamespace)
- },
- resources
- }).then(([bundle]) => {
- if (bundle) {
- // console.log(`${libraryNamespace}/library-preload.js bundle created`);
- return workspace.write(bundle);
- }
- });
+ return Promise.all([
+ moduleBundler({
+ options: {
+ bundleDefinition: getBundleDefinition(libraryNamespace)
+ },
+ resources
+ }).then(([bundle]) => {
+ if (bundle) {
+ // console.log(`${libraryNamespace}/library-preload.js bundle created`);
+ return workspace.write(bundle);
+ }
+ }),
+ moduleBundler({
+ options: {
+ bundleDefinition: getBundleDefinition(libraryNamespace, /* h2 */ true)
+ },
+ resources
+ }).then(([bundle]) => {
+ if (bundle) {
+ // console.log(`${libraryNamespace}/library-h2-preload.js bundle created`);
+ return workspace.write(bundle);
+ }
+ })
+ ]);
} else {
log.verbose(`Could not determine library namespace from file "${libraryIndicatorPath}" for project ${options.projectName}. Skipping library preload bundling.`);
return Promise.resolve();
diff --git a/test/expected/build/application.g/dest/Component-h2-preload.js b/test/expected/build/application.g/dest/Component-h2-preload.js
new file mode 100644
index 000000000..075512062
--- /dev/null
+++ b/test/expected/build/application.g/dest/Component-h2-preload.js
@@ -0,0 +1,6 @@
+sap.ui.require.preload({
+ "application/g/manifest.json":'{"_version":"1.1.0","sap.app":{"_version":"1.1.0","id":"application.g","type":"application","applicationVersion":{"version":"1.2.2"},"embeds":["embedded"],"title":"{{title}}"}}'
+});
+sap.ui.loader.config({depCacheUI5:{
+"application/g/Component.js": ["sap/ui/core/UIComponent.js"]
+}});
diff --git a/test/expected/build/application.g/dest/Component-preload.js b/test/expected/build/application.g/dest/Component-preload.js
index a976c01f8..fda965fae 100644
--- a/test/expected/build/application.g/dest/Component-preload.js
+++ b/test/expected/build/application.g/dest/Component-preload.js
@@ -1,7 +1,5 @@
-jQuery.sap.registerPreloadedModules({
-"version":"2.0",
-"modules":{
+sap.ui.require.preload({
"application/g/Component.js":function(){sap.ui.define(["sap/ui/core/UIComponent"],function(n){"use strict";return n.extend("application.g.Component",{metadata:{manifest:"json"}})});
},
"application/g/manifest.json":'{"_version":"1.1.0","sap.app":{"_version":"1.1.0","id":"application.g","type":"application","applicationVersion":{"version":"1.2.2"},"embeds":["embedded"],"title":"{{title}}"}}'
-}});
+});
diff --git a/test/expected/build/application.g/dest/subcomponentA/Component-h2-preload.js b/test/expected/build/application.g/dest/subcomponentA/Component-h2-preload.js
new file mode 100644
index 000000000..c8b3dad45
--- /dev/null
+++ b/test/expected/build/application.g/dest/subcomponentA/Component-h2-preload.js
@@ -0,0 +1,6 @@
+sap.ui.require.preload({
+ "application/g/subcomponentA/manifest.json":'{"_version":"1.1.0","sap.app":{"_version":"1.1.0","id":"application.g.subcomponentA","type":"application","applicationVersion":{"version":"1.2.2"},"embeds":["embedded"],"title":"{{title}}"}}'
+});
+sap.ui.loader.config({depCacheUI5:{
+"application/g/subcomponentA/Component.js": ["sap/ui/core/UIComponent.js"]
+}});
diff --git a/test/expected/build/application.g/dest/subcomponentA/Component-preload.js b/test/expected/build/application.g/dest/subcomponentA/Component-preload.js
index c30a66412..a5c055e68 100644
--- a/test/expected/build/application.g/dest/subcomponentA/Component-preload.js
+++ b/test/expected/build/application.g/dest/subcomponentA/Component-preload.js
@@ -1,7 +1,5 @@
-jQuery.sap.registerPreloadedModules({
-"version":"2.0",
-"modules":{
+sap.ui.require.preload({
"application/g/subcomponentA/Component.js":function(){sap.ui.define(["sap/ui/core/UIComponent"],function(n){"use strict";return n.extend("application.g.subcomponentA.Component",{metadata:{manifest:"json"}})});
},
"application/g/subcomponentA/manifest.json":'{"_version":"1.1.0","sap.app":{"_version":"1.1.0","id":"application.g.subcomponentA","type":"application","applicationVersion":{"version":"1.2.2"},"embeds":["embedded"],"title":"{{title}}"}}'
-}});
+});
diff --git a/test/expected/build/application.g/dest/subcomponentB/Component-h2-preload.js b/test/expected/build/application.g/dest/subcomponentB/Component-h2-preload.js
new file mode 100644
index 000000000..ea6c03fb7
--- /dev/null
+++ b/test/expected/build/application.g/dest/subcomponentB/Component-h2-preload.js
@@ -0,0 +1,6 @@
+sap.ui.require.preload({
+ "application/g/subcomponentB/manifest.json":'{"_version":"1.1.0","sap.app":{"_version":"1.1.0","id":"application.g.subcomponentB","type":"application","applicationVersion":{"version":"1.2.2"},"embeds":["embedded"],"title":"{{title}}"}}'
+});
+sap.ui.loader.config({depCacheUI5:{
+"application/g/subcomponentB/Component.js": ["sap/ui/core/UIComponent.js"]
+}});
diff --git a/test/expected/build/application.g/dest/subcomponentB/Component-preload.js b/test/expected/build/application.g/dest/subcomponentB/Component-preload.js
index 89aab0dd2..8ca51d2f9 100644
--- a/test/expected/build/application.g/dest/subcomponentB/Component-preload.js
+++ b/test/expected/build/application.g/dest/subcomponentB/Component-preload.js
@@ -1,7 +1,5 @@
-jQuery.sap.registerPreloadedModules({
-"version":"2.0",
-"modules":{
+sap.ui.require.preload({
"application/g/subcomponentB/Component.js":function(){sap.ui.define(["sap/ui/core/UIComponent"],function(n){"use strict";return n.extend("application.g.subcomponentB.Component",{metadata:{manifest:"json"}})});
},
"application/g/subcomponentB/manifest.json":'{"_version":"1.1.0","sap.app":{"_version":"1.1.0","id":"application.g.subcomponentB","type":"application","applicationVersion":{"version":"1.2.2"},"embeds":["embedded"],"title":"{{title}}"}}'
-}});
+});
diff --git a/test/expected/build/application.h/dest/sectionsA/customBundle.js b/test/expected/build/application.h/dest/sectionsA/customBundle.js
index 3a8371325..bb5036f72 100644
--- a/test/expected/build/application.h/dest/sectionsA/customBundle.js
+++ b/test/expected/build/application.h/dest/sectionsA/customBundle.js
@@ -1,8 +1,6 @@
-jQuery.sap.registerPreloadedModules({
-"version":"2.0",
-"modules":{
+sap.ui.require.preload({
"application/h/sectionsA/section1.js":function(){sap.ui.define(["sap/m/Button"],function(n){console.log("Section 1 included")});
},
"application/h/sectionsA/section3.js":function(){sap.ui.define(["sap/m/Button"],function(n){console.log("Section 3 included")});
}
-}});
+});
diff --git a/test/expected/build/application.h/dest/sectionsB/customBundle.js b/test/expected/build/application.h/dest/sectionsB/customBundle.js
index 53acb8710..daf309364 100644
--- a/test/expected/build/application.h/dest/sectionsB/customBundle.js
+++ b/test/expected/build/application.h/dest/sectionsB/customBundle.js
@@ -1,10 +1,8 @@
-jQuery.sap.registerPreloadedModules({
-"version":"2.0",
-"modules":{
+sap.ui.require.preload({
"application/h/sectionsB/section1.js":function(){sap.ui.define(["sap/m/Button"],function(n){console.log("Section 1 included")});
},
"application/h/sectionsB/section2.js":function(){sap.ui.define(["sap/m/Button"],function(n){console.log("Section 2 included")});
},
"application/h/sectionsB/section3.js":function(){sap.ui.define(["sap/m/Button"],function(n){console.log("Section 3 included")});
}
-}});
+});
diff --git a/test/expected/build/library.h/dest/resources/library/h/components/Component-h2-preload.js b/test/expected/build/library.h/dest/resources/library/h/components/Component-h2-preload.js
new file mode 100644
index 000000000..afdad3f0b
--- /dev/null
+++ b/test/expected/build/library.h/dest/resources/library/h/components/Component-h2-preload.js
@@ -0,0 +1,3 @@
+sap.ui.loader.config({depCacheUI5:{
+"library/h/components/Component.js": ["sap/ui/core/UIComponent.js"]
+}});
diff --git a/test/expected/build/library.h/dest/resources/library/h/components/subcomponent1/Component-h2-preload.js b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent1/Component-h2-preload.js
new file mode 100644
index 000000000..e3b18e3e4
--- /dev/null
+++ b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent1/Component-h2-preload.js
@@ -0,0 +1,3 @@
+sap.ui.loader.config({depCacheUI5:{
+"library/h/components/subcomponent1/Component.js": ["sap/ui/core/UIComponent.js"]
+}});
diff --git a/test/expected/build/library.h/dest/resources/library/h/components/subcomponent2/Component-h2-preload.js b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent2/Component-h2-preload.js
new file mode 100644
index 000000000..7918dabf1
--- /dev/null
+++ b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent2/Component-h2-preload.js
@@ -0,0 +1,3 @@
+sap.ui.loader.config({depCacheUI5:{
+"library/h/components/subcomponent2/Component.js": ["sap/ui/core/UIComponent.js"]
+}});
diff --git a/test/expected/build/library.h/dest/resources/library/h/components/subcomponent3/Component-h2-preload.js b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent3/Component-h2-preload.js
new file mode 100644
index 000000000..a56c0b050
--- /dev/null
+++ b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent3/Component-h2-preload.js
@@ -0,0 +1,3 @@
+sap.ui.loader.config({depCacheUI5:{
+"library/h/components/subcomponent3/Component.js": ["sap/ui/core/UIComponent.js"]
+}});
diff --git a/test/expected/build/library.i/dest/resources/library/i/library.js b/test/expected/build/library.i/dest/resources/library/i/library.js
index 48a19acb7..e2764c75a 100644
--- a/test/expected/build/library.i/dest/resources/library/i/library.js
+++ b/test/expected/build/library.i/dest/resources/library/i/library.js
@@ -2,7 +2,7 @@
* Some fancy copyright
*/
sap.ui.define([
- 'sap/ui/core/Core',
+ 'sap/ui/core/Core'
], function(Core) {
"use strict";
@@ -13,10 +13,10 @@ sap.ui.define([
dependencies : ["sap.ui.core"],
types: [
"library.i.ButtonType",
- "library.i.DialogType",
+ "library.i.DialogType"
],
interfaces: [
- "library.i.IContent",
+ "library.i.IContent"
],
controls: [
"library.i.Button",
diff --git a/test/expected/build/library.j/dest/resources/library/e/.library b/test/expected/build/library.j/dest/resources/library/e/.library
new file mode 100644
index 000000000..20c990700
--- /dev/null
+++ b/test/expected/build/library.j/dest/resources/library/e/.library
@@ -0,0 +1,11 @@
+
+
+
+ library.d
+ SAP SE
+ ${copyright}
+ ${version}
+
+ Library E
+
+
diff --git a/test/expected/build/library.j/dest/resources/library/e/library-h2-preload.js b/test/expected/build/library.j/dest/resources/library/e/library-h2-preload.js
new file mode 100644
index 000000000..9e6f50502
--- /dev/null
+++ b/test/expected/build/library.j/dest/resources/library/e/library-h2-preload.js
@@ -0,0 +1,5 @@
+sap.ui.require.preload({
+ "library/e/manifest.json":'{"_version":"1.9.0","sap.app":{"id":"library.d","type":"library","embeds":[],"applicationVersion":{"version":"1.0.0"},"title":"Library E","description":"Library E","resources":"resources.json","offline":true},"sap.ui":{"technology":"UI5","supportedThemes":[]},"sap.ui5":{"dependencies":{"minUI5Version":"1.0","libs":{}},"library":{"i18n":false}}}'
+});
+sap.ui.loader.config({depCacheUI5:{
+}});
diff --git a/test/expected/build/library.j/dest/resources/library/e/library-preload.js b/test/expected/build/library.j/dest/resources/library/e/library-preload.js
new file mode 100644
index 000000000..047a36e01
--- /dev/null
+++ b/test/expected/build/library.j/dest/resources/library/e/library-preload.js
@@ -0,0 +1,10 @@
+sap.ui.require.preload({
+ "library/e/manifest.json":'{"_version":"1.9.0","sap.app":{"id":"library.d","type":"library","embeds":[],"applicationVersion":{"version":"1.0.0"},"title":"Library E","description":"Library E","resources":"resources.json","offline":true},"sap.ui":{"technology":"UI5","supportedThemes":[]},"sap.ui5":{"dependencies":{"minUI5Version":"1.0","libs":{}},"library":{"i18n":false}}}',
+ "library/e/some.js":function(){/*!
+ * UI development toolkit for HTML5 (OpenUI5)
+ * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company.
+ * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
+ */
+console.log("HelloWorld");
+}
+});
diff --git a/test/expected/build/library.j/dest/resources/library/e/manifest.json b/test/expected/build/library.j/dest/resources/library/e/manifest.json
new file mode 100644
index 000000000..90cbd949f
--- /dev/null
+++ b/test/expected/build/library.j/dest/resources/library/e/manifest.json
@@ -0,0 +1,28 @@
+{
+ "_version": "1.9.0",
+ "sap.app": {
+ "id": "library.d",
+ "type": "library",
+ "embeds": [],
+ "applicationVersion": {
+ "version": "1.0.0"
+ },
+ "title": "Library E",
+ "description": "Library E",
+ "resources": "resources.json",
+ "offline": true
+ },
+ "sap.ui": {
+ "technology": "UI5",
+ "supportedThemes": []
+ },
+ "sap.ui5": {
+ "dependencies": {
+ "minUI5Version": "1.0",
+ "libs": {}
+ },
+ "library": {
+ "i18n": false
+ }
+ }
+}
\ No newline at end of file
diff --git a/test/expected/build/library.j/dest/resources/library/e/some-dbg.js b/test/expected/build/library.j/dest/resources/library/e/some-dbg.js
new file mode 100644
index 000000000..dc9e1fc91
--- /dev/null
+++ b/test/expected/build/library.j/dest/resources/library/e/some-dbg.js
@@ -0,0 +1,6 @@
+/*!
+ * UI development toolkit for HTML5 (OpenUI5)
+ * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company.
+ * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
+ */
+console.log('HelloWorld');
\ No newline at end of file
diff --git a/test/expected/build/library.j/dest/resources/library/e/some.js b/test/expected/build/library.j/dest/resources/library/e/some.js
new file mode 100644
index 000000000..39e3277ce
--- /dev/null
+++ b/test/expected/build/library.j/dest/resources/library/e/some.js
@@ -0,0 +1,6 @@
+/*!
+ * UI development toolkit for HTML5 (OpenUI5)
+ * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company.
+ * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
+ */
+console.log("HelloWorld");
\ No newline at end of file
diff --git a/test/expected/build/library.j/dest/test-resources/library/e/Test.html b/test/expected/build/library.j/dest/test-resources/library/e/Test.html
new file mode 100644
index 000000000..e69de29bb
diff --git a/test/fixtures/library.i/main/src/library/i/library.js b/test/fixtures/library.i/main/src/library/i/library.js
index e1c0e2cb0..f70247c43 100644
--- a/test/fixtures/library.i/main/src/library/i/library.js
+++ b/test/fixtures/library.i/main/src/library/i/library.js
@@ -2,7 +2,7 @@
* ${copyright}
*/
sap.ui.define([
- 'sap/ui/core/Core',
+ 'sap/ui/core/Core'
], function(Core) {
"use strict";
@@ -13,10 +13,10 @@ sap.ui.define([
dependencies : ["sap.ui.core"],
types: [
"library.i.ButtonType",
- "library.i.DialogType",
+ "library.i.DialogType"
],
interfaces: [
- "library.i.IContent",
+ "library.i.IContent"
],
controls: [
"library.i.Button",
diff --git a/test/fixtures/library.j/main/src/library/j/.library b/test/fixtures/library.j/main/src/library/j/.library
new file mode 100644
index 000000000..cc3e55eba
--- /dev/null
+++ b/test/fixtures/library.j/main/src/library/j/.library
@@ -0,0 +1,18 @@
+
+
+
+ library.j
+ SAP SE
+ Some fancy copyright
+ ${version}
+
+ {{title}}
+ {{description}}
+
+
+
+ sap.ui.core
+
+
+
+
diff --git a/test/fixtures/library.j/main/src/library/j/helper.js b/test/fixtures/library.j/main/src/library/j/helper.js
new file mode 100644
index 000000000..2c98f170b
--- /dev/null
+++ b/test/fixtures/library.j/main/src/library/j/helper.js
@@ -0,0 +1,14 @@
+/*!
+ * ${copyright}
+ */
+sap.ui.define([
+ 'sap/ui/model/json/JSONModel'
+], function(JSONModel) {
+
+ "use strict";
+
+ return function(data) {
+ return new JSONModel(data);
+ };
+
+});
diff --git a/test/fixtures/library.j/main/src/library/j/library.js b/test/fixtures/library.j/main/src/library/j/library.js
new file mode 100644
index 000000000..5fbbd09d0
--- /dev/null
+++ b/test/fixtures/library.j/main/src/library/j/library.js
@@ -0,0 +1,18 @@
+/*!
+ * ${copyright}
+ */
+sap.ui.define([
+ 'sap/ui/core/Core'
+], function(Core) {
+
+ "use strict";
+
+ sap.ui.getCore().initLibrary({
+ name : "library.j",
+ version: "${version}",
+ dependencies : ["sap.ui.core"]
+ });
+
+ return thisLib;
+
+});
diff --git a/test/fixtures/library.j/package.json b/test/fixtures/library.j/package.json
new file mode 100644
index 000000000..f930ef082
--- /dev/null
+++ b/test/fixtures/library.j/package.json
@@ -0,0 +1,9 @@
+{
+ "name": "library.h",
+ "version": "1.0.0",
+ "description": "Simple SAPUI5 based library",
+ "dependencies": {},
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ }
+}
diff --git a/test/lib/builder/builder.js b/test/lib/builder/builder.js
index 21ffa3dca..246c0babf 100644
--- a/test/lib/builder/builder.js
+++ b/test/lib/builder/builder.js
@@ -253,6 +253,52 @@ test("Build library.i with manifest info taken from .library and library.js", (t
});
});
+test("Build library.j with library preloads", (t) => {
+ const destPath = "./test/tmp/build/library.j/dest";
+ const expectedPath = "./test/expected/build/library.j/dest";
+
+ return builder.build({
+ tree: libraryJTree,
+ destPath
+ }).then(() => {
+ return findFiles(expectedPath);
+ }).then((expectedFiles) => {
+ // Check for all directories and files
+ assert.directoryDeepEqual(destPath, expectedPath);
+
+ // Check for all file contents
+ expectedFiles.forEach((expectedFile) => {
+ const relativeFile = path.relative(expectedPath, expectedFile);
+ const destFile = path.join(destPath, relativeFile);
+ assert.fileEqual(destFile, expectedFile);
+ t.pass();
+ });
+ });
+});
+
+const coreLibraryTree = {
+ "id": "sap.ui.core-evo",
+ "version": "1.0.0",
+ "path": libraryCore,
+ "dependencies": [],
+ "_level": 0,
+ "specVersion": "0.1",
+ "type": "library",
+ "metadata": {
+ "name": "sap.ui.core",
+ "copyright": "Some fancy copyright"
+ },
+ "resources": {
+ "configuration": {
+ "paths": {
+ "src": "main/src"
+ }
+ },
+ "pathMappings": {
+ "/resources/": "main/src"
+ }
+ }
+};
const applicationATree = {
"id": "application.a",
@@ -389,7 +435,9 @@ const applicationGTree = {
"name": "application.g",
"namespace": "application/g"
},
- "dependencies": [],
+ "dependencies": [
+ cloneProjectTree(coreLibraryTree)
+ ],
"resources": {
"configuration": {
"paths": {
@@ -422,7 +470,9 @@ const applicationGTreeComponentPreloadPaths = {
"name": "application.g",
"namespace": "application/g"
},
- "dependencies": [],
+ "dependencies": [
+ cloneProjectTree(coreLibraryTree)
+ ],
"resources": {
"configuration": {
"paths": {
@@ -453,7 +503,9 @@ const applicationHTree = {
"name": "application.h",
"namespace": "application/h"
},
- "dependencies": [],
+ "dependencies": [
+ cloneProjectTree(coreLibraryTree)
+ ],
"resources": {
"configuration": {
"paths": {
@@ -507,29 +559,7 @@ const libraryDTree = {
"version": "1.0.0",
"path": libraryDPath,
"dependencies": [
- {
- "id": "sap.ui.core-evo",
- "version": "1.0.0",
- "path": libraryCore,
- "dependencies": [],
- "_level": 1,
- "specVersion": "0.1",
- "type": "library",
- "metadata": {
- "name": "sap.ui.core",
- "copyright": "Some fancy copyright"
- },
- "resources": {
- "configuration": {
- "paths": {
- "src": "main/src"
- }
- },
- "pathMappings": {
- "/resources/": "main/src"
- }
- }
- }
+ cloneProjectTree(coreLibraryTree)
],
"_level": 0,
"specVersion": "0.1",
@@ -557,29 +587,7 @@ const libraryETree = {
"version": "1.0.0",
"path": libraryEPath,
"dependencies": [
- {
- "id": "sap.ui.core-evo",
- "version": "1.0.0",
- "path": libraryCore,
- "dependencies": [],
- "_level": 1,
- "specVersion": "0.1",
- "type": "library",
- "metadata": {
- "name": "sap.ui.core",
- "copyright": "Some fancy copyright"
- },
- "resources": {
- "configuration": {
- "paths": {
- "src": "main/src"
- }
- },
- "pathMappings": {
- "/resources/": "main/src"
- }
- }
- }
+ cloneProjectTree(coreLibraryTree)
],
"_level": 0,
"specVersion": "0.1",
@@ -607,29 +615,7 @@ const libraryHTree = {
"version": "1.0.0",
"path": libraryHPath,
"dependencies": [
- {
- "id": "sap.ui.core-evo",
- "version": "1.0.0",
- "path": libraryCore,
- "dependencies": [],
- "_level": 1,
- "specVersion": "0.1",
- "type": "library",
- "metadata": {
- "name": "sap.ui.core",
- "copyright": "Some fancy copyright"
- },
- "resources": {
- "configuration": {
- "paths": {
- "src": "main/src"
- }
- },
- "pathMappings": {
- "/resources/": "main/src"
- }
- }
- }
+ cloneProjectTree(coreLibraryTree)
],
"_level": 0,
"specVersion": "0.1",
@@ -689,29 +675,7 @@ const libraryITree = {
"version": "1.0.0",
"path": libraryIPath,
"dependencies": [
- {
- "id": "sap.ui.core-evo",
- "version": "1.0.0",
- "path": libraryCore,
- "dependencies": [],
- "_level": 1,
- "specVersion": "0.1",
- "type": "library",
- "metadata": {
- "name": "sap.ui.core",
- "copyright": "Some fancy copyright"
- },
- "resources": {
- "configuration": {
- "paths": {
- "src": "main/src"
- }
- },
- "pathMappings": {
- "/resources/": "main/src"
- }
- }
- },
+ cloneProjectTree(coreLibraryTree),
cloneProjectTree(libraryDTree)
],
"_level": 0,
@@ -735,3 +699,31 @@ const libraryITree = {
}
};
+const libraryJTree = {
+ "id": "library.j",
+ "version": "1.0.0",
+ "path": libraryEPath,
+ "dependencies": [
+ cloneProjectTree(coreLibraryTree)
+ ],
+ "_level": 0,
+ "specVersion": "0.1",
+ "type": "library",
+ "metadata": {
+ "name": "library.j",
+ "copyright": "UI development toolkit for HTML5 (OpenUI5)\n * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company.\n * Licensed under the Apache License, Version 2.0 - see LICENSE.txt."
+ },
+ "resources": {
+ "configuration": {
+ "paths": {
+ "src": "src",
+ "test": "test"
+ }
+ },
+ "pathMappings": {
+ "/resources/": "src",
+ "/test-resources/": "test"
+ }
+ }
+};
+