### Install Chomp and Run Tests Source: https://github.com/systemjs/systemjs/blob/main/README.md Install Chomp globally and run the test suite. Requires Node.js and npm. ```bash npm install -g chomp ``` ```bash chomp test ``` -------------------------------- ### CSS Module Example - file.css Source: https://github.com/systemjs/systemjs/blob/main/docs/module-types.md Example CSS file used as a module. The CSS is imported as a CSSStyleSheet object. ```css /* file.css */ .brown { color: brown; } ``` -------------------------------- ### Install SystemJS via npm or yarn Source: https://github.com/systemjs/systemjs/blob/main/docs/nodejs.md Install SystemJS using npm or yarn. The system-node.cjs build is included in the package. ```sh npm install --save systemjs # or yarn add systemjs ``` -------------------------------- ### JSON Module Example - file.json Source: https://github.com/systemjs/systemjs/blob/main/docs/module-types.md Example JSON file used as a module. The JSON is imported as the default export. ```json { "some": "json value" } ``` -------------------------------- ### System.constructor: Create a custom System instance Source: https://github.com/systemjs/systemjs/blob/main/docs/api.md Instantiates a new System base class to create a custom context for module loading. The example shows importing a module in that custom context. ```javascript var clonedSystem = new System.constructor(); clonedSystem.import('x'); // imports in a custom context ``` -------------------------------- ### Install SystemJS via npm Source: https://github.com/systemjs/systemjs/blob/main/README.md Use this command to install SystemJS as a dependency in your project. It is the standard installation method for adding SystemJS to a Node.js-based project. ```bash npm install systemjs ``` -------------------------------- ### Transformed System.register example Source: https://github.com/systemjs/systemjs/blob/main/docs/system-register.md The System.register transformation of the ES module example. It shows how imports become setters, exports are handled via $__export, and hoisted functions are exported immediately. The execute function runs separately after all bindings are set up. ```javascript System.register(['./dep'], function($__export, $__moduleContext) { var s, C, q; function func() { return q; } $__export('func', func); return { setters: [ // every time a dependency updates an export, // this function is called to update the local binding // the setter array matches up with the dependency array above function(m) { q = m.p; } ], execute: function() { // use the export function to update the exports of this module s = 'local'; $__export('C', C = $traceurRuntime.createClass(...)); } }; }); ``` -------------------------------- ### Web Assembly Module Example - Import Map and Import Source: https://github.com/systemjs/systemjs/blob/main/docs/module-types.md Defines an import map for a Wasm dependency and imports a Wasm module, calling an exported function that uses the dependency. ```html ``` -------------------------------- ### System.firstGlobalProp: Example global.js module Source: https://github.com/systemjs/systemjs/blob/main/docs/api.md Shows the contents of a global module that defines two globals. Used to illustrate how System.firstGlobalProp affects which global is used as the module value. ```javascript window.a = 'a'; window.b = 'b'; ``` -------------------------------- ### Circular dependency example: b.js Source: https://github.com/systemjs/systemjs/blob/main/docs/system-register.md Companion module to a.js in the circular dependency example. It imports a from a.js and calls a() at module top level, which executes before a.js's own execution due to deferred binding setup. ```javascript import {a} from './a.js'; export function b() { console.log('b'); } a(); ``` -------------------------------- ### ES module example for System.register semantics Source: https://github.com/systemjs/systemjs/blob/main/docs/system-register.md An example ES module that imports a binding, declares a local variable, and exports a function and a class. This is the input for the transformation shown in the next snippet. ```javascript import { p as q } from './dep'; var s = 'local'; export function func() { return q; } export class C { } ``` -------------------------------- ### Depcache Example with Lazy Import Source: https://github.com/systemjs/systemjs/blob/main/docs/import-maps.md Defines dependencies for a lazily loaded module using the non-standard 'depcache' extension. The import map declares dependencies for 'dep.js' through 'dep5.js'. The script triggers a lazy import after 10 seconds, and SystemJS loads all dependencies in parallel once 'dep' is loaded. ```html ``` ```html ``` -------------------------------- ### Define an import map for module resolution Source: https://github.com/systemjs/systemjs/blob/main/README.md Use a systemjs-importmap script to map module names to URLs. The example maps 'lodash' to a CDN URL. An alternative external import map is shown in a comment. ```html ``` -------------------------------- ### Hook System.resolve to handle unresolved specifiers Source: https://github.com/systemjs/systemjs/blob/main/docs/errors.md Override System.constructor.prototype.resolve to catch resolution errors and return a fallback URL. This example returns '/some-url.js' for any unresolved specifier. ```html ``` -------------------------------- ### Loading Import Maps: Separate src and Inline Source: https://github.com/systemjs/systemjs/blob/main/docs/import-maps.md Shows two ways to load import maps: from a separate URL using the src attribute, and inline within a script tag. The inline example includes imports and scopes. The import map is fixed after the first System.resolve or System.import call. ```html ``` -------------------------------- ### ES module with import assertions Source: https://github.com/systemjs/systemjs/blob/main/docs/system-register.md Shows native ES module syntax using import assertions for JSON and CSS modules, plus dynamic import with assert option. This is the input that the following System.register example transforms. ```javascript import a from './a.json' assert { type: 'json' }; import b from 'b' import c from './c.css' assert { type: 'css' }; const { d } = await import('d') const { e } = await import('e',{assert: {type: 'javascript'}}) ``` -------------------------------- ### Set base URL with setBaseUrl Source: https://github.com/systemjs/systemjs/blob/main/docs/nodejs.md Change the base URL for resolving relative URLs. By default, process.cwd() is used. Examples show network and file URLs. ```js const { System, setBaseUrl } = require('systemjs'); const path = require('path'); const { pathToFileURL } = require('url'); // relative to process.cwd() System.resolve('./file.js'); // Use a network URL as the base setBaseUrl(System, 'https://example.com/base/'); // Use a file URL as the base setBaseUrl(System, 'file:///Users/name/some-dir/'); setBaseUrl(System, pathToFileURL(path.join(process.cwd(), 'some-dir')) + path.sep); ``` -------------------------------- ### Original ES module with uninitialized let binding Source: https://github.com/systemjs/systemjs/blob/main/docs/system-register.md Shows an ES module exporting an uninitialized let binding x and a function p that assigns to it. This is the source example that the following System.register version converts. ```javascript export let x; export function p () { x = 10; } ``` -------------------------------- ### Circular dependency example: a.js Source: https://github.com/systemjs/systemjs/blob/main/docs/system-register.md Part of a pair of modules (a.js and b.js) demonstrating circular imports. When a.js is imported first, b.js executes first, and b.js can call the function export from a.js before a.js executes due to deferred execution. ```javascript import {b} from './b.js'; export function a() { b(); } ``` -------------------------------- ### Invalid AMD define() calls causing SystemJS Error #9 Source: https://github.com/systemjs/systemjs/blob/main/docs/errors.md Examples of invalid calls to define() that trigger SystemJS Error #9. Passing a number or a string as the first argument does not match any valid pattern. ```javascript // INVALID // A number is not a valid argument to define() define(123); // INVALID // A string is not a valid argument to define() define("asdfasdf"); ``` -------------------------------- ### Handling import map errors with onerror attribute Source: https://github.com/systemjs/systemjs/blob/main/docs/import-maps.md Use the onerror attribute in the systemjs-importmap script tag to handle errors when fetching external import maps. The example shows both a named function and an inline script. ```html ``` -------------------------------- ### System reference and loading from file or network Source: https://github.com/systemjs/systemjs/blob/main/docs/nodejs.md Shows that System is referentially equal to global.System and demonstrates loading modules from file and HTTP URLs. ```js const { System } = require('systemjs'); console.log(System === global.System) // true System.import('file:///Users/name/some-module.js'); System.import('https://example.com/some-module.js'); ``` -------------------------------- ### new System.constructor() Source: https://github.com/systemjs/systemjs/blob/main/docs/nodejs.md Creates a new SystemJS instance with its own import map and module registry. ```APIDOC ## new System.constructor() ### Description Creates a new SystemJS instance with its own import map and module registry. ### Method constructor ### Endpoint new System.constructor() ### Parameters None ### Request Example ```js const system1 = new System.constructor(); const system2 = new System.constructor(); ``` ### Response #### Success Response - **system** (object) - A new SystemJS instance. #### Response Example ```js System { // new instance } ``` ``` -------------------------------- ### instantiate(url, parentUrl) -> Promise Source: https://github.com/systemjs/systemjs/blob/main/docs/hooks.md Downloads and executes the code for a module. The promise must resolve with a 'register' array. ```APIDOC ## instantiate(url, parentUrl) -> Promise ### Description This function downloads and executes the code for a module. The promise must resolve with a "register" array, as described in the `getRegister` documentation. ### Method instantiate ### Parameters - **url** (String) - Required - The URL of the module. - **parentUrl** (String) - Required - The parent URL from which the module is being loaded. ### Returns - **Promise** - Resolves with the register array. ### Default Implementation The default system.js implementation appends a script tag that downloads and executes the module's code, subsequently resolving the promise with the most recent register: `resolve(System.getRegister())`. ``` -------------------------------- ### System.constructor Source: https://github.com/systemjs/systemjs/blob/main/docs/api.md Represents the System base class, which can be extended or reinstantiated to create a custom System instance. ```APIDOC ## System.constructor ### Description Represents the System base class, which can be extended or reinstantiated to create a custom System instance. ### Method Constructor ### Usage Example ```js var clonedSystem = new System.constructor(); clonedSystem.import('x'); // imports in a custom context ``` ``` -------------------------------- ### System.set with import map: Remap URL to bare specifier Source: https://github.com/systemjs/systemjs/blob/main/docs/api.md Shows how to use an import map to remap a URL to a bare specifier, then set a module using the 'app:' prefix and import it by the bare specifier. ```html ``` ```javascript ``` -------------------------------- ### Dynamically load modules with System.import Source: https://github.com/systemjs/systemjs/blob/main/README.md Use System.import() to load a module at any time. The module must be in System.register format. ```javascript System.import('/js/main.js'); ``` -------------------------------- ### System.get(id) -> Module Source: https://github.com/systemjs/systemjs/blob/main/docs/api.md Retrieve a loaded module from the registry by ID. Module records with an error state will return null. ```APIDOC ## System.get(id) -> Module ### Description Retrieve a loaded module from the registry by ID. Module records with an error state will return null. ### Method Function ### Parameters - **id** (string) - Required - The module ID to retrieve. ### Returns The module namespace object, or null if the module has an error state. ### Example ```js System.get('http://site.com/normalized/module/name.js').exportedFunction(); ``` ``` -------------------------------- ### System.import(moduleUrl) -> Promise Source: https://github.com/systemjs/systemjs/blob/main/docs/nodejs.md Loads a module from a file URL or network URL. Returns a promise that resolves to the loaded module. ```APIDOC ## System.import(moduleUrl) ### Description Loads a module from a file URL or network URL. Returns a promise that resolves to the loaded module. ### Method import ### Endpoint System.import(moduleUrl) ### Parameters #### Path Parameters - **moduleUrl** (string) - Required - The URL of the module to load. Can be a file:// or http:// URL. ### Request Example ```js System.import('file:///Users/name/some-module.js').then(module => { console.log("The loaded module", module); }); ``` ### Response #### Success Response - **module** (object) - The loaded module object. #### Response Example ```js { // module exports } ``` ``` -------------------------------- ### System.entries: Iterate over all registry modules Source: https://github.com/systemjs/systemjs/blob/main/docs/api.md Iterates over all modules in the registry, logging each key and module namespace. ```javascript for (const [id, ns] of System.entries()) { console.log(id); // 'http://localhost/path-to-file.js' console.log(ns); // { exportName: 'value' } }; ``` -------------------------------- ### Create multiple SystemJS instances Source: https://github.com/systemjs/systemjs/blob/main/docs/nodejs.md Create separate SystemJS instances, each with its own import map and module registry. ```js const { System } = require('systemjs'); const system1 = new System.constructor(); const system2 = new System.constructor(); ``` -------------------------------- ### Basic usage: import a module with System.import Source: https://github.com/systemjs/systemjs/blob/main/docs/nodejs.md Require SystemJS and use System.import to load a module from a file URL. The promise resolves with the loaded module. ```js const { System, applyImportMap, setBaseUrl } = require('systemjs'); System.import('file:///Users/name/some-module.js').then(module => { console.log("The loaded module", module); }); ``` -------------------------------- ### System.entries() -> Iterator<[key, module]> Source: https://github.com/systemjs/systemjs/blob/main/docs/api.md Allows you to retrieve all modules in the System registry. Each value will be an array with two values: a key and the module. ```APIDOC ## System.entries() -> Iterator<[key, module]> ### Description Allows you to retrieve all modules in the System registry. Each value will be an array with two values: a key and the module. ### Method Function ### Returns An iterator of [key, module] pairs. ### Example ```js for (const [id, ns] of System.entries()) { console.log(id); // 'http://localhost/path-to-file.js' console.log(ns); // { exportName: 'value' } }; ``` ``` -------------------------------- ### System.get: Retrieve a loaded module from the registry Source: https://github.com/systemjs/systemjs/blob/main/docs/api.md Retrieves a module from the registry by ID and calls an exported function. Module records with an error state return null. ```javascript System.get('http://site.com/normalized/module/name.js').exportedFunction(); ``` -------------------------------- ### System.import(id [, parentURL]) -> Promise(Module) Source: https://github.com/systemjs/systemjs/blob/main/docs/api.md Loads a module by name taking an optional normalized parent URL argument. Promise resolves to the ES module namespace value. ```APIDOC ## System.import(id [, parentURL]) -> Promise(Module) ### Description Loads a module by name taking an optional normalized parent URL argument. Promise resolves to the ES module namespace value. ### Method Function ### Parameters - **id** (string) - Required - The module name to load. - **parentURL** (string) - Optional - A valid URL to use as the parent for resolution. ### Returns Promise that resolves to the ES module namespace value. ### Notes If provided, `parentURL` must be a valid URL, or URL resolution may break. ``` -------------------------------- ### fetch(url, options) -> Promise Source: https://github.com/systemjs/systemjs/blob/main/docs/hooks.md The default fetch implementation used in SystemJS. Can be hooked to enable arbitrary transformation. ```APIDOC ## fetch(url, options) -> Promise ### Description The default fetch implementation used in SystemJS is simply `System.fetch = window.fetch`, which can be further hooked to enable arbitrary transformation. ### Method fetch ### Parameters - **url** (String) - Required - The URL to fetch. - **options** (Object) - Required - Fetch options. ### Returns - **Promise** - A promise that resolves to a Response object. ``` -------------------------------- ### Using import.meta.resolve to resolve dependencies and assets Source: https://github.com/systemjs/systemjs/blob/main/docs/system-register.md Shows how to use import.meta.resolve to resolve import map resolutions or assets. Note that import.meta.resolve currently has no specification or browser implementation and may still change. ```javascript const resolvedDep = await import.meta.resolve('dep'); const localAsset = await import.meta.resolve('./asset.ext'); const depPath = await import.meta.resolve('dep/'); ``` -------------------------------- ### Define an import map for a bare specifier Source: https://github.com/systemjs/systemjs/blob/main/docs/errors.md Add a systemjs-importmap script to map the bare specifier 'vue' to a URL. After this, System.import('vue') resolves to https://unpkg.com/vue. ```html ``` -------------------------------- ### Using import.meta.url to reference assets Source: https://github.com/systemjs/systemjs/blob/main/docs/system-register.md Shows how to use import.meta.url to construct a URL for an asset relative to the current module. This is useful in many module environments. ```javascript const assetUrl = new URL('./asset.ext', import.meta.url); ``` -------------------------------- ### General structure of System.register Source: https://github.com/systemjs/systemjs/blob/main/docs/system-register.md Shows the basic structure of a System.register module, including the dependency array, setters, execute function, and optional metas. The global callback supports CSP policies, and setters push live bindings for performance and circularity handling. ```javascript System.register(['dependency'], function (_export, _context) { var dep; return { setters: [function (_dep) { dep = _dep; }], execute: function () { _export({ name: 'value' }); } }; },/*optional metas*/ [ /*optional meta for dependency*/ {assert: {type: 'javascript'}}, ]); ``` -------------------------------- ### Load System.register modules with script elements Source: https://github.com/systemjs/systemjs/blob/main/README.md Use script tags with type="systemjs-module" to load System.register modules. The src can be a path or an import: prefixed module name. ```html ``` -------------------------------- ### shouldFetch(url) -> Boolean Source: https://github.com/systemjs/systemjs/blob/main/docs/hooks.md Determines if a module should be loaded by adding a ` ``` -------------------------------- ### Import JSON Module with System.import Source: https://github.com/systemjs/systemjs/blob/main/docs/module-types.md Imports a JSON file using System.import and logs the default export as a JavaScript object. ```javascript System.import('file.json').then(function (module) { console.log(module.default); // The json as a js object. }); ``` -------------------------------- ### Conditionally load polyfills for IE11 Source: https://github.com/systemjs/systemjs/blob/main/README.md Load Promise and fetch polyfills only when they are missing. Place this script before the SystemJS script. Uses document.write to inject script tags. ```html ``` -------------------------------- ### Hooking the Loader Source: https://github.com/systemjs/systemjs/blob/main/docs/hooks.md The standard pattern for overriding loader hooks by extending the System.constructor.prototype. ```APIDOC ## Hooking the Loader ### Description The loader is designed to be hookable in a very light-weight way using only function extensions. The standard pattern is to override a hook on `System.constructor.prototype`. ### Pattern ```js const existingHook = System.constructor.prototype.hookName; System.constructor.prototype.hookName = function (args) { return Promise.resolve(existingHook.call(this, args)) .then(function (existingHookResult) { // custom hook here return ...; }); }; ``` ### Notes - Pay attention to the order in which hooks apply. - Keep existing hooks running where they provide necessary functionality. - Some hooks are Promise-based, so Promise chaining needs to be carefully applied only where necessary. ``` -------------------------------- ### System.register(deps, declare) Source: https://github.com/systemjs/systemjs/blob/main/docs/api.md Declaration function for defining modules of the System.register polyfill module format. ```APIDOC ## System.register(deps, declare) ### Description Declaration function for defining modules of the System.register polyfill module format. ### Method Function ### Parameters - **deps** (array) - Required - List of dependency module specifiers. - **declare** (function) - Required - The declare function for the module. ### Notes Named System.register is only supported through the named-register extra. ``` -------------------------------- ### System.set(id, module) -> Module Source: https://github.com/systemjs/systemjs/blob/main/docs/api.md Sets a module in the registry by ID. Note that when using import maps, the id must be a URL. ```APIDOC ## System.set(id, module) -> Module ### Description Sets a module in the registry by ID. Note that when using import maps, the id must be a URL. ### Method Function ### Parameters - **id** (string) - Required - The module ID to set. - **module** (object or Module Namespace) - Required - An object of names to set as named exports, or an existing Module Namespace to use by reference. ### Returns The module that was set. ### Example ```js System.set('http://site.com/normalized/module/name.js', { exportedFunction: value }); ``` ### Remapping with import maps If you want to remap the url to a bare specifier, you can do so with an import map: ```html ``` ``` -------------------------------- ### System.register with import assertions Source: https://github.com/systemjs/systemjs/blob/main/docs/system-register.md Transforms the previous ES module into System.register. Static imports become dependencies with assertion metadata in the third array argument; dynamic imports use $__moduleContext.import with the assert option. ```javascript System.register(['./a.json', 'b', './a.css'], function ($__export, $__moduleContext) { var a, b, c return { setters: [ function (m) { a = m["default"]; }, function (m) { b = m["default"]; }, function (m) { c = m["default"]; } ], execute: async function () { const {d} = await $__moduleContext.import('d') const {e} = await $__moduleContext.import('e', {assert: {type: 'javascript'}}) } }; }, [ {assert: {type: 'json'}}, /*just omit or use undefined if not needed*/ undefined, {assert: {type: 'css'}}, ]); ``` -------------------------------- ### System.has(id) -> Boolean Source: https://github.com/systemjs/systemjs/blob/main/docs/api.md Determine if a given ID is available in the loader registry. Module records with an error state still return true, while in-progress loads return false. ```APIDOC ## System.has(id) -> Boolean ### Description Determine if a given ID is available in the loader registry. Module records that have an error state in the registry still return `true`, while module records with in-progress loads will return `false`. ### Method Function ### Parameters - **id** (string) - Required - The module ID to check. ### Returns Boolean indicating whether the ID is in the registry. ### Example ```js System.has('http://site.com/normalized/module/name.js'); ``` ``` -------------------------------- ### Apply import map with applyImportMap Source: https://github.com/systemjs/systemjs/blob/main/docs/nodejs.md Use applyImportMap to set an import map for a SystemJS instance. Note that calling it multiple times overrides the map, not merges. Shows separate maps for separate instances. ```js const { System, applyImportMap } = require('systemjs'); const path = require('path'); const { pathToFileURL } = require('url'); applyImportMap(System, { imports: { // File loading "module-a": "file:///Users/name/a.js", "module-b": pathToFileURL(path.join(process.cwd(), './b.js')), // Network loading "module-c": "https://example.com/c.js", } }); System.import('module-a'); // Separate import map for separate SystemJS instance const otherSystem = new System.constructor(); applyImportMap(otherSystem, { imports: { "module-a": "file:///Users/name/other-a.js", } }); otherSystem.import('module-a'); ``` -------------------------------- ### Multiple import maps composition Source: https://github.com/systemjs/systemjs/blob/main/docs/import-maps.md Multiple systemjs-importmap scripts are supported, with each successive map composing with the previous one. Existing mappings are replaced. ```html ``` -------------------------------- ### Default createContext Implementation Source: https://github.com/systemjs/systemjs/blob/main/docs/hooks.md The default implementation of the createContext hook, which populates the import.meta for a module. It returns an object containing the url. ```javascript System.constructor.prototype.createContext = function (url) { return { url }; }; ``` -------------------------------- ### System.register module wrapper structure Source: https://github.com/systemjs/systemjs/blob/main/docs/system-register.md The general structure of a System.register module definition. The wrapper takes an array of dependency strings and a declare function that returns an object with setters and an execute function. The optional metas argument provides metadata for dependencies. ```javascript System.register([...deps...], function (_export, _context) { return { setters: [...setters...], execute: function () { } }; }, [...metas...],); ``` -------------------------------- ### applyImportMap(loader, importMap) -> undefined Source: https://github.com/systemjs/systemjs/blob/main/docs/nodejs.md Applies an import map to a SystemJS instance. Calling multiple times completely overrides the previous import map. ```APIDOC ## applyImportMap(loader, importMap) ### Description Applies an import map to a SystemJS instance. Calling multiple times completely overrides the previous import map. ### Method applyImportMap ### Endpoint applyImportMap(loader, importMap) ### Parameters #### Path Parameters - **loader** (object) - Required - The SystemJS instance to apply the import map to. - **importMap** (object) - Required - The import map object with an `imports` property mapping bare specifiers to URLs. ### Request Example ```js applyImportMap(System, { imports: { "module-a": "file:///Users/name/a.js", "module-b": pathToFileURL(path.join(process.cwd(), './b.js')), "module-c": "https://example.com/c.js", } }); ``` ### Response #### Success Response Returns `undefined`. #### Response Example ```js undefined ``` ``` -------------------------------- ### Web Assembly Module Source - wasm-module.wat Source: https://github.com/systemjs/systemjs/blob/main/docs/module-types.md Web Assembly text format source that imports a function and exports another that calls it. ```wat (module (func $exampleImport (import "example" "exampleImport") (param i32) (result i32)) (func $exampleExport (export "exampleExport") (param $value i32) (result i32) get_local $value call $exampleImport ) ) ``` -------------------------------- ### System.set with invalid and valid IDs (W3) Source: https://github.com/systemjs/systemjs/blob/main/docs/errors.md Shows invalid bare specifiers and page-relative URLs, and valid full URLs for System.set. Bare specifiers and page-relative URLs are invalid; full URLs are valid. ```javascript // bare specifiers are invalid System.set('foo', { some: 'value' }); // page-relative URLs are invalid System.set('/foo.js', { some: 'value' }); System.set('./foo.js', { some: 'value' }); // Full urls are valid System.set('http://example.com/foo.js', { some: 'value' }); ``` -------------------------------- ### createScript(url) -> HTMLScriptElement | Promise Source: https://github.com/systemjs/systemjs/blob/main/docs/hooks.md Allows hooking the creation of the ` ``` ```html ``` -------------------------------- ### Webpack output.libraryTarget set to 'system' Source: https://github.com/systemjs/systemjs/blob/main/README.md Required webpack config to compile bundles to System.register format. As of webpack@4.30.0, set output.libraryTarget to 'system'. ```javascript { output: { libraryTarget: 'system', } } ``` -------------------------------- ### Conditionally Load Constructable Style Sheets Polyfill Source: https://github.com/systemjs/systemjs/blob/main/docs/module-types.md Loads the construct-style-sheets-polyfill script for browsers that do not support Constructable Style Sheets. Note: does not work in IE11. ```html ``` -------------------------------- ### Anonymous System.register statement Source: https://github.com/systemjs/systemjs/blob/main/README.md When building System modules, ensure anonymous System.register statements are emitted. These behave like normal ES modules. ```javascript System.register([], function () { ... }); ``` -------------------------------- ### Named System.register statement Source: https://github.com/systemjs/systemjs/blob/main/README.md Named register statements are supported with the named register extension but are typically not recommended for modern module workflows. ```javascript System.register('name', [], function () { ... }); ``` -------------------------------- ### Add named-register extra to fix SystemJS Error #6 Source: https://github.com/systemjs/systemjs/blob/main/docs/errors.md Include the named-register extra script after the SystemJS and AMD extras to resolve Error #6 when using named AMD modules. This is the recommended fix when other causes do not apply. ```html ``` -------------------------------- ### setBaseUrl(loader, url) -> undefined Source: https://github.com/systemjs/systemjs/blob/main/docs/nodejs.md Sets the base URL used for resolving relative module URLs. Defaults to process.cwd(). ```APIDOC ## setBaseUrl(loader, url) ### Description Sets the base URL used for resolving relative module URLs. Defaults to process.cwd(). ### Method setBaseUrl ### Endpoint setBaseUrl(loader, url) ### Parameters #### Path Parameters - **loader** (object) - Required - The SystemJS instance to set the base URL for. - **url** (string) - Required - The base URL to use. Can be a file:// or http:// URL. ### Request Example ```js setBaseUrl(System, 'https://example.com/base/'); setBaseUrl(System, 'file:///Users/name/some-dir/'); ``` ### Response #### Success Response Returns `undefined`. #### Response Example ```js undefined ``` ``` -------------------------------- ### Unreachable external import map (W4) Source: https://github.com/systemjs/systemjs/blob/main/docs/errors.md HTML script tag referencing an unreachable import map, causing warning W4. The import map is skipped and processing continues. ```html // references an unreachable import map ``` -------------------------------- ### Base-level Imports Mapping Source: https://github.com/systemjs/systemjs/blob/main/docs/import-maps.md Defines a single import mapping for the bare specifier 'lodash'. This resolves any import 'lodash' call to the provided path, but does not support submodules like 'lodash/x'. ```html ``` -------------------------------- ### Named AMD module definition using define() Source: https://github.com/systemjs/systemjs/blob/main/docs/errors.md This JavaScript snippet shows a named AMD module called 'my-module-name'. To use named AMD modules without System.import() or with multiple modules per file, include the named-register.js extra to avoid SystemJS warning W6. ```js // A named AMD module called my-module-name define('my-module-name', [], function () {}); ```