Loading JSON using Text module stops Persistence Toolkit working

If you add JSON resources to your app, as shown in these code snippets, the Oracle Offline Persistence Toolkit stops working.

// Add resource
define([
  'text!resources2/js/test.json'
], function(

// Where resources2 is defined as:
  "requirejs": {
        "paths": {
            "resources2": "{{ location.pathname + (window.vbInitConfig.BASE_URL_TOKEN ? 
                          window.vbInitConfig.BASE_URL_TOKEN + '/' : '') + 'resources'}}"
        }
    },

The following error occurs when the app tries to load the Oracle Offline Persistence Toolkit.

Failed to load offline handler from /ic/builder/rt/otf/2.0/webApps/foo/
version_279023731935549663/app-flow.js: Error: importScripts failed for /ic/builder/rt/otf/2.0/
webApps/foo/version_279023731935549663/app-flow.js at /ic/builder/rt/otf/2.0/webApps/foo/versio
n_279023731935549663/app-flow.js
https://requirejs.org/docs/errors.html#importscripts

Two possible workarounds exist to address this issue:

  1. Wrap the JSON file in a JavaScript file and load the JavaScript file.
  2. Use the Fetch API to load the JSON file in the offline handler.