Skip to content

feat(rsc): validate server action exports with runtime global#14000

Closed
SyMind wants to merge 3 commits into
mainfrom
fix-relative-resource-path-bug
Closed

feat(rsc): validate server action exports with runtime global#14000
SyMind wants to merge 3 commits into
mainfrom
fix-relative-resource-path-bug

Conversation

@SyMind
Copy link
Copy Markdown
Member

@SyMind SyMind commented May 12, 2026

Summary

  • Add RuntimeGlobals::RSC_ENSURE_SERVER_ACTIONS mapped to __webpack_require__.rscA.
  • Add an RSC runtime module that defines __webpack_require__.rscA for "use server" export validation.
  • Update the SWC server actions transform to call __webpack_require__.rscA([...]) instead of importing ensureServerActions from react-server-dom-rspack/server.
  • Let RscServerPlugin inject the runtime helper based on build_info.rsc.action_ids, including concatenated modules.
  • Add rsc-plugin/server-actions-export-validation to verify invalid server action exports through runtime execution instead of bundle string matching.

Related links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings May 12, 2026 02:43
@github-actions github-actions Bot added the release: feature release: feature related release(mr only) label May 12, 2026
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 12, 2026

Deploying rspack with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1b5ee20
Status: ✅  Deploy successful!
Preview URL: https://264b2310.rspack-v2.pages.dev
Branch Preview URL: https://fix-relative-resource-path-b.rspack-v2.pages.dev

View logs

@SyMind SyMind force-pushed the fix-relative-resource-path-bug branch from 68e6130 to 4270ddc Compare May 12, 2026 02:45
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new RSC runtime global + runtime module to validate "use server" exports at runtime (via __webpack_require__.rscA), and refines source-map handling so [relative-resource-path] behaves correctly for both external and inline source maps, with updated docs and regression tests.

Changes:

  • Introduce RuntimeGlobals::RSC_ENSURE_SERVER_ACTIONS (rscA) + an RSC runtime module that validates server action exports at runtime.
  • Update the SWC server-actions transform to call __webpack_require__.rscA([...]) (instead of importing ensureServerActions).
  • Improve [relative-resource-path] source-map behavior (inline vs external base path + dedup) and add/adjust test cases + docs.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
website/docs/zh/config/output.mdx Updates Chinese docs for [relative-resource-path] inline source map behavior.
website/docs/en/config/output.mdx Updates English docs for [relative-resource-path] inline source map behavior.
tests/rspack-test/configCases/source-map/relative-resource-path/test.config.js Updates test harness to expect multiple bundles.
tests/rspack-test/configCases/source-map/relative-resource-path/rspack.config.js Extends test to validate per-source-map relative paths across multiple output directories.
tests/rspack-test/configCases/source-map/relative-resource-path-inline/test.config.js New inline-source-map regression test harness.
tests/rspack-test/configCases/source-map/relative-resource-path-inline/src/index.js New inline-source-map fixture entry.
tests/rspack-test/configCases/source-map/relative-resource-path-inline/src/button/index.js New inline-source-map fixture dependency.
tests/rspack-test/configCases/source-map/relative-resource-path-inline/rspack.config.js Validates inline source map sources are relative to emitted asset directory.
tests/rspack-test/configCases/rsc-plugin/server-actions-export-validation/test.config.js New RSC config case for runtime export validation.
tests/rspack-test/configCases/rsc-plugin/server-actions-export-validation/src/server-actions.js Fixture with invalid "use server" export.
tests/rspack-test/configCases/rsc-plugin/server-actions-export-validation/src/framework/entry.ssr.js SSR entry for the config case.
tests/rspack-test/configCases/rsc-plugin/server-actions-export-validation/src/framework/entry.rsc.js Asserts runtime validation triggers via loadServerAction.
tests/rspack-test/configCases/rsc-plugin/server-actions-export-validation/src/framework/entry.client.js Client entry placeholder for typical RSC project structure.
tests/rspack-test/configCases/rsc-plugin/server-actions-export-validation/src/Client.js Client component importing the invalid server action export.
tests/rspack-test/configCases/rsc-plugin/server-actions-export-validation/src/App.js Server entry that renders the client component.
tests/rspack-test/configCases/rsc-plugin/server-actions-export-validation/rspack.config.js Dual-compiler setup (node/web) for the new RSC config case.
crates/rspack_plugin_rsc/src/server_plugin.rs Injects rscA runtime requirements and adds the ensure runtime module to chunks.
crates/rspack_plugin_rsc/src/lib.rs Registers new runtime module source file.
crates/rspack_plugin_rsc/src/ensure_server_actions_runtime_module.rs New runtime module defining __webpack_require__.rscA.
crates/rspack_plugin_devtool/src/source_map_dev_tool_plugin.rs Canonicalizes/deduplicates relative source names and fixes inline base-path handling.
crates/rspack_plugin_devtool/src/module_filename_helpers.rs Adjusts [relative-resource-path] handling for virtual runtime modules.
crates/rspack_plugin_devtool/Cargo.toml Adds url dependency used by source-map canonicalization.
crates/rspack_loader_swc/src/rsc_transforms/server_actions.rs Emits __webpack_require__.rscA([...]) runtime validation call.
crates/rspack_core/src/runtime_globals.rs Adds RSC_ENSURE_SERVER_ACTIONS runtime global mapped to rscA.
Cargo.lock Records new Rust dependency resolution for url.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

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: 68e6130a48

