JoshuaKGoldberg / JoshuaKGoldberg/create-typescript-app

🚀 Feature: Dynamically computed TSDown entry value

Open
#1,931 2 comments 1 reaction 0 assignees View on GitHub
status: in discussion type: feature
Dominant language
TypeScript
Stars
1.4k
Forks
89
Avg merge
1m
Merged PRs (30d)
3

Description

### Bug Report Checklist

- [x] I have pulled the latest `main` branch of the repository.
- [x] I have [searched for related issues](https://github.com/JoshuaKGoldberg/create-typescript-app/issues?q=is%3Aissue) and found none that matched my issue.

### Overview

Splitting out of #1910: right now, the TSup config includes _all_ `src/**/*.ts` files except test files:

https://github.com/JoshuaKGoldberg/create-typescript-app/blob/21b4be0f8ebf3cdf501ca9c4d4af3ef08b690d3d/tsup.config.ts#L7

That presents an edge case for test utility files with names like `data.fakes.ts`. They're not excluded by the `!src/**/*.test.*`, and so are included by the `src/**/*.ts` - even though they shouldn't be in the output package. As a result I've been less willing to write files like that.

The tsup config could in theory be expanded to exclude files with known names like `*.fakes.*`...

```js
entry: ["src/**/*.ts", "!src/**/*.fakes.*", "!src/**/*.test.*"],
```

...but then that establishes a convention that not every package already uses. -1 from me.

I think what we _really_ need here is an `entry` that respects `package.json` `exports`/`main`. I think that could be achieved with some kind of helper library used like:

```js
import { defineConfig } from "tsup";
import { readEntryPoints } from "read-entry-points";

export default defineConfig({
// ...
entry: readEntryPoints(),
// ...
});
```

### Additional Info

I see this as kind of an intermediate step in lieu of / towards #1910. This wouldn't solve the issues around tsup falling out of maintenance. But it would solve the specific issue of out-of-entrypoints modules still being included.

Putting in `status: in discussion` for a bit to let the idea settle. I'm also asking around about #1910 on social media: https://bsky.app/profile/joshuakgoldberg.com/post/3lhgppvnyjc2e, https://fosstodon.org/@JoshuaKGoldberg/113951603816733558.

💖

Contributor guide

Open the contributing guide

Research direction

Start with tsup.config.ts and the package.json exports/main fields, then read the context in #1910. Determine whether a helper or another approach can make the build include only package entry points rather than every src/**/*.ts file; done means out-of-entrypoint modules such as data.fakes.ts are excluded without imposing a new naming convention.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.