Skip to content

Commit e65166f

Browse files
docs: Update build.md with framework table (#100)
1 parent 37eb06c commit e65166f

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

docs/build.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@ id: build
33
title: Build
44
---
55

6-
The Vite build setup provided is the culmination of several attempts to make the TanStack libraries work in all environments, including ESM, CJS, the various TypeScript module resolution options, and a diverse bundler ecosystem.
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.
77

8-
## Usage
8+
## Do I Need This?
9+
10+
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).
11+
12+
## Setup
913

1014
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!
1115

@@ -63,6 +67,14 @@ export default mergeConfig(
6367
)
6468
```
6569

66-
## Caveats
70+
## Frameworks
71+
72+
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.
6773

68-
While this config _will_ work with most frameworks with a Vite adapter, it doesn't mean you _should_ use it for all frameworks. For instance, Svelte publishes [@sveltejs/package](https://www.npmjs.com/package/@sveltejs/package), and Angular publishes [ng-packagr](https://www.npmjs.com/package/ng-packagr). When a framework-specific build tool exists, this should be preferred.
74+
| Framework | Recommendation |
75+
| --------- | -------------------------------------------------------------------------------------------------- |
76+
| Angular | [ng-packagr](https://www.npmjs.com/package/ng-packagr) (official tool) |
77+
| React | [@tanstack/config](https://www.npmjs.com/package/@tanstack/config) (only if you need dual ESM/CJS) |
78+
| Solid | [tsc](https://www.npmjs.com/package/typescript) (preserves JSX, necessary for SSR) |
79+
| Svelte | [@sveltejs/package](https://www.npmjs.com/package/@sveltejs/package) (official tool) |
80+
| Vue | [@tanstack/config](https://www.npmjs.com/package/@tanstack/config) (only if you need dual ESM/CJS) |

0 commit comments

Comments
 (0)