fix: avoid rspack runtime name conflicts - #14996
LingyuCoder wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0b498c0b18
ℹ️ 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".
| } else { | ||
| parser.parser_runtime_requirements.require.as_str() | ||
| } | ||
| parser.parser_runtime_requirements.require.as_str() |
There was a problem hiding this comment.
Choose the nested name from the render mode
With experiments.runtimeMode: "rspack" and ordinary non-modern-module output, module code uses RspackContext, so the factory argument is __rspack_context while parser_runtime_requirements.require is the member expression __rspack_context.r. No declaration can match that string, leaving nested bindings named __rspack_context unchanged so they can shadow generated calls such as __rspack_context.r(...) and break a nested require(). This also regresses configCases/runtime/runtime-mode-nested-rspack-context, which explicitly expects the binding to be renamed; keep using the context name for RspackContext and use the require name only for RspackExport.
Useful? React with 👍 / 👎.
| parser.compiler_options.experiments.runtime_mode == RuntimeMode::Rspack | ||
| && parser.is_esm | ||
| && parser.is_top_level_scope() |
There was a problem hiding this comment.
Limit the ESM binding exemption to export rendering
When Rspack runtime mode parses an ESM source for ordinary non-modern-module output, this predicate is still true even though no ESM linker will deconflict the binding; with concatenation disabled, the module is emitted inside a factory whose parameters include __rspack_exports and __rspack_context. A top-level declaration such as const __rspack_exports = ... is therefore skipped here and emitted as a lexical redeclaration of the factory parameter, making the bundle fail to parse. Restrict this exemption to the RspackExport render mode where the ESM linker actually handles top-level bindings.
Useful? React with 👍 / 👎.
📦 Binary Size-limit
🙈 Size remains the same at 66.74MB |
Rsdoctor Bundle Diff AnalysisFound 5 projects in monorepo, 0 projects with changes. 📊 Quick Summary
Generated by Rsdoctor GitHub Action |
Merging this PR will not alter performance
Comparing Footnotes
|
|
Split into focused pull requests for easier review:
|
Summary
rspackRequiremodule factory argument when handling nested bindingscontext,exports, local CJSrspackRequire, and runtime-free exported function namesTesting
corepack pnpm --filter @rspack/binding run build:devcorepack pnpm --parallel --filter '@rspack/*' test\n- targeted RuntimeModeEsmOutput regression cases\n-cargo check -p rspack_plugin_esm_library -p rspack_plugin_javascript