Skip to content

perf(bundle): stop three routes shipping the block and tool registries - #6138

Merged
waleedlatif1 merged 1 commit into
stagingfrom
perf/landing-registry-edges
Jul 31, 2026
Merged

perf(bundle): stop three routes shipping the block and tool registries#6138
waleedlatif1 merged 1 commit into
stagingfrom
perf/landing-registry-edges

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

The public /integrations page downloaded, parsed and executed 19.54 MB of JavaScript, 15.52 MB of it the tool registry — 4,351 tool configs, to render a catalog of names and icons. It arrived as <script async> in the initial HTML, so the browser fetched and ran it on load.

/integrations before after
JS pulled 19.54 MB 3.55 MB
chunks 45 41
chunks > 1 MB one 15.52 MB registry chunk none

−82%. credit-usage loses its copy too. Measured from production builds, counting the chunks each page's own HTML references.

Three edges, one shape

Every case is a module mixing pure helpers with registry-backed ones, so importing the pure half dragged in all 282 block configs and the tool registry behind them.

1. lib/integrations/index.ts built POPULAR_WORKFLOWS at module scope via getAllBlockMeta(), and re-exported registry functions. The landing grid is a 'use client' component, so importing anything from that barrel inherited the whole graph. POPULAR_WORKFLOWS moves to its own module — its one real consumer is a server page — and the re-export goes, which .claude/rules/sim-imports.md already forbids and which nothing imported through the barrel anyway.

