RequireJS alias issues

Getting mighty fighting tired to make JS work in a predictable way. Its debugging support is not impressive.

My config.js file looks like this:

require.config({

baseUrl: "Scripts",

paths: {
    "jquery": "jquery-2.1.1.min",
    "bootstrap": "bootstrap.min",
    "knockout": "knockout-3.1.0"
},
shim: {
    "bootstrap": {
        deps: ["jquery"],
        exports: "$.fn.popover"
    }
},
enforceDefine: true
});
require(["jquery", "bootstrap"], function ($, bootstrap) {
    console.log("(A) loaded jq + bs");
    if ($)
        console.log("$ is present");
    if (bootstrap)
        console.log("bootstrap is present");
});
//# sourceMappingURL=Config.js.map

      

JavaScript in the / Scripts folder where Config.js is located. "jquery" should be a specific version alias, but when the browser loads it, it tries to load/Scripts/jquery.js

The alias file /Scripts/jquery-2.1.1.min.js

exists.

The same happens with bootstrap - it loads boostrap.js

instead ofbootstrap.min.js

I hate the way requireJS has this secret way of mixing different behaviors in the same path parameter that changes based on the content of the string.

+3


source to share


1 answer


This link may help you .. config file is loaded asynchronously and not executed on first call to require ()



Check out this Require JS to ignore my config

+2


source







All Articles