Skip to content

BundleRoute: don't rebuild on every artifact GET (#97) - #103

Draft
nounder wants to merge 1 commit into
mainfrom
cursor/fix-97-bundle-route-rebuild-c215
Draft

BundleRoute: don't rebuild on every artifact GET (#97)#103
nounder wants to merge 1 commit into
mainfrom
cursor/fix-97-bundle-route-rebuild-c215

Conversation

@nounder

@nounder nounder commented Aug 12, 2026

Copy link
Copy Markdown
Owner

Fixes #97

Summary

BundleRoute was calling bundle.rebuild() on every GET /_bundle/* whenever rebuild was present, causing a full bundler rerun per asset — including in production.

This gates rebuild on Development being in context. In production, artifacts are served as-is and freshness comes from file watch + BundleContext.events.

Changes

  • Gate bundle.rebuild() on Development.option in BundleRoute
  • Add tests covering rebuild-with-Development and no-rebuild-without-Development

Test plan

  • bun test test/bundler/BundleRoute.test.ts
Open in Web Open in Cursor 

Previously every GET to /_bundle/* called bundle.rebuild() when the
bundle context exposed a rebuild function, forcing a full bundler
rerun on every asset request in production. Gate the rebuild on
Development being present in context so it only runs during dev;
production relies on the bundle staying fresh via file watch +
BundleContext.events instead of a per-request rebuild.

Adds tests asserting no rebuild happens outside of Development and
that it does happen when Development is provided.

Co-authored-by: Ralph Gutkowski <nounder@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BundleRoute: don't rebuild on every artifact GET

2 participants