@@ -30,6 +30,7 @@ var TMPFILE = join( tmpdir(), '.__browserify-string-tmp-file_' );
3030* @param {string } str - input string
3131* @param {string } [dest] - output file path
3232* @param {Options } [options] - browserify options
33+ * @param {string } [options.standalone] - standalone browserify bundle export name
3334* @param {string } [options.exportName] - bundle target name
3435* @param {Array } [options.transforms] - transforms to apply when bundling
3536* @param {Array } [options.plugins] - plugins to apply when bundling
@@ -87,6 +88,9 @@ function bundle( str, dest, options, clbk ) {
8788 opts = dest ;
8889 cb = options ;
8990 }
91+ if ( hasOwnProp ( opts , 'standalone' ) && ! isString ( opts . standalone ) ) {
92+ throw new TypeError ( 'invalid option. `standalone` option must be a string. Option: `' + opts . standalone + '`.' ) ;
93+ }
9094 if ( hasOwnProp ( opts , 'exportName' ) && ! isString ( opts . exportName ) ) {
9195 throw new TypeError ( 'invalid option. `exportName` option must be a string. Option: `' + opts . exportName + '`.' ) ;
9296 }
@@ -122,7 +126,9 @@ function bundle( str, dest, options, clbk ) {
122126 debug ( 'Encountered an error when creating a temporary file: %s' , error . message ) ;
123127 return done ( error ) ;
124128 }
125- if ( opts . exportName ) {
129+ if ( opts . standalone ) {
130+ b = browserify ( tmpfile , opts ) ;
131+ } else if ( opts . exportName ) {
126132 b = browserify ( opts ) ;
127133 b . require ( tmpfile , {
128134 'expose' : opts . exportName
0 commit comments