Created
March 31, 2016 16:21
-
-
Save shawninder/24ff053c202aa50379007ab2603ca453 to your computer and use it in GitHub Desktop.
Example of streaming data to browserify instead of passing it the path to a file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
var Stream = require('stream') | |
var browserify = require('browserify') | |
var st = new Stream.Readable() | |
var js = '// A string of javascript with requires' | |
st.push(js, 'utf8') | |
st.push(null) | |
var b = browserify(st).bundle() | |
b.on('error', console.error) | |
var total = '' | |
b.on('data', (chunk) => { | |
total += chunk.toString() | |
}) | |
b.on('end', () => { | |
console.log('After browserify: ', total) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment