File tree 4 files changed +18
-12
lines changed
4 files changed +18
-12
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ Think of it as doing code-splitting 'last', rather than first.
15
15
16
16
## Requirements
17
17
18
- Node 14 +.
18
+ Node 16 +.
19
19
20
20
Kuto works best on large (>1mb) singular JS bundles 'bundled' to ESM — the tool works on a statement level, and an IIFE/webpack output is one giant statement.
21
21
Original file line number Diff line number Diff line change @@ -71,8 +71,18 @@ export default async function cmdInfo(args: InfoArgs) {
71
71
console . info ( `- ${ g } ${ rw ? ' (written)' : '' } ` ) ;
72
72
}
73
73
74
+ console . info ( '\nImports used at top-level:' ) ;
75
+ for ( const g of toplevelFind . imports . keys ( ) ) {
76
+ console . info ( `- ${ g } ` ) ;
77
+ }
78
+
74
79
console . info ( '\nGlobals used in callables:' ) ;
75
80
for ( const [ g , rw ] of nestedFind . globals ) {
76
81
console . info ( `- ${ g } ${ rw ? ' (written)' : '' } ` ) ;
77
82
}
83
+
84
+ console . info ( '\nImports used in callables:' ) ;
85
+ for ( const g of nestedFind . imports . keys ( ) ) {
86
+ console . info ( `- ${ g } ` ) ;
87
+ }
78
88
}
Original file line number Diff line number Diff line change 1
1
#!/usr/bin/env node
2
2
3
3
import * as cmd from './lib/cmd.ts' ;
4
- import cmdSplit from './cmd/split.ts' ;
5
- import cmdInfo from './cmd/info.ts' ;
6
4
7
5
cmd . register ( 'info' , {
8
6
description : 'Show information about a JS module file' ,
9
7
positional : true ,
10
8
usageSuffix : '<path>' ,
11
- handler ( res ) {
9
+ async handler ( res ) {
12
10
if ( res . positionals . length !== 1 ) {
13
11
throw new cmd . CommandError ( ) ;
14
12
}
15
13
14
+ const { default : cmdInfo } = await import ( './cmd/info.ts' ) ;
16
15
return cmdInfo ( { path : res . positionals [ 0 ] } ) ;
17
16
} ,
18
17
} ) ;
@@ -49,15 +48,16 @@ cmd.register('split', {
49
48
default : '' ,
50
49
short : 'n' ,
51
50
help : 'output basename (default to basename of source)' ,
52
- }
51
+ } ,
53
52
} ,
54
53
positional : true ,
55
54
usageSuffix : '<source> <outdir/>' ,
56
- handler ( res ) {
55
+ async handler ( res ) {
57
56
if ( res . positionals . length !== 2 ) {
58
57
throw new cmd . CommandError ( ) ;
59
58
}
60
59
60
+ const { default : cmdSplit } = await import ( './cmd/split.ts' ) ;
61
61
return cmdSplit ( {
62
62
min : + ( res . values [ 'min' ] ?? 0 ) ,
63
63
keep : + ( res . values [ 'keep' ] ?? 0 ) ,
@@ -70,8 +70,4 @@ cmd.register('split', {
70
70
} ,
71
71
} ) ;
72
72
73
- // TODO: until we rev from node14
74
- const p = Promise . resolve ( cmd . run ( ) ) ;
75
- p . catch ( ( e ) => {
76
- throw e ;
77
- } ) ;
73
+ await cmd . run ( ) ;
Original file line number Diff line number Diff line change @@ -79,4 +79,4 @@ export const run = (argv = process.argv.slice(2)): any => {
79
79
process . exit ( v [ 'help' ] ? 0 : 1 ) ;
80
80
} ;
81
81
82
- export class CommandError extends Error { }
82
+ export class CommandError extends Error { }
You can’t perform that action at this time.
0 commit comments