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

scope reconcile to JSON/TOML/JSONC/YAML (not HTML/CSS/file loader)

4dd327e
Select commit
Loading
Failed to load commit list.
Claude / Claude Code Review completed Jul 26, 2026 in 17m 8s

Code review found 2 potential issues

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

Details

Severity Count
🔴 Important 0
🟡 Nit 2
🟣 Pre-existing 0
Severity File:Line Issue
🟡 Nit src/jsc/bindings/ModuleLoader.cpp:932-941 reconcile clobbers require.extensions result when module.loaded is false

Annotations

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

See this annotation in the file changed.

@claude claude / Claude Code Review

reconcile clobbers require.extensions result when module.loaded is false

The `mod->hasEvaluated` gate also clobbers a `require.extensions['.json']` result: a Node-style handler that assigns `module.exports = ...` directly (no `_compile()`) leaves the cached module with `hasEvaluated == false`, so a later ESM import of the same file falls through to `mod->setExportsObject(value)` and replaces the extension's exports with the on-disk parse. This is separate from the plain-object case above — here `dynamicDowncast` succeeds, so an `entry.isUndefined()` guard would not h