build(dashboard): bundle via tsup so refactor can use TypeScript modules#29
Merged
Conversation
The dashboard refactor (#28) needs to extract panels into typed modules. Plain ESM-from-CDN can't follow `import` paths to local sibling files at request time, so app.js has to go through a bundler before it lands on the browser. Reusing the existing tsup toolchain keeps build infra consistent with src/. - tsup.config.ts adds a third entry: `dashboard/app.js` → `dashboard/dist/app.js`. Browser target, externals match `^https://` so esm.sh imports stay as live URLs in the output. - dashboard/tsconfig.json extends the root config, swaps Node types for DOM, allowJs so the legacy app.js compiles unmodified while new TS modules under dashboard/src/ get strict checks. - src/server/assets.ts reads app.js from `dashboard/dist/`; new branch serves the sourcemap. - typecheck script chains both root + dashboard projects; verify now runs build first (matches the bundle-smoke pattern that already assumes CI builds before tests). - package.json files: ship `dashboard/dist/` instead of the raw source app.js for npm consumers. - Asset test that touches /assets/app.js skips when `dashboard/dist/app.js` is missing — same convention as the existing tests/bundle-smoke.test.ts. No behavioral change at the dashboard level — esbuild passes the source through; CDN imports stay external. First real TS module extraction follows in a separate PR.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The dashboard refactor (#28) needs to extract panels into typed modules under
dashboard/src/. Plain ESM-from-CDN can't followimport { x } from "./lib/format"to local sibling files at request time, soapp.jshas to be bundled before it lands on the browser.The original tracking issue mistakenly listed "no build step" as a constraint. That's wrong for a TypeScript-everywhere project —
src/is already strict TS, but the dashboard was the only directory with plain.js. This PR removes that inconsistency by reusing the existing tsup pipeline.This PR is pure infrastructure. No behavior change to the dashboard itself —
dashboard/app.jspasses through esbuild unmodified; CDN imports stay as livehttps://esm.sh/...URLs in the bundled output. The first real TS module extraction (dashboard/src/lib/format.ts) lands in the next PR.Changes
tsup.config.ts— third entry:dashboard/app.js→dashboard/dist/app.js.target: es2022,platform: browser,external: [/^https:\/\//]so esm.sh imports stay as live URLs.dashboard/tsconfig.json(new) — extends root config; swapstypes: ["node"]for browserlib: ["ES2023", "DOM", "DOM.Iterable"];allowJs: trueso the legacyapp.jscompiles unmodified while new TS modules underdashboard/src/get strict checks.src/server/assets.ts—loadApp()reads fromdashboard/dist/app.js; newloadAppMap()serves the sourcemap (404s if missing).package.json:filesshipsdashboard/dist/instead of the raw sourceapp.js.typecheckchainstsc --noEmit && tsc --noEmit -p dashboard.verifynow runsnpm run buildfirst, matching the patterntests/bundle-smoke.test.tsalready assumes.tests/server-dashboard.test.ts— the asset-serving test skips whendashboard/dist/app.jsis missing, mirroring the bundle-smoke convention.Out of scope
dashboard/app.jscontent is unchanged (just bundled).dashboard/src/yet — the directory is reserved for the next PR.dashboard/codemirror.jsships as-is; Stage 2 of tracking: dashboard refactor (4768-line single file → modular panels) #28 deletes it with the editor surface.Test plan
npm run buildproducesdashboard/dist/app.js(~136 KB) + sourcemap.npm run typecheckpasses both root + dashboard projects.npm run lintclean (6 pre-existing warnings unrelated to this PR).npm test— 1665/1665 pass.https://esm.sh/...(verified viahead dashboard/dist/app.js).