Skip to content

Commit

Permalink
docs: add explanation about local debugging using ESM and typescript …
Browse files Browse the repository at this point in the history
…paths
  • Loading branch information
Avivbens committed Jun 7, 2024
1 parent 3497d03 commit 510044e
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions docs/app/setup/runtime-explain.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,44 @@ In order to use `fast-alfred` runtime, you have to configure your package as ESM
Add `"type": "module"` to your `package.json` file.
:::

## Local Debugging

Sometimes, we just want to run scripts locally, and put some debugger breakpoints to understand the flow.

In case you're using [`typescript` paths](https://www.typescriptlang.org/tsconfig/#paths), you might need to convert them after being built (without `fast-alfred` bundler).

::: warning NOTE :rotating_light:
You need to install the `tsc-alias` package to convert the paths

```bash
npm i -D tsc-alias
```

:::

Your `package.json` should have the following script:

```json
{
"scripts": {
"build": "tsc -p tsconfig.json && tsc-alias -p tsconfig.json"
}
}
```

Then, you can run the following command:

```bash
node ./dist/your-script-under-main.js
```

::: tip TIP :zap:
The code above is an example of how to trigger your Node.js script in a local environment,
right from your IDE.

**You can place your breakpoints and debug your script from your .ts file.**
:::

## How It Works

At build time, an additional asset, named `run-node.sh` would be attached to the workflow, under the `assets` directory.
Expand Down

0 comments on commit 510044e

Please sign in to comment.