I'm trying to build a mashup using d3 v5 using require.js to load it. This seems to be working fine as long as I try to use it within the scope of my main function in the script. However, when trying to use it within the callback of app.createCube() d3 v3 is used instead. I have checked this by writing d3 to the console log from within the main function and from within the callback.
Yes, the dependencies you define in your require call will be defined inside the function you send in to require, but outside of that function it will not, so you will get the global D3 used by Qlik Sense.
You need to move the function where you use D3 to inside the require callback.