Creating a loading sequence of an application
Do you think there is a nicer way how to express this without any external dependency?


Use Babel preset to only include browsers from the last two years. In that case, the promise polyfill is not needed. For example

{
  "presets": [
    ["env", {
      "targets": {
        "browsers": ["since 2016"]
      }
    }]
  ]
}



  Additionally, I would like to DRY up the lines with require.ensure. I am not entirely sure how this works, but is there some way how to specify name of loaded file dynamically, perhaps using context?


Use a wrapper function to pass the strings as arguments:

return setupRenderer((resolve) =&gt; { ensurance('./infosite', 'infosite')});


And define the function before the call:

function ensurance(path, name){
  require.ensure([path], (require) =&gt; resolve(require(path)), name);
}


References


Babel: env preset
caniuse: promises