Skip to content

fix: asset sorting#7251

Merged
schiller-manuel merged 1 commit intomainfrom
fix-asset-sorting
Apr 24, 2026
Merged

fix: asset sorting#7251
schiller-manuel merged 1 commit intomainfrom
fix-asset-sorting

Conversation

@schiller-manuel
Copy link
Copy Markdown
Contributor

@schiller-manuel schiller-manuel commented Apr 24, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Fixed CSS asset ordering to ensure styles from imported chunks are emitted before route chunk styles, improving stylesheet load sequence and preventing potential styling conflicts.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 24, 2026

📝 Walkthrough

Walkthrough

This PR fixes CSS asset ordering in TanStack Start's manifest plugin. The change reorders CSS asset collection so that styles from imported chunks are emitted before the route chunk's own CSS, with corresponding test expectations updated to reflect this new ordering behavior.

Changes

Cohort / File(s) Summary
Changesets Metadata
.changeset/start-asset-sorting.md
New changeset entry marking a patch release for @tanstack/start-plugin-core documenting the CSS asset ordering fix.
CSS Asset Collection Logic
packages/start-plugin-core/src/start-manifest-plugin/manifestBuilder.ts
Reordered CSS asset collection in createChunkCssAssetCollector().getChunkCssAssets() to defer appending chunk.css until after recursively traversing and accumulating CSS from chunk.imports.
Test Expectations
packages/start-plugin-core/tests/start-manifest-plugin/manifestBuilder.test.ts
Updated CSS-related test expectations throughout the test suite to match the new asset ordering behavior, including swapped href strings and reordered assertion arrays. Added explicit test case validating that imported chunk CSS is emitted before route chunk CSS.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 CSS styles now flow in perfect harmony,
Imports first, then routes—orderly symphony!
No more tangled asset confusion, hooray,
A sorted rabbit's dream, hip-hip-hooray! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: asset sorting' directly describes the main change: reordering CSS asset collection so imported chunk styles are emitted before route chunk styles.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-asset-sorting

Comment @coderabbitai help to get the list of available commands and usage tips.

@nx-cloud
Copy link
Copy Markdown
Contributor

nx-cloud Bot commented Apr 24, 2026

View your CI Pipeline Execution ↗ for commit 7093fee

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ✅ Succeeded 7m 58s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 32s View ↗

☁️ Nx Cloud last updated this comment at 2026-04-24 20:25:56 UTC

@github-actions
Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

1 package(s) bumped directly, 4 bumped as dependents.

🟩 Patch bumps

Package Version Reason
@tanstack/start-plugin-core 1.169.0 → 1.169.1 Changeset
@tanstack/react-start 1.167.44 → 1.167.45 Dependent
@tanstack/react-start-rsc 0.0.23 → 0.0.24 Dependent
@tanstack/solid-start 1.167.39 → 1.167.40 Dependent
@tanstack/vue-start 1.167.38 → 1.167.39 Dependent

@github-actions
Copy link
Copy Markdown
Contributor

Bundle Size Benchmarks

  • Commit: 03ac20e42eab
  • Measured at: 2026-04-24T20:18:42.989Z
  • Baseline source: history:dda463c8b571
  • Dashboard: bundle-size history
Scenario Current (gzip) Delta vs baseline Raw Brotli Trend
react-router.minimal 87.35 KiB 0 B (0.00%) 274.60 KiB 75.97 KiB ▁██████████
react-router.full 90.63 KiB 0 B (0.00%) 285.74 KiB 78.87 KiB ▁▂▂████████
solid-router.minimal 35.55 KiB 0 B (0.00%) 106.71 KiB 31.96 KiB ▁▂▂▂▂▆█████
solid-router.full 40.02 KiB 0 B (0.00%) 120.20 KiB 35.94 KiB ▁▂▂▂▂▇█████
vue-router.minimal 53.30 KiB 0 B (0.00%) 152.01 KiB 47.88 KiB ▁██████████
vue-router.full 58.20 KiB 0 B (0.00%) 167.43 KiB 52.06 KiB ▁██████████
react-start.minimal 101.77 KiB 0 B (0.00%) 322.39 KiB 88.05 KiB ▁▃▃████████
react-start.full 105.21 KiB 0 B (0.00%) 332.72 KiB 90.89 KiB ▁▃▃████████
solid-start.minimal 49.53 KiB 0 B (0.00%) 152.52 KiB 43.68 KiB ▁▄▄▄▄█▇▇▇▇▇
solid-start.full 55.07 KiB 0 B (0.00%) 168.73 KiB 48.43 KiB ▁▂▂▂▂▅█████

