Skip to content

Commit 6142d6b

Browse files
authored
Build all packages using tsdown (#3722)
1 parent 75543b1 commit 6142d6b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+370
-322
lines changed

.changeset/nice-rocks-crash.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
"@gitbook/emoji-codepoints": patch
3+
"@gitbook/react-contentkit": patch
4+
"@gitbook/openapi-parser": patch
5+
"@gitbook/browser-types": patch
6+
"@gitbook/react-openapi": patch
7+
"@gitbook/cache-tags": patch
8+
"@gitbook/react-math": patch
9+
"gitbook": patch
10+
"@gitbook/colors": patch
11+
"@gitbook/embed": patch
12+
"@gitbook/fonts": patch
13+
"@gitbook/icons": patch
14+
"@gitbook/expr": patch
15+
---
16+
17+
Mark as sideEffects, fix all package bundles

.github/workflows/publish.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ jobs:
2222
fetch-depth: 0
2323
- name: Setup Bun
2424
uses: ./.github/composite/setup-bun
25+
- name: Setup npmrc
26+
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc
2527
- name: Install dependencies
2628
run: bun install --frozen-lockfile
2729
env:
@@ -36,8 +38,6 @@ jobs:
3638
# Using a PAT instead of GITHUB_TOKEN because we need to run workflows when releases are created
3739
# https://github.com/orgs/community/discussions/26875#discussioncomment-3253761
3840
GITHUB_TOKEN: ${{ secrets.GH_PERSONAL_TOKEN }}
39-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
40-
NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }}
4141
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
4242
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
4343

bun.lock

