Skip to content

Commit 43ca9fe

Browse files
committed
fixup! MDL-87922 [docs] Add guide for JavaScript import maps in Moodle
1 parent 55f86dd commit 43ca9fe

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

docs/guides/javascript/react/importmap.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,16 @@ An import map is a JSON object, embedded in the page as a `<script type="importm
1919
that tells the browser how to resolve bare specifiers used in `import` statements.
2020

2121
```html
22-
<script type="importmap">
23-
{
24-
"imports": {
25-
"@moodle/lms/": "https://example.com/esm/-1/@moodle/lms/",
26-
"@moodlehq/design-system": "https://example.com/esm/-1/@moodlehq/design-system",
27-
"react": "https://example.com/esm/-1/react",
28-
"react/": "https://example.com/esm/-1/react/",
29-
"react-dom": "https://example.com/esm/-1/react-dom"
30-
}
31-
}
32-
</script>
22+
<script type="importmap">{
23+
"imports": {
24+
"@moodle/lms/": "http://localhost/MDL-87922/r.php/core/esm/-1/@moodle/lms/",
25+
"@moodlehq/design-system": "http://localhost/MDL-87922/r.php/core/esm/-1/@moodlehq/design-system",
26+
"react": "http://localhost/MDL-87922/r.php/core/esm/-1/react",
27+
"react/": "http://localhost/MDL-87922/r.php/core/esm/-1/react/",
28+
"react-dom": "http://localhost/MDL-87922/r.php/core/esm/-1/react-dom",
29+
"react-dom/": "http://localhost/MDL-87922/r.php/core/esm/-1/react-dom/"
30+
}
31+
}</script>
3332
```
3433

3534
With this map in place, any ES module on the page can write:
@@ -74,6 +73,7 @@ The following specifiers are registered by default in `add_standard_imports()`:
7473
| `react` | `{loaderBase}react` | `lib/js/bundles/react/react.js` |
7574
| `react/` | `{loaderBase}react/` | `lib/js/bundles/react/` (prefix) |
7675
| `react-dom` | `{loaderBase}react-dom` | `lib/js/bundles/react-dom/react-dom.js` |
76+
| `react-dom/` | `{loaderBase}react-dom/` | `lib/js/bundles/react-dom/` (prefix) |
7777

7878
The `react/` prefix entry covers all sub-specifiers such as `react/jsx-runtime`.
7979

0 commit comments

Comments
 (0)