How to import local js file in realm functions

I have tried to put shared util js codes in the functions folder, but it causes error when I run realm-cli push because the shared js does not export a default function by exports =.

I also tired to put shared js codes outside the functions folder, the app can be deploy but the shared js is actually not deployed so it causes module not found error when execution.

So how can I import/require shared js codes for reusing common logics in my realm functions?

Hi @mattohoh ,

I believe the best way is to turn your shared code into an npm package and upload it as a dependency to realm:

https://docs.mongodb.com/realm/functions/upload-external-dependencies/

Than look how to require it in your functions.

Thanks
Pavel