diff --git a/README.md b/README.md index 6f8a271e..d65b4baf 100644 --- a/README.md +++ b/README.md @@ -137,21 +137,6 @@ var fetchr = require('fetchr'), //... ``` - -## 5. Swap Fetchr <=> Fetchr.client - -Fetchr relies on a build process that swaps out `lib/fetchr.js` with `lib/fetchr.client.js` in the bundle that is generated for client side use. Usually the bundle is generated using tools like [webpack](http://webpack.github.io/) or [browserify](http://browserify.org/). - -``` -//webpack config -plugins: [ - //... - //Replace fetcher lib with client side fetcher lib - new webpack.NormalModuleReplacementPlugin(/^fetchr$/, require.resolve('fetchr/libs/fetcher.client.js')) - //... -] -``` - # Usage Examples See the [simple example](https://github.com/yahoo/fetchr/tree/master/examples/simple) diff --git a/examples/simple/webpack.config.js b/examples/simple/webpack.config.js index a1eb3eaf..129686a0 100644 --- a/examples/simple/webpack.config.js +++ b/examples/simple/webpack.config.js @@ -2,16 +2,10 @@ * Copyright 2014, Yahoo! Inc. * Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. */ -var webpack = require('webpack'), - path = require('path'); module.exports = { entry: require.resolve('./client/app.js'), output: { path: __dirname+'/client/build/', filename: "app.js" - }, - plugins: [ - //Replace fetcher lib with client side fetcher lib - new webpack.NormalModuleReplacementPlugin(/^..\/..\/..\/libs\/fetcher.js$/, path.resolve('../../libs/fetcher.client.js')) - ] + } }; diff --git a/libs/fetcher.js b/libs/fetcher.js index 5533c5e5..fa83f515 100644 --- a/libs/fetcher.js +++ b/libs/fetcher.js @@ -94,7 +94,7 @@ module.exports = function createFetcherClass (options) { config: {}, callback: function (err, data) { if (err) { - res.send('400', 'request failed'); + res.status('400').send('request failed'); } res.json(data); } diff --git a/package.json b/package.json index 9ff9475f..af6f0090 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,9 @@ "mockery": "^1.4.0", "precommit-hook": "^1.0.2" }, + "browser": { + "./libs/fetcher.js": "./libs/fetcher.client.js" + }, "jshintConfig": { "node": true },