Skip to content

Commit 48691ed

Browse files
committed
node16, better info
1 parent 5e525e3 commit 48691ed

File tree

4 files changed

+18
-12
lines changed

4 files changed

+18
-12
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Think of it as doing code-splitting 'last', rather than first.
1515

1616
## Requirements
1717

18-
Node 14+.
18+
Node 16+.
1919

2020
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.
2121

app/cmd/info.ts

+10
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,18 @@ export default async function cmdInfo(args: InfoArgs) {
7171
console.info(`- ${g}${rw ? ' (written)' : ''}`);
7272
}
7373

74+
console.info('\nImports used at top-level:');
75+
for (const g of toplevelFind.imports.keys()) {
76+
console.info(`- ${g}`);
77+
}
78+
7479
console.info('\nGlobals used in callables:');
7580
for (const [g, rw] of nestedFind.globals) {
7681
console.info(`- ${g}${rw ? ' (written)' : ''}`);
7782
}
83+
84+
console.info('\nImports used in callables:');
85+
for (const g of nestedFind.imports.keys()) {
86+
console.info(`- ${g}`);
87+
}
7888
}

app/index.ts

+6-10
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
#!/usr/bin/env node
22

33
import * as cmd from './lib/cmd.ts';
4-
import cmdSplit from './cmd/split.ts';
5-
import cmdInfo from './cmd/info.ts';
64

75
cmd.register('info', {
86
description: 'Show information about a JS module file',
97
positional: true,
108
usageSuffix: '<path>',
11-
handler(res) {
9+
async handler(res) {
1210
if (res.positionals.length !== 1) {
1311
throw new cmd.CommandError();
1412
}
1513

14+
const { default: cmdInfo } = await import('./cmd/info.ts');
1615
return cmdInfo({ path: res.positionals[0] });
1716
},
1817
});
@@ -49,15 +48,16 @@ cmd.register('split', {
4948
default: '',
5049
short: 'n',
5150
help: 'output basename (default to basename of source)',
52-
}
51+
},
5352
},
5453
positional: true,
5554
usageSuffix: '<source> <outdir/>',
56-
handler(res) {
55+
async handler(res) {
5756
if (res.positionals.length !== 2) {
5857
throw new cmd.CommandError();
5958
}
6059

60+
const { default: cmdSplit } = await import('./cmd/split.ts');
6161
return cmdSplit({
6262
min: +(res.values['min'] ?? 0),
6363
keep: +(res.values['keep'] ?? 0),
@@ -70,8 +70,4 @@ cmd.register('split', {
7070
},
7171
});
7272

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();

app/lib/cmd.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,4 @@ export const run = (argv = process.argv.slice(2)): any => {
7979
process.exit(v['help'] ? 0 : 1);
8080
};
8181

82-
export class CommandError extends Error { }
82+
export class CommandError extends Error {}

0 commit comments

Comments
 (0)