fix(x402): add tsdown config to build middleware entry point (#48)

* fix(x402): add tsdown config to build middleware entry point

* adds optimizeDeps.exclude and ssr.optimizeDeps.exclude for @emdash-cms/x402 in the integration's Vite config

* fix CI typecheck

---------

Co-authored-by: Matt Kane <mkane@cloudflare.com>
This commit is contained in:
Mason Hall
2026-04-04 04:03:41 -04:00
committed by GitHub
parent 018be7f1c3
commit 036e0fc23a
2 changed files with 21 additions and 1 deletions

View File

@@ -49,7 +49,9 @@ export function x402(config: X402Config): AstroIntegration {
name: "@emdash-cms/x402", name: "@emdash-cms/x402",
hooks: { hooks: {
"astro:config:setup": ({ addMiddleware, updateConfig }) => { "astro:config:setup": ({ addMiddleware, updateConfig }) => {
// Inject the virtual module that provides config to the middleware // Inject the virtual module that provides config to the middleware.
// The middleware must be excluded from Vite's SSR dependency optimizer
// because esbuild cannot resolve virtual modules — only Vite plugins can.
updateConfig({ updateConfig({
vite: { vite: {
plugins: [ plugins: [
@@ -65,6 +67,14 @@ export function x402(config: X402Config): AstroIntegration {
}, },
}, },
], ],
optimizeDeps: {
exclude: ["@emdash-cms/x402"],
},
ssr: {
optimizeDeps: {
exclude: ["@emdash-cms/x402"],
},
},
}, },
}); });

View File

@@ -0,0 +1,10 @@
import { defineConfig } from "tsdown";
export default defineConfig({
entry: ["src/index.ts", "src/middleware.ts"],
format: ["esm"],
dts: true,
clean: true,
inlineOnly: false,
external: ["astro:middleware", "virtual:x402/config"],
});