Skip to content

Conversation

@calvinmetcalf
Copy link
Contributor

No description provided.

@calvinmetcalf
Copy link
Contributor Author

ok fixed it so it will now work in 0.8

@calvinmetcalf
Copy link
Contributor Author

judging by the shear number of errors in 0.6 I'm guessing this is how far back we've been supporting in node

@rvagg
Copy link
Member

rvagg commented Mar 13, 2015

yes, 0.6 is dead to readable-stream

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this smells a little but I don't have a better suggestion

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could j patch Buffer instead?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, the global.setImmediate is unfortunate enough as it is, we could lift this out to a helper function and/or put the array at the top level or something, but if this works then perhaps that's premature optimization.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Buffer.isEncoding is used exactly once I believe so it won't make much difference

@rvagg
Copy link
Member

rvagg commented Mar 13, 2015

@feross how far off browserify testability are we? any idea how we can confirm the current version works well enough with browserify?

@calvinmetcalf
Copy link
Contributor Author

the current version browserifies to 165k/42k zipped and after these changes its 166/42

@calvinmetcalf
Copy link
Contributor Author

ok just pushed up what may be a horrible hack but may be useful, basically we treat streams like Voldemort and avoid saying its name replacing require('stream'); with require('st' + 'ream'); I'd want to get @substack's opinion on this but the idea is that if stream has been required somewhere then the require should work and streams get imported but if they are not required anywhere else then the import fails. Since the only reason we import streams is for use when people compare against streams (which they'd have to require) this change should be unobservable but shrinks the size

Which Full Uglified Gzipped Uglified and Gzipped
before 172213 94271 43520 21839
after 115985 67996 30023 16022
change -32.65% -27.87% -31.01% -26.64%

some other odds and ends include we have to replace Stream as superclass with event emitter, the actual requires need to be inside of try/catch blocks (which i put inside iife's just in case for performance reasons), plus I caught a bug that I missed earlier which is that in the browser you can't use if (!(chunk instanceof Buffer)) you need to use Buffer.isBuffer(chunk)

@calvinmetcalf
Copy link
Contributor Author

@iojs/streams comments?

@feross
Copy link
Contributor

feross commented Apr 12, 2015

@rvagg Last I looked into making the tests work in the browser was a while ago. I might be able to take another look soon.

@calvinmetcalf Good call on the Buffer.isBuffer vs. instanceof Buffer change. This is definitely required to test for buffers in the browser. Once Uint8Arrays become subclassable in ES6, we can make Buffer a proper subclass of Uint8Array and make instanceof Buffer start to work correctly while preserving performance in the browser! Tracking issue: feross/buffer#40

@feross
Copy link
Contributor

feross commented Apr 12, 2015

@calvinmetcalf Also, thanks for thinking of bundle size! This is an issue near and dear to my heart. I've been traveling around NZ with 16KB/s mobile Wi-Fi speed and now viscerally appreciate the importance of small page weight.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens here? could this ever fail? (excuse me if I'm asking dumb questions)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will fail in the browser if streams are not already in the bundle which it won't be by default because browserify won't recognize this as requiring the stream module during the static analysis phase but will during the actual execution.

Basically the only reason we are requiring streams is that so if somebody goes myStream instance of require('stream').Readable it will be true. which they can't do if they havn't required streams

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK now i get it, thanks for the explaination 😄. We should get this merged, because we really need to get this module up-to-date with core.

@calvinmetcalf
Copy link
Contributor Author

ping @rvagg @isaacs or @TooTallNate (who have access to readable-streams on npm) the if (!(chunk instanceof Buffer)) bug actually came up in pouchdb-community/pouchdb-replication-stream#29 as streams from separate browserify bundles don't work together

@rvagg
Copy link
Member

rvagg commented Apr 22, 2015

@calvinmetcalf what's the action item here? does @iojs/streams believe that we're ready to cut a 3.0.0 release for npm using the current code? Should it be at a specific point? Maybe to coincide with iojs@2.0.0?

@calvinmetcalf
Copy link
Contributor Author

we are way overdue on cutting 3.0.0 as it corresponds to io.js 1.1 and 1.2

I'd love to get a 👍 from @chrisdickinson first but in general Id like to get this out sooner rather then latter.

@calvinmetcalf
Copy link
Contributor Author

though looks like 1.8.1 made some changes to process.nextTick which streams is going to include but aren't in browserify (yet defunctzombie/node-process#43) so we'd probably want to base 3.0.0 off of iojs 1.7.1

@calvinmetcalf
Copy link
Contributor Author

yeah this isn't going to work out of the box against older versions of browserify but does work with browserify 10 which has the updated process.nextTick shim

@calvinmetcalf calvinmetcalf changed the title get build working with 1.5.1 as far back as 0.10.36 get build working with 1.7.1 as far back as 0.10.36, 2.0.0 with browserify 10 May 7, 2015
@rvagg
Copy link
Member

rvagg commented May 7, 2015

I've been holding off on this, waiting for a broader consensus from @iojs/streams that this is actually ready to cut as 3.0.0, I'm hesitant because it's a big deal

@calvinmetcalf
Copy link
Contributor Author

cutting a beta/prerelease and then retagging the current as latest might be a good step

@calvinmetcalf
Copy link
Contributor Author

published as io-stream in order for people to be able to test it https://www.npmjs.com/package/io-stream

@calvinmetcalf
Copy link
Contributor Author

io-stream is now updated with the streams from 2.0.2 so if people want to test it, it's there, I can setup a new pull to merge the changes in if that makes sense

@calvinmetcalf
Copy link
Contributor Author

closing in favor of #135

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants