File tree Expand file tree Collapse file tree 3 files changed +65
-0
lines changed Expand file tree Collapse file tree 3 files changed +65
-0
lines changed Original file line number Diff line number Diff line change 1+ import { Command } from '@commander-js/extra-typings' ;
2+ import chalk from 'chalk' ;
3+ import { build , context , type BuildOptions } from 'esbuild' ;
4+
5+ /**
6+ * Returns a {@link Command} that executes with the provided ESBuild options.
7+ */
8+ export default function getBuildCommand ( esbuildOptions : Omit < BuildOptions , 'minify' > ) {
9+ return new Command ( )
10+ . option ( '--dev' , 'If specified, the built output is not minified for easier debugging' )
11+ . option ( '--watch' , 'Run esbuild in watch mode' )
12+ . action ( async ( { dev, watch } ) => {
13+ if ( watch ) {
14+ const buildContext = await context ( {
15+ ...esbuildOptions ,
16+ minify : ! dev ,
17+ plugins : [ {
18+ name : 'Watch Plugin' ,
19+ setup ( { onEnd } ) {
20+ onEnd ( ( ) => {
21+ console . log ( chalk . greenBright ( 'Build completed.' ) ) ;
22+ } ) ;
23+ }
24+ } ]
25+ } ) ;
26+ console . log ( chalk . yellowBright ( 'Running ESBuild in watch mode.' ) ) ;
27+ await buildContext . watch ( ) ;
28+ } else {
29+ await build ( esbuildOptions ) ;
30+ }
31+ } ) ;
32+ }
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " @sourceacademy/lib-compiler" ,
3+ "private" : true ,
4+ "version" : " 1.0.0" ,
5+ "type" : " module" ,
6+ "description" : " Wrapper around esbuild and commander to make it simpler to bundle library packages" ,
7+ "devDependencies" : {
8+ "@commander-js/extra-typings" : " ^13.0.0" ,
9+ "typescript" : " ^5.8.2"
10+ },
11+ "dependencies" : {
12+ "chalk" : " ^5.0.1" ,
13+ "commander" : " ^13.0.0" ,
14+ "esbuild" : " ^0.25.5"
15+ },
16+ "exports" : {
17+ "." : {
18+ "types" : " ./index.ts" ,
19+ "default" : " ./dist/index.js"
20+ }
21+ },
22+ "scripts" : {
23+ "build" : " yarn tsc"
24+ }
25+ }
Original file line number Diff line number Diff line change 1+ {
2+ "include" : [" ./index.ts" ],
3+ "compilerOptions" : {
4+ "module" : " nodenext" ,
5+ "moduleResolution" : " nodenext" ,
6+ "outDir" : " ./dist"
7+ }
8+ }
You can’t perform that action at this time.
0 commit comments