From 7c2bb4ee4c4ee4d6abc8f7f3757d40c039a1bcac Mon Sep 17 00:00:00 2001
From: Jacky Zhao <j.zhao2k19@gmail.com>
Date: Mon, 24 Jul 2023 00:58:35 +0000
Subject: [PATCH] bundleinfo flag, minify scripts
---
content/features/upcoming features.md | 1 -
quartz/bootstrap-cli.mjs | 12 ++++++++++--
quartz/components/scripts/graph.inline.ts | 2 +-
3 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/content/features/upcoming features.md b/content/features/upcoming features.md
index fbfccf8..dbd5a17 100644
--- a/content/features/upcoming features.md
+++ b/content/features/upcoming features.md
@@ -4,7 +4,6 @@
## high priority
-- attachments path
- inspect bundle size generated by esbuild (it shouldnt be that high)
- component resources should be emitted by an emitter
- https://help.obsidian.md/Editing+and+formatting/Tags#Nested+tags nested tags??
diff --git a/quartz/bootstrap-cli.mjs b/quartz/bootstrap-cli.mjs
index f25484b..475e624 100755
--- a/quartz/bootstrap-cli.mjs
+++ b/quartz/bootstrap-cli.mjs
@@ -79,6 +79,11 @@
default: 8080,
describe: "port to serve Quartz on",
},
+ bundleInfo: {
+ boolean: true,
+ default: false,
+ describe: "show detailed bundle information"
+ }
}
function escapePath(fp) {
@@ -284,6 +289,7 @@
outfile: path.join("quartz", cacheFile),
bundle: true,
keepNames: true,
+ minify: true,
platform: "node",
format: "esm",
jsx: "automatic",
@@ -315,6 +321,7 @@
sourcefile,
},
write: false,
+ minify: true,
bundle: true,
platform: "browser",
format: "esm",
@@ -338,13 +345,14 @@
process.exit(1)
})
- if (argv.verbose) {
+ if (argv.bundleInfo) {
const outputFileName = "quartz/.quartz-cache/transpiled-build.mjs"
const meta = result.metafile.outputs[outputFileName]
console.log(
`Successfully transpiled ${Object.keys(meta.inputs).length} files (${prettyBytes(
meta.bytes,
- )})`,
+ )})`)
+ console.log(await esbuild.analyzeMetafile(result.metafile, { color: true })
)
}
diff --git a/quartz/components/scripts/graph.inline.ts b/quartz/components/scripts/graph.inline.ts
index bd57f7d..f3f5cbd 100644
--- a/quartz/components/scripts/graph.inline.ts
+++ b/quartz/components/scripts/graph.inline.ts
@@ -1,4 +1,4 @@
-import { ContentDetails } from "../../plugins/emitters/contentIndex"
+import type { ContentDetails } from "../../plugins/emitters/contentIndex"
import * as d3 from "d3"
import { registerEscapeHandler, removeAllChildren } from "./util"
import { CanonicalSlug, getCanonicalSlug, getClientSlug, resolveRelative } from "../../path"
--
Gitblit v1.10.0