Skip to content

scripts/ts-resolve-loader.js: module.register() is deprecated (Node warns DEP0205) #1832

Description

@carlos-alm

Running any script that uses the .js -> .ts fallback loader (scripts/ts-resolve-loader.js, used by benchmark, query-benchmark, incremental-benchmark, token-benchmark, and now doctor -- see #1733) prints:

(node:XXXXX) [DEP0205] DeprecationWarning: module.register() is deprecated. Use module.registerHooks() instead.

scripts/ts-resolve-loader.js calls register() from node:module:

const { register } = await import('node:module');
const hooksURL = new URL('./ts-resolve-hooks.js', import.meta.url);
register(hooksURL.href, { parentURL: import.meta.url });

module.registerHooks() is the newer synchronous, in-thread alternative (no worker thread, no async resolve/load hooks needed) added in recent Node versions. Since this repo's minimum supported Node is >=22.6 (per CLAUDE.md) / >=22.12.0 (per package.json engines), worth checking registerHooks()'s availability floor before migrating -- it may need a version gate similar to the existing --experimental-strip-types / --strip-types handling in the same file family.

Purely a deprecation warning today (still functional), not a build/test failure. Found while implementing #1733 (environment doctor), which adds another consumer of this loader.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions