Expand description
Relative import specifiers, and what moving a file does to them.
Only specifiers that denote a file take part. ./core.js and ../lib/y are paths; Rust’s
crate::core and Java’s com.example.Core are module names that a file move does not
rewrite, and treating them as paths would corrupt them. So everything here is gated on the
specifier starting with ./ or ../.
The arithmetic is done on normalised segments rather than by string surgery, because ..
that escapes the repository root and . segments in the middle both produce specifiers that
look plausible and resolve somewhere else.
Functions§
- between
- The specifier an importer in
importerneeds to reachtarget, preserving any extension style the original used. - is_
relative - Whether a specifier names a file rather than a module.
- resolve
- Resolves a relative specifier against the directory of the importing file.
- rewrite
- The specifier for
targetas written from a file that has moved tomoved_to.