Skip to content

Commit

Permalink
docs: add note about interop default
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 authored Oct 5, 2024
1 parent 61891a0 commit 537fa39
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@
- Super slim and zero dependency
- Custom resolve aliases
- Smart syntax detection to avoid extra transforms
- Node.js native require cache integration
- Node.js native `require.cache` integration
- Filesystem transpile with hard disk caches
- ESM Loader support
- JSX support (opt-in)

> [!IMPORTANT]
> To enhance npm compatibility with the introduction of native ESM, jiti `>=2.1` enabled [`interopdefault`](https://github.com/unjs/jiti#interopdefault) using a new Proxy. This may cause behavior changes, especially if you migrated to `2.0.0` earlier, you might need to explicitly use the `.default` value of `jiti()`/`jiti.import()`.
## 💡 Usage

### CLI
Expand Down Expand Up @@ -72,15 +75,15 @@ jiti("./path/to/file.ts");
const resolvedPath = jiti.resolve("./src");
```
You can also pass options as second argument:
You can also pass options as the second argument:
```js
const jiti = createJiti(import.meta.url, { debug: true });
```
### Register global ESM loader
You can globally register jiti using [global hooks](https://nodejs.org/api/module.html#initialize). (important: Requires Node.js > 20)
You can globally register jiti using [global hooks](https://nodejs.org/api/module.html#initialize). (Important: Requires Node.js > 20)
```js
import "jiti/register";
Expand Down Expand Up @@ -116,7 +119,7 @@ Filesystem source cache (enabled by default)
By default (when is `true`), jiti uses `node_modules/.cache/jiti` (if exists) or `{TMP_DIR}/jiti`.
**Note:** It is recommended to keep this option enabled for better performance.
**Note:** It is recommended that this option be enabled for better performance.
### `moduleCache`
Expand Down

0 comments on commit 537fa39

Please sign in to comment.