Skip to content

fix: circular import#319

Merged
ospfranco merged 1 commit into
OP-Engineering:mainfrom
needim:no-cycle
Sep 10, 2025
Merged

fix: circular import#319
ospfranco merged 1 commit into
OP-Engineering:mainfrom
needim:no-cycle

Conversation

@needim
Copy link
Copy Markdown
Contributor

@needim needim commented Sep 10, 2025

When using TypeScript with moduleResolution: "NodeNext" and module: "NodeNext", importing named exports from @op-engineering/op-sqlite v15 fails with:

error TS2305: Module '"@op-engineering/op-sqlite"' has no exported member 'open'

However, the same import works perfectly with moduleResolution: "bundler" and module: "esnext".

The issue stems from a circular dependency in the package's TypeScript definitions:

Why NodeNext Fails

TypeScript's NodeNext module resolution uses stricter ESM semantics and has difficulty resolving re-exports when there are circular type dependencies. The module resolution algorithm fails to properly expose the open function export due to this circular reference.

Why Bundler Works

The bundler module resolution mode is designed for modern bundlers that handle circular dependencies more gracefully. It resolves the re-exports in a way that successfully breaks the circular dependency cycle.

related: #263 #308 #317

@needim needim changed the title fix: cycle import fix: circular import Sep 10, 2025
@ospfranco
Copy link
Copy Markdown
Contributor

I guess you are running in some sort of monorepo setup? Are you even supposed to run RN without the bundler setting? Does it not mess with metro?

@ospfranco ospfranco merged commit 4089ec4 into OP-Engineering:main Sep 10, 2025
8 checks passed
@needim
Copy link
Copy Markdown
Contributor Author

needim commented Sep 10, 2025

Yes, we have a monorepo setup, changing moduleResolution to bundler resolves it.

Looks like package.json exports confusing nodenext. I'm not sure.

https://arethetypeswrong.github.io/?p=%40op-engineering%2Fop-sqlite%4015.0.3

image

Thanks for the amazing work btw. 💙

@ospfranco
Copy link
Copy Markdown
Contributor

Monorepo setups are too complicated, so they are not in my priority list. Feel free to submit PRs that fix the problem, as long as they don't clash with RN just functioning I will continue merging them.

subtleGradient pushed a commit to effect-native/op-sqlite that referenced this pull request Sep 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants