Skip to content

Commit

Permalink
feat: make experimental cjs code splitting available behine flag `--s…
Browse files Browse the repository at this point in the history
…plitting`

closes #408
  • Loading branch information
egoist committed Sep 16, 2021
1 parent c939d4d commit 1667fd2
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 68 deletions.
9 changes: 6 additions & 3 deletions docs/README.md
Expand Up @@ -33,9 +33,6 @@ tsup src/index.ts src/cli.ts
```

This will output `dist/index.js` and `dist/cli.js`.

Code splitting only works in `esm` format and is enabled by default.

### Excluding packages

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.
Expand Down Expand Up @@ -188,6 +185,12 @@ dist
└── index.js
```

## Code Splitting

Code splitting currently only works with the `esm` output format, and it's enabled by default. If you want code splitting for `cjs` output format as well, try using `--splitting` flag which is an experimental feature to get rid of [the limitation in esbuild](https://esbuild.github.io/api/#splitting).

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`.
Expand Down

1 comment on commit 1667fd2

@vercel
Copy link

@vercel vercel bot commented on 1667fd2 Sep 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.