2. blocks/icon-color.ts mixed pure contrast maths (getTileIconColorClass, isLightTileColor — what the landing page uses) with getBareIconStyle, which reads getAllBlocks(). Split by dependency into blocks/brand-icon-style.ts. All six getBareIconStyle consumers are under app/workspace/**, where the registry is already legitimately present.

3. credit-usage-view.tsx imported a date formatter from the logs feature's utils.ts, which also exports registry-backed badge components. formatDateShort has three consumers across three features (logs, credit-usage, audit-logs), so it moves to lib/core/utils/date-display.ts per the repo's utils-location rule.

No codegen, no async refactor, no dynamic imports — just severing import edges that shouldn't have existed.

Deliberately not fixed here

account/settings/[section] still reaches the registry, but through workspace-permissions-providersocket-provider — one of the four known client edges from the module-graph audit, not a stray import. It's also loaded via dynamic(), so it's likely lazy rather than on first paint. That belongs with the registry split.

workspace/* keeps its copy, which is correct — the editor genuinely needs tool params and outputs.

A measurement note worth recording

My first check used total client JS (110.08 MB → 110.04 MB) and looked like a total failure. That was the wrong instrument: total sums every route, and this is a per-route fix — the registry still ships to workspace/* by design. Measuring the page's own referenced chunks showed the 82% drop. Worth remembering before anyone concludes a route-scoped change "did nothing".

Type of Change

  • Performance

Testing

  • Production builds before/after; per-route chunk attribution via each page's rendered HTML and the client reference manifests
  • tsc --noEmit clean (one pre-existing trigger.config.ts node-24 error on staging, untouched here)
  • biome check clean
  • 51 test files / 717 tests pass across blocks, lib/integrations, lib/core/utils
  • Verified all three 'use client' directives remain the first statement in their files after the import moves

The public /integrations page downloaded, parsed and executed 19.54 MB of
JavaScript, 15.52 MB of which was the tool registry — 4,351 tool configs, to
render a catalog of names and icons. It arrived as `<script async>` in the
initial HTML, so the browser fetched and ran it on load.

Measured on a production build, chunks referenced by the page's own HTML:

  /integrations   19.54 MB -> 3.55 MB across 41 chunks   (-82%)

No chunk over 1 MB remains on that route. credit-usage also loses its copy.

Three separate import edges, all the same shape: a module mixing pure helpers
with registry-backed ones, so importing the pure half dragged in all 282 block
configs and the tool registry behind them.

- `lib/integrations/index.ts` built POPULAR_WORKFLOWS at module scope via
  `getAllBlockMeta()` and re-exported registry functions. The landing grid is a
  client component, so importing anything from that barrel inherited the whole
  graph. POPULAR_WORKFLOWS moves to its own module — its one real consumer is a
  server page — and the re-export goes, which .claude/rules/sim-imports.md
  already forbids and which nothing imported through the barrel.

- `blocks/icon-color.ts` mixed pure contrast maths (`getTileIconColorClass`,
  `isLightTileColor`, used by the landing page) with `getBareIconStyle`, which
  reads `getAllBlocks()`. Split by dependency into `blocks/brand-icon-style.ts`;
  all six of its consumers are under app/workspace/** where the registry is
  already legitimately present.

- `credit-usage-view.tsx` imported a date formatter from the logs feature's
  `utils.ts`, which also exports registry-backed badge components.
  `formatDateShort` has three consumers across three features, so it moves to
  `lib/core/utils/date-display.ts` per the repo's utils-location rule.

Not addressed: account/settings/[section] still reaches the registry through
workspace-permissions-provider -> socket-provider, one of the four known
client edges from the module-graph audit rather than a stray import. It is
also loaded via `dynamic()`, so it is likely lazy rather than on first paint.
That belongs with the registry split, not here.

workspace/* keeps its copy, which is correct — the editor needs tool params
and outputs.
@vercel

vercel Bot commented Jul 31, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jul 31, 2026 10:57pm

Request Review

@cursor

cursor Bot commented Jul 31, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Import-path and module-split refactor with no intended behavior changes; registry remains on workspace routes by design. Main risk is a missed import edge reintroducing the heavy chunk on a client route.

Overview
This PR cuts accidental bundle weight on public and settings routes by splitting modules that mixed lightweight helpers with registry-backed code, so importing “just a formatter” or “just the integrations barrel” no longer drags in all block configs and the tool registry.

Integrations catalog: POPULAR_WORKFLOWS and registry re-exports are removed from @/lib/integrations. The landing integrations server page now imports POPULAR_WORKFLOWS from @/lib/integrations/popular-workflows only; the client grid keeps importing the barrel without getAllBlockMeta() at module scope.

Icon styling: getBareIconStyle and StyleableIcon move to blocks/brand-icon-style.ts (registry-backed). blocks/icon-color.ts keeps pure tile contrast helpers for the landing page. Workspace UI updates imports to brand-icon-style.

Dates: formatDateShort moves to lib/core/utils/date-display.ts so logs, credit usage, and audit logs no longer import it from logs utils.ts (which also exports registry-backed badges).

Workspace code that legitimately needs the registry still imports @/blocks/registry directly (e.g. suggested actions).

Reviewed by Cursor Bugbot for commit 691912b. Configure here.

@greptile-apps

greptile-apps Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR separates registry-backed utilities from lightweight modules to reduce route-specific client bundles.

  • Moves popular-workflow derivation out of the integrations barrel and keeps its registry dependency server-side.
  • Moves registry-backed brand-icon styling out of the pure icon-color helpers and updates workspace consumers.
  • Moves the shared compact date formatter out of the registry-backed logs utility module.

Confidence Score: 5/5

The PR appears safe to merge, with the utility relocations preserving existing behavior while removing unintended registry dependencies.

All removed exports have migrated consumers, the popular-workflow registry access remains confined to a server component, and the extracted icon and date helpers preserve their previous implementations without introducing unresolved imports or runtime-boundary issues.

Important Files Changed

Filename Overview
apps/sim/lib/integrations/index.ts Removes registry-backed workflow derivation and registry re-exports from the lightweight integrations barrel without leaving unresolved consumers.
apps/sim/lib/integrations/popular-workflows.ts Preserves popular-workflow derivation in a dedicated module consumed only by the server-rendered integrations page.
apps/sim/blocks/brand-icon-style.ts Relocates the existing registry-backed icon styling implementation while preserving its behavior and updating all consumers.
apps/sim/blocks/icon-color.ts Retains only pure contrast helpers, severing the block-registry dependency from lightweight callers.
apps/sim/lib/core/utils/date-display.ts Relocates the compact date formatter unchanged into a dependency-free shared utility and updates all known consumers.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Landing["/integrations client UI"] --> Catalog["Lightweight integrations catalog"]
  Landing --> Colors["Pure icon-color helpers"]
  ServerPage["/integrations server page"] --> Popular["Popular workflows"]
  Popular --> BlockRegistry["Block registry"]
  Workspace["Workspace routes"] --> BrandStyle["Brand icon styling"]
  BrandStyle --> BlockRegistry
  Logs["Logs / credit usage / audit logs"] --> Dates["Pure date-display helper"]
  BlockRegistry --> ToolRegistry["Tool registry"]
Loading

Reviews (1): Last reviewed commit: "perf(bundle): stop three routes shipping..." | Re-trigger Greptile

@waleedlatif1
waleedlatif1 merged commit 0bcf64a into staging Jul 31, 2026
27 checks passed
@waleedlatif1
waleedlatif1 deleted the perf/landing-registry-edges branch August 1, 2026 04:19
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.

1 participant