Lines changed: 186 additions & 168 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
"packageManager": "bun@1.2.15",
1111
"overrides": {
1212
"@codemirror/state": "6.4.1",
13-
"react": "^19.0.0",
14-
"react-dom": "^19.0.0",
13+
"react": "catalog:",
14+
"react-dom": "catalog:",
1515
"esbuild": "0.24.2"
1616
},
1717
"private": true,
@@ -36,8 +36,15 @@
3636
"packages": ["packages/*"],
3737
"catalog": {
3838
"@gitbook/api": "0.143.2",
39+
"assert-never": "^1.4.0",
3940
"bidc": "^0.0.2",
40-
"tsdown": "^0.15.6"
41+
"bun-types": "^1.1.20",
42+
"classnames": "^2.5.1",
43+
"react": "^19.0.0",
44+
"react-dom": "^19.0.0",
45+
"tsdown": "^0.15.6",
46+
"typescript": "^5.5.3",
47+
"usehooks-ts": "^3.1.0"
4148
}
4249
},
4350
"patchedDependencies": {

packages/browser-types/package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,20 @@
88
"default": "./dist/index.js"
99
}
1010
},
11+
"sideEffects": false,
1112
"version": "0.1.1",
1213
"dependencies": {
1314
"@gitbook/api": "catalog:",
1415
"@gitbook/icons": "workspace:"
1516
},
1617
"devDependencies": {
17-
"typescript": "^5.5.3"
18+
"tsdown": "catalog:",
19+
"typescript": "catalog:"
1820
},
1921
"scripts": {
20-
"build": "tsc",
21-
"typecheck": "tsc --noEmit"
22+
"build": "tsdown",
23+
"typecheck": "tsc --noEmit",
24+
"dev": "bun run build -- --watch ./src"
2225
},
2326
"files": ["dist", "README.md", "CHANGELOG.md"],
2427
"publishConfig": {

packages/cache-tags/package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,25 @@
44
"exports": {
55
".": {
66
"types": "./dist/index.d.ts",
7-
"development": "./src/index.ts",
87
"default": "./dist/index.js"
98
}
109
},
10+
"sideEffects": false,
1111
"version": "0.3.2",
1212
"dependencies": {
1313
"@gitbook/api": "catalog:",
14-
"assert-never": "^1.2.1"
14+
"assert-never": "catalog:"
1515
},
1616
"devDependencies": {
17-
"typescript": "^5.5.3"
17+
"tsdown": "catalog:",
18+
"typescript": "catalog:"
1819
},
1920
"scripts": {
20-
"build": "tsc",
21+
"build": "tsdown",
2122
"typecheck": "tsc --noEmit",
22-
"dev": "tsc -w"
23+
"dev": "bun run build -- --watch ./src"
2324
},
24-
"files": ["dist", "src", "README.md", "CHANGELOG.md"],
25+
"files": ["dist", "README.md", "CHANGELOG.md"],
2526
"publishConfig": {
2627
"access": "public",
2728
"registry": "https://registry.npmjs.org/"

packages/colors/package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,21 @@
44
"exports": {
55
".": {
66
"types": "./dist/index.d.ts",
7-
"development": "./src/index.ts",
87
"default": "./dist/index.js"
98
}
109
},
10+
"sideEffects": false,
1111
"version": "0.4.1",
1212
"devDependencies": {
13-
"typescript": "^5.5.3"
13+
"tsdown": "catalog:",
14+
"typescript": "catalog:"
1415
},
1516
"scripts": {
16-
"build": "tsc",
17+
"build": "tsdown",
1718
"typecheck": "tsc --noEmit",
18-
"dev": "tsc -w"
19+
"dev": "bun run build -- --watch ./src"
1920
},
20-
"files": ["dist", "src", "README.md", "CHANGELOG.md"],
21+
"files": ["dist", "README.md", "CHANGELOG.md"],
2122
"publishConfig": {
2223
"access": "public",
2324
"registry": "https://registry.npmjs.org/"

packages/embed/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,20 @@
1212
"default": "./dist/react/index.js"
1313
}
1414
},
15+
"sideEffects": false,
1516
"version": "0.1.3",
1617
"dependencies": {
1718
"@gitbook/api": "catalog:",
1819
"@gitbook/icons": "workspace:",
1920
"bidc": "catalog:"
2021
},
2122
"peerDependencies": {
22-
"react": "^18.0.0"
23+
"react": "*"
2324
},
2425
"devDependencies": {
2526
"tsdown": "catalog:",
26-
"typescript": "^5.5.3",
27-
"react": "^19.0.0"
27+
"typescript": "catalog:",
28+
"react": "catalog:"
2829
},
2930
"scripts": {
3031
"build": "bun run build-lib && bun run build-standalone",

packages/embed/src/react/GitBookFrame.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import React from 'react';
1+
'use client';
2+
3+
import { useEffect, useMemo, useRef, useState } from 'react';
24
import type {
35
GetFrameURLOptions,
46
GitBookEmbeddableConfiguration,
@@ -17,19 +19,19 @@ export type GitBookFrameProps = {
1719
export function GitBookFrame(props: GitBookFrameProps) {
1820
const { className, visitor, buttons, welcomeMessage, suggestions, tools } = props;
1921

20-
const frameRef = React.useRef<HTMLIFrameElement>(null);
22+
const frameRef = useRef<HTMLIFrameElement>(null);
2123
const gitbook = useGitBook();
22-
const [gitbookFrame, setGitbookFrame] = React.useState<GitBookFrameClient | null>(null);
24+
const [gitbookFrame, setGitbookFrame] = useState<GitBookFrameClient | null>(null);
2325

24-
const frameURL = React.useMemo(() => gitbook.getFrameURL({ visitor }), [gitbook, visitor]);
26+
const frameURL = useMemo(() => gitbook.getFrameURL({ visitor }), [gitbook, visitor]);
2527

26-
React.useEffect(() => {
28+
useEffect(() => {
2729
if (frameRef.current) {
2830
setGitbookFrame(gitbook.createFrame(frameRef.current));
2931
}
3032
}, [gitbook]);
3133

32-
React.useEffect(() => {
34+
useEffect(() => {
3335
gitbookFrame?.configure({
3436
buttons,
3537
welcomeMessage,

packages/embed/tsdown.config.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@ import { defineConfig } from 'tsdown';
22

33
export default defineConfig([
44
{
5-
entry: ['src/index.ts', 'src/react/index.ts'],
6-
dts: true,
7-
format: ['esm'],
5+
entry: 'src/index.ts',
6+
outDir: 'dist',
7+
},
8+
{
9+
entry: 'src/react/index.ts',
10+
outDir: 'dist/react',
11+
unbundle: true,
812
},
913
]);

0 commit comments

Comments
 (0)