Skip to content

fix: support stable subresource integrity config#65

Open
ScriptedAlchemy wants to merge 10 commits into
mainfrom
codex/stable-subresource-integrity
Open

fix: support stable subresource integrity config#65
ScriptedAlchemy wants to merge 10 commits into
mainfrom
codex/stable-subresource-integrity

Conversation

@ScriptedAlchemy

Copy link
Copy Markdown
Collaborator

Summary\n- accept top-level subResourceIntegrity alongside future.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

@pkg-pr-new

pkg-pr-new Bot commented Jun 28, 2026

Copy link
Copy Markdown

Open in StackBlitz

pnpm add https://pkg.pr.new/rsbuild-plugin-react-router@7d5f0cc

commit: 7d5f0cc

@github-actions

github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Benchmark Results

Compared PR head 7d5f0cc against base fe514bc.

Total median wall time: 17.66s -> 17.69s (+0.2%, 1.00x speedup)
Compiler ready median: 15.47s -> 15.55s (+0.5%)
Route load median: 2.04s -> 2.04s (+0.1%)

Benchmark Base total Head total Delta Head ready Head routes Speedup Head RSS p95
large-355-ssr-esm 17.66s 17.69s +0.2% 15.55s 2.04s 1.00x -

Profile: large; mode: dev; iterations: 3; warmup: 0.
Workflow run

@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@ScriptedAlchemy, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0610dd74-cdfe-47fb-8cb6-c80d96358d06

📥 Commits

Reviewing files that changed from the base of the PR and between 8d4da87 and 7d5f0cc.

📒 Files selected for processing (5)
  • README.md
  • src/index.ts
  • src/modify-browser-manifest.ts
  • tests/index.test.ts
  • tests/modify-browser-manifest.test.ts
📝 Walkthrough

Walkthrough

The change adds top-level subResourceIntegrity config support and keeps it synchronized with future.unstable_subResourceIntegrity. It updates config resolution, web build setup, rspack SRI enabling, browser-manifest handling, and server manifest generation to use collected integrity data. Tests and a changeset were added for config precedence, build wiring, and integrity collection.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.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
Title check ✅ Passed The title matches the main change: adding support for stable subresource integrity config.
Description check ✅ Passed The description is directly aligned with the code changes and verification steps.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/stable-subresource-integrity

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.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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 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

📥 Commits

Reviewing files that changed from the base of the PR and between fe514bc and a25cc3d.

📒 Files selected for processing (4)
  • src/index.ts
  • src/modify-browser-manifest.ts
  • src/react-router-config.ts
  • tests/react-router-config.test.ts

Comment thread src/react-router-config.ts
@ScriptedAlchemy

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 win

Include collected SRI in the emitted browser manifest.

subResourceIntegrity is passed into this plugin, but both browser manifest serializations still use manifest, and onManifest always receives undefined. With SRI enabled, the emitted browser manifest lacks sri entries.

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

📥 Commits

Reviewing files that changed from the base of the PR and between a25cc3d and 2bac7be.

📒 Files selected for processing (8)
  • .changeset/stable-subresource-integrity.md
  • src/index.ts
  • src/modify-browser-manifest.ts
  • src/react-router-config.ts
  • tests/index.test.ts
  • tests/modify-browser-manifest.test.ts
  • tests/react-router-config.test.ts
  • tests/setup.ts
✅ Files skipped from review due to trivial changes (1)
  • .changeset/stable-subresource-integrity.md

Comment thread tests/setup.ts
@ScriptedAlchemy

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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 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

📥 Commits

Reviewing files that changed from the base of the PR and between 2bac7be and 8d4da87.

📒 Files selected for processing (4)
  • src/manifest.ts
  • src/modify-browser-manifest.ts
  • tests/modify-browser-manifest.test.ts
  • tests/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

Comment thread src/modify-browser-manifest.ts Outdated
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