Trend sparkline is historical gzip bytes ending with this PR measurement; lower is better.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@packages/start-plugin-core/tests/start-manifest-plugin/manifestBuilder.test.ts`:
- Around line 555-557: The test is using an untyped asset parameter in the map
call; replace the cast "(asset: any)" with "(asset: RouterManagedTag)" and add
an import for RouterManagedTag from "@tanstack/router-core" at the top of the
test file so the expression
manifest.routes['/field-detail-panel']!.assets!.map((asset: RouterManagedTag) =>
asset.attrs.href) is strictly typed; ensure the import name matches the symbol
RouterManagedTag used in the map callback.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b1a39da5-4f44-457e-9343-9e801fc2ea49

📥 Commits

Reviewing files that changed from the base of the PR and between 03ac20e and 7093fee.

📒 Files selected for processing (3)
  • .changeset/start-asset-sorting.md
  • packages/start-plugin-core/src/start-manifest-plugin/manifestBuilder.ts
  • packages/start-plugin-core/tests/start-manifest-plugin/manifestBuilder.test.ts

Comment on lines +555 to +557
manifest.routes['/field-detail-panel']!.assets!.map(
(asset: any) => asset.attrs.href,
),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify explicit `any` usage in this test file and inspect context.
rg -nP --type=ts -C2 '\bany\b' packages/start-plugin-core/tests/start-manifest-plugin/manifestBuilder.test.ts

Repository: TanStack/router

Length of output: 3628


🏁 Script executed:

# Check for type definitions related to assets and manifest
fd -e ts -e tsx packages/start-plugin-core | grep -E '(type|interface|manifest)' | head -20

Repository: TanStack/router

Length of output: 469


🏁 Script executed:

# Search for RouterManagedTag definition
rg -n 'RouterManagedTag' packages/start-plugin-core --type=ts

Repository: TanStack/router

Length of output: 2792


🏁 Script executed:

# Find the manifest type definition to understand asset typing
rg -n -A5 'assets.*:' packages/start-plugin-core --type=ts | head -40

Repository: TanStack/router

Length of output: 4213


🏁 Script executed:

# Check what types are available for the asset mapping pattern
rg -n '\btype.*Asset' packages/start-plugin-core --type=ts

Repository: TanStack/router

Length of output: 426


Replace any with RouterManagedTag to maintain strict type safety.

Line 556 uses (asset: any) when mapping assets; use RouterManagedTag (imported from @tanstack/router-core) instead, consistent with the manifest builder's type definitions and TypeScript strict mode requirements.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@packages/start-plugin-core/tests/start-manifest-plugin/manifestBuilder.test.ts`
around lines 555 - 557, The test is using an untyped asset parameter in the map
call; replace the cast "(asset: any)" with "(asset: RouterManagedTag)" and add
an import for RouterManagedTag from "@tanstack/router-core" at the top of the
test file so the expression
manifest.routes['/field-detail-panel']!.assets!.map((asset: RouterManagedTag) =>
asset.attrs.href) is strictly typed; ensure the import name matches the symbol
RouterManagedTag used in the map callback.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 24, 2026

More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/@tanstack/arktype-adapter@7251

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/@tanstack/eslint-plugin-router@7251

@tanstack/eslint-plugin-start

npm i https://pkg.pr.new/@tanstack/eslint-plugin-start@7251

@tanstack/history

npm i https://pkg.pr.new/@tanstack/history@7251

@tanstack/nitro-v2-vite-plugin

npm i https://pkg.pr.new/@tanstack/nitro-v2-vite-plugin@7251

@tanstack/react-router

npm i https://pkg.pr.new/@tanstack/react-router@7251

@tanstack/react-router-devtools

npm i https://pkg.pr.new/@tanstack/react-router-devtools@7251

@tanstack/react-router-ssr-query

