Exclude express-middleware from browser bundle

Fix lib/loopback to include express-middleware only on the server.

Bump up strong-remoting dependency to use the version working in
browsers.
This commit is contained in:
Miroslav Bajtoš 2014-06-03 10:15:15 +02:00
parent 663e2d1903
commit 88a4bb462e
3 changed files with 20 additions and 14 deletions

View File

@ -1,7 +1,7 @@
var express = require('express'); var express = require('express');
var path = require('path'); var path = require('path');
var middlewares = express.middlewares = {}; var middlewares = exports;
function safeRequire(m) { function safeRequire(m) {
try { try {
@ -50,7 +50,3 @@ middlewares.favicon = function (icon, options) {
icon = icon || path.join(__dirname, '../favicon.ico'); icon = icon || path.join(__dirname, '../favicon.ico');
return favicon(icon, options); return favicon(icon, options);
}; };
module.exports = express;

View File

@ -2,7 +2,7 @@
* Module dependencies. * Module dependencies.
*/ */
var express = require('./express-middleware') var express = require('express')
, fs = require('fs') , fs = require('fs')
, ejs = require('ejs') , ejs = require('ejs')
, path = require('path') , path = require('path')
@ -89,8 +89,7 @@ function createApplication() {
} }
/*! /*!
* Expose express.middleware as loopback.* * Expose static express methods like `express.errorHandler`.
* for example `loopback.errorHandler` etc.
*/ */
for (var key in express) { for (var key in express) {
@ -100,11 +99,22 @@ for (var key in express) {
, Object.getOwnPropertyDescriptor(express, key)); , Object.getOwnPropertyDescriptor(express, key));
} }
for (var key in express.middlewares) { /*!
Object.defineProperty( * Expose additional middleware like session as loopback.*
loopback * This will keep the loopback API compatible with express 3.x
, key *
, Object.getOwnPropertyDescriptor(express.middlewares, key)); * ***only in node***
*/
if (loopback.isServer) {
var middlewares = require('./express-middleware');
for (var key in middlewares) {
Object.defineProperty(
loopback
, key
, Object.getOwnPropertyDescriptor(middlewares, key));
}
} }
/*! /*!

View File

@ -34,7 +34,7 @@
"debug": "~0.8.1", "debug": "~0.8.1",
"express": "4.x", "express": "4.x",
"body-parser": "~1.2.2", "body-parser": "~1.2.2",
"strong-remoting": "2.0.0-beta2", "strong-remoting": "2.0.0-beta3",
"inflection": "~1.3.5", "inflection": "~1.3.5",
"passport": "~0.2.0", "passport": "~0.2.0",
"passport-local": "~1.0.0", "passport-local": "~1.0.0",