diff --git a/packages/realm/package.json b/packages/realm/package.json index 83977152e4..deb8ad2af5 100644 --- a/packages/realm/package.json +++ b/packages/realm/package.json @@ -37,8 +37,7 @@ "build:watch": "rollup -c --watch" }, "dependencies": { - "debug": "^4.3.4", - "path-browserify": "^1.0.1" + "debug": "^4.3.4" }, "peerDependencies": { "bson": "^4", @@ -61,6 +60,7 @@ "@types/path-browserify": "^1.0.0", "chai": "^4.3.6", "mocha": "^10.1.0", + "path-browserify": "^1.0.1", "react-native": "^0.71.0-rc.5", "rollup-plugin-dts": "^5.0.0", "tsm": "^2.2.2" diff --git a/packages/realm/rollup.config.mjs b/packages/realm/rollup.config.mjs index 158f7d9892..565ee3740e 100644 --- a/packages/realm/rollup.config.mjs +++ b/packages/realm/rollup.config.mjs @@ -16,6 +16,8 @@ // //////////////////////////////////////////////////////////////////////////// +import { nodeResolve } from "@rollup/plugin-node-resolve"; +import commonjs from "@rollup/plugin-commonjs"; import typescript from "@rollup/plugin-typescript"; import replace from "@rollup/plugin-replace"; import dts from "rollup-plugin-dts"; @@ -30,11 +32,13 @@ export default [ file: pkg.main, format: "cjs", sourcemap: true, + exports: "named", }, { file: pkg.module, format: "esm", sourcemap: true, + exports: "named", }, ], plugins: [ @@ -59,6 +63,11 @@ export default [ sourcemap: true, }, plugins: [ + nodeResolve({ + resolveOnly: ["path-browserify"], + }), + // We need to use `commonjs` because of "path-browserify" + commonjs(), replace({ preventAssignment: true, delimiters: ["", ""], @@ -70,7 +79,7 @@ export default [ tsconfig: "src/react-native/tsconfig.json", }), ], - external: ["bson", "debug", "react-native", "path-browserify"], + external: ["bson", "debug", "react-native"], }, { input: "src/index.ts", diff --git a/packages/realm/src/react-native/fs.ts b/packages/realm/src/react-native/fs.ts index ed7232839b..8321462b98 100644 --- a/packages/realm/src/react-native/fs.ts +++ b/packages/realm/src/react-native/fs.ts @@ -15,10 +15,11 @@ // limitations under the License. // //////////////////////////////////////////////////////////////////////////// +import { isAbsolute, join } from "path-browserify"; + import { inject } from "../platform/file-system"; import { extendDebug } from "../debug"; import { Helpers, JsPlatformHelpers } from "../binding"; -import { isAbsolute, join } from "path-browserify"; const debug = extendDebug("fs"); diff --git a/packages/realm/src/react-native/tsconfig.json b/packages/realm/src/react-native/tsconfig.json index a1915a4e16..125baece08 100644 --- a/packages/realm/src/react-native/tsconfig.json +++ b/packages/realm/src/react-native/tsconfig.json @@ -4,7 +4,8 @@ "noResolve": false, "incremental": true, "types": [ - "react-native" + "react-native", + "path-browserify" ] }, "exclude": [