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
nameis not a plain name: - Return the URL resolution of
namerelative toparentName - Otherwise, if
nameis a plain name: - Return the plain name resolution for
namerelative toparentName
Plain name resolution:
Apply contextual map, then global map, then paths resolution.
- If
parentNameis a contextual map parent: - If
namematches any of the contextual maps forparentName: 1. Setnameto the mapping of the most specific contextual map match innamereplaced with its map target. - If
nameis still a plain name: - If
namematches any of the global map mappings: 1. Setnameto the mapping of the most specific global map match innamereplaced with its map target. - If
nameis 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
namematches any paths: - Return the mapping of the most specific paths match in
namereplaced with its paths target. - If
nameis still a plain name: - Return
baseURL+name.