ReviewOS

also looking at this

stacks/ts-analytics

fix: emit a real library build (dist/index.js + ./stx) so the package is importable

#124
Merged glennmichael123 wants to merge fix/library-build into main
6 files +72 -13
9 days ago

build.ts was generateStaticSite({ outputDir: 'dist' }) — a static dashboard site, not a library. So dist/ had only 404.html + assets, and the entry points package.json references (module/exports/types → dist/index.js, dist/integrations/stx.js, dist/index.d.ts) never existed. Neither @stacksjs/ts-analytics nor @stacksjs/ts-analytics/stx (the tsAnalytics() module from #0047f42) was importable once installed/published — it only worked from source.

Fix

  • build.ts → Bun.build over the . and ./stx entrypoints (src/index.ts + src/integrations/stx.ts), bun-plugin-dtsx for declarations, packages: 'external' → dist/index.js + dist/integrations/stx.js + both .d.ts.
  • Dashboard site moves to bun run build:site → dist-site/ (so the SSG's cleanOutput stops wiping the library). preview.ts follows. Lambda deploy untouched — it uses scripts/build-views.ts.
  • Tracker hardening: JSON.stringify siteId/apiEndpoint in buildConfigSection (was raw single-quote interpolation — a quote/</script>/newline breakout for any inline-tracker consumer).

Verified

  • bun run build → dist/index.js + dist/integrations/stx.js + both .d.ts.
  • @stacksjs/ts-analytics/stx resolves tsAnalytics/tsAnalyticsTag; tsAnalyticsTag({ appId: 'bench-review', apiEndpoint: 'http://localhost:2027' }) → <script defer data-site="bench-review" src="http://localhost:2027/script.js"></script>.
  • Existing analytics tests: 157 pass / 0 fail.

Stacks on top of your feat(integrations) 0047f42 (the tsAnalytics() integration) — this just makes it shippable.

6 changed files on the files tab, with 0 review threads.

Sign in to comment on this pull request.