Skip to content

Avoid dynamic require of the native package#200

Merged
penberg merged 1 commit intotursodatabase:v0.5from
bgw:statically-analyzable-requires
Aug 26, 2025
Merged

Avoid dynamic require of the native package#200
penberg merged 1 commit intotursodatabase:v0.5from
bgw:statically-analyzable-requires

Conversation

@bgw
Copy link

@bgw bgw commented Aug 22, 2025

Fixes libsql with next build --turbopack: vercel/next.js#82881 (comment)

When combined with a non-isolating hoisting package manager (e.g. pnpm avoids this problem), these requires are written in a way that bundlers may be forced to pull in extra packages and files that are also under the @libsql/ namespace. Even if this doesn't cause issues with certain tooling, it's playing with fire.

This could be written in a more clever way, but this writes it in the simplest-to-analyze possible way that should work with all bundlers. There's no real standard for what is or isn't statically analyzable by a bundler.

This is a PR for the v0.5 branch.

v0.6.x does not appear to have this problem, as it's written in a similar way to this, where there are simple require() expressions with static strings.

@penberg penberg merged commit 4b007a6 into tursodatabase:v0.5 Aug 26, 2025
penberg added a commit that referenced this pull request Aug 26, 2025
This reverts commit 4b007a6, reversing
changes made to 776474a.

Fixes #201
@penberg
Copy link
Contributor

penberg commented Aug 26, 2025

Hey @bgw! I had to unfortunately revert this as #201 reported breakage with esbuild...

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