Skip to content

Instantly share code, notes, and snippets.

@guybedford
Last active December 21, 2015 06:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guybedford/3712492cf0f629eed761 to your computer and use it in GitHub Desktop.
Save guybedford/3712492cf0f629eed761 to your computer and use it in GitHub Desktop.
A quick summary of suggested System normalization rules

ES6 Module Loader Polyfill System Normalization & Resolution Rules

For clarity, the exact normalization and resolve algorithm used in the polyfill is listed here.

URL detection

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:...).

System.resolve

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.

System.normalize

  1. If the module name is a URL, it is left as-is and returned as the normalized module name.
  2. The module name is then resolved relative to the referer name. ../ and ./ denoting relative module names.
  3. 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment