You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/tsdown-readme.md
+41-24Lines changed: 41 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,16 @@
1
-
# TSDX React w/ Storybook User Guide
1
+
# tsdown React w/ Storybook User Guide
2
2
3
-
Congrats! You just saved yourself hours of work by bootstrapping this project with TSDX. Let’s get you oriented with what’s 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.
4
4
5
-
> This TSDX 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`.
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`.
6
6
7
7
> If you’re new to TypeScript and React, checkout [this handy cheatsheet](https://github.com/sw-yx/react-typescript-cheatsheet/)
8
8
9
9
## Commands
10
10
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`.
12
12
13
-
The recommended workflow is to run TSDX in one terminal:
13
+
The recommended workflow is to run tsdown in one terminal:
14
14
15
15
```bash
16
16
npm start # or pnpm start
@@ -42,7 +42,7 @@ npm i # or pnpm install to install dependencies
42
42
npm start # or pnpm start
43
43
```
44
44
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).
46
46
47
47
To do a one-off build, use `npm run build` or `pnpm build`.
48
48
@@ -89,9 +89,9 @@ tsconfig.json
89
89
90
90
We do not set up `react-testing-library` for you yet, we welcome contributions and documentation on this.
91
91
92
-
### Rollup
92
+
### tsdown
93
93
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.
95
95
96
96
### TypeScript
97
97
@@ -108,25 +108,42 @@ Two actions are added by default:
108
108
109
109
## Optimizations
110
110
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:
You can configure these options in your `tsdown.config.js` file:
122
120
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
+
exportdefault {
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
+
```
124
135
125
136
## Module Formats
126
137
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`:
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.
130
147
131
148
## Deploying the Example Playground
132
149
@@ -163,19 +180,19 @@ We recommend using [np](https://github.com/sindresorhus/np).
163
180
164
181
## Usage with Lerna
165
182
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_.
167
184
168
185
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.
169
186
170
187
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.
171
188
172
189
```diff
173
-
"alias": {
190
+
"alias": {
174
191
- "react": "../node_modules/react",
175
192
- "react-dom": "../node_modules/react-dom"
176
193
+ "react": "../../../node_modules/react",
177
194
+ "react-dom": "../../../node_modules/react-dom"
178
-
},
195
+
},
179
196
```
180
197
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