Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ jobs:
(cd packages/react-native-nitro-sqlite-vec && ../../node_modules/.bin/jest --coverage --runInBand)
(cd example && ../node_modules/.bin/jest --config jest.mocha.config.js --runInBand --watchman=false)
node --test example/macos/scripts/test-macos.test.mjs
- name: Build the library package
if: steps.select.outputs.typescript == 'true'
run: bun --cwd packages/react-native-nitro-sqlite run build
- name: Format C++
if: steps.select.outputs.cpp_format == 'true'
run: |
Expand Down
3 changes: 1 addition & 2 deletions example/babel.config.shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ function createExampleBabelConfig(projectRoot) {
const aliases = {
[libraryPackage.name]: path.join(
__dirname,
'../packages/react-native-nitro-sqlite',
libraryPackage.source,
'../packages/react-native-nitro-sqlite/src/index',
),
'stream': 'readable-stream',
'react-native-sqlite-storage': libraryPackage.name,
Expand Down
2 changes: 2 additions & 0 deletions packages/react-native-nitro-sqlite/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module.exports = {
root: true,
extends: '../../config/.eslintrc.js',
// bob's per-target Babel configs sit outside the TypeScript project, like babel.config.js.
ignorePatterns: ['babel.config.*.js'],
parserOptions: {
project: true,
tsconfigRootDir: __dirname,
Expand Down
10 changes: 10 additions & 0 deletions packages/react-native-nitro-sqlite/babel.config.commonjs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// bob builds the commonjs target with this config so it can parse the decorated .nitro.ts specs.
module.exports = {
presets: [
[
'react-native-builder-bob/babel-preset',
{ modules: 'commonjs', esm: true },
],
],
parserOpts: { plugins: ['decorators'] },
}
10 changes: 10 additions & 0 deletions packages/react-native-nitro-sqlite/babel.config.module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// bob builds the module target with this config so it can parse the decorated .nitro.ts specs.
module.exports = {
presets: [
[
'react-native-builder-bob/babel-preset',
{ modules: 'preserve', esm: true },
],
],
parserOpts: { plugins: ['decorators'] },
}
13 changes: 6 additions & 7 deletions packages/react-native-nitro-sqlite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
"name": "react-native-nitro-sqlite",
"version": "10.2.0",
"description": "Fast SQLite library for React Native built using Nitro Modules",
"main": "./lib/module/index",
"main": "./lib/commonjs/index",
"module": "./lib/module/index",
"types": "./lib/typescript/module/index.d.ts",
"source": "./src/index",
"react-native": "./src/index",
"react-native": "./lib/module/index",
"exports": {
".": {
"react-native": "./src/index.ts",
"import": {
"types": "./lib/typescript/module/index.d.ts",
"default": "./lib/module/index.js"
Expand All @@ -20,7 +18,6 @@
}
},
"./errors": {
"react-native": "./src/errors.ts",
"import": {
"types": "./lib/typescript/module/errors.d.ts",
"default": "./lib/module/errors.js"
Expand Down Expand Up @@ -157,13 +154,15 @@
[
"commonjs",
{
"esm": true
"esm": true,
"configFile": "./babel.config.commonjs.js"
}
],
[
"module",
{
"esm": true
"esm": true,
"configFile": "./babel.config.module.js"
}
],
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ jest.mock('react-native-nitro-modules', () => ({
},
}))

import { readFileSync } from 'node:fs'
import { join } from 'node:path'
import { NitroModules } from 'react-native-nitro-modules'
import {
NitroSQLite,
Expand Down Expand Up @@ -53,4 +55,19 @@ describe('entrypoints', () => {
.find((value) => 'init' in value)
expect(onLoad?.init).toHaveBeenCalledTimes(1)
})

it('publishes built entry points so apps never compile the decorated specs', () => {
const manifest = JSON.parse(
readFileSync(join(__dirname, '../../package.json'), 'utf8'),
) as Record<string, unknown>
const entryPoints = JSON.stringify([
manifest.main,
manifest.module,
manifest['react-native'],
manifest.source,
manifest.exports,
])

expect(entryPoints).not.toContain('src/')
})
})
Loading