Skip to content

Commit fba1cc1

Browse files
cspotcodewebstrandsheeit
authored
Docs merge for 10.5.0 (#1631)
* Note `skip-ignore` for "Skipping `node_modules`" (#1553) * 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 <[email protected]> * Passing arguments in shebang on Linux (env -S) (#1545) * Passing arguments in shebang on Linux (env -S) It is possible to pass arguments into commands in the shebang on Linux using the env(1) -S option. * fix * fix * fix Co-authored-by: Andrew Bradley <[email protected]> * link from readme logo to website (#1604) Co-authored-by: webstrand <[email protected]> Co-authored-by: wmb <[email protected]>
1 parent db6f850 commit fba1cc1

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

website/docs/how-it-works.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,16 @@ Vanilla `node` loads `.js` by reading code from disk and executing it. Our hook
1616
1717
## Skipping `node_modules`
1818

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

2121
1. Modules should always be published in a format node.js can consume
2222
2. Transpiling the entire dependency tree will make your project slower
2323
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
2424

25+
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.
26+
27+
## Skipping pre-compiled TypeScript
28+
29+
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.
30+
31+
To force ts-node to import the TypeScript source, not the precompiled JavaScript, use [`--preferTsExts`](./options#transpilation).

website/docs/usage.md

+17-4
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,27 @@ ts-node-cwd script.ts
3535
console.log("Hello, world!")
3636
```
3737

38-
Passing CLI arguments via shebang is allowed on Mac but not Linux. For example, the following will fail on Linux:
38+
Passing options via shebang requires the [`env -S` flag](https://manpages.debian.org/bullseye/coreutils/env.1.en.html#S), which is available on recent versions of `env`. ([compatibility](https://github.com/TypeStrong/ts-node/pull/1448#issuecomment-913895766))
3939

40+
```typescript
41+
#!/usr/bin/env -S ts-node --files
42+
// This shebang works on Mac and Linux with newer versions of env
43+
// Technically, Mac allows omitting `-S`, but Linux requires it
4044
```
41-
#!/usr/bin/env ts-node --files
42-
// This shebang is not portable. It only works on Mac
45+
46+
To write scripts with maximum portability, [specify all options in your `tsconfig.json`](./configuration#via-tsconfigjson-recommended) and omit them from the shebang.
47+
48+
```typescript
49+
#!/usr/bin/env ts-node
50+
// This shebang works everywhere
4351
```
4452

45-
Instead, specify all ts-node options in your `tsconfig.json`.
53+
To test your version of `env` for compatibility:
54+
55+
```shell
56+
# Note that these unusual quotes are necessary
57+
/usr/bin/env --debug '-S echo foo bar'
58+
```
4659

4760
## Programmatic
4861

website/readme-sources/prefix.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ You can build the readme with this command:
1414
cd website && yarn build-readme
1515
-->
1616

17-
# ![TypeScript Node](logo.svg?sanitize=true)
17+
# [![TypeScript Node](logo.svg?sanitize=true)](https://typestrong.org/ts-node)
1818

1919
[![NPM version](https://img.shields.io/npm/v/ts-node.svg?style=flat)](https://npmjs.org/package/ts-node)
2020
[![NPM downloads](https://img.shields.io/npm/dm/ts-node.svg?style=flat)](https://npmjs.org/package/ts-node)

0 commit comments

Comments
 (0)