Any code that causes a parse error will need to be in a different file to your config and boot.
You could put the browser check in the config file and make it add different paths if it is IE.
There is also the IE conditional html comments which can be used to load different files.
This is how I use requirejs to load my shims and polyfills only if they are required by the browser.
//main
require.config({
paths: {
"JSON": "shims/json2",
"Array": "shims/array",
"input.placeholder": "shims/placeholders.min"
},
shim: {
"JSON": {
exports: "JSON"
}
}
});
if (typeof JSON === 'object') {
define('JSON', [], JSON);
} else {
//load shim for JSON now
require(['JSON']);
}
if (Array.prototype.forEach) {
//if forEach exists assume all new array functions exist
define('Array', [], function () { return Array; });
}
if ('placeholder' in document.createElement('input')) {
define('input.placeholder');
}
The shim/polyfill file then either includes a define or it is in require.config.shim like JSON.
//shims/array.js
//Add new array functions to prototype.
if(typeof define==='function'&&define.amd){define('Array',[],function(){return Array});}
Then if I need that feature I include the dependency.
require(['src/app','JSON','Array','input.placeholder'], function (app, JSON) {
//can now use [].forEach() without checking if it exists
});