Tuesday, 15 July 2014

backbone.js - How to load backbone-deep-model with RequireJS? -



backbone.js - How to load backbone-deep-model with RequireJS? -

while backbone-deep-model has amd back upwards utilize requirejs, depends on underscore mixin in external file called underscore.mixin.deepextend.js not amd compatible.

looking @ question: how mixin underscore plugins in requirejs?, seems can manually mixin deepextend underscore within shim init setting in requirejs.

... shim: { ... 'deep-model': { deps: 'underscore', init: function() { _.mixin(/* hash of deepextend functions */); homecoming _; } } } ...

however, stuck @ @ point since underscore.mixin.deepextend not homecoming hash of functions _.mixin() requires.

is there way load backbone-deep-model requirejs without modifying source code?

this may not reply you're looking for, 1 alternative i'd advise leave underscore (and mix-ins, , backbone , jquery) out of require entirely. main advantage of approach (beyond making problem go away side effect) don't have start every require module importing same library (or libraries if same backbone/jquery).

true, "pollutes" global space, in sentiment having _ (or $ or backbone) variable in global namespace won't wound anything. solve problem, avoid need shim @ all, , save lot of importing. , of course of study can (and should) still utilize require own code, keeping variables "polluting" global namespace save future headaches.

just thought.

backbone.js requirejs underscore.js

No comments:

Post a Comment