From 7e46b1b46024bfb9bf5ab288c3075b1d13acd2e8 Mon Sep 17 00:00:00 2001 From: MohamedKassim Date: Mon, 13 Apr 2026 01:44:15 +0200 Subject: [PATCH 1/2] feat(sqlite-plugin): export shared adapter helpers via ./internals subpath Made-with: Cursor --- packages/sqlite-plugin/package.json | 5 +++ .../src/react-native/internals.ts | 12 ++++++ packages/sqlite-plugin/vite.config.ts | 41 ++++++++++++++++++- 3 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 packages/sqlite-plugin/src/react-native/internals.ts diff --git a/packages/sqlite-plugin/package.json b/packages/sqlite-plugin/package.json index b4733a23..3bbc7006 100644 --- a/packages/sqlite-plugin/package.json +++ b/packages/sqlite-plugin/package.json @@ -75,6 +75,11 @@ "import": "./dist/react-native/index.js", "require": "./dist/react-native/index.cjs" }, + "./internals": { + "types": "./dist/react-native/internals.d.ts", + "import": "./dist/react-native/internals.js", + "require": "./dist/react-native/internals.cjs" + }, "./package.json": "./package.json" }, "publishConfig": { diff --git a/packages/sqlite-plugin/src/react-native/internals.ts b/packages/sqlite-plugin/src/react-native/internals.ts new file mode 100644 index 00000000..c56fac13 --- /dev/null +++ b/packages/sqlite-plugin/src/react-native/internals.ts @@ -0,0 +1,12 @@ +/** + * Shared SQL + bridge helpers for custom SQLite adapters (e.g. non-Expo drivers). + * @see createSqliteAdapter in ./adapters/generic.ts + */ +export type { SqlStatementSegment } from '../shared/sql'; +export { + classifySqlStatement, + normalizeSingleStatementSql, + splitSqlStatements, + statementReturnsRows, +} from '../shared/sql'; +export { decodeSqliteBridgeValue, formatSqliteError } from '../shared/bridge-values'; diff --git a/packages/sqlite-plugin/vite.config.ts b/packages/sqlite-plugin/vite.config.ts index 7db548c7..5f27d878 100644 --- a/packages/sqlite-plugin/vite.config.ts +++ b/packages/sqlite-plugin/vite.config.ts @@ -1,10 +1,49 @@ /// +import path from 'node:path'; import { defineConfig } from 'vite'; import { rozenitePlugin } from '@rozenite/vite-plugin'; +/** Second entry for `@rozenite/sqlite-plugin/internals` without touching the shared vite RN preset. */ +const sqliteInternalsSubpathPlugin = { + name: 'sqlite-plugin-internals-subpath', + enforce: 'post' as const, + config(config: import('vite').UserConfig) { + const root = __dirname; + config.build ??= {}; + config.build.lib = { + ...config.build.lib, + entry: { + index: path.resolve(root, 'react-native.ts'), + internals: path.resolve(root, 'src/react-native/internals.ts'), + }, + fileName: (format: string, entryName: string) => { + const ext = format === 'es' ? 'js' : 'cjs'; + return `react-native/${entryName}.${ext}`; + }, + }; + config.build.rollupOptions ??= {}; + config.build.rollupOptions.output = [ + { + format: 'es', + exports: 'named' as const, + interop: 'auto' as const, + entryFileNames: 'react-native/[name].js', + chunkFileNames: 'react-native/chunks/[name].js', + }, + { + format: 'cjs', + exports: 'named' as const, + interop: 'auto' as const, + entryFileNames: 'react-native/[name].cjs', + chunkFileNames: 'react-native/chunks/[name].cjs', + }, + ]; + }, +}; + export default defineConfig({ root: __dirname, - plugins: [rozenitePlugin()], + plugins: [rozenitePlugin(), sqliteInternalsSubpathPlugin], base: './', build: { outDir: './dist', From f5636926cb2f944f139302e84d7f441830375bb9 Mon Sep 17 00:00:00 2001 From: MohamedKassim Date: Mon, 13 Apr 2026 02:04:59 +0200 Subject: [PATCH 2/2] refactor(sqlite-plugin): re-export adapter helpers from main entry Drop ./internals subpath and the extra Vite entry; export shared SQL and bridge helpers from react-native.ts alongside createSqliteAdapter. Made-with: Cursor --- packages/sqlite-plugin/package.json | 5 --- packages/sqlite-plugin/react-native.ts | 10 +++++ .../src/react-native/internals.ts | 12 ------ packages/sqlite-plugin/vite.config.ts | 41 +------------------ 4 files changed, 11 insertions(+), 57 deletions(-) delete mode 100644 packages/sqlite-plugin/src/react-native/internals.ts diff --git a/packages/sqlite-plugin/package.json b/packages/sqlite-plugin/package.json index 3bbc7006..b4733a23 100644 --- a/packages/sqlite-plugin/package.json +++ b/packages/sqlite-plugin/package.json @@ -75,11 +75,6 @@ "import": "./dist/react-native/index.js", "require": "./dist/react-native/index.cjs" }, - "./internals": { - "types": "./dist/react-native/internals.d.ts", - "import": "./dist/react-native/internals.js", - "require": "./dist/react-native/internals.cjs" - }, "./package.json": "./package.json" }, "publishConfig": { diff --git a/packages/sqlite-plugin/react-native.ts b/packages/sqlite-plugin/react-native.ts index 6f8b9397..e50e0853 100644 --- a/packages/sqlite-plugin/react-native.ts +++ b/packages/sqlite-plugin/react-native.ts @@ -19,6 +19,16 @@ export type { ExpoSqliteLike, } from './src/react-native/adapters/expo-sqlite'; +/** Shared SQL + bridge helpers for custom adapters (e.g. non-Expo SQLite drivers). */ +export type { SqlStatementSegment } from './src/shared/sql'; +export { + classifySqlStatement, + normalizeSingleStatementSql, + splitSqlStatements, + statementReturnsRows, +} from './src/shared/sql'; +export { decodeSqliteBridgeValue, formatSqliteError } from './src/shared/bridge-values'; + type CreateSqliteAdapter = typeof import('./src/react-native/adapters').createSqliteAdapter; type CreateExpoSqliteAdapter = diff --git a/packages/sqlite-plugin/src/react-native/internals.ts b/packages/sqlite-plugin/src/react-native/internals.ts deleted file mode 100644 index c56fac13..00000000 --- a/packages/sqlite-plugin/src/react-native/internals.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Shared SQL + bridge helpers for custom SQLite adapters (e.g. non-Expo drivers). - * @see createSqliteAdapter in ./adapters/generic.ts - */ -export type { SqlStatementSegment } from '../shared/sql'; -export { - classifySqlStatement, - normalizeSingleStatementSql, - splitSqlStatements, - statementReturnsRows, -} from '../shared/sql'; -export { decodeSqliteBridgeValue, formatSqliteError } from '../shared/bridge-values'; diff --git a/packages/sqlite-plugin/vite.config.ts b/packages/sqlite-plugin/vite.config.ts index 5f27d878..7db548c7 100644 --- a/packages/sqlite-plugin/vite.config.ts +++ b/packages/sqlite-plugin/vite.config.ts @@ -1,49 +1,10 @@ /// -import path from 'node:path'; import { defineConfig } from 'vite'; import { rozenitePlugin } from '@rozenite/vite-plugin'; -/** Second entry for `@rozenite/sqlite-plugin/internals` without touching the shared vite RN preset. */ -const sqliteInternalsSubpathPlugin = { - name: 'sqlite-plugin-internals-subpath', - enforce: 'post' as const, - config(config: import('vite').UserConfig) { - const root = __dirname; - config.build ??= {}; - config.build.lib = { - ...config.build.lib, - entry: { - index: path.resolve(root, 'react-native.ts'), - internals: path.resolve(root, 'src/react-native/internals.ts'), - }, - fileName: (format: string, entryName: string) => { - const ext = format === 'es' ? 'js' : 'cjs'; - return `react-native/${entryName}.${ext}`; - }, - }; - config.build.rollupOptions ??= {}; - config.build.rollupOptions.output = [ - { - format: 'es', - exports: 'named' as const, - interop: 'auto' as const, - entryFileNames: 'react-native/[name].js', - chunkFileNames: 'react-native/chunks/[name].js', - }, - { - format: 'cjs', - exports: 'named' as const, - interop: 'auto' as const, - entryFileNames: 'react-native/[name].cjs', - chunkFileNames: 'react-native/chunks/[name].cjs', - }, - ]; - }, -}; - export default defineConfig({ root: __dirname, - plugins: [rozenitePlugin(), sqliteInternalsSubpathPlugin], + plugins: [rozenitePlugin()], base: './', build: { outDir: './dist',