Skip to content

Commit

Permalink
Including "path-browserify" in the RN bundle (#5379)
Browse files Browse the repository at this point in the history
  • Loading branch information
kraenhansen committed Mar 1, 2023
1 parent ae9401e commit d1b5816
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/realm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
Expand Down
11 changes: 10 additions & 1 deletion packages/realm/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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: [
Expand All @@ -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: ["", ""],
Expand All @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion packages/realm/src/react-native/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
3 changes: 2 additions & 1 deletion packages/realm/src/react-native/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"noResolve": false,
"incremental": true,
"types": [
"react-native"
"react-native",
"path-browserify"
]
},
"exclude": [
Expand Down

0 comments on commit d1b5816

Please sign in to comment.