-
Notifications
You must be signed in to change notification settings - Fork 30k
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
stream: move legacy to lib/internal dir #8197
Conversation
I don't feel qualified to judge the implementation, but +1 on the idea. |
lib/_stream_legacy.js
Outdated
@@ -0,0 +1,91 @@ | |||
'use strict'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps this belongs in lib/internal/streams/
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason is? IMO the legacy stream class should not be internal class, it's exposed to user-land, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense, especially since everything in the file is exported. Nevermind! :)
I think it would be better to put it in an internal file and have |
@Fishrock123 what do you mean by "have _stream_legacy" export it as deprecated"? Could you explain more, thanks :-) |
And I will try to put the legacy file to internal dir as @Fishrock123 and @brendanashworth expected. |
@nodejs/streams ... please take a look at this. Would moving this to internal have a detrimental impact on the readable-streams module? |
@yorkie we have 3 major versions of streams: 1, 2 and 3. "legacy" is version 1, and it is used by modules such as through, split, serial-port and the like. It comes from the 0.8 era. Since 0.10 we had streams 2, and streams 3. Streams 3 are fairly stable, with their own quirks. I think we should deprecate streams 1 as semver-major, and maybe remove it in a year or two. I'll leave the question about readable-stream to @calvinmetcalf |
c133999
to
83c7a88
Compare
@calvinmetcalf ping? |
I mean yes this would involve a bit of work to upgrade readable-stream, but it wouldn't be a big deal, honestly a drop in the bucket compared to other stuff so don't worry about it on my account. |
@yorkie can you please rebase/update this PR on top of master, we can land this. |
@mcollina does this PR necessary to land, current master seems not have the |
@yorkie it seems it has it: https://github.com/nodejs/node/tree/master/lib/internal. |
Rebased done @mcollina :) |
@yorkie I've re-read this PR, and the majority idea is to move the legacy file into the |
@mcollina Done and running a new CI: https://ci.nodejs.org/job/node-test-pull-request/5748 :) |
citgm: https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/510/ edit: now with windows :D 🎉 |
Ping, and any reviews? Thanks :) |
lib/stream.js
Outdated
@@ -1,11 +1,18 @@ | |||
'use strict'; | |||
|
|||
module.exports = Stream; | |||
|
|||
const EE = require('events'); | |||
const util = require('util'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused.
lib/stream.js
Outdated
util.inherits(Stream, EE); | ||
function Stream() { | ||
EE.call(this); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I meant previously is why can't we just move this into the new internal module and export it into this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it :)
lib/stream.js
Outdated
var Stream = require('internal/streams/stream').Stream; | ||
|
||
// wrap the old-style stream | ||
require('internal/streams/legacy')(Stream); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not clear to me. Basically the definition of Stream
is divided into two files, whicn is not easy to understand in my opinion. If we also move the definition of Stream
, I think internal/streams/stream
should also include the 'legacy' bits.
How about we move all _stream
prefixed files into internal/streams
? That might be a better solution overall.
cc @nodejs/streams.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You couldn't just move those files because that would break someone trying to require()
them? Unless you mean leave behind similarly-named files that simple re-export?
Also, I think the point of this PR was to separate the actual old Stream
implementation from the other things, like the re-exporting of the various stream types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but then why split the definition of it in one file, and the legacy part in another?
Either we just move the legacy bits, we move the full definition, or we move all the streams parts.
I'm 👎 in having both internal/streams/stream
and internal/streams/legacy
, if we are not moving along readable, writable, etc.
lib/internal/streams/stream.js
Outdated
} | ||
util.inherits(Stream, EE); | ||
|
||
exports.Stream = Stream; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole file should be merged with lib/internal/streams/legacy.js
The legacy.js file should then just module.exports = Stream;
and lib/stream.js should just require()
that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just saw this, I think we agree.
Done :) |
LGTM if CI and CITGM are green. |
Can we land this @mcollina ? |
CITGM has some unrelated failures. |
Landed as 1b30df1. |
Improve readability of lib/stream.js by moving the legacy abstract Stream into lib/internal/streams/legacy.js. PR-URL: #8197 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Improve readability of lib/stream.js by moving the legacy abstract Stream into lib/internal/streams/legacy.js. PR-URL: nodejs#8197 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Improve readability of lib/stream.js by moving the legacy abstract Stream into lib/internal/streams/legacy.js. PR-URL: nodejs#8197 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Requires a backport PR to land on v4 |
Improve readability of lib/stream.js by moving the legacy abstract Stream into lib/internal/streams/legacy.js. PR-URL: #8197 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Improve readability of lib/stream.js by moving the legacy abstract Stream into lib/internal/streams/legacy.js. PR-URL: #8197 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Checklist
make -j4 test
(UNIX), orvcbuild test nosign
(Windows) passesAffected core subsystem(s)
stream
Description of change
This won't fix anything problem or adds any new feature, it just makes the "lib/stream.js" clear to read in my opinion, I'm unsure if this makes any sense, if the feedback from anyone in @nodejs/collaborators is negative, feel free to close :-)