Skip to content

Commit

Permalink
Adding an alias for "bson" pointing to the .cjs bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
kraenhansen committed Apr 15, 2024
1 parent 5bbec94 commit 234ccc4
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
31 changes: 31 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
],
"dependencies": {
"@react-native/eslint-config": "0.73.2",
"@rollup/plugin-alias": "^5.1.0",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^15.2.3",
Expand Down
14 changes: 14 additions & 0 deletions packages/realm-web/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@
//
////////////////////////////////////////////////////////////////////////////

import alias from "@rollup/plugin-alias";
import commonjs from "@rollup/plugin-commonjs";
import typescript from "@rollup/plugin-typescript";
import nodeResolve from "@rollup/plugin-node-resolve";
import replace from "@rollup/plugin-replace";
import dts from "rollup-plugin-dts";

import { createRequire } from "node:module";
const require = createRequire(import.meta.url);

import pkg from "./package.json" assert { type: "json" };

const replacer = replace({
Expand Down Expand Up @@ -100,6 +104,16 @@ export default [
},
],
plugins: [
// Providing an alias for the "bson" package
// See https://github.com/mongodb/js-bson/pull/669#pullrequestreview-1994786536 for more context
alias({
entries: [
{
find: "bson",
replacement: require.resolve("bson"),
},
],
}),
nodeResolve({
mainFields: ["browser", "module", "main"],
exportConditions: ["browser", "module", "main"],
Expand Down

0 comments on commit 234ccc4

Please sign in to comment.