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

[Docs] Clarify programmatic usage with ESM support #1863

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion website/docs/performance.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ These tricks will make ts-node faster.

## Skip typechecking

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.
It is often better to typecheck as part of your tests or linting. You can use `tsc --noEmit` to do this. In these cases, ts-node can skip typechecking making it much faster.

To skip typechecking in ts-node, do one of the following:

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

## With typechecking

If you absolutely must use ts-node for typechecking:

* Avoid dynamic `require()` which may trigger repeated typechecking; prefer `import`
* Try with and without `--files`; one may be faster depending on your project
* Check `tsc --showConfig`; make sure all executed files are included
Expand Down
2 changes: 2 additions & 0 deletions website/docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,6 @@ node --loader ts-node/esm --inspect ./index.ts

You can require ts-node and register the loader for future requires by using `require('ts-node').register({ /* options */ })`.

Note that this does not support ESM, node currently does not offer a way to programmatically add hooks when using ES modules. If you want to programmatically use ts-node with ESM support you need to write your own module loader which wraps ts-node and then invoke it in one of the ways described above.

Check out our [API](./api.md) for more features.