这是indexloc提供的服务,不要输入任何密码
Skip to content

feat: export main cli & add tsup-node command #290

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@ Code splitting is enabled by default and supported in `cjs` and `esm` format.

By default tsup bundles all `import`-ed modules but `dependencies` and `peerDependencies` in your `packages.json` are always excluded, you can also use `--external <module>` flag to mark other packages as external.

### Excluding all packages

If you are using **tsup** to build for **Node.js** applications/APIs, usually bundling dependencies is not needed, and it can even break things, for instance, while outputting to [ESM](https://nodejs.org/api/esm.html).

tsup automatically excludes packages specified in the `dependencies` and `peerDependencies` fields in the `packages.json`, but if it somehow doesn't exclude some packages, this library also has a special executable `tsup-node` that automatically skips bundling any Node.js package.

```bash
tsup-node src/index.ts
```

All other CLI flags still apply to this command.

### Generate declaration file

```bash
Expand Down
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
"name": "tsup",
"version": "0.0.0-semantic-release",
"main": "dist/index.js",
"bin": "dist/cli.js",
"bin": {
"tsup": "dist/cli-default.js",
"tsup-node": "dist/cli-node.js"
},
"types": "dist/index.d.ts",
"files": [
"dist"
Expand All @@ -13,12 +16,12 @@
"url": "https://github.com/egoist/tsup.git"
},
"scripts": {
"build": "npm run tsup -- src/cli.ts src/index.ts src/rollup.ts --clean --dts-resolve",
"build": "npm run tsup -- src/cli-*.ts src/index.ts src/rollup.ts --clean --dts-resolve",
"prepublishOnly": "npm run build",
"test": "npm run build:simple && jest",
"//": "Building without dts for speed",
"build:simple": "npm run tsup -- src/cli.ts src/index.ts src/rollup.ts --clean",
"tsup": "node -r sucrase/register src/cli.ts"
"build:simple": "npm run tsup -- src/cli-*.ts src/index.ts src/rollup.ts --clean",
"tsup": "node -r sucrase/register src/cli-default.ts"
},
"dependencies": {
"cac": "^6.7.2",
Expand Down
Loading