Skip to content

streams : wrong dependencies execution order #815

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dduponchel opened this issue Jul 6, 2014 · 4 comments
Closed

streams : wrong dependencies execution order #815

dduponchel opened this issue Jul 6, 2014 · 4 comments

Comments

@dduponchel
Copy link

With the following test.js file :

var stream = require('readable-stream');
console.log(stream.Transform.prototype.on);

In nodejs, I get the expected [Function] loggued.
I then use browserify :

$ browserify --version
4.2.0
$ browserify test.js -o bundle.js -s bundle

In a browser (tested with Firefox 30 and Chromium 35), I get undefined.

In the generated bundle.js file, if I add a log for each interesting inherits call, I get :

Stream inherits EventEmitter
Writable inherits Stream
Duplex inherits Readable
Transform inherits Duplex
PassThrough inherits Transform
Readable inherits Stream          // <- too late !

The Readable class inherits Stream too late, and the other classes don't get its methods (like on).

@dduponchel
Copy link
Author

After more debugging, this seems to come from this line in isaacs/readable-stream : require('stream') triggers in browserify the inclusion of all the stream classes.
After everything is resolved (with an empty Readable because we are still executing its init code), we continue and finally get the util.inherits(Readable, Stream); call, too late.

If I use require('readable-stream/transform') in my test, Transform is OK, but PassThrough still have order issues.

@gobengo
Copy link

gobengo commented Jul 8, 2014

This sounds a lot like what I ran into before reporting #810.

When massaging things to get them working, I would frequently notice that certain Readable.prototype values weren't there (like pipe and on).

@digitallyrefreshed
Copy link

Does anybody have a solution for this? I really don't want to have to modify my bundle just to call require('readable-stream/x')

@goto-bus-stop
Copy link
Member

Seems to have been fixed sometime in the past 3½ years. thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants