-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
lib: reduce internal usage of public require('util') #26546
Comments
I can work on it 🎉 |
@micheleriva That's great! If possible please try to refactor each file in single commit and submit them as separate PRs, otherwise the PR is bound to require manual backport. |
Remove public require('util') and replace util.isFunction with internal/util/isFunction Fixes: nodejs#26546
@joyeecheung Just curious, in many cases |
@joyeecheung ok no prob! So I'll close my PR #26552 in flavour of single PRs. |
@SimonSchick For public ES5-style classes we have to support instantiation without new so we cannot refactor them to ES6 classes. |
I was talking about those that do not support instantiation without Might also be worth mentioning that we dealt with the same issue in sequelize using |
PR-URL: nodejs#26548 Refs: nodejs#26546 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
I can work on it! |
@SimonSchick I guess if you are sure those do not support instantiation without new, those could be refactored if the tests are happy (probably also needs a CITGM run anyway because undoing |
PR-URL: nodejs#26548 Refs: nodejs#26546 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
@joyeecheung Maybe make this task a table like this jestjs/jest#7807 (comment) |
Remove the usage of public require('util'), as described in issue: nodejs#26546
Replace `require('util').inspect` and `require('util').format` with `require('util/internal/inspect').inspect` and `require('util/internal/inspect').format` in `lib/internal/errors.js`. PR-URL: #26782 Refs: #26546 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com>
This patch: - Moves the timer callback initialization into bootstrap/node.js, documents when they will be called, and make the dependency on process._tickCallback explicit. - Moves the initialization of tick callbacks and timer callbacks to the end of the bootstrap to make sure the operations done before those initializations are synchronous. - Moves more internals into internal/timers.js from timers.js. PR-URL: #26583 Refs: #26546 Reviewed-By: Anna Henningsen <anna@addaleax.net>
Use `require('internal/util/inspect').inspect` and `require('internal/util/debuglog').debuglog` instead of `require('util').inspect` and `require('util').debuglog`. Refs: #26546 PR-URL: #26820 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Masashi Hirano <shisama07@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Use `require('internal/util/inspect').inspect`, `require('internal/util/debuglog').debuglog`, `require('internal/util').deprecate` and `Object.setPrototypeOf` instead of `require('util')`. Fix test in `test/parallel/test-net-access-byteswritten.js` to do not check the `super_` property that was set when using `require('util').inherits`. Refs: #26546 Refs: #26896 PR-URL: #26920 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Michaël Zasso <targos@protonmail.com>
Use `require('internal/util/inspect').inspect` and `require('internal/util/debuglog').debuglog` instead of `require('util').inspect` and `require('util').debuglog`. Refs: #26546 PR-URL: #26820 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Masashi Hirano <shisama07@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Use `require('internal/util/inspect').inspect`, `require('internal/util/debuglog').debuglog`, `require('internal/util').deprecate` and `Object.setPrototypeOf` instead of `require('util')`. Fix test in `test/parallel/test-net-access-byteswritten.js` to do not check the `super_` property that was set when using `require('util').inherits`. Refs: #26546 Refs: #26896 PR-URL: #26920 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Michaël Zasso <targos@protonmail.com>
Use `require('internal/util/debuglog').debuglog` instead of `require('util').debuglog` in `lib/internal/modules/esm/create_dynamic_module.js`. Refs: nodejs#26546
Use `require('internal/util/debuglog').debuglog` instead of `require('util').debuglog` in `lib/internal/modules/esm/create_dynamic_module.js`. PR-URL: nodejs#26803 Refs: nodejs#26546 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Use `require('internal/util/inspect').format` instead of `require('util').format`. Refs: #26546 PR-URL: #26822 Reviewed-By: Masashi Hirano <shisama07@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Use `require('internal/util/inspect').format` instead of `require('util').format`. Refs: #26546 PR-URL: #26822 Reviewed-By: Masashi Hirano <shisama07@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Was looking for issues to work on and noticed that required changes have already been made and merged for timers in lib/internal/timers.js and lib/timers.js. Corresponding PRs can be updated in the original post. |
Any reason that this is still open? |
I can only find a single |
A few patterns (modulo destructuring):
require('util').inherits()
usages underlib
: Remove util.inherits usage internally? #24395require('util').inspect
withrequire('internal/util/inspect').inspect
require('util').format
withrequire('internal/util/inspect').format
require('util').debuglog
withrequire('internal/util/debuglog').debuglog
require('util').types
withrequire('internal/util/types')
require('util').deprecate
withrequire('internal/util').deprecate
require('util').promisify
withrequire('internal/util').promisify
List of JS files that can be refactored:
lib/domain.js#L29lib/inspector.js#L19The text was updated successfully, but these errors were encountered: