From 3ac6b42e16dca5a44ed3fec2c0314f1dbbc2322b Mon Sep 17 00:00:00 2001
From: Jacky Zhao <j.zhao2k19@gmail.com>
Date: Sun, 16 Jul 2023 06:02:12 +0000
Subject: [PATCH] finish path refactoring, add sourcemap + better trace support

---
 quartz/bootstrap-cli.mjs |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/quartz/bootstrap-cli.mjs b/quartz/bootstrap-cli.mjs
index b1503f2..bb83fe0 100755
--- a/quartz/bootstrap-cli.mjs
+++ b/quartz/bootstrap-cli.mjs
@@ -9,6 +9,7 @@
 import fs from 'fs'
 import { intro, isCancel, outro, select, text } from '@clack/prompts'
 import { rimraf } from 'rimraf'
+import prettyBytes from 'pretty-bytes'
 
 const cacheFile = "./.quartz-cache/transpiled-build.mjs"
 const fp = "./quartz/build.ts"
@@ -133,7 +134,7 @@
 `)
   })
   .command('build', 'Build Quartz into a bundle of static HTML files', BuildArgv, async (argv) => {
-    await esbuild.build({
+    const result = await esbuild.build({
       entryPoints: [fp],
       outfile: path.join("quartz", cacheFile),
       bundle: true,
@@ -143,6 +144,8 @@
       jsx: "automatic",
       jsxImportSource: "preact",
       packages: "external",
+      metafile: true,
+      sourcemap: true,
       plugins: [
         sassPlugin({
           type: 'css-text',
@@ -186,6 +189,12 @@
       process.exit(1)
     })
 
+    if (argv.verbose) {
+      const outputFileName = 'quartz/.quartz-cache/transpiled-build.mjs'
+      const meta = result.metafile.outputs[outputFileName]
+      console.log(chalk.gray(`[debug] Successfully transpiled ${Object.keys(meta.inputs).length} files (${prettyBytes(meta.bytes)})`))
+    }
+
     const { default: init } = await import(cacheFile)
     init(argv, version)
   })

--
Gitblit v1.10.0