ℹ️ 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".

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 12, 2026

📦 Binary Size-limit

Comparing 1b5ee20 to chore(deps): update dependency mermaid to v11.15.0 [security] (#13997) by renovate[bot]

❌ Size increased by 28.00KB from 61.97MB to 61.99MB (⬆️0.04%)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 12, 2026

Rsdoctor Bundle Diff Analysis

Found 6 projects in monorepo, 6 projects with changes.

📊 Quick Summary
Project Total Size Change
popular-libs 1.7 MB -
react-10k 5.7 MB -
react-5k 2.7 MB -
react-1k 826.3 KB -
rome 1.6 MB -
ui-components 4.8 MB -
📋 Detailed Reports (Click to expand)

📁 popular-libs

Path: ../build-tools-performance/cases/popular-libs/dist/rsdoctor-data.json

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 1.7 MB - -
📄 JavaScript 1.7 MB - -
🎨 CSS 0 B - -
🌐 HTML 289.0 B - -
📁 Other Assets 0 B - -

📁 react-10k

Path: ../build-tools-performance/cases/react-10k/dist/rsdoctor-data.json

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 5.7 MB - -
📄 JavaScript 5.7 MB - -
🎨 CSS 21.0 B - -
🌐 HTML 328.0 B - -
📁 Other Assets 0 B - -

📁 react-5k

Path: ../build-tools-performance/cases/react-5k/dist/rsdoctor-data.json

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 2.7 MB - -
📄 JavaScript 2.7 MB - -
🎨 CSS 21.0 B - -
🌐 HTML 328.0 B - -
📁 Other Assets 0 B - -

📁 react-1k

Path: ../build-tools-performance/cases/react-1k/dist/rsdoctor-data.json

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 826.3 KB - -
📄 JavaScript 826.0 KB - -
🎨 CSS 0 B - -
🌐 HTML 328.0 B - -
📁 Other Assets 0 B - -

📁 rome

Path: ../build-tools-performance/cases/rome/dist/rsdoctor-data.json

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 1.6 MB - -
📄 JavaScript 1.6 MB - -
🎨 CSS 0 B - -
🌐 HTML 0 B - -
📁 Other Assets 0 B - -

📁 ui-components

Path: ../build-tools-performance/cases/ui-components/dist/rsdoctor-data.json

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 4.8 MB - -
📄 JavaScript 4.7 MB - -
🎨 CSS 107.0 KB - -
🌐 HTML 328.0 B - -
📁 Other Assets 0 B - -

Generated by Rsdoctor GitHub Action

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 12, 2026

Merging this PR will not alter performance

✅ 34 untouched benchmarks
⏩ 25 skipped benchmarks1


Comparing fix-relative-resource-path-bug (1b5ee20) with main (46dec16)

Open in CodSpeed

Footnotes

  1. 25 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.

@SyMind SyMind force-pushed the fix-relative-resource-path-bug branch from 4270ddc to b902a9f Compare May 12, 2026 03:31
@SyMind
Copy link
Copy Markdown
Member Author

SyMind commented May 12, 2026

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

ℹ️ 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".

@web-infra-dev web-infra-dev deleted a comment from github-actions Bot May 12, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 12, 2026

📝 Rspack Ecosystem CI: Open

suite result
rsbuild ❌ failure
rsdoctor ✅ success
rslib ✅ success
modernjs ✅ success
rstest ✅ success
rsbuild-rsc-plugin ✅ success
devserver ✅ success
rspress ✅ success
plugin ❌ failure
lynx-stack ❌ failure
examples ✅ success

@SyMind SyMind closed this May 12, 2026
@SyMind SyMind deleted the fix-relative-resource-path-bug branch May 12, 2026 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: feature release: feature related release(mr only)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants