File tree 2 files changed +29
-2
lines changed
2 files changed +29
-2
lines changed Original file line number Diff line number Diff line change
1
+ import { mkdir , rename } from "fs/promises" ;
2
+ import { cp } from "fs/promises" ;
3
+ import { rm } from "fs/promises" ;
4
+ import { join } from "path" ;
5
+ import bunfig from "./bunfig.toml" ;
6
+ import pkg from "./package.json" ;
7
+
8
+ await rm ( bunfig . build . outdir , { recursive : true , force : true } ) ;
9
+ await mkdir ( bunfig . build . outdir , { recursive : true } ) ;
10
+
11
+ await Promise . all ( [ esm ( ) , cjs ( ) , types ( ) ] ) ;
12
+
13
+ function cjs ( ) {
14
+ return Bun . build ( { ...bunfig . build , format : "cjs" } ) ;
15
+ }
16
+
17
+ async function esm ( ) {
18
+ await Bun . build ( { ...bunfig . build , format : "esm" } ) ;
19
+ const jsPath = join ( bunfig . build . outdir , "index.js" ) ;
20
+ const mjsPath = join ( process . cwd ( ) , pkg . module ) ;
21
+ return rename ( jsPath , mjsPath ) ;
22
+ }
23
+
24
+ function types ( ) {
25
+ const srcTypesPath = join ( process . cwd ( ) , "src/types.ts" ) ;
26
+ const outTypesPath = join ( process . cwd ( ) , pkg . types ) ;
27
+ return cp ( srcTypesPath , outTypesPath ) ;
28
+ }
Original file line number Diff line number Diff line change 28
28
" dist"
29
29
],
30
30
"scripts" : {
31
- "prebuild" : " shx rm -rf dist" ,
32
- "build" : " rollup -c --environment NODE_ENV:production" ,
31
+ "build" : " bun run build.ts" ,
33
32
"commit" : " commit" ,
34
33
"prelint" : " prettier -l --write ." ,
35
34
"lint" : " eslint --ext .ts,.js --fix ." ,
You can’t perform that action at this time.
0 commit comments