Reputation: 29186
I'm using RequireJS 2.1.6.
Here's the main.js file:
requirejs.config({
paths: {
baseUrl: "/Scripts",
products: "Products/products",
jquery: "jquery-2.0.2.min",
modernizr: "modernizr-2.6.2"
},
shim: {
jquery: {
exports: "$"
},
modernizr: {
exports: "modernizr"
}
}
});
Here is the Products.js file declaration:
define(["modernizr"], function (modernizr) {
// Rest of code.
});
The problem is that modernizr
is undefined
when I execute the code in Products.js
. If I remove the parameter modernizr
and instead use the Modernizr
variable instead (which is naturally exposed by Modernizer.js globally), then the code works fine. However, this is not my ideal setup.
I've double-checked the spelling, and the config, but I cannot understand why this is the case. I assume I've missed a fundamental point here, so I'm hoping someone can explain where I've gone wrong.
Upvotes: 0
Views: 129
Reputation:
Try this:
requirejs.config({
paths: {
baseUrl: "/Scripts",
products: "Products/products",
jquery: "jquery-2.0.2.min",
modernizr: "modernizr-2.6.2"
},
shim: {
jquery: {
exports: "$"
},
modernizr: {
exports: "Modernizr"
}
}
});
Modernizr exposes Modernizr
and not modernizr
.
Upvotes: 1