fix: keep CSS when referenced both statically and dynamically#6891
fix: keep CSS when referenced both statically and dynamically#6891schiller-manuel merged 4 commits intomainfrom
Conversation
🦋 Changeset detectedLatest commit: 19e3ab9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds CSS-modules SSR reproduction pages and tests (static and lazy widget scenarios), new UI components and CSS modules, updates E2E scripts, and refactors the start-manifest-plugin by extracting manifest construction into a new manifestBuilder that scans client chunks, resolves assets (including dynamic CSS), and deduplicates route preloads. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
rect rgba(200,200,255,0.5)
participant Dev as Developer/Build
end
rect rgba(200,255,200,0.5)
participant Plugin as Start Plugin
end
rect rgba(255,200,200,0.5)
participant Builder as manifestBuilder
participant Rollup as Rollup Bundle
participant RouteTree as RouteTreeRoutes
end
Dev->>Plugin: invoke plugin.load (clientBundle, routeTreeRoutes)
Plugin->>Builder: buildStartManifest({ clientBundle, routeTreeRoutes, basePath })
Builder->>Rollup: scanClientChunks(clientBundle)
Builder->>RouteTree: read routeTreeRoutes (filePath mappings)
Builder->>Rollup: collectDynamicImportCss(route chunks)
Builder->>Builder: createManifestAssetResolvers(dynamicCss)
Builder->>Builder: buildRouteManifestRoutes(...merged assets/preloads...)
Builder->>Plugin: return startManifest (routes + clientEntry)
Plugin->>Dev: return manifest for serve/build
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
|
View your CI Pipeline Execution ↗ for commit 19e3ab9
☁️ Nx Cloud last updated this comment at |
Bundle Size Benchmarks
Trend sparkline is historical gzip bytes ending with this PR measurement; lower is better. |
fed53b3 to
59aa0a6
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (2)
packages/start-plugin-core/src/start-manifest-plugin/manifestBuilder.ts (1)
540-548: Consider adding a guard for missing child routes.The non-null assertion on
routesById[childRouteId]could cause a confusing runtime error if the route tree has children referencing non-existent route IDs. A descriptive error would help debugging misconfigured route trees.🛡️ Optional: Add defensive check with clear error message
if (route.children) { for (const childRouteId of route.children) { + const childRoute = routesById[childRouteId] + if (!childRoute) { + throw new Error(`Child route "${childRouteId}" not found in routes`) + } dedupeNestedRoutePreloads( - routesById[childRouteId]!, + childRoute, routesById, seenPreloads, ) } }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/start-plugin-core/src/start-manifest-plugin/manifestBuilder.ts` around lines 540 - 548, The loop in dedupeNestedRoutePreloads uses a non-null assertion on routesById[childRouteId] which can throw an unclear runtime error if a child ID is missing; add a defensive guard inside the for loop that checks whether routesById[childRouteId] exists and, if not, throws or logs a descriptive error (e.g. include the parent route id and missing childRouteId) before calling dedupeNestedRoutePreloads, referencing the variables route.children, childRouteId, routesById, and seenPreloads so the missing-route condition is detected and reported clearly.packages/start-plugin-core/tests/start-manifest-plugin/manifestBuilder.test.ts (1)
627-643: Test is misplaced in the wrong describe block.This test verifies
buildStartManifestthrows when a non-root route lacksfilePath, but it's nested underdescribe('dedupeNestedRoutePreloads', ...). Consider moving it to thedescribe('buildStartManifest', ...)block for better organization.🤖 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 627 - 643, The test asserting buildStartManifest throws when a non-root route lacks filePath is in the wrong describe block; move the test (the case using buildStartManifest with routeTreeRoutes containing __root__ and '/about' and expecting "expected filePath to be set for /about") out of the describe('dedupeNestedRoutePreloads', ...) group and into the describe('buildStartManifest', ...) block so it lives with related buildStartManifest tests and clearly references the buildStartManifest, routeTreeRoutes, __root__, and '/about' symbols.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/start-plugin-core/src/start-manifest-plugin/manifestBuilder.ts`:
- Around line 540-548: The loop in dedupeNestedRoutePreloads uses a non-null
assertion on routesById[childRouteId] which can throw an unclear runtime error
if a child ID is missing; add a defensive guard inside the for loop that checks
whether routesById[childRouteId] exists and, if not, throws or logs a
descriptive error (e.g. include the parent route id and missing childRouteId)
before calling dedupeNestedRoutePreloads, referencing the variables
route.children, childRouteId, routesById, and seenPreloads so the missing-route
condition is detected and reported clearly.
In
`@packages/start-plugin-core/tests/start-manifest-plugin/manifestBuilder.test.ts`:
- Around line 627-643: The test asserting buildStartManifest throws when a
non-root route lacks filePath is in the wrong describe block; move the test (the
case using buildStartManifest with routeTreeRoutes containing __root__ and
'/about' and expecting "expected filePath to be set for /about") out of the
describe('dedupeNestedRoutePreloads', ...) group and into the
describe('buildStartManifest', ...) block so it lives with related
buildStartManifest tests and clearly references the buildStartManifest,
routeTreeRoutes, __root__, and '/about' symbols.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 15ab33de-da8b-4aa4-8474-58248bdff412
📒 Files selected for processing (3)
.changeset/open-pants-vanish.mdpackages/start-plugin-core/src/start-manifest-plugin/manifestBuilder.tspackages/start-plugin-core/tests/start-manifest-plugin/manifestBuilder.test.ts
Summary by CodeRabbit
New Features
Tests
Chores