Updated Answer
Alexander Farkas pointed out in a comment that polyfiller defines itself as "polyfiller"
like this:
define('polyfiller', ['jquery'], factory);
So:
No shim should be required to load polyfiller.js.
The module defined by
polyfiller.js
should always be referred to as"polyfiller"
. So there has to be apaths
setting that maps the module namepolyfiller
to the actual path of thepolyfiller.js
file.
So the original config should be modified to remove the "webshims"
shim, then the paths
setting "webshims": "lib/polyfiller"
should become "polyfiller": "lib/polyfiller"
and the require call should be:
require(["jquery", "lib/underscore", "lib/backbone", "app", "lib/modernizr-custom", "polyfiller"], function($, _, Backbone, Router, modernizr) {
I've dropped the last variable from the function's parameters because there's no need to pass the module value since the polyfiller.js
file registers itself as $.webshims
.
This is similar to how jQuery defines itself as "jquery"
(it needs no shim and is always called "jquery"
).
Original Answer
Change your require
call so that you require "webshims"
instead of "lib/polyfiller"
:
require(["jquery", "lib/underscore", "lib/backbone", "app", "lib/modernizr-custom", "webshims"], ...
The code in your question shows you've set the paths
configuration option so that the module name "webshims"
resolves to "lib/polyfiller"
, and created what looks like a sensible shim for it. However, when you require the webshims
module you refer to it as "lib/polyfiller"
. RequireJS does not do a reverse resolution to figure out that "lib/polyfiller"
is "webshims"
.
Alternatively, you could drop the "webshims"
name from paths
and rename the shim so that it is set for "lib/polyfiller"
. However, I consider it to be a better practice to refer to 3rd party libraries by one-word names throughout an application rather than have paths for them. So "jquery", "bootstrap", "underscore", and "webshims" etc. rather than "lib/...".