For clarity, the exact normalization and resolve algorithm used in the polyfill is listed here.
A module name is assumed a URL if it starts with a protocol ([protocol]://...
/ //...
) or an absolute URL reference (/...
). It may be worth allowing data-URIs and file system URIs as well here (filesystem:...
and data:...
).
Given a normalized module name, the resolve function will only add the base URL and .js
extension if the module name is not detected as being a URL as described above. The module name can start with ../
indicating it is below the baseURL.
The resolve function also handles the ondemand resolution map, which is an overriding map from a normalized module name to a URL.
- If the module name is a URL, it is left as-is and returned as the normalized module name.
- The module name is then resolved relative to the referer name.
../
and./
denoting relative module names. - If no referer name is present, or the module name backtracks below the referer name, the module name can be allowed to start with
../
to indicate that it is below the baseURL.