Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tenpamk2/esbuild-typescript-vscode-template

πŸ”° The esbuild & TypeScript template for debugging by VSCode πŸ”°
https://github.com/tenpamk2/esbuild-typescript-vscode-template

Last synced: about 2 months ago
JSON representation

πŸ”° The esbuild & TypeScript template for debugging by VSCode πŸ”°

Awesome Lists containing this project

README

        

# esbuild-typescript-vscode-template

πŸ”° The esbuild & TypeScript template for debugging by VSCode πŸ”°

## πŸ“› How to build

Install requirements including `esbuild` .

```sh
npm install
```

Build the sample TypeScript source.

```sh
npm run build
```

It will generate `dist/index.cjs` .

Run output.
It execute `node dist/index.cjs` .

```sh
npm run exe
```

## πŸ”΄ How to debug by VSCode

### Recommended: auto-build

Start watching.

```sh
npm run watch
```

It will automatically generate the output for every file change.

Set breakpoints anywhere you like.

Press `F5` ( `Debug: continue` ).
It launch `"Launch Program"` in `.vscode/launch.json` .

If it will stop at the breakpoints, the setup is completed.

![sample break points](./images/sample-break-points.png)

### Not recommended: manual-build

Enable the comment-outed lines in `.vscode/launch.json` .

```json
// Enable if you don't use `watch` mode.
// "preLaunchTask": "npm: build-debug",
```

It will execute the build task for each debug ( `F5` ).

This method does not use `watch` mode of esbuild.
This would be useful in some cases. For example, cases where you want to control the build timing.

## πŸ’  Appendix: Application to Node single executable applications

[Node single executable applications](https://nodejs.org/api/single-executable-applications.html)
can use only single JavaScript file.
It cannot use multiple JavaScript files.
And of course, it cannot use the npm packages...

Bundlers can solve this problem by bundle the multiple JavaScript files and npm packages into a single file.
`esbuild` also bundle multiple TypeScript files and npm packages into single JavaScript file❗

This repository helps development of single executable applications by making debug easy❗