feat(rsc): validate server action exports with runtime global#14000
feat(rsc): validate server action exports with runtime global#14000SyMind wants to merge 3 commits into
Conversation
Deploying rspack with
|
| 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 |
68e6130 to
4270ddc
Compare
There was a problem hiding this comment.
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 importingensureServerActions). - 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.
There was a problem hiding this comment.
💡 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".
📦 Binary Size-limit
❌ Size increased by 28.00KB from 61.97MB to 61.99MB (⬆️0.04%) |
Rsdoctor Bundle Diff AnalysisFound 6 projects in monorepo, 6 projects with changes. 📊 Quick Summary
📋 Detailed Reports (Click to expand)📁 popular-libsPath:
📁 react-10kPath:
📁 react-5kPath:
📁 react-1kPath:
📁 romePath:
📁 ui-componentsPath:
Generated by Rsdoctor GitHub Action |
Merging this PR will not alter performance
Comparing Footnotes
|
4270ddc to
b902a9f
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Breezy! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Summary
RuntimeGlobals::RSC_ENSURE_SERVER_ACTIONSmapped to__webpack_require__.rscA.__webpack_require__.rscAfor"use server"export validation.__webpack_require__.rscA([...])instead of importingensureServerActionsfromreact-server-dom-rspack/server.RscServerPlugininject the runtime helper based onbuild_info.rsc.action_ids, including concatenated modules.rsc-plugin/server-actions-export-validationto verify invalid server action exports through runtime execution instead of bundle string matching.Related links
Checklist