Skip to content

Commit

Permalink
docs: Separate publish docs from overview
Browse files Browse the repository at this point in the history
  • Loading branch information
lachlancollins committed Jan 27, 2024
1 parent c2c6697 commit f87d53a
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 55 deletions.
10 changes: 5 additions & 5 deletions docs/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ title: Build

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.

# Usage
## Usage

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!

## package.json
### package.json

- Ensure `"type": "module"` is set.
- Ensure you have [Vite](https://www.npmjs.com/package/vite) installed. Installing [Publint](https://www.npmjs.com/package/publint) is also recommended.
Expand All @@ -34,12 +34,12 @@ The build config is quite opinionated, as it is designed to work with our intern
}
```

## tsconfig.json
### tsconfig.json

- Ensure your `"include"` field includes `"vite.config.ts"`.
- Set `"moduleResolution"` to `"bundler"`.

## vite.config.ts
### vite.config.ts

- Import `mergeConfig` and `tanstackBuildConfig`.
- Merge your custom config first, followed by `tanstackBuildConfig`.
Expand All @@ -63,6 +63,6 @@ export default mergeConfig(
)
```

# Caveats
## Caveats

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.
4 changes: 4 additions & 0 deletions docs/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
{
"label": "Build",
"to": "build"
},
{
"label": "Publish",
"to": "publish"
}
]
}
Expand Down
58 changes: 8 additions & 50 deletions docs/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ id: overview
title: Overview
---

TanStack Config allows you to publish, update, and maintain your packages
without having to provide complex configuration.
TanStack Config allows you to publish, update, and maintain your packages without having to provide complex configuration.

# Required Pre-Requisites
## Utilities

- [Build](./build)
- [Publish](./publish)

## Required Pre-Requisites

The following tools are required to be installed on the system running TanStack Config scripts:

Expand All @@ -17,56 +21,10 @@ The following tools are required to be installed on the system running TanStack

> PNPM is currently the only supported package manager for TanStack Config.
# Installation
## Installation

To install TanStack Config, run the following command:

```bash
pnpm add --save-dev @tanstack/config
```

# Usage

You have two options for using TanStack Config:

- [CLI Usage](#cli-usage)
- [Programmatic Usage](#programmatic-usage)

## CLI Usage

To run the publish script for your package, run the following command:

```bash
pnpm run tanstack-config publish
```

## Programmatic Usage

To use the TanStack Config programmatically, you can import the `publish` function:

```ts
import { publish } from '@tanstack/config';

publish({
branchConfigs: configOpts.branchConfigs,
packages: configOpts.packages,
rootDir: configOpts.rootDir,
branch: process.env.BRANCH,
tag: process.env.TAG,
ghToken: process.env.GH_TOKEN,
})
.then(() => {
console.log('Successfully published packages!');
})
.catch(console.error)
```

> The programmatic usage is only available for ESM packages. To support this, you have to have:
>
> ```json
> {
> "type": "module"
> }
> ```
>
> in your `package.json` file and use `import` instead of `require`.
50 changes: 50 additions & 0 deletions docs/publish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
id: publish
title: Publish
---

## Usage

You have two options for using TanStack Config to publish:

- [CLI Usage](#cli-usage)
- [Programmatic Usage](#programmatic-usage)

### CLI Usage

To run the publish script for your package, run the following command:

```bash
pnpm run tanstack-config publish
```

### Programmatic Usage

To use the TanStack Config programmatically, you can import the `publish` function:

```ts
import { publish } from '@tanstack/config';

publish({
branchConfigs: configOpts.branchConfigs,
packages: configOpts.packages,
rootDir: configOpts.rootDir,
branch: process.env.BRANCH,
tag: process.env.TAG,
ghToken: process.env.GH_TOKEN,
})
.then(() => {
console.log('Successfully published packages!');
})
.catch(console.error)
```

> The programmatic usage is only available for ESM packages. To support this, you have to have:
>
> ```json
> {
> "type": "module"
> }
> ```
>
> in your `package.json` file and use `import` instead of `require`.

0 comments on commit f87d53a

Please sign in to comment.