Skip to content

feat(sqlite-plugin): add adapter-helpers subpath export#226

Closed
Mohamed-kassim wants to merge 1 commit intocallstackincubator:mainfrom
Mohamed-kassim:feat/sqlite-plugin-internals-export
Closed

feat(sqlite-plugin): add adapter-helpers subpath export#226
Mohamed-kassim wants to merge 1 commit intocallstackincubator:mainfrom
Mohamed-kassim:feat/sqlite-plugin-internals-export

Conversation

@Mohamed-kassim
Copy link
Copy Markdown

@Mohamed-kassim Mohamed-kassim commented Apr 12, 2026

Summary

We’re integrating Rozenite SQLite inspector with non-Expo SQLite drivers (e.g. react-native-nitro-sqlite). The plugin already has shared SQL normalization / statement classification / bridge decode / error formatting helpers, but they were not available on a stable public subpath.

This PR exposes those helpers via a dedicated subpath:

  • @rozenite/sqlite-plugin/adapter-helpers

This keeps helper code out of the main package entry and avoids leaking it into production builds that only use the core plugin APIs.

Implementation notes

  • Added src/react-native/adapter-helpers.ts to re-export existing shared helpers from src/shared/sql and src/shared/bridge-values.
  • Added ./adapter-helpers to packages/sqlite-plugin/package.json exports.
  • Added a second RN build entry in vite.config.ts so dist emits:
    • dist/react-native/adapter-helpers.js
    • dist/react-native/adapter-helpers.cjs
    • dist/react-native/adapter-helpers.d.ts

Question for maintainers

We also have a small adapter that wires react-native-nitro-sqlite into createSqliteAdapter, using these same helpers. Are you open to follow-up PRs that add additional first-party adapters (e.g. Nitro)?


Thanks for reviewing.

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 12, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
rozenite Skipped Skipped May 9, 2026 9:37am

Request Review

@Mohamed-kassim Mohamed-kassim changed the title feat(sqlite-plugin): expose shared adapter helpers via ./internals feat(sqlite-plugin): export shared adapter helpers from main package entry Apr 13, 2026
Copy link
Copy Markdown
Contributor

@V3RON V3RON left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should create a separate entry point for these helpers, since they are currently being pulled into production app builds (they are not gated by the if statement below).

For example, we could define a new entry point like @rozenite/sqlite-plugin/adapter-helpers and export them from there. This would eliminate any risk of leakage.

@Mohamed-kassim Mohamed-kassim changed the title feat(sqlite-plugin): export shared adapter helpers from main package entry feat(sqlite-plugin): add adapter-helpers subpath export May 8, 2026
@Mohamed-kassim
Copy link
Copy Markdown
Author

I think we should create a separate entry point for these helpers, since they are currently being pulled into production app builds (they are not gated by the if statement below).

For example, we could define a new entry point like @rozenite/sqlite-plugin/adapter-helpers and export them from there. This would eliminate any risk of leakage.

Sorry for the delay, I missed your reply.
Addressed! I moved the helper exports out of the main entry into a dedicated subpath. The main entry is now focused on the existing plugin API.

Co-authored-by: Cursor <cursoragent@cursor.com>
@V3RON
Copy link
Copy Markdown
Contributor

V3RON commented May 11, 2026

This approach doesn't work quite as expected. Vite crashes when trying to run vite-require-plugin because it generates multiple outputs where only one is expected. Even after fixing that, some extra files still end up in dist/react-native, like the JS bundle for the DevTools UI.

To keep things simple for now, I decided to go with the same approach we already use for other plugin exports and just provide mocks in production. It's not perfect, but it should work well enough until I get a chance to revisit the Vite plugin setup.

See #259

@V3RON V3RON closed this May 11, 2026
V3RON added a commit that referenced this pull request May 11, 2026
#259)

## Why

When building a custom SQLite adapter for Rozenite (e.g. a driver not
covered by the built-in Expo SQLite adapter), developers need to parse,
classify, and normalise SQL statements themselves — and decode
bridge-encoded values returned over the JS/native boundary. The relevant
utilities already exist in `shared/sql` and `shared/bridge-values`, but
they were not exported from the package, forcing consumers to either
duplicate the logic or reach into internal paths.

## What

Exports the following helpers from the `react-native` entry-point of
`sqlite-plugin`:

**`shared/sql`**
- `SqlStatementSegment` (type)
- `classifySqlStatement`
- `normalizeSingleStatementSql`
- `splitSqlStatements`
- `statementReturnsRows`

**`shared/bridge-values`**
- `decodeSqliteBridgeValue`
- `formatSqliteError`

## Approach

An earlier attempt at this was made in #226, which tried to generate a
new dedicated entry-point for these helpers. That approach turned out to
be flaky, so for the time being the same pattern used for all other
exported functions is applied here: `let` declarations assigned via
inline `require()` calls that Metro can statically analyse, with passive
no-op mocks assigned in the `else` branch for production/web/SSR builds.
This ensures the helpers are completely tree-shaken out of production
bundles.
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