From feb95e41c199d5b455272ba5886cdd79d1502cd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20O=C3=9Fwald?= Date: Thu, 28 Feb 2019 16:25:35 +0100 Subject: [PATCH] [FIX] Bundler: Create sap-ui-core-dbg.js (#176) Fixes: #175 --- lib/tasks/bundlers/generateLibraryPreload.js | 107 +++++++++++------- .../preload/resources/sap-ui-core-dbg.js | 3 + .../tasks/bundlers/generateLibraryPreload.js | 2 +- 3 files changed, 71 insertions(+), 41 deletions(-) create mode 100644 test/expected/build/sap.ui.core/preload/resources/sap-ui-core-dbg.js diff --git a/lib/tasks/bundlers/generateLibraryPreload.js b/lib/tasks/bundlers/generateLibraryPreload.js index 5bce9165d..438c8617b 100644 --- a/lib/tasks/bundlers/generateLibraryPreload.js +++ b/lib/tasks/bundlers/generateLibraryPreload.js @@ -108,47 +108,74 @@ module.exports = function({workspace, dependencies, options}) { filters = ["jquery.sap.global.js"]; } - p = moduleBundler({ - options: { - bundleOptions: { - optimize: true, - decorateBootstrapModule: true, - addTryCatchRestartWrapper: true, - usePredefineCalls: true + p = Promise.all([ + moduleBundler({ + options: { + bundleOptions: { + optimize: true, + decorateBootstrapModule: true, + addTryCatchRestartWrapper: true, + usePredefineCalls: true + }, + bundleDefinition: { + name: "sap-ui-core.js", + sections: [ + { + // include all 'raw' modules that are needed for the UI5 loader + mode: "raw", + filters, + resolve: true, // dependencies for raw modules are taken from shims in .library files + sort: true, // topological sort on raw modules is mandatory + declareModules: false + }, + { + mode: "preload", + filters: [ + "sap/ui/core/Core.js" + ], + resolve: true + }, + { + mode: "require", + filters: [ + "sap/ui/core/Core.js" + ] + } + ] + } }, - bundleDefinition: { - name: "sap-ui-core.js", - sections: [ - { - // include all 'raw' modules that are needed for the UI5 loader - mode: "raw", - filters, - resolve: true, // dependencies for raw modules are taken from shims in .library files - sort: true, // topological sort on raw modules is mandatory - declareModules: false - }, - { - mode: "preload", - filters: [ - "sap/ui/core/Core.js" - ], - resolve: true - }, - { - mode: "require", - filters: [ - "sap/ui/core/Core.js" - ] - } - ] - } - }, - resources - }).then(([bundle]) => { - if (bundle) { - // console.log("sap-ui-core.js bundle created"); - return workspace.write(bundle); - } + resources + }), + moduleBundler({ + options: { + bundleOptions: { + optimize: false + }, + bundleDefinition: { + name: "sap-ui-core-dbg.js", + sections: [ + { + // include all 'raw' modules that are needed for the UI5 loader + mode: "raw", + filters, + resolve: true, // dependencies for raw modules are taken from shims in .library files + sort: true, // topological sort on raw modules is mandatory + declareModules: false + }, + { + mode: "require", + filters: [ + "sap/ui/core/Core.js" + ] + } + ] + } + }, + resources + }) + ]).then((results) => { + const bundles = Array.prototype.concat.apply([], results); + return Promise.all(bundles.map((bundle) => workspace.write(bundle))); }); } else { p = Promise.resolve(); diff --git a/test/expected/build/sap.ui.core/preload/resources/sap-ui-core-dbg.js b/test/expected/build/sap.ui.core/preload/resources/sap-ui-core-dbg.js new file mode 100644 index 000000000..827fe1cab --- /dev/null +++ b/test/expected/build/sap.ui.core/preload/resources/sap-ui-core-dbg.js @@ -0,0 +1,3 @@ +sap.ui.requireSync("sap/ui/core/Core"); +// as this module contains the Core, we ensure that the Core has been booted +sap.ui.getCore().boot && sap.ui.getCore().boot(); diff --git a/test/lib/tasks/bundlers/generateLibraryPreload.js b/test/lib/tasks/bundlers/generateLibraryPreload.js index 1d4eb86be..5f10168df 100644 --- a/test/lib/tasks/bundlers/generateLibraryPreload.js +++ b/test/lib/tasks/bundlers/generateLibraryPreload.js @@ -95,7 +95,7 @@ test("integration: build sap.ui.core with library preload", async (t) => { assert.directoryDeepEqual(destPath, expectedPath); // Check for all file contents - t.deepEqual(expectedFiles.length, 6, "6 files are expected"); + t.deepEqual(expectedFiles.length, 7, "7 files are expected"); expectedFiles.forEach((expectedFile) => { const relativeFile = path.relative(expectedPath, expectedFile); const destFile = path.join(destPath, relativeFile);