Skip to content

mut-cjs-exports doesn't properly handle circular imports with barrel files #577

@karmeleon

Description

@karmeleon

Describe the bug

When a dependency cycle includes a barrel file, imports are not resolved properly.

See this issue on the original repo for a more detailed explanation of the issue.

URL to minimal reproduction

Please provide a minimal reproduction of the issue. Ideally, the reproduction should only have

  • @swc/core or next
  • the problematic Wasm plugin
    as the dependency.

https://github.com/karmeleon/swc-jest-repro/tree/main

Expected behavior

The tests in the above repo should pass -- see README for details.

Additional context

The recommendation on the original repo was to override Object.defineProperty to make all invocations of it configurable. However, since swc without this plugin transpiles CJS exports to use getters and does not include setters, simply setting configurable throws the error TypeError: Cannot set property notify of [object Object] which has only a getter. I haven't been able to write a new defineProperty shim that works reliably.

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