Issues with Assets location when using requirejs on combined build cesium.js file

I am trying to use cesium within an application that also relies on requirejs.

Folder structure

/libs/cesium/1.12.0/Cesium.js

/src/scripts/packages/cesium-czml-viewer/1.0.0-pre/lenses/CesiumCzmlLensFactory.ts

/src/scripts/main.ts

I have a cesium shim

“Cesium”:{

exports:“Cesium”,

deps:[

“css!/libs/cesium/1.12.0/Widgets/widgets.css”

]

}

generated CesiumCzmlLensFactory.js has

define([“require”, “exports”, … “Cesium”, “template!../templates/CesiumLensTemplate.html”], function (require, exports, AscendClient, AscendUser, Cesium) {

CesiumCzmlLens.prototype.startCesium = function(){

var viewer = new Cesium.Viewer(…);

};

function CesiumCzmlLensFactory(blade) {

return new CesiumCzmlLens(blade);

}

return CesiumCzmlLensFactory;

}

cesium.js is loaded fine. but as soon as startCesium is triggered, then it tries to load all the assets relative to the modules path so getting not founds on /src/scripts/packages/cesium-czml-viewer/1.0.0-pre/lenses/Assets/… where all the assets is at the /lib/cesium/1.12.0/Assets/…

But if I in the application uses the console before the above module CesiumCzmlLensFactory is loaded and type require([“Cesium”], function(cesium){}); and then open the module everything works.

So concluding that Cesium is using the relative paths from where cesium module first is loaded which is not the normal behavior in requirjs/amd loaders. So could this be an error in the amd loader stuff injected into the builded/combined cesium.js file?

Are there a way to get around this? I do not want to use the source files.

I can see that the restrictions on https://github.com/jrburke/almond list not to use require.toUrl, but thats been done a few times in cesium which properly is the reason for above issues.
https://github.com/AnalyticalGraphicsInc/cesium/search?utf8=✓&q=toUrl

Scott can hopefully chime in here since he knows more than I do about this area, but try setting the CESIUM_BASE_URL global variable before anything else, which will force Cesium to load things relative to that path. In this case I think you want to set it to " /lib/cesium/1.12.0".