diff --git a/lib/browser.js b/lib/browser.js new file mode 100644 index 00000000..39ea1354 --- /dev/null +++ b/lib/browser.js @@ -0,0 +1,11 @@ +// Including compiler for CommonJS browser environments. +// this replaces server.js via the "browser" attribute on package.json +// for bundling environments like browserify +module.exports = function (dust) { + var parser = require('./parser'), + compiler = require('./compiler')(dust); + + compiler.parse = parser.parse; + dust.compile = compiler.compile; + dust.optimizers = compiler.optimizers; +}; diff --git a/package.json b/package.json index 2e8ecda2..688f84fe 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,9 @@ "uglify-js" : "1.3.3", "pegjs" : "0.7.0" }, + "browser": { + "./lib/server.js": "./lib/browser.js" + }, "license": "MIT", "engine": { "node": ">=0.5"