From 0a989d96cb1ff34704aa1ee8754d0ab5517ebe38 Mon Sep 17 00:00:00 2001 From: Saikat Mitra Date: Wed, 15 May 2024 17:15:12 +0530 Subject: [PATCH] docs: fix broken links (#555) --- docs/node/cjs.md | 3 +-- docs/node/esm.md | 6 +++++- docs/node/ts-import.md | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/node/cjs.md b/docs/node/cjs.md index b60e40df1..f6eea34f2 100644 --- a/docs/node/cjs.md +++ b/docs/node/cjs.md @@ -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`. @@ -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 diff --git a/docs/node/esm.md b/docs/node/esm.md index f7ffb56c3..b7df389ce 100644 --- a/docs/node/esm.md +++ b/docs/node/esm.md @@ -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 @@ -33,6 +33,7 @@ NODE_OPTIONS='--loader tsx/esm' npx some-binary ## Programmatic API ### Registration & Unregistration + ```js import { register } from 'tsx/esm/api' @@ -44,6 +45,7 @@ unregister() ``` #### Tracking loaded files + Detect files that get loaded with the `onImport` hook: ```ts @@ -56,6 +58,7 @@ register({ ``` #### Tracking loaded files + Detect files that get loaded with the `onImport` hook: ```ts @@ -68,6 +71,7 @@ register({ ``` ### Scoped registration + If you want to register tsx without affecting the environment, you can add a namespace. ```js diff --git a/docs/node/ts-import.md b/docs/node/ts-import.md index 52cb05ffc..1a4c680b3 100644 --- a/docs/node/ts-import.md +++ b/docs/node/ts-import.md @@ -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' @@ -25,7 +24,7 @@ const loaded = await tsImport('./file.ts', import.meta.url) const loadedAgain = await tsImport('./file.ts', import.meta.url) ``` -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 @@ -36,6 +35,7 @@ const loaded = await tsImport('./file.ts', __filename) ``` ## Tracking loaded files + Detect files that get loaded with the `onImport` hook: ```ts