Skip to main content

package_file

Function package_file 

Source
pub fn package_file(
    from_dir: &Path,
    name: &str,
    subpath: &str,
) -> Result<PathBuf>
Expand description

Resolve <name>/<subpath> to a real file inside the installed package.

When the package declares exports, only the subpaths it maps resolve — one it does not is refused, mirroring Node’s ERR_PACKAGE_PATH_NOT_EXPORTED; otherwise the file is addressed directly (Node’s behavior for a package without exports, e.g. bootstrap-icons). The result is canonicalized and guaranteed to sit inside the package’s real directory — an in-package symlink resolving outside it is refused.