You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can also import JavaScript from local ES modules.
15
+
You can also import JavaScript from local ES modules. For example, if this is `foo.js`:
16
16
17
17
```js no-run
18
+
exportconstfoo=42;
19
+
```
20
+
21
+
Then you can say
22
+
23
+
```js show
18
24
import {foo} from"./foo.js"
19
25
```
20
26
27
+
and the imported value of `foo` is: ${foo}.
28
+
21
29
This allows you to move code out of Markdown and into vanilla JavaScript files that can be shared by multiple pages — or even another application. And you can write tests for your code.
22
30
23
31
TK There is a [bug](https://github.com/observablehq/cli/issues/115) where npm protocol imports don’t work from local ES modules.
0 commit comments