npm i https://pkg.pr.new/@tanstack/react-router-ssr-query@7251

@tanstack/react-start

npm i https://pkg.pr.new/@tanstack/react-start@7251

@tanstack/react-start-client

npm i https://pkg.pr.new/@tanstack/react-start-client@7251

@tanstack/react-start-rsc

npm i https://pkg.pr.new/@tanstack/react-start-rsc@7251

@tanstack/react-start-server

npm i https://pkg.pr.new/@tanstack/react-start-server@7251

@tanstack/router-cli

npm i https://pkg.pr.new/@tanstack/router-cli@7251

@tanstack/router-core

npm i https://pkg.pr.new/@tanstack/router-core@7251

@tanstack/router-devtools

npm i https://pkg.pr.new/@tanstack/router-devtools@7251

@tanstack/router-devtools-core

npm i https://pkg.pr.new/@tanstack/router-devtools-core@7251

@tanstack/router-generator

npm i https://pkg.pr.new/@tanstack/router-generator@7251

@tanstack/router-plugin

npm i https://pkg.pr.new/@tanstack/router-plugin@7251

@tanstack/router-ssr-query-core

npm i https://pkg.pr.new/@tanstack/router-ssr-query-core@7251

@tanstack/router-utils

npm i https://pkg.pr.new/@tanstack/router-utils@7251

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/@tanstack/router-vite-plugin@7251

@tanstack/solid-router

npm i https://pkg.pr.new/@tanstack/solid-router@7251

@tanstack/solid-router-devtools

npm i https://pkg.pr.new/@tanstack/solid-router-devtools@7251

@tanstack/solid-router-ssr-query

npm i https://pkg.pr.new/@tanstack/solid-router-ssr-query@7251

@tanstack/solid-start

npm i https://pkg.pr.new/@tanstack/solid-start@7251

@tanstack/solid-start-client

npm i https://pkg.pr.new/@tanstack/solid-start-client@7251

@tanstack/solid-start-server

npm i https://pkg.pr.new/@tanstack/solid-start-server@7251

@tanstack/start-client-core

npm i https://pkg.pr.new/@tanstack/start-client-core@7251

@tanstack/start-fn-stubs

npm i https://pkg.pr.new/@tanstack/start-fn-stubs@7251

@tanstack/start-plugin-core

npm i https://pkg.pr.new/@tanstack/start-plugin-core@7251

@tanstack/start-server-core

npm i https://pkg.pr.new/@tanstack/start-server-core@7251

@tanstack/start-static-server-functions

npm i https://pkg.pr.new/@tanstack/start-static-server-functions@7251

@tanstack/start-storage-context

npm i https://pkg.pr.new/@tanstack/start-storage-context@7251

@tanstack/valibot-adapter

npm i https://pkg.pr.new/@tanstack/valibot-adapter@7251

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/@tanstack/virtual-file-routes@7251

@tanstack/vue-router

npm i https://pkg.pr.new/@tanstack/vue-router@7251

@tanstack/vue-router-devtools

npm i https://pkg.pr.new/@tanstack/vue-router-devtools@7251

@tanstack/vue-router-ssr-query

npm i https://pkg.pr.new/@tanstack/vue-router-ssr-query@7251

@tanstack/vue-start

npm i https://pkg.pr.new/@tanstack/vue-start@7251

@tanstack/vue-start-client

npm i https://pkg.pr.new/@tanstack/vue-start-client@7251

@tanstack/vue-start-server

npm i https://pkg.pr.new/@tanstack/vue-start-server@7251

@tanstack/zod-adapter

npm i https://pkg.pr.new/@tanstack/zod-adapter@7251

commit: 7093fee

@schiller-manuel schiller-manuel merged commit 9252206 into main Apr 24, 2026
16 checks passed
@schiller-manuel schiller-manuel deleted the fix-asset-sorting branch April 24, 2026 20:29
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 24, 2026

Merging this PR will not alter performance

✅ 5 untouched benchmarks
⏩ 1 skipped benchmark1


Comparing fix-asset-sorting (7093fee) with main (dda463c)2

Open in CodSpeed

Footnotes

  1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports.

  2. No successful run was found on main (03ac20e) during the generation of this report, so dda463c was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant