Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create "Quick start" page #1776

Draft
wants to merge 8 commits into
base: docs
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions website/docs/configuration.md
Expand Up @@ -27,8 +27,8 @@ You can use this sample configuration as a starting point:

```json title="tsconfig.json"
{
// This is an alias to @tsconfig/node12: https://github.com/tsconfig/bases
"extends": "ts-node/node12/tsconfig.json",
// This is an alias to @tsconfig/node16: https://github.com/tsconfig/bases
"extends": "ts-node/node16/tsconfig.json",

// Most ts-node options can be specified here using their programmatic names.
"ts-node": {
Expand Down
14 changes: 8 additions & 6 deletions website/docs/options.md
Expand Up @@ -328,7 +328,7 @@ ts-node --scope

Scope compiler to files within `scopeDir`. Anything outside this directory is ignored.

*Default: `false` <br/>
*Default:* `false` <br/>
*Environment:* `TS_NODE_SCOPE`

### scopeDir
Expand Down Expand Up @@ -374,10 +374,12 @@ Disable top-level await in REPL. Equivalent to node's [`--no-experimental-repl-

Enable experimental hooks that re-map imports and require calls to support:

* resolves `.js` to `.ts`, so that `import "./foo.js"` will execute `foo.ts`
* resolves `.cjs` to `.cts`
* resolves `.mjs` to `.mts`
* allows including file extensions in CommonJS, for consistency with ESM where this is often mandatory
* remapping extensions, e.g. so that `import "./foo.js"` will execute `foo.ts`. Currently the following extensions will be mapped:
* `.js` to `.ts`, `.tsx`, or `.jsx`
* `.cjs` to `.cts`
* `.mjs` to `.mts`
* `.jsx` to `.tsx`
* including file extensions in CommonJS, for consistency with ESM where this is often mandatory

In the future, this hook will also support:

Expand All @@ -397,7 +399,7 @@ ts-node --experimentalSpecifierResolution node
```

Like node's [`--experimental-specifier-resolution`](https://nodejs.org/dist/latest-v18.x/docs/api/esm.html#customizing-esm-specifier-resolution-algorithm), but can also be set in your `tsconfig.json` for convenience.
Requires `esm` to be enabled.
Requires [`esm`](#esm) to be enabled.

*Default:* `explicit`<br/>

Expand Down
4 changes: 2 additions & 2 deletions website/docs/performance.md
Expand Up @@ -8,9 +8,9 @@ These tricks will make ts-node faster.

It is often better to use `tsc --noEmit` to typecheck as part of your tests or linting. In these cases, ts-node can skip typechecking.

* Enable [swc](./transpilers.md#swc)
* Enable [swc](./swc.md)
* This is by far the fastest option
* Enable [`transpileOnly`](./options.md) to skip typechecking without swc
* Enable [`transpileOnly`](./options.md#transpileonly) to skip typechecking without swc

## With typechecking

Expand Down
45 changes: 45 additions & 0 deletions website/docs/quick-start.md
@@ -0,0 +1,45 @@
---
title: Quick start
---

This guide offers an opinionated configuration for a modern, fast ts-node project.

You can also view this sample project in our examples repository: TODO LINK

Install dependencies:

```
npm i -D ts-node typescript @types/node @tsconfig/node18 @swc/core
```

Create `tsconfig.json`:

```jsonc
{
// Recommendations for a node v18 project: https://github.com/tsconfig/bases
"extends": "@tsconfig/node18/tsconfig.json",
"ts-node": {
// Skip typechecking and use swc for fast startup.
// We recommend running `tsc --noEmit` for typechecking.
// Remove if you really want ts-node to do your typechecking.
"swc": true,
// Enable full ESM support.
// You can remove this if your project is still fully CommonJS
"esm": true,
// Enable full NodeNext support.
"experimentalResolver": true
},
"compilerOptions": {
// Explicitly listing your global types will speed up `tsc`.
"types": ["node"],
// Full support for cts, mts, cjs, mjs, and package.json "type"
"module": "NodeNext"
}
}
```

Create entrypoint:

```

```