-
-
Notifications
You must be signed in to change notification settings - Fork 354
/
Copy pathdev.ts
75 lines (63 loc) · 1.53 KB
/
dev.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
Run Rollup in watch mode for development.
To specific the package to watch, simply pass its name and the desired build
formats to watch (defaults to "global"):
```
# name supports fuzzy match. will watch all packages with name containing "core-base"
pnpm dev core-base
# specify the format to output
pnpm dev core --formats mjs
# Can also drop all __DEV__ blocks with:
__DEV__=false pnpm run dev
```
*/
import { execa } from 'execa'
import { spawnSync } from 'node:child_process'
import { parseArgs } from 'node:util'
import { fuzzyMatchTarget } from './utils'
const commit = spawnSync('git', ['rev-parse', '--short=7', 'HEAD'])
.stdout.toString()
.trim()
const { values, positionals: targets } = parseArgs({
allowPositionals: true,
options: {
formats: {
type: 'string',
short: 'f'
},
sourceMap: {
type: 'boolean',
short: 's'
}
}
})
const { formats: rawFormats, sourceMap } = values
const formats = rawFormats?.split(',')
async function main() {
const resolveTarget = targets.length
? (await fuzzyMatchTarget(targets))[0]
: 'vue-i18n'
// eslint-disable-next-line @typescript-eslint/no-floating-promises
execa(
'rollup',
[
'-wc',
'--environment',
[
`COMMIT:${commit}`,
`TARGET:${resolveTarget}`,
`FORMATS:${formats || 'global'}`,
sourceMap ? `SOURCE_MAP:true` : ``
]
.filter(Boolean)
.join(',')
],
{
stdio: 'inherit'
}
)
}
main().catch(err => {
console.error(err)
process.exit(1)
})