pub fn normalize_specifier(base: &str, specifier: &str) -> StringExpand description
The reference’s textual specifier rule, shared with the AOT bundler.
See js_parse::normalize_specifier: the loader and the bundler have to agree on a
module’s name, or a product reports “could not load module filename” for a module it is
carrying.
The name specifier resolves to when imported from base, textually.
This is the reference’s js_default_module_normalize_name, and it is textual on
purpose: ./a.js imported from /x/main.js is /x/a.js without anything being
resolved against the filesystem. Two things depend on that rule and must not disagree:
- the loader, which uses the name as the cache key and as what diagnostics print;
- the AOT bundler, which registers precompiled modules under that name so the engine can find them without a loader at all.
A second implementation of this in the bundler would drift from the loader’s, and the symptom would be a product that reports “could not load module filename” for a module it is carrying.
Only the leading ./ and ../ are folded, matching the reference: a specifier that
is not relative (lodash, node:fs) is returned unchanged, so a bare specifier keeps
failing the way it always did instead of being silently rewritten into a path.