The Wikidata Query UI is currently built using a rather dated pipeline of Grunt tasks, including now-unmaintained ones like grunt-usemin. (See T274626: wikidata-query-gui build tooling uses outdated packages (via grunt) for some details.) We should port it to some modern build system, such as Webpack or (more likely, in light of recent tasks like T276366) Rollup.
To keep the scope of this task down, we should try to do this with as little changes to the code as possible. In other words, this is not the task for abandoning jQuery, using async/await, or other sweeping modernizations. Let’s start with the build system only.
It would be nice if one result of this was a version of the code that we can publish to npm with little extra effort (basically, include lib-level code in wikibase/queryService/, while excluding application-level code like wikibase/init.js); however, since the current build system has nothing like this either (compare T267836), I don’t think this should be a hard requirement.