From cc0ca8b555ef88b3401cf8eef7bf22cd57f959fa Mon Sep 17 00:00:00 2001 From: Andrew Bradley Date: Sat, 21 May 2022 15:00:34 -0400 Subject: [PATCH 1/8] Update options.md (#1768) --- website/docs/options.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/website/docs/options.md b/website/docs/options.md index 2ddf09fb9..17604df29 100644 --- a/website/docs/options.md +++ b/website/docs/options.md @@ -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: From 88372160ac6e1c869fbb127f9ec23122113b9dfb Mon Sep 17 00:00:00 2001 From: Andrew Bradley Date: Sat, 21 May 2022 15:55:13 -0400 Subject: [PATCH 2/8] Update options.md --- website/docs/options.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/options.md b/website/docs/options.md index 17604df29..192b7ea4c 100644 --- a/website/docs/options.md +++ b/website/docs/options.md @@ -399,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`
From b9c4ea219f7bf4f14258939483eae17a6587dc11 Mon Sep 17 00:00:00 2001 From: Andrew Bradley Date: Sat, 21 May 2022 16:05:01 -0400 Subject: [PATCH 3/8] Update options.md --- website/docs/options.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/options.md b/website/docs/options.md index 192b7ea4c..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 From bf5d7d816f86b21ddfac6af13a4f5013ff41c4de Mon Sep 17 00:00:00 2001 From: Andrew Bradley Date: Thu, 26 May 2022 13:46:17 -0400 Subject: [PATCH 4/8] Update configuration.md --- website/docs/configuration.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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": { From ab373d9e3d78f65a22115f2212e23f5ad27042ee Mon Sep 17 00:00:00 2001 From: Andrew Bradley Date: Thu, 26 May 2022 13:51:46 -0400 Subject: [PATCH 5/8] Update performance.md --- website/docs/performance.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 From df81c763285962e69ff1d3f011ad265fe40fcc1c Mon Sep 17 00:00:00 2001 From: Andrew Bradley Date: Thu, 26 May 2022 14:17:38 -0400 Subject: [PATCH 6/8] Create quick-start.md --- website/docs/quick-start.md | 44 +++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 website/docs/quick-start.md diff --git a/website/docs/quick-start.md b/website/docs/quick-start.md new file mode 100644 index 000000000..d2e7a106b --- /dev/null +++ b/website/docs/quick-start.md @@ -0,0 +1,44 @@ +--- +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 +{ + "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 global types will speed up `tsc`. + "types": ["node"], + // Full support for cts, mts, cjs, mjs, and package.json "type" + "module": "NodeNext" + } +} +``` + +Create entrypoint: + +``` + +``` From fada2bbf7b1541805446bc394077d04e749f5798 Mon Sep 17 00:00:00 2001 From: Andrew Bradley Date: Thu, 26 May 2022 14:23:36 -0400 Subject: [PATCH 7/8] Update quick-start.md --- website/docs/quick-start.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/website/docs/quick-start.md b/website/docs/quick-start.md index d2e7a106b..32c141897 100644 --- a/website/docs/quick-start.md +++ b/website/docs/quick-start.md @@ -1,6 +1,4 @@ ---- -title: Quick start ---- +# Quick Start This guide offers an opinionated configuration for a modern, fast ts-node project. @@ -16,6 +14,7 @@ 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. @@ -29,7 +28,7 @@ Create `tsconfig.json`: "experimentalResolver": true }, "compilerOptions": { - // Explicitly listing global types will speed up `tsc`. + // Explicitly listing your global types will speed up `tsc`. "types": ["node"], // Full support for cts, mts, cjs, mjs, and package.json "type" "module": "NodeNext" From 5d99b39b4292ecb2c241a4a30c43084dd3319bb9 Mon Sep 17 00:00:00 2001 From: Andrew Bradley Date: Thu, 26 May 2022 14:24:03 -0400 Subject: [PATCH 8/8] Update quick-start.md --- website/docs/quick-start.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/website/docs/quick-start.md b/website/docs/quick-start.md index 32c141897..efbf5affb 100644 --- a/website/docs/quick-start.md +++ b/website/docs/quick-start.md @@ -1,4 +1,6 @@ -# Quick Start +--- +title: Quick start +--- This guide offers an opinionated configuration for a modern, fast ts-node project.