@@ -284,7 +284,7 @@ export class Project {
284
284
}
285
285
}
286
286
287
- // wait project ready
287
+ // wait for project ready
288
288
await this . ready
289
289
290
290
// lookup output modules
@@ -295,13 +295,13 @@ export class Project {
295
295
lookup ( '//deno.land/x/aleph/nomodule.js' )
296
296
lookup ( '//deno.land/x/aleph/tsc/tslib.js' )
297
297
298
- // ensure ouput directory ready
299
298
if ( existsDirSync ( outputDir ) ) {
300
299
await Deno . remove ( outputDir , { recursive : true } )
301
300
}
302
301
await ensureDir ( outputDir )
303
302
await ensureDir ( distDir )
304
303
304
+ // ssg
305
305
const { ssr } = this . config
306
306
if ( ssr ) {
307
307
log . info ( colors . bold ( ' Pages (SSG)' ) )
@@ -329,22 +329,19 @@ export class Project {
329
329
const fi = await Deno . lstat ( p )
330
330
await ensureDir ( path . dirname ( fp ) )
331
331
await Deno . copyFile ( p , fp )
332
- let sizeColorful = colors . dim
333
- if ( fi . size > 10 * MB ) {
334
- sizeColorful = colors . red
335
- } else if ( fi . size > MB ) {
336
- sizeColorful = colors . yellow
337
- }
338
332
log . info ( ' ✹' , rp , colors . dim ( '•' ) , getColorfulBytesString ( fi . size ) )
339
333
}
340
334
}
341
335
342
- let deps = 0
343
- let depsBytes = 0
344
- let modules = 0
345
- let modulesBytes = 0
346
- let styles = 0
347
- let stylesBytes = 0
336
+ const moduleState = {
337
+ deps : { bytes : 0 , count : 0 } ,
338
+ modules : { bytes : 0 , count : 0 } ,
339
+ styles : { bytes : 0 , count : 0 }
340
+ }
341
+ const logModule = ( key : 'deps' | 'modules' | 'styles' , size : number ) => {
342
+ moduleState [ key ] . bytes += size
343
+ moduleState [ key ] . count ++
344
+ }
348
345
349
346
// write modules
350
347
const { sourceMap } = this . config
@@ -354,15 +351,12 @@ export class Project {
354
351
const name = path . basename ( sourceFilePath ) . replace ( reModuleExt , '' )
355
352
const jsFile = path . join ( saveDir , name + ( isRemote ? '' : '.' + hash . slice ( 0 , hashShort ) ) ) + '.js'
356
353
if ( isRemote ) {
357
- deps ++
358
- depsBytes += jsContent . length
354
+ logModule ( 'deps' , jsContent . length )
359
355
} else {
360
356
if ( sourceType === 'css' || sourceType === 'less' ) {
361
- styles ++
362
- stylesBytes += jsContent . length
357
+ logModule ( 'styles' , jsContent . length )
363
358
} else {
364
- modules ++
365
- modulesBytes += jsContent . length
359
+ logModule ( 'modules' , jsContent . length )
366
360
}
367
361
}
368
362
return Promise . all ( [
@@ -376,15 +370,15 @@ export class Project {
376
370
const { hash } = this . #modules. get ( '/data.js' ) !
377
371
const data = await this . getStaticData ( )
378
372
const jsContent = `export default ${ JSON . stringify ( data ) } `
379
- modules ++
380
- modulesBytes += jsContent . length
381
373
await writeTextFile ( path . join ( distDir , `data.${ hash . slice ( 0 , hashShort ) } .js` ) , jsContent )
374
+ logModule ( 'modules' , jsContent . length )
382
375
}
383
376
377
+ const { deps, modules, styles } = moduleState
384
378
log . info ( colors . bold ( ' Modules' ) )
385
- log . info ( ' ▲' , colors . bold ( deps . toString ( ) ) , 'deps' , colors . dim ( `• ${ util . bytesString ( depsBytes ) } (mini, uncompress)` ) )
386
- log . info ( ' ▲' , colors . bold ( modules . toString ( ) ) , 'modules' , colors . dim ( `• ${ util . bytesString ( modulesBytes ) } (mini, uncompress)` ) )
387
- log . info ( ' ▲' , colors . bold ( styles . toString ( ) ) , 'styles' , colors . dim ( `• ${ util . bytesString ( stylesBytes ) } (mini, uncompress)` ) )
379
+ log . info ( ' ▲' , colors . bold ( deps . count . toString ( ) ) , 'deps' , colors . dim ( `• ${ util . bytesString ( deps . bytes ) } (mini, uncompress)` ) )
380
+ log . info ( ' ▲' , colors . bold ( modules . count . toString ( ) ) , 'modules' , colors . dim ( `• ${ util . bytesString ( modules . bytes ) } (mini, uncompress)` ) )
381
+ log . info ( ' ▲' , colors . bold ( styles . count . toString ( ) ) , 'styles' , colors . dim ( `• ${ util . bytesString ( styles . bytes ) } (mini, uncompress)` ) )
388
382
389
383
log . info ( `Done in ${ Math . round ( performance . now ( ) - start ) } ms` )
390
384
}
0 commit comments