Requirejs' order does not work with priority config and CDN dependencies

后端 未结 1 1772
礼貌的吻别
礼貌的吻别 2021-01-03 13:42

The following main.js code do not respect the order of priorities (sometimes underscore.js is not loaded when backbone.js needs it):

相关标签:
1条回答
  • 2021-01-03 14:36

    I recently updated the RequireJS docs, but I have not pushed the change to the site yet:

    The "priority" configuration cannot load resources loaded by plugins. So to accomplish what you are trying to do, you can just nest require() calls, which will give you the behavior you want:

    require(
        {
            baseUrl:'/scripts'
        },
        [
            "require",
            "order!http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js",
            "order!http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/jquery-ui.min.js",
            "order!http://ajax.cdnjs.com/ajax/libs/underscore.js/1.1.6/underscore-min.js",
            "order!http://ajax.cdnjs.com/ajax/libs/backbone.js/0.3.3/backbone-min.js"
    
        ], 
        function (require) {
            require(["src/app"], function (app) {
                app.start();
            });
        }
    );
    

    This assumes you have the order plugin in the /scripts/order.js location.

    0 讨论(0)
提交回复
热议问题