I am currently experimenting with the Hot Towel SPA Template, which defines these two libraries for Durandal if I understand this correctly. I cannot figure out the exact difference between these two calls, though:
// Durandal 2.x assumes no global libraries. It will ship expecting
// Knockout and jQuery to be defined with requirejs. .NET
// templates by default will set them up as standard script
// libs and then register them with require as follows:
define('jquery', function () { return jQuery; });
define('knockout', ko);
Would define('knockout', function () => { return ko; });?
do the same?
In the case of the former, we're defining a module whose name is 'jquery' and that is defined in a global namespace.
In the case of the latter, we're defining a module the reference to which is defined in a require path.
The effect is the same for both cases. John Papa, the creator of Hot Towel, recommends not defining third-party modules using require. Instead, only one's own modules should be defined this way. Of course, jQuery and Knockout are exceptions in the Durandal framework because they are a part of the Durandal framework.
But the reason John gives that advice is due to all of the technical ins and outs of how third-party frameworks are designed. Sometimes you have to shim, sometimes not. Sometimes you have to return something defined on the window, sometimes not. Sometimes there are order dependencies, or auxiliary library dependencies (which, in turn, have their own idiosyncrasies).