@@ -8,12 +8,12 @@ const WATCH = [
8
8
"./dictionary/misc.ts" ,
9
9
"./dictionary/parser.ts" ,
10
10
"./dictionary/type.ts" ,
11
- "./telo-misikeke/linku-data .json" ,
12
- "./telo-misikeke /Parser.js" ,
13
- "./telo-misikeke /rules.js" ,
14
- "./telo-misikeke/telo-misikeke .js" ,
11
+ "./telo_misikeke/linku_data .json" ,
12
+ "./telo_misikeke /Parser.js" ,
13
+ "./telo_misikeke /rules.js" ,
14
+ "./telo_misikeke/telo_misikeke .js" ,
15
15
"./src/" ,
16
- "./project-data .json" ,
16
+ "./project_data .json" ,
17
17
] ;
18
18
const DICTIONARY = / d i c t i o n a r y [ / \\ ] [ ^ / \\ ] + $ / ;
19
19
@@ -25,24 +25,30 @@ function buildOptions(minify: boolean): ESBuild.BuildOptions {
25
25
bundle : true ,
26
26
minify,
27
27
sourcemap : "linked" ,
28
+ target : [ `es${ new Date ( ) . getFullYear ( ) - 3 } ` ] ,
28
29
plugins : [ ...denoPlugins ( ) ] ,
29
30
} ;
30
31
}
31
- async function buildAll ( options : {
32
- minify : boolean ;
33
- buildDictionary : boolean ;
34
- checkDictionary ?: boolean ;
35
- } ) : Promise < void > {
32
+ async function buildAll (
33
+ options : Readonly < {
34
+ minify : boolean ;
35
+ buildDictionary : boolean ;
36
+ checkDictionary ?: boolean ;
37
+ } > ,
38
+ ) : Promise < void > {
36
39
const { minify, buildDictionary, checkDictionary } = options ;
37
40
try {
38
41
if ( buildDictionary ) {
39
42
const Dictionary = await import ( "./dictionary/build.ts" ) ;
40
43
await Dictionary . build ( checkDictionary ?? true ) ;
41
44
}
45
+ // deno-lint-ignore no-console
42
46
console . log ( "Building main.js..." ) ;
43
47
await ESBuild . build ( buildOptions ( minify ) ) ;
48
+ // deno-lint-ignore no-console
44
49
console . log ( "Building done!" ) ;
45
50
} catch ( error ) {
51
+ // deno-lint-ignore no-console
46
52
console . error ( error ) ;
47
53
}
48
54
}
@@ -53,33 +59,29 @@ if (import.meta.main) {
53
59
break ;
54
60
}
55
61
case "watch" : {
62
+ // deno-lint-ignore no-console
56
63
console . log ( "Press ctrl+c to exit." ) ;
57
64
const watcher = Deno . watchFs ( WATCH ) ;
58
65
let task = Promise . resolve ( ) ;
59
- try {
60
- await buildAll ( { minify : false , buildDictionary : true } ) ;
61
- let dictionaryChanged = false ;
62
- const buildDebounced = debounce ( ( buildDictionary : boolean ) => {
63
- task = task . then ( async ( ) => {
64
- await buildAll ( {
65
- minify : true ,
66
- buildDictionary,
67
- checkDictionary : false ,
68
- } ) ;
69
- dictionaryChanged = false ;
66
+ await buildAll ( { minify : false , buildDictionary : true } ) ;
67
+ let dictionaryChanged = false ;
68
+ const buildDebounced = debounce ( ( buildDictionary : boolean ) => {
69
+ task = task . then ( async ( ) => {
70
+ await buildAll ( {
71
+ minify : false ,
72
+ buildDictionary,
73
+ checkDictionary : false ,
70
74
} ) ;
71
- } , 500 ) ;
72
- for await ( const event of watcher ) {
73
- if ( event . paths . some ( ( path ) => DICTIONARY . test ( path ) ) ) {
74
- dictionaryChanged = true ;
75
- }
76
- buildDebounced ( dictionaryChanged ) ;
75
+ dictionaryChanged = false ;
76
+ } ) ;
77
+ } , 500 ) ;
78
+ for await ( const event of watcher ) {
79
+ if ( event . paths . some ( ( path ) => DICTIONARY . test ( path ) ) ) {
80
+ dictionaryChanged = true ;
77
81
}
78
- throw new Error ( "unreachable" ) ;
79
- } finally {
80
- watcher . close ( ) ;
81
- await task ;
82
+ buildDebounced ( dictionaryChanged ) ;
82
83
}
84
+ throw new Error ( "unreachable" ) ;
83
85
}
84
86
default :
85
87
throw new Error ( `unrecognized build option: ${ Deno . args [ 0 ] } ` ) ;
0 commit comments