diff --git a/Gruntfile.js b/Gruntfile.js index 6c664e2b..b99e667e 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -133,6 +133,24 @@ module.exports = function(grunt) { components: '**' }, + 'component_compat_140': { + options: { + resources: 'test/preload/fixtures/app', + dest: 'tmp/preload/component_compat_140', + compatVersion: '1.40' + }, + components: '**' + }, + + 'component_compat_154': { + options: { + resources: 'test/preload/fixtures/app', + dest: 'tmp/preload/component_compat_154', + compatVersion: '1.54' + }, + components: '**' + }, + 'library_default_options': { options: { resources: 'test/preload/fixtures/library', @@ -159,6 +177,15 @@ module.exports = function(grunt) { libraries: '**' }, + 'library_compat_154': { + options: { + resources: 'test/preload/fixtures/library', + dest: 'tmp/preload/library_compat_154', + compatVersion: '1.54' + }, + libraries: '**' + }, + 'library_resource_prefix': { options: { resources: [ diff --git a/tasks/preload.js b/tasks/preload.js index b7cb46f1..5e3888ac 100644 --- a/tasks/preload.js +++ b/tasks/preload.js @@ -34,6 +34,16 @@ var defaultResourcePatterns = [ var copyrightCommentsPattern = /copyright|\(c\)|released under|license|\u00a9/i; var xmlHtmlPrePattern = /<(?:\w+:)?pre>/; +function createJSPreload(preloadObject) { + return 'sap.ui.require.preload(' + JSON.stringify(preloadObject.modules, null, '\t') + ', "' + preloadObject.name + '");'; +} +function createLegacyJSPreload(preloadObject) { + return 'jQuery.sap.registerPreloadedModules(' + JSON.stringify(preloadObject, null, '\t') + ');'; +} +function createLegacyJSONPreload(preloadObject) { + return JSON.stringify(preloadObject, null, '\t'); +} + module.exports = function (grunt) { grunt.registerMultiTask('openui5_preload', 'Create OpenUI5 preload files', function() { @@ -117,44 +127,50 @@ module.exports = function (grunt) { return; } + if (options.compatVersion !== "edge") { + var aVersionMatch = options.compatVersion.match(/^([0-9]+)\.([0-9]+)$/); + if (!aVersionMatch) { + grunt.fail.warn('\'' + options.compatVersion + '\' is not a valid value for option compatVersion!'); + return; + } + iMajor = parseInt(aVersionMatch[1], 10); + iMinor = parseInt(aVersionMatch[2], 10); + } + if (preloadType === 'libraries') { preloadInfo = { moduleName: 'library-preload', - indicatorFile: 'library.js', - processModuleName: function(moduleName) { - return moduleName.replace(/\//g, '.'); - } + ext: '.js', + indicatorFile: 'library.js' }; - if (options.compatVersion !== "edge") { - var aVersionMatch = options.compatVersion.match(/^([0-9]+)\.([0-9]+)$/); - if (!aVersionMatch) { - grunt.fail.warn('\'' + options.compatVersion + '\' is not a valid value for option compatVersion!'); - return; - } - iMajor = parseInt(aVersionMatch[1], 10); - iMinor = parseInt(aVersionMatch[2], 10); - } - - if (options.compatVersion === "edge" || (iMajor === 1 && iMinor >= 40) || iMajor > 1) { + if (options.compatVersion === "edge" || (iMajor === 1 && iMinor >= 54) || iMajor > 1) { // Build library-preload as .js file - preloadInfo.ext = ".js"; - preloadInfo.processContent = function(content) { - return 'jQuery.sap.registerPreloadedModules(' + content + ');'; - }; + preloadInfo.createContent = createJSPreload; + } else if (iMajor === 1 && iMinor >= 40 && iMinor < 54) { + // Build library-preload as .js file + preloadInfo.createContent = createLegacyJSPreload; } else { - // Build as .json file (legacy, needed because UI5 <1.40 only loads the .json files) + // Build as .json file (legacy, needed because UI5 < 1.40 only loads the .json files) preloadInfo.ext = ".json"; + preloadInfo.processModuleName = function(moduleName) { + return moduleName.replace(/\//g, '.'); + }; + preloadInfo.createContent = createLegacyJSONPreload; } } else { preloadInfo = { moduleName: 'Component-preload', ext: '.js', - indicatorFile: 'Component.js', - processContent: function(content) { - return 'jQuery.sap.registerPreloadedModules(' + content + ');'; - } + indicatorFile: 'Component.js' }; + + if (options.compatVersion === "edge" || (iMajor === 1 && iMinor >= 54) || iMajor > 1) { + preloadInfo.createContent = createJSPreload; + } else { + preloadInfo.createContent = createLegacyJSPreload; + } + } @@ -293,10 +309,7 @@ module.exports = function (grunt) { preloadObject.modules[preloadFile] = fileContent; }); - var content = JSON.stringify(preloadObject, null, '\t'); - if (typeof preloadInfo.processContent === 'function') { - content = preloadInfo.processContent(content); - } + var content = preloadInfo.createContent(preloadObject); var destPath = options.dest; var preloadResourceInfo = resourceMap[preloadFile]; diff --git a/test/preload/expected/component_compat_140/my/app/Component-preload.js b/test/preload/expected/component_compat_140/my/app/Component-preload.js new file mode 100644 index 00000000..07a1edc4 --- /dev/null +++ b/test/preload/expected/component_compat_140/my/app/Component-preload.js @@ -0,0 +1,9 @@ +jQuery.sap.registerPreloadedModules({ + "version": "2.0", + "name": "my/app/Component-preload", + "modules": { + "my/app/Component.js": "/* © */\n\"use strict\";function myFunction(n,o){return n+o}/**\n* This is a copyright comment\n*/\n/* (c) */\n/* released under */\n/* license */\nconsole.log(\"myJS\");", + "my/app/view/my.view.xml": "XML\n", + "my/app/view/myHtmlPre.view.xml": "XML\n\n " + } +}); diff --git a/test/preload/expected/component_compat_154/my/app/Component-preload.js b/test/preload/expected/component_compat_154/my/app/Component-preload.js new file mode 100644 index 00000000..7a3687af --- /dev/null +++ b/test/preload/expected/component_compat_154/my/app/Component-preload.js @@ -0,0 +1,5 @@ +sap.ui.require.preload({ + "my/app/Component.js": "/* © */\n\"use strict\";function myFunction(n,o){return n+o}/**\n* This is a copyright comment\n*/\n/* (c) */\n/* released under */\n/* license */\nconsole.log(\"myJS\");", + "my/app/view/my.view.xml": "XML\n", + "my/app/view/myHtmlPre.view.xml": "XML\n\n " +}, "my/app/Component-preload"); diff --git a/test/preload/expected/component_default_options/my/app/Component-preload.js b/test/preload/expected/component_default_options/my/app/Component-preload.js index 07a1edc4..7a3687af 100644 --- a/test/preload/expected/component_default_options/my/app/Component-preload.js +++ b/test/preload/expected/component_default_options/my/app/Component-preload.js @@ -1,9 +1,5 @@ -jQuery.sap.registerPreloadedModules({ - "version": "2.0", - "name": "my/app/Component-preload", - "modules": { - "my/app/Component.js": "/* © */\n\"use strict\";function myFunction(n,o){return n+o}/**\n* This is a copyright comment\n*/\n/* (c) */\n/* released under */\n/* license */\nconsole.log(\"myJS\");", - "my/app/view/my.view.xml": "XML\n", - "my/app/view/myHtmlPre.view.xml": "XML\n\n " - } -}); +sap.ui.require.preload({ + "my/app/Component.js": "/* © */\n\"use strict\";function myFunction(n,o){return n+o}/**\n* This is a copyright comment\n*/\n/* (c) */\n/* released under */\n/* license */\nconsole.log(\"myJS\");", + "my/app/view/my.view.xml": "XML\n", + "my/app/view/myHtmlPre.view.xml": "XML\n\n " +}, "my/app/Component-preload"); diff --git a/test/preload/expected/component_no_compress/my/app/Component-preload.js b/test/preload/expected/component_no_compress/my/app/Component-preload.js index 8a84bfca..f3c3d18a 100644 --- a/test/preload/expected/component_no_compress/my/app/Component-preload.js +++ b/test/preload/expected/component_no_compress/my/app/Component-preload.js @@ -1,9 +1,5 @@ -jQuery.sap.registerPreloadedModules({ - "version": "2.0", - "name": "my/app/Component-preload", - "modules": { - "my/app/Component.js": "/* © */\n'use strict';\n\n/**\n* This is a copyright comment\n*/\n\n/* (c) */\n\n/* released under */\n/* normal comment */\n/* license */\n\n\nconsole.log('myJS');\n\n/**\n * This is a little comment\n */\nfunction myFunction(longVariableName, longerVariableName) {\n\treturn longVariableName + longerVariableName;\n}\n", - "my/app/view/my.view.xml": "XML\n", - "my/app/view/myHtmlPre.view.xml": "XML\n\n " - } -}); +sap.ui.require.preload({ + "my/app/Component.js": "/* © */\n'use strict';\n\n/**\n* This is a copyright comment\n*/\n\n/* (c) */\n\n/* released under */\n/* normal comment */\n/* license */\n\n\nconsole.log('myJS');\n\n/**\n * This is a little comment\n */\nfunction myFunction(longVariableName, longerVariableName) {\n\treturn longVariableName + longerVariableName;\n}\n", + "my/app/view/my.view.xml": "XML\n", + "my/app/view/myHtmlPre.view.xml": "XML\n\n " +}, "my/app/Component-preload"); diff --git a/test/preload/expected/component_resource_prefix/Component-preload.js b/test/preload/expected/component_resource_prefix/Component-preload.js index 07a1edc4..7a3687af 100644 --- a/test/preload/expected/component_resource_prefix/Component-preload.js +++ b/test/preload/expected/component_resource_prefix/Component-preload.js @@ -1,9 +1,5 @@ -jQuery.sap.registerPreloadedModules({ - "version": "2.0", - "name": "my/app/Component-preload", - "modules": { - "my/app/Component.js": "/* © */\n\"use strict\";function myFunction(n,o){return n+o}/**\n* This is a copyright comment\n*/\n/* (c) */\n/* released under */\n/* license */\nconsole.log(\"myJS\");", - "my/app/view/my.view.xml": "XML\n", - "my/app/view/myHtmlPre.view.xml": "XML\n\n " - } -}); +sap.ui.require.preload({ + "my/app/Component.js": "/* © */\n\"use strict\";function myFunction(n,o){return n+o}/**\n* This is a copyright comment\n*/\n/* (c) */\n/* released under */\n/* license */\nconsole.log(\"myJS\");", + "my/app/view/my.view.xml": "XML\n", + "my/app/view/myHtmlPre.view.xml": "XML\n\n " +}, "my/app/Component-preload"); diff --git a/test/preload/expected/library_compat_140/my/ui/lib/library-preload.js b/test/preload/expected/library_compat_140/my/ui/lib/library-preload.js index 60d18f22..93f2544c 100644 --- a/test/preload/expected/library_compat_140/my/ui/lib/library-preload.js +++ b/test/preload/expected/library_compat_140/my/ui/lib/library-preload.js @@ -1,6 +1,6 @@ jQuery.sap.registerPreloadedModules({ "version": "2.0", - "name": "my.ui.lib.library-preload", + "name": "my/ui/lib/library-preload", "modules": { "my/ui/lib/library.js": "jQuery.sap.require(\"sap.ui.core.library\"),jQuery.sap.declare(\"my.ui.lib.library\"),sap.ui.getCore().initLibrary({name:\"my.ui.lib\",version:\"0.0.0\",dependencies:[\"sap.ui.core\"]});", "my/ui/lib/myJS.js": "/* © */\n\"use strict\";function myFunction(n,o){return n+o}/**\n* This is a copyright comment\n*/\n/* (c) */\n/* released under */\n/* license */\nconsole.log(\"myJS\");", diff --git a/test/preload/expected/library_compat_154/my/ui/lib/library-preload.js b/test/preload/expected/library_compat_154/my/ui/lib/library-preload.js new file mode 100644 index 00000000..08299856 --- /dev/null +++ b/test/preload/expected/library_compat_154/my/ui/lib/library-preload.js @@ -0,0 +1,7 @@ +sap.ui.require.preload({ + "my/ui/lib/library.js": "jQuery.sap.require(\"sap.ui.core.library\"),jQuery.sap.declare(\"my.ui.lib.library\"),sap.ui.getCore().initLibrary({name:\"my.ui.lib\",version:\"0.0.0\",dependencies:[\"sap.ui.core\"]});", + "my/ui/lib/myJS.js": "/* © */\n\"use strict\";function myFunction(n,o){return n+o}/**\n* This is a copyright comment\n*/\n/* (c) */\n/* released under */\n/* license */\nconsole.log(\"myJS\");", + "my/ui/lib/my.view.xml": "XML\n", + "my/ui/lib/myHtmlPre.view.xml": "XML\n\n ", + "my/ui/lib/foo.properties": "FOO=BAR\n" +}, "my/ui/lib/library-preload"); diff --git a/test/preload/expected/library_custom_uglify_params/my/ui/lib/library-preload.js b/test/preload/expected/library_custom_uglify_params/my/ui/lib/library-preload.js index 12098244..61c44192 100644 --- a/test/preload/expected/library_custom_uglify_params/my/ui/lib/library-preload.js +++ b/test/preload/expected/library_custom_uglify_params/my/ui/lib/library-preload.js @@ -1,11 +1,7 @@ -jQuery.sap.registerPreloadedModules({ - "version": "2.0", - "name": "my.ui.lib.library-preload", - "modules": { - "my/ui/lib/library.js": "jQuery.sap.require(\"sap.ui.core.library\"),jQuery.sap.declare(\"my.ui.lib.library\"),sap.ui.getCore().initLibrary({name:\"my.ui.lib\",version:\"0.0.0\",dependencies:[\"sap.ui.core\"]});", - "my/ui/lib/myJS.js": "/* © */\n\"use strict\";function myFunction(longVariableName,longerVariableName){return longVariableName+longerVariableName+\"\\u518d\\u6309\\u4e00\\u6b21\\u9000\\u51fa\\u4f19\\u62fc\"}/**\n* This is a copyright comment\n*/\n/* (c) */\n/* released under */\n/* license */\nconsole.log(\"myJS\");", - "my/ui/lib/my.view.xml": "XML\n", - "my/ui/lib/myHtmlPre.view.xml": "XML\n\n ", - "my/ui/lib/foo.properties": "FOO=BAR\n" - } -}); +sap.ui.require.preload({ + "my/ui/lib/library.js": "jQuery.sap.require(\"sap.ui.core.library\"),jQuery.sap.declare(\"my.ui.lib.library\"),sap.ui.getCore().initLibrary({name:\"my.ui.lib\",version:\"0.0.0\",dependencies:[\"sap.ui.core\"]});", + "my/ui/lib/myJS.js": "/* © */\n\"use strict\";function myFunction(longVariableName,longerVariableName){return longVariableName+longerVariableName+\"\\u518d\\u6309\\u4e00\\u6b21\\u9000\\u51fa\\u4f19\\u62fc\"}/**\n* This is a copyright comment\n*/\n/* (c) */\n/* released under */\n/* license */\nconsole.log(\"myJS\");", + "my/ui/lib/my.view.xml": "XML\n", + "my/ui/lib/myHtmlPre.view.xml": "XML\n\n ", + "my/ui/lib/foo.properties": "FOO=BAR\n" +}, "my/ui/lib/library-preload"); diff --git a/test/preload/expected/library_default_options/my/ui/lib/library-preload.js b/test/preload/expected/library_default_options/my/ui/lib/library-preload.js index 60d18f22..08299856 100644 --- a/test/preload/expected/library_default_options/my/ui/lib/library-preload.js +++ b/test/preload/expected/library_default_options/my/ui/lib/library-preload.js @@ -1,11 +1,7 @@ -jQuery.sap.registerPreloadedModules({ - "version": "2.0", - "name": "my.ui.lib.library-preload", - "modules": { - "my/ui/lib/library.js": "jQuery.sap.require(\"sap.ui.core.library\"),jQuery.sap.declare(\"my.ui.lib.library\"),sap.ui.getCore().initLibrary({name:\"my.ui.lib\",version:\"0.0.0\",dependencies:[\"sap.ui.core\"]});", - "my/ui/lib/myJS.js": "/* © */\n\"use strict\";function myFunction(n,o){return n+o}/**\n* This is a copyright comment\n*/\n/* (c) */\n/* released under */\n/* license */\nconsole.log(\"myJS\");", - "my/ui/lib/my.view.xml": "XML\n", - "my/ui/lib/myHtmlPre.view.xml": "XML\n\n ", - "my/ui/lib/foo.properties": "FOO=BAR\n" - } -}); +sap.ui.require.preload({ + "my/ui/lib/library.js": "jQuery.sap.require(\"sap.ui.core.library\"),jQuery.sap.declare(\"my.ui.lib.library\"),sap.ui.getCore().initLibrary({name:\"my.ui.lib\",version:\"0.0.0\",dependencies:[\"sap.ui.core\"]});", + "my/ui/lib/myJS.js": "/* © */\n\"use strict\";function myFunction(n,o){return n+o}/**\n* This is a copyright comment\n*/\n/* (c) */\n/* released under */\n/* license */\nconsole.log(\"myJS\");", + "my/ui/lib/my.view.xml": "XML\n", + "my/ui/lib/myHtmlPre.view.xml": "XML\n\n ", + "my/ui/lib/foo.properties": "FOO=BAR\n" +}, "my/ui/lib/library-preload"); diff --git a/test/preload/expected/library_no_compress/my/ui/lib/library-preload.js b/test/preload/expected/library_no_compress/my/ui/lib/library-preload.js index acf6bbc6..68e6a9a1 100644 --- a/test/preload/expected/library_no_compress/my/ui/lib/library-preload.js +++ b/test/preload/expected/library_no_compress/my/ui/lib/library-preload.js @@ -1,11 +1,7 @@ -jQuery.sap.registerPreloadedModules({ - "version": "2.0", - "name": "my.ui.lib.library-preload", - "modules": { - "my/ui/lib/library.js": "jQuery.sap.require(\"sap.ui.core.library\");\njQuery.sap.declare(\"my.ui.lib.library\");\n\nsap.ui.getCore().initLibrary({\n\tname : \"my.ui.lib\",\n\tversion: \"0.0.0\",\n\tdependencies : [\"sap.ui.core\"]\n});\n", - "my/ui/lib/myJS.js": "/* © */\n'use strict';\n\n/**\n* This is a copyright comment\n*/\n\n/* (c) */\n\n/* released under */\n/* normal comment */\n/* license */\n\n\nconsole.log('myJS');\n\n/**\n * This is a little comment\n */\nfunction myFunction(longVariableName, longerVariableName) {\n\treturn longVariableName + longerVariableName;\n}\n", - "my/ui/lib/my.view.xml": "XML\n", - "my/ui/lib/myHtmlPre.view.xml": "XML\n\n ", - "my/ui/lib/foo.properties": "FOO=BAR\n" - } -}); +sap.ui.require.preload({ + "my/ui/lib/library.js": "jQuery.sap.require(\"sap.ui.core.library\");\njQuery.sap.declare(\"my.ui.lib.library\");\n\nsap.ui.getCore().initLibrary({\n\tname : \"my.ui.lib\",\n\tversion: \"0.0.0\",\n\tdependencies : [\"sap.ui.core\"]\n});\n", + "my/ui/lib/myJS.js": "/* © */\n'use strict';\n\n/**\n* This is a copyright comment\n*/\n\n/* (c) */\n\n/* released under */\n/* normal comment */\n/* license */\n\n\nconsole.log('myJS');\n\n/**\n * This is a little comment\n */\nfunction myFunction(longVariableName, longerVariableName) {\n\treturn longVariableName + longerVariableName;\n}\n", + "my/ui/lib/my.view.xml": "XML\n", + "my/ui/lib/myHtmlPre.view.xml": "XML\n\n ", + "my/ui/lib/foo.properties": "FOO=BAR\n" +}, "my/ui/lib/library-preload"); diff --git a/test/preload/expected/library_resource_prefix/library-preload.js b/test/preload/expected/library_resource_prefix/library-preload.js index 60d18f22..08299856 100644 --- a/test/preload/expected/library_resource_prefix/library-preload.js +++ b/test/preload/expected/library_resource_prefix/library-preload.js @@ -1,11 +1,7 @@ -jQuery.sap.registerPreloadedModules({ - "version": "2.0", - "name": "my.ui.lib.library-preload", - "modules": { - "my/ui/lib/library.js": "jQuery.sap.require(\"sap.ui.core.library\"),jQuery.sap.declare(\"my.ui.lib.library\"),sap.ui.getCore().initLibrary({name:\"my.ui.lib\",version:\"0.0.0\",dependencies:[\"sap.ui.core\"]});", - "my/ui/lib/myJS.js": "/* © */\n\"use strict\";function myFunction(n,o){return n+o}/**\n* This is a copyright comment\n*/\n/* (c) */\n/* released under */\n/* license */\nconsole.log(\"myJS\");", - "my/ui/lib/my.view.xml": "XML\n", - "my/ui/lib/myHtmlPre.view.xml": "XML\n\n ", - "my/ui/lib/foo.properties": "FOO=BAR\n" - } -}); +sap.ui.require.preload({ + "my/ui/lib/library.js": "jQuery.sap.require(\"sap.ui.core.library\"),jQuery.sap.declare(\"my.ui.lib.library\"),sap.ui.getCore().initLibrary({name:\"my.ui.lib\",version:\"0.0.0\",dependencies:[\"sap.ui.core\"]});", + "my/ui/lib/myJS.js": "/* © */\n\"use strict\";function myFunction(n,o){return n+o}/**\n* This is a copyright comment\n*/\n/* (c) */\n/* released under */\n/* license */\nconsole.log(\"myJS\");", + "my/ui/lib/my.view.xml": "XML\n", + "my/ui/lib/myHtmlPre.view.xml": "XML\n\n ", + "my/ui/lib/foo.properties": "FOO=BAR\n" +}, "my/ui/lib/library-preload"); diff --git a/test/preload/fixtures/app-same-dest/my/app/Component-preload.js b/test/preload/fixtures/app-same-dest/my/app/Component-preload.js index 8cfddd3c..bf8d2deb 100644 --- a/test/preload/fixtures/app-same-dest/my/app/Component-preload.js +++ b/test/preload/fixtures/app-same-dest/my/app/Component-preload.js @@ -1,9 +1,5 @@ -jQuery.sap.registerPreloadedModules({ - "version": "2.0", - "name": "my/app/Component-preload", - "modules": { - "my/app/Component.js": "/* © */\n\"use strict\";function myFunction(n,o){return n+o}/**\n* This is a copyright comment\n*/\n/* (c) */\n/* released under */\n/* license */\nconsole.log(\"myJS\");", - "my/app/view/my.view.xml": "XML\n", - "my/app/view/myHtmlPre.view.xml": "XML\n\n " - } -}); \ No newline at end of file +sap.ui.require.preload({ + "my/app/Component.js": "/* © */\n\"use strict\";function myFunction(n,o){return n+o}/**\n* This is a copyright comment\n*/\n/* (c) */\n/* released under */\n/* license */\nconsole.log(\"myJS\");", + "my/app/view/my.view.xml": "XML\n", + "my/app/view/myHtmlPre.view.xml": "XML\n\n " +}, "my/app/Component-preload"); \ No newline at end of file diff --git a/test/preload/fixtures/library-same-dest/my/ui/lib/library-preload.js b/test/preload/fixtures/library-same-dest/my/ui/lib/library-preload.js index cc0422c4..316aeb12 100644 --- a/test/preload/fixtures/library-same-dest/my/ui/lib/library-preload.js +++ b/test/preload/fixtures/library-same-dest/my/ui/lib/library-preload.js @@ -1,11 +1,7 @@ -jQuery.sap.registerPreloadedModules({ - "version": "2.0", - "name": "my.ui.lib.library-preload", - "modules": { - "my/ui/lib/library.js": "jQuery.sap.require(\"sap.ui.core.library\"),jQuery.sap.declare(\"my.ui.lib.library\"),sap.ui.getCore().initLibrary({name:\"my.ui.lib\",version:\"0.0.0\",dependencies:[\"sap.ui.core\"]});", - "my/ui/lib/myJS.js": "/* © */\n\"use strict\";function myFunction(n,o){return n+o}/**\n* This is a copyright comment\n*/\n/* (c) */\n/* released under */\n/* license */\nconsole.log(\"myJS\");", - "my/ui/lib/my.view.xml": "XML\n", - "my/ui/lib/myHtmlPre.view.xml": "XML\n\n ", - "my/ui/lib/foo.properties": "FOO=BAR\n" - } -}); \ No newline at end of file +sap.ui.require.preload({ + "my/ui/lib/library.js": "jQuery.sap.require(\"sap.ui.core.library\"),jQuery.sap.declare(\"my.ui.lib.library\"),sap.ui.getCore().initLibrary({name:\"my.ui.lib\",version:\"0.0.0\",dependencies:[\"sap.ui.core\"]});", + "my/ui/lib/myJS.js": "/* © */\n\"use strict\";function myFunction(n,o){return n+o}/**\n* This is a copyright comment\n*/\n/* (c) */\n/* released under */\n/* license */\nconsole.log(\"myJS\");", + "my/ui/lib/my.view.xml": "XML\n", + "my/ui/lib/myHtmlPre.view.xml": "XML\n\n ", + "my/ui/lib/foo.properties": "FOO=BAR\n" +}, "my/ui/lib/library-preload"); \ No newline at end of file diff --git a/test/preload_test.js b/test/preload_test.js index d3da0eb7..272c5704 100644 --- a/test/preload_test.js +++ b/test/preload_test.js @@ -45,6 +45,14 @@ describe('openui5_preload', function() { }); }); + it('compat_154', function() { + fileContent.equal({ + sActualFileSource: 'tmp/preload/library_compat_154/my/ui/lib/library-preload.js', + sExpectedFileSource: 'test/preload/expected/library_compat_154/my/ui/lib/library-preload.js', + sMessage: 'library preload JS should be correctly created.' + }); + }); + it('resource_prefix', function() { fileContent.equal({ sActualFileSource: 'tmp/preload/library_resource_prefix/library-preload.js', @@ -89,6 +97,22 @@ describe('openui5_preload', function() { }); }); + it('compat_140', function() { + fileContent.equal({ + sActualFileSource: 'tmp/preload/component_compat_140/my/app/Component-preload.js', + sExpectedFileSource: 'test/preload/expected/component_compat_140/my/app/Component-preload.js', + sMessage: 'component preload JS should be correctly created.' + }); + }); + + it('compat_154', function() { + fileContent.equal({ + sActualFileSource: 'tmp/preload/component_compat_154/my/app/Component-preload.js', + sExpectedFileSource: 'test/preload/expected/component_compat_154/my/app/Component-preload.js', + sMessage: 'component preload JS should be correctly created.' + }); + }); + it('resource_prefix', function() { fileContent.equal({ sActualFileSource: 'tmp/preload/component_resource_prefix/Component-preload.js',