javascript - How can I use npm for front-end dependencies? -


i want ask if possible (and idea) use npm handle front-end dependencies (backbone, jquery).

i have found backbone, jquery , on available through npm have set extraction point (the default node_modules) or symlink or else...

has done before?

is possible?

what have change in package.json?

short answer: sort of.

it largely module author support this, isn't common. socket.io example of such supporting module, demonstrated on landing page. there other solutions however. these 2 know about:

  • http://ender.no.de/ - ender js, self-described npm analogue client modules. bit involved tastes.
  • https://github.com/substack/node-browserify - browserify, utility walk dependencies , allow output single script emulating node.js module pattern. can use jake|cake|rake|make build script spit out application.js, , automate if want fancy. used briefly, decided bit clunky, , became annoying debug. also, not dual-environment npm modules run through browserify.

personally, opting using requirejs ( http://requirejs.org/ ) , manually managing modules, similar how mozilla browserquest sample application ( https://github.com/mozilla/browserquest ). note comes challenge of having potentially shim modules backbone or underscore removed support amd style module loaders. can find example of involved in shimming here: http://tbranyen.com/post/amdrequirejs-shim-plugin-for-loading-incompatible-javascript

really seems going hurt no matter what, why native module support such hot topic.


Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -