swc-project / swc-project/plugins

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

Open
#577 0 comments 0 reactions 1 assignee View on GitHub

@kdy1 is already working on this.

Since Mar 21, 2026.

Dominant language
Rust
Stars
389
Forks
106
Avg merge
10m
Merged PRs (30d)
1

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.