https://github.com/hoangvvo/tscd
tsc but for building TypeScript library with dual CJS/ESM output.
https://github.com/hoangvvo/tscd
Last synced: 2 months ago
JSON representation
tsc but for building TypeScript library with dual CJS/ESM output.
- Host: GitHub
- URL: https://github.com/hoangvvo/tscd
- Owner: hoangvvo
- License: mit
- Created: 2022-07-08T06:52:42.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-03-24T01:00:33.000Z (about 1 year ago)
- Last Synced: 2024-10-30T02:42:53.543Z (8 months ago)
- Language: JavaScript
- Homepage:
- Size: 117 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tscd
`tsc` but for building TypeScript library with dual CJS/ESM output.
Require `typescript` 4.7 or above.
## Installation
```sh
npm i tscd
```## Usage
Call `tscd` with the same args as `tsc`, with an addition of `entry` (defaulted to `index.js`) arg which is the entrypoint (with extension) with respect to `outDir`. Every options are passed to `tsc`.
```sh
tscd --entry index.js --outDir dist
```The command will build CJS and ESM versions of the library in two directories and also emitting the types. It will also update `package.json` with fields like below automatically:
```json
{
"exports": {
"import": {
"types": "./dist/types/index.d.ts",
"default": "./dist/esm/index.js"
},
"require": {
"types": "./dist/types/index.d.ts",
"default": "./dist/commonjs/index.cjs"
}
},
"main": "dist/commonjs/index.cjs",
"types": "dist/types/index.d.ts"
}
```Go ahead and publish your package. It will be usable in both CJS and ESM context.
## License
[MIT](LICENSE)