Fix bcrypt issues for browserify

This commit is contained in:
Raymond Feng 2014-12-08 14:59:21 -08:00
parent bb2632a5fc
commit cb2f40bb86
3 changed files with 9 additions and 3 deletions

View File

@ -70,7 +70,7 @@ module.exports = function(grunt) {
'dist/loopback.js': ['index.js'],
},
options: {
ignore: ['nodemailer', 'passport'],
ignore: ['nodemailer', 'passport', 'bcrypt'],
standalone: 'loopback'
}
}
@ -174,7 +174,8 @@ module.exports = function(grunt) {
'passport',
'passport-local',
'superagent',
'supertest'
'supertest',
'bcrypt'
],
// transform: ['coffeeify'],
// debug: true,

View File

@ -11,6 +11,10 @@ var bcrypt;
try {
// Try the native module first
bcrypt = require('bcrypt');
// Browserify returns an empty object
if (bcrypt && typeof bcrypt.compare !== 'function') {
bcrypt = require('bcryptjs');
}
} catch (err) {
// Fall back to pure JS impl
bcrypt = require('bcryptjs');

View File

@ -94,7 +94,8 @@
"express": "./lib/browser-express.js",
"./lib/server-app.js": "./lib/browser-express.js",
"connect": false,
"nodemailer": false
"nodemailer": false,
"bcrypt": false
},
"license": {
"name": "Dual MIT/StrongLoop",