9. Production Build And Resolution - rbarilani/systemjs GitHub Wiki
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.
- If
name
is not a plain name: - Return the URL resolution of
name
relative toparentName
- Otherwise, if
name
is a plain name: - Return the plain name resolution for
name
relative toparentName
Plain name resolution:
Apply contextual map, then global map, then paths resolution.
- If
parentName
is a contextual map parent: - If
name
matches any of the contextual maps forparentName
: 1. Setname
to the mapping of the most specific contextual map match inname
replaced with its map target. - If
name
is still a plain name: - If
name
matches any of the global map mappings: 1. Setname
to the mapping of the most specific global map match inname
replaced with its map target. - If
name
is defined in the loader registry, returnname
- Otherwise, return the paths resolution of
name
Paths resolution:
Apply paths, then baseURL at the very end only if still a plain name.
- If
name
matches any paths: - Return the mapping of the most specific paths match in
name
replaced with its paths target. - If
name
is still a plain name: - Return
baseURL
+name
.