Skip to main content

esm_relative_specifier

Function esm_relative_specifier 

Source
pub fn esm_relative_specifier(
    from_path: &str,
    to_path: &str,
    ext: &str,
) -> String
Expand description

Compute the relative ES-module import specifier from the file that hosts module from_path to the file that hosts module to_path, both keyed on their declared dotted module-paths and laid out at the mirrored path (core.optioncore/option.<ext>). The entry module is always at the build root as main.<ext> regardless of its declared path, so callers pass the empty string as from_path for the entry file.

Returns a specifier that always begins with ./ or ../ and ends with the target file extension (e.g. ./core/option.js, ../helper.ts) — ESM requires a relative specifier to be explicitly relative and, for Node, to carry the file extension.