Sunday, 15 March 2015

knockout.js - Use Browserify + Knockout + Knockout projections -



knockout.js - Use Browserify + Knockout + Knockout projections -

i trying include both knockout , knockout-projections in project browserify. using browserify-shim bind together.

unfortunately knockout-projections code fails when requires knockout, either compile-time error or runtime error – depending on setup of shim.

to illustrate problem have set github repository: brianmhunt/bshim-ko-testcase.

@brianmhunt, still not issue browserify.

your latest alter on repo installs both knockout , knockout-projections via bower. fine.

however, each bower component has package.json. not issue either, package.json file in knockout-projections specifies knockout dependancy well.

between "browser" setting have in own package.json , knockout-projections calling "require('knockout')" in code, it's kinda of catch-22 in scenario.

a couple of workarounds:

delete package.json file in knockout-projections directory run "npm install" in knockout-projections directory (see gotchas below)

alternative: (install via npm):

{ "name": "bshim-ko-test", "version": "0.0.3", "repository": "https://github.com/brianmhunt/bshim-ko-testcase", "browser": { "koproj": "knockout-projections" }, "main": "./test.js", "dependencies" : { "knockout" : "~3.0.0", "knockout-projections" : "stevesanderson/knockout-projections" } }

now steps be:

git clone <repository> npm install browserify -g cd <repository>, , "npm install" browserify test.js -o bundle.js

gotchas:

be careful doing either sec workaround above, or alternate. if knockout versions don't match, both copies of knockout in bundle.js. definately, not expecting. the package.json files in knockout , ko projections pointing debug files (not minified) create bundle.js quite large.

knockout.js browserify commonjs browserify-shim knockout-projections

No comments:

Post a Comment