Skip to content
Source
Sign inSign up
TanStack/config
Open History to see the last commit

package-structure.md

32 lines1.2 KB

1---
2id: package-structure
3title: Package Structure
4---
5​
6The following structure ensures packages work optimally with our monorepo/Nx workflow.
7​
8### `./package.json`
9​
10- All TanStack projects have `"type": "module"` to set the default resolution of `.js` files to ESM; this does not have any impact on building for CJS
11- It is also essential to have an `"exports"` field
12- For legacy reasons, you should also include the `"main"`, `"module"`, and `"types"` fields
13- All packages have the following scripts which are cached by Nx: `"test:eslint"`, `"test:types"`, `"test:lib"`, `"build"`, `"test:build"`
14​
15### `./tsconfig.json`
16​
17- Extends the root-level tsconfig (e.g. `"extends": "../../tsconfig.json"`)
18- Add any framework-specific options and included files here
19​
20### `./vite.config.ts`
21​
22- Includes config for Vitest, and for Vite if [@tanstack/config/vite](../vite.md) is used
23​
24### `./src`
25​
26- This folder should only include code which gets built and shipped to users
27- Tests should not be placed in this folder, as they bloat the shipped code, and can unintentionally invalidate the Nx cache
28​
29### `./tests`
30​
31- This folder should include all test files
32- It should also include any test setup files required by that framework