Skip to content

Commit 45a47bd

Browse files
docs: update publish and vite docs (#330)
* WIP * Update docs
1 parent 0607b12 commit 45a47bd

File tree

10 files changed

+61
-37
lines changed

10 files changed

+61
-37
lines changed

.github/workflows/autofix.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: Setup Tools
2525
uses: ./.github/setup
2626
- name: Fix formatting
27-
run: pnpm run prettier:write
27+
run: pnpm run format
2828
- name: Apply fixes
2929
uses: autofix-ci/action@635ffb0c9798bd160680f18fd73371e355b85f27
3030
with:

.prettierignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,5 @@
33
**/.svelte-kit
44
**/coverage
55
**/dist
6-
**/docs
76
**/snap
87
pnpm-lock.yaml

docs/ci-cd.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ title: CI/CD
66
## GitHub Workflows
77

88
- `pr.yml`:
9-
- Runs tests for all pull requests
10-
- Runs `nx affected`, which only executes tasks with invalidated cache
11-
- Also uses `pkg-pr-new` to publish package previews and create links to our examples
9+
- Runs tests for all pull requests
10+
- Runs `nx affected`, which only executes tasks with invalidated cache
11+
- Also uses `pkg-pr-new` to publish package previews and create links to our examples
1212
- `release.yml`:
13-
- Runs tests for code merged into release branches
14-
- Runs `nx run-many`, which executes all tasks and ensures the outputs are present (necessary for publishing builds)
15-
- Uses [Changesets](https://github.com/changesets/changesets) to handle versioning and publishing
13+
- Runs tests for code merged into release branches
14+
- Runs `nx run-many`, which executes all tasks and ensures the outputs are present (necessary for publishing builds)
15+
- Uses [Changesets](https://github.com/changesets/changesets) to handle versioning and publishing
1616

1717
## Nx
1818

@@ -21,7 +21,7 @@ The TanStack projects use Nx to enable rapid execution of our tests and builds.
2121
### Config Files
2222

2323
- `./nx.json`: Main config file, which defines task dependencies, inputs, and outputs
24-
- `./package.json`: Need to manually specify root-level scripts (e.g. `test:format`)
24+
- `./package.json`: Need to manually specify root-level scripts (e.g. `test:eslint`)
2525
- `./**/package.json`: Package-level scripts (e.g. `build`) are automatically detected
2626

2727
### Nx Agents

docs/dependencies.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ We use 3 separate tools to help manage our dependencies and prevent us from unne
1818
### Renovate
1919

2020
- Renovate is a bot which runs on GitHub to scan for outdated or insecure dependencies
21-
- This reduces the burden on maintainers by automatically submitting PRs
21+
- This reduces the burden on maintainers by automatically submitting PRs

docs/overview.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ TanStack Config is a collection of tools we currently use between our projects t
99

1010
The following tools are required to use these packages:
1111

12-
- [Node.js v18.17+](https://nodejs.org/en/download/current/)
12+
- [Node.js v20.17.0+](https://nodejs.org/en/download/current/)
1313
- [Git CLI](https://git-scm.com/downloads)
1414
- [GitHub CLI](https://cli.github.com/) (pre-installed on GitHub Actions)
15-
- [pnpm v8+](https://pnpm.io/)
15+
- [pnpm v10+](https://pnpm.io/)
1616

1717
> pnpm is the only supported package manager for TanStack Config.
1818

docs/package-structure.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ The following structure ensures packages work optimally with our monorepo/Nx wor
1717
- Extends the root-level tsconfig (e.g. `"extends": "../../tsconfig.json"`)
1818
- Add any framework-specific options and included files here
1919

20-
### `./vite.config.ts`
21-
22-
- Includes config for Vitest, and for Vite if [@tanstack/vite-config](./vite.md) is used
23-
2420
### `./src`
2521

2622
- This folder should only include code which gets built and shipped to users
@@ -30,3 +26,11 @@ The following structure ensures packages work optimally with our monorepo/Nx wor
3026

3127
- This folder should include all test files
3228
- It should also include any test setup files required by that framework
29+
30+
### `./tsdown.config.ts`
31+
32+
- Defines `tsdown` config, including any framework-specific plugins.
33+
34+
### `./vitest.config.ts`
35+
36+
- Defines config for Vitest

docs/publish.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ To install the package, run the following command:
1111
pnpm add -D @tanstack/publish-config
1212
```
1313

14-
1514
## Usage
1615

1716
To use the TanStack Config programmatically, you can import the `publish` function:
@@ -42,3 +41,24 @@ publish({
4241
> ```
4342
>
4443
> in your `package.json` file and use `import` instead of `require`.
44+
45+
## Trusted Publishing
46+
47+
Trusted publishing is the new npm strategy to allow publishing packages without npm tokens, using OIDC authentication. It currently requires you to set up for each package individually; however, once enabled, no further interaction is required!
48+
49+
### Step 1
50+
51+
- If the package already has a published version on npm, you can skip this step.
52+
- If the package has never been published, you can publish a "placeholder" package to do the setup process. This CLI tool streamlines this: [setup-npm-trusted-publish](https://github.com/azu/setup-npm-trusted-publish)
53+
54+
### Step 2
55+
56+
- If you're only setting up one package, you can skip this step. Otherwise, the tools below help dramatically when setting up 5+ packages all at once.
57+
- [open-packages-on-npm](https://github.com/antfu/open-packages-on-npm)
58+
- [sxzz's userscript](https://github.com/sxzz/userscripts/blob/main/src/npm-trusted-publisher.md)
59+
60+
### Step 3
61+
62+
- Fill in the fields on the package's settings page, similar to this. You will need to authenticate with MFA to save these settings.
63+
64+
![Settings](https://raw.githubusercontent.com/TanStack/config/refs/heads/main/media/trusted-publisher.png)

docs/vite.md

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@ id: vite
33
title: Vite
44
---
55

6-
The Vite build setup is the culmination of several attempts to dual publish ESM and CJS for TanStack projects, while preserving compatibility with all Typescript module resolution options.
6+
The Vite build setup was the result of several attempts to dual publish ESM and CJS for TanStack projects, while preserving compatibility with all Typescript module resolution options.
77

8-
## Do I Need This?
8+
## Do I need dual publishing?
99

1010
ES Modules (ESM) is the standard for writing JavaScript modules. However, due to the historical dependency on CommonJS (CJS), many ecosystem tools and projects were initially incompatible with ESM. It is becoming exceedingly rare for this to be the case, and I would urge you to consider whether it is necessary to distribute CJS code at all. Sindre Sorhus has a good summary on this issue [here](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c).
1111

12+
## Do I need this package?
13+
14+
Many alternatives have bene created recently, with the most notable being [tsdown](https://github.com/rolldown/tsdown), built on top of `rolldown`. We will be adopting tsdown for future projects rather than continuing to use our custom Vite setup.
15+
1216
## Installation
1317

1418
To install the package, run the following command:
@@ -17,9 +21,20 @@ To install the package, run the following command:
1721
pnpm add -D @tanstack/vite-config
1822
```
1923

20-
## Setup
24+
## Frameworks
25+
26+
| Framework | Dual Types | ESM only |
27+
| --------- | ----------------------------- | ------------------------------------------------------------------------------------ |
28+
| Vanilla | [tsdown](https://tsdown.dev/) | [tsdown](https://tsdown.dev/) or [tsc](https://www.npmjs.com/package/typescript) |
29+
| Angular | Not required | [ng-packagr](https://www.npmjs.com/package/ng-packagr) (official tool) |
30+
| React | [tsdown](https://tsdown.dev/) | [tsdown](https://tsdown.dev/) or [tsc](https://www.npmjs.com/package/typescript) |
31+
| Solid | Not required | [tsc](https://www.npmjs.com/package/typescript) (preserves JSX, necessary for SSR) |
32+
| Svelte | Not required | [@sveltejs/package](https://www.npmjs.com/package/@sveltejs/package) (official tool) |
33+
| Vue | [tsdown](https://tsdown.dev/) | [tsdown](https://tsdown.dev/) or [tsc](https://www.npmjs.com/package/typescript) |
34+
35+
## Legacy Setup
2136

22-
The build config is quite opinionated, as it is designed to work with our internal libraries. If you follow the below instructions, it _may_ work for your library too!
37+
The build config is opinionated, and was designed to work with our internal libraries. If you follow the below instructions, it _may_ work for your library too!
2338

2439
### package.json
2540

@@ -74,15 +89,3 @@ export default mergeConfig(
7489
}),
7590
)
7691
```
77-
78-
## Frameworks
79-
80-
While this config _will_ work with most frameworks with a Vite adapter, it doesn't mean you _should_ use it for all frameworks, as many have their own build tools which are optimised for their ecosystem. When a framework-specific build tool exists, this should be preferred.
81-
82-
| Framework | Recommendation |
83-
| --------- | -------------------------------------------------------------------------------------------------- |
84-
| Angular | [ng-packagr](https://www.npmjs.com/package/ng-packagr) (official tool) |
85-
| React | [@tanstack/vite-config](https://www.npmjs.com/package/@tanstack/vite-config) (only if you need dual ESM/CJS) |
86-
| Solid | [tsc](https://www.npmjs.com/package/typescript) (preserves JSX, necessary for SSR) |
87-
| Svelte | [@sveltejs/package](https://www.npmjs.com/package/@sveltejs/package) (official tool) |
88-
| Vue | [@tanstack/vite-config](https://www.npmjs.com/package/@tanstack/vite-config) (only if you need dual ESM/CJS) |

media/trusted-publisher.png

53.5 KB
Loading

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,15 @@
1515
"test:build": "nx affected --target=test:build",
1616
"test:types": "nx affected --target=test:types",
1717
"test:eslint": "nx affected --target=test:eslint",
18-
"test:format": "pnpm run prettier --check",
1918
"test:sherif": "sherif",
2019
"test:docs": "node scripts/verify-links.ts",
2120
"build": "nx affected --target=build",
2221
"build:all": "nx run-many --target=build",
2322
"watch": "pnpm run build:all && nx watch --all -- pnpm run build:all",
2423
"dev": "pnpm run watch",
25-
"prettier": "prettier --experimental-cli --ignore-unknown '**/*'",
26-
"prettier:write": "pnpm run prettier --write",
24+
"format": "prettier --experimental-cli --ignore-unknown '**/*' --write",
2725
"changeset": "changeset",
28-
"changeset:version": "changeset version && pnpm install --no-frozen-lockfile && pnpm prettier:write",
26+
"changeset:version": "changeset version && pnpm install --no-frozen-lockfile && pnpm format",
2927
"changeset:publish": "changeset publish"
3028
},
3129
"nx": {

0 commit comments

Comments
 (0)