fix: support stable subresource integrity config#65
Conversation
commit: |
Benchmark ResultsCompared PR head Total median wall time: 17.66s -> 17.69s (+0.2%, 1.00x speedup)
Profile: |
|
Warning Review limit reached
More reviews will be available in 32 minutes and 46 seconds. Learn how PR review limits work. To continue reviewing without waiting, enable usage-based billing in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThe change adds top-level 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/react-router-config.ts`:
- Around line 160-169: The SRI precedence in mergeReactRouterConfig is wrong
because top-level subResourceIntegrity can override a user’s
future.unstable_subResourceIntegrity after merging. Normalize the two SRI fields
on each input config before the merge, then in resolvedReactRouterConfig ensure
resolved.future.unstable_subResourceIntegrity is kept in sync with the final
subResourceIntegrity value so the merged config stays consistent and user intent
wins.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 17cc5b0f-1ca0-453e-b306-dbbd4eb771d1
📒 Files selected for processing (4)
src/index.tssrc/modify-browser-manifest.tssrc/react-router-config.tstests/react-router-config.test.ts
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/modify-browser-manifest.ts (1)
90-167: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick winInclude collected SRI in the emitted browser manifest.
subResourceIntegrityis passed into this plugin, but both browser manifest serializations still usemanifest, andonManifestalways receivesundefined. With SRI enabled, the emitted browser manifest lackssrientries.Proposed fix
const manifest = await getReactRouterManifestForDev( routes, pluginOptions, stats, appDirectory, assetPrefix, routeChunkOptions ); + const sri = + routeChunkOptions?.isBuild && + (options?.subResourceIntegrity ?? + options?.future?.unstable_subResourceIntegrity) + ? collectSubresourceIntegrity(stats, compilation, assetPrefix) + : undefined; + const manifestWithSri = sri ? { ...manifest, sri } : manifest; const virtualManifestPath = 'static/js/virtual/react-router/browser-manifest.js'; if (compilation.assets[virtualManifestPath]) { @@ const newSource = originalSource.replace( /["'`]PLACEHOLDER["'`]/, - jsesc(manifest, { es6: true }) + jsesc(manifestWithSri, { es6: true }) ); @@ const manifestSource = `window.__reactRouterManifest=${jsesc( - manifest, + manifestWithSri, { es6: true } )};`; @@ - options?.onManifest?.(manifest, undefined); + options?.onManifest?.(manifestWithSri, sri);🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/modify-browser-manifest.ts` around lines 90 - 167, The browser manifest emission in ModifyBrowserManifest is ignoring subResourceIntegrity, so the serialized manifest and onManifest callback never carry SRI data. Update the emit hook in modify-browser-manifest.ts to collect the SRI map when subResourceIntegrity is enabled, pass that value into getReactRouterManifestForDev and both manifest serializations, and replace the hardcoded undefined in options?.onManifest with the collected SRI so the emitted browser manifest includes sri entries.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/setup.ts`:
- Around line 21-24: The shared mock in tests/setup.ts leaves process-global
__reactRouterTestConfig state behind, which can leak between tests. Add a shared
cleanup in the test setup (for example an afterEach hook) that resets
__reactRouterTestConfig on globalThis so every test starts from a clean state.
Use the existing globalThis access pattern around __reactRouterTestConfig to
locate the mock and clear it centrally rather than relying on individual tests.
---
Outside diff comments:
In `@src/modify-browser-manifest.ts`:
- Around line 90-167: The browser manifest emission in ModifyBrowserManifest is
ignoring subResourceIntegrity, so the serialized manifest and onManifest
callback never carry SRI data. Update the emit hook in
modify-browser-manifest.ts to collect the SRI map when subResourceIntegrity is
enabled, pass that value into getReactRouterManifestForDev and both manifest
serializations, and replace the hardcoded undefined in options?.onManifest with
the collected SRI so the emitted browser manifest includes sri entries.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 3790e833-1ea7-449b-a0ae-d9bf7a3f88e9
📒 Files selected for processing (8)
.changeset/stable-subresource-integrity.mdsrc/index.tssrc/modify-browser-manifest.tssrc/react-router-config.tstests/index.test.tstests/modify-browser-manifest.test.tstests/react-router-config.test.tstests/setup.ts
✅ Files skipped from review due to trivial changes (1)
- .changeset/stable-subresource-integrity.md
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/modify-browser-manifest.ts`:
- Line 173: The `onManifest` callback in `modify-browser-manifest` is dropping
the SRI payload by passing `undefined` as the second argument. Update the
`options?.onManifest?.(...)` call to preserve and forward the collected
integrity map from the current build context, using the available `stats`,
`compilation`, and `assetPrefix` data so existing consumers of
`onManifest(manifest, sri)` keep working.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: c92283a6-05e8-4c4f-a65a-efca6acb368e
📒 Files selected for processing (4)
src/manifest.tssrc/modify-browser-manifest.tstests/modify-browser-manifest.test.tstests/setup.ts
✅ Files skipped from review due to trivial changes (1)
- src/manifest.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- tests/setup.ts
Summary\n- accept top-level
subResourceIntegrityalongsidefuture.unstable_subResourceIntegrity\n- pass the resolved stable setting into browser manifest SRI generation\n- add resolver coverage for stable and future config keys\n\n## Verification\n-pnpm test:core tests/react-router-config.test.ts\n-pnpm build