-
Notifications
You must be signed in to change notification settings - Fork 5.6k
fix(ext/node): upgrade node:stream
#28855
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
Conversation
node:streams
node:stream
ext/node/update_node_stream.js
Outdated
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.
@dsherret because this involves code transpilation, it'd be good to get your eyes.
0319ace
to
82367f4
Compare
80fe5e8
to
82e758d
Compare
ext/node/update_node_stream.js
Outdated
// This file is used to transform Node.js internal streams code to | ||
// Deno polyfills. |
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.
Can you expand this description? This file is only run when we want to upgrade the node streams code?
Can you use TypeScript 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.
Ported to TypeScript
ext/node/update_node_stream.js
Outdated
// Workaround a bug in our formatter: "export default from;" does not work | ||
// correctly, so we rename it to something else and export. | ||
const renameForDefaultExport = ["from"]; |
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.
can you open a dprint issue and link it here?
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.
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.
It looks like an swc syntax error.
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.
it can parse it on the swc playground
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.
It's an swc diagnostic that's not surfaced in the playground. I'll open an swc issue.
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.
Looked into it and here's an example of the swc playground erroring: https://play.swc.rs/?version=1.11.20&code=H4sIAAAAAAAAA0vOzysuUUgrys9VsFWorrXmSq0oyC8qUUhJTUsszYHIWAMAg8l5qiUAAAA%3D&config=H4sIAAAAAAAAA1WPsQ6DMAxEd74Cee7aDp2rbv0IKzUoKCGRbSQQ4t8JkNCyxXfPd%2FFc1TV0YuBZz%2BmZhogsxOecFJl6xTEpQMajGLZR4VZcGmNgfVGDg9M3B59A5YFOoJNtt0EntEvL4YAit6R7rNxzHrgQhAqeNW9720z%2FPzLBRyaRK7ih2LeOrnVVrgQfvsNu5kt1inTUP%2BAHlbIzGKx8yuZ2WLWst%2B%2Fb9zUBAAA%3D
It's because of the export default from
proposal.
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.
swc-project/swc#10372 -- Using identifiers that are also contextual keywords is kind of asking to hit edge cases.
6aa984f
to
257132a
Compare
257132a
to
b7b27cf
Compare
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.
LGTM - this is a massive improvement!
Ref #28836 This PR replaces the _stream.mjs bundle with a file-by-file port instead. A codemod transpiles Node.js internals to ESM. The codemod performs three tasks: translating CJS to ESM, remapping internal dependencies, and hoisting lazy requires as imports. The process is fully automated through the `update_node_stream.ts` script, simplifying future internal updates. The script checks out Node.js from a specific tag defined in the `tests/node_compat/runner`. Additionally, the update enables new tests in our Node test runner and adds features (like compose()) that were missing from the outdated bundle. ## Performance There is a 140KB+ binary size increase on aarch64-apple-darwin and nop startup time stays the same.
Ref #28836 This PR replaces the _stream.mjs bundle with a file-by-file port instead. A codemod transpiles Node.js internals to ESM. The codemod performs three tasks: translating CJS to ESM, remapping internal dependencies, and hoisting lazy requires as imports. The process is fully automated through the `update_node_stream.ts` script, simplifying future internal updates. The script checks out Node.js from a specific tag defined in the `tests/node_compat/runner`. Additionally, the update enables new tests in our Node test runner and adds features (like compose()) that were missing from the outdated bundle. ## Performance There is a 140KB+ binary size increase on aarch64-apple-darwin and nop startup time stays the same.
Ref #28836
This PR replaces the outdated
_streams.mjs
bundle with an auto-managed, file-by-file port of Node.js stream internals using theext/node/update_node_stream.ts
script.TBD:
internal/errors.ts
#28856newReadableStreamFromStreamReadable
fordeno_web
interopinternal/streams/duplexify
lazy loading (can't be hoisted due to circular dependency)Performance
Binary size (aarch64-apple-darwin): 85396664 bytes (+140KB from
main
)Startup time: