Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Functions call singleton every invocation #50

Open
alexpchin opened this issue Jan 19, 2023 · 2 comments
Open

Functions call singleton every invocation #50

alexpchin opened this issue Jan 19, 2023 · 2 comments

Comments

@alexpchin
Copy link

As this package uses eval('require') does that mean that a singleton created every time the function gets executed? We're having a problem with a setup function being called lots of times in the app and we're wondering if this library may cause the problem by the way it requires files?

@george43g
Copy link
Owner

eval('require') is used instead of just 'require' because when the code is packed, webpack (vercel/ncc) will include all of the required source code in every single transpiled function, increasing cold start time.

I have not yet had a chance to investigate Firebase Function's compatibility with the new esm 'import' statements, which might defeat the purpose of the entire optimisation. I need time to investigate further on this.

@george43g
Copy link
Owner

When you say setup function, do you mean initializeApp() that's used to create Firestore etc... instances?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants