Expand description
Module map and module graph.
§Terms
- Module graph: it maintains the relationships between a module and its dependencies tree.
- Module map: it maintains all the dependencies loaded into the js rutime, i.e. the rsvim editor.
§Module
In the most popular js runtime node.js, a module is loaded by the keyword
require (Common JS) or import (ECMAScript Module). And there’re two kinds of imports:
static and dynamic. For example:
Case-1: Static Import
// ES Module
const _ = import "lodash";
// Common JS
const _ = require("lodash");// Case-2: Dynamic Import
// Wait for import complete.
const _ = await import("lodash");
// Trigger callbacks on import complete.
import("lodash")
.then((_) => {})
.catch((err) => {});Static import runs synchronizely, dynamic import runs asynchronizely.
Structs§
- Module
Graph - Module graph.
- Module
Map - Module map. It maintains all the modules inside js runtime, including already resolved and pending fetching.
Enums§
- Import
Kind - Import kind.