I’m modifying the Cesium(1.84) source code and customizing some features, and for this I need to reference some third-party libraries, but they are built in UMD format, and I want to know how to reference them correctly.
I have tried loading an external script using the “loadAndExecuteScript” method, but this method is based on “Promise” and dealing with asynchronous mechanisms makes things tricky. Maybe I am using it the wrong way?
Anyway, if you have any solutions or good ideas, thank you very much!
Are you using any build tools, or the build process in CesiumJS itself?
There should be no need to call loadAndExecuteScript directly. If you are modifying the Cesium source code, which is ESM, you should be able to load UMD modules with import:
I built it using Cesium itself, and I did load it successfully using loadAndExecuteScript. However, the loading operation is asynchronous, and all operations must be completed in then(). I have used third-party libraries many times in the source code, which makes the code look messy.
It seems that using import cannot avoid this problem. Is there any other way?