mirror of
https://github.com/cockpit-project/cockpit.git
synced 2026-11-03 21:49:50 -09:00
build.js: support outputting esbuild metadata file
ESbuild supports outputting a metadata file which can be used to view bundle size information using https://esbuild.github.io/analyze/ Closes: #18267
This commit is contained in:
parent
81bc3677e9
commit
9f4cda65d5
1 changed files with 7 additions and 1 deletions
8
build.js
8
build.js
|
|
@ -50,9 +50,13 @@ const qunitOptions = {
|
|||
const parser = (await import('argparse')).default.ArgumentParser();
|
||||
parser.add_argument('-r', '--rsync', { help: "rsync bundles to ssh target after build", metavar: "HOST" });
|
||||
parser.add_argument('-w', '--watch', { action: 'store_true', help: "Enable watch mode" });
|
||||
parser.add_argument('-m', '--metafile', { help: "Enable bund size information file", metavar: "FILE" });
|
||||
parser.add_argument('onlydir', { nargs: '?', help: "The pkg/<DIRECTORY> to build (eg. base1, shell, ...)", metavar: "DIRECTORY" });
|
||||
const args = parser.parse_args();
|
||||
|
||||
if (args.metafile)
|
||||
pkgOptions.metafile = true;
|
||||
|
||||
if (args.onlydir?.includes('/'))
|
||||
parser.error("Directory must not contain '/'");
|
||||
|
||||
|
|
@ -201,7 +205,9 @@ async function build() {
|
|||
});
|
||||
|
||||
try {
|
||||
await Promise.all([pkgContext.rebuild(), qunitContext.rebuild()]);
|
||||
const results = await Promise.all([pkgContext.rebuild(), qunitContext.rebuild()]);
|
||||
if (args.metafile)
|
||||
fs.writeFileSync(args.metafile, JSON.stringify(results[0].metafile));
|
||||
} catch (e) {
|
||||
if (!args.watch)
|
||||
process.exit(1);
|
||||
|
|
|
|||
Loading…
Reference in a new issue