Documentation
¶
Overview ¶
Package resolver provides the shared node_modules package resolution used by the bundler (bare import specifiers) and the docs plugin (npm docs themes).
Resolution mirrors Node's `module`/`main`/index fallback: a package's entry file is picked from package.json `module` (preferred) or `main`, then from a top-level index.* file, by walking up the directory tree from a start dir looking for node_modules/<pkg>.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NodeModule ¶
NodeModule resolves a bare npm package specifier ("formslib", "@scope/formslib") by walking up from startDir looking for node_modules/pkg. It returns the absolute path to the package entry file, or "" if the package (or an entry file) cannot be found. startDir may be an absolute or root-relative path.
func NodeModuleDir ¶
NodeModuleDir resolves a bare npm specifier that may include a subpath, e.g. "formslib", "@scope/formslib", or "formslib/styles/x.css". For a bare package name it returns the package entry file (via PackageDir); when a subpath is present it returns the joined subpath. It walks up from startDir looking for node_modules/<pkg>, returning "" when nothing resolves.
func PackageDir ¶
PackageDir resolves a package directory's entry file: package.json `module` (preferred), then `main`, then a top-level index.* — or "" if none exist.