Permalink
Browse files

Made possible a proper browser build

  • Loading branch information...
1 parent 3ec7391 commit 705ec36ea7a98d2b74a21e7765a13b9f1925dc07 @christkv christkv committed Feb 18, 2013
Showing with 23 additions and 4 deletions.
  1. +1 −1 Makefile
  2. +4 −2 browser_build/bson.js
  3. +8 −0 browser_build/package.json
  4. +7 −0 build_browser.js
  5. +3 −1 lib/bson/binary.js
View
@@ -14,6 +14,6 @@ clean:
node-gyp clean
browserify:
- node_modules/.bin/onejs build package.json browser_build/bson.js
+ node_modules/.bin/onejs build browser_build/package.json browser_build/bson.js
.PHONY: all
@@ -165,7 +165,7 @@ bson.pkg(function(parents){
return {
'name' : 'bson',
- 'mainModuleId' : 'index',
+ 'mainModuleId' : 'bson',
'modules' : [],
'parents' : parents
};
@@ -174,7 +174,9 @@ bson.pkg(function(parents){
/**
* Module dependencies.
*/
-var Buffer = require('buffer').Buffer; // TODO just use global Buffer
+if(typeof window === 'undefined') {
+ var Buffer = require('buffer').Buffer; // TODO just use global Buffer
+}
// Binary default subtype
var BSON_BINARY_SUBTYPE_DEFAULT = 0;
@@ -0,0 +1,8 @@
+{ "name" : "bson"
+, "description" : "A bson parser for node.js and the browser"
+, "main": "../lib/bson/bson"
+, "directories" : { "lib" : "../lib/bson" }
+, "engines" : { "node" : ">=0.6.0" }
+, "licenses" : [ { "type" : "Apache License, Version 2.0"
+ , "url" : "http://www.apache.org/licenses/LICENSE-2.0" } ]
+}
View
@@ -0,0 +1,7 @@
+require('one');
+
+one('./package.json')
+ .tie('bson', BSON)
+ // .exclude('buffer')
+ .tie('buffer', {})
+ .save('./browser_build/bson.js')
View
@@ -1,7 +1,9 @@
/**
* Module dependencies.
*/
-var Buffer = require('buffer').Buffer; // TODO just use global Buffer
+if(typeof window === 'undefined') {
+ var Buffer = require('buffer').Buffer; // TODO just use global Buffer
+}
// Binary default subtype
var BSON_BINARY_SUBTYPE_DEFAULT = 0;

0 comments on commit 705ec36

Please sign in to comment.