Skip to content

runtime: share one parsed value between import and require() of a JSON/TOML file - #35973

Open
robobun wants to merge 9 commits into
mainfrom
farm/dc16e277/json-require-import-identity
Open

runtime: share one parsed value between import and require() of a JSON/TOML file#35973
robobun wants to merge 9 commits into
mainfrom
farm/dc16e277/json-require-import-identity

runtime: share one parsed value between import and require() of a JSO…

d55375f
Select commit
Loading
Failed to load commit list.
Claude / Claude Code Review completed Jul 26, 2026 in 24m 38s

Code review found 1 potential issue

Found 1 candidates, confirmed 1. See review comments for details.

Details

Severity Count
🔴 Important 0
🟡 Nit 1
🟣 Pre-existing 0
Severity File:Line Issue
🟡 Nit src/jsc/bindings/ModuleLoader.cpp:933-949 ESM data-module import overwrites non-JSCommonJSModule require.cache entries

Annotations

Check warning on line 949 in src/jsc/bindings/ModuleLoader.cpp

See this annotation in the file changed.

@claude claude / Claude Code Review

ESM data-module import overwrites non-JSCommonJSModule require.cache entries

`reconcileDataModuleWithRequireCache` overwrites a user-installed plain-object `require.cache` entry: `JSMap::get()` returns `jsUndefined()` for a missing key, so `dynamicDowncast<JSCommonJSModule>(entry)` yields `nullptr` for both "no entry" and "entry is a plain `{exports: mock}`", and both fall through to `create()` + `requireMap()->set()`. Pre-PR the ESM JSON/TOML path never touched `requireMap`, so a plain-object mock survived and `overridableRequire` returned `existing.exports`; post-PR th