Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: experimental plugin system #486

Merged
merged 13 commits into from Dec 10, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 13 additions & 7 deletions docs/README.md
Expand Up @@ -72,7 +72,7 @@ All other CLI flags still apply to this command.

You can also use `tsup` using file configurations or in a property inside your `package.json`, and you can even use `TypeScript` and have type-safety while you are using it.

> Most of these options can be overwritten using the CLI options
> INFO: Most of these options can be overwritten using the CLI options

You can use any of these files:

Expand All @@ -82,7 +82,7 @@ You can use any of these files:
- `tsup.config.json`
- `tsup` property in your `package.json`

> In all the custom files you can export the options either as `tsup`, `default` or `module.exports =`
> INFO: In all the custom files you can export the options either as `tsup`, `default` or `module.exports =`

[Check out all available options](https://github.com/egoist/tsup/blob/master/src/options.ts).

Expand Down Expand Up @@ -218,7 +218,7 @@ To disable code splitting altogether, try the `--no-splitting` flag instead.

### ES5 support

You can use `--target es5` to compile the code down to es5, it's processed by [buble](http://buble.surge.sh/). Some features are NOT supported by this target, namely: `for .. of`.
You can use `--target es5` to compile the code down to es5, in this target your code will be transpiled by esbuild to es2020 first, and then transpiled to es5 by [SWC](https://swc.rc).

### Compile-time environment variables

Expand All @@ -240,24 +240,24 @@ tsup src/index.ts --watch

Turn on watch mode. This means that after the initial build, tsup will continue to watch for changes in any of the resolved files.

> By default it always ignores `dist`, `node_modules` & `.git`
> INFO: By default it always ignores `dist`, `node_modules` & `.git`

```bash
tsup src/index.ts --watch --ignore-watch ignore-this-folder-too
```

> You can specify more than a folder repeating "--ignore-watch", for example: `tsup src src/index.ts --watch --ignore-watch folder1 --ignore-watch folder2`
> INFO: You can specify more than a folder repeating "--ignore-watch", for example: `tsup src src/index.ts --watch --ignore-watch folder1 --ignore-watch folder2`

### onSuccess

You can specify command to be executed after a successful build, specially useful for **Watch mode**

> You should not use shell scripts, if you need to specify shell scripts you can add it in your "scripts" field and set for example `tsup src/index.ts --watch --onSuccess \"npm run dev\"`

```bash
tsup src/index.ts --watch --onSuccess "node dist/index.js"
```

> Warning: You should not use shell scripts, if you need to specify shell scripts you can add it in your "scripts" field and set for example `tsup src/index.ts --watch --onSuccess \"npm run dev\"`

### Minify output

You can also minify the output, resulting into lower bundle sizes by using the `--minify` flag.
Expand Down Expand Up @@ -364,6 +364,12 @@ For more details:
tsup --help
```

## Troubleshooting

### error: No matching export in "xxx.ts" for import "xxx"

This usualy happens when you have `emitDecoratorMetadata` enabled in your tsconfig.json, in this mode we use [SWC](https://swc.rc) to transpile decorators to JavaScript so exported types will be eliminated, that's why esbuild won't be able to find corresponding exports. You can fix this by changing your import statement from `import { SomeType }` to `import { type SomeType }` or `import type { SomeType }`.

## License

MIT © [EGOIST](https://github.com/sponsors/egoist)
2 changes: 1 addition & 1 deletion docs/index.html
Expand Up @@ -12,7 +12,7 @@
<!-- Stylesheet -->
<link
rel="stylesheet"
href="https://unpkg.com/@egoist/docup@1/dist/docup.min.css"
href="https://unpkg.com/@egoist/docup@2/dist/docup.min.css"
/>
</head>
<body>
Expand Down
11 changes: 4 additions & 7 deletions package.json
Expand Up @@ -29,7 +29,7 @@
"ts"
],
"require": [
"sucrase//register"
"sucrase/register"
]
},
"dependencies": {
Expand All @@ -44,22 +44,19 @@
"postcss-load-config": "^3.0.1",
"resolve-from": "^5.0.0",
"rollup": "^2.60.0",
"sucrase": "^3.20.1",
"tree-kill": "^1.2.2"
"tree-kill": "^1.2.2",
"source-map": "^0.7.3",
"sucrase": "^3.20.3"
},
"devDependencies": {
"@babel/core": "^7.13.15",
"@rollup/plugin-json": "^4.1.0",
"@swc/core": "^1.2.112",
"@types/babel__core": "^7.1.16",
"@types/buble": "^0.19.2",
"@types/debug": "^4.1.5",
"@types/flat": "^5.0.2",
"@types/fs-extra": "^9.0.11",
"@types/node": "^14.14.41",
"@types/resolve": "^1.20.0",
"ava": "^4.0.0-rc.1",
"buble": "^0.20.0",
"colorette": "^2.0.16",
"consola": "^2.15.3",
"flat": "^5.0.2",
Expand Down