Skip to content

Commit 79dd78d

Browse files
committed
Readme
1 parent 8231dc6 commit 79dd78d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,8 @@ While it is ideal, the luxury of having full control over the application is not
2929
</script>
3030
```
3131

32-
## Solutions
33-
3432
### `dynamic-importmap` solution
3533

36-
Note that `dynamic-importmap` is meant to be a last resort (e.g., after considering the alternatives listed below).
37-
As noted by the WICG (quoted above), import maps should ideally be defined at the application level using `<script type="importmap"/>` to ensure that common modules can be shared.
38-
3934
```html
4035
<script type="module">
4136
import { importWithMap } from 'https://unpkg.com/[email protected]';
@@ -54,6 +49,11 @@ As noted by the WICG (quoted above), import maps should ideally be defined at th
5449
</script>
5550
```
5651

52+
Note that `dynamic-importmap` is meant to be a last resort (e.g., after considering the alternative solutions below).
53+
As noted by the WICG (quoted above), import maps should ideally be defined at the application level using `<script type="importmap"/>` to ensure that common modules can be shared.
54+
55+
## Alternative solutions
56+
5757
### ESM-aware CDN solution
5858

5959
An alternate solution is to use a CDN such as [esm.sh](https://esm.sh/) which can perform bare import specifier rewriting on the server side.
@@ -122,7 +122,7 @@ Just kidding :laughing:
122122

123123
A common practice is to publish a React component library to NPM as ESM in which `react` and `react-dom` have been "externalized" and kept as bare import specifiers.
124124
Using `dynamic-importmap`, this component library can be dynamically imported from a regular CDN (e.g., [unpkg](https://unpkg.com/)), without having full control over the importmaps on the page.
125-
For example, such a React component library might need to be imported into an ES module that will run in a Jupyter notebook with [anywidget](https://github.com/manzt/anywidget).
125+
For example, such a React component library might need to be imported into an ES module that will run in a Jupyter notebook with [anywidget](https://github.com/manzt/anywidget) or an R [htmlwidget](https://www.htmlwidgets.org/develop_intro.html#javascript-binding).
126126

127127
```html
128128
<div id="root"></div>

0 commit comments

Comments
 (0)