Skip to content

Latest commit

 

History

History
62 lines (43 loc) · 2.93 KB

production-build.md

File metadata and controls

62 lines (43 loc) · 2.93 KB

SystemJS Production Build

The SystemJS production build supports loading System.register and System.registerDynamic modules using script tag loading, while also keeping support for Web Assembly when enabled via System.config({ wasm: true }).

The configuration options of baseURL, paths, map, depCache and bundles are supported identically to the full development build, and as documented at the configuration API page.

For contextual map configuration, the production build permits objects in the map configuration which act just like package maps, allowing mappings within the package.

Resolution Algorithm

The following is a detailed description of the production loader resolution algorithm in full, which can also help to understand the SystemJS development build resolution as this resolution is a subset of that, although with some subtle differences as well.

Plain Names

An important concept in the resolution algorithm is one of plain names or bare names as they are referred to in the WhatWG loader specification. These are module names that do not start with / or ./ or ../ and do not parse as URLs (new URL(name) fails).

Resolution Phases

The overall process of resolution is based on the steps for a given module name, being resolved to parentName. If the module import is a top-level System.import call then parentName is set to the environment baseURI.

paths, map, and contextual map targets are all fully normalized into URLs by the configuration system before running the resolution algorithm, where the map and contextual map configurations themselves are normalized through paths resolution if plain names.

Core Resolution:

If a plain name, resolve with plain name resolution, otherwise resolve as a URL.

  1. If name is not a plain name:
  2. Return the URL resolution of name relative to parentName
  3. Otherwise, if name is a plain name:
  4. Return the plain name resolution for name relative to parentName

Plain name resolution:

Apply contextual map, then global map, then paths resolution.

  1. If parentName is a contextual map parent:
  2. If name matches any of the contextual maps for parentName: 1. Set name to the mapping of the most specific contextual map match in name replaced with its map target.
  3. If name is still a plain name:
  4. If name matches any of the global map mappings: 1. Set name to the mapping of the most specific global map match in name replaced with its map target.
  5. If name is defined in the loader registry, return name
  6. Otherwise, return the paths resolution of name

Paths resolution:

Apply paths, then baseURL at the very end only if still a plain name.

  1. If name matches any paths:
  2. Return the mapping of the most specific paths match in name replaced with its paths target.
  3. If name is still a plain name:
  4. Return baseURL + name.