Skip to content

Commit 524cb77

Browse files
committed
docs(cjs): add compilation caveats
1 parent 7f8a051 commit 524cb77

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

docs/dev-api/register-cjs.md

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
The CommonJS Register API allows you to manually register the enhancement at runtime. But note, this only affects CommonJS modules (`.cjs`/`.cts`, and `.js`/`.ts` when `package.json#type` is unset or `commonjs`).
44

5+
::: warning Caveats
6+
7+
- `import()` calls in the loaded files are not enhanced because they're handled by Node's ESM hook. Use with the [`ESM Register API`](/dev-api/register-esm).
8+
- Because it compiles ESM syntax to run in CommonJS mode, top-level await is not supported
9+
:::
10+
511
## Usage
612
```js
713
const tsx = require('tsx/cjs/api')

docs/dev-api/tsx-require.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Note, the current file path must be passed in as the second argument to resolve
88

99
::: warning Caveats
1010

11-
- `import()` calls in the loaded files are not enhanced.
11+
- `import()` calls in the loaded files are not enhanced. Use [`tsImport()`](/dev-api/ts-import) instead.
1212
- Because it compiles ESM syntax to run in CommonJS mode, top-level await is not supported
1313
:::
1414

0 commit comments

Comments
 (0)