Skip to content

Commit

Permalink
Follow up for Jest entry point (#6019)
Browse files Browse the repository at this point in the history
  • Loading branch information
takameyer authored Jul 31, 2023
1 parent cd9025f commit 109ae64
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 16 deletions.
17 changes: 1 addition & 16 deletions packages/realm/index.react-native.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,4 @@
/* eslint-disable @typescript-eslint/no-var-requires -- We're exporting using CJS assignment */
/* eslint-env commonjs */

// eslint-disable-next-line no-undef -- In React Native, process is not defined, but in Jest it is
const isJest = process?.env?.JEST_WORKER_ID !== undefined;

let entryPoint;

if (isJest) {
// Define a require function that will load the node bundle
// otherwise, metro will preemptively load the node bundle
const nodeRequire = require;
// Jest is running, use the node bundle
entryPoint = nodeRequire("./dist/bundle.node");
} else {
entryPoint = require("./dist/bundle.react-native");
}

module.exports = entryPoint.Realm;
module.exports = require("./dist/bundle.react-native").Realm;
1 change: 1 addition & 0 deletions packages/realm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
".": {
"types": "./types.d.cts",
"node": "./index.node.js",
"require": "./index.node.js",
"react-native": "./index.react-native.js"
},
"./scripts/submit-analytics": "./scripts/submit-analytics.mjs",
Expand Down

0 comments on commit 109ae64

Please sign in to comment.