Angular and Realm Web SDK issues


I just created a new Angular app using the CLI, added Angular Universal and PWS support. Added Realm-Web and wired it up to my Realm App / MongoDB Atlas Cluster. It seems to work and I can make queries and return data.

I noticed when I build my Angular app for Prod I get a bundle size warning. Keep in mind this app is very bare bones and I only added a few files to get connected to my Realm backend.

Warning: bundle initial exceeded maximum budget. Budget 500.00 kB was not met by 441.48 kB with a total of 941.48 kB.

This is HUGE considering my app only has a couple services and a module added.

Something else I noticed when i build…

./node_modules/realm-web/dist/ - Warning: Module not found: Error: Can't resolve 'electron' in '/Users/Jesse/Projects/GCP/BasinsList-Platform/web/node_modules/realm-web/dist'

Given the above error I must ask does the Realm Web sdk support tree shaking? Why is my web app trying to include electron? How much other bloat is getting added to my app bundles?


A couple observations since first post. The Realm-Web SDK obviously does not run on Node which is where SSR takes place. I removed Angular Universal and the electron module not found error is gone. My guess is that when the run time is Node then electron is bundled?

Using a bundle analyzer I don’t see electron included, which is desirable but my bundle sizes are still too large.

I know this posting was a while ago, but I seem to have a similar issue with

“realm-web”: “^2.0.0”

I’m trying to migrate from Stitch to Realm on a web app using Angular written in TS.

when I include it (i.e import * as Realm from ‘realm-web’; ) in an angular service, I can’t build the app any more. I get the following error.

ERROR in …/node_modules/realm-web/dist/bundle.d.ts:307:48 - error TS2304: Cannot find name ‘Omit’.

Any help would be appreciated.