Skip to content

The function exported using Object.defineProperty in node_modules cannot be found. #56304

Open
@shlroland

Description

@shlroland

Version

v22.9.0

Platform

Darwin mini.local 24.0.0 Darwin Kernel Version 24.0.0: Tue Sep 24 23:36:26 PDT 2024; root:xnu-11215.1.12~1/RELEASE_ARM64_T8103 arm64

Subsystem

No response

What steps will reproduce the bug?

related issue #56286

reproduction code demo_import.zip

Advance declaration: The code inside the current node_modules which is in reproduction code, I did not use any package manager(npm/yarn/pnpm) for installation, but rather manually copied and pasted it in, ensuring the exclusion of interference from package management.

Steps:
Download and unzip the reproduction code, and directly execute node index.js.

This is my execution result

Image

How often does it reproduce? Is there a required condition?

100%

What is the expected behavior? Why is that the expected behavior?

shouldImport This function can be directly accessed in the first layer of the module object, rather than only being obtainable in the internal default object.

What do you see instead?

shouldImport was lost during the conversion from cjs to esm

Additional information

I also tried to execute the code using bun(1.1.40), and the result was correct.

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions