Repository navigation
fix: support deferred imports introduced by hot updates - #16015
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
📦 Binary Size-limit
🙈 Size remains the same at 67.17MB |
Rsdoctor Bundle Diff AnalysisFound 5 projects in monorepo, 1 project with changes. 📊 Quick Summary
📋 Detailed Reports (Click to expand)📁 ui-componentsPath:
📦 Download Diff Report: ui-components Bundle Diff 🤖 AI Degradation Analysis (Click to expand)📊 Size ChangesNo significant regressions detected 🎉. Total bundle size decreased slightly (-3 bytes). 🔍 Root Cause Analysis
|
Merging this PR will not alter performance
Comparing Footnotes
|
Motivation
Fixes #15960.
With
experiments.deferImport, lazy compilation can introduce deferred imports through a hot update after the initial bootstrap has run. The deferred namespace and async-dependency helpers access the module cache through a bootstrap-local variable, causingReferenceError: __webpack_module_cache__ is not definedin the hot-update chunk. The deferred exports table has the same scope problem, and the initialrequiremay not include support for sharing those exports.Changes
Reference the module cache through
MODULE_CACHEand expose the deferred exports table asDEFERRED_MODULE_EXPORTS. When HMR andexperiments.deferImportare enabled, initialize the shared table and the correspondingrequiresupport in the initial bootstrap, while generating the deferred namespace helper only when needed.Carry the shared state through both runtime modes and modern-module output so pending namespaces retain their export targets when helpers are updated. Also remove table entries after successful module execution with
strictModuleErrorHandling, preventing stale export objects from being reused by subsequent hot updates.