register
Documentation / @wtf/project-resolve / register
Registers the hooks of ./hooks, once a process, by Node’s registerHooks: each package of the
workspace resolves by its @wtf/source condition, to its TypeScript, beside any loader of
module.register, before it or after it; and a relative import of TypeScript written ./x.js
or ./x resolves to its .ts. Node strips the types itself.
The packages are those of the workspace Node runs in, its working directory’s, and of the one its
entry is in, the script it runs: so a dev entry an MCP client starts from a folder of its own,
as /repo/packages/cli/bin/dev.js, reads its own workspace’s source. Of a name both have, the
working directory’s.
Given to Node by --import=@wtf/project-resolve/register, or imported first by an entry. The
hooks run in the thread that loads, for import and require alike.
Once a process, of every copy: a process that loads it twice, from its source and its build, or
by two URLs, registers the hooks once. Its own resolve hook answers REGISTERED, a
specifier nothing else resolves, so each copy asks Node’s resolver, the chain of the hooks
registered, whether one is there: a test asks it so too, by import.meta.resolve or
require.resolve.
