requirejs / almond

A minimal AMD API implementation for use after optimized builds
Other
2.42k stars 169 forks source link

require.config(...) is being executed too late #126

Open sscheidegger opened 3 years ago

sscheidegger commented 3 years ago

I am using an app (readium-js-viewer) which uses almond.js to load all modules. In index.html I am including the minified readium-js-viewer bundle, which includes almond.js:

<script type="text/javascript" src="scripts/readium-js-viewer_all_LITE.js"> </script>

Afterwards I am calling require.config() to provide some basic configuration to readium modules:

require.config({
    waitSeconds: 0,   
    config : {
        'readium_js_viewer/ModuleConfig' : {
                ...

However, every other time the app is not starting properly because the configuration is missing. It seems require.config() is sometimes being called too late, when the app already tries to access the config.

Using require.js, I could define var require = {waitSeconds: 0, config : ...} before loading require.js. However, this is not possible with almond.js.

Using almond.js, how am I supposed to make sure the config is being loaded before the app is trying to access it?