From 0c083b9f88d9fa231488cfae10bdf7fd700f6ee7 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Tue, 10 Nov 2026 11:45:10 +0100 Subject: [PATCH] chore!: ship ESM-only package output Drop the CommonJS build target. The package now publishes one ES module build in lib/module and one set of type definitions in lib/typescript, and the export conditions point both import and require resolution at them. BREAKING CHANGE: The package no longer ships a CommonJS build. Jest setups that load react-native-nitro-sqlite/mock must add the package to transformIgnorePatterns so Jest transforms its ES modules. Co-Authored-By: Claude Opus 5.5 --- docs/content/docs/guides/node-test-mock.mdx | 15 ++++++- .../react-native-nitro-sqlite/package.json | 41 ++++--------------- 2 files changed, 22 insertions(+), 34 deletions(-) diff --git a/docs/content/docs/guides/node-test-mock.mdx b/docs/content/docs/guides/node-test-mock.mdx index cfd1140f..0591ad66 100644 --- a/docs/content/docs/guides/node-test-mock.mdx +++ b/docs/content/docs/guides/node-test-mock.mdx @@ -7,7 +7,20 @@ Import `react-native-nitro-sqlite/mock` to test SQLite connections in Node witho ## Set up Jest -Add a setup file to your existing Jest `setupFilesAfterEnv` configuration: +The package ships ES modules. Jest runs tests as CommonJS and skips transforming files in `node_modules` by default, so add `react-native-nitro-sqlite` to the packages your `transformIgnorePatterns` lets Jest transform. If your pattern already lists other packages, add it to that list: + +```js +// jest.config.js +module.exports = { + // ...your existing configuration + transformIgnorePatterns: [ + 'node_modules/(?!((jest-)?react-native|@react-native(-community)?|react-native-nitro-sqlite)/)', + ], + setupFilesAfterEnv: ['/jest.setup.ts'], +} +``` + +Then reset the mock databases in that setup file: ```ts // jest.setup.ts diff --git a/packages/react-native-nitro-sqlite/package.json b/packages/react-native-nitro-sqlite/package.json index c82104b3..b3369876 100644 --- a/packages/react-native-nitro-sqlite/package.json +++ b/packages/react-native-nitro-sqlite/package.json @@ -4,41 +4,23 @@ "description": "Fast SQLite library for React Native built using Nitro Modules", "main": "./lib/module/index", "module": "./lib/module/index", - "types": "./lib/typescript/module/index.d.ts", + "types": "./lib/typescript/index.d.ts", "source": "./src/index", "react-native": "./src/index", "exports": { ".": { "react-native": "./src/index.ts", - "import": { - "types": "./lib/typescript/module/index.d.ts", - "default": "./lib/module/index.js" - }, - "require": { - "types": "./lib/typescript/commonjs/index.d.ts", - "default": "./lib/commonjs/index.js" - } + "types": "./lib/typescript/index.d.ts", + "default": "./lib/module/index.js" }, "./errors": { "react-native": "./src/errors.ts", - "import": { - "types": "./lib/typescript/module/errors.d.ts", - "default": "./lib/module/errors.js" - }, - "require": { - "types": "./lib/typescript/commonjs/errors.d.ts", - "default": "./lib/commonjs/errors.js" - } + "types": "./lib/typescript/errors.d.ts", + "default": "./lib/module/errors.js" }, "./mock": { - "import": { - "types": "./lib/typescript/module/mock.d.ts", - "default": "./lib/module/mock.js" - }, - "require": { - "types": "./lib/typescript/commonjs/mock.d.ts", - "default": "./lib/commonjs/mock.js" - } + "types": "./lib/typescript/mock.d.ts", + "default": "./lib/module/mock.js" } }, "files": [ @@ -148,12 +130,6 @@ "source": "src", "output": "lib", "targets": [ - [ - "commonjs", - { - "esm": true - } - ], [ "module", { @@ -164,8 +140,7 @@ "typescript", { "tsc": "../../node_modules/.bin/tsc", - "project": "tsconfig.build.json", - "esm": true + "project": "tsconfig.build.json" } ] ]