Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4079f1b

Browse files
feat: use tsdown, vitest, pnpm (#279)
* feat: use pnpm * fix: jest ts * fix: workflow * fix: lint * fix: jest warnings * feat: tsdown * fix: lint * fix: global * fix: remove windows * fix: tests * fix: build * fix: asdf * feat: vitest * fix: storybook * chore: readme
1 parent 5355d8b commit 4079f1b

Some content is hidden

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

41 files changed

+33395
-24809
lines changed

‎.github/workflows/coverage.yml‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,29 @@ jobs:
88

99
strategy:
1010
matrix:
11-
node-version: [12.x]
11+
node-version: [22.x]
1212

1313
steps:
1414
- name: Checkout repository
15-
uses: actions/checkout@v2
15+
uses: actions/checkout@v4
1616
with:
1717
fetch-depth: 2
1818

1919
- name: Set up Node.js ${{ matrix.node-version }}
20-
uses: actions/setup-node@v1
20+
uses: actions/setup-node@v4
2121
with:
2222
node-version: ${{ matrix.node-version }}
2323

24+
- name: Install PNPM
25+
run: npm install -g pnpm
26+
2427
- name: Install dependencies
25-
run: yarn install
28+
run: pnpm install --frozen-lockfile
2629

2730
- name: Run the tests
28-
run: yarn test -- --coverage
31+
run: pnpm run test:coverage
2932

3033
- name: Upload coverage to Codecov
31-
uses: codecov/codecov-action@v1
34+
uses: codecov/codecov-action@v4
3235
with:
3336
token: ${{ secrets.CODECOV_TOKEN }}

‎.github/workflows/main.yml‎

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,48 @@
11
name: CI
2-
on: [push]
2+
on: [push, pull_request]
33
jobs:
44
build:
55
name: Build, lint, and test on Node ${{ matrix.node }} and ${{ matrix.os }}
66

77
runs-on: ${{ matrix.os }}
88
strategy:
99
matrix:
10-
node: ['12.x']
11-
os: [ubuntu-latest, windows-latest, macOS-latest]
10+
node: ['22.x']
11+
os: [ubuntu-latest, macOS-latest]
1212

1313
steps:
1414
- name: Checkout repo
15-
uses: actions/checkout@v2
15+
uses: actions/checkout@v4
1616

1717
- name: Use Node ${{ matrix.node }}
18-
uses: actions/setup-node@v1
18+
uses: actions/setup-node@v4
1919
with:
2020
node-version: ${{ matrix.node }}
2121

22-
- name: Install deps and build (with cache)
23-
uses: bahmutov/npm-install@v1
22+
- name: Install PNPM
23+
run: npm install -g pnpm
24+
25+
- name: Get PNPM store directory
26+
shell: bash
27+
run: |
28+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
29+
30+
- name: Setup PNPM cache
31+
uses: actions/cache@v4
32+
with:
33+
path: ${{ env.STORE_PATH }}
34+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
35+
restore-keys: |
36+
${{ runner.os }}-pnpm-store-
37+
38+
- name: Install dependencies
39+
run: pnpm install --frozen-lockfile
2440

2541
- name: Lint
26-
run: yarn lint
42+
run: pnpm lint
2743

2844
- name: Test
29-
run: yarn test --ci --coverage --maxWorkers=2
45+
run: pnpm test
3046

3147
- name: Build
32-
run: yarn build
48+
run: pnpm build

‎.github/workflows/size.yml‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ jobs:
66
env:
77
CI_JOB_NUMBER: 1
88
steps:
9-
- uses: actions/checkout@v1
9+
- uses: actions/checkout@v4
10+
- name: Install PNPM
11+
run: npm install -g pnpm
12+
- name: Install dependencies
13+
run: pnpm install --frozen-lockfile
14+
- name: Build
15+
run: pnpm build
1016
- uses: andresz1/size-limit-action@v1
1117
with:
1218
github_token: ${{ secrets.GITHUB_TOKEN }}

‎.github/workflows/surge.yml‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,27 @@ jobs:
99

1010
strategy:
1111
matrix:
12-
node-version: [12.x]
12+
node-version: [22.x]
1313

1414
steps:
1515
- name: Checkout repository
16-
uses: actions/checkout@v2
16+
uses: actions/checkout@v4
1717
with:
1818
fetch-depth: 2
1919

2020
- name: Set up Node.js ${{ matrix.node-version }}
21-
uses: actions/setup-node@v1
21+
uses: actions/setup-node@v4
2222
with:
2323
node-version: ${{ matrix.node-version }}
2424

25+
- name: Install PNPM
26+
run: npm install -g pnpm
27+
2528
- name: Install dependencies
26-
run: yarn install
29+
run: pnpm install --frozen-lockfile
2730

2831
- name: Build Storybook
29-
run: yarn build-storybook
32+
run: pnpm build-storybook
3033

3134
- name: Install Surge
3235
run: npm install --global surge

‎.storybook/main.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ module.exports = {
3434
// https://storybook.js.org/docs/react/configure/typescript#mainjs-configuration
3535
typescript: {
3636
check: true, // type-check stories during Storybook build
37-
// reactDocgen: false, // https://github.com/storybookjs/storybook/issues/15336
37+
reactDocgen: false, // Disable to fix TypeScript 5.9.2 compatibility issue
3838
},
3939
};

‎README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ With npm
2323
npm install react-scroll-parallax
2424
```
2525

26-
or yarn
26+
or pnpm
2727

2828
```
29-
yarn add react-scroll-parallax
29+
pnpm add react-scroll-parallax
3030
```
3131

3232
## Example

‎docs/development.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,29 @@ Scripts and procedures for developing locally.
77
Install node modules
88

99
```
10-
yarn install
10+
pnpm install
1111
```
1212

1313
Start storybook
1414

1515
```
16-
yarn start
16+
pnpm start
1717
```
1818

1919
## Testing
2020

21-
Run Jest tests
21+
Run Vitest tests
2222

2323
```
24-
yarn test
24+
pnpm test
2525
```
2626

2727
## Prettier
2828

2929
Run prettier on source files
3030

3131
```
32-
yarn prettier
32+
pnpm prettier
3333
```
3434

3535
## Publishing New Version to NPM

‎docs/tsdx-readme.md‎ renamed to ‎docs/tsdown-readme.md‎

Lines changed: 50 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
# TSDX React w/ Storybook User Guide
1+
# tsdown React w/ Storybook User Guide
22

3-
Congrats! You just saved yourself hours of work by bootstrapping this project with TSDX. Lets get you oriented with whats here and how to use it.
3+
Congrats! You just saved yourself hours of work by bootstrapping this project with tsdown. Let's get you oriented with what's here and how to use it.
44

5-
> This TSDX setup is meant for developing React component libraries (not apps!) that can be published to NPM. If youre looking to build a React-based app, you should use `create-react-app`, `razzle`, `nextjs`, `gatsby`, or `react-static`.
5+
> This tsdown setup is meant for developing React component libraries (not apps!) that can be published to NPM. If you're looking to build a React-based app, you should use `create-react-app`, `razzle`, `nextjs`, `gatsby`, or `react-static`.
66
77
> If you’re new to TypeScript and React, checkout [this handy cheatsheet](https://github.com/sw-yx/react-typescript-cheatsheet/)
88
99
## Commands
1010

11-
TSDX scaffolds your new library inside `/src`, and also sets up a [Parcel-based](https://parceljs.org) playground for it inside `/example`.
11+
tsdown scaffolds your new library inside `/src`, and also sets up a [Parcel-based](https://parceljs.org) playground for it inside `/example`.
1212

13-
The recommended workflow is to run TSDX in one terminal:
13+
The recommended workflow is to run tsdown in one terminal:
1414

1515
```bash
16-
npm start # or yarn start
16+
npm start # or pnpm start
1717
```
1818

1919
This builds to `/dist` and runs the project in watch mode so any edits you save inside `src` causes a rebuild to `/dist`.
@@ -25,7 +25,7 @@ Then run either Storybook or the example playground:
2525
Run inside another terminal:
2626

2727
```bash
28-
yarn storybook
28+
pnpm storybook
2929
```
3030

3131
This loads the stories from `./stories`.
@@ -38,23 +38,23 @@ Then run the example inside another:
3838

3939
```bash
4040
cd example
41-
npm i # or yarn to install dependencies
42-
npm start # or yarn start
41+
npm i # or pnpm install to install dependencies
42+
npm start # or pnpm start
4343
```
4444

45-
The default example imports and live reloads whatever is in `/dist`, so if you are seeing an out of date component, make sure TSDX is running in watch mode like we recommend above. **No symlinking required**, we use [Parcel's aliasing](https://parceljs.org/module_resolution.html#aliases).
45+
The default example imports and live reloads whatever is in `/dist`, so if you are seeing an out of date component, make sure tsdown is running in watch mode like we recommend above. **No symlinking required**, we use [Parcel's aliasing](https://parceljs.org/module_resolution.html#aliases).
4646

47-
To do a one-off build, use `npm run build` or `yarn build`.
47+
To do a one-off build, use `npm run build` or `pnpm build`.
4848

49-
To run tests, use `npm test` or `yarn test`.
49+
To run tests, use `npm test` or `pnpm test`.
5050

5151
## Configuration
5252

5353
Code quality is set up for you with `prettier`, `husky`, and `lint-staged`. Adjust the respective fields in `package.json` accordingly.
5454

55-
### Jest
55+
### Vitest
5656

57-
Jest tests are set up to run with `npm test` or `yarn test`.
57+
Vitest tests are set up to run with `npm test` or `pnpm test`.
5858

5959
### Bundle analysis
6060

@@ -89,9 +89,9 @@ tsconfig.json
8989

9090
We do not set up `react-testing-library` for you yet, we welcome contributions and documentation on this.
9191

92-
### Rollup
92+
### tsdown
9393

94-
TSDX uses [Rollup](https://rollupjs.org) as a bundler and generates multiple rollup configs for various module formats and build settings. See [Optimizations](#optimizations) for details.
94+
tsdown uses [esbuild](https://esbuild.github.io/) as a bundler and generates multiple output formats for various module formats and build settings. See [Optimizations](#optimizations) for details.
9595

9696
### TypeScript
9797

@@ -108,25 +108,42 @@ Two actions are added by default:
108108

109109
## Optimizations
110110

111-
Please see the main `tsdx`[optimizations docs](https://github.com/palmerhq/tsdx#optimizations). In particular, know that you can take advantage of development-only optimizations:
111+
tsdown provides fast builds using esbuild and includes several optimization features:
112112

113-
```js
114-
// ./types/index.d.ts
115-
declare var __DEV__: boolean;
113+
- **Tree shaking**: Automatically removes unused code
114+
- **Minification**: Optional minification for production builds
115+
- **Source maps**: Generated for debugging
116+
- **Multiple formats**: ESM and CommonJS output
117+
- **TypeScript declarations**: Automatic `.d.ts` generation
116118

117-
// inside your code...
118-
if (__DEV__) {
119-
console.log('foo');
120-
}
121-
```
119+
You can configure these options in your `tsdown.config.js` file:
122120

123-
You can also choose to install and use [invariant](https://github.com/palmerhq/tsdx#invariant) and [warning](https://github.com/palmerhq/tsdx#warning) functions.
121+
```js
122+
export default {
123+
entry: 'src/index.ts',
124+
outDir: 'dist',
125+
format: ['esm', 'cjs'],
126+
dts: true,
127+
external: ['react', 'react-dom'],
128+
clean: true,
129+
sourcemap: true,
130+
minify: false,
131+
splitting: false,
132+
treeshake: true,
133+
};
134+
```
124135

125136
## Module Formats
126137

127-
CJS, ESModules, and UMD module formats are supported.
138+
ESM and CommonJS module formats are supported by default.
139+
140+
The appropriate paths are configured in `package.json`:
141+
142+
- `main`: `dist/index.js` (CommonJS)
143+
- `module`: `dist/index.mjs` (ESM)
144+
- `types`: `dist/index.d.ts` (TypeScript declarations)
128145

129-
The appropriate paths are configured in `package.json` and `dist/index.js` accordingly. Please report if any issues are found.
146+
Please report if any issues are found.
130147

131148
## Deploying the Example Playground
132149

@@ -142,7 +159,7 @@ Alternatively, if you already have a git repo connected, you can set up continuo
142159

143160
```bash
144161
netlify init
145-
# build command: yarn build && cd example && yarn && yarn build
162+
# build command: pnpm build && cd example && pnpm install && pnpm build
146163
# directory to deploy: example/dist
147164
# pick yes for netlify.toml
148165
```
@@ -163,19 +180,19 @@ We recommend using [np](https://github.com/sindresorhus/np).
163180

164181
## Usage with Lerna
165182

166-
When creating a new package with TSDX within a project set up with Lerna, you might encounter a `Cannot resolve dependency` error when trying to run the `example` project. To fix that you will need to make changes to the `package.json` file _inside the `example` directory_.
183+
When creating a new package with tsdown within a project set up with Lerna, you might encounter a `Cannot resolve dependency` error when trying to run the `example` project. To fix that you will need to make changes to the `package.json` file _inside the `example` directory_.
167184

168185
The problem is that due to the nature of how dependencies are installed in Lerna projects, the aliases in the example project's `package.json` might not point to the right place, as those dependencies might have been installed in the root of your Lerna project.
169186

170187
Change the `alias` to point to where those packages are actually installed. This depends on the directory structure of your Lerna project, so the actual path might be different from the diff below.
171188

172189
```diff
173-
"alias": {
190+
"alias": {
174191
- "react": "../node_modules/react",
175192
- "react-dom": "../node_modules/react-dom"
176193
+ "react": "../../../node_modules/react",
177194
+ "react-dom": "../../../node_modules/react-dom"
178-
},
195+
},
179196
```
180197

181-
An alternative to fixing this problem would be to remove aliases altogether and define the dependencies referenced as aliases as dev dependencies instead.[However, that might cause other problems.](https://github.com/palmerhq/tsdx/issues/64)
198+
An alternative to fixing this problem would be to remove aliases altogether and define the dependencies referenced as aliases as dev dependencies instead.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /