Skip to content

Commit

Permalink
final fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cspotcode committed Mar 10, 2022
1 parent 6e4dafd commit 3f2bbdf
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
14 changes: 12 additions & 2 deletions website/docs/recipes/npx-and-yarn-dlx.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ title: npx and yarn dlx

Using [`npx`](https://docs.npmjs.com/cli/v8/commands/npx) or [`yarn dlx`](https://yarnpkg.com/cli/dlx) is a great ways to publish reusable TypeScript tools to GitHub without precompiling or packaging.

Check out our working example: [TypeStrong/ts-node-npx-example](https://github.com/TypeStrong/ts-node-npx-example)

```shell
npx typestrong/ts-node-npx-demo --help
npx typestrong/ts-node-npx-demo --first Arthur --last Dent
npx typestrong/ts-node-npx-example --help
npx typestrong/ts-node-npx-example --first Arthur --last Dent
```

TODO publish demo and link to it
Expand All @@ -15,6 +17,8 @@ TODO test demo:
- try running demo
- does ts-node need to be installed globally?

This boilerplate is a good starting point:

```json title="package.json"
{
"bin": "./cli.ts",
Expand All @@ -41,3 +45,9 @@ TODO test demo:

console.log("Hello world!")
```

If you require native ESM support, use `ts-node-esm` in your shebang and follow the configuration instructions for ESM: [Native ECMAScript modules](../commonjs-vs-native-ecmascript-modules.md#native-ecmascript-modules)

```typescript twoslash title="cli.ts"
#!/usr/bin/env ts-node-esm
```
10 changes: 7 additions & 3 deletions website/docs/scope.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ title: Ignored files
---

ts-node transforms certain files and ignores others. We refer to this mechanism as "scoping." There are various
options to configure scope so that ts-node transforms the files in your project and ignores others.
options to configure scoping, so that ts-node transforms only the files in your project.

> **Note:** an ignored file can still be executed by node.js. Ignoring a file means we do not transform it from TypeScript into JavaScript.
> **Warning:**
>
> An ignored file can still be executed by node.js. Ignoring a file means we do not transform it from TypeScript into JavaScript, but it does not prevent execution.
>
> If a file requires transformation but is ignored, node may either fail to resolve it or attempt to execute it as vanilla JavaScript. This may cause syntax errors or other failures, because node does not understand TypeScript type syntax nor bleeding-edge ECMAScript features.
Expand All @@ -15,7 +17,9 @@ options to configure scope so that ts-node transforms the files in your project

`.tsx` and `.jsx` are only transformed when [`jsx`](https://www.typescriptlang.org/docs/handbook/jsx.html) is enabled.

> **Warning:** When ts-node is used with `allowJs`, _all_ non-ignored JavaScript files are transformed by ts-node.
> **Warning:**
>
> When ts-node is used with `allowJs`, _all_ non-ignored JavaScript files are transformed by ts-node.
## Skipping `node_modules`

Expand Down
2 changes: 1 addition & 1 deletion website/docs/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,4 @@ When executing TypeScript with `npx` or `yarn dlx`, the code resides within a te

The contents of `node_modules` are ignored by default. If execution fails, enable [`skipIgnore`](./options.md#skipignore).

See also: [npx and yarn dlx](./recipes/npx-and-yarn-dlx.md)
<!--See also: [npx and yarn dlx](./recipes/npx-and-yarn-dlx.md)-->
2 changes: 1 addition & 1 deletion website/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module.exports = {
collapsed: false,
items: [
'recipes/watching-and-restarting',
'recipes/npx-and-yarn-dlx',
// 'recipes/npx-and-yarn-dlx',
'recipes/ava',
'recipes/gulp',
'recipes/intellij',
Expand Down

0 comments on commit 3f2bbdf

Please sign in to comment.