镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

fix(commonjs): fix crash with invalidated proxy modules - #1876

Merged
shellscape merged 1 commit into
masterfrom
fix/commonjs/handle-invalidated-proxy-modules
Jun 17, 2025
Merged

shellscape merged 1 commit into
masterfrom
fix/commonjs/handle-invalidated-proxy-modules

Conversation

@lukastaegert

@lukastaegert lukastaegert commented Jun 14, 2025 •

Copy link
Copy Markdown
Member

In watch mode when the code imports CommonJS from ESM, depending on the setup, it can happen that the ES to Commonjs proxy module is re-evaluated. If that happens, its meta information is lost, leading to a weird crash.

Rollup Plugin Name: commonjs

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes (bugfixes and features will not be merged without tests)
  • no

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

If yes, then include "BREAKING CHANGES:" in the first commit message body, followed by a description of what is breaking.

List any relevant issue numbers:

Description

I stumbled upon a case where in watch mode when changing a file, the CommonJS plugin would show a weird error. What happened is that a proxy module that was generated for a CommonJS from ESM import was being re-evaluated in its importer's shouldTransformCachedModule hook. Due to a small bug, the meta information of the proxy was lost, leading to a crash. This fixes it by supplying this meta information via loading the full resolved id object (that contains the meta information) instead of just using the id.

In watch mode when the code imports CommonJS from ESM, depending on the setup,
it can happen that the ES to Commonjs proxy module is re-evaluated. If that
happens, its meta information is lost, leading to a weird crash.
@lukastaegert
lukastaegert requested a review from shellscape as a code owner June 14, 2025 06:19
@shellscape
shellscape merged commit 7b9d40d into master Jun 17, 2025
@shellscape
shellscape deleted the fix/commonjs/handle-invalidated-proxy-modules branch June 17, 2025 13:21
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.

2 participants