https://github.com/u3u/fix-tsup-cjs
Fix the commonjs default export statement and type definition of tsup output
https://github.com/u3u/fix-tsup-cjs
commonjs tsup
Last synced: 7 months ago
JSON representation
Fix the commonjs default export statement and type definition of tsup output
- Host: GitHub
- URL: https://github.com/u3u/fix-tsup-cjs
- Owner: u3u
- License: mit
- Created: 2023-05-02T12:04:42.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-03-10T06:09:25.000Z (7 months ago)
- Last Synced: 2025-03-11T03:51:40.491Z (7 months ago)
- Topics: commonjs, tsup
- Language: TypeScript
- Homepage:
- Size: 146 KB
- Stars: 11
- Watchers: 1
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# fix-tsup-cjs
> Fix the `commonjs` default export statement and type definition of [tsup](https://github.com/egoist/tsup) output
[](https://npm.im/fix-tsup-cjs) [](https://npm.im/fix-tsup-cjs) [](https://codecov.io/gh/u3u/fix-tsup-cjs)
## Motivation
The default export statement in the `commonjs` format output by [tsup](https://github.com/egoist/tsup) is `module.exports.default`, which means that you actually need to import it through `require().default`. This cannot be directly used for configuration files such as [Prettier](https://prettier.io/docs/en/configuration.html#basic-configuration) and [ESLint](https://eslint.org/docs/latest/extend/shareable-configs), because they only read `require()`.
## Usage
```sh
tsup && npx fix-tsup-cjs
```> _Note: By default, `dist/**/*.js` will be fixed. If the `type` in your `package.json` is set to `module`, then `dist/**/*.cjs` will be fixed._
## CLI Options
```
Usage:
$ fix-tsup-cjs [...files]Commands:
[...files] Custom matching files globFor more info, run any command with the `--help` flag:
$ fix-tsup-cjs --helpOptions:
--cwd [path] Set fix directory (default: dist)
--dts Fix commonjs d.ts and d.cts files (default: true)
-i, --ignore [...files] Ignore files
--silent Suppress logs
-v, --version Display version number
-h, --help Display this message
```## License
[MIT](./LICENSE) License © 2023 [u3u](https://github.com/u3u)