diff --git a/website/docs/configuration.md b/website/docs/configuration.md index 130a69eba..9e6f9b948 100644 --- a/website/docs/configuration.md +++ b/website/docs/configuration.md @@ -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": { diff --git a/website/docs/options.md b/website/docs/options.md index 2ddf09fb9..0c59f203b 100644 --- a/website/docs/options.md +++ b/website/docs/options.md @@ -328,7 +328,7 @@ ts-node --scope Scope compiler to files within `scopeDir`. Anything outside this directory is ignored. -*Default: `false`
+*Default:* `false`
*Environment:* `TS_NODE_SCOPE` ### scopeDir @@ -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: @@ -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`
diff --git a/website/docs/performance.md b/website/docs/performance.md index aebc50def..21704761e 100644 --- a/website/docs/performance.md +++ b/website/docs/performance.md @@ -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 diff --git a/website/docs/quick-start.md b/website/docs/quick-start.md new file mode 100644 index 000000000..efbf5affb --- /dev/null +++ b/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: + +``` + +```