Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
egoist committed Mar 19, 2020
0 parents commit 2999775
Show file tree
Hide file tree
Showing 6 changed files with 1,426 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
*.log
dist
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# tsup

A bundler focusing on TypeScript experience, based on Rollup.

## Install

Install it locally in your project folder:

```bash
npm i tsup -D
# Or Yarn
yarn add tsup --dev
```

You can also install it globally but it's not recommended.

## License

MIT.
22 changes: 22 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "tsup",
"version": "1.0.0",
"main": "index.js",
"author": "EGOIST",
"license": "MIT",
"devDependencies": {
"@types/node": "^13.9.2",
"cac": "^6.5.7",
"rollup": "^2.1.0",
"rollup-plugin-typescript2": "^0.26.0",
"ts-node": "^8.7.0"
},
"dependencies": {
"@babel/core": "^7.8.7",
"@babel/preset-env": "^7.8.7",
"@babel/preset-typescript": "^7.8.3",
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-hashbang": "^2.2.2",
"typescript": "^3.8.3"
}
}
40 changes: 40 additions & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env node
import { readFileSync } from 'fs'
import {join} from 'path'
import { cac } from 'cac'

const cli = cac('tsup')

cli.command('[file]', 'Bundle a speific file')
.option('--format <format>', 'Bundle format')
.action(async (file: string, options) => {
const {rollup} = await import('rollup')

return rollup({
input: file,
plugins: [
require('rollup-plugin-hashbang')(),
require('rollup-plugin-babel')({
extensions: ['.js', '.jsx', '.ts', '.tsx'],
presets: [
[require.resolve('@babel/preset-env'), {
modules: false
}],
require.resolve('@babel/preset-typescript')
]
})
]
}).then(result => {
result.write({
dir: 'dist',
format: options.format || 'cjs'
})
})
})

cli.help()

const pkgPath = join(__dirname, '../package.json')
cli.version(JSON.parse(readFileSync(pkgPath, 'utf8')).version)

cli.parse()
Empty file added src/index.ts
Empty file.
Loading

0 comments on commit 2999775

Please sign in to comment.