Skip to content

Commit

Permalink
Note skip-ignore for "Skipping node_modules" (#1553)
Browse files Browse the repository at this point in the history
* Note `skip-ignore` for "Skipping `node_modules`"

* Remove spurious duplication

* update

* revert changes to readme; readme is built from docs/

* more wordsmithing

* more tweaks

Co-authored-by: Andrew Bradley <cspotcode@gmail.com>
  • Loading branch information
webstrand and cspotcode authored Jan 21, 2022
1 parent bc03a3e commit 56638fe
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion website/docs/how-it-works.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,16 @@ Vanilla `node` loads `.js` by reading code from disk and executing it. Our hook
## Skipping `node_modules`

By default, **TypeScript Node** avoids compiling files in `/node_modules/` for three reasons:
By default, ts-node avoids compiling files in `/node_modules/` for three reasons:

1. Modules should always be published in a format node.js can consume
2. Transpiling the entire dependency tree will make your project slower
3. Differing behaviours between TypeScript and node.js (e.g. ES2015 modules) can result in a project that works until you decide to support a feature natively from node.js

If you need to import uncompiled TypeScript in `node_modules`, use [`--skipIgnore`](./options#transpilation) or [`TS_NODE_SKIP_IGNORE`](./options#transpilation) to bypass this restriction.

## Skipping pre-compiled TypeScript

If a compiled JavaScript file with the same name as a TypeScript file already exists, the TypeScript file will be ignored. ts-node will import the pre-compiled JavaScript.

To force ts-node to import the TypeScript source, not the precompiled JavaScript, use [`--preferTsExts`](./options#transpilation).

0 comments on commit 56638fe

Please sign in to comment.