Skip to content

Fix route resolution and coherent development builds - #149

Merged
ScriptedAlchemy merged 6 commits into
mainfrom
codex/resolve-issues-145-148
Sep 25, 2026
Merged

ScriptedAlchemy merged 6 commits into
mainfrom
codex/resolve-issues-145-148

Conversation

@ScriptedAlchemy

@ScriptedAlchemy ScriptedAlchemy commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes #145, #146, #147, and #148.

Route imports now use Rspack’s actual resolved resource before choosing the client or server route transform. This preserves dependency-specific aliases, conditional package imports, extension priority, directory indexes, TypeScript paths, and symlinked route files. Queryless and explicitly tagged routes share one transform registration so importing a route twice does not duplicate its module state. RSC uses the native issuer layer to distinguish SSR client modules from server components; the old AST path guessing is removed.

Development changes now preserve a coherent server build and browser manifest:

  • Overlapping CSS and loader edits retry mismatched compiler results before committing, and pending client and server edits survive superseded compilations and empty retries.
  • CSS ownership reloads follow successful commits. RSC fallback revalidation waits through invalidation, compilation, and failures, while preserving pending helper edits across client-only updates.
  • Each development manifest has its own manifest-<version>.js asset. Previous versions remain available; native Web output.clean is rejected during development. The obsolete virtual manifest entry, placeholder transform, and lazy-compilation exception are removed.

Closed-issue audit and upstream comparison

Revisited #21, #24, #38, #78, #106, #124, #129, #130, #132, #133, #135, #136, and #139, tracing their implementation history and relevant adjacent behavior. #133 was closed as not planned after the reporter isolated external dependency paths; it is not presented as a plugin regression.

Additional reproduced bugs fixed:

  • A generated split-route entry could overwrite a real route entry, yielding a successful build with a wrong client-loader module. Check the shared entry namespace before insertion.
  • Configuration, outputs, typegen, and version-dependent defaults used the caller's directory rather than Rsbuild's project root. Resolve them from that root without changing the process directory.
  • Development manifests guessed a CSS filename for ?url imports even when no extracted stylesheet existed. Use emitted compilation assets only.
  • RSC federation overrode JSONP chunk loading with an incompatible ESM loader. Preserve the mode's native loader.
  • A consuming federation host named root was mistaken for an emitted container, splitting the application runtime and duplicating singleton state. Only nonempty exposes declares a container.
  • Classic prerender redirects consumed unused response bodies, so errored or pending bodies could fail or hang builds. Handle redirects from their headers and release the request.
  • Classic and RSC redirect HTML failed to escape attribute values. Reuse the HTML escape helper and include quotes.
  • RSC SPA fallbacks rejected a valid 404 under a basename. Validate the unprefixed fallback artifact identity.

Cross-checked installed @react-router/dev 8.3.1 and the upstream Vite plugin, style collection, and RSC plugin. Vite owns root resolution, uses module IDs/queries for route chunks, and ignores URL/raw/inline CSS for style injection. The installed Vite implementation retains redirect-body, HTML-context escaping, and RSC basename limitations; regression tests define the corrected behavior here. Federation fixes were verified against native Rspack compilation and runtime identity because those mechanics are compiler-specific.

Additional cache and configuration pass

  • Warm persistent-cache builds of MDX routes failed because the route-analysis callback was skipped and raw MDX was parsed as JavaScript. Store compiled analysis in native module buildInfo and restore it from every Web compilation, preserving normal caching and loader order. The regression covers cold, warm, and changed-export builds.
  • An inferred root ID could overwrite the framework root and leave a self-parented route graph. Validate effective IDs, including inferred IDs, and reject non-string IDs.
  • RSC capability checks still resolved dependencies from the caller directory. Bind them to the configured project root.
  • Native checks found no additional failure for SRI with query hashes, hashed directories, .mjs, extensionless JS, and forced shared/runtime chunks, or for warm/Node-only builds changing server options and route partitions with unchanged browser assets.

Verification

  • pnpm test: all workspace typechecks and 835 tests passed.
  • pnpm build, source formatting, and diff checks passed.
  • Latest focused browser run: cached MDX cold/warm/export-change regression plus all four HMR/HDR browser tests passed (5 tests).
  • 14 native Rspack resolver cases verify actual module identity and the query received by loaders.
  • Production classic and RSC browser regressions cover route re-exports/imports, symlinked route files, and symlinked app directories and confirm server-only sentinels stay out of browser bundles. Direct browser .server imports still fail.
  • Earlier full React Router ecosystem run: 1,058 passed and 46 expected skips, including all four classic/custom-server/MDX/RSC HMR and HDR browser tests.
  • 61 affected CSS, federation, classic/RSC prerender, and SPA build-process browser tests passed after the audit fixes; final native root controls also passed, including custom paths, typegen, SSR loader execution, and unchanged process cwd.
  • New regressions cover overlapping and superseded client/server builds, RSC invalidation/failure recovery, and retaining previous manifest bytes after a second native compilation.
  • Issue [Bug]: CSS rebuild leaves the dev browser manifest stale and resets pre-hydration input #148’s real Chromium reproduction loaded the new manifest, preserved the pre-hydration draft, and recorded zero hydration recoveries.

Versioned manifests preserve their own bytes and separately named assets; existing development JavaScript with unhashed filenames remains subject to normal HMR replacement.

Resolve aliased route imports through Rspack, evaluate paired Node edits, remove precommit CSS reloads, and emit versioned development browser manifests.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-22T23:26:25.351225Z 5d08c67 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@pkg-pr-new

pkg-pr-new Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

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

commit: 7dc08bb

@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark results

Case Base Head Delta
build-256-ssr 1304.0 ms 1331.3 ms +2.1%
dev-48-ssr 588.0 ms 584.8 ms -0.6%

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5d08c6755c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/route-imports.ts Outdated
Comment on lines +123 to +124
.getResolver('normal', {})
.resolve({}, input.context, input.request, {}, (error, resolved) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve dependency-specific resolver options

When a route imports a bare specifier under resolve.byDependency rules (for example, an esm.alias that differs from the global alias), this generic resolver can select a different file from the resolver that NormalModuleFactory would use for the actual dependency. If the generic result is a registered route, the subsequent mutation forces the import to that incorrect route; if only the dependency-specific result is a route, it remains untagged and bypasses client export pruning. Create the probe resolver with data.dependencyType and retain the original resolution context so it matches the real import resolution.

Useful? React with 👍 / 👎.

@codspeed

codspeed Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 1 untouched benchmark
⏩ 2 skipped benchmarks1


Comparing codex/resolve-issues-145-148 (7dc08bb) with main (3713893)2

Open in CodSpeed

Footnotes

  1. 2 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

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

@ScriptedAlchemy ScriptedAlchemy changed the title Fix route imports and coherent development manifest generations Fix route resolution and coherent development builds Sep 23, 2026
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.

[Bug]: aliased route re-export fails production server-export pruning

1 participant