-
Notifications
You must be signed in to change notification settings - Fork 933
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
Pass NODE_OPTIONS
when spawning firebase-functions
to enable TS support in the emulator
#6112
Comments
Passing this along to @taeold from the Cloud Function for Firebase team. My initial thought is that this is reasonable but low prioirity, as in production, Cloud Function will require compiled TS and we don't like to deviate from production behavior in the emulator |
People using TS currently need to:
This change would allow them to simplify the first part, which is the most complex of the two, so it would already be a huge win for DX. And it's a 1 line change that won't affect anything architecture-wise. It doesn't even need to be thought as a way to enable TS support. It's just an improvement in compatibility with Node.js in general. Now, thinking about production, why not use a loader too so it's possible to enable built-in support for TS in a way that won't affect a lot of the architecture and take ages to implement? Even if the performance is not great (I'm not sure about that though because I mean: make it work, then make it fast (supposing the loader is actually slower). |
Our team handles automatic transpilation during while the emulators are running by adding |
|
I understand @joehan point, but I think @gustavopch approach here is pretty elegant. IIUC, the suggested patch doesn't alter the runtime behavior of CF3 function - it only affects how the function code is loaded during deployment analysis time. It's a low cost change that no impact to most users, but a huge devx win for folks like @gustavopch who know what they are doing. @gustavopch if you have a patch already at hand feel free to share a PR with us. Otherwise, I'll get one going soon. |
Hello team, please also consider the use case of passing flags such as For example, I currently receive the following error from Node upon starting my Firebase functions, both in production and in the emulator, and I'd like to track down which NPM module (among thousands) is using the deprecated constructor mentioned:
With the attached fix, I can easily add this flag and receive the stack trace. WIthout it, I'm kinda lost! There's no easy way to grep for |
firebase-tools/src/deploy/functions/runtimes/node/index.ts
Lines 162 to 171 in f458180
By adding
NODE_OPTIONS: process.env.NODE_OPTIONS
, we'll be able to enable TS support in userland in the emulator simply by installing@esbuild-kit/esm-loader
(or anything similar) and using the following script to run:NODE_OPTIONS='--loader=@esbuild-kit/esm-loader' firebase emulators:start
Solves: #5633
The text was updated successfully, but these errors were encountered: