Openui5: Chrome apps/extensions: full preload build with no XmlHttpRequest to load modules

Created on 10 Jan 2016  路  9Comments  路  Source: SAP/openui5

A fully pre-loaded build with all UI components such that requireModule doesn't dynamically load modules will be useful for Chrome apps/extensions. Due to content security policy in chrome apps, one cannot use XmlHttpRequest to load local JS modules or inline scripts.

enhancement in progress

Most helpful comment

@matz3 I'd also like to build a UI5 app (PWA) with ServiceWorkers API. Would it be feasible soon?

All 9 comments

thanks for this question. Cloud you please be a bit more specific about this? Possibly with a coding example and/or practical use-case? From your description it will be really hard to help you through.
Thanks!

Hi Thilo,

Please see: https://developer.chrome.com/apps/contentSecurityPolicy
Even the simplest helloworld openui5 sample won't work as a Chrome packaged app. First, all application resources are expected to be present within a chrome packaged app. Assuming I do that and then use sap-ui-core-all-dbg.js, then I get the following error when launching a packaged app in Chrome:

Uncaught Error: failed to load 'sap/ui/thirdparty/signals.js' from resources/sap/ui/thirdparty/signals.js: 0 - InvalidAccessError: Failed to execute 'open' on 'XMLHttpRequest': Synchronous requests are disabled for this page.

It appears that sap-ui-core-all.js isn't really a all in one js. Basically, we need a _true_ all-in-one JS with all controls and all modules, so there are no xml http requests made for loading modules/libraries.

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta charset="UTF-8">
    <title>SAPUI5 Walkthrough</title>
    <script
        id="sap-ui-bootstrap"
        src="resources/sap-ui-core-all-dbg.js"
        data-sap-ui-theme="sap_bluecrystal"
        data-sap-ui-libs="sap.m"
        data-sap-ui-compatVersion="edge">
    </script>
    <script src="app-init.js"></script>
</head>
<body class="sapUiBody" id="content">
</body>
</html>
sap.ui.getCore().attachInit(function () {
    new sap.m.Text({
        text: "Hello World"
    }).placeAt("content");
});

Thanks! this one I got. @codeworrior could you please have a look into this?

This is a known limitation to UI5 and our goal is to get rid of all sync requests. But we are not quite there.

Some time ago I wanted to enable offline support using a ServiceWorker which also does not support sync XHRs. Therefore I created some custom grunt build to re-bundle a core.js file that (at least almost) doesn't require sync XHRs (see my comments on the gist).
However this just a proof-of-concept. It might break whenever we are changing internals of the sap-ui-core.js.

Hi,
Is there any chance to fix this issue?
Regards
Krzysiek

@matz3 I'd also like to build a UI5 app (PWA) with ServiceWorkers API. Would it be feasible soon?

IMHO openui5/sapui5 should provide at least a list of files per library which need to be preloaded by a service worker in order to support complete offline operation afterwards.

Is this issue still in queue? 2.5 years of pending. I want progressive web app feature.

It is not only for PWA, but it is also for the user's experience. When navigating a UI5 app you can feel that it is clunky.

Was this page helpful?
0 / 5 - 0 ratings