question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pipe a readable stream into browserify

See original GitHub issue

Is there a way to pipe an already existing stream into a browserify instance? Here is an example of my use case:

fs.createReadStream('./my-entry-script.js')
  .pipe(through2(function () {
    // Some transform that pulls some meta data about the file and possibly
    // preforms modifications on the content 
  }))
  .pipe(browserify())
  .pipe(someOutputStream);

I looked into the pipeline stuff here but did not see an easy way to hook into this. I would be willing to open up a PR to take a stab at this if there is not already something to handle this situation, just wanted to start a discussion before working on it 😃

Also, FWIW, I know there are ways to solve the exact use case above, but this is for integrating browserify into a larger ecosystem of stream based transforms for content management type app I am working on. So I know there are probably ways to solve the exact problem above with a concat stream and buffer, but I would really like to be able to do the duplex stream like above.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
wesleytoddcommented, Mar 9, 2016

@substack I am glad to hear that it is possible. Is my linked solution what you mean? Or is there a less hacky way?

If you can tell me the recommended solution I will try to find a place for it in the docs so anyone else with this question can easily find the answer. Thanks!!

EDIT - link: https://github.com/wesleytodd/rufio-filter-browserify/blob/master/index.js

1reaction
wesleytoddcommented, Mar 3, 2016

I did manage to get a working solution, but I think there are some issues, and it is certainly hacked on top of browserify, so any help would be appreciated. Here is my implementation for reference: https://github.com/wesleytodd/rufio-filter-browserify/blob/master/index.js

Read more comments on GitHub >

github_iconTop Results From Across the Web

base.ReadableStream.pipe JavaScript and Node.js ... - Tabnine
Best JavaScript code snippets using base.ReadableStream.pipe(Showing top 3 results out of 315) ; gulp.task('vendor', function () { ;.on('error', err => console.
Read more >
How to use a stream as input for Browserify? - Stack Overflow
You can't pass a vinyl stream to browserify. It only accepts text or buffer streams. The only solution is to transform the input...
Read more >
Top 5 stream-browserify Code Examples - Snyk
To help you get started, we've selected a few stream-browserify examples, based on popular ways it is used in public projects. Secure your...
Read more >
readable-stream - npm.io
If you want to guarantee a stable streams base, regardless of what version of Node you, or the users of your libraries are...
Read more >
stream-browserify - npm
You usually do not have to install stream-browserify yourself! If your code runs in Node.js, stream is built in, or readable-stream can be ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found