Skip to content

Commit

Permalink
docs: fix broken links (#555)
Browse files Browse the repository at this point in the history
  • Loading branch information
saikatmitra91 committed May 15, 2024
1 parent e2afc60 commit 0a989d9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 1 addition & 2 deletions docs/node/cjs.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Only CommonJS mode

Node.js runs files in CommonJS mode when the file extension is `.cjs` (or `.cts` if TypeScript), or `.js` when [`package.json#type`](https://nodejs.org/api/packages.html#type) is undefined or set to `commonjs`.
Expand All @@ -8,7 +7,7 @@ This section is only for adding tsx in CommonJS mode (doesn't affect `.mjs` or `
::: warning Not for 3rd-party packages
This enhances the entire runtime so it may not be suitable for loading TypeScript files from a 3rd-party package as it may lead to unexpected behavior in user code.

For importing TypeScript files in CommonJS mode without affecting the environment, see [`tsx.require()`](http://localhost:5173/node/tsx-require).
For importing TypeScript files in CommonJS mode without affecting the environment, see [`tsx.require()`](/node/tsx-require).
:::

## Command-line API
Expand Down
6 changes: 5 additions & 1 deletion docs/node/esm.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This section is only for adding tsx in Module mode (doesn't affect `.cjs` or `.c
::: warning Not for 3rd-party packages
This enhances the entire runtime so it may not be suitable for loading TypeScript files from a 3rd-party package as it may lead to unexpected behavior in user code.

For importing TypeScript files in Module mode without affecting the environment, see the *Scoped registration* section below or [`tsImport()`](http://localhost:5173/node/ts-import).
For importing TypeScript files in Module mode without affecting the environment, see the _Scoped registration_ section below or [`tsImport()`](/node/ts-import).
:::

## Command-line API
Expand All @@ -33,6 +33,7 @@ NODE_OPTIONS='--loader tsx/esm' npx some-binary
## Programmatic API

### Registration & Unregistration

```js
import { register } from 'tsx/esm/api'

Expand All @@ -44,6 +45,7 @@ unregister()
```

#### Tracking loaded files

Detect files that get loaded with the `onImport` hook:

```ts
Expand All @@ -56,6 +58,7 @@ register({
```

#### Tracking loaded files

Detect files that get loaded with the `onImport` hook:

```ts
Expand All @@ -68,6 +71,7 @@ register({
```

### Scoped registration

If you want to register tsx without affecting the environment, you can add a namespace.

```js
Expand Down
4 changes: 2 additions & 2 deletions docs/node/ts-import.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ CommonJS files are currently not enhanced due to this [Node.js bug](https://gith

## ESM usage


```js
import { tsImport } from 'tsx/esm/api'

Expand All @@ -25,7 +24,7 @@ const loaded = await tsImport('./file.ts', import.meta.url)
const loadedAgain = await tsImport('./file.ts', import.meta.url)

Check warning on line 24 in docs/node/ts-import.md

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

'loadedAgain' is assigned a value but never used

Check warning on line 24 in docs/node/ts-import.md

View workflow job for this annotation

GitHub Actions / Release

'loadedAgain' is assigned a value but never used
```
If you'd like to leverage module caching, see the [ESM scoped registration](http://localhost:5173/node/esm#scoped-registration) section.
If you'd like to leverage module caching, see the [ESM scoped registration](/node/esm#scoped-registration) section.
## CommonJS usage
Expand All @@ -36,6 +35,7 @@ const loaded = await tsImport('./file.ts', __filename)
```
## Tracking loaded files
Detect files that get loaded with the `onImport` hook:
```ts
Expand Down

0 comments on commit 0a989d9

Please sign in to comment.