fix: compile-time evaluation of optional chaining#12494
Conversation
✅ Deploy Preview for rspack canceled.
|
There was a problem hiding this comment.
Pull request overview
This PR enables compile-time evaluation and member expression analysis for optional chaining expressions in the JavaScript parser. It refactors the member expression utilities to work with the Expr enum (which includes both Expr::Member and Expr::OptChain) rather than just MemberExpr directly, and removes the test filter that was blocking the optional chaining test case.
- Generalizes
get_member_expression_infoandextract_member_expression_chainto acceptExprinstead of&MemberExpr - Updates all call sites to wrap
MemberExprwithExpr::Member()when calling these functions - Enables the previously disabled optional chaining test to verify compile-time evaluation works with DefinePlugin
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/rspack-test/configCases/parsing/optional-chaining/test.filter.js | Removes test filter to enable optional chaining test case |
| crates/rspack_plugin_javascript/src/visitors/dependency/parser/walk.rs | Updates call sites to wrap MemberExpr with Expr::Member when calling get_member_expression_info |
| crates/rspack_plugin_javascript/src/visitors/dependency/parser/mod.rs | Refactors member expression utilities to accept Expr instead of &MemberExpr, adds OptChain handling |
| crates/rspack_plugin_javascript/src/visitors/dependency/parser/call_hooks_name.rs | Updates MemberExpr::call_hooks_name to wrap with Expr::Member |
| crates/rspack_plugin_javascript/src/utils/eval/eval_member_expr.rs | Updates call site to wrap MemberExpr with Expr::Member |
| crates/rspack_plugin_javascript/src/parser_plugin/url_plugin.rs | Updates call site to wrap MemberExpr with Expr::Member |
| crates/rspack_plugin_javascript/src/parser_plugin/import_meta_plugin.rs | Updates call site to wrap MemberExpr with Expr::Member |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
crates/rspack_plugin_javascript/src/visitors/dependency/parser/mod.rs
Outdated
Show resolved
Hide resolved
…/mod.rs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Rsdoctor Bundle Diff AnalysisFound 5 project(s) in monorepo. 📊 Quick Summary (Click to expand)
📋 Detailed Reports (Click to expand)📁 react-10kPath:
📦 Download Diff Report: react-10k Bundle Diff 📁 react-1kPath:
📦 Download Diff Report: react-1k Bundle Diff 📁 react-5kPath:
📦 Download Diff Report: react-5k Bundle Diff 📁 ui-componentsPath:
📦 Download Diff Report: ui-components Bundle Diff 📁 romePath:
📦 Download Diff Report: rome Bundle Diff Generated by Rsdoctor GitHub Action |
📦 Binary Size-limit
❌ Size increased by 2.38KB from 48.26MB to 48.27MB (⬆️0.00%) |
CodSpeed Performance ReportMerging #12494 will not alter performanceComparing Summary
|
Summary
This PR enables compile-time evaluation and member expression analysis for
import.metaand optional chaining expressions in the JavaScript parser. It generalizes the member expression utilities to work onExpr(includingExpr::OptChain) and removes theoptional-chainingtest filter so that the config case now runs as part of the normal test suite.Checklist