build: bundle dependencies and ship pre-built dist

This commit is contained in:
saberzero1 2026-04-27 21:37:45 +02:00
parent 603fff35d3
commit 4c76de3ad3
No known key found for this signature in database
2 changed files with 24 additions and 1 deletions

View file

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

View file

@ -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",
@ -12,6 +24,8 @@ export default defineConfig({
treeshake: true,
target: "es2022",
splitting: false,
noExternal: [/.*/],
external: SINGLETON_EXTERNALS,
outDir: "dist",
platform: "node",
});