From fd3c021ab47f91e80591e148f6caadea95c82df1 Mon Sep 17 00:00:00 2001 From: saberzero1 Date: Mon, 27 Apr 2026 21:37:37 +0200 Subject: [PATCH] build: bundle dependencies and ship pre-built dist --- .github/workflows/ci.yml | 11 ++++++++++- tsup.config.ts | 15 ++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 13ee19f..d6c1a2c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,6 +28,15 @@ jobs: - name: Build run: npm run build + - name: Verify dist is up to date + run: | + if git diff --quiet dist/; then + echo "dist/ is up to date" + else + echo "::error::dist/ is stale. Run 'npm run build' and commit the result." + git diff --stat dist/ + exit 1 + fi - name: Verify dist externals run: | node -e " @@ -37,7 +46,7 @@ jobs: const pkg = JSON.parse(fs.readFileSync('package.json', 'utf-8')); const peerDeps = Object.keys(pkg.peerDependencies || {}); const builtins = new Set(['assert','buffer','child_process','cluster','console','constants','crypto','dgram','dns','domain','events','fs','http','http2','https','inspector','module','net','os','path','perf_hooks','process','punycode','querystring','readline','repl','stream','string_decoder','sys','timers','tls','trace_events','tty','url','util','v8','vm','wasi','worker_threads','zlib']); - const shared = ['@quartz-community/','preact','@jackyzha0/quartz','vfile']; + const shared = ['@quartz-community/','preact','@jackyzha0/quartz','vfile','unified']; const content = fs.readFileSync(dist, 'utf-8'); const re = /^\s*(?:import\s+.*\s+from|export\s+.*\s+from)\s+[\"']([^\"'./][^\"']*)[\"']/gm; const unexpected = new Set(); diff --git a/tsup.config.ts b/tsup.config.ts index e148734..1d46f2f 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -1,5 +1,17 @@ import { defineConfig } from "tsup"; +const SINGLETON_EXTERNALS = [ + "preact", + "preact/hooks", + "preact/jsx-runtime", + "preact/compat", + "@jackyzha0/quartz", + "@jackyzha0/quartz/*", + "vfile", + "vfile/*", + "unified", +]; + export default defineConfig({ entry: { index: "src/index.ts", @@ -14,7 +26,8 @@ export default defineConfig({ treeshake: true, target: "es2022", splitting: false, - noExternal: ["@quartz-community/utils"], + noExternal: [/.*/], + external: SINGLETON_EXTERNALS, outDir: "dist", platform: "node", esbuildOptions(options) {