Skip to content

fix(native): add CJS require-destructured binding support to resolve receiver edges #1678

Description

@carlos-alm

PR #1677 added a WASM fix (commit 066d7d0) that detects const { X } = require('…') CJS destructured bindings and feeds them into importArtifactNames so resolveReceiverEdge can correctly emit receiver edges for CJS-imported classes (e.g. calc.compute() where Calculator was CJS-imported).

The native Rust engine does not have the equivalent fix, causing a build-parity test failure: WASM produces 39 edges on sample-project (JS) while native produces 38.

Root cause: buildImportArtifactNames in the native build-edges path does not include CJS require bindings in the import artifact name set passed to resolveReceiverEdge.

Fix needed:

  1. Detect const { X } = require('…') in the Rust JavaScript extractor (mirrors WASM extractDestructuredBindingsWalk changes)
  2. Pass CJS bindings into the Rust equivalent of buildImportArtifactNames / resolveReceiverEdge

Introduced in PR #1677.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions