Skip to content

A new major version? #153

Open
0 of 4 issues completed
Open

Description

@gameroman

Releasing a new major version dropping support for old versions of Node.js will allow to drop 2 dependencies and use newer syntax

Activity

  1. mahmoodhamdi commented on Mar 29, 2026

    @mahmoodhamdi

    I'd love to see this happen. I took a look at the current dependency tree and here's what I found regarding what could be simplified by dropping older Node.js versions:

    Dependencies that could be removed/inlined:

    1. setprototypeof — On any Node.js version with native Object.setPrototypeOf (v4+), this package already just re-exports the native function. With a higher minimum Node.js target, this can be replaced with Object.setPrototypeOf directly.

    2. inherits — Resolves to util.inherits on Node.js, which itself just does Object.setPrototypeOf(ctor.prototype, superCtor.prototype). Could be replaced with ES6 class extends syntax or a direct Object.setPrototypeOf call. This would also align with the ES6 class extension discussion in Allow HttpError extension by ES6 classes #98.

    3. toidentifier — A ~6 line function that converts a string to PascalCase. Small enough to inline directly.

    Dependencies that would likely stay:

    1. depd — Provides runtime deprecation warnings with caller site info. Not trivially replaceable without losing functionality, though process.emitWarning() (Node.js 6+) could be an alternative worth exploring.

    2. statuses — Core functionality (HTTP status code → message mapping). Would stay as a dependency.

    So targeting something like Node.js >= 18 (current oldest LTS) would allow dropping 3 of 5 dependencies, and potentially using modern syntax throughout (class, const/let, etc.).

    Happy to help with a PR if there's agreement on the minimum Node.js version to target.

  2. mahmoodhamdi commented on Mar 29, 2026

    @mahmoodhamdi

    One more thought — if we're targeting modern Node.js for v3, using ES6 classes would also naturally solve #98 (ES6 class extension support). The entire codebase could become significantly simpler:

    class HttpError extends Error {
      constructor () {
        if (new.target === HttpError) {
          throw new TypeError('cannot construct abstract class')
        }
        super()
      }
    }
    
    class ClientError extends HttpError {
      constructor (message, code, className) {
        super()
        this.message = message ?? statuses.message[code]
        this.name = className
        this.status = code
        this.statusCode = code
        this.expose = true
      }
    }

    This would drop inherits and setprototypeof naturally, fix the instanceof issues with subclassing (#98), and make the whole codebase more readable. toidentifier could just be inlined as a 6-line helper.

    That would take the dependency count from 5 down to 2 (depd + statuses).

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions