Skip to content

fix: resolve import() of self-accepting modules to their latest evaluation - #16595

Merged
hai-x merged 2 commits into
mainfrom
lazy-compilation-stale-proxy
Nov 13, 2026
Merged

hai-x merged 2 commits into
mainfrom
lazy-compilation-stale-proxy

Conversation

@hai-x

@hai-x hai-x commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Motivation

With lazy compilation on, import() of a module that accepts its own hot updates keeps returning the exports from its first evaluation. The module is re-evaluated on every edit and the page does not reload, so the stale value is silent.

// rspack.config.js: lazyCompilation: { imports: true }

// src/index.js
window.load = () => import('./value.js').then((m) => console.log(m.value));

// src/value.js — edit 'v1' to 'v2', then call load() again
export const value = 'v1';
import.meta.webpackHot.accept();
  • Expected: load() logs v2, as it does with lazyCompilation: false
  • Actual: load() logs v1

This hits tools that add a self-accept to component modules, such as solid-refresh.

Closes #16594

Changes

A lazily compiled module is imported through a proxy module. The proxy exported one promise, created when the proxy first ran, and only replaced it when a hot update reached the proxy. An update that a module accepts itself stops at that module, so the proxy kept the old promise.

The proxy now exports a thenable that loads the inner module on every import(), so each call reads the current module instance.

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

📦 Binary Size-limit

Comparing 96a3d4a to perf: reduce chunk filename runtime size (#16598) by Jiahan Chen

🙈 Size remains the same at 68.82MB

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Rsdoctor Bundle Diff Analysis

⚠️ Note: The latest commit (36bcf608d046b20a6ba1c0fbe43c58d8f0c37f1c) does not have baseline artifacts. Using commit b14db6b2e07d0f76ea538c2d1c9ca192e77f4bc2 for baseline comparison instead. If this seems incorrect, please wait a few minutes and try rerunning the workflow.

Found 5 projects in monorepo, 0 projects with changes.

📊 Quick Summary
Project Total Size Gzip Size Change Gzip Change
popular-libs 1.7 MB 541.5 KB 0 0
react-10k 5.4 MB 1.3 MB 0 0
react-1k 827.5 KB 225.2 KB 0 0
react-5k 2.6 MB 670.6 KB 0 0
ui-components 4.7 MB 1.4 MB 0 0

Generated by Rsdoctor GitHub Action

@codspeed

codspeed Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 57 untouched benchmarks
⏩ 47 skipped benchmarks1


Comparing lazy-compilation-stale-proxy (96a3d4a) with main (b14db6b)2

Open in CodSpeed

Footnotes

  1. 47 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. ↩

  2. No successful run was found on main (36bcf60) during the generation of this report, so b14db6b was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@hai-x

hai-x commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-13T03:52:21.860695Z 96a3d4a Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 96a3d4ade4

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: lazy compilation: import() of a module that accepts its own updates keeps resolving to its first namespace

2 participants