Skip to content

Commit 130724c

Browse files
feat: use tsup to build lib/ (#640)
<!-- 👋 Hi, thanks for sending a PR to template-typescript-node-package! 💖. Please fill out all fields below and make sure each item is true and [x] checked. Otherwise we may not be able to review your PR. --> ## PR Checklist - [x] Addresses an existing open issue: fixes #632 - [x] That issue was marked as [`status: accepting prs`](https://github.com/JoshuaKGoldberg/template-typescript-node-package/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22) - [x] Steps in [CONTRIBUTING.md](https://github.com/JoshuaKGoldberg/template-typescript-node-package/blob/main/.github/CONTRIBUTING.md) were taken ## Overview Bumps to the latest version of `tsup` to include egoist/tsup#934. Adds an `entry` for all non-`test` files in `src/` so that the existing directory structure is maintained.
1 parent 0fca978 commit 130724c

File tree

8 files changed

+513
-14
lines changed

8 files changed

+513
-14
lines changed

.github/DEVELOPMENT.md

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,17 @@ pnpm install
1313
1414
## Building
1515

16-
Run [TypeScript](https://typescriptlang.org) locally to type check and build source files from `src/` into output files in `lib/`:
16+
Run [[**tsup**](https://tsup.egoist.dev) locally to build source files from `src/` into output files in `lib/`:
1717

1818
```shell
19-
pnpm build --watch
19+
pnpm build
2020
```
2121

22-
You should also see suggestions from TypeScript in your editor.
22+
Add `--watch` to run the builder in a watch mode that continuously cleans and recreates `lib/` as you save files:
23+
24+
```shell
25+
pnpm build --watch
26+
```
2327

2428
## Formatting
2529

@@ -67,6 +71,22 @@ Calls to `console.log`, `console.warn`, and other console methods will cause a t
6771
This repository includes a [VS Code launch configuration](https://code.visualstudio.com/docs/editor/debugging) for debugging unit tests.
6872
To launch it, open a test file, then run _Debug Current Test File_ from the VS Code Debug panel (or press F5).
6973

74+
## Type Checking
75+
76+
You should be able to see suggestions from [TypeScript](https://typescriptlang.org) in your editor for all open files.
77+
78+
However, it can be useful to run the TypeScript command-line (`tsc`) to type check all files in `src/`:
79+
80+
```shell
81+
pnpm tsc
82+
```
83+
84+
Add `--watch` to keep the type checker running in a watch mode that updates the display as you save files:
85+
86+
```shell
87+
pnpm tsc --watch
88+
```
89+
7090
## The Hydration Script
7191

7292
This template's "hydration" script is located in `src/hydrate/`.

.github/workflows/tsc.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
jobs:
2+
type_check:
3+
runs-on: ubuntu-latest
4+
steps:
5+
- uses: actions/checkout@v3
6+
- uses: ./.github/actions/prepare
7+
- run: pnpm tsc
8+
9+
name: Type Check
10+
11+
on:
12+
pull_request: ~
13+
push:
14+
branches:
15+
- main

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ It sets up the following tooling for you:
4040
- [**Prettier**](https://prettier.io): Opinionated formatting for code, run on file save and as a Git commit hook via [husky](https://typicode.github.io/husky) and [lint-staged](https://github.com/okonet/lint-staged).
4141
- [**release-it**](https://github.com/release-it/release-it): Generates changelogs, bumps the package version, and publishes to GitHub and npm based on [conventional commits](https://www.conventionalcommits.org).
4242
- [**Renovate**](https://docs.renovatebot.com): Keeps dependencies up-to-date with PRs, configured to wait a few days after each update for safety.
43+
- [**tsup**](https://tsup.egoist.dev): Builds output definitions and JavaScript files using [esbuild](https://esbuild.github.io).
4344
- [**TypeScript**](https://typescriptlang.org): A typed superset of JavaScript, configured with strict compiler options.
4445
- [**Vitest**](https://vitest.dev): Fast unit tests, configured with coverage tracking and [console-fail-test](https://github.com/JoshuaKGoldberg/console-fail-test).
4546

cspell.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"outro",
2424
"packagejson",
2525
"quickstart",
26+
"tsup",
2627
"Unstaged",
2728
"wontfix"
2829
]

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"README.md"
2323
],
2424
"scripts": {
25-
"build": "tsc",
25+
"build": "tsup",
2626
"format": "prettier \"**/*\" --ignore-unknown",
2727
"format:write": "pnpm format --write",
2828
"hydrate:test": "node script/hydrate-test-e2e.js",
@@ -60,6 +60,7 @@
6060
"@types/eslint": "^8.37.0",
6161
"@types/git-url-parse": "^9.0.1",
6262
"@types/js-yaml": "^4.0.5",
63+
"@types/node": "^20.4.8",
6364
"@types/prettier": "^2.7.2",
6465
"@typescript-eslint/eslint-plugin": "^6.0.0",
6566
"@typescript-eslint/parser": "^6.0.0",
@@ -96,6 +97,7 @@
9697
"release-it": "^16.0.0",
9798
"sentences-per-line": "^0.2.1",
9899
"should-semantic-release": "^0.1.1",
100+
"tsup": "^7.2.0",
99101
"tsx": "^3.12.7",
100102
"typescript": "^5.0.4",
101103
"vitest": "^0.34.0",

0 commit comments

Comments
 (0)