fix-tsup-cjs
TypeScript icon, indicating that this package has built-in type declarations

1.2.0 • Public • Published

fix-tsup-cjs

Fix the commonjs default export statement and type definition of tsup output

npm version npm downloads codecov

Motivation

The default export statement in the commonjs format output by 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 and ESLint, because they only read require().

Usage

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 glob

For more info, run any command with the `--help` flag:
  $ fix-tsup-cjs --help

Options:
  --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 © 2023 u3u

Package Sidebar

Install

npm i fix-tsup-cjs

Weekly Downloads

316

Version

1.2.0

License

MIT

Unpacked Size

23.2 kB

Total Files

13

Last publish

Collaborators

  • u3u