feat(DEP0205): migrate compatible module hooks to `module.registerHooks()`
I maintainer di solito rispondono entro 2 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- node.js, typescript
Direzione di ricerca
Start by locating the codemod entry point and fixtures for module.register() calls; trace how it can inspect both the registration site and each referenced local hook module. Define conservative checks for compatible synchronous resolve hooks and preserve registration-before-application loading order. Done means supported cases are transformed and fixtures cover aliases, unresolved specifiers, unsupported hooks, and load order, while unsafe cases are skipped or reported.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
module.register() became runtime-deprecated in Node.js 26.0.0 under DEP0205. The replacement is module.registerHooks().
This is not a direct function rename. register() loads hook implementations on a separate loader thread, while registerHooks() receives synchronous hook functions that execute on the thread loading the modules.
Add a partial migration for local hook modules whose behavior is compatible with synchronous, same-thread execution. The codemod must inspect both the registration site and the referenced hook module before proposing edits.
Additional Information
- Start with literal local module specifiers and simple, stateless
resolvehooks that already use synchronous control flow and return plain objects or the result ofnextResolve(). - Introduce an import of the supported hook function and pass it through
registerHooks({ resolve }), preserving binding names and avoiding collisions. - Preserve loading order: application modules that need customization must still be loaded after hook registration, using dynamic
import()or an appropriaterequire(). - Moving the hook module to the main thread can change its initialization order, global state, side effects, and interaction with other registered hooks. Skip cases where compatibility cannot be established.
- Skip hooks using
initialize, transferred data, MessagePorts, asynchronous I/O, unresolved dependencies, or thread-specific behavior. - Do not remove
asyncorawaitmechanically. Asyncloadhooks, CommonJS-specific behavior, mixed hook chains, and worker inheritance need separate analysis. - Programmatically registered synchronous hooks are not inherited by child workers in the same way as asynchronous hooks. Report applications relying on that inheritance; preloaded registration files require their own review.
- Keep existing
registerHooks()calls unchanged. Include fixtures for supported local hooks, aliases, unresolved module specifiers, unsupported hooks, and application load order.
Examples
For a local hooks.mjs containing only a compatible stateless resolve export, the registration file can change as follows:
-import { register } from 'node:module';
+import { registerHooks } from 'node:module';
+import { resolve } from './hooks.mjs';
-register('./hooks.mjs', import.meta.url);
+registerHooks({ resolve });
await import('./app.mjs');
Example compatible hooks.mjs, unchanged by this migration:
export function resolve(specifier, context, nextResolve) {
if (specifier === 'app:config') {
return {
url: new URL('./config.mjs', import.meta.url).href,
shortCircuit: true,
};
}
return nextResolve(specifier, context);
}
This example assumes that the hook module has no initialization effects or dependencies on loader-thread isolation, existing hook chains, or worker inheritance. More complex modules should be reported for manual migration.
Refs
- Lingua principale
- TypeScript
- Stelle
- 85
- Fork
- 58
- Merge medio
- 1g 21h
- PR unite (30g)
- 8
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di nodejs/userland-migrations
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
nodejs/userland-migrations#562 · 4 reazioni ·
I maintainer di solito rispondono entro 2 giorni
-
good first issue human help wanted
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
nodejs/userland-migrations#560 · 1 reazione ·
I maintainer di solito rispondono entro 2 giorni
-
good first issue human help wanted
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
nodejs/userland-migrations#559 ·
I maintainer di solito rispondono entro 2 giorni
-
good first issue human help wanted
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
nodejs/userland-migrations#558 ·
I maintainer di solito rispondono entro 2 giorni
-
good first issue human help wanted
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
nodejs/userland-migrations#557 ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di nodejs/userland-migrations
Issue simili
-
Chip source filter and denial markers miss Storage rows when a Storage activity source is pickedApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
omdsh-dev/DSH-better-sidebar#1141 ·
I maintainer di solito rispondono entro 2 giorni
-
desktop linux photos
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Cleanup SetupForse già presa @AlexanderKaran l’ha presa oggi. Apertadocumentation enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
e18e/framework-tracker#769 ·
I maintainer di solito rispondono entro 1 giorno
-
fix(docker): correct stale --db-path comments in fetch/git Dockerfiles and clarify git READMEApertabug v2
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
modelcontextprotocol/servers#5483 ·
I maintainer di solito rispondono entro 1 giorno