-
Notifications
You must be signed in to change notification settings - Fork 11
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
Use esbuild to bundle firebase functions rewritten in TypeScipt #539
Conversation
[diff-counting] Significant lines: 33. |
3fee853
to
5444f8f
Compare
Visit the preview URL for this PR (updated for commit ad37f77): https://cornelldti-courseplan-dev--pr539-esbuild-bundle-funct-ha8f04cr.web.app (expires Wed, 20 Oct 2021 23:03:27 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 |
5444f8f
to
39fd729
Compare
7f89c1f
to
17805d8
Compare
17805d8
to
611210d
Compare
hmm looks like i don't have permissions either. @willespencer can you review this? |
@hahnbeelee try to run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, so I was able to run npm run deploy
but when I tried invoking TrackUsers
here I got this error:
I might know what's happening. I think bumping |
@hahnbeelee I bumped the dependencies and deployed it, but still could not test. Can you help to run it? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary
This PR adds a build step to firebase functions instead of using the old approach of using JS only without any build step.
I decided to use esbuild to bundle it mostly for its speed and ease of configuration. You can also use webpack for bundling, but that requires a lot of config.
In addition, I decided to bundle instead of simply transpile since I have future plan to organize our repo into workspaces (see npm workspaces (v7 only) or yarn workspaces). Unfortunately, firebase tools do not work well with with these workspaces, so we have to bundle the code into a single, self-contained js file without any dependencies, so that firebase tools will not look into
node_modules
. The bundled code is put insidefunctions/deployment-template
with a package.json without dependencies.Test Plan
cd functions && npm run deploy
Function should be invoked fine (unfortunately I don't have access to the google cloud project)