https://github.com/zhangyu1818/tscb
A lightweight TypeScript packaging library
https://github.com/zhangyu1818/tscb
typescript typescript-library
Last synced: 9 months ago
JSON representation
A lightweight TypeScript packaging library
- Host: GitHub
- URL: https://github.com/zhangyu1818/tscb
- Owner: zhangyu1818
- Created: 2023-07-10T10:16:12.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-07-11T09:08:09.000Z (over 2 years ago)
- Last Synced: 2025-03-03T03:34:30.257Z (10 months ago)
- Topics: typescript, typescript-library
- Language: TypeScript
- Homepage:
- Size: 38.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# tscb
A lightweight TypeScript packaging library that solves the issue of tsconfig not being able to output both cjs and esm files simultaneously.
## Install
```shell
npm install tscb
```
## Usage
`tscb` will read the configuration from `tscb.config.js` or `package.json`, and any new configuration will overwrite the settings in the project's `tsconfig.json`.
```json
// package.json
{
"tscb": [
{
"compilerOptions": {
"module": "es2015",
"outDir": "dist",
"declaration": true
}
},
{
"compilerOptions": {
"module": "commonjs",
"outDir": "dist/cjs"
},
"include": ["lib"]
}
]
}
```
```js
// tscb.config.js
module.exports = [
{
compilerOptions: {
module: 'es2015',
outDir: 'dist',
declaration: true,
},
},
{
compilerOptions: {
module: 'commonjs',
outDir: 'dist/cjs',
},
include: ['lib'],
},
]
```
Please note, if your project is set to `"type": "module"`, you need to change the configuration file suffix to cjs - `tscb.config.cjs`.
Run the `tscb` command
```shell
tscb
```
or
```shell
npx tscb
```
## Command Line Arguments
```shell
tscb [--config /path/to/config] [--project /path/to/tsconfig]
```
## API
```ts
import { tscb } from 'tscb'
tscb({
compilerOptions: {
module: 'commonjs',
outDir: 'dist/cjs',
},
include: ['lib'],
})
```