The resolution settings
The export conditions mapping each subpath to its source file, as listed in customConditions; where a package
matches more than one, the key order of its own exports decides which applies.
Optionalroot?: stringThe project root the linked packages and their peers resolve from; defaults to the current working directory.
Synchronous module hooks resolving linked imports to source, deduplicating linked packages and their
peers, mapping .js relative imports to their .ts sources, and leaving all other imports to the default resolution
Creates module hooks running a Node process against the live source of locally linked packages, with no rebuild.
Imports of workspace members and of sibling checkouts linked into
node_modulesresolve to their TypeScript source, which Node runs through its built-in type stripping, so edits are picked up as they are saved. Packages installed from the registry keep resolving to their build, as do packages whoseexportsname none of the conditions.Packages are looked up as Node does, from the
node_modulesnearest to the importer up through its ancestors; imports with no importer start from the root. A linked checkout importing a package the project links as well loads the linked source rather than the registry copy it installs for itself, so the two never diverge.The process loads a single copy of every linked package and of each of their
peerDependencies, as libraries holding module state such as Preact hooks require. Those packages resolve from the root, whatever copies a linked checkout installs for itself, and from the importer only where the root does not install them. Other dependencies of a linked package resolve from its checkout, as Node does, since the process loads no other copy of them.Relative imports of a
.jsfile from a TypeScript module, asNodeNextmodule resolution requires, resolve to the.tsfile next to it when the.jsfile does not exist. Sources compiled todistthus run fromsrcunder plainnode, with no loader such astsx. Where such a loader is registered as well, the imports it resolves are left to it, and the hooks only add the resolution of linked packages to their TypeScript source.The hooks take effect once registered with
registerHooksfromnode:module, before the first import they have to resolve, typically from a module loaded with--import. Importing@metreeca/rack/noderegisters them with the conditions of thetsconfig.jsonnearest to the current working directory, with no setup module to write.