My team and I have an AngularJS app that does not use RequireJS but is loaded within the context of an existing site which uses RequireJS. During the build process I am minifying/concatenating all our scripts into a single JS file which includes certain vendor libs like Lodash, Moment, etc.
Running the site isolated from the parent is fine, but within the context of the parent application I get the well-documented error:
Uncaught Error: Mismatched anonymous define() module: function () { return _; }
I don't have control of the parent application, is there a way at runtime to "disable" RequireJS or configure it to ignore my scripts?
The current solution we have is to modify the vendor libs and remove the AMD code, but this is undesired because we use Bower (with grunt-bower-install) and would like to just update dependencies automatically rather than rely on manual processes and custom hacks.
An approach that could be considered if you are confident you have all the relevant script dependencies under control is to hide the define
function at the start of your minified/concatenated scripts.
For example, do something like the following at the start of the minified scripts:
var __origDefine = define;
define = null;
And at the end of the minified scripts:
define = __origDefine;