Skip to content

fix(core): guard interop has trap against primitive default export#1234

Merged
fi3ework merged 1 commit into
mainfrom
fix/interop-has-trap-primitive
May 9, 2026
Merged

fix(core): guard interop has trap against primitive default export#1234
fi3ework merged 1 commit into
mainfrom
fix/interop-has-trap-primitive

Conversation

@fi3ework

@fi3ework fi3ework commented May 9, 2026

Copy link
Copy Markdown
Member

Summary

  • Follow-up to feat(core): resolve dynamic imports against source module origin #1210 (ultrareview finding bug_004).
  • The has trap in createInteropProxy evaluated prop in defaultExport behind only a truthiness check. For CJS modules whose module.exports is a truthy primitive (42, "str", true), in against a primitive throws TypeError: Cannot use 'in' operator to search for ... in 42.
  • The get trap was already safe via ?. optional chaining; the has path needed an explicit !isPrimitive(defaultExport) gate to match.

Test plan

  • pnpm --filter @rstest/core test -- tests/runner/interop.test.ts (189/189 pass, including new primitive module.exports regression cases for 'foo' in ns not throwing and default resolving via both get and has).

The `has` trap in `createInteropProxy` evaluated `prop in defaultExport`
behind only a truthiness check. For CJS modules whose `module.exports`
is a truthy primitive (`42`, `"str"`, `true`), this threw
`TypeError: Cannot use 'in' operator to search for ... in 42`.

Mirror the `get` trap's optional-chaining semantics by gating with
`!isPrimitive(defaultExport)`.
@github-actions

github-actions Bot commented May 9, 2026

Copy link
Copy Markdown

📝 Rstest Ecosystem CI: Open

suite result
modernjs ✅ success
rspress ✅ success
rsdoctor ✅ success
examples ✅ success
rslib ✅ success
rsbuild ✅ success

@github-actions

github-actions Bot commented May 9, 2026

Copy link
Copy Markdown

Rsdoctor Bundle Diff Analysis

Found 12 projects in monorepo, 1 project with changes.

📊 Quick Summary
Project Total Size Change
adapter-rsbuild 3.6 KB 0
adapter-rslib 24.6 KB 0
adapter-rspack 7.7 KB 0
browser 2.0 MB 0
browser-react 3.7 KB 0
browser-ui 803.5 KB 0
coverage-istanbul 9.6 KB 0
core/browser 970.2 KB 0
core/loaders 869.0 B 0
core/main 1.6 MB +14.0 B (0.0%)
vscode/extension 58.9 MB 0
vscode/worker 14.4 KB 0
📋 Detailed Reports (Click to expand)

📁 core/main

Path: packages/core/.rsdoctor/main/rsdoctor-data.json

📌 Baseline Commit: 130762b375 | PR: #1210

Metric Current Baseline Change
📊 Total Size 1.6 MB 1.6 MB +14.0 B (0.0%)
📄 JavaScript 1.5 MB 1.5 MB +14.0 B (0.0%)
🎨 CSS 0 B 0 B 0
🌐 HTML 0 B 0 B 0
📁 Other Assets 79.2 KB 79.2 KB 0

📦 Download Diff Report: core/main Bundle Diff

Generated by Rsdoctor GitHub Action

@fi3ework fi3ework merged commit 0129db1 into main May 9, 2026
19 checks passed
@fi3ework fi3ework deleted the fix/interop-has-trap-primitive branch May 9, 2026 05:40
@9aoy 9aoy mentioned this pull request May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant