I\'m trying to use Browerifiy in the browser, if I use the standalone option it exposes one module. I don\'t want to do this. The website and documentation just seems to cut
I got this working my own way without obfuscating the project too much with dependancies.
In grunt I have
browserify: {
standalone: {
src: [ '<%= yeoman.server %>/shared-components/exposed-modules.js' ],
dest: '<%= yeoman.client %>/app/js/browserifed-shared-code.js',
options: {
browserifyOptions: {
standalone: 'Shared'
}
}
},
}
//In-completed example.
watch: {
scripts: {
files: ['<%= yeoman.server %>/shared-components/**/*.js'],
tasks: ['browserify'],
options: {
spawn: false
}
},
Then I exposed the modules I want using:
'use strict';
//This is the main entry point for all shared libraries.
var Utility = require('./utility');
var UrlController = require('./url-controller');
var Shared = function(){};
//Added new client modules to be exposed here.
Shared.Utility = Utility;
Shared.UrlController = UrlController;
module.exports = Shared;
In the browser I can now call
shared.Utility.isAscii('test'); //Working.
And anywhere I wanna reuse I just assign in the scope, so
//Some scope.
var Utility = shared.Utility;