Permalink
Browse files

[dist] Browserify build for frontend

  • Loading branch information...
1 parent f658ae0 commit 8bd3cfbc30ef7bf5a06a00d9eda46f4e40291b71 @pksunkara pksunkara committed Dec 23, 2011
Showing with 22 additions and 9 deletions.
  1. +3 −0 lib/browser.js
  2. +18 −9 lib/resourceful/engines.js
  3. +1 −0 package.json
View
@@ -0,0 +1,3 @@
+window.resourceful = require('./resourceful');
+
+require('./resourceful/engines/memory');
View
@@ -12,14 +12,23 @@ var fs = require('fs'),
var engines = exports;
-//
-// Setup all engines as lazy-loaded getters.
-//
-fs.readdirSync(path.join(__dirname, 'engines')).forEach(function (file) {
- var engine = file.replace('.js', ''),
- name = common.capitalize(engine);
+if (fs.readdirSync) {
+ // Backend - Setup all engines as lazy-loaded getters.
+ fs.readdirSync(path.join(__dirname, 'engines')).forEach(function (file) {
+ var engine = file.replace('.js', ''),
+ name = common.capitalize(engine);
- engines.__defineGetter__(name, function () {
- return require('./engines/' + engine)[name];
+ engines.__defineGetter__(name, function () {
+ return require('./engines/' + engine)[name];
+ });
});
-});
+} else {
+ // Frontend support for engines
+ ['memory'].forEach(function (engine) {
+ var name = common.capitalize(engine);
+
+ engines.__defineGetter__(name, function () {
+ return require(path.resolve(__dirname, './engines/', engine))[name];
+ });
+ });
+}
View
@@ -23,6 +23,7 @@
},
"main": "./lib/resourceful",
"scripts": {
+ "browserify": "browserify lib/browser.js -o build/resourceful.js",
"test": "vows --spec -i"
}
}

0 comments on commit 8bd3cfb

Please sign in to comment.