How do you use shims to map global thirdparty project to scoped object

Solution 1:

You can use the sap.ui.loader API to influence this. Somewhere before you import this module, like in Component.js do:

sap.ui.loader.config({
   shim: {
     "path/to/module/myLodash": {
        exports: "_"
      }
   }
});

Then you can import it like:

sap.ui.define(["path/to/module/myLodash"], function (myLodash) {
   "use strict";
    myLodash.chunk(...)
    ...
});

Make sure that path/to/module/myLodash leads to where your lodash module is located.

Update

In this blog it is explained how to consume modules directly from node_modules, which in my opinion is the better option.