backbone.js - Backbone app with CommonJS and Browserify -


i thinking of bringing existing app on using commonjs modules , using browserify bundle modules 1 file.

i'm getting head around writing modules 1 thing i'm little sceptical before dive in , start re-writing bits, how can optimise don't have include backbone, underscore, jquery , helper files in in each file, ie.

var backbone = require('/backbone'); var $ = require('/jquery'); var _ = require('/underscore'); 

at top of each file going little tedious after while.

being complete commonjs, browserify n00b, i'm wondering if i'm missing obvious somewhere?

the "very obvious thing" you're missing can create globals in node.js, , in browserify environment same. either explicitly using global.backbone = require('/backbone'), or less explicit doing backbone = require('/backbone') (without var in front).

note in browser, global object in fact window object. however, attaching window object mean lose compatibility node.js, because typically doesn't have global variable window defined.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -