Skip to content

Commit

Permalink
use $:import name for importing ES Modules
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Nov 1, 2024
1 parent 4a52c97 commit d070973
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/docs/lips/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -1007,13 +1007,13 @@ LIPS Scheme runs in ES Module, but `import` is reserved for experimental R7RS mo
to import module that is ESM only. You need to access JavaScript dynamic import. But `global.import` is not defined. If you want to define JavaScript dynamic import, you can use code:

```scheme
(define import (global.eval "(x) => import(x)"))
(define $:import (global.eval "(x) => import(x)"))
```

You can use this function like this:

```javascript
(--> (import "fs/promises") (readFile "README.md" "utf8"))
(--> ($:import "fs/promises") (readFile "README.md" "utf8"))
```
But it will also work with ESM only module that can't be imported with `require`.
Expand Down

0 comments on commit d070973

Please sign